Improve ChatMonitorFilter to use Message::Backlog rather than the timestamp
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 18 Aug 2008 06:43:30 +0000 (08:43 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 18 Aug 2008 06:43:30 +0000 (08:43 +0200)
Also makes the ChatMonitor work correctly after reconnect.

src/qtui/chatmonitorfilter.cpp
src/qtui/chatmonitorfilter.h

index ef68a9c..1fbab84 100644 (file)
 #include "networkmodel.h"
 
 ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
 #include "networkmodel.h"
 
 ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
-  : MessageFilter(model, QList<BufferId>(), parent),
-    _initTime(QDateTime::currentDateTime())
+  : MessageFilter(model, QList<BufferId>(), parent)
 {
 }
 
 bool ChatMonitorFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
   Q_UNUSED(sourceParent)
 {
 }
 
 bool ChatMonitorFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
   Q_UNUSED(sourceParent)
-  Message::Type type = (Message::Type)sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageModel::TypeRole).toInt();
+
   Message::Flags flags = (Message::Flags)sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageModel::FlagsRole).toInt();
   Message::Flags flags = (Message::Flags)sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageModel::FlagsRole).toInt();
-  if(!((type & (Message::Plain | Message::Notice | Message::Action)) || flags & Message::Self))
+  if(flags & Message::Backlog || flags & Message::Self)
     return false;
 
     return false;
 
-  QDateTime msgTime = sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageModel::TimestampRole).toDateTime();
-  return msgTime > _initTime;
+  Message::Type type = (Message::Type)sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageModel::TypeRole).toInt();
+  if(!(type & (Message::Plain | Message::Notice | Message::Action)))
+    return false;
+
+  return true;
 }
 
 // override this to inject display of network and channel
 }
 
 // override this to inject display of network and channel
@@ -48,7 +50,7 @@ QVariant ChatMonitorFilter::data(const QModelIndex &index, int role) const {
     return MessageFilter::data(index, role);
 
   int showFields_ = showFields();
     return MessageFilter::data(index, role);
 
   int showFields_ = showFields();
-    
+
   BufferId bufid = data(index, ChatLineModel::BufferIdRole).value<BufferId>();
   if(!bufid.isValid()) {
     qDebug() << "ChatMonitorFilter::data(): chatline belongs to an invalid buffer!";
   BufferId bufid = data(index, ChatLineModel::BufferIdRole).value<BufferId>();
   if(!bufid.isValid()) {
     qDebug() << "ChatMonitorFilter::data(): chatline belongs to an invalid buffer!";
@@ -56,7 +58,7 @@ QVariant ChatMonitorFilter::data(const QModelIndex &index, int role) const {
   }
 
   QModelIndex source_index = mapToSource(index);
   }
 
   QModelIndex source_index = mapToSource(index);
-  
+
   QStringList fields;
   if(showFields_ & NetworkField) {
     fields << Client::networkModel()->networkName(bufid);
   QStringList fields;
   if(showFields_ & NetworkField) {
     fields << Client::networkModel()->networkName(bufid);
index a27d3e5..c1258b6 100644 (file)
@@ -50,7 +50,6 @@ public:
   void removeShowField(int field);
 
 private:
   void removeShowField(int field);
 
 private:
-  QDateTime _initTime;
 
   void showFieldSettingsChanged();
 };
 
   void showFieldSettingsChanged();
 };