+QVariantList BufferSyncer::initActivities() const
+{
+ QVariantList list;
+ auto iter = _bufferActivities.constBegin();
+ while (iter != _bufferActivities.constEnd()) {
+ list << QVariant::fromValue<BufferId>(iter.key())
+ << QVariant::fromValue<int>((int) iter.value());
+ ++iter;
+ }
+ return list;
+}
+
+
+void BufferSyncer::initSetActivities(const QVariantList &list)
+{
+ _bufferActivities.clear();
+ Q_ASSERT(list.count() % 2 == 0);
+ for (int i = 0; i < list.count(); i += 2) {
+ setBufferActivity(list.at(i).value<BufferId>(), list.at(i+1).value<int>());
+ }
+}
+
+
+Message::Types BufferSyncer::activity(BufferId buffer) const
+{
+ return _bufferActivities.value(buffer, Message::Types());
+}
+
+
+void BufferSyncer::removeBuffer(BufferId buffer)
+{
+ if (_lastSeenMsg.contains(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);
+}
+
+
+void BufferSyncer::mergeBuffersPermanently(BufferId buffer1, BufferId buffer2)
+{
+ if (_lastSeenMsg.contains(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<BufferId>(iter.key())
+ << QVariant::fromValue<int>((int) iter.value());
+ ++iter;
+ }
+ return list;