From 60aebc188674bbfb67be51958ec33171c72986b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Wed, 16 Nov 2011 17:06:34 +0200 Subject: [PATCH] * The iEventQueue interface is now properly registered. * The iApp interface implementation now registers events and listens for EV_QUIT and EV_RESTART events. Broadcasting EV_READY and EV_TERMINATING events still needs to be implemented. This is also valid for iApp::ready() and iApp::terminating() signals. --- src/libs/Common/app.cpp | 29 ++++++++++++++++++++++++++++- src/libs/Common/app.h | 10 ++++++++++ src/libs/Common/eventqueue.cpp | 1 + src/libs/Common/version.h | 4 ++-- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/libs/Common/app.cpp b/src/libs/Common/app.cpp index 53efce9..21818f9 100644 --- a/src/libs/Common/app.cpp +++ b/src/libs/Common/app.cpp @@ -19,7 +19,9 @@ #include "app.h" #include "globals.h" -#include "registry.h" +#include "iregistry.h" +#include "ieventqueue.h" +#include "event.h" #include "version.h" #include @@ -49,6 +51,10 @@ App::App() : iApp() , mReady(false) , mName(VER_PRODUCT_NAME_STR) + , mEvQuit(0) + , mEvRestart(0) + , mEvReady(0) + , mEvTerminating(0) { setObjectName(QString("%1.iApp").arg(VER_MODULE_NAME_STR)); @@ -63,6 +69,12 @@ bool App::init() // Register our interface iRegistry::instance()->registerInterface("iApp", this); + // Register events + mEvQuit = iEventQueue::instance()->subscribeEvent(iEventQueue::instance()->registerEvent(EV_QUIT), this); + mEvRestart = iEventQueue::instance()->subscribeEvent(iEventQueue::instance()->registerEvent(EV_RESTART), this); + mEvReady = iEventQueue::instance()->registerEvent(EV_READY); + mEvTerminating = iEventQueue::instance()->registerEvent(EV_TERMINATING); + // Set the default application name and language mName = VER_PRODUCT_NAME_STR; mLanguage = QLocale::system().name(); @@ -176,6 +188,21 @@ bool App::init() return true; } +bool App::event(QEvent * e) +{ + if (e->type() == Event::eVafEvent) { + Event * event = static_cast(e); + if (event->id() == mEvQuit) + quit(); + else if (event->id() == mEvRestart) + restart(); + + return false; + } + else + return iApp::event(e); +} + QString const App::dataRootDir() const { if (mDataRootDir.isEmpty()) { diff --git a/src/libs/Common/app.h b/src/libs/Common/app.h index 3bcde5a..8fb0dca 100644 --- a/src/libs/Common/app.h +++ b/src/libs/Common/app.h @@ -25,6 +25,8 @@ #include #include +class QEvent; + namespace eVaf { namespace Common { namespace Internal { @@ -48,6 +50,8 @@ public: */ bool init(); + virtual bool event(QEvent *); + /* iApp interface */ @@ -113,6 +117,12 @@ private: /// Name of the documentation directory mutable QString mDocDir; + /// Event numbers + uint mEvQuit; + uint mEvRestart; + uint mEvReady; + uint mEvTerminating; + }; } // namespace eVaf::Common::Internal diff --git a/src/libs/Common/eventqueue.cpp b/src/libs/Common/eventqueue.cpp index 33e73c0..795224c 100644 --- a/src/libs/Common/eventqueue.cpp +++ b/src/libs/Common/eventqueue.cpp @@ -45,6 +45,7 @@ EventQueue::EventQueue() : iEventQueue() , mNextEventId(1) { + iRegistry::instance()->registerInterface("iEventQueue", this); } EventQueue::~EventQueue() diff --git a/src/libs/Common/version.h b/src/libs/Common/version.h index b99636f..5feecd6 100644 --- a/src/libs/Common/version.h +++ b/src/libs/Common/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,2,5 +#define VER_FILE_VERSION 0,1,3,6 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.2.5\0" +#define VER_FILE_VERSION_STR "0.1.3.6\0" /** * Module/library name (shall end with \0) -- 2.47.0