kexi

kexievents.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. 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 "kexievents.h"
21
22Event::Event(TQObject *sender, const TQCString &signal,
23 TQObject *receiver, const TQCString &slot)
24{
25 m_sender = sender;
26 m_receiver = receiver;
27 m_slot = slot;
28 m_signal = signal;
29}
30
31Event::Event(TQObject *sender, const TQCString &signal,
32 const TQCString &functionName)
33{
34 m_sender = sender;
35 m_signal = signal;
36 m_slot = functionName;
37}
38
39void
40EventList::addEvent(Event *event)
41{
42 if(event)
43 append(event);
44}
45
46void
47EventList::addEvent(TQObject *sender, const TQCString &signal, TQObject *receiver, const TQCString &slot)
48{
49 Event *ev = new Event(sender, signal, receiver, slot);
50 append(ev);
51}
52
53void
54EventList::addEvent(TQObject *sender, const TQCString &signal, const TQCString &function)
55{
56 Event *ev = new Event(sender, signal, function);
57 append(ev);
58}
59
60void
61EventList::removeEvent(Event *event)
62{
63 if(!event) return;
64 remove(event);
65 delete event;
66}
67
68EventList*
69EventList::allEventsForObject(TQObject *widget)
70{
71 if(!widget) return 0;
72
73 EventList *l = new EventList();
74 EventList::ConstIterator endIt = constEnd();
75 for(EventList::ConstIterator it = constBegin(); it != endIt; ++it) {
76 if( ((*it)->sender() == widget) || ( (*it)->receiver() == widget) )
77 l->addEvent(*it);
78 }
79
80 return l;
81}
82
83void
84EventList::removeAllEventsForObject(TQObject *widget)
85{
86 EventList::ConstIterator endIt = constEnd();
87 for(EventList::ConstIterator it = constBegin(); it != endIt; ++it) {
88 if( ((*it)->sender() == widget) || ( (*it)->receiver() == widget) )
89 removeEvent(*it);
90 }
91}
92
A simple class to store events.
Definition kexievents.h:39