X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fbuffersyncer.cpp;h=99493068b951fae57d296ebf2be142d6ab3d33ce;hp=7198a464bb11462f25cb617fe2b81e10e2379932;hb=3a3e844f9fcfd12235a0086af75ecd503b621ef4;hpb=68878dc8366f2f4a0afe132847aad9a51a80cdbf diff --git a/src/common/buffersyncer.cpp b/src/common/buffersyncer.cpp index 7198a464..99493068 100644 --- a/src/common/buffersyncer.cpp +++ b/src/common/buffersyncer.cpp @@ -20,18 +20,25 @@ #include "buffersyncer.h" -INIT_SYNCABLE_OBJECT(BufferSyncer) +#include + BufferSyncer::BufferSyncer(QObject *parent) : SyncableObject(parent) { } -BufferSyncer::BufferSyncer(const QHash &lastSeenMsg, const QHash &markerLines, const QHash &activities, QObject *parent) - : SyncableObject(parent), - _lastSeenMsg(lastSeenMsg), - _markerLines(markerLines), - _bufferActivities(activities) +BufferSyncer::BufferSyncer( + QHash lastSeenMsg, + QHash markerLines, + QHash activities, + QHash highlightCounts, + QObject *parent +) : SyncableObject(parent), + _lastSeenMsg(std::move(lastSeenMsg)), + _markerLines(std::move(markerLines)), + _bufferActivities(std::move(activities)), + _highlightCounts(std::move(highlightCounts)) { } @@ -162,6 +169,8 @@ void BufferSyncer::removeBuffer(BufferId buffer) _markerLines.remove(buffer); if (_bufferActivities.contains(buffer)) _bufferActivities.remove(buffer); + if (_highlightCounts.contains(buffer)) + _highlightCounts.remove(buffer); SYNC(ARG(buffer)) emit bufferRemoved(buffer); } @@ -175,6 +184,31 @@ void BufferSyncer::mergeBuffersPermanently(BufferId buffer1, BufferId 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()); + } +}