From 0e94b5e425dfaf39462a747bcf275f3ec089708c Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Thu, 1 Dec 2022 11:53:39 +0100
Subject: [PATCH] WidgetUtils: DoubleDesctoptor --> DoubleProperty

---
 GUI/View/Common/DoubleSpinBox.h |  2 +-
 GUI/View/Tool/WidgetUtils.cpp   | 17 ++++++++---------
 GUI/View/Tool/WidgetUtils.h     |  8 ++++----
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/GUI/View/Common/DoubleSpinBox.h b/GUI/View/Common/DoubleSpinBox.h
index 75390ca6f17..4b55286fdd0 100644
--- a/GUI/View/Common/DoubleSpinBox.h
+++ b/GUI/View/Common/DoubleSpinBox.h
@@ -14,7 +14,7 @@
 
 #ifndef BORNAGAIN_GUI_VIEW_COMMON_DOUBLESPINBOX_H
 #define BORNAGAIN_GUI_VIEW_COMMON_DOUBLESPINBOX_H
-#include "GUI/Model/Descriptor/DoubleDescriptor.h"
+#include "GUI/Model/Descriptor/DoubleProperty.h"
 #include <QDoubleSpinBox>
 
 //! SpinBox for DoubleDescriptors, supporting units.
diff --git a/GUI/View/Tool/WidgetUtils.cpp b/GUI/View/Tool/WidgetUtils.cpp
index f1fd0b7554a..2cef9206300 100644
--- a/GUI/View/Tool/WidgetUtils.cpp
+++ b/GUI/View/Tool/WidgetUtils.cpp
@@ -54,12 +54,11 @@ QComboBox* GUI::Util::createComboBox(function<ComboProperty()> comboFunction,
     return combo;
 }
 
-DoubleSpinBox* GUI::Util::createDoubleSpinBoxRow(QFormLayout* parentLayout,
-                                                 const DoubleDescriptor& d,
+DoubleSpinBox* GUI::Util::createDoubleSpinBoxRow(QFormLayout* parentLayout, const DoubleProperty& d,
                                                  function<void(double)> slot)
 {
     auto* sb = new DoubleSpinBox(d);
-    parentLayout->addRow(labelWithUnit(d.label, d.unit) + ":", sb);
+    parentLayout->addRow(labelWithUnit(d.label(), d.unit()) + ":", sb);
 
     if (slot)
         QObject::connect(sb, &DoubleSpinBox::baseValueChanged, [=](int v) { slot(v); });
@@ -78,22 +77,22 @@ QString GUI::Util::labelWithUnit(const QString& label, variant<QString, Unit> un
     return label;
 }
 
-QString GUI::Util::labelWithUnit(const DoubleDescriptor& d)
+QString GUI::Util::labelWithUnit(const DoubleProperty& d)
 {
-    return labelWithUnit(d.label, d.unit);
+    return labelWithUnit(d.label(), d.unit());
 }
 
 ScientificSpinBox* GUI::Util::createScientificSpinBox(QFormLayout* parentLayout,
-                                                      const DoubleDescriptor& d,
+                                                      const DoubleProperty& d,
                                                       function<void(double)> slot)
 {
     auto* spinBox = new ScientificSpinBox(parentLayout->parentWidget());
     spinBox->setFocusPolicy(Qt::StrongFocus);
-    GUI::View::EditUtil::configSpinbox(spinBox, d.decimals, d.limits);
-    spinBox->setToolTip(d.tooltip);
+    GUI::View::EditUtil::configSpinbox(spinBox, d.decimals(), d.limits());
+    spinBox->setToolTip(d.tooltip());
     spinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     spinBox->setValue(d.get());
-    parentLayout->addRow(labelWithUnit(d.label, d.unit) + ":", spinBox);
+    parentLayout->addRow(labelWithUnit(d.label(), d.unit()) + ":", spinBox);
 
     if (slot)
         QObject::connect(spinBox, &ScientificSpinBox::valueChanged, [=](double v) { slot(v); });
diff --git a/GUI/View/Tool/WidgetUtils.h b/GUI/View/Tool/WidgetUtils.h
index d5dd31598c0..97adb1b6089 100644
--- a/GUI/View/Tool/WidgetUtils.h
+++ b/GUI/View/Tool/WidgetUtils.h
@@ -26,7 +26,7 @@ class QSpinBox;
 class QCheckBox;
 class DoubleSpinBox;
 class QDoubleSpinBox;
-class DoubleDescriptor;
+class DoubleProperty;
 class QFormLayout;
 class ScientificSpinBox;
 
@@ -102,7 +102,7 @@ QComboBox* createComboBoxFromDescriptor(SelectionDescriptor<T> d,
 //! will *not* be notified to the descriptor. The additional (and optional) slot can be used to be
 //! notified about a value change (the notified new value is in the base unit of the
 //! DoubleDescriptor).
-DoubleSpinBox* createDoubleSpinBoxRow(QFormLayout* parentLayout, const DoubleDescriptor& d,
+DoubleSpinBox* createDoubleSpinBoxRow(QFormLayout* parentLayout, const DoubleProperty& d,
                                       std::function<void(double)> slot = nullptr);
 
 //! Create a label and a scientific spin box with the information found in a DoubleDescriptor and
@@ -116,7 +116,7 @@ DoubleSpinBox* createDoubleSpinBoxRow(QFormLayout* parentLayout, const DoubleDes
 //! No connections to update the descriptor will be established! Therefore changes in the spin box
 //! will *not* be notified to the descriptor. The additional (and optional) slot can be used to be
 //! notified about a value change.
-ScientificSpinBox* createScientificSpinBox(QFormLayout* parentLayout, const DoubleDescriptor& d,
+ScientificSpinBox* createScientificSpinBox(QFormLayout* parentLayout, const DoubleProperty& d,
                                            std::function<void(double)> slot = nullptr);
 
 //! Create a label with an optional unit in brackets.
@@ -127,7 +127,7 @@ QString labelWithUnit(const QString& label, std::variant<QString, Unit> unit);
 //! Create a label with an optional unit in brackets, both taken from the given descriptor.
 //!
 //! No trailing ':' will be appended
-QString labelWithUnit(const DoubleDescriptor& d);
+QString labelWithUnit(const DoubleProperty& d);
 
 //! Creates an updatable checkbox
 QCheckBox* createCheckBox(const QString& title, std::function<bool()> getter,
-- 
GitLab