X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fqtuimessageprocessor.cpp;h=1c1a82c574674c41f695fd7c56e082e0bf33e6b7;hb=e531fd1f1ea36a360a9d876c94e73b0f3b1bcd22;hp=e7fa198354509560579631bb91111be242964325;hpb=6d55e659fa87565462d7f3e92da594fdcf9708a2;p=quassel.git diff --git a/src/qtui/qtuimessageprocessor.cpp b/src/qtui/qtuimessageprocessor.cpp index e7fa1983..1c1a82c5 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())); @@ -138,7 +138,7 @@ void QtUiMessageProcessor::checkForHighlight(Message &msg) { nickList = myIdentity->nicks(); } foreach(QString nickname, nickList) { - QRegExp nickRegExp("\\b" + QRegExp::escape(nickname) + "\\b", + QRegExp nickRegExp("\\b" + QRegExp::escape(nickname) + "(\\W|\\b|$)", // + "\\b", this does not seem to work for trailing ` -> upstream bug? _nicksCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); if(nickRegExp.indexIn(msg.contents()) >= 0) { msg.setFlags(msg.flags() | Message::Highlight); @@ -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++; } }