cleaning up the general settings page
[quassel.git] / src / qtui / qtuimessageprocessor.cpp
index e7fa198..ac98bc8 100644 (file)
@@ -40,8 +40,8 @@ QtUiMessageProcessor::QtUiMessageProcessor(QObject *parent)
   _highlightNick = notificationSettings.highlightNick();
   highlightListChanged(notificationSettings.highlightList());
   notificationSettings.notify("Highlights/NicksCaseSensitive", this, SLOT(nicksCaseSensitiveChanged(const QVariant &)));
-  notificationSettings.notify("highlightList", this, SLOT(highlightListChanged(const QVariant &)));
-  notificationSettings.notify("highlightNick", this, SLOT(highlightNickChanged(const QVariant &)));
+  notificationSettings.notify("Highlights/CustomList", this, SLOT(highlightListChanged(const QVariant &)));
+  notificationSettings.notify("Highlights/HighlightNick", this, SLOT(highlightNickChanged(const QVariant &)));
 
   _processTimer.setInterval(0);
   connect(&_processTimer, SIGNAL(timeout()), this, SLOT(processNextMessage()));
@@ -151,13 +151,15 @@ void QtUiMessageProcessor::checkForHighlight(Message &msg) {
       if(!rule.isEnabled)
        continue;
 
-      QRegExp userRegExp;
+      bool match = false;
       if(rule.isRegExp) {
-        userRegExp = QRegExp(rule.name, rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive);
+        QRegExp rx(rule.name, rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive);
+        match = rx.exactMatch(msg.contents());
       } else {
-        userRegExp = QRegExp("\\b" + QRegExp::escape(rule.name) + "\\b", rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive);
+        QRegExp rx("\\b" + QRegExp::escape(rule.name) + "\\b", rule.caseSensitive? Qt::CaseSensitive : Qt::CaseInsensitive);
+        match = (rx.indexIn(msg.contents()) >= 0);
       }
-      if(userRegExp.exactMatch(msg.contents())) {
+      if(match) {
         msg.setFlags(msg.flags() | Message::Highlight);
         return;
       }
@@ -174,13 +176,12 @@ void QtUiMessageProcessor::highlightListChanged(const QVariant &variant) {
 
   _highlightRules.clear();
   QVariantList::const_iterator iter = varList.constBegin();
-  QVariantList::const_iterator iterEnd = varList.constEnd();
-  while(iter != iterEnd) {
-    QVariantMap rule;
-    _highlightRules << HighlightRule(rule["name"].toString(),
-                                     rule["enable"].toBool(),
-                                     rule["cs"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive,
-                                     rule["regex"].toBool());
+  while(iter != varList.constEnd()) {
+    QVariantMap rule = iter->toMap();
+    _highlightRules << HighlightRule(rule["Name"].toString(),
+                                     rule["Enable"].toBool(),
+                                     rule["CS"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive,
+                                     rule["RegEx"].toBool());
     iter++;
   }
 }