modernize: Use '= default' instead of empty ctor/dtor bodies
[quassel.git] / src / core / corebuffersyncer.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #pragma once
22
23 #include "buffersyncer.h"
24
25 class CoreSession;
26
27 class CoreBufferSyncer : public BufferSyncer
28 {
29     Q_OBJECT
30
31 public:
32     explicit CoreBufferSyncer(CoreSession *parent);
33
34 public slots:
35     void requestSetLastSeenMsg(BufferId buffer, const MsgId &msgId) override;
36     void requestSetMarkerLine(BufferId buffer, const MsgId &msgId) override;
37
38     inline void requestRemoveBuffer(BufferId buffer) override { removeBuffer(buffer); }
39     void removeBuffer(BufferId bufferId) override;
40
41     void addBufferActivity(const Message &message) {
42         auto oldActivity = activity(message.bufferId());
43         if (!oldActivity.testFlag(message.type())) {
44             setBufferActivity(message.bufferId(), (int) (oldActivity | message.type()));
45         }
46     }
47
48     void addCoreHighlight(const Message &message) {
49         auto oldHighlightCount = highlightCount(message.bufferId());
50         if (message.flags().testFlag(Message::Flag::Highlight) && !message.flags().testFlag(Message::Flag::Self)) {
51             setHighlightCount(message.bufferId(), oldHighlightCount + 1);
52         }
53     }
54
55     void setBufferActivity(BufferId buffer, int activity) override;
56
57     void setHighlightCount(BufferId buffer, int highlightCount) override;
58
59     inline void requestRenameBuffer(BufferId buffer, QString newName) override { renameBuffer(buffer, newName); }
60     void renameBuffer(BufferId buffer, QString newName) override;
61
62     inline void requestMergeBuffersPermanently(BufferId buffer1, BufferId buffer2) override { mergeBuffersPermanently(buffer1, buffer2); }
63     void mergeBuffersPermanently(BufferId buffer1, BufferId buffer2) override;
64
65     void requestPurgeBufferIds() override;
66
67     inline void requestMarkBufferAsRead(BufferId buffer) override {
68         int activity = Message::Types();
69         setBufferActivity(buffer, activity);
70         setHighlightCount(buffer, 0);
71         markBufferAsRead(buffer);
72     }
73
74     void storeDirtyIds();
75
76 protected:
77     void customEvent(QEvent *event) override;
78
79 private:
80     CoreSession *_coreSession;
81     bool _purgeBuffers;
82
83     QSet<BufferId> dirtyLastSeenBuffers;
84     QSet<BufferId> dirtyMarkerLineBuffers;
85     QSet<BufferId> dirtyActivities;
86     QSet<BufferId> dirtyHighlights;
87
88     void purgeBufferIds();
89 };