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
;
25 #define KPARTS_EVENT_MAGIC 42
27 class KParts::EventPrivate
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
) )
48 const char *Event::eventName() const
50 return d
->m_eventName
;
53 bool Event::test( const QEvent
*event
)
58 return ( event
->type() == (QEvent::Type
)(QEvent::User
+ KPARTS_EVENT_MAGIC
) );
61 bool Event::test( const QEvent
*event
, const char *name
)
66 return ( strcmp( name
, ((Event
*)event
)->eventName() ) == 0 );
70 /////// GUIActivateEvent ////////
72 class KParts::GUIActivateEventPrivate
75 GUIActivateEventPrivate( bool activated
)
76 : m_bActivated( activated
)
79 static const char *s_strGUIActivateEvent
;
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()
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
112 PartActivateEventPrivate( bool activated
,
115 m_bActivated( activated
),
120 static const char *s_strPartActivateEvent
;
126 const char *PartActivateEventPrivate::s_strPartActivateEvent
= "KParts/PartActivateEvent";
128 PartActivateEvent::PartActivateEvent( bool activated
,
131 Event( PartActivateEventPrivate::s_strPartActivateEvent
),
132 d( new PartActivateEventPrivate(activated
,part
,widget
) )
136 PartActivateEvent::~PartActivateEvent()
141 bool PartActivateEvent::activated() const
143 return d
->m_bActivated
;
146 Part
*PartActivateEvent::part() const
151 QWidget
*PartActivateEvent::widget() const
156 bool PartActivateEvent::test( const QEvent
*event
)
158 return Event::test( event
, PartActivateEventPrivate::s_strPartActivateEvent
);
162 /////// PartSelectEvent ////////
164 class KParts::PartSelectEventPrivate
167 PartSelectEventPrivate( bool selected
,
170 m_bSelected( selected
),
175 static const char *s_strPartSelectEvent
;
181 const char *PartSelectEventPrivate::s_strPartSelectEvent
=
182 "KParts/PartSelectEvent";
184 PartSelectEvent::PartSelectEvent( bool selected
,
187 Event( PartSelectEventPrivate::s_strPartSelectEvent
),
188 d( new PartSelectEventPrivate(selected
,part
,widget
) )
192 PartSelectEvent::~PartSelectEvent()
197 bool PartSelectEvent::selected() const
199 return d
->m_bSelected
;
202 Part
*PartSelectEvent::part() const
207 QWidget
*PartSelectEvent::widget() const
212 bool PartSelectEvent::test( const QEvent
*event
)
214 return Event::test( event
, PartSelectEventPrivate::s_strPartSelectEvent
);