Implement core-side highlights
[quassel.git] / src / qtui / qtuimessageprocessor.cpp
index ca93938..de35336 100644 (file)
@@ -1,22 +1,22 @@
 /***************************************************************************
-*   Copyright (C) 2005-09 by the Quassel Project                          *
-*   devel@quassel-irc.org                                                 *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) version 3.                                           *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU General Public License     *
-*   along with this program; if not, write to the                         *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
+ *   Copyright (C) 2005-2016 by the Quassel Project                        *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+ ***************************************************************************/
 
 #include "qtuimessageprocessor.h"
 
@@ -26,8 +26,6 @@
 #include "messagemodel.h"
 #include "network.h"
 
-const int progressUpdateDelay = 100;  // ms between progress signal updates
-
 QtUiMessageProcessor::QtUiMessageProcessor(QObject *parent)
     : AbstractMessageProcessor(parent),
     _processing(false),
@@ -59,7 +57,8 @@ void QtUiMessageProcessor::reset()
 
 void QtUiMessageProcessor::process(Message &msg)
 {
-    checkForHighlight(msg);
+    if (!Client::coreFeatures().testFlag(Quassel::Feature::CoreSideHighlights))
+        checkForHighlight(msg);
     preProcess(msg);
     Client::messageModel()->insertMessage(msg);
 }
@@ -70,9 +69,10 @@ void QtUiMessageProcessor::process(QList<Message> &msgs)
     QList<Message>::iterator msgIter = msgs.begin();
     QList<Message>::iterator msgIterEnd = msgs.end();
     while (msgIter != msgIterEnd) {
-        checkForHighlight(*msgIter);
+        if (!Client::coreFeatures().testFlag(Quassel::Feature::CoreSideHighlights))
+            checkForHighlight(*msgIter);
         preProcess(*msgIter);
-        msgIter++;
+        ++msgIter;
     }
     Client::messageModel()->insertMessages(msgs);
     return;
@@ -132,7 +132,7 @@ void QtUiMessageProcessor::checkForHighlight(Message &msg)
         }
         foreach(QString nickname, nickList) {
             QRegExp nickRegExp("(^|\\W)" + QRegExp::escape(nickname) + "(\\W|$)", _nicksCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
-            if (nickRegExp.indexIn(msg.contents()) >= 0) {
+            if (nickRegExp.indexIn(stripFormatCodes(msg.contents())) >= 0) {
                 msg.setFlags(msg.flags() | Message::Highlight);
                 return;
             }
@@ -163,7 +163,7 @@ void QtUiMessageProcessor::checkForHighlight(Message &msg)
             else {
                 rx = QRegExp("(^|\\W)" + QRegExp::escape(rule.name) + "(\\W|$)", rule.caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
             }
-            bool match = (rx.indexIn(msg.contents()) >= 0);
+            bool match = (rx.indexIn(stripFormatCodes(msg.contents())) >= 0);
             if (match) {
                 msg.setFlags(msg.flags() | Message::Highlight);
                 return;
@@ -192,7 +192,7 @@ void QtUiMessageProcessor::highlightListChanged(const QVariant &variant)
             rule["CS"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive,
             rule["RegEx"].toBool(),
             rule["Channel"].toString());
-        iter++;
+        ++iter;
     }
 }