- foreach(QVariant highlight, notificationSettings.highlightList()) {
- QVariantMap highlightRule = highlight.toMap();
- if(!highlightRule["enable"].toBool())
- continue;
- Qt::CaseSensitivity caseSensitivity = highlightRule["cs"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive;
- QString name = highlightRule["name"].toString();
- QRegExp userRegExp;
- if(highlightRule["regex"].toBool()) {
- userRegExp = QRegExp(name, caseSensitivity);
- } else {
- userRegExp = QRegExp("^(.*\\W)?" + QRegExp::escape(name) + "(\\W.*)?$", caseSensitivity);
- }
- if(userRegExp.exactMatch(msg.contents())) {
- msg.setFlags(msg.flags() | Message::Highlight);
+
+void QtUiMessageProcessor::nicksCaseSensitiveChanged(const QVariant &variant)
+{
+ _nicksCaseSensitive = variant.toBool();
+ // Update nickname matcher, too
+ _nickMatcher.setCaseSensitive(_nicksCaseSensitive);
+}
+
+
+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;
+ }
+}
+
+
+void QtUiMessageProcessor::highlightNickChanged(const QVariant &variant)
+{
+ _highlightNick = (HighlightNickType)variant.toInt();
+ // Convert from QtUiMessageProcessor::HighlightNickType (which is from NotificationSettings) to
+ // NickHighlightMatcher::HighlightNickType
+ _nickMatcher.setHighlightMode(
+ static_cast<NickHighlightMatcher::HighlightNickType>(_highlightNick));
+}
+
+
+void QtUiMessageProcessor::networkRemoved(NetworkId id)
+{
+ // Clean up nickname matching cache
+ _nickMatcher.removeNetwork(id);
+}
+
+
+/**************************************************************************
+ * LegacyHighlightRule
+ *************************************************************************/
+bool QtUiMessageProcessor::LegacyHighlightRule::operator!=(const LegacyHighlightRule &other) const
+{
+ return (_contents != other._contents ||
+ _isRegEx != other._isRegEx ||
+ _isCaseSensitive != other._isCaseSensitive ||
+ _isEnabled != other._isEnabled ||
+ _chanName != other._chanName);
+ // Don't compare ExpressionMatch objects as they are created as needed from the above
+}
+
+
+void QtUiMessageProcessor::LegacyHighlightRule::determineExpressions() const
+{
+ // Don't update if not needed
+ if (!_cacheInvalid) {