- // now dispatch the event
- QList<Handler>::const_iterator it = handlers.begin();
- while(it != handlers.end()) {
+void EventManager::dispatchEvent(Event *event)
+{
+ //qDebug() << "Dispatching" << event;
+
+ // we try handlers from specialized to generic by masking the enum
+
+ // build a list sorted by priorities that contains all eligible handlers
+ QList<Handler> handlers;
+ QHash<QObject *, Handler> filters;
+ QSet<QObject *> ignored;
+ uint type = event->type();
+
+ bool checkDupes = false;
+
+ // special handling for numeric IrcEvents
+ if ((type & ~IrcEventNumericMask) == IrcEventNumeric) {
+ ::IrcEventNumeric *numEvent = static_cast< ::IrcEventNumeric *>(event);
+ if (!numEvent)
+ qWarning() << "Invalid event type for IrcEventNumeric!";
+ else {
+ int num = numEvent->number();
+ if (num > 0) {
+ insertHandlers(registeredHandlers().value(type + num), handlers, false);
+ insertFilters(registeredFilters().value(type + num), filters);
+ checkDupes = true;
+ }
+ }
+ }