81e2cb337771e3fe6fab1345dc82be164bbce43b
[quassel.git] / src / common / bufferviewconfig.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 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(int allowedBufferTypes READ allowedBufferTypes WRITE setAllowedBufferTypes)
36   Q_PROPERTY(int minimumActivity READ minimumActivity WRITE setMinimumActivity)
37
38 public:
39   BufferViewConfig(int bufferViewId, QObject *parent = 0);
40   BufferViewConfig(int bufferViewId, const QVariantMap &properties, QObject *parent = 0);
41
42
43 public slots:
44   inline int bufferViewId() const { return _bufferViewId; }
45
46   inline const QString &bufferViewName() const { return _bufferViewName; }
47   void setBufferViewName(const QString &bufferViewName);
48
49   inline const NetworkId &networkId() const { return _networkId; }
50   void setNetworkId(const NetworkId &networkId);
51
52   inline bool addNewBuffersAutomatically() const { return _addNewBuffersAutomatically; }
53   void setAddNewBuffersAutomatically(bool addNewBuffersAutomatically);
54
55   inline bool sortAlphabetically() const { return _sortAlphabetically; }
56   void setSortAlphabetically(bool sortAlphabetically);
57
58   inline int allowedBufferTypes() const { return _allowedBufferTypes; }
59   void setAllowedBufferTypes(int bufferTypes);
60
61   inline int minimumActivity() const { return _minimumActivity; }
62   void setMinimumActivity(int activity);
63
64   inline bool hideInactiveBuffers() const { return _hideInactiveBuffers; }
65   void setHideInactiveBuffers(bool hideInactiveBuffers);
66   
67   virtual inline void requestSetBufferViewName(const QString &bufferViewName) { emit setBufferViewNameRequested(bufferViewName); }
68
69   const QList<BufferId> &bufferList() const { return _buffers; }
70   const QSet<BufferId> &removedBuffers() const { return _removedBuffers; }
71
72   QVariantList initBufferList() const;
73   void initSetBufferList(const QVariantList &buffers);
74   void initSetBufferList(const QList<BufferId> &buffers);
75
76   QVariantList initRemovedBuffersList() const;
77   void initSetRemovedBuffersList(const QVariantList &buffers);
78
79   void addBuffer(const BufferId &bufferId, int pos);
80   virtual inline void requestAddBuffer(const BufferId &bufferId, int pos) { emit addBufferRequested(bufferId, pos); }
81   void moveBuffer(const BufferId &bufferId, int pos);
82   virtual inline void requestMoveBuffer(const BufferId &bufferId, int pos) { emit moveBufferRequested(bufferId, pos); }
83   void removeBuffer(const BufferId &bufferId);
84   virtual inline void requestRemoveBuffer(const BufferId &bufferId) { emit removeBufferRequested(bufferId); }
85   void removeBufferPermanently(const BufferId &bufferId);
86   virtual inline void requestRemoveBufferPermanently(const BufferId &bufferId) { emit removeBufferPermanentlyRequested(bufferId); }
87   
88   
89 signals:
90   void bufferViewNameSet(const QString &bufferViewName);
91   void networkIdSet(const NetworkId &networkId);
92   void addNewBuffersAutomaticallySet(bool addNewBuffersAutomatically);
93   void sortAlphabeticallySet(bool sortAlphabetically);  
94   void allowedBufferTypesSet(int allowedBufferTypes);
95   void minimumActivitySet(int activity);
96   void hideInactiveBuffersSet(bool hideInactiveBuffers);
97   void bufferListSet();
98
99   void bufferAdded(const BufferId &bufferId, int pos);
100   void addBufferRequested(const BufferId &bufferId, int pos);
101   void bufferMoved(const BufferId &bufferId, int pos);
102   void moveBufferRequested(const BufferId &bufferId, int pos);
103   void bufferRemoved(const BufferId &bufferId);
104   void bufferPermanentlyRemoved(const BufferId &bufferId);
105   void removeBufferRequested(const BufferId &bufferId);
106   void removeBufferPermanentlyRequested(const BufferId &bufferId);
107   
108   void setBufferViewNameRequested(const QString &bufferViewName);
109
110 private:
111   int _bufferViewId;
112   QString _bufferViewName;
113   NetworkId _networkId;
114   bool _addNewBuffersAutomatically;
115   bool _sortAlphabetically;
116   bool _hideInactiveBuffers;
117   int _allowedBufferTypes;
118   int _minimumActivity;
119   QList<BufferId> _buffers;
120   QSet<BufferId> _removedBuffers;
121 };
122
123 #endif // BUFFERVIEWCONFIG_H