+
+
+void HighlightRuleManager::determineNickExpressions(const QString ¤tNick,
+ const QStringList identityNicks) const
+{
+ // Don't do anything for no nicknames
+ if (_highlightNick == HighlightNickType::NoNick) {
+ return;
+ }
+
+ // Only update if needed (check nickname config, current nick, identity nicks for change)
+ if (!_cacheNickConfigInvalid
+ && _cachedNickCurrent == currentNick
+ && _cachedIdentityNicks == identityNicks) {
+ return;
+ }
+
+ // Add all nicknames
+ QStringList nickList;
+ if (_highlightNick == CurrentNick) {
+ nickList << currentNick;
+ }
+ else if (_highlightNick == AllNicks) {
+ nickList = identityNicks;
+ if (!nickList.contains(currentNick))
+ nickList.prepend(currentNick);
+ }
+
+ // Set up phrase matcher, joining with newlines
+ _cachedNickMatcher = ExpressionMatch(nickList.join("\n"),
+ ExpressionMatch::MatchMode::MatchMultiPhrase,
+ _nicksCaseSensitive);
+
+ _cacheNickConfigInvalid = false;
+ _cachedNickCurrent = currentNick;
+ _cachedIdentityNicks = identityNicks;
+}
+
+
+/**************************************************************************
+ * HighlightRule
+ *************************************************************************/
+bool HighlightRuleManager::HighlightRule::operator!=(const HighlightRule &other) const
+{
+ return (_id != other._id ||
+ _contents != other._contents ||
+ _isRegEx != other._isRegEx ||
+ _isCaseSensitive != other._isCaseSensitive ||
+ _isEnabled != other._isEnabled ||
+ _isInverse != other._isInverse ||
+ _sender != other._sender ||
+ _chanName != other._chanName);
+ // Don't compare ExpressionMatch objects as they are created as needed from the above
+}
+
+
+void HighlightRuleManager::HighlightRule::determineExpressions() const
+{
+ // Don't update if not needed
+ if (!_cacheInvalid) {
+ return;
+ }
+
+ // Set up matching rules
+ // Message is either phrase or regex
+ ExpressionMatch::MatchMode contentsMode =
+ _isRegEx ? ExpressionMatch::MatchMode::MatchRegEx :
+ ExpressionMatch::MatchMode::MatchPhrase;
+ // Sender and channel are either multiple wildcard entries or regex
+ ExpressionMatch::MatchMode scopeMode =
+ _isRegEx ? ExpressionMatch::MatchMode::MatchRegEx :
+ ExpressionMatch::MatchMode::MatchMultiWildcard;
+
+ _contentsMatch = ExpressionMatch(_contents, contentsMode, _isCaseSensitive);
+ _senderMatch = ExpressionMatch(_sender, scopeMode, _isCaseSensitive);
+ _chanNameMatch = ExpressionMatch(_chanName, scopeMode, _isCaseSensitive);
+
+ _cacheInvalid = false;
+}