blob: 678ea04f322c716d90a3ff69073df7ff55a18a22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#ifndef SWIFT_QtMainEventLoop_H
#define SWIFT_QtMainEventLoop_H
#include <QObject>
#include <QEvent>
#include <QCoreApplication>
#include "Swiften/EventLoop/EventLoop.h"
class QtMainEventLoop : public QObject, public Swift::EventLoop
{
public:
QtMainEventLoop() {}
virtual void post(const 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;
}
return false;
}
private:
struct Event : public QEvent {
Event(const EventLoop::Event& event) :
QEvent(QEvent::User), event_(event) {
}
EventLoop::Event event_;
};
};
#endif
|