summaryrefslogtreecommitdiffhomepage
path: root/opentrack-compat/options.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-12 21:51:37 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-14 18:14:46 +0200
commitd3aac3ed3b9bd65b8ca4cdffd0c4f09fabbc583d (patch)
tree766de6dc53eba6b511ff395a2a4ff18fbd4af98d /opentrack-compat/options.hpp
parentf4667d5cc9fbe8a5a65df136736a347c1fb37fd0 (diff)
compat/options: slider_value improvements
- a comparison operator. Qt uses it with the metatype support. - pretty print support for QDebug
Diffstat (limited to 'opentrack-compat/options.hpp')
-rw-r--r--opentrack-compat/options.hpp28
1 files changed, 15 insertions, 13 deletions
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)
{