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