From 74dff816c07737b7e697e5d63222e59a9fefe23e Mon Sep 17 00:00:00 2001
From: Stanislaw Halik <sthalik@misaki.pl>
Date: Fri, 1 Jul 2022 15:42:26 +0200
Subject: compat/macros: move cv_qualified to options/

---
 options/base-value.hpp   | 1 +
 options/tie.hpp          | 4 ++--
 options/value-traits.hpp | 5 +++++
 3 files changed, 8 insertions(+), 2 deletions(-)

(limited to 'options')

diff --git a/options/base-value.hpp b/options/base-value.hpp
index d0fa42cf..eb8c89b7 100644
--- a/options/base-value.hpp
+++ b/options/base-value.hpp
@@ -26,6 +26,7 @@ class OTR_OPTIONS_EXPORT value_ : public QObject
 {
     Q_OBJECT
 
+    template<typename t> using cv_qualified = detail::cv_qualified<t>;
     template<typename t>
     using signal_sig = void(value_::*)(cv_qualified<t>) const;
 
diff --git a/options/tie.hpp b/options/tie.hpp
index 5cd8cbbc..46ade075 100644
--- a/options/tie.hpp
+++ b/options/tie.hpp
@@ -56,14 +56,14 @@ void tie_setting(value<t>& v, QComboBox* cb, From&& fn_to_index, To&& fn_to_valu
                     &v, [&v, cb, fn_to_value](int idx) { v = fn_to_value(idx, cb->currentData()); },
                     v.DIRECT_CONNTYPE);
     value_::connect(&v, value_::value_changed<t>(),
-                    cb, [cb, fn_to_index](cv_qualified<t>& v) { cb->setCurrentIndex(fn_to_index(v)); },
+                    cb, [cb, fn_to_index](detail::cv_qualified<t>& v) { cb->setCurrentIndex(fn_to_index(v)); },
                     v.DIRECT_CONNTYPE);
 }
 
 template<typename t, typename F>
 void tie_setting(value<t>& v, QLabel* lb, F&& fun)
 {
-    auto closure = [lb, fun](cv_qualified<t> v) { lb->setText(fun(v)); };
+    auto closure = [lb, fun](detail::cv_qualified<t> v) { lb->setText(fun(v)); };
 
     closure(v());
     value_::connect(&v, value_::value_changed<t>(),
diff --git a/options/value-traits.hpp b/options/value-traits.hpp
index 308e110c..145cd924 100644
--- a/options/value-traits.hpp
+++ b/options/value-traits.hpp
@@ -9,6 +9,11 @@
 #include <QString>
 
 namespace options::detail {
+template<typename t>
+using cv_qualified =
+    std::conditional_t<std::is_fundamental_v<std::remove_cvref_t<t>>,
+                       std::remove_cvref_t<t>,
+                       std::add_lvalue_reference_t<std::add_const_t<std::remove_cvref_t<t>>>>;
 
 template<typename t, typename u = t, typename Enable = void>
 struct default_value_traits
-- 
cgit v1.2.3