From d3aac3ed3b9bd65b8ca4cdffd0c4f09fabbc583d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jun 2016 21:51:37 +0200 Subject: compat/options: slider_value improvements - a comparison operator. Qt uses it with the metatype support. - pretty print support for QDebug --- opentrack-compat/options.hpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'opentrack-compat/options.hpp') diff --git a/opentrack-compat/options.hpp b/opentrack-compat/options.hpp index 76f36146..af36ea08 100644 --- a/opentrack-compat/options.hpp +++ b/opentrack-compat/options.hpp @@ -58,14 +58,11 @@ namespace options { double cur_, min_, max_; public: - slider_value(double cur, double min, double max) : - cur_(cur), - min_(min), - max_(max) - {} - slider_value(const slider_value& v) : slider_value(v.cur(), v.min(), v.max()) {} - slider_value() : slider_value(0, 0, 0) {} - slider_value& operator=(const slider_value& v) { cur_ = v.cur_; min_ = v.min_; max_ = v.max_; return *this; } + slider_value(double cur, double min, double max); + slider_value(const slider_value& v); + slider_value(); + slider_value& operator=(const slider_value& v); + bool operator==(const slider_value& v) const; operator double() const; double cur() const { return cur_; } double min() const { return min_; } @@ -73,12 +70,13 @@ namespace options }; } -Q_DECLARE_METATYPE(options::slider_value) +QDebug operator << (QDebug dbg, const options::slider_value& val); QDataStream& operator << (QDataStream& out, const options::slider_value& v); - QDataStream& operator >> (QDataStream& in, options::slider_value& v); +Q_DECLARE_METATYPE(options::slider_value) + namespace options { namespace { class custom_type_initializer @@ -258,7 +256,9 @@ namespace options { *this = def; } - value(pbundle b, const char* name, t def) : value(b, QString(name), def) {} + value(pbundle b, const char* name, t def) : value(b, QString(name), def) + { + } operator t() const { @@ -313,7 +313,8 @@ namespace options { v(v), cb(cb), enum_cases(enum_cases) - {} + { + } void operator()(int idx) { @@ -334,7 +335,8 @@ namespace options { v(v), cb(cb), enum_cases(enum_cases) - {} + { + } void operator()(int val) { -- cgit v1.2.3