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) {
//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());
}
messageProcessor()->process(msglist);
//qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
+ // DO NOT CHANGE without knowing what you do, some of these flags are stored in the database
- None = 0,
- Self = 1,
- Highlight = 2,
- Redirected = 4
+ None = 0x00,
+ Self = 0x01,
+ Highlight = 0x02,
+ Redirected = 0x04,
+ Backlog = 0x80
};
Q_DECLARE_FLAGS(Flags, Flag)
};
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,
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);
void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
Q_UNUSED(parent);
if(QApplication::activeWindow() != 0)
return;
if(QApplication::activeWindow() != 0)
return;
for(int i = start; i <= end; i++) {
QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn);
if(!idx.isValid()) {
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();
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);
BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>();
BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId);