From fa1801471c2708ed8266ec7b99bd4cec886ccc1b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 8 Jul 2018 23:29:49 +0200 Subject: options: fix 2 issues 1. Calling valueChanged didn't invoke machinery in value, only base_value aka value_. There's a fast path in value::type() despite the pessimization. 2. Split global scope stuff into options::globals from the options::globals stuff 3. Adjust usages --- options/value-traits.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'options/value-traits.hpp') 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; using value_type = std::decay_t; - 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(x); } - static inline stored_type to_storage(const value_type& val) { return static_cast(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(x); } + static stored_type to_storage(const value_type& val) { return static_cast(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(); + } }; template -- cgit v1.2.3