+ bool matches = false;
+
+ for (int i = 0; i < _highlightRuleList.count(); i++) {
+ const HighlightRule &rule = _highlightRuleList.at(i);
+ if (!rule.isEnabled)
+ continue;
+
+ if (!rule.chanName.isEmpty()
+ && !scopeMatch(bufferName, rule.chanName, rule.isRegEx, rule.isCaseSensitive)) {
+ // A channel name rule is specified and does NOT match the current buffer name, skip
+ // this rule
+ continue;
+ }
+
+ QRegExp rx;
+ if (rule.isRegEx) {
+ rx = QRegExp(rule.name, rule.isCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
+ } else {
+ rx = QRegExp("(^|\\W)" + QRegExp::escape(rule.name) + "(\\W|$)", rule.isCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
+ }
+ bool nameMatch = (rx.indexIn(stripFormatCodes(msgContents)) >= 0);
+
+ bool senderMatch;
+ if (rule.sender.isEmpty()) {
+ senderMatch = true;
+ } else {
+ // A sender name rule is specified, match according to scope rules.
+ senderMatch = scopeMatch(msgSender, rule.sender, rule.isRegEx, rule.isCaseSensitive);
+ }
+
+ if (nameMatch && senderMatch) {
+ // If an inverse rule matches, then we know that we never want to return a highlight.
+ if (rule.isInverse) {
+ return false;
+ } else {
+ matches = true;
+ }
+ }
+ }
+
+ if (matches)
+ return true;
+