summaryrefslogtreecommitdiffhomepage
path: root/options/value-traits.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-07-08 23:29:49 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-07-08 23:29:49 +0200
commitfa1801471c2708ed8266ec7b99bd4cec886ccc1b (patch)
treeaa56218c2c7e4939aaf11a2046b0f12760326545 /options/value-traits.hpp
parent90940a774eab876c38d5cef981b4be5bae67a462 (diff)
options: fix 2 issues
1. Calling valueChanged didn't invoke machinery in value<t>, only base_value aka value_. There's a fast path in value<t>::type() despite the pessimization. 2. Split global scope stuff into options::globals from the options::globals stuff 3. Adjust usages
Diffstat (limited to 'options/value-traits.hpp')
-rw-r--r--options/value-traits.hpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/options/value-traits.hpp b/options/value-traits.hpp
index b507874c..1c98f3e9 100644
--- a/options/value-traits.hpp
+++ b/options/value-traits.hpp
@@ -18,9 +18,19 @@ struct default_value_traits
using stored_type = std::decay_t<t>;
using value_type = std::decay_t<u>;
- static inline value_type from_value(const value_type& val, const value_type&) { return val; }
- static inline value_type from_storage(const stored_type& x) { return static_cast<value_type>(x); }
- static inline stored_type to_storage(const value_type& val) { return static_cast<stored_type>(val); }
+ static value_type from_value(const value_type& val, const value_type&) { return val; }
+ static value_type from_storage(const stored_type& x) { return static_cast<value_type>(x); }
+ static stored_type to_storage(const value_type& val) { return static_cast<stored_type>(val); }
+
+ static value_type value_from_variant(const QVariant& x)
+ {
+ return from_storage(storage_from_variant(x));
+ }
+
+ static stored_type storage_from_variant(const QVariant& x)
+ {
+ return x.value<stored_type>();
+ }
};
template<typename t, typename u = t, typename Enable = void>