Reworking highlighting a bit
[quassel.git] / src / client / clientsettings.cpp
index 2bf6412..3120078 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
+#include <QStringList>
+
 #include "client.h"
 #include "clientsettings.h"
-#include "global.h"
+#include "quassel.h"
 
-#include <QStringList>
-
-ClientSettings::ClientSettings(QString g) : Settings(g, Global::clientApplicationName) {
+ClientSettings::ClientSettings(QString g) : Settings(g, Quassel::buildInfo().clientApplicationName) {
 }
 
 ClientSettings::~ClientSettings() {
@@ -39,7 +39,8 @@ CoreAccountSettings::CoreAccountSettings(const QString &subgroup) : ClientSettin
 QList<AccountId> CoreAccountSettings::knownAccounts() {
   QList<AccountId> ids;
   foreach(QString key, localChildGroups()) {
-    ids << key.toInt();
+    AccountId acc = key.toInt();
+    if(acc.isValid()) ids << acc;
   }
   return ids;
 }
@@ -78,21 +79,58 @@ QVariant CoreAccountSettings::accountValue(const QString &key, const QVariant &d
   return localValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().toInt()).arg(_subgroup).arg(key), def);
 }
 
+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);
+}
+
+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 CoreAccountSettings::removeAccount(AccountId id) {
   removeLocalKey(QString("%1").arg(id.toInt()));
 }
 
+
 /***********************************************************************************************/
+// NotificationSettings:
+
+NotificationSettings::NotificationSettings() : ClientSettings("Notification") {
+}
+
+void NotificationSettings::setHighlightList(const QVariantList &highlightList) {
+  setLocalValue("highlightList", highlightList);
+}
+
+QVariantList NotificationSettings::highlightList() {
+  return localValue("highlightList").toList();
+}
+
+void NotificationSettings::setHighlightNick(NotificationSettings::HighlightNickType highlightNickType) {
+  setLocalValue("highlightNick", highlightNickType);
+}
 
-BufferSettings::BufferSettings(BufferId bufferId)
-  : CoreAccountSettings(QString("Buffers/%1").arg(bufferId.toInt()))
-{
+NotificationSettings::HighlightNickType NotificationSettings::highlightNick() {
+  return (NotificationSettings::HighlightNickType) localValue("highlightNick", CurrentNick).toInt();
 }
 
-void BufferSettings::setLastSeen(QDateTime seenDate) {
-  setAccountValue("LastSeen", seenDate);
+void NotificationSettings::setNicksCaseSensitive(bool cs) {
+  setLocalValue("Highlights/NicksCaseSensitive", cs);
 }
 
-QDateTime BufferSettings::lastSeen() {
-  return accountValue("LastSeen", QDateTime()).value<QDateTime>();
+bool NotificationSettings::nicksCaseSensitive() {
+  return localValue("Highlights/NicksCaseSensitive", true).toBool();
 }