-void EventManager::registerObject(QObject *object, Priority priority, const QString &methodPrefix) {
- for(int i = object->metaObject()->methodOffset(); i < object->metaObject()->methodCount(); i++) {
- QString methodSignature(object->metaObject()->method(i).signature());
-
- if(!methodSignature.startsWith(methodPrefix))
- continue;
+int EventManager::findEventType(const QString &methodSignature_, const QString &methodPrefix) const {
+ if(!methodSignature_.startsWith(methodPrefix))
+ return -1;
+
+ QString methodSignature = methodSignature_;
+
+ methodSignature = methodSignature.section('(',0,0); // chop the attribute list
+ methodSignature = methodSignature.mid(methodPrefix.length()); // strip prefix
+
+ int eventType = -1;
+
+ // special handling for numeric IrcEvents: IrcEvent042 gets mapped to IrcEventNumeric + 42
+ if(methodSignature.length() == 8+3 && methodSignature.startsWith("IrcEvent")) {
+ int num = methodSignature.right(3).toUInt();
+ if(num > 0) {
+ QString numericSig = methodSignature.left(methodSignature.length() - 3) + "Numeric";
+ eventType = eventEnum().keyToValue(numericSig.toAscii());
+ if(eventType < 0) {
+ qWarning() << Q_FUNC_INFO << "Could not find EventType" << numericSig << "for handling" << methodSignature;
+ return -1;
+ }
+ eventType += num;
+ }
+ }