blob: 2df3ad0b285e507ec77c08378a3a08944344f13b (
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 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;
}
return false;
}
private:
struct Event : public QEvent {
Event(const Swift::Event& event) :
QEvent(QEvent::User), event_(event) {
}
Swift::Event event_;
};
};
#endif
|