summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Dominic K <mdk@codethink.co.uk>2010-11-22 09:03:00 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-11-22 09:03:00 (GMT)
commitbafdb949583a3178449f68afe2e2621687e29de7 (patch)
tree3874042a6e14abf4f4f82bde747d0bcfe93e49e5
parentea440d1897c7c9d69401ac293663fbc4f2866d08 (diff)
downloadQt-bafdb949583a3178449f68afe2e2621687e29de7.zip
Qt-bafdb949583a3178449f68afe2e2621687e29de7.tar.gz
Qt-bafdb949583a3178449f68afe2e2621687e29de7.tar.bz2
Dynamically register the event number.
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp12
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoswitchevent.h12
2 files changed, 18 insertions, 6 deletions
diff --git a/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp b/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp
index b136ce8..22ea0fe 100644
--- a/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp
@@ -41,7 +41,9 @@
#include "qmeegoswitchevent.h"
-QMeeGoSwitchEvent::QMeeGoSwitchEvent(const QString &graphicsSystemName, QMeeGoSwitchEvent::State s) : QEvent((QEvent::Type) QMeeGoSwitchEvent::SwitchEvent)
+static int switchEventNumber = -1;
+
+QMeeGoSwitchEvent::QMeeGoSwitchEvent(const QString &graphicsSystemName, QMeeGoSwitchEvent::State s) : QEvent(QMeeGoSwitchEvent::eventNumber())
{
name = graphicsSystemName;
switchState = s;
@@ -55,4 +57,12 @@ QString QMeeGoSwitchEvent::graphicsSystemName() const
QMeeGoSwitchEvent::State QMeeGoSwitchEvent::state() const
{
return switchState;
+}
+
+QEvent::Type QMeeGoSwitchEvent::eventNumber()
+{
+ if (switchEventNumber < 0)
+ switchEventNumber = QEvent::registerEventType();
+
+ return (QEvent::Type) switchEventNumber;
} \ No newline at end of file
diff --git a/tools/qmeegographicssystemhelper/qmeegoswitchevent.h b/tools/qmeegographicssystemhelper/qmeegoswitchevent.h
index 2d8371e..0ddbd3d 100644
--- a/tools/qmeegographicssystemhelper/qmeegoswitchevent.h
+++ b/tools/qmeegographicssystemhelper/qmeegoswitchevent.h
@@ -62,11 +62,6 @@ public:
DidSwitch
};
- //! The event type id to use to detect this event.
- enum Type {
- SwitchEvent = QEvent::User + 1024
- };
-
//! Constructor for the event.
/*!
Creates a new event with the given name and the given state.
@@ -83,6 +78,13 @@ public:
//! Returns the state represented by this event.
State state() const;
+ //! Returns the event type/number for QMeeGoSwitchEvent.
+ /*!
+ The type is registered on first access. Use this to detect incoming
+ QMeeGoSwitchEvents.
+ */
+ QEvent::Type eventNumber();
+
private:
QString name;
State switchState;