From 79a8a98f5a499c2da6c1e57855e9c7b2815ec6d4 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Thu, 22 Mar 2012 14:54:23 +0100 Subject: [PATCH] Only show notifications for buffers, which are part of a chatlist currently in use --- src/qtui/mainwin.cpp | 50 ++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index bd17c9a4..99cf0dce 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -1271,29 +1271,39 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) { BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value(); BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId); + // check if bufferId belongs to the shown chatlists + if(!(Client::bufferViewOverlay()->bufferIds().contains(bufId) || + Client::bufferViewOverlay()->tempRemovedBufferIds().contains(bufId))) + continue; + + // check if it's the buffer currently displayed if(hasFocus && bufId == Client::bufferModel()->currentBuffer()) continue; - if((flags & Message::Highlight || bufType == BufferInfo::QueryBuffer) - && !(Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value(), - Client::networkModel()->networkName(bufId)))) - { - QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn); - QString sender = senderIdx.data(ChatLineModel::EditRole).toString(); - QString contents = idx.data(ChatLineModel::DisplayRole).toString(); - AbstractNotificationBackend::NotificationType type; - - if(bufType == BufferInfo::QueryBuffer && !hasFocus) - type = AbstractNotificationBackend::PrivMsg; - else if(bufType == BufferInfo::QueryBuffer && hasFocus) - type = AbstractNotificationBackend::PrivMsgFocused; - else if(flags & Message::Highlight && !hasFocus) - type = AbstractNotificationBackend::Highlight; - else - type = AbstractNotificationBackend::HighlightFocused; - - QtUi::instance()->invokeNotification(bufId, type, sender, contents); - } + // only show notifications for higlights or queries + if(bufType != BufferInfo::QueryBuffer && !(flags & Message::Highlight)) + continue; + + // and of course: don't notify for ignored messages + if(Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value(), Client::networkModel()->networkName(bufId))) + continue; + + // seems like we have a legit notification candidate! + QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn); + QString sender = senderIdx.data(ChatLineModel::EditRole).toString(); + QString contents = idx.data(ChatLineModel::DisplayRole).toString(); + AbstractNotificationBackend::NotificationType type; + + if(bufType == BufferInfo::QueryBuffer && !hasFocus) + type = AbstractNotificationBackend::PrivMsg; + else if(bufType == BufferInfo::QueryBuffer && hasFocus) + type = AbstractNotificationBackend::PrivMsgFocused; + else if(flags & Message::Highlight && !hasFocus) + type = AbstractNotificationBackend::Highlight; + else + type = AbstractNotificationBackend::HighlightFocused; + + QtUi::instance()->invokeNotification(bufId, type, sender, contents); } } -- 2.20.1