Introduce IgnoreList backend
[quassel.git] / src / client / messagefilter.cpp
index 323405e..53ac5e1 100644 (file)
@@ -25,6 +25,7 @@
 #include "buffermodel.h"
 #include "messagemodel.h"
 #include "networkmodel.h"
+#include "clientignorelistmanager.h"
 
 MessageFilter::MessageFilter(QAbstractItemModel *source, QObject *parent)
   : QSortFilterProxyModel(parent),
@@ -46,6 +47,8 @@ MessageFilter::MessageFilter(MessageModel *source, const QList<BufferId> &buffer
 void MessageFilter::init() {
   setDynamicSortFilter(true);
 
+  _userNoticesTarget = _serverNoticesTarget = _errorMsgsTarget = -1;
+
   BufferSettings defaultSettings;
   defaultSettings.notify("UserNoticesTarget", this, SLOT(messageRedirectionChanged()));
   defaultSettings.notify("ServerNoticesTarget", this, SLOT(messageRedirectionChanged()));
@@ -140,6 +143,12 @@ bool MessageFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePar
   if(myNetworkId != msgNetworkId)
     return false;
 
+  // ignorelist handling
+  const MessageModelItem *item = const_cast<const MessageModel*>(static_cast<MessageModel*>(sourceModel()))->messageItemAt(sourceRow);
+  // only match if message is not flagged as server msg
+  if(!(item->message().flags() & Message::ServerMsg) &&
+     Client::ignoreListManager()->match(item->message(), Client::networkModel()->networkName(item->bufferId())))
+      return false;
 
   if(flags & Message::Redirected) {
     int redirectionTarget = 0;