[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [vidalia/alpha] Add volatile value handling to VSettings



commit f207eae3bf56a7c462190355089a23c74a5f846f
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Fri Feb 3 22:09:14 2012 -0300

    Add volatile value handling to VSettings
---
 src/vidalia/config/VSettings.cpp |   14 ++++++++++++++
 src/vidalia/config/VSettings.h   |    9 ++++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/vidalia/config/VSettings.cpp b/src/vidalia/config/VSettings.cpp
index aab0f9b..ca8cdd4 100644
--- a/src/vidalia/config/VSettings.cpp
+++ b/src/vidalia/config/VSettings.cpp
@@ -103,3 +103,17 @@ VSettings::allSettings() const
   return settings;
 }
 
+QVariant
+VSettings::volatileValue(const QString &key,
+                         const QVariant &defaultVal)
+{
+  if(_volatileSettings.count(key) == 0)
+    return defaultVal;
+  return _volatileSettings.value(key);
+}
+
+void
+VSettings::setVolatileValue(const QString &key, const QVariant &val)
+{
+  _volatileSettings.insert(key, val);
+}
diff --git a/src/vidalia/config/VSettings.h b/src/vidalia/config/VSettings.h
index ed31255..50357fc 100644
--- a/src/vidalia/config/VSettings.h
+++ b/src/vidalia/config/VSettings.h
@@ -57,9 +57,16 @@ protected:
    * point. */
   QMap<QString, QVariant> allSettings() const;
 
+  virtual QVariant volatileValue(const QString &key,
+                                 const QVariant &defaultVal = QVariant());
+  virtual void setVolatileValue(const QString &key, const QVariant &val);
+
 private:
   /** Association of setting key names to default setting values. */
-  QHash<QString, QVariant> _defaults; 
+  QHash<QString, QVariant> _defaults;
+
+  /** Stores values that last as long as Vidalia lives as a process */
+  QMap<QString, QVariant> _volatileSettings;
 };
 
 #endif



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits