summaryrefslogtreecommitdiffhomepage
path: root/options/group.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-17 21:28:45 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-17 21:34:53 +0200
commitcb33be1c50b68d6022f344ddac923c7aac3a11d5 (patch)
tree1840e3f9829aa69f10f81804f655e97be3f2eca8 /options/group.hpp
parent41ba8aa5329c16a797140dc23650ef45f42753a3 (diff)
move options framework into its own library
- adjust usages - add support for QList signals and metatype
Diffstat (limited to 'options/group.hpp')
-rw-r--r--options/group.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/options/group.hpp b/options/group.hpp
new file mode 100644
index 00000000..0deddfa8
--- /dev/null
+++ b/options/group.hpp
@@ -0,0 +1,42 @@
+#pragma once
+
+#include "export.hpp"
+#include <map>
+#include <memory>
+#include <QString>
+#include <QList>
+#include <QVariant>
+#include <QSettings>
+
+namespace options {
+
+// snapshot of qsettings group at given time
+class OPENTRACK_OPTIONS_EXPORT group final
+{
+private:
+ std::map<QString, QVariant> kvs;
+ QString name;
+public:
+ group(const QString& name);
+ void save() const;
+ void put(const QString& s, const QVariant& d);
+ bool contains(const QString& s) const;
+ static QString ini_directory();
+ static QString ini_filename();
+ static QString ini_pathname();
+ static const QStringList ini_list();
+ static const std::shared_ptr<QSettings> ini_file();
+ bool operator==(const group& other) const;
+ bool operator!=(const group& other) const { return !(*this == other); }
+
+ template<typename t>
+ t get(const QString& k) const
+ {
+ auto value = kvs.find(k);
+ if (value != kvs.cend())
+ return value->second.value<t>();
+ return t();
+ }
+};
+
+}