From ee0dd3b6d5ad2b6083372f4e4f0cb57a45aaaff2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 26 Jun 2018 22:52:18 +0200 Subject: options/base-value: rename to `value_' --- options/base-value.cpp | 10 ++++----- options/base-value.hpp | 16 ++++++++------- options/bundle.cpp | 4 ++-- options/bundle.hpp | 2 +- options/connector.hpp | 6 +++--- options/tie.cpp | 56 +++++++++++++++++++++++++------------------------- options/tie.hpp | 12 +++++------ options/value.hpp | 4 ++-- 8 files changed, 56 insertions(+), 54 deletions(-) (limited to 'options') diff --git a/options/base-value.cpp b/options/base-value.cpp index 6c287321..dbeabbea 100644 --- a/options/base-value.cpp +++ b/options/base-value.cpp @@ -2,7 +2,7 @@ using namespace options; -base_value::base_value(bundle b, const QString& name, base_value::comparator cmp, std::type_index type_idx) : +value_::value_(bundle b, const QString& name, value_::comparator cmp, std::type_index type_idx) : b(b), self_name(name), cmp(cmp), @@ -11,17 +11,17 @@ base_value::base_value(bundle b, const QString& name, base_value::comparator cmp b->on_value_created(name, this); } -base_value::~base_value() +value_::~value_() { b->on_value_destructed(self_name, this); } -void base_value::notify() const +void value_::notify() const { bundle_value_changed(); } -void base_value::store(const QVariant& datum) +void value_::store(const QVariant& datum) { b->store_kv(self_name, datum); } @@ -29,7 +29,7 @@ void base_value::store(const QVariant& datum) namespace options { namespace detail { -void set_base_value_to_default(base_value* val) +void set_base_value_to_default(value_* val) { val->set_to_default(); } diff --git a/options/base-value.hpp b/options/base-value.hpp index b094d693..5b924ab3 100644 --- a/options/base-value.hpp +++ b/options/base-value.hpp @@ -3,9 +3,10 @@ #include "bundle.hpp" #include "slider.hpp" #include "connector.hpp" +#include "metatype.hpp" #include "export.hpp" -#include "compat/meta.hpp" +#include "compat/macros.hpp" #include #include @@ -20,7 +21,7 @@ namespace options { -class OTR_OPTIONS_EXPORT base_value : public QObject +class OTR_OPTIONS_EXPORT value_ : public QObject { Q_OBJECT @@ -28,20 +29,20 @@ class OTR_OPTIONS_EXPORT base_value : public QObject using comparator = bool(*)(const QVariant& val1, const QVariant& val2); template - using signal_sig = void(base_value::*)(cv_qualified) const; + using signal_sig = void(value_::*)(cv_qualified) const; public: bundle get_bundle() { return b; } QString name() const { return self_name; } - base_value(bundle b, const QString& name, comparator cmp, std::type_index type_idx); - ~base_value() override; + value_(bundle b, const QString& name, comparator cmp, std::type_index type_idx); + ~value_() override; // MSVC has ODR problems in 15.4 // no C++17 "constexpr inline" for data declarations in MSVC template constexpr static auto value_changed() { - return static_cast>(&base_value::valueChanged); + return static_cast>(&value_::valueChanged); } void notify() const; @@ -63,6 +64,7 @@ signals: OPENTRACK_DEFINE_SIGNAL(const QList&); OPENTRACK_DEFINE_SIGNAL(const QList&); OPENTRACK_DEFINE_SIGNAL(const QList&); + protected: bundle b; QString self_name; @@ -98,7 +100,7 @@ public slots: virtual void bundle_value_changed() const = 0; virtual void set_to_default() = 0; - friend void ::options::detail::set_base_value_to_default(base_value* val); + friend void ::options::detail::set_base_value_to_default(value_* val); }; } //ns options diff --git a/options/bundle.cpp b/options/bundle.cpp index 4a133402..e0db3fb3 100644 --- a/options/bundle.cpp +++ b/options/bundle.cpp @@ -12,7 +12,7 @@ #include #include -using options::base_value; +using options::value_; namespace options { @@ -53,7 +53,7 @@ void bundle::set_all_to_default() { QMutexLocker l(&mtx); - forall([](const QString&, base_value* val) { set_base_value_to_default(val); }); + forall([](const QString&, value_* val) { set_base_value_to_default(val); }); if (is_modified()) group::mark_ini_modified(); diff --git a/options/bundle.hpp b/options/bundle.hpp index 3ab6f74a..98e194db 100644 --- a/options/bundle.hpp +++ b/options/bundle.hpp @@ -31,7 +31,7 @@ namespace options { namespace detail { -void set_base_value_to_default(base_value* val); +void set_base_value_to_default(value_* val); struct bundler; diff --git a/options/connector.hpp b/options/connector.hpp index 5091ae67..68e86096 100644 --- a/options/connector.hpp +++ b/options/connector.hpp @@ -22,15 +22,15 @@ namespace options { -class base_value; +class value_; namespace detail { class OTR_OPTIONS_EXPORT connector { - friend class ::options::base_value; + friend class ::options::value_; - using value_type = base_value*; + using value_type = value_*; using value_vec = std::vector; using comparator = bool(*)(const QVariant&, const QVariant&); using tt = std::tuple; diff --git a/options/tie.cpp b/options/tie.cpp index 0042a0fb..9de3df4c 100644 --- a/options/tie.cpp +++ b/options/tie.cpp @@ -15,16 +15,16 @@ OTR_OPTIONS_EXPORT void tie_setting(value& v, QComboBox* cb) { cb->setCurrentIndex(v); v = cb->currentIndex(); - base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE); + value_::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); + value_::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE); } OTR_OPTIONS_EXPORT void tie_setting(value& v, QComboBox* cb) { cb->setCurrentText(v); v = cb->currentText(); - base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(const QString&)), v.DIRECT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(const QString&)), cb, SLOT(setCurrentText(const QString&)), v.SAFE_CONNTYPE); + value_::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(const QString&)), v.DIRECT_CONNTYPE); + value_::connect(&v, SIGNAL(valueChanged(const QString&)), cb, SLOT(setCurrentText(const QString&)), v.SAFE_CONNTYPE); } OTR_OPTIONS_EXPORT void tie_setting(value& v, QComboBox* cb) @@ -52,13 +52,13 @@ OTR_OPTIONS_EXPORT void tie_setting(value& v, QComboBox* cb) else v = QVariant(QVariant::Invalid); - base_value::connect(cb, static_cast(&QComboBox::currentIndexChanged), - &v, [cb, &v](int idx) { + value_::connect(cb, static_cast(&QComboBox::currentIndexChanged), + &v, [cb, &v](int idx) { v = cb->itemData(idx); }, v.DIRECT_CONNTYPE); - base_value::connect(&v, base_value::value_changed(), - cb, - [cb, set_idx](const QVariant& var) { + value_::connect(&v, value_::value_changed(), + cb, + [cb, set_idx](const QVariant& var) { run_in_thread_sync(cb, [&] { set_idx(var); }); @@ -70,42 +70,42 @@ OTR_OPTIONS_EXPORT void tie_setting(value& v, QComboBox* cb) OTR_OPTIONS_EXPORT void tie_setting(value& v, QCheckBox* cb) { cb->setChecked(v); - base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.DIRECT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.SAFE_CONNTYPE); + value_::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.DIRECT_CONNTYPE); + value_::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.SAFE_CONNTYPE); } OTR_OPTIONS_EXPORT void tie_setting(value& v, QDoubleSpinBox* dsb) { dsb->setValue(v); - base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.DIRECT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.SAFE_CONNTYPE); + value_::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.DIRECT_CONNTYPE); + value_::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.SAFE_CONNTYPE); } OTR_OPTIONS_EXPORT void tie_setting(value& v, QSpinBox* sb) { sb->setValue(v); - base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.SAFE_CONNTYPE); + value_::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); + value_::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.SAFE_CONNTYPE); } OTR_OPTIONS_EXPORT void tie_setting(value& v, QLineEdit* le) { le->setText(v); - base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.DIRECT_CONNTYPE); - base_value::connect(&v, base_value::value_changed(), le, &QLineEdit::setText, v.SAFE_CONNTYPE); + value_::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.DIRECT_CONNTYPE); + value_::connect(&v, value_::value_changed(), le, &QLineEdit::setText, v.SAFE_CONNTYPE); } OTR_OPTIONS_EXPORT void tie_setting(value& v, QLabel* lb) { lb->setText(v); - base_value::connect(&v, base_value::value_changed(), lb, &QLabel::setText, v.SAFE_CONNTYPE); + value_::connect(&v, value_::value_changed(), lb, &QLabel::setText, v.SAFE_CONNTYPE); } OTR_OPTIONS_EXPORT void tie_setting(value& v, QTabWidget* t) { t->setCurrentIndex(v); - base_value::connect(t, SIGNAL(currentChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), t, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE); + value_::connect(t, SIGNAL(currentChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); + value_::connect(&v, SIGNAL(valueChanged(int)), t, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE); } OTR_OPTIONS_EXPORT void tie_setting(value& v, QSlider* w) @@ -118,10 +118,10 @@ OTR_OPTIONS_EXPORT void tie_setting(value& v, QSlider* w) v = v().update_from_slider(w->value(), q_min, q_max); } - base_value::connect(w, - &QSlider::valueChanged, - &v, - [=, &v](int pos) + value_::connect(w, + &QSlider::valueChanged, + &v, + [=, &v](int pos) { run_in_thread_sync(w, [&]() { @@ -133,10 +133,10 @@ OTR_OPTIONS_EXPORT void tie_setting(value& v, QSlider* w) }, v.DIRECT_CONNTYPE); - base_value::connect(&v, - base_value::value_changed(), - w, - [=, &v](double) { + value_::connect(&v, + value_::value_changed(), + w, + [=, &v](double) { run_in_thread_sync(w, [=, &v]() { const int q_min = w->minimum(); diff --git a/options/tie.hpp b/options/tie.hpp index ff82142e..59fd0da1 100644 --- a/options/tie.hpp +++ b/options/tie.hpp @@ -37,7 +37,7 @@ std::enable_if_t> tie_setting(value& v, QComboBox* cb) cb->setCurrentIndex(cb->findData(int(static_cast(v)))); v = static_cast(cb->currentData().toInt()); - base_value::connect(cb, + value_::connect(cb, static_cast(&QComboBox::currentIndexChanged), &v, [&v, cb](int idx) { run_in_thread_sync(cb, [&] { @@ -46,7 +46,7 @@ std::enable_if_t> tie_setting(value& v, QComboBox* cb) }, v.DIRECT_CONNTYPE); - base_value::connect(&v, base_value::value_changed(), + value_::connect(&v, value_::value_changed(), cb, [cb](int x) { run_in_thread_sync(cb, [=] { cb->setCurrentIndex(cb->findData(x)); }); }, @@ -59,13 +59,13 @@ void tie_setting(value& v, QComboBox* cb, From&& fn_to_index, To&& fn_to_valu cb->setCurrentIndex(fn_to_index(v)); v = fn_to_value(cb->currentIndex(), cb->currentData()); - base_value::connect(cb, static_cast(&QComboBox::currentIndexChanged), + value_::connect(cb, static_cast(&QComboBox::currentIndexChanged), &v, [&v, cb, fn_to_value](int idx) { run_in_thread_sync(cb, [&] { v = fn_to_value(idx, cb->currentData()); }); }, v.DIRECT_CONNTYPE); - base_value::connect(&v, base_value::value_changed(), + value_::connect(&v, value_::value_changed(), cb, [&v, cb, fn_to_index](cv_qualified& v) { run_in_thread_sync(cb, [&] { cb->setCurrentIndex(fn_to_index(v)); @@ -79,7 +79,7 @@ void tie_setting(value& v, QLabel* lb, F&& fun) auto closure = [=](cv_qualified x) { lb->setText(fun(x)); }; closure(v()); - base_value::connect(&v, base_value::value_changed(), + value_::connect(&v, value_::value_changed(), lb, closure, v.SAFE_CONNTYPE); } @@ -92,7 +92,7 @@ void tie_setting(value& v, QObject* obj, F&& fun) fun(v()); - base_value::connect(&v, base_value::value_changed(), + value_::connect(&v, value_::value_changed(), obj, fun, v.DIRECT_CONNTYPE); } diff --git a/options/value.hpp b/options/value.hpp index 42e72e50..f1e44677 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -32,7 +32,7 @@ namespace options { template -class value final : public base_value +class value final : public value_ { using traits = detail::value_traits; using stored_type = typename traits::stored_type; @@ -76,7 +76,7 @@ public: cc_noinline value(bundle b, const QString& name, t def) : - base_value(b, name, &is_equal, std::type_index(typeid(stored_type))), + value_(b, name, &is_equal, std::type_index(typeid(stored_type))), def(def) { if (!self_name.isEmpty()) -- cgit v1.2.3