From 1177f164f518b8f47b64f6736d176a995d5c17ed Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Mon, 4 Feb 2008 15:18:49 +0000 Subject: [PATCH] Quassl shows now activity from the backlog aswell. The first time you start a client on a new mashine will result in a pretty colorfull buffer overview. this is because the visited state is stored locally per client. --- src/client/buffermodel.cpp | 2 ++ src/client/client.cpp | 2 +- src/client/clientsettings.cpp | 18 +++++++++++----- src/client/clientsettings.h | 8 +++++++ src/client/networkmodel.cpp | 39 ++++++++++++++++++++++++++++++----- src/client/networkmodel.h | 13 ++++++++++-- version.inc | 4 ++-- 7 files changed, 71 insertions(+), 15 deletions(-) diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index 2fc222ed..0b87f813 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -73,5 +73,7 @@ QModelIndex BufferModel::currentIndex() { void BufferModel::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { Q_UNUSED(current); + setData(current, QDateTime::currentDateTime(), NetworkModel::LastSeenRole); + setData(previous, QDateTime::currentDateTime(), NetworkModel::LastSeenRole); setData(previous, qVariantFromValue((int)BufferItem::NoActivity), NetworkModel::BufferActivityRole); } diff --git a/src/client/client.cpp b/src/client/client.cpp index 9e22ce08..804f8276 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -405,7 +405,7 @@ void Client::recvBacklogData(BufferInfo id, QVariantList msgs, bool /*done*/) { foreach(QVariant v, msgs) { Message msg = v.value(); b->prependMsg(msg); - // networkModel()->updateBufferActivity(msg); + networkModel()->updateBufferActivity(msg); if(!layoutQueue.contains(b)) layoutQueue.append(b); } if(layoutQueue.count() && !layoutTimer->isActive()) layoutTimer->start(); diff --git a/src/client/clientsettings.cpp b/src/client/clientsettings.cpp index 87ad8166..2bf6412b 100644 --- a/src/client/clientsettings.cpp +++ b/src/client/clientsettings.cpp @@ -25,20 +25,15 @@ #include ClientSettings::ClientSettings(QString g) : Settings(g, Global::clientApplicationName) { - - } ClientSettings::~ClientSettings() { - - } /***********************************************************************************************/ CoreAccountSettings::CoreAccountSettings(const QString &subgroup) : ClientSettings("CoreAccounts") { _subgroup = subgroup; - } QList CoreAccountSettings::knownAccounts() { @@ -87,4 +82,17 @@ void CoreAccountSettings::removeAccount(AccountId id) { removeLocalKey(QString("%1").arg(id.toInt())); } +/***********************************************************************************************/ +BufferSettings::BufferSettings(BufferId bufferId) + : CoreAccountSettings(QString("Buffers/%1").arg(bufferId.toInt())) +{ +} + +void BufferSettings::setLastSeen(QDateTime seenDate) { + setAccountValue("LastSeen", seenDate); +} + +QDateTime BufferSettings::lastSeen() { + return accountValue("LastSeen", QDateTime()).value(); +} diff --git a/src/client/clientsettings.h b/src/client/clientsettings.h index 9a935977..79624234 100644 --- a/src/client/clientsettings.h +++ b/src/client/clientsettings.h @@ -65,4 +65,12 @@ class CoreAccountSettings : public ClientSettings { QString _subgroup; }; +class BufferSettings : public CoreAccountSettings { +public: + BufferSettings(BufferId bufferId); + + void setLastSeen(QDateTime); + QDateTime lastSeen(); +}; + #endif diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 0401dca1..61b269ff 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -51,8 +51,9 @@ BufferItem::BufferItem(BufferInfo bufferInfo, AbstractTreeItem *parent) if(bufferType() == QueryType) flags |= Qt::ItemIsDropEnabled; setFlags(flags); -} + _lastSeen = BufferSettings(bufferInfo.bufferId()).lastSeen(); +} const BufferInfo &BufferItem::bufferInfo() const { return _bufferInfo; @@ -81,14 +82,17 @@ BufferItem::ActivityLevel BufferItem::activity() const { return _activity; } -void BufferItem::setActivity(const ActivityLevel &level) { +bool BufferItem::setActivity(const ActivityLevel &level) { _activity = level; emit dataChanged(); + return true; } void BufferItem::updateActivity(const ActivityLevel &level) { + ActivityLevel oldActivity = _activity; _activity |= level; - emit dataChanged(); + if(oldActivity != _activity) + emit dataChanged(); } QVariant BufferItem::data(int column, int role) const { @@ -115,7 +119,9 @@ QVariant BufferItem::data(int column, int role) const { bool BufferItem::setData(int column, const QVariant &value, int role) { switch(role) { case NetworkModel::BufferActivityRole: - setActivity((ActivityLevel)value.toInt()); + return setActivity((ActivityLevel)value.toInt()); + case NetworkModel::LastSeenRole: + return setLastSeen(); default: return PropertyMapItem::setData(column, value, role); } @@ -263,6 +269,21 @@ void BufferItem::userModeChanged(IrcUser *ircUser) { addUserToCategory(ircUser); } +void BufferItem::setLastMsgInsert(QDateTime msgDate) { + if(msgDate.isValid() && msgDate > _lastMsgInsert) + _lastMsgInsert = msgDate; +} + +bool BufferItem::setLastSeen() { + _lastSeen = _lastMsgInsert; + BufferSettings(bufferInfo().bufferId()).setLastSeen(_lastSeen); + return true; +} + +QDateTime BufferItem::lastSeen() { + return _lastSeen; +} + /***************************************** * Network Items *****************************************/ @@ -701,6 +722,14 @@ void NetworkModel::bufferUpdated(BufferInfo bufferInfo) { } void NetworkModel::updateBufferActivity(const Message &msg) { + BufferItem *buff = bufferItem(msg.bufferInfo()); + Q_ASSERT(buff); + + buff->setLastMsgInsert(msg.timestamp()); + + if(buff->lastSeen() >= msg.timestamp()) + return; + BufferItem::ActivityLevel level = BufferItem::OtherActivity; if(msg.type() == Message::Plain || msg.type() == Message::Notice) level |= BufferItem::NewMessage; @@ -708,7 +737,7 @@ void NetworkModel::updateBufferActivity(const Message &msg) { const Network *net = Client::network(msg.bufferInfo().networkId()); if(net && msg.text().contains(net->myNick())) level |= BufferItem::Highlight; - + bufferItem(msg.bufferInfo())->updateActivity(level); } diff --git a/src/client/networkmodel.h b/src/client/networkmodel.h index b038f9d2..959d89a4 100644 --- a/src/client/networkmodel.h +++ b/src/client/networkmodel.h @@ -32,6 +32,8 @@ class BufferInfo; #include "selectionmodelsynchronizer.h" #include "modelpropertymapper.h" +#include "clientsettings.h" + class MappedSelectionModel; class QAbstractItemView; class Network; @@ -81,9 +83,13 @@ public: Q_DECLARE_FLAGS(ActivityLevel, Activity) ActivityLevel activity() const; - void setActivity(const ActivityLevel &level); + bool setActivity(const ActivityLevel &level); void updateActivity(const ActivityLevel &level); + void setLastMsgInsert(QDateTime msgDate); + bool setLastSeen(); + QDateTime lastSeen(); + public slots: void setTopic(const QString &topic); void join(IrcUser *ircUser); @@ -100,6 +106,8 @@ private: BufferInfo _bufferInfo; ActivityLevel _activity; Type _type; + QDateTime _lastMsgInsert; + QDateTime _lastSeen; QPointer _ircChannel; }; @@ -210,7 +218,8 @@ public: BufferIdRole, NetworkIdRole, BufferInfoRole, - ItemTypeRole + ItemTypeRole, + LastSeenRole }; enum itemTypes { diff --git a/version.inc b/version.inc index ead22e7c..d6629d4b 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.2.0-pre"; - quasselDate = "2008-02-03"; - quasselBuild = 454; + quasselDate = "2008-02-04"; + quasselBuild = 455; //! Minimum client build number the core needs clientBuildNeeded = 437; -- 2.20.1