X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatmonitorfilter.cpp;h=9c7082b19564c38bf4ee97d9471750c444a91c44;hp=7c33bc75c8544b010c0c2b2af4b06d9075facfaa;hb=3033999cfae93d1cc513bfb7494e0bb578457110;hpb=e528271e366acaa788b420bdfab8e1dd03b43e12 diff --git a/src/qtui/chatmonitorfilter.cpp b/src/qtui/chatmonitorfilter.cpp index 7c33bc75..9c7082b1 100644 --- a/src/qtui/chatmonitorfilter.cpp +++ b/src/qtui/chatmonitorfilter.cpp @@ -20,6 +20,11 @@ #include "chatmonitorfilter.h" +#include "buffer.h" +#include "client.h" +#include "chatlinemodel.h" +#include "networkmodel.h" + ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent) : MessageFilter(model, QList(), parent) { @@ -28,6 +33,11 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent) } 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(); + if(!((type & (Message::Plain | Message::Notice | Message::Action)) || flags & Message::Self)) + return false; QDateTime msgTime = sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageModel::TimestampRole).toDateTime(); return msgTime > _initTime; } @@ -35,3 +45,30 @@ bool ChatMonitorFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourc QString ChatMonitorFilter::idString() const { return "ChatMonitor"; } + +// override this to inject display of network and channel +QVariant ChatMonitorFilter::data(const QModelIndex &index, int role) const { + if(index.column() != ChatLineModel::SenderColumn) return MessageFilter::data(index, role); + if(role == ChatLineModel::DisplayRole) { + BufferId bufid = data(index, ChatLineModel::BufferIdRole).value(); + if(bufid.isValid()) { + Buffer *buf = Client::buffer(bufid); + if(!buf) { + qDebug() << "invalid buffer!"; + return QVariant(); + } + const Network *net = Client::networkModel()->networkByIndex(Client::networkModel()->bufferIndex(bufid)); + if(!net) { + qDebug() << "invalid net!"; + return QVariant(); + } + QString result = QString("<%1:%2:%3").arg(net->networkName()) + .arg(buf->bufferInfo().bufferName()) + .arg(MessageFilter::data(index, role).toString().mid(1)); + return result; + } + + } + return MessageFilter::data(index, role); + +}