diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-20 17:13:03 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-20 17:13:13 +0200 |
commit | 092e2910ae8f6c2e188e930b9540d58e145c9142 (patch) | |
tree | 7ea71d7246fea224e8fc66703cc39874b31f5d4f /options | |
parent | 2e778f953bf6efb71f0b000a9b930a245b3b11e0 (diff) |
options: allow for dud values
Diffstat (limited to 'options')
-rw-r--r-- | options/value.hpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/options/value.hpp b/options/value.hpp index e8c39445..099a8cb2 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -45,6 +45,9 @@ class value final : public base_value never_inline t get() const { + if (self_name.isEmpty()) + return def; + if (!b->contains(self_name) || b->get<QVariant>(self_name).type() == QVariant::Invalid) return def; @@ -57,8 +60,12 @@ public: never_inline t operator=(const t& datum) { + if (self_name.isEmpty()) + return def; + if (datum != get()) store(traits::to_storage(datum)); + return datum; } @@ -104,13 +111,15 @@ public: never_inline void reload() override { - *this = static_cast<t>(*this); + if (!self_name.isEmpty()) + *this = static_cast<t>(*this); } never_inline void bundle_value_changed() const override { - emit valueChanged(traits::to_storage(get())); + if (!self_name.isEmpty()) + emit valueChanged(traits::to_storage(get())); } never_inline |