lib

eventsignal.cpp
1/***************************************************************************
2 * eventsignal.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 "eventsignal.h"
21
22#include "variant.h"
23#include "qtobject.h"
24
25#include <tqmetaobject.h>
26#include <tqucom_p.h> // for the TQt TQUObject API.
27
28using namespace Kross::Api;
29
30EventSignal::EventSignal(const TQString& name, TQObject* sender, TQCString signal)
31 : Event<EventSignal>(name)
32 , m_sender(sender)
33 , m_signal(signal) //TQObject::normalizeSignalSlot(signal)
34{
35}
36
40
41const TQString EventSignal::getClassName() const
42{
43 return "Kross::Api::EventSignal";
44}
45
46Object::Ptr EventSignal::call(const TQString& /*name*/, TDESharedPtr<List> arguments)
47{
48#ifdef KROSS_API_EVENTSIGNAL_CALL_DEBUG
49 krossdebug( TQString("EventSignal::call() m_signal=%1 arguments=%2").arg(m_signal).arg(arguments->toString()) );
50#endif
51
52 TQString n = m_signal;
53
54 if(n.startsWith("2")) // Remove prefix of TQ_SIGNAL-macros
55 n.remove(0,1);
56
57 int signalid = m_sender->metaObject()->findSignal(n.latin1(), false);
58 if(signalid < 0)
59 throw new Exception(TQString("No such signal '%1'.").arg(n));
60
61 TQUObject* uo = QtObject::toTQUObject(n, arguments);
62 m_sender->tqt_emit(signalid, uo); // emit the signal
63 delete [] uo;
64
65 return new Variant( TQVariant(true) );
66}
virtual ~EventSignal()
Destructor.
EventSignal(const TQString &name, TQObject *sender, TQCString signal)
Constructor.
virtual const TQString getClassName() const
Return the class name.
virtual Object::Ptr call(const TQString &name, TDESharedPtr< List > arguments)
Pass a call to the object and evaluated it recursive down the object-hierachy.
Event(const TQString &name)
Definition event.h:68
Common exception class used for representing exceptions in Kross.
Definition exception.h:39
TDESharedPtr< Object > Ptr
Shared pointer to implement reference-counting.
Definition object.h:56
static TQUObject * toTQUObject(const TQString &signature, List::Ptr arguments)
Build a TQt TQUObject struct out of the TQt signal or slot signature and the passed List arguments.
Definition qtobject.cpp:91
Variant value to wrap a TQVariant into a Kross::Api::Value to enable primitive types like strings or ...
Definition variant.h:39
The common Kross API used as common codebase.
Definition callable.h:33
KOFFICE_EXPORT void krossdebug(const TQString &s)
Debugging function.