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).
//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());
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,
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()) {
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);