kexi

kexiappmodule.cpp
1/***************************************************************************
2 * kexiappmodule.cpp
3 * This file is part of the KDE project
4 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 ***************************************************************************/
19
20#include "kexiappmodule.h"
21#include "kexiappmainwindow.h"
22
23#include "core/keximainwindow.h"
24
25#include <api/object.h>
26#include <api/qtobject.h>
27#include <main/manager.h>
28
29#include <kdebug.h>
30
31// The as version() published versionnumber of this kross-module.
32#define KROSS_KEXIAPP_VERSION 1
33
34extern "C"
35{
40 Kross::Api::Object* TDE_EXPORT init_module(Kross::Api::Manager* manager)
41 {
42 return new Kross::KexiApp::KexiAppModule(manager);
43 }
44}
45
46namespace Kross { namespace KexiApp {
47
49 class KexiAppModulePrivate
50 {
51 public:
52 Kross::Api::Manager* manager;
53 };
54
55}}
56
57using namespace Kross::KexiApp;
58
59KexiAppModule::KexiAppModule(Kross::Api::Manager* manager)
60 : Kross::Api::Module("KexiApp")
61 , d(new KexiAppModulePrivate())
62{
63 kdDebug() << "Kross::KexiApp::KexiAppModule Ctor" << endl;
64
65 d->manager = manager;
66
67 Kross::Api::Object::Ptr mainwinobject = manager->getChild("KexiMainWindow");
68 if(mainwinobject) {
69 Kross::Api::QtObject* mainwinqtobject = dynamic_cast< Kross::Api::QtObject* >( mainwinobject.data() );
70 if(mainwinqtobject) {
71 ::KexiMainWindow* mainwin = dynamic_cast< ::KexiMainWindow* >( mainwinqtobject->getObject() );
72 if(mainwin) {
73 addChild( "version", new Kross::Api::Variant(KROSS_KEXIAPP_VERSION) );
74 addChild( new KexiAppMainWindow(mainwin) );
75 return;
76 }
77 else kdDebug()<<"Kross::KexiApp::KexiAppModule: Failed to determinate KexiMainWindow instance"<<endl;
78 }
79 else kdDebug()<<"Kross::KexiApp::KexiAppModule: Failed to cast 'KexiMainWindow' to a QtObject"<<endl;
80 }
81 else kdDebug()<<"Kross::KexiApp::KexiAppModule: No such object 'KexiMainWindow'"<<endl;
82
83 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("There was no 'KexiMainWindow' published.") );
84}
85
87{
88 kdDebug() << "Kross::KexiApp::KexiAppModule Dtor" << endl;
89 delete d;
90}
91
92
93const TQString KexiAppModule::getClassName() const
94{
95 return "Kross::KexiApp::KexiAppModule";
96}
97
Kexi's main window interface This interface is implemented by KexiMainWindowImpl class.
Class to handle Kexi's mainwindow instance.
The Kexi-application module which provides us the main entrypoint to communicate with a running Kexi-...
KexiAppModule(Kross::Api::Manager *manager)
Constructor.
virtual const TQString getClassName() const
virtual ~KexiAppModule()
Destructor.
Wrapper around the Kexi-application to access runtime information a running Kexi-application likes to...