From 18d4adfd7b17362164fb5a181246472f5031bb34 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Fri, 8 Dec 2023 10:34:33 +0100
Subject: [PATCH] rm most direct uses of QDoubleSpinBox

---
 GUI/View/Material/MaterialEditorDialog.cpp |  5 ++--
 GUI/View/Numeric/NumWidgetUtil.h           |  1 -
 GUI/View/Numeric/NumberUtil.cpp            | 27 ----------------------
 GUI/View/Numeric/NumberUtil.h              |  3 ---
 GUI/View/ParEdit/CustomEditors.cpp         |  2 +-
 GUI/View/Setup/Scale2DEditor.cpp           |  1 -
 6 files changed, 3 insertions(+), 36 deletions(-)

diff --git a/GUI/View/Material/MaterialEditorDialog.cpp b/GUI/View/Material/MaterialEditorDialog.cpp
index 9aeac23e377..b0b88fd28bd 100644
--- a/GUI/View/Material/MaterialEditorDialog.cpp
+++ b/GUI/View/Material/MaterialEditorDialog.cpp
@@ -27,7 +27,6 @@
 #include <QColorDialog>
 #include <QDialog>
 #include <QDialogButtonBox>
-#include <QDoubleSpinBox>
 #include <QFormLayout>
 #include <QGroupBox>
 #include <QHBoxLayout>
@@ -343,8 +342,8 @@ void MaterialEditorDialog::onSelectMaterial()
         m_sld_group->hide();
         for (auto* lineEdit : m_editor->findChildren<QLineEdit*>())
             lineEdit->clear();
-        for (auto* spinBox : m_editor->findChildren<QDoubleSpinBox*>())
-            spinBox->clear();
+        for (auto* spinBox : m_editor->findChildren<DoubleSpinBox*>())
+            spinBox->replaceProperty(nullptr);
         return;
     }
 
diff --git a/GUI/View/Numeric/NumWidgetUtil.h b/GUI/View/Numeric/NumWidgetUtil.h
index 1ad8733f89f..c19e70784ba 100644
--- a/GUI/View/Numeric/NumWidgetUtil.h
+++ b/GUI/View/Numeric/NumWidgetUtil.h
@@ -17,7 +17,6 @@
 
 #include "Fit/Param/RealLimits.h"
 #include <QCheckBox>
-#include <QDoubleSpinBox>
 #include <QFormLayout>
 #include <QSpinBox>
 #include <QString>
diff --git a/GUI/View/Numeric/NumberUtil.cpp b/GUI/View/Numeric/NumberUtil.cpp
index 590c3f8c75a..fca169aa52c 100644
--- a/GUI/View/Numeric/NumberUtil.cpp
+++ b/GUI/View/Numeric/NumberUtil.cpp
@@ -18,18 +18,6 @@
 #include "GUI/View/Numeric/ScientificSpinBox.h"
 #include <cmath>
 
-namespace {
-
-//! Single step for QDoubleSpinBox.
-double singleStep(int decimals)
-{
-    // For item with decimals=3 (i.e. 0.001) single step will be 0.1
-    return 1. / std::pow(10., decimals - 1);
-}
-
-} // namespace
-
-
 void GUI::View::NumberUtil::configScientificDoubleEdit(QLineEdit* edit, const RealLimits& limits)
 {
     auto* validator = new QDoubleValidator(0.0, 1e200, 1000, edit);
@@ -41,18 +29,3 @@ void GUI::View::NumberUtil::configScientificDoubleEdit(QLineEdit* edit, const Re
 
     edit->setValidator(validator);
 }
-
-void GUI::View::NumberUtil::configSpinBox(QDoubleSpinBox* spinBox, int decimals,
-                                          const RealLimits& limits)
-{
-    spinBox->setMaximum(std::numeric_limits<double>::max());
-    spinBox->setMinimum(std::numeric_limits<double>::lowest());
-
-    if (limits.hasLowerLimit())
-        spinBox->setMinimum(limits.min());
-    if (limits.hasUpperLimit())
-        spinBox->setMaximum(limits.max());
-
-    spinBox->setDecimals(decimals);
-    spinBox->setSingleStep(singleStep(decimals));
-}
diff --git a/GUI/View/Numeric/NumberUtil.h b/GUI/View/Numeric/NumberUtil.h
index 7f846cdc641..052518ff43c 100644
--- a/GUI/View/Numeric/NumberUtil.h
+++ b/GUI/View/Numeric/NumberUtil.h
@@ -15,7 +15,6 @@
 #ifndef BORNAGAIN_GUI_VIEW_NUMERIC_NUMBERUTIL_H
 #define BORNAGAIN_GUI_VIEW_NUMERIC_NUMBERUTIL_H
 
-#include <QDoubleSpinBox>
 #include <QLineEdit>
 
 class DoubleSpinBox;
@@ -26,8 +25,6 @@ namespace GUI::View::NumberUtil {
 
 void configScientificDoubleEdit(QLineEdit* edit, const RealLimits& limits);
 
-void configSpinBox(QDoubleSpinBox* spinBox, int decimals, const RealLimits& limits);
-
 } // namespace GUI::View::NumberUtil
 
 #endif // BORNAGAIN_GUI_VIEW_NUMERIC_NUMBERUTIL_H
diff --git a/GUI/View/ParEdit/CustomEditors.cpp b/GUI/View/ParEdit/CustomEditors.cpp
index 62bea657ef5..1a133fb4a97 100644
--- a/GUI/View/ParEdit/CustomEditors.cpp
+++ b/GUI/View/ParEdit/CustomEditors.cpp
@@ -23,7 +23,7 @@
 
 namespace {
 
-//! Single step for QDoubleSpinBox.
+//! Single step for ScientificSpinBoxEditor.
 
 double singleStep(int decimals)
 {
diff --git a/GUI/View/Setup/Scale2DEditor.cpp b/GUI/View/Setup/Scale2DEditor.cpp
index 16bbc3dea0c..105a0032e6c 100644
--- a/GUI/View/Setup/Scale2DEditor.cpp
+++ b/GUI/View/Setup/Scale2DEditor.cpp
@@ -23,7 +23,6 @@
 #include "GUI/View/Tool/LayoutUtil.h"
 #include "GUI/View/Widget/GroupBoxes.h"
 #include <QCheckBox>
-#include <QDoubleSpinBox>
 #include <QFormLayout>
 #include <QLineEdit>
 
-- 
GitLab