Testing the new SyncObjects concept - looking good so far
[quassel.git] / src / common / bufferviewconfig.h
1 /***************************************************************************
2  *   Copyright (C) 2005-09 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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef BUFFERVIEWCONFIG_H
22 #define BUFFERVIEWCONFIG_H
23
24 #include "syncableobject.h"
25
26 #include "types.h"
27
28 class BufferViewConfig : public SyncableObject {
29   Q_OBJECT
30   Q_PROPERTY(QString bufferViewName READ bufferViewName WRITE setBufferViewName)
31   Q_PROPERTY(NetworkId networkId READ networkId WRITE setNetworkId)
32   Q_PROPERTY(bool addNewBuffersAutomatically READ addNewBuffersAutomatically WRITE setAddNewBuffersAutomatically)
33   Q_PROPERTY(bool sortAlphabetically READ sortAlphabetically WRITE setSortAlphabetically)
34   Q_PROPERTY(bool hideInactiveBuffers READ hideInactiveBuffers WRITE setHideInactiveBuffers)
35   Q_PROPERTY(bool disableDecoration READ disableDecoration WRITE setDisableDecoration)
36   Q_PROPERTY(int allowedBufferTypes READ allowedBufferTypes WRITE setAllowedBufferTypes)
37   Q_PROPERTY(int minimumActivity READ minimumActivity WRITE setMinimumActivity)
38
39 public:
40   BufferViewConfig(int bufferViewId, QObject *parent = 0);
41   BufferViewConfig(int bufferViewId, const QVariantMap &properties, QObject *parent = 0);
42
43   inline virtual const QMetaObject *syncMetaObject() const { return &staticMetaObject; }
44
45 public slots:
46   inline int bufferViewId() const { return _bufferViewId; }
47
48   inline const QString &bufferViewName() const { return _bufferViewName; }
49   void setBufferViewName(const QString &bufferViewName);
50
51   inline const NetworkId &networkId() const { return _networkId; }
52   void setNetworkId(const NetworkId &networkId);
53
54   inline bool addNewBuffersAutomatically() const { return _addNewBuffersAutomatically; }
55   void setAddNewBuffersAutomatically(bool addNewBuffersAutomatically);
56
57   inline bool sortAlphabetically() const { return _sortAlphabetically; }
58   void setSortAlphabetically(bool sortAlphabetically);
59
60   inline bool disableDecoration() const { return _disableDecoration; }
61   void setDisableDecoration(bool disableDecoration);
62
63   inline int allowedBufferTypes() const { return _allowedBufferTypes; }
64   void setAllowedBufferTypes(int bufferTypes);
65
66   inline int minimumActivity() const { return _minimumActivity; }
67   void setMinimumActivity(int activity);
68
69   inline bool hideInactiveBuffers() const { return _hideInactiveBuffers; }
70   void setHideInactiveBuffers(bool hideInactiveBuffers);
71
72   virtual inline void requestSetBufferViewName(const QString &bufferViewName) { emit setBufferViewNameRequested(bufferViewName); }
73
74   const QList<BufferId> &bufferList() const { return _buffers; }
75   const QSet<BufferId> &removedBuffers() const { return _removedBuffers; }
76   const QSet<BufferId> &temporarilyRemovedBuffers() const { return _temporarilyRemovedBuffers; }
77
78   QVariantList initBufferList() const;
79   void initSetBufferList(const QVariantList &buffers);
80   void initSetBufferList(const QList<BufferId> &buffers);
81
82   QVariantList initRemovedBuffers() const;
83   void initSetRemovedBuffers(const QVariantList &buffers);
84
85   QVariantList initTemporarilyRemovedBuffers() const;
86   void initSetTemporarilyRemovedBuffers(const QVariantList &buffers);
87
88   void addBuffer(const BufferId &bufferId, int pos);
89   virtual inline void requestAddBuffer(const BufferId &bufferId, int pos) { emit addBufferRequested(bufferId, pos); }
90   void moveBuffer(const BufferId &bufferId, int pos);
91   virtual inline void requestMoveBuffer(const BufferId &bufferId, int pos) { emit moveBufferRequested(bufferId, pos); }
92   void removeBuffer(const BufferId &bufferId);
93   virtual inline void requestRemoveBuffer(const BufferId &bufferId) { emit removeBufferRequested(bufferId); }
94   void removeBufferPermanently(const BufferId &bufferId);
95   virtual inline void requestRemoveBufferPermanently(const BufferId &bufferId) { emit removeBufferPermanentlyRequested(bufferId); }
96
97
98 signals:
99   void bufferViewNameSet(const QString &bufferViewName);
100   void networkIdSet(const NetworkId &networkId);
101   void addNewBuffersAutomaticallySet(bool addNewBuffersAutomatically);
102   void sortAlphabeticallySet(bool sortAlphabetically);
103   void disableDecorationSet(bool disableDecoration);
104   void allowedBufferTypesSet(int allowedBufferTypes);
105   void minimumActivitySet(int activity);
106   void hideInactiveBuffersSet(bool hideInactiveBuffers);
107   void bufferListSet();
108
109   void bufferAdded(const BufferId &bufferId, int pos);
110   void addBufferRequested(const BufferId &bufferId, int pos);
111   void bufferMoved(const BufferId &bufferId, int pos);
112   void moveBufferRequested(const BufferId &bufferId, int pos);
113   void bufferRemoved(const BufferId &bufferId);
114   void bufferPermanentlyRemoved(const BufferId &bufferId);
115   void removeBufferRequested(const BufferId &bufferId);
116   void removeBufferPermanentlyRequested(const BufferId &bufferId);
117
118   void setBufferViewNameRequested(const QString &bufferViewName);
119
120 private:
121   int _bufferViewId;
122   QString _bufferViewName;
123   NetworkId _networkId;
124   bool _addNewBuffersAutomatically;
125   bool _sortAlphabetically;
126   bool _hideInactiveBuffers;
127   bool _disableDecoration;
128   int _allowedBufferTypes;
129   int _minimumActivity;
130   QList<BufferId> _buffers;
131   QSet<BufferId> _removedBuffers;
132   QSet<BufferId> _temporarilyRemovedBuffers;
133 };
134
135 #endif // BUFFERVIEWCONFIG_H