summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-09 08:51:25 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-09 15:00:58 +0200
commit6bc3fe31a3f354afc7be870a4a2d375ab6c746b6 (patch)
tree39b439b16cb872b3d982a6083a546456001d0f8e /options
parentcc6fc6577940df89c57db08743b181291c2a4b43 (diff)
add support for migrations
They're run from the UI thread so can even be interactive.
Diffstat (limited to 'options')
-rw-r--r--options/bundle.cpp10
-rw-r--r--options/bundle.hpp6
-rw-r--r--options/group.cpp4
-rw-r--r--options/group.hpp5
4 files changed, 17 insertions, 8 deletions
diff --git a/options/bundle.cpp b/options/bundle.cpp
index 48689720..61be509a 100644
--- a/options/bundle.cpp
+++ b/options/bundle.cpp
@@ -16,6 +16,10 @@ bundle::bundle(const QString& group_name)
{
}
+bundle::~bundle()
+{
+}
+
void bundle::reload()
{
if (group_name.size())
@@ -114,7 +118,7 @@ void bundler::bundle_decf(const bundler::k& key)
if (--std::get<0>(implsgl_data[key]) == 0)
{
- qDebug() << "bundle -" << key;
+ //qDebug() << "bundle -" << key;
implsgl_data.erase(key);
}
@@ -132,7 +136,7 @@ void bundler::after_profile_changed_()
mem<v> bundle_ = bundle.lock();
if (bundle_)
{
- qDebug() << "bundle: reverting" << kv.first << "due to profile change";
+ //qDebug() << "bundle: reverting" << kv.first << "due to profile change";
bundle_->reload();
}
}
@@ -163,7 +167,7 @@ std::shared_ptr<bundler::v> bundler::make_bundle(const bundler::k &key)
return shared;
}
- qDebug() << "bundle +" << key;
+ //qDebug() << "bundle +" << key;
std::shared_ptr<v> shr(new v(key), [this](v* val) { bundle_decf(val->name()); });
diff --git a/options/bundle.hpp b/options/bundle.hpp
index 20ec9eaa..3d75a8de 100644
--- a/options/bundle.hpp
+++ b/options/bundle.hpp
@@ -24,6 +24,8 @@ namespace options {
namespace detail {
+struct bundler;
+
class OPENTRACK_OPTIONS_EXPORT bundle final : public QObject, public virtual connector
{
class OPENTRACK_OPTIONS_EXPORT mutex final : public QMutex
@@ -35,6 +37,8 @@ class OPENTRACK_OPTIONS_EXPORT bundle final : public QObject, public virtual con
Q_OBJECT
private:
+ friend bundler;
+
mutex mtx;
const QString group_name;
group saved;
@@ -50,7 +54,7 @@ signals:
void changed() const;
public:
bundle(const QString& group_name);
- ~bundle() override {}
+ ~bundle() override;
QString name() { return group_name; }
void reload();
void store_kv(const QString& name, const QVariant& datum);
diff --git a/options/group.cpp b/options/group.cpp
index a2169ae5..69b79cef 100644
--- a/options/group.cpp
+++ b/options/group.cpp
@@ -72,7 +72,7 @@ QString group::ini_pathname()
return dir + "/" + ini_filename();
}
-const QStringList group::ini_list()
+QStringList group::ini_list()
{
const auto dirname = ini_directory();
if (dirname == "")
@@ -83,7 +83,7 @@ const QStringList group::ini_list()
return list;
}
-const std::shared_ptr<QSettings> group::ini_file()
+std::shared_ptr<QSettings> group::ini_file()
{
const auto pathname = ini_pathname();
if (pathname != "")
diff --git a/options/group.hpp b/options/group.hpp
index f76978ad..f5b3e523 100644
--- a/options/group.hpp
+++ b/options/group.hpp
@@ -17,6 +17,7 @@ class OPENTRACK_OPTIONS_EXPORT group final
QString name;
public:
std::map<QString, QVariant> kvs;
+ group(const QString& name, mem<QSettings> s);
group(const QString& name);
void save() const;
void save_deferred(QSettings& s) const;
@@ -25,8 +26,8 @@ public:
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();
+ static QStringList ini_list();
+ static std::shared_ptr<QSettings> ini_file();
template<typename t>
t get(const QString& k) const