diff options
Diffstat (limited to 'Swiften/EventLoop/Qt')
-rw-r--r-- | Swiften/EventLoop/Qt/QtEventLoop.h | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/Swiften/EventLoop/Qt/QtEventLoop.h b/Swiften/EventLoop/Qt/QtEventLoop.h index b42b916..8f6c709 100644 --- a/Swiften/EventLoop/Qt/QtEventLoop.h +++ b/Swiften/EventLoop/Qt/QtEventLoop.h @@ -12,34 +12,36 @@ #include "Swiften/EventLoop/EventLoop.h" -class QtEventLoop : public QObject, public Swift::EventLoop { - public: - QtEventLoop() {} - ~QtEventLoop() { - QCoreApplication::removePostedEvents(this); - } - - virtual void post(const Swift::Event& event) { - QCoreApplication::postEvent(this, new Event(event)); - } - - virtual bool event(QEvent* qevent) { - Event* event = dynamic_cast<Event*>(qevent); - if (event) { - handleEvent(event->event_); - //event->deleteLater(); FIXME: Leak? - return true; +namespace Swift { + class QtEventLoop : public QObject, public EventLoop { + public: + QtEventLoop() {} + ~QtEventLoop() { + QCoreApplication::removePostedEvents(this); } - return false; - } - - private: - struct Event : public QEvent { - Event(const Swift::Event& event) : - QEvent(QEvent::User), event_(event) { + virtual void post(const Swift::Event& event) { + QCoreApplication::postEvent(this, new Event(event)); + } + + virtual bool event(QEvent* qevent) { + Event* event = dynamic_cast<Event*>(qevent); + if (event) { + handleEvent(event->event_); + //event->deleteLater(); FIXME: Leak? + return true; } - Swift::Event event_; - }; -}; + return false; + } + + private: + struct Event : public QEvent { + Event(const Swift::Event& event) : + QEvent(QEvent::User), event_(event) { + } + + Swift::Event event_; + }; + }; +} |