+void QtUiMessageProcessor::checkForHighlight(Message &msg)
+{
+ if (!((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self)))
+ return;
+
+ // TODO: Cache this (per network)
+ const Network *net = Client::network(msg.bufferInfo().networkId());
+ if (net && !net->myNick().isEmpty()) {
+ // Get current nick
+ QString currentNick = net->myNick();
+ // Get identity nicks
+ QStringList identityNicks = {};
+ const Identity *myIdentity = Client::identity(net->identity());
+ if (myIdentity) {
+ identityNicks = myIdentity->nicks();
+ }
+
+ // Get buffer name, message contents
+ QString bufferName = msg.bufferInfo().bufferName();
+ QString msgContents = msg.contents();
+ bool matches = false;
+
+ for (int i = 0; i < _highlightRuleList.count(); i++) {
+ auto &rule = _highlightRuleList.at(i);
+ if (!rule.isEnabled())
+ continue;
+
+ // Skip if channel name doesn't match and channel rule is not empty
+ //
+ // Match succeeds if...
+ // Channel name matches a defined rule
+ // Defined rule is empty
+ // And take the inverse of the above
+ if (!rule.chanNameMatcher().match(bufferName, true)) {
+ // A channel name rule is specified and does NOT match the current buffer name, skip
+ // this rule
+ continue;
+ }
+
+ // Check message according to specified rule, allowing empty rules to match
+ bool contentsMatch = rule.contentsMatcher().match(stripFormatCodes(msgContents), true);
+
+ // Support for sender matching can be added here
+
+ if (contentsMatch) {
+ // Support for inverse rules can be added here
+ matches = true;
+ }
+ }
+
+ if (matches) {
+ msg.setFlags(msg.flags() | Message::Highlight);
+ return;
+ }
+
+ // Check nicknames
+ if (_highlightNick != HighlightNickType::NoNick && !currentNick.isEmpty()) {
+ // Update cache if needed
+ determineNickExpressions(currentNick, identityNicks);
+
+ // Check for a match
+ if (_cachedNickMatcher.isValid()
+ && _cachedNickMatcher.match(stripFormatCodes(msgContents))) {
+ // Nick matcher is valid and match found
+ msg.setFlags(msg.flags() | Message::Highlight);
+ return;
+ }
+ }
+ }
+}
+
+
+void QtUiMessageProcessor::nicksCaseSensitiveChanged(const QVariant &variant)
+{
+ _nicksCaseSensitive = variant.toBool();
+ _cacheNickConfigInvalid = true;
+}
+
+
+void QtUiMessageProcessor::highlightListChanged(const QVariant &variant)
+{
+ QVariantList varList = variant.toList();
+
+ _highlightRuleList.clear();
+ QVariantList::const_iterator iter = varList.constBegin();
+ while (iter != varList.constEnd()) {
+ QVariantMap rule = iter->toMap();
+ _highlightRuleList << LegacyHighlightRule(rule["Name"].toString(),
+ rule["RegEx"].toBool(),
+ rule["CS"].toBool(),
+ rule["Enable"].toBool(),
+ rule["Channel"].toString());
+ ++iter;