improve and cash hilight regexp
authorsheepluva
Mon, 24 Oct 2011 01:09:33 +0200
changeset 6194 32b7e0ece99a
parent 6193 4f234aa06182
child 6195 6c9ada03602d
improve and cash hilight regexp
QTfrontend/ui/widget/chatwidget.cpp
QTfrontend/ui/widget/chatwidget.h
--- a/QTfrontend/ui/widget/chatwidget.cpp	Sun Oct 23 22:47:59 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Mon Oct 24 01:09:33 2011 +0200
@@ -30,7 +30,6 @@
 #include <QScrollBar>
 #include <QItemSelectionModel>
 #include <QStringList>
-#include <QRegExp>
 
 
 #include "HWDataManager.h"
@@ -468,10 +467,7 @@
 
     bool isHL = (!nick.isEmpty() &&
                 (nick != m_userNick) &&
-                str.toLower().contains(
-                        QRegExp(QString("^(.* )?%1(( |: ).*)?$").
-                            arg(QRegExp::escape(m_userNick).toLower())))
-                );
+                str.toLower().contains(m_hlRegExp));
 
     addLine(cssClass, formattedStr, isHL);
 }
@@ -545,6 +541,8 @@
     chatStrings.clear();
     chatNicks->clear();
     m_userNick = gameSettings->value("net/nick","").toString();
+    m_hlRegExp = QRegExp(QString("^(.* )?%1(( |[^-a-z0-9_]( |$)).*)?$").
+                            arg(QRegExp::escape(m_userNick).toLower()));
 }
 
 void HWChatWidget::onKick()
--- a/QTfrontend/ui/widget/chatwidget.h	Sun Oct 23 22:47:59 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.h	Mon Oct 24 01:09:33 2011 +0200
@@ -123,6 +123,7 @@
   QString m_helloSound;
   QString m_hilightSound;
   QString m_userNick;
+  QRegExp m_hlRegExp; ///< regular expression used for highlighting messages
   bool notify;
   bool showReady;