OK Folks, my first commit after quite a while, and while Quassel looks the same as...
[quassel.git] / src / common / settings.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-07 by The Quassel Team                             *
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) any later version.                                   *
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 #include <QSettings>
22 #include <QStringList>
23 #include <QDebug>
24
25 #include "settings.h"
26
27 Settings::Settings(QString g) : QObject(), group(g) {
28
29
30 }
31
32 Settings::~Settings() {
33
34 }
35
36 void Settings::setGroup(QString g) {
37   group = g;
38
39 }
40
41 QStringList Settings::allLocalKeys() {
42   QSettings s;
43   s.beginGroup(group);
44   return s.allKeys();
45 }
46
47 QStringList Settings::localChildKeys() {
48   QSettings s;
49   s.beginGroup(group);
50   return s.childKeys();
51 }
52
53 QStringList Settings::localChildGroups() {
54   QSettings s;
55   s.beginGroup(group);
56   return s.childGroups();
57 }
58
59 void Settings::setLocalValue(const QString &key, const QVariant &data) {
60   QSettings s;
61   s.beginGroup(group);
62   s.setValue(key, data);
63 }
64
65 QVariant Settings::localValue(const QString &key, const QVariant &def) {
66   QSettings s;
67   s.beginGroup(group);
68   return s.value(key, def);
69 }
70
71 void Settings::removeLocalKey(const QString &key) {
72   QSettings s;
73   s.beginGroup(group);
74   s.remove(key);
75 }
76