kexi
kexiappmodule.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kexiappmodule.h"
00021 #include "kexiappmainwindow.h"
00022
00023 #include "core/keximainwindow.h"
00024
00025 #include <api/object.h>
00026 #include <api/qtobject.h>
00027 #include <main/manager.h>
00028
00029 #include <kdebug.h>
00030
00031
00032 #define KROSS_KEXIAPP_VERSION 1
00033
00034 extern "C"
00035 {
00040 Kross::Api::Object* KDE_EXPORT init_module(Kross::Api::Manager* manager)
00041 {
00042 return new Kross::KexiApp::KexiAppModule(manager);
00043 }
00044 }
00045
00046 namespace Kross { namespace KexiApp {
00047
00049 class KexiAppModulePrivate
00050 {
00051 public:
00052 Kross::Api::Manager* manager;
00053 };
00054
00055 }}
00056
00057 using namespace Kross::KexiApp;
00058
00059 KexiAppModule::KexiAppModule(Kross::Api::Manager* manager)
00060 : Kross::Api::Module("KexiApp")
00061 , d(new KexiAppModulePrivate())
00062 {
00063 kdDebug() << "Kross::KexiApp::KexiAppModule Ctor" << endl;
00064
00065 d->manager = manager;
00066
00067 Kross::Api::Object::Ptr mainwinobject = dynamic_cast< Kross::Api::Object* >(manager)->getChild("KexiMainWindow");
00068 if(mainwinobject) {
00069 Kross::Api::QtObject* mainwinqtobject = dynamic_cast< Kross::Api::QtObject* >( mainwinobject.data() );
00070 if(mainwinqtobject) {
00071 ::KexiMainWindow* mainwin = dynamic_cast< ::KexiMainWindow* >( mainwinqtobject->getObject() );
00072 if(mainwin) {
00073 addChild( new Kross::Api::Variant(KROSS_KEXIAPP_VERSION), "version" );
00074 addChild( new KexiAppMainWindow(mainwin) );
00075 return;
00076 }
00077 else kdDebug()<<"Kross::KexiApp::KexiAppModule: Failed to determinate KexiMainWindow instance"<<endl;
00078 }
00079 else kdDebug()<<"Kross::KexiApp::KexiAppModule: Failed to cast 'KexiMainWindow' to a QtObject"<<endl;
00080 }
00081 else kdDebug()<<"Kross::KexiApp::KexiAppModule: No such object 'KexiMainWindow'"<<endl;
00082
00083 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("There was no 'KexiMainWindow' published.") );
00084 }
00085
00086 KexiAppModule::~KexiAppModule()
00087 {
00088 kdDebug() << "Kross::KexiApp::KexiAppModule Dtor" << endl;
00089 delete d;
00090 }
00091
00092
00093 const QString KexiAppModule::getClassName() const
00094 {
00095 return "Kross::KexiApp::KexiAppModule";
00096 }
00097
|