X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fqtuimessageprocessor.cpp;h=aa24f08cbaafb2217a0763b3a7cce7be906706ad;hb=dd8d82a90c136fa1e56d7f72781881cd5099574f;hp=2466e15d7992d0e17dbaf8461adaf1ff954cd584;hpb=7e20c659f88e26ccdfdc65f4894ed6ecf61ca8a9;p=quassel.git diff --git a/src/qtui/qtuimessageprocessor.cpp b/src/qtui/qtuimessageprocessor.cpp index 2466e15d..aa24f08c 100644 --- a/src/qtui/qtuimessageprocessor.cpp +++ b/src/qtui/qtuimessageprocessor.cpp @@ -115,10 +115,11 @@ void QtUiMessageProcessor::checkForHighlight(Message &msg) { const Identity *myIdentity = Client::identity(net->identity()); if(myIdentity) nickList = myIdentity->nicks(); + if(!nickList.contains(net->myNick())) + 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; @@ -128,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; @@ -160,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++; } }