From 9a0822c445e56580fb3034224191ec825ea0274a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Oct 2017 15:05:05 +0200 Subject: 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. --- options/tie.hpp | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'options/tie.hpp') 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& v, QComboBox* cb) v.SAFE_CONNTYPE); } -template -void tie_setting(value& v, QLabel* lb, const QString& format, const xs&... args) +template +void tie_setting(value& v, QLabel* lb, F&& fun) { - auto closure = [=](const t& x) { lb->setText(format.arg(x, args...)); }; + auto closure = [=](cv_qualified x) { lb->setText(fun(x)); }; closure(v()); - base_value::connect(&v, static_cast(&base_value::valueChanged), + base_value::connect(&v, base_value::signal_fun(), lb, closure, v.SAFE_CONNTYPE); } -template -decltype((void)((std::declval())(std::declval()))) -tie_setting(value& 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(&base_value::valueChanged), - lb, closure, - v.SAFE_CONNTYPE); -} - -template -decltype((void)((std::declval())(std::declval()))) -tie_setting(value& v, QLabel* lb, F&& fun) -{ - tie_setting(v, lb, fun, QStringLiteral("%1")); -} - OTR_OPTIONS_EXPORT void tie_setting(value& v, QComboBox* cb); OTR_OPTIONS_EXPORT void tie_setting(value& v, QComboBox* cb); OTR_OPTIONS_EXPORT void tie_setting(value& v, QComboBox* cb); -- cgit v1.2.3