summaryrefslogtreecommitdiffhomepage
path: root/options/tie.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-10-13 15:05:05 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-10-13 15:09:26 +0200
commit9a0822c445e56580fb3034224191ec825ea0274a (patch)
tree9fce6a93bb72a0db6b60015b58272abe0fba68ba /options/tie.hpp
parent887dd41c5d67c30bd1e9631920d8fc1c3dd1a3f0 (diff)
options/tie: change "tie" overloads
Adjust usages. There are ODR issues with MSVC and it doesn't support C++17 "static inline constexpr" _variables_. Otherwise, "signal_fun" could be a variable and not a function. The usages in accela/ewma2 dialog are more verbose now but the original API was silly.
Diffstat (limited to 'options/tie.hpp')
-rw-r--r--options/tie.hpp27
1 files changed, 4 insertions, 23 deletions
diff --git a/options/tie.hpp b/options/tie.hpp
index 92e98680..0a4ace74 100644
--- a/options/tie.hpp
+++ b/options/tie.hpp
@@ -52,36 +52,17 @@ tie_setting(value<t>& v, QComboBox* cb)
v.SAFE_CONNTYPE);
}
-template<typename t, typename... xs>
-void tie_setting(value<t>& v, QLabel* lb, const QString& format, const xs&... args)
+template<typename t, typename F>
+void tie_setting(value<t>& v, QLabel* lb, F&& fun)
{
- auto closure = [=](const t& x) { lb->setText(format.arg(x, args...)); };
+ auto closure = [=](cv_qualified<t> x) { lb->setText(fun(x)); };
closure(v());
- base_value::connect(&v, static_cast<void(base_value::*)(const t&) const>(&base_value::valueChanged),
+ base_value::connect(&v, base_value::signal_fun<t>(),
lb, closure,
v.SAFE_CONNTYPE);
}
-template<typename t, typename F, typename... xs>
-decltype((void)((std::declval<F>())(std::declval<const t&>())))
-tie_setting(value<t>& v, QLabel* lb, F&& fun, const QString& fmt, const xs&... args)
-{
- auto closure = [=](const t& x) { lb->setText(fmt.arg(fun(x), args...)); };
-
- closure(v());
- base_value::connect(&v, static_cast<void(base_value::*)(const t&) const>(&base_value::valueChanged),
- lb, closure,
- v.SAFE_CONNTYPE);
-}
-
-template<typename t, typename F, typename... xs>
-decltype((void)((std::declval<F>())(std::declval<const t&>())))
-tie_setting(value<t>& v, QLabel* lb, F&& fun)
-{
- tie_setting(v, lb, fun, QStringLiteral("%1"));
-}
-
OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QComboBox* cb);
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QComboBox* cb);
OTR_OPTIONS_EXPORT void tie_setting(value<QVariant>& v, QComboBox* cb);