lib

eventsignal.cpp

00001 /***************************************************************************
00002  * eventsignal.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 "eventsignal.h"
00021 
00022 #include "variant.h"
00023 #include "qtobject.h"
00024 
00025 #include <qmetaobject.h>
00026 #include <private/qucom_p.h> // for the Qt QUObject API.
00027 
00028 using namespace Kross::Api;
00029 
00030 EventSignal::EventSignal(const QString& name, Object::Ptr parent, QObject* sender, QCString signal)
00031     : Event<EventSignal>(name, parent)
00032     , m_sender(sender)
00033     , m_signal(signal) //QObject::normalizeSignalSlot(signal)
00034 {
00035 }
00036 
00037 EventSignal::~EventSignal()
00038 {
00039 }
00040 
00041 const QString EventSignal::getClassName() const
00042 {
00043     return "Kross::Api::EventSignal";
00044 }
00045 
00046 Object::Ptr EventSignal::call(const QString& /*name*/, KSharedPtr<List> arguments)
00047 {
00048 #ifdef KROSS_API_EVENTSIGNAL_CALL_DEBUG
00049     kdDebug() << QString("EventSignal::call() name=%1 m_signal=%2 arguments=%3").arg(name).arg(m_signal).arg(arguments->toString()) << endl;
00050 #endif
00051 
00052     QString n = m_signal;
00053 
00054     if(n.startsWith("2")) // Remove prefix of SIGNAL-macros
00055         n.remove(0,1);
00056 
00057     int signalid = m_sender->metaObject()->findSignal(n.latin1(), false);
00058     if(signalid < 0)
00059         throw new Exception(QString("No such signal '%1'.").arg(n));
00060 
00061     QUObject* uo = QtObject::toQUObject(n, arguments);
00062     m_sender->qt_emit(signalid, uo); // emit the signal
00063     delete [] uo;
00064 
00065     return new Variant(true, "Kross::Api::EventSignal::Bool");
00066 }
KDE Home | KDE Accessibility Home | Description of Access Keys