From c131280809d6ac54cbb6114bef79a40ee7a77fe7 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Wed, 7 Dec 2022 11:46:49 +0100
Subject: [PATCH] SelectionProperty: add fields from Descriptor

---
 GUI/Model/Descriptor/SelectionProperty.h | 23 +++++++++++++++++++++--
 GUI/Model/Device/BeamItems.h             |  1 -
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/GUI/Model/Descriptor/SelectionProperty.h b/GUI/Model/Descriptor/SelectionProperty.h
index e35dd80d43b..d72def48916 100644
--- a/GUI/Model/Descriptor/SelectionProperty.h
+++ b/GUI/Model/Descriptor/SelectionProperty.h
@@ -61,6 +61,7 @@ public:
     template <typename... ArgsForCreation>
     void init(const QString& label, const QString& tooltip, ArgsForCreation... argsForCreation)
     {
+        initFields(label, tooltip);
         initDescriptor(label, tooltip, argsForCreation...);
         m_descriptor.setCurrentIndex(0);
     }
@@ -82,6 +83,7 @@ public:
     {
         m_initializer = initializer;
 
+        initFields(label, tooltip);
         initDescriptor(label, tooltip);
         m_descriptor.setCurrentIndex(0);
     }
@@ -106,6 +108,7 @@ public:
         m_initializer = initializer;
         m_types = types;
 
+        initFields(label, tooltip);
         initDescriptor(label, tooltip);
         m_descriptor.setCurrentIndex(0);
     }
@@ -141,9 +144,9 @@ public:
     template <typename... ArgsForCreation>
     void rwSelected(Streamer& s, const QString& tag, ArgsForCreation... argsForCreation)
     {
-        if (QXmlStreamWriter* w = s.xmlWriter()) {
+        if (s.xmlWriter()) {
             s.write<Catalog>(tag, m_p.get());
-        } else if (QXmlStreamReader* r = s.xmlReader()) {
+        } else if (s.xmlReader()) {
             CatalogedType* p = nullptr;
             s.read<Catalog>(tag, p, argsForCreation...);
             m_p.reset(p);
@@ -151,6 +154,14 @@ public:
     }
 
 private:
+    void initFields(const QString& label, const QString& tooltip) {
+        m_label = label;
+        m_tooltip = tooltip;
+        m_options.clear();
+        for (const auto type : m_types)
+            m_options << Catalog::uiInfo(type).menuEntry;
+
+    }
     template <typename... ArgsForCreation>
     void initDescriptor(const QString& label, const QString& tooltip,
                         ArgsForCreation... argsForCreation)
@@ -174,12 +185,20 @@ private:
         m_descriptor.currentItem = [=] { return m_p.get(); };
     }
 
+    QString label() {return m_label;}
+    QString tooltip() {return m_tooltip;}
+    QStringList options() {return m_options;}
+    CatalogedType* currentItem() {return m_p.get();}
+
 private:
     SelectionDescriptor<CatalogedType*>
         m_descriptor; //!< descriptor, holding attributes like label, tooltip
 
     std::unique_ptr<CatalogedType> m_p; //!< Current selection
 
+    QString m_label;       //!< A label text (short, no trailing colon)
+    QString m_tooltip;     //!< Tooltip text
+    QStringList m_options; //!< List of options, usually presented as combo entries
     QVector<typename Catalog::Type> m_types = Catalog::types();
 
     //! initializer function. Can be empty.
diff --git a/GUI/Model/Device/BeamItems.h b/GUI/Model/Device/BeamItems.h
index d781482fd0b..6de0b398146 100644
--- a/GUI/Model/Device/BeamItems.h
+++ b/GUI/Model/Device/BeamItems.h
@@ -16,7 +16,6 @@
 #define BORNAGAIN_GUI_MODEL_DEVICE_BEAMITEMS_H
 
 #include "GUI/Model/CatDevice/FootprintItemCatalog.h"
-#include "GUI/Model/Descriptor/SelectionDescriptor.h"
 #include "GUI/Model/Descriptor/SelectionProperty.h"
 #include "GUI/Model/Device/BeamAngleItems.h"
 #include "GUI/Model/Device/BeamWavelengthItem.h"
-- 
GitLab