From b9a73f8181f4cee4b5b226b4a641796f04e85179 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Mon, 11 Aug 2008 18:47:34 +0200 Subject: [PATCH] Bring back notifications (again...) 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 | 4 +++- src/common/message.h | 12 +++++++----- src/qtui/mainwin.cpp | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index b0bd4df3..faddce72 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -450,7 +450,9 @@ void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) { //QTime start = QTime::currentTime(); QList msglist; foreach(QVariant v, msgs) { - msglist << v.value(); + Message msg = v.value(); + msg.setFlags(msg.flags() | Message::Backlog); + msglist << msg; } messageProcessor()->process(msglist); //qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime()); diff --git a/src/common/message.h b/src/common/message.h index a4c4ab6a..9bb1c9c8 100644 --- a/src/common/message.h +++ b/src/common/message.h @@ -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, diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index d302ee14..c888d228 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -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(); BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId); -- 2.20.1