Bring back notifications (again...)
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 11 Aug 2008 16:47:34 +0000 (18:47 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 11 Aug 2008 16:48:22 +0000 (18:48 +0200)
Adds a new flag Message::Backlog that indicates that a message was received during
backlog replay, and which is also set after notifications have been processed the first
time for that message to avoid multiple process runs (possible if multiple ChatViews let
that message through their filters).

src/client/client.cpp
src/common/message.h
src/qtui/mainwin.cpp

index b0bd4df..faddce7 100644 (file)
@@ -450,7 +450,9 @@ void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) {
   //QTime start = QTime::currentTime();
   QList<Message> msglist;
   foreach(QVariant v, msgs) {
-    msglist << v.value<Message>();
+    Message msg = v.value<Message>();
+    msg.setFlags(msg.flags() | Message::Backlog);
+    msglist << msg;
   }
   messageProcessor()->process(msglist);
   //qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
index a4c4ab6..9bb1c9c 100644 (file)
@@ -48,14 +48,16 @@ public:
     Error  = 0x1000
   };
 
+  // DO NOT CHANGE without knowing what you do, some of these flags are stored in the database
   enum Flag {
-    None = 0,
-    Self = 1,
-    Highlight = 2,
-    Redirected = 4
+    None = 0x00,
+    Self = 0x01,
+    Highlight = 0x02,
+    Redirected = 0x04,
+    Backlog = 0x80
   };
   Q_DECLARE_FLAGS(Flags, Flag)
-  
+
 
   Message(const BufferInfo &bufferInfo = BufferInfo(), Type type = Plain, const QString &contents = "", const QString &sender = "", Flags flags = None);
   Message(const QDateTime &ts, const BufferInfo &buffer = BufferInfo(), Type type = Plain,
index d302ee1..c888d22 100644 (file)
@@ -560,12 +560,10 @@ void MainWin::toggleVisibility() {
 
 void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
   Q_UNUSED(parent);
+
   if(QApplication::activeWindow() != 0)
     return;
 
-  // FIXME
-  return;
-
   for(int i = start; i <= end; i++) {
     QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn);
     if(!idx.isValid()) {
@@ -573,6 +571,10 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
       continue;
     }
     Message::Flags flags = (Message::Flags)idx.data(ChatLineModel::FlagsRole).toInt();
+    if(flags.testFlag(Message::Backlog)) continue;
+    flags |= Message::Backlog;  // we only want to trigger a highlight once!
+    Client::messageModel()->setData(idx, (int)flags, ChatLineModel::FlagsRole);
+
     BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>();
     BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId);