qtui: Set proper icon for "About Quassel" menu option
[quassel.git] / src / common / ignorelistmanager.cpp
index a6fbd16..b01273e 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2014 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -23,7 +23,6 @@
 #include <QtCore>
 #include <QDebug>
 #include <QStringList>
-#include <QRegExp>
 
 INIT_SYNCABLE_OBJECT(IgnoreListManager)
 IgnoreListManager &IgnoreListManager::operator=(const IgnoreListManager &other)
@@ -92,7 +91,7 @@ void IgnoreListManager::initSetIgnoreList(const QVariantMap &ignoreList)
     int count = ignoreRule.count();
     if (count != scopeRule.count() || count != isRegEx.count() ||
         count != scope.count() || count != strictness.count() || count != ignoreType.count() || count != isActive.count()) {
-        qWarning() << "Corrupted IgnoreList settings! (Count missmatch)";
+        qWarning() << "Corrupted IgnoreList settings! (Count mismatch)";
         return;
     }
 
@@ -137,27 +136,21 @@ IgnoreListManager::StrictnessType IgnoreListManager::_match(const QString &msgCo
         if (!item.isActive || item.type == CtcpIgnore)
             continue;
         if (item.scope == GlobalScope
-            || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network))
-            || (item.scope == ChannelScope && scopeMatch(item.scopeRule, bufferName))) {
+            || (item.scope == NetworkScope && scopeMatch(network, item.scopeRule))
+            || (item.scope == ChannelScope && scopeMatch(bufferName, item.scopeRule))) {
             QString str;
             if (item.type == MessageIgnore)
                 str = msgContents;
             else
                 str = msgSender;
 
-            QRegExp ruleRx = QRegExp(item.ignoreRule);
-            ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
-            if (!item.isRegEx) {
-                ruleRx.setPatternSyntax(QRegExp::Wildcard);
-            }
-
 //      qDebug() << "IgnoreListManager::match: ";
 //      qDebug() << "string: " << str;
 //      qDebug() << "pattern: " << ruleRx.pattern();
 //      qDebug() << "scopeRule: " << item.scopeRule;
 //      qDebug() << "now testing";
-            if ((!item.isRegEx && ruleRx.exactMatch(str)) ||
-                (item.isRegEx && ruleRx.indexIn(str) != -1)) {
+            if ((!item.isRegEx && item.regEx.exactMatch(str)) ||
+                (item.isRegEx && item.regEx.indexIn(str) != -1)) {
 //        qDebug() << "MATCHED!";
                 return item.strictness;
             }
@@ -167,20 +160,6 @@ IgnoreListManager::StrictnessType IgnoreListManager::_match(const QString &msgCo
 }
 
 
-bool IgnoreListManager::scopeMatch(const QString &scopeRule, const QString &string) const
-{
-    foreach(QString rule, scopeRule.split(";")) {
-        QRegExp ruleRx = QRegExp(rule.trimmed());
-        ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
-        ruleRx.setPatternSyntax(QRegExp::Wildcard);
-        if (ruleRx.exactMatch(string)) {
-            return true;
-        }
-    }
-    return false;
-}
-
-
 void IgnoreListManager::removeIgnoreListItem(const QString &ignoreRule)
 {
     removeAt(indexOf(ignoreRule));
@@ -203,7 +182,7 @@ bool IgnoreListManager::ctcpMatch(const QString sender, const QString &network,
     foreach(IgnoreListItem item, _ignoreList) {
         if (!item.isActive)
             continue;
-        if (item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network))) {
+        if (item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(network, item.scopeRule))) {
             QString sender_;
             QStringList types = item.ignoreRule.split(QRegExp("\\s+"), QString::SkipEmptyParts);