Quassel no longer gets a nervous breakdown when you select too many buffers - fixes...
[quassel.git] / src / client / clientsettings.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 CLIENTSETTINGS_H
22 #define CLIENTSETTINGS_H
23
24 #include "settings.h"
25 #include "types.h"
26
27 class ClientSettings : public Settings {
28 public:
29   virtual ~ClientSettings();
30
31 protected:
32   ClientSettings(QString group = "General");
33 };
34
35 // Deriving from CoreAccountSettings:
36 // MySettings() : CoreAccountSettings("MyGroup") {};
37 // Then use accountValue() / setAccountValue() to retrieve/store data associated to the currently
38 // connected account. This is stored in CoreAccounts/$ACCID/MyGroup/$KEY) then.
39 //
40 // Note that you'll get invalid data (and setting is ignored) if you are not connected to a core!
41
42 class CoreAccountSettings : public ClientSettings {
43 public:
44   // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
45   CoreAccountSettings(const QString &subgroup = "General");
46
47   virtual void notify(const QString &key, QObject *receiver, const char *slot);
48
49   QList<AccountId> knownAccounts();
50   AccountId lastAccount();
51   void setLastAccount(AccountId);
52   AccountId autoConnectAccount();
53   void setAutoConnectAccount(AccountId);
54
55   void storeAccountData(AccountId id, const QVariantMap &data);
56   QVariantMap retrieveAccountData(AccountId);
57   void removeAccount(AccountId);
58
59   void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
60   QHash<int, BufferId> jumpKeyMap();
61
62 protected:
63   void setAccountValue(const QString &key, const QVariant &data);
64   QVariant accountValue(const QString &key, const QVariant &def = QVariant());
65
66 private:
67   QString _subgroup;
68 };
69
70 class NotificationSettings : public ClientSettings {
71
72   public:
73     enum HighlightNickType {
74       NoNick = 0x00,
75       CurrentNick= 0x01,
76       AllNicks = 0x02
77     };
78
79     NotificationSettings();
80
81     inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
82     inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
83     inline void remove(const QString &key) { removeLocalKey(key); }
84
85     void setHighlightList(const QVariantList &highlightList);
86     QVariantList highlightList();
87
88     void setHighlightNick(HighlightNickType);
89     HighlightNickType highlightNick();
90
91     void setNicksCaseSensitive(bool);
92     bool nicksCaseSensitive();
93
94 };
95 #endif