From 33d24590f00dbfc15e8fabf4821462092b2b9231 Mon Sep 17 00:00:00 2001
From: Joachim Wuttke <j.wuttke@fz-juelich.de>
Date: Fri, 26 Jul 2024 08:15:57 +0200
Subject: [PATCH] merge private fct

---
 GUI/Model/Descriptor/PolyItem.h | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/GUI/Model/Descriptor/PolyItem.h b/GUI/Model/Descriptor/PolyItem.h
index ad6f81925e3..7f239e28df2 100644
--- a/GUI/Model/Descriptor/PolyItem.h
+++ b/GUI/Model/Descriptor/PolyItem.h
@@ -52,8 +52,6 @@ public:
     int currentIndex() const { return m_types.indexOf(Catalog::type(m_item.get())); }
 
 private:
-    void initFieldsAndSetter(const QString& label, const QString& tooltip);
-
     //! Reimplementable function to set currently selected option.
     std::function<void(int)> currentIndexSetter = nullptr;
 
@@ -73,25 +71,10 @@ private:
 template <typename C>
 void PolyItem<C>::simpleInit(const QString& label, const QString& tooltip,
                              typename C::Type currentType)
-{
-    initFieldsAndSetter(label, tooltip);
-    int index = C::types().indexOf(currentType);
-    setCurrentIndex(index);
-}
-
-//! Directly set the new item.
-template <typename C> template <typename S> S* PolyItem<C>::createCertainItem()
-{
-    auto* t = new S;
-    m_item.reset(t);
-    return t;
-}
-
-template <typename C>
-void PolyItem<C>::initFieldsAndSetter(const QString& label, const QString& tooltip)
 {
     m_label = label;
     m_tooltip = tooltip;
+
     m_menu_entries.clear();
     for (const auto type : m_types)
         m_menu_entries << C::uiInfo(type).menuEntry;
@@ -100,6 +83,17 @@ void PolyItem<C>::initFieldsAndSetter(const QString& label, const QString& toolt
         BaseItem* t = C::create(m_types[current]);
         m_item.reset(t);
     };
+
+    int index = C::types().indexOf(currentType);
+    setCurrentIndex(index);
+}
+
+//! Directly set the new item.
+template <typename C> template <typename S> S* PolyItem<C>::createCertainItem()
+{
+    auto* t = new S;
+    m_item.reset(t);
+    return t;
 }
 
 #endif // BORNAGAIN_GUI_MODEL_DESCRIPTOR_POLYITEM_H
-- 
GitLab