Stop log_backtrace() from looping in some (all? rare? whatever) cases
[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   const QSet<BufferId> &temporarilyRemovedBuffers() const { return _temporarilyRemovedBuffers; }
72
73   QVariantList initBufferList() const;
74   void initSetBufferList(const QVariantList &buffers);
75   void initSetBufferList(const QList<BufferId> &buffers);
76
77   QVariantList initRemovedBuffers() const;
78   void initSetRemovedBuffers(const QVariantList &buffers);
79
80   QVariantList initTemporarilyRemovedBuffers() const;
81   void initSetTemporarilyRemovedBuffers(const QVariantList &buffers);
82
83   void addBuffer(const BufferId &bufferId, int pos);
84   virtual inline void requestAddBuffer(const BufferId &bufferId, int pos) { emit addBufferRequested(bufferId, pos); }
85   void moveBuffer(const BufferId &bufferId, int pos);
86   virtual inline void requestMoveBuffer(const BufferId &bufferId, int pos) { emit moveBufferRequested(bufferId, pos); }
87   void removeBuffer(const BufferId &bufferId);
88   virtual inline void requestRemoveBuffer(const BufferId &bufferId) { emit removeBufferRequested(bufferId); }
89   void removeBufferPermanently(const BufferId &bufferId);
90   virtual inline void requestRemoveBufferPermanently(const BufferId &bufferId) { emit removeBufferPermanentlyRequested(bufferId); }
91   
92   
93 signals:
94   void bufferViewNameSet(const QString &bufferViewName);
95   void networkIdSet(const NetworkId &networkId);
96   void addNewBuffersAutomaticallySet(bool addNewBuffersAutomatically);
97   void sortAlphabeticallySet(bool sortAlphabetically);  
98   void allowedBufferTypesSet(int allowedBufferTypes);
99   void minimumActivitySet(int activity);
100   void hideInactiveBuffersSet(bool hideInactiveBuffers);
101   void bufferListSet();
102
103   void bufferAdded(const BufferId &bufferId, int pos);
104   void addBufferRequested(const BufferId &bufferId, int pos);
105   void bufferMoved(const BufferId &bufferId, int pos);
106   void moveBufferRequested(const BufferId &bufferId, int pos);
107   void bufferRemoved(const BufferId &bufferId);
108   void bufferPermanentlyRemoved(const BufferId &bufferId);
109   void removeBufferRequested(const BufferId &bufferId);
110   void removeBufferPermanentlyRequested(const BufferId &bufferId);
111   
112   void setBufferViewNameRequested(const QString &bufferViewName);
113
114 private:
115   int _bufferViewId;
116   QString _bufferViewName;
117   NetworkId _networkId;
118   bool _addNewBuffersAutomatically;
119   bool _sortAlphabetically;
120   bool _hideInactiveBuffers;
121   int _allowedBufferTypes;
122   int _minimumActivity;
123   QList<BufferId> _buffers;
124   QSet<BufferId> _removedBuffers;
125   QSet<BufferId> _temporarilyRemovedBuffers;
126 };
127
128 #endif // BUFFERVIEWCONFIG_H