kexi

kexievents.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  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 "kexievents.h"
00021 
00022 Event::Event(QObject *sender, const QCString &signal,
00023   QObject *receiver, const QCString &slot)
00024 {
00025     m_sender = sender;
00026     m_receiver = receiver;
00027     m_slot = slot;
00028     m_signal = signal;
00029 }
00030 
00031 Event::Event(QObject *sender, const QCString &signal,
00032   const QCString &functionName)
00033 {
00034     m_sender = sender;
00035     m_signal = signal;
00036     m_slot = functionName;
00037 }
00038 
00039 void
00040 EventList::addEvent(Event *event)
00041 {
00042     if(event)
00043         append(event);
00044 }
00045 
00046 void
00047 EventList::addEvent(QObject *sender, const QCString &signal, QObject *receiver, const QCString &slot)
00048 {
00049     Event *ev = new Event(sender, signal, receiver, slot);
00050     append(ev);
00051 }
00052 
00053 void
00054 EventList::addEvent(QObject *sender, const QCString &signal, const QCString &function)
00055 {
00056     Event *ev = new Event(sender, signal, function);
00057     append(ev);
00058 }
00059 
00060 void
00061 EventList::removeEvent(Event *event)
00062 {
00063     if(!event)  return;
00064     remove(event);
00065     delete event;
00066 }
00067 
00068 EventList*
00069 EventList::allEventsForObject(QObject *widget)
00070 {
00071     if(!widget)  return 0;
00072 
00073     EventList *l = new EventList();
00074     EventList::ConstIterator endIt = constEnd();
00075     for(EventList::ConstIterator it = constBegin(); it != endIt; ++it) {
00076         if( ((*it)->sender() == widget) || ( (*it)->receiver() == widget) )
00077             l->addEvent(*it);
00078     }
00079 
00080     return l;
00081 }
00082 
00083 void
00084 EventList::removeAllEventsForObject(QObject *widget)
00085 {
00086     EventList::ConstIterator endIt = constEnd();
00087     for(EventList::ConstIterator it = constBegin(); it != endIt; ++it) {
00088         if( ((*it)->sender() == widget) || ( (*it)->receiver() == widget) )
00089             removeEvent(*it);
00090     }
00091 }
00092 
KDE Home | KDE Accessibility Home | Description of Access Keys