modernize: Prefer default member init over ctor init
[quassel.git] / src / common / bufferviewconfig.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 "common-export.h"
24
25 #include "syncableobject.h"
26
27 #include "bufferinfo.h"
28 #include "types.h"
29
30 class COMMON_EXPORT BufferViewConfig : public SyncableObject
31 {
32     Q_OBJECT
33     SYNCABLE_OBJECT
34
35     Q_PROPERTY(QString bufferViewName READ bufferViewName WRITE setBufferViewName)
36     Q_PROPERTY(NetworkId networkId READ networkId WRITE setNetworkId)
37     Q_PROPERTY(bool addNewBuffersAutomatically READ addNewBuffersAutomatically WRITE setAddNewBuffersAutomatically)
38     Q_PROPERTY(bool sortAlphabetically READ sortAlphabetically WRITE setSortAlphabetically)
39     Q_PROPERTY(bool hideInactiveBuffers READ hideInactiveBuffers WRITE setHideInactiveBuffers)
40     Q_PROPERTY(bool hideInactiveNetworks READ hideInactiveNetworks WRITE setHideInactiveNetworks)
41     Q_PROPERTY(bool disableDecoration READ disableDecoration WRITE setDisableDecoration)
42     Q_PROPERTY(int allowedBufferTypes READ allowedBufferTypes WRITE setAllowedBufferTypes)
43     Q_PROPERTY(int minimumActivity READ minimumActivity WRITE setMinimumActivity)
44     Q_PROPERTY(bool showSearch READ showSearch WRITE setShowSearch)
45
46 public :
47     BufferViewConfig(int bufferViewId, QObject *parent = nullptr);
48     BufferViewConfig(int bufferViewId, const QVariantMap &properties, QObject *parent = nullptr);
49
50 public slots:
51     inline int bufferViewId() const { return _bufferViewId; }
52
53     inline const QString &bufferViewName() const { return _bufferViewName; }
54     void setBufferViewName(const QString &bufferViewName);
55
56     inline const NetworkId &networkId() const { return _networkId; }
57     void setNetworkId(const NetworkId &networkId);
58
59     inline bool addNewBuffersAutomatically() const { return _addNewBuffersAutomatically; }
60     void setAddNewBuffersAutomatically(bool addNewBuffersAutomatically);
61
62     inline bool sortAlphabetically() const { return _sortAlphabetically; }
63     void setSortAlphabetically(bool sortAlphabetically);
64
65     inline bool disableDecoration() const { return _disableDecoration; }
66     void setDisableDecoration(bool disableDecoration);
67
68     inline int allowedBufferTypes() const { return _allowedBufferTypes; }
69     void setAllowedBufferTypes(int bufferTypes);
70
71     inline int minimumActivity() const { return _minimumActivity; }
72     void setMinimumActivity(int activity);
73
74     inline bool hideInactiveBuffers() const { return _hideInactiveBuffers; }
75     void setHideInactiveBuffers(bool hideInactiveBuffers);
76
77     inline bool hideInactiveNetworks() const { return _hideInactiveNetworks; }
78     void setHideInactiveNetworks(bool hideInactiveNetworks);
79
80     inline bool showSearch() const { return _showSearch; }
81     void setShowSearch(bool showSearch);
82
83     virtual inline void requestSetBufferViewName(const QString &bufferViewName) { REQUEST(ARG(bufferViewName)) }
84
85     const QList<BufferId> &bufferList() const { return _buffers; }
86     const QSet<BufferId> &removedBuffers() const { return _removedBuffers; }
87     const QSet<BufferId> &temporarilyRemovedBuffers() const { return _temporarilyRemovedBuffers; }
88
89     QVariantList initBufferList() const;
90     void initSetBufferList(const QVariantList &buffers);
91     void initSetBufferList(const QList<BufferId> &buffers);
92
93     QVariantList initRemovedBuffers() const;
94     void initSetRemovedBuffers(const QVariantList &buffers);
95
96     QVariantList initTemporarilyRemovedBuffers() const;
97     void initSetTemporarilyRemovedBuffers(const QVariantList &buffers);
98
99     void addBuffer(const BufferId &bufferId, int pos);
100     virtual inline void requestAddBuffer(const BufferId &bufferId, int pos) { REQUEST(ARG(bufferId), ARG(pos)) }
101     void moveBuffer(const BufferId &bufferId, int pos);
102     virtual inline void requestMoveBuffer(const BufferId &bufferId, int pos) { REQUEST(ARG(bufferId), ARG(pos)) }
103     void removeBuffer(const BufferId &bufferId);
104     virtual inline void requestRemoveBuffer(const BufferId &bufferId) { REQUEST(ARG(bufferId)) }
105     void removeBufferPermanently(const BufferId &bufferId);
106     virtual inline void requestRemoveBufferPermanently(const BufferId &bufferId) { REQUEST(ARG(bufferId)) }
107
108 signals:
109     void bufferViewNameSet(const QString &bufferViewName); // invalidate
110     void configChanged();
111     void networkIdSet(const NetworkId &networkId);
112 //   void addNewBuffersAutomaticallySet(bool addNewBuffersAutomatically); // invalidate
113 //   void sortAlphabeticallySet(bool sortAlphabetically); // invalidate
114 //   //  void disableDecorationSet(bool disableDecoration); // invalidate
115 //   void allowedBufferTypesSet(int allowedBufferTypes); // invalidate
116 //   void minimumActivitySet(int activity); // invalidate
117 //   void hideInactiveBuffersSet(bool hideInactiveBuffers); // invalidate
118     void bufferListSet(); // invalidate
119
120     void bufferAdded(const BufferId &bufferId, int pos);
121 //   void addBufferRequested(const BufferId &bufferId, int pos);
122     void bufferMoved(const BufferId &bufferId, int pos);
123 //   void moveBufferRequested(const BufferId &bufferId, int pos);
124     void bufferRemoved(const BufferId &bufferId);
125     void bufferPermanentlyRemoved(const BufferId &bufferId);
126 //   void removeBufferRequested(const BufferId &bufferId);
127 //   void removeBufferPermanentlyRequested(const BufferId &bufferId);
128
129 //   void setBufferViewNameRequested(const QString &bufferViewName);
130
131 private:
132     int _bufferViewId = 0;                   ///< ID of the associated BufferView
133     QString _bufferViewName = {};            ///< Display name of the associated BufferView
134     NetworkId _networkId = {};               ///< Network ID this buffer belongs to
135
136     bool _addNewBuffersAutomatically = true; ///< Automatically add new buffers when created
137     bool _sortAlphabetically = true;         ///< Sort buffers alphabetically
138     bool _hideInactiveBuffers = false;       ///< Hide buffers without activity
139     bool _hideInactiveNetworks = false;      ///< Hide networks without activity
140     bool _disableDecoration = false;         ///< Disable buffer decoration (not fully implemented)
141     /// Buffer types allowed within this view
142     int _allowedBufferTypes = (BufferInfo::StatusBuffer | BufferInfo::ChannelBuffer
143                                | BufferInfo::QueryBuffer | BufferInfo::GroupBuffer);
144     int _minimumActivity = 0;                ///< Minimum activity for a buffer to show
145     bool _showSearch = false;                ///< Persistently show the buffer search UI
146
147     QList<BufferId> _buffers;
148     QSet<BufferId> _removedBuffers;
149     QSet<BufferId> _temporarilyRemovedBuffers;
150 };