X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fqtuimessageprocessor.cpp;h=ac98bc8b5050fb0294fa8758de5883175527f5b0;hb=e7494078ad676d9fd14fab0396f51608a3ad46dc;hp=e7fa198354509560579631bb91111be242964325;hpb=6d55e659fa87565462d7f3e92da594fdcf9708a2;p=quassel.git diff --git a/src/qtui/qtuimessageprocessor.cpp b/src/qtui/qtuimessageprocessor.cpp index e7fa1983..ac98bc8b 100644 --- a/src/qtui/qtuimessageprocessor.cpp +++ b/src/qtui/qtuimessageprocessor.cpp @@ -40,8 +40,8 @@ QtUiMessageProcessor::QtUiMessageProcessor(QObject *parent) _highlightNick = notificationSettings.highlightNick(); highlightListChanged(notificationSettings.highlightList()); notificationSettings.notify("Highlights/NicksCaseSensitive", this, SLOT(nicksCaseSensitiveChanged(const QVariant &))); - notificationSettings.notify("highlightList", this, SLOT(highlightListChanged(const QVariant &))); - notificationSettings.notify("highlightNick", this, SLOT(highlightNickChanged(const QVariant &))); + notificationSettings.notify("Highlights/CustomList", this, SLOT(highlightListChanged(const QVariant &))); + notificationSettings.notify("Highlights/HighlightNick", this, SLOT(highlightNickChanged(const QVariant &))); _processTimer.setInterval(0); connect(&_processTimer, SIGNAL(timeout()), this, SLOT(processNextMessage())); @@ -151,13 +151,15 @@ void QtUiMessageProcessor::checkForHighlight(Message &msg) { if(!rule.isEnabled) continue; - QRegExp userRegExp; + bool match = false; if(rule.isRegExp) { - userRegExp = QRegExp(rule.name, rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive); + QRegExp rx(rule.name, rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive); + match = rx.exactMatch(msg.contents()); } else { - userRegExp = QRegExp("\\b" + QRegExp::escape(rule.name) + "\\b", rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive); + QRegExp rx("\\b" + QRegExp::escape(rule.name) + "\\b", rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive); + match = (rx.indexIn(msg.contents()) >= 0); } - if(userRegExp.exactMatch(msg.contents())) { + if(match) { msg.setFlags(msg.flags() | Message::Highlight); return; } @@ -174,13 +176,12 @@ void QtUiMessageProcessor::highlightListChanged(const QVariant &variant) { _highlightRules.clear(); QVariantList::const_iterator iter = varList.constBegin(); - QVariantList::const_iterator iterEnd = varList.constEnd(); - while(iter != iterEnd) { - QVariantMap rule; - _highlightRules << HighlightRule(rule["name"].toString(), - rule["enable"].toBool(), - rule["cs"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive, - rule["regex"].toBool()); + while(iter != varList.constEnd()) { + QVariantMap rule = iter->toMap(); + _highlightRules << HighlightRule(rule["Name"].toString(), + rule["Enable"].toBool(), + rule["CS"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive, + rule["RegEx"].toBool()); iter++; } }