lib

mainmodule.cpp
1/***************************************************************************
2 * mainmodule.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 "mainmodule.h"
21
22using namespace Kross::Api;
23
24namespace Kross { namespace Api {
25
27 class MainModulePrivate
28 {
29 public:
34 Exception::Ptr exception;
35 };
36
37}}
38
39MainModule::MainModule(const TQString& name)
40 : Module(name)
41 , d(new MainModulePrivate())
42{
43 d->exception = 0;
44}
45
47{
48 delete d;
49}
50
51const TQString MainModule::getClassName() const
52{
53 return "Kross::Api::MainModule";
54}
55
57{
58 return d->exception != 0;
59}
60
62{
63 return d->exception;
64}
65
67{
68 d->exception = exception;
69}
70
71#if 0
72bool MainModule::hasChild(const TQString& name) const
73{
74 return Callable::hasChild(name);
75}
76#endif
77
78EventSignal::Ptr MainModule::addSignal(const TQString& name, TQObject* sender, TQCString signal)
79{
80 EventSignal* event = new EventSignal(name, sender, signal);
81 if(! addChild(name, event)) {
82 krosswarning( TQString("Failed to add signal name='%1' signature='%2'").arg(name).arg(signal.data()) );
83 return 0;
84 }
85 return event;
86}
87
88EventSlot::Ptr MainModule::addSlot(const TQString& name, TQObject* receiver, TQCString slot)
89{
90 EventSlot* event = new EventSlot(name, receiver, slot);
91 if(! addChild(name, event)) {
92 krosswarning( TQString("Failed to add slot name='%1' signature='%2'").arg(name).arg(slot.data()) );
93 return 0;
94 }
95 return event;
96}
97
98QtObject::Ptr MainModule::addTQObject(TQObject* object, const TQString& name)
99{
100 QtObject* qtobject = new QtObject(object, name);
101 if(! addChild(name, qtobject)) {
102 krosswarning( TQString("Failed to add TQObject name='%1'").arg(object->name()) );
103 return 0;
104 }
105 return qtobject;
106}
107
109{
110 EventAction* event = new EventAction(name, action);
111 if(! addChild(name, event)) {
112 krosswarning( TQString("Failed to add TDEAction name='%1'").arg(action->name()) );
113 return 0;
114 }
115 return event;
116}
117
bool hasChild(const TQString &name) const
Returns if the defined child is avaible.
Definition callable.cpp:47
bool addChild(const TQString &name, Object *object)
Add a new child.
Definition callable.cpp:62
The EventAction class is used to wrap TDEAction instances into the Kross object hierachy and provide ...
Definition eventaction.h:43
TDESharedPtr< EventAction > Ptr
Shared pointer to implement reference-counting.
Definition eventaction.h:50
Each TQt signal and slot connection between a TQObject instance and a functionname is represented wit...
Definition eventsignal.h:38
TDESharedPtr< EventSignal > Ptr
Shared pointer to implement reference-counting.
Definition eventsignal.h:44
Each TQt signal and slot connection between a TQObject instance and a functionname is represented wit...
Definition eventslot.h:39
TDESharedPtr< EventSlot > Ptr
Shared pointer to implement reference-counting.
Definition eventslot.h:45
TDESharedPtr< Exception > Ptr
Shared pointer to implement reference-counting.
Definition exception.h:45
virtual const TQString getClassName() const
QtObject::Ptr addTQObject(TQObject *object, const TQString &name=TQString())
Add a TQObject to the eventcollection.
Exception::Ptr getException()
EventAction::Ptr addTDEAction(TDEAction *action, const TQString &name=TQString())
Add a TDEAction to the eventcollection.
MainModule(const TQString &name)
Constructor.
virtual ~MainModule()
Destructor.
void setException(Exception::Ptr exception)
Set the Exception this module throwed.
EventSlot::Ptr addSlot(const TQString &name, TQObject *receiver, TQCString slot)
Add a TQt slot to the Module by creating an EventSlot for it.
EventSignal::Ptr addSignal(const TQString &name, TQObject *sender, TQCString signal)
Add a TQt signal to the Module by creating an EventSignal for it.
Module(const TQString &name)
Constructor.
Definition module.h:53
Class to wrap TQObject or inherited instances.
Definition qtobject.h:46
TDESharedPtr< QtObject > Ptr
Shared pointer to implement reference-counting.
Definition qtobject.h:52
The common Kross API used as common codebase.
Definition callable.h:33
The Kross scripting bridge to embed scripting functionality into an application.
Definition callable.h:33
KOFFICE_EXPORT void krosswarning(const TQString &s)
Warning function.