summaryrefslogtreecommitdiffhomepage
path: root/options/value.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-18 14:53:00 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-18 17:05:13 +0200
commita18ca7764abbe24b601885ef06fcc98f0b7ed10b (patch)
tree1381ca22c6b2e68f5e43f0443435863eb3578c77 /options/value.hpp
parent132a1925340bcd75a88f831a3487044736dccb4a (diff)
options: factor out connector out of bundle
Diffstat (limited to 'options/value.hpp')
-rw-r--r--options/value.hpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/options/value.hpp b/options/value.hpp
index d09924c5..4d067af1 100644
--- a/options/value.hpp
+++ b/options/value.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "connector.hpp"
+
#include "bundle.hpp"
#include "slider.hpp"
#include <type_traits>
@@ -17,7 +19,7 @@ template<> struct value_type_traits<QString> { using type = const QString&; };
template<> struct value_type_traits<slider_value> { using type = const slider_value&; };
template<typename u> struct value_type_traits<QList<u>>
{
- using type = const QList<typename std::remove_const<typename std::remove_reference<u>::type>::type>&;
+ using type = const QList<u>&;
};
template<typename t> using value_type_t = typename value_type_traits<t>::type;
}
@@ -27,7 +29,10 @@ class OPENTRACK_OPTIONS_EXPORT base_value : public QObject
Q_OBJECT
public:
QString name() const { return self_name; }
- base_value(bundle b, const QString& name) : b(b), self_name(name) {}
+ base_value(bundle b, const QString& name) : b(b), self_name(name)
+ {
+ b->on_bundle_created(name, this);
+ }
signals:
OPENTRACK_DEFINE_SIGNAL(double);
OPENTRACK_DEFINE_SIGNAL(float);
@@ -52,7 +57,6 @@ protected:
void store(const t& datum)
{
b->store_kv(self_name, QVariant::fromValue(datum));
- emit valueChanged(static_cast<detail::value_type_t<t>>(datum));
}
void store(float datum)
@@ -77,6 +81,7 @@ public slots:
OPENTRACK_DEFINE_SLOT(const QList<QPointF>&)
public slots:
virtual void reload() = 0;
+ virtual void bundle_value_changed() const = 0;
};
namespace detail {
@@ -159,6 +164,11 @@ public:
*this = static_cast<t>(*this);
}
+ void bundle_value_changed() const override
+ {
+ emit valueChanged(static_cast<detail::value_type_t<t>>(get()));
+ }
+
private:
t def;
};