Bring back highlights
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 31 Jul 2008 23:43:46 +0000 (01:43 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 2 Aug 2008 13:17:11 +0000 (15:17 +0200)
src/client/client.cpp
src/qtui/chatline.cpp

index 5f9ca04..110c8ff 100644 (file)
@@ -437,8 +437,9 @@ void Client::networkDestroyed() {
   }
 }
 
-void Client::recvMessage(const Message &msg) {
-  //checkForHighlight(msg);
+void Client::recvMessage(const Message &msg_) {
+  Message msg = msg_;
+  checkForHighlight(msg);
   _messageModel->insertMessage(msg);
 }
 
@@ -447,10 +448,11 @@ void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) {
 }
 
 void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) {
-  //checkForHighlight(msg);
   //QTime start = QTime::currentTime();
   foreach(QVariant v, msgs) {
-    _messageModel->insertMessage(v.value<Message>());
+    Message msg = v.value<Message>();
+    checkForHighlight(msg);
+    _messageModel->insertMessage(msg);
   }
   //qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
 }
@@ -475,7 +477,11 @@ AbstractUiMsg *Client::layoutMsg(const Message &msg) {
   return instance()->mainUi->layoutMsg(msg);
 }
 
+// TODO optimize checkForHighlight
 void Client::checkForHighlight(Message &msg) {
+  if(!((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self)))
+    return;
+
   NotificationSettings notificationSettings;
   const Network *net = network(msg.bufferInfo().networkId());
   if(net && !net->myNick().isEmpty()) {
@@ -489,9 +495,7 @@ void Client::checkForHighlight(Message &msg) {
     }
     foreach(QString nickname, nickList) {
       QRegExp nickRegExp("^(.*\\W)?" + QRegExp::escape(nickname) + "(\\W.*)?$");
-      if((msg.type() & (Message::Plain | Message::Notice | Message::Action))
-          && !(msg.flags() & Message::Self)
-          && nickRegExp.exactMatch(msg.contents())) {
+      if(nickRegExp.exactMatch(msg.contents())) {
         msg.setFlags(msg.flags() | Message::Highlight);
         return;
       }
@@ -509,9 +513,7 @@ void Client::checkForHighlight(Message &msg) {
       } else {
         userRegExp = QRegExp("^(.*\\W)?" + QRegExp::escape(name) + "(\\W.*)?$", caseSensitivity);
       }
-      if((msg.type() & (Message::Plain | Message::Notice | Message::Action))
-          && !(msg.flags() & Message::Self)
-          && userRegExp.exactMatch(msg.contents())) {
+      if(userRegExp.exactMatch(msg.contents())) {
         msg.setFlags(msg.flags() | Message::Highlight);
         return;
       }
index 65d68bf..5f03d9d 100644 (file)
@@ -35,6 +35,8 @@ ChatLine::ChatLine(const QModelIndex &index, QGraphicsItem *parent) : QGraphicsI
   _timestampItem->setPos(0,0);
   _width = _height = 0;
   _selection = 0;
+
+  if(_contentsItem->data(MessageModel::FlagsRole).toInt() & Message::Highlight) setHighlighted(true);
 }
 
 ChatLine::~ChatLine() {