#ifndef EVENTMANAGER_H
#define EVENTMANAGER_H
-#include <QHash>
-#include <QObject>
+#include <QMetaEnum>
class Event;
class EventManager : public QObject {
Q_OBJECT
+ Q_FLAGS(EventFlag EventFlags)
Q_ENUMS(EventType)
public:
HighestPriority
};
+ enum EventFlag {
+ Backlog = 0x40,
+ Stopped = 0x80
+ };
+ Q_DECLARE_FLAGS(EventFlags, EventFlag)
+
/*
*/
IrcServerEvent = 0x00020000,
IrcServerIncoming,
+ IrcServerParseError,
IrcEvent = 0x00030000,
IrcEventCap,
IrcEventPrivmsg,
IrcEventQuit,
IrcEventTopic,
+ IrcEventRawPrivmsg, ///< Undecoded privmsg (still needs CTCP parsing)
+ IrcEventRawNotice, ///< Undecoded notice (still needs CTCP parsing)
+ IrcEventUnknown, ///< Unknown non-numeric cmd
IrcEventNumeric = 0x00031000, /* needs 1000 (0x03e8) consecutive free values! */
+
+ MessageEvent = 0x00040000, ///< Stringified event suitable for converting to Message
};
EventManager(QObject *parent = 0);
- //virtual ~EventManager();
+ virtual ~EventManager();
- QStringList providesEnums();
+ EventType eventTypeByName(const QString &name) const;
+ EventType eventGroupByName(const QString &name) const;
+ QString enumName(EventType type) const;
public slots:
void registerObject(QObject *object, Priority priority = NormalPriority, const QString &methodPrefix = "handle");
*/
void sendEvent(Event *event);
+protected:
+ virtual void customEvent(QEvent *event);
+
private:
struct Handler {
QObject *object;
//! Add handlers to an existing sorted (by priority) handler list
void insertHandlers(const QList<Handler> &newHandlers, QList<Handler> &existing);
+ void processEvents();
void dispatchEvent(Event *event);
+ //! @return the EventType enum
+ QMetaEnum eventEnum() const;
+
HandlerHash _registeredHandlers;
+ mutable QMetaEnum _enum;
+ QList<Event *> _eventQueue;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(EventManager::EventFlags);
+
#endif