X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fbuffersyncer.cpp;h=3f437d98ba0b0496574ea5cac82bb005ef047431;hb=ab7ef4d24f62b5848b628482b7762ebfc0b53e1a;hp=27ded35e591905f2d25212099fa81b5d58144b1d;hpb=d93a32a6d25f2a3aef89e7c948d468d892d8f768;p=quassel.git diff --git a/src/common/buffersyncer.cpp b/src/common/buffersyncer.cpp index 27ded35e..3f437d98 100644 --- a/src/common/buffersyncer.cpp +++ b/src/common/buffersyncer.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 * @@ -27,11 +27,17 @@ BufferSyncer::BufferSyncer(QObject *parent) } -BufferSyncer::BufferSyncer(const QHash &lastSeenMsg, const QHash &markerLines, const QHash &activities, QObject *parent) - : SyncableObject(parent), +BufferSyncer::BufferSyncer( + const QHash &lastSeenMsg, + const QHash &markerLines, + const QHash &activities, + const QHash &highlightCounts, + QObject *parent +) : SyncableObject(parent), _lastSeenMsg(lastSeenMsg), _markerLines(markerLines), - _bufferActivities(activities) + _bufferActivities(activities), + _highlightCounts(highlightCounts) { } @@ -160,6 +166,10 @@ void BufferSyncer::removeBuffer(BufferId buffer) _lastSeenMsg.remove(buffer); if (_markerLines.contains(buffer)) _markerLines.remove(buffer); + if (_bufferActivities.contains(buffer)) + _bufferActivities.remove(buffer); + if (_highlightCounts.contains(buffer)) + _highlightCounts.remove(buffer); SYNC(ARG(buffer)) emit bufferRemoved(buffer); } @@ -171,6 +181,33 @@ void BufferSyncer::mergeBuffersPermanently(BufferId buffer1, BufferId buffer2) _lastSeenMsg.remove(buffer2); if (_markerLines.contains(buffer2)) _markerLines.remove(buffer2); + if (_bufferActivities.contains(buffer2)) + _bufferActivities.remove(buffer2); + if (_highlightCounts.contains(buffer2)) + _highlightCounts.remove(buffer2); SYNC(ARG(buffer1), ARG(buffer2)) emit buffersPermanentlyMerged(buffer1, buffer2); } + +int BufferSyncer::highlightCount(BufferId buffer) const { + return _highlightCounts.value(buffer, 0); +} + +QVariantList BufferSyncer::initHighlightCounts() const { + QVariantList list; + auto iter = _highlightCounts.constBegin(); + while (iter != _highlightCounts.constEnd()) { + list << QVariant::fromValue(iter.key()) + << QVariant::fromValue((int) iter.value()); + ++iter; + } + return list; +} + +void BufferSyncer::initSetHighlightCounts(const QVariantList &list) { + _highlightCounts.clear(); + Q_ASSERT(list.count() % 2 == 0); + for (int i = 0; i < list.count(); i += 2) { + setHighlightCount(list.at(i).value(), list.at(i+1).value()); + } +}