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