X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fnetworkmodel.cpp;h=821496624cf27511e33b005f7c2aff01723e8003;hp=1f8306d636f235f9dae47839aed8caafd3830e76;hb=aec9c711900a443bfa7860fa86c6e9c86b81a3e7;hpb=7fccb74ec00f505d3a5485ad9592c37248c1e8c6 diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 1f8306d6..82149662 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -34,6 +34,7 @@ #include "ircchannel.h" #include "network.h" #include "signalproxy.h" +#include "buffersyncer.h" /***************************************** * Network Items @@ -145,6 +146,14 @@ BufferItem *NetworkItem::bufferItem(const BufferInfo &bufferInfo) break; } + BufferSyncer *bufferSyncer = Client::bufferSyncer(); + if (bufferSyncer) { + bufferItem->addActivity( + bufferSyncer->activity(bufferItem->bufferId()), + bufferSyncer->highlightCount(bufferItem->bufferId()) > 0 + ); + } + return bufferItem; } @@ -293,7 +302,7 @@ void BufferItem::setActivityLevel(BufferInfo::ActivityLevel level) void BufferItem::clearActivityLevel() { - if (Client::coreFeatures().testFlag(Quassel::Feature::BufferActivitySync)) { + if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync)) { // If the core handles activity sync, clear only the highlight flag _activity &= ~BufferInfo::Highlight; } else { @@ -302,7 +311,7 @@ void BufferItem::clearActivityLevel() _firstUnreadMsgId = MsgId(); // FIXME remove with core proto v11 - if (!(Client::coreFeatures() & Quassel::SynchronizedMarkerLine)) { + if (!Client::isCoreFeatureEnabled(Quassel::Feature::SynchronizedMarkerLine)) { _markerLineMsgId = _lastSeenMsgId; } @@ -313,7 +322,7 @@ void BufferItem::clearActivityLevel() void BufferItem::updateActivityLevel(const Message &msg) { // If the core handles activity, and this message is not a highlight, ignore this - if (Client::coreFeatures().testFlag(Quassel::Feature::BufferActivitySync) && !msg.flags().testFlag(Message::Highlight)) { + if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync) && !msg.flags().testFlag(Message::Highlight)) { return; } @@ -337,7 +346,15 @@ void BufferItem::updateActivityLevel(const Message &msg) _firstUnreadMsgId = msg.msgId(); } - if (addActivity(Message::Types(msg.type()), msg.flags().testFlag(Message::Highlight)) || stateChanged) { + Message::Types type; + // If the core handles activities, ignore types + if (Client::isCoreFeatureEnabled(Quassel::Feature::BufferActivitySync)) { + type = Message::Types(); + } else { + type = msg.type(); + } + + if (addActivity(type, msg.flags().testFlag(Message::Highlight)) || stateChanged) { emit dataChanged(); } } @@ -356,14 +373,11 @@ void BufferItem::setActivity(Message::Types type, bool highlight) { bool BufferItem::addActivity(Message::Types type, bool highlight) { auto oldActivity = activityLevel(); - // If the core handles activities, only handle highlights - if (!Client::coreFeatures().testFlag(Quassel::Feature::BufferActivitySync)) { - if (type != 0) - _activity |= BufferInfo::OtherActivity; + if (type != Message::Types()) + _activity |= BufferInfo::OtherActivity; - if (type.testFlag(Message::Plain) || type.testFlag(Message::Notice) || type.testFlag(Message::Action)) - _activity |= BufferInfo::NewMessage; - } + if (type.testFlag(Message::Plain) || type.testFlag(Message::Notice) || type.testFlag(Message::Action)) + _activity |= BufferInfo::NewMessage; if (highlight) _activity |= BufferInfo::Highlight; @@ -424,7 +438,7 @@ void BufferItem::setLastSeenMsgId(MsgId msgId) _lastSeenMsgId = msgId; // FIXME remove with core protocol v11 - if (!(Client::coreFeatures() & Quassel::SynchronizedMarkerLine)) { + if (!Client::isCoreFeatureEnabled(Quassel::Feature::SynchronizedMarkerLine)) { if (!isCurrentBuffer()) _markerLineMsgId = msgId; } @@ -1737,13 +1751,22 @@ void NetworkModel::messageRedirectionSettingsChanged() } void NetworkModel::bufferActivityChanged(BufferId bufferId, const Message::Types activity) { - auto bufferItem = findBufferItem(bufferId); - if (!bufferItem) { + auto _bufferItem = findBufferItem(bufferId); + if (!_bufferItem) { qDebug() << "NetworkModel::bufferActivityChanged(): buffer is unknown:" << bufferId; return; } auto hiddenTypes = BufferSettings(bufferId).messageFilter(); auto visibleTypes = ~hiddenTypes; auto activityVisibleTypesIntersection = activity & visibleTypes; - bufferItem->setActivity(activityVisibleTypesIntersection, false); + _bufferItem->setActivity(activityVisibleTypesIntersection, false); +} + +void NetworkModel::highlightCountChanged(BufferId bufferId, int count) { + auto _bufferItem = findBufferItem(bufferId); + if (!_bufferItem) { + qDebug() << "NetworkModel::highlightCountChanged(): buffer is unknown:" << bufferId; + return; + } + _bufferItem->addActivity(Message::Types{}, count > 0); }