kexi

kexiappmodule.cpp

00001 /***************************************************************************
00002  * kexiappmodule.cpp
00003  * This file is part of the KDE project
00004  * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
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 // The as version() published versionnumber of this kross-module.
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 = 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( "version", new Kross::Api::Variant(KROSS_KEXIAPP_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 
KDE Home | KDE Accessibility Home | Description of Access Keys