/***************************************************************************
- * 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 *
#include "client.h"
#include "clientsettings.h"
+#include "global.h"
#include <QStringList>
-ClientSettings::ClientSettings(QString g) : Settings(g) {
-
-
+ClientSettings::ClientSettings(QString g) : Settings(g, Global::clientApplicationName) {
}
ClientSettings::~ClientSettings() {
+}
+/***********************************************************************************************/
+CoreAccountSettings::CoreAccountSettings(const QString &subgroup) : ClientSettings("CoreAccounts") {
+ _subgroup = subgroup;
}
-QStringList ClientSettings::sessionKeys() {
- return Client::sessionDataKeys();
+QList<AccountId> CoreAccountSettings::knownAccounts() {
+ QList<AccountId> ids;
+ foreach(QString key, localChildGroups()) {
+ AccountId acc = key.toInt();
+ if(acc.isValid()) ids << acc;
+ }
+ return ids;
}
-void ClientSettings::setSessionValue(const QString &key, const QVariant &data) {
- Client::storeSessionData(key, data);
+AccountId CoreAccountSettings::lastAccount() {
+ return localValue("LastAccount", 0).toInt();
}
-QVariant ClientSettings::sessionValue(const QString &key, const QVariant &def) {
- return Client::retrieveSessionData(key, def);
+void CoreAccountSettings::setLastAccount(AccountId account) {
+ setLocalValue("LastAccount", account.toInt());
}
-/***********************************************************************************************/
+AccountId CoreAccountSettings::autoConnectAccount() {
+ return localValue("AutoConnectAccount", 0).toInt();
+}
-AccountSettings::AccountSettings() : ClientSettings("Accounts") {
+void CoreAccountSettings::setAutoConnectAccount(AccountId account) {
+ setLocalValue("AutoConnectAccount", account.toInt());
+}
+void CoreAccountSettings::storeAccountData(AccountId id, const QVariantMap &data) {
+ setLocalValue(QString("%1/Connection").arg(id.toInt()), data);
+}
+QVariantMap CoreAccountSettings::retrieveAccountData(AccountId id) {
+ return localValue(QString("%1/Connection").arg(id.toInt()), QVariant()).toMap();
}
-QStringList AccountSettings::knownAccounts() {
- return localChildGroups();
+void CoreAccountSettings::setAccountValue(const QString &key, const QVariant &value) {
+ if(!Client::currentCoreAccount().isValid()) return;
+ setLocalValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().toInt()).arg(_subgroup).arg(key), value);
}
-QString AccountSettings::lastAccount() {
- return localValue("LastAccount", "").toString();
+QVariant CoreAccountSettings::accountValue(const QString &key, const QVariant &def) {
+ if(!Client::currentCoreAccount().isValid()) return QVariant();
+ return localValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().toInt()).arg(_subgroup).arg(key), def);
}
-void AccountSettings::setLastAccount(const QString &account) {
- setLocalValue("LastAccount", account);
+void CoreAccountSettings::setJumpKeyMap(const QHash<int, BufferId> &keyMap) {
+ QVariantMap variants;
+ QHash<int, BufferId>::const_iterator mapIter = keyMap.constBegin();
+ while(mapIter != keyMap.constEnd()) {
+ variants[QString::number(mapIter.key())] = qVariantFromValue(mapIter.value());
+ mapIter++;
+ }
+ setLocalValue("JumpKeyMap", variants);
}
-QString AccountSettings::autoConnectAccount() {
- return localValue("AutoConnectAccount", "").toString();
+QHash<int, BufferId> CoreAccountSettings::jumpKeyMap() {
+ QHash<int, BufferId> keyMap;
+ QVariantMap variants = localValue("JumpKeyMap", QVariant()).toMap();
+ QVariantMap::const_iterator mapIter = variants.constBegin();
+ while(mapIter != variants.constEnd()) {
+ keyMap[mapIter.key().toInt()] = mapIter.value().value<BufferId>();
+ mapIter++;
+ }
+ return keyMap;
}
-void AccountSettings::setAutoConnectAccount(const QString &account) {
- setLocalValue("AutoConnectAccount", account);
+void CoreAccountSettings::removeAccount(AccountId id) {
+ removeLocalKey(QString("%1").arg(id.toInt()));
}
-void AccountSettings::setValue(const QString &account, const QString &key, const QVariant &data) {
- setLocalValue(QString("%1/%2").arg(account).arg(key), data);
+
+/***********************************************************************************************/
+// NotificationSettings:
+
+NotificationSettings::NotificationSettings() : ClientSettings("Notification") {
}
-QVariant AccountSettings::value(const QString &account, const QString &key, const QVariant &def) {
- return localValue(QString("%1/%2").arg(account).arg(key), def);
+void NotificationSettings::setHighlightList(const QVariantList &highlightList) {
+ setLocalValue("highlightList", highlightList);
}
-void AccountSettings::removeAccount(const QString &account) {
- removeLocalKey(account);
+QVariantList NotificationSettings::highlightList() {
+ return localValue("highlightList").toList();
}
+void NotificationSettings::setHighlightNick(NotificationSettings::HighlightNickType highlightNickType) {
+ setLocalValue("highlightNick", highlightNickType);
+}
+NotificationSettings::HighlightNickType NotificationSettings::highlightNick() {
+ return (NotificationSettings::HighlightNickType) localValue("highlightNick", CurrentNick).toInt();
+}