1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #include <QCoreApplication>
23 #include <QStringList>
32 Settings::Settings(QString g, QString applicationName) : QSettings(QCoreApplication::organizationName(), applicationName), group(g) {
34 /* we need to call the constructor immediately in order to set the path...
36 QSettings(QCoreApplication::organizationName(), applicationName);
38 // FIXME sandboxDir() is not currently working correctly...
39 //if(Qtopia::sandboxDir().isEmpty()) QSettings();
40 //else QSettings(Qtopia::sandboxDir() + "/etc/QuasselIRC.conf", QSettings::NativeFormat);
41 // ...so we have to use a workaround:
42 QString appPath = QCoreApplication::applicationFilePath();
43 if(appPath.startsWith(Qtopia::packagePath())) {
44 QString sandboxPath = appPath.left(Qtopia::packagePath().length() + 32);
45 QSettings(sandboxPath + "/etc/QuasselIRC.conf", QSettings::IniFormat);
46 qDebug() << sandboxPath + "/etc/QuasselIRC.conf";
48 QSettings(QCoreApplication::organizationName(), applicationName);
54 Settings::~Settings() {
58 void Settings::setGroup(QString g) {
63 QStringList Settings::allLocalKeys() {
65 QStringList res = allKeys();
70 QStringList Settings::localChildKeys(const QString &rootkey) {
72 if(rootkey.isEmpty()) g = group;
73 else g = QString("%1/%2").arg(group, rootkey);
75 QStringList res = childKeys();
80 QStringList Settings::localChildGroups(const QString &rootkey) {
82 if(rootkey.isEmpty()) g = group;
83 else g = QString("%1/%2").arg(group, rootkey);
85 QStringList res = childGroups();
90 void Settings::setLocalValue(const QString &key, const QVariant &data) {
96 QVariant Settings::localValue(const QString &key, const QVariant &def) {
98 QVariant res = value(key, def);
103 void Settings::removeLocalKey(const QString &key) {