1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
23 #include "buffersyncer.h"
27 class CoreBufferSyncer : public BufferSyncer
32 explicit CoreBufferSyncer(CoreSession* parent);
35 void requestSetLastSeenMsg(BufferId buffer, const MsgId& msgId) override;
36 void requestSetMarkerLine(BufferId buffer, const MsgId& msgId) override;
38 inline void requestRemoveBuffer(BufferId buffer) override { removeBuffer(buffer); }
39 void removeBuffer(BufferId bufferId) override;
41 void addBufferActivity(const Message& message)
43 auto oldActivity = activity(message.bufferId());
44 if (!oldActivity.testFlag(message.type())) {
45 setBufferActivity(message.bufferId(), (int)(oldActivity | message.type()));
49 void addCoreHighlight(const Message& message)
51 auto oldHighlightCount = highlightCount(message.bufferId());
52 if (message.flags().testFlag(Message::Flag::Highlight) && !message.flags().testFlag(Message::Flag::Self)) {
53 setHighlightCount(message.bufferId(), oldHighlightCount + 1);
57 void setBufferActivity(BufferId buffer, int activity) override;
59 void setHighlightCount(BufferId buffer, int highlightCount) override;
61 inline void requestRenameBuffer(BufferId buffer, QString newName) override { renameBuffer(buffer, newName); }
62 void renameBuffer(BufferId buffer, QString newName) override;
64 inline void requestMergeBuffersPermanently(BufferId buffer1, BufferId buffer2) override { mergeBuffersPermanently(buffer1, buffer2); }
65 void mergeBuffersPermanently(BufferId buffer1, BufferId buffer2) override;
67 void requestPurgeBufferIds() override;
69 inline void requestMarkBufferAsRead(BufferId buffer) override
71 int activity = Message::Types();
72 setBufferActivity(buffer, activity);
73 setHighlightCount(buffer, 0);
74 markBufferAsRead(buffer);
80 void customEvent(QEvent* event) override;
83 CoreSession* _coreSession;
86 QSet<BufferId> dirtyLastSeenBuffers;
87 QSet<BufferId> dirtyMarkerLineBuffers;
88 QSet<BufferId> dirtyActivities;
89 QSet<BufferId> dirtyHighlights;
91 void purgeBufferIds();