KParts

event.cpp
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 1999 Simon Hausmann <[email protected]>
4  SPDX-FileCopyrightText: 1999 David Faure <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "event.h"
10 #include "event_p.h"
11 
12 using namespace KParts;
13 
14 // the answer!
15 #define KPARTS_EVENT_MAGIC 42
16 
17 Event::Event(const char *eventName)
18  : Event(*new EventPrivate(eventName))
19 {
20 }
21 
22 Event::Event(EventPrivate &dd)
23  : QEvent((QEvent::Type)(QEvent::User + KPARTS_EVENT_MAGIC))
24  , d(&dd)
25 {
26 }
27 
28 Event::~Event() = default;
29 
30 const char *Event::eventName() const
31 {
32  Q_D(const Event);
33 
34  return d->m_eventName;
35 }
36 
37 bool Event::test(const QEvent *event)
38 {
39  if (!event) {
40  return false;
41  }
42 
43  return (event->type() == (QEvent::Type)(QEvent::User + KPARTS_EVENT_MAGIC));
44 }
45 
46 bool Event::test(const QEvent *event, const char *name)
47 {
48  if (!test(event)) {
49  return false;
50  }
51 
52  return (strcmp(name, ((Event *)event)->eventName()) == 0);
53 }
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
The KParts namespace,.
Q_D(Todo)
Base class for all KParts events.
Definition: event.h:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Aug 17 2022 04:19:18 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.