X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientsettings.cpp;h=841035097dc1e30518160a00609aa9dba45e0cf7;hp=6f40a2354563ec15e2568a4a4e1968fb3090f85a;hb=23eed68958b7585552be04fab4e5871a781b7f38;hpb=44b22c4419f478a20f6324f9f3a700a2dec56302 diff --git a/src/client/clientsettings.cpp b/src/client/clientsettings.cpp index 6f40a235..84103509 100644 --- a/src/client/clientsettings.cpp +++ b/src/client/clientsettings.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -20,10 +20,11 @@ #include "client.h" #include "clientsettings.h" +#include "global.h" #include -ClientSettings::ClientSettings(QString g) : Settings(g) { +ClientSettings::ClientSettings(QString g) : Settings(g, Global::clientApplicationName) { } @@ -47,41 +48,56 @@ QVariant ClientSettings::sessionValue(const QString &key, const QVariant &def) { /***********************************************************************************************/ -AccountSettings::AccountSettings() : ClientSettings("Accounts") { +CoreAccountSettings::CoreAccountSettings() : ClientSettings("CoreAccounts") { } -QStringList AccountSettings::knownAccounts() { - return localChildGroups(); +QStringList CoreAccountSettings::knownAccounts() { + return localChildKeys("Accounts"); } -QString AccountSettings::lastAccount() { +QString CoreAccountSettings::lastAccount() { return localValue("LastAccount", "").toString(); } -void AccountSettings::setLastAccount(const QString &account) { +void CoreAccountSettings::setLastAccount(const QString &account) { setLocalValue("LastAccount", account); } -QString AccountSettings::autoConnectAccount() { +QString CoreAccountSettings::autoConnectAccount() { return localValue("AutoConnectAccount", "").toString(); } -void AccountSettings::setAutoConnectAccount(const QString &account) { +void CoreAccountSettings::setAutoConnectAccount(const QString &account) { setLocalValue("AutoConnectAccount", account); } -void AccountSettings::setValue(const QString &account, const QString &key, const QVariant &data) { - setLocalValue(QString("%1/%2").arg(account).arg(key), data); +void CoreAccountSettings::storeAccount(const QString name, const QVariantMap &data) { + setLocalValue(QString("Accounts/%2").arg(name), data); } -QVariant AccountSettings::value(const QString &account, const QString &key, const QVariant &def) { - return localValue(QString("%1/%2").arg(account).arg(key), def); +QVariantMap CoreAccountSettings::retrieveAccount(const QString &name) { + return localValue(QString("Accounts/%2").arg(name), QVariant()).toMap(); } -void AccountSettings::removeAccount(const QString &account) { - removeLocalKey(account); +void CoreAccountSettings::storeAllAccounts(const QHash accounts) { + removeLocalKey(QString("Accounts")); + foreach(QString name, accounts.keys()) { + storeAccount(name, accounts[name]); + } +} + +QHash CoreAccountSettings::retrieveAllAccounts() { + QHash accounts; + foreach(QString name, knownAccounts()) { + accounts[name] = retrieveAccount(name); + } + return accounts; +} + +void CoreAccountSettings::removeAccount(const QString &account) { + removeLocalKey(QString("Accounts/%1").arg(account)); }