X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fqtuimessageprocessor.cpp;h=aa24f08cbaafb2217a0763b3a7cce7be906706ad;hp=353928aeaa755696d72e19be3e50c2b88f3a4acf;hb=7a413a4808e9357e7d2c69840efe913b4c4ab0a3;hpb=020c860035180e468705b836a21f7aaa70ba0160 diff --git a/src/qtui/qtuimessageprocessor.cpp b/src/qtui/qtuimessageprocessor.cpp index 353928ae..aa24f08c 100644 --- a/src/qtui/qtuimessageprocessor.cpp +++ b/src/qtui/qtuimessageprocessor.cpp @@ -119,8 +119,7 @@ void QtUiMessageProcessor::checkForHighlight(Message &msg) { nickList.prepend(net->myNick()); } foreach(QString nickname, nickList) { - QRegExp nickRegExp("\\b" + QRegExp::escape(nickname) + "(\\W|\\b|$)", // + "\\b", this does not seem to work for trailing ` -> upstream bug? - _nicksCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); + QRegExp nickRegExp("(^|\\W)" + QRegExp::escape(nickname) + "(\\W|$)", _nicksCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); if(nickRegExp.indexIn(msg.contents()) >= 0) { msg.setFlags(msg.flags() | Message::Highlight); return; @@ -130,16 +129,27 @@ void QtUiMessageProcessor::checkForHighlight(Message &msg) { for(int i = 0; i < _highlightRules.count(); i++) { const HighlightRule &rule = _highlightRules.at(i); if(!rule.isEnabled) - continue; + continue; + + if(rule.chanName.size() > 0 && rule.chanName.compare(".*") != 0) { + if(rule.chanName.startsWith("!")) { + QRegExp rx(rule.chanName.mid(1), Qt::CaseInsensitive); + if(rx.exactMatch(msg.bufferInfo().bufferName())) + continue; + } else { + QRegExp rx(rule.chanName, Qt::CaseInsensitive); + if(!rx.exactMatch(msg.bufferInfo().bufferName())) + continue; + } + } - bool match = false; + QRegExp rx; if(rule.isRegExp) { - QRegExp rx(rule.name, rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive); - match = rx.exactMatch(msg.contents()); + rx = QRegExp(rule.name, rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive); } else { - QRegExp rx("\\b" + QRegExp::escape(rule.name) + "\\b", rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive); - match = (rx.indexIn(msg.contents()) >= 0); + rx = QRegExp("(^|\\W)" + QRegExp::escape(rule.name) + "(\\W|$)", rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive); } + bool match = (rx.indexIn(msg.contents()) >= 0); if(match) { msg.setFlags(msg.flags() | Message::Highlight); return; @@ -162,7 +172,8 @@ void QtUiMessageProcessor::highlightListChanged(const QVariant &variant) { _highlightRules << HighlightRule(rule["Name"].toString(), rule["Enable"].toBool(), rule["CS"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive, - rule["RegEx"].toBool()); + rule["RegEx"].toBool(), + rule["Chan"].toString()); iter++; } }