1 /***************************************************************************
2 * Copyright (C) 2005-2018 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 "common-export.h"
25 #include "bufferinfo.h"
26 #include "syncableobject.h"
29 class COMMON_EXPORT BufferViewConfig : public SyncableObject
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)
46 BufferViewConfig(int bufferViewId, QObject* parent = nullptr);
47 BufferViewConfig(int bufferViewId, const QVariantMap& properties, QObject* parent = nullptr);
50 inline int bufferViewId() const { return _bufferViewId; }
52 inline const QString& bufferViewName() const { return _bufferViewName; }
53 void setBufferViewName(const QString& bufferViewName);
55 inline const NetworkId& networkId() const { return _networkId; }
56 void setNetworkId(const NetworkId& networkId);
58 inline bool addNewBuffersAutomatically() const { return _addNewBuffersAutomatically; }
59 void setAddNewBuffersAutomatically(bool addNewBuffersAutomatically);
61 inline bool sortAlphabetically() const { return _sortAlphabetically; }
62 void setSortAlphabetically(bool sortAlphabetically);
64 inline bool disableDecoration() const { return _disableDecoration; }
65 void setDisableDecoration(bool disableDecoration);
67 inline int allowedBufferTypes() const { return _allowedBufferTypes; }
68 void setAllowedBufferTypes(int bufferTypes);
70 inline int minimumActivity() const { return _minimumActivity; }
71 void setMinimumActivity(int activity);
73 inline bool hideInactiveBuffers() const { return _hideInactiveBuffers; }
74 void setHideInactiveBuffers(bool hideInactiveBuffers);
76 inline bool hideInactiveNetworks() const { return _hideInactiveNetworks; }
77 void setHideInactiveNetworks(bool hideInactiveNetworks);
79 inline bool showSearch() const { return _showSearch; }
80 void setShowSearch(bool showSearch);
82 virtual inline void requestSetBufferViewName(const QString& bufferViewName) { REQUEST(ARG(bufferViewName)) }
84 const QList<BufferId>& bufferList() const { return _buffers; }
85 const QSet<BufferId>& removedBuffers() const { return _removedBuffers; }
86 const QSet<BufferId>& temporarilyRemovedBuffers() const { return _temporarilyRemovedBuffers; }
88 QVariantList initBufferList() const;
89 void initSetBufferList(const QVariantList& buffers);
90 void initSetBufferList(const QList<BufferId>& buffers);
92 QVariantList initRemovedBuffers() const;
93 void initSetRemovedBuffers(const QVariantList& buffers);
95 QVariantList initTemporarilyRemovedBuffers() const;
96 void initSetTemporarilyRemovedBuffers(const QVariantList& buffers);
98 void addBuffer(const BufferId& bufferId, int pos);
99 virtual inline void requestAddBuffer(const BufferId& bufferId, int pos) { REQUEST(ARG(bufferId), ARG(pos)) }
100 void moveBuffer(const BufferId& bufferId, int pos);
101 virtual inline void requestMoveBuffer(const BufferId& bufferId, int pos) { REQUEST(ARG(bufferId), ARG(pos)) }
102 void removeBuffer(const BufferId& bufferId);
103 virtual inline void requestRemoveBuffer(const BufferId& bufferId) { REQUEST(ARG(bufferId)) }
104 void removeBufferPermanently(const BufferId& bufferId);
105 virtual inline void requestRemoveBufferPermanently(const BufferId& bufferId){REQUEST(ARG(bufferId))}
107 signals : void bufferViewNameSet(const QString& bufferViewName); // invalidate
108 void configChanged();
109 void networkIdSet(const NetworkId& networkId);
110 // void addNewBuffersAutomaticallySet(bool addNewBuffersAutomatically); // invalidate
111 // void sortAlphabeticallySet(bool sortAlphabetically); // invalidate
112 // // void disableDecorationSet(bool disableDecoration); // invalidate
113 // void allowedBufferTypesSet(int allowedBufferTypes); // invalidate
114 // void minimumActivitySet(int activity); // invalidate
115 // void hideInactiveBuffersSet(bool hideInactiveBuffers); // invalidate
116 void bufferListSet(); // invalidate
118 void bufferAdded(const BufferId& bufferId, int pos);
119 // void addBufferRequested(const BufferId &bufferId, int pos);
120 void bufferMoved(const BufferId& bufferId, int pos);
121 // void moveBufferRequested(const BufferId &bufferId, int pos);
122 void bufferRemoved(const BufferId& bufferId);
123 void bufferPermanentlyRemoved(const BufferId& bufferId);
124 // void removeBufferRequested(const BufferId &bufferId);
125 // void removeBufferPermanentlyRequested(const BufferId &bufferId);
127 // void setBufferViewNameRequested(const QString &bufferViewName);
130 int _bufferViewId = 0; ///< ID of the associated BufferView
131 QString _bufferViewName = {}; ///< Display name of the associated BufferView
132 NetworkId _networkId = {}; ///< Network ID this buffer belongs to
134 bool _addNewBuffersAutomatically = true; ///< Automatically add new buffers when created
135 bool _sortAlphabetically = true; ///< Sort buffers alphabetically
136 bool _hideInactiveBuffers = false; ///< Hide buffers without activity
137 bool _hideInactiveNetworks = false; ///< Hide networks without activity
138 bool _disableDecoration = false; ///< Disable buffer decoration (not fully implemented)
139 /// Buffer types allowed within this view
140 int _allowedBufferTypes = (BufferInfo::StatusBuffer | BufferInfo::ChannelBuffer | BufferInfo::QueryBuffer | BufferInfo::GroupBuffer);
141 int _minimumActivity = 0; ///< Minimum activity for a buffer to show
142 bool _showSearch = false; ///< Persistently show the buffer search UI
144 QList<BufferId> _buffers;
145 QSet<BufferId> _removedBuffers;
146 QSet<BufferId> _temporarilyRemovedBuffers;