fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / kparts / event.cpp
blob185305ef80163d0fdf3b55aa035614a42d8fedd9
1 /* This file is part of the KDE project
2 Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3 (C) 1999 David Faure <faure@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library 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.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
20 #include <kparts/event.h>
22 using namespace KParts;
24 //the answer!
25 #define KPARTS_EVENT_MAGIC 42
27 class KParts::EventPrivate
29 public:
30 EventPrivate( const char *eventName ) :
31 m_eventName(eventName)
34 const char* m_eventName;
37 Event::Event( const char *eventName )
38 : QEvent( (QEvent::Type)(QEvent::User + KPARTS_EVENT_MAGIC) )
39 , d( new EventPrivate(eventName) )
43 Event::~Event()
45 delete d;
48 const char *Event::eventName() const
50 return d->m_eventName;
53 bool Event::test( const QEvent *event )
55 if ( !event )
56 return false;
58 return ( event->type() == (QEvent::Type)(QEvent::User + KPARTS_EVENT_MAGIC ) );
61 bool Event::test( const QEvent *event, const char *name )
63 if ( !test( event ) )
64 return false;
66 return ( strcmp( name, ((Event*)event)->eventName() ) == 0 );
70 /////// GUIActivateEvent ////////
72 class KParts::GUIActivateEventPrivate
74 public:
75 GUIActivateEventPrivate( bool activated )
76 : m_bActivated( activated )
79 static const char *s_strGUIActivateEvent;
80 bool m_bActivated;
83 const char *GUIActivateEventPrivate::s_strGUIActivateEvent = "KParts/GUIActivate";
85 GUIActivateEvent::GUIActivateEvent( bool activated ) :
86 Event( GUIActivateEventPrivate::s_strGUIActivateEvent ),
87 d( new GUIActivateEventPrivate(activated) )
91 GUIActivateEvent::~GUIActivateEvent()
93 delete d;
96 bool GUIActivateEvent::activated() const
98 return d->m_bActivated;
101 bool GUIActivateEvent::test( const QEvent *event )
103 return Event::test( event, GUIActivateEventPrivate::s_strGUIActivateEvent );
107 /////// PartActivateEvent ////////
109 class KParts::PartActivateEventPrivate
111 public:
112 PartActivateEventPrivate( bool activated,
113 Part *part,
114 QWidget *widget ) :
115 m_bActivated( activated ),
116 m_part( part ),
117 m_widget( widget )
120 static const char *s_strPartActivateEvent;
121 bool m_bActivated;
122 Part *m_part;
123 QWidget *m_widget;
126 const char *PartActivateEventPrivate::s_strPartActivateEvent = "KParts/PartActivateEvent";
128 PartActivateEvent::PartActivateEvent( bool activated,
129 Part *part,
130 QWidget *widget ) :
131 Event( PartActivateEventPrivate::s_strPartActivateEvent ),
132 d( new PartActivateEventPrivate(activated,part,widget) )
136 PartActivateEvent::~PartActivateEvent()
138 delete d;
141 bool PartActivateEvent::activated() const
143 return d->m_bActivated;
146 Part *PartActivateEvent::part() const
148 return d->m_part;
151 QWidget *PartActivateEvent::widget() const
153 return d->m_widget;
156 bool PartActivateEvent::test( const QEvent *event )
158 return Event::test( event, PartActivateEventPrivate::s_strPartActivateEvent );
162 /////// PartSelectEvent ////////
164 class KParts::PartSelectEventPrivate
166 public:
167 PartSelectEventPrivate( bool selected,
168 Part *part,
169 QWidget *widget ) :
170 m_bSelected( selected ),
171 m_part( part ),
172 m_widget( widget )
175 static const char *s_strPartSelectEvent;
176 bool m_bSelected;
177 Part *m_part;
178 QWidget *m_widget;
181 const char *PartSelectEventPrivate::s_strPartSelectEvent =
182 "KParts/PartSelectEvent";
184 PartSelectEvent::PartSelectEvent( bool selected,
185 Part *part,
186 QWidget *widget ) :
187 Event( PartSelectEventPrivate::s_strPartSelectEvent ),
188 d( new PartSelectEventPrivate(selected,part,widget) )
192 PartSelectEvent::~PartSelectEvent()
194 delete d;
197 bool PartSelectEvent::selected() const
199 return d->m_bSelected;
202 Part *PartSelectEvent::part() const
204 return d->m_part;
207 QWidget *PartSelectEvent::widget() const
209 return d->m_widget;
212 bool PartSelectEvent::test( const QEvent *event )
214 return Event::test( event, PartSelectEventPrivate::s_strPartSelectEvent );