Example #1
0
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;
    }
  }

  if(eventType < 0)
    eventType = eventEnum().keyToValue(methodSignature.toAscii());
  if(eventType < 0) {
    qWarning() << Q_FUNC_INFO << "Could not find EventType" << methodSignature;
    return -1;
  }
  return eventType;
}
Example #2
0
EventManager::EventType EventManager::eventTypeByName(const QString &name) const {
  int val = eventEnum().keyToValue(name.toLatin1());
  return (val == -1) ? Invalid : static_cast<EventType>(val);
}
Example #3
0
QString EventManager::enumName(EventType type) const {
  return eventEnum().valueToKey(type);
}
Example #4
0
QString EventManager::enumName(int type)
{
    return eventEnum().valueToKey(type);
}