From a0c05d51bd3549556c8f7ba5cbf8a06a959e7774 Mon Sep 17 00:00:00 2001 From: Joachim Wuttke <j.wuttke@fz-juelich.de> Date: Fri, 26 Jul 2024 11:42:54 +0200 Subject: [PATCH] start PolyBase - reference in ISelectionForm no longer templated --- GUI/Model/Descriptor/PolyPtr.h | 21 +++++++++++++++------ GUI/View/Sample/ISelectionForm.h | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/GUI/Model/Descriptor/PolyPtr.h b/GUI/Model/Descriptor/PolyPtr.h index 98bcd3c8405..867922676a2 100644 --- a/GUI/Model/Descriptor/PolyPtr.h +++ b/GUI/Model/Descriptor/PolyPtr.h @@ -19,7 +19,16 @@ //! Holds a polymorphous item. Possible types of the item are specified by a Catalog. -template <typename Catalog> class PolyPtr { +class PolyBase { +public: + virtual QString piLabel() const = 0; + virtual QString piTooltip() const = 0; + virtual QStringList menuEntries() const = 0; + virtual void setCurrentIndex(int index) = 0; + virtual int currentIndex() const = 0; +}; + +template <typename Catalog> class PolyPtr : public PolyBase { public: using BaseItem = typename Catalog::BaseItem; @@ -43,12 +52,12 @@ public: m_item.reset(XML::readItemFrom<Catalog>(r, args...)); } - QString piLabel() const { return m_label; } - QString piTooltip() const { return m_tooltip; } - QStringList menuEntries() const { return m_menu_entries; } + QString piLabel() const override { return m_label; } + QString piTooltip() const override { return m_tooltip; } + QStringList menuEntries() const override { return m_menu_entries; } - void setCurrentIndex(int index) { m_item.reset(Catalog::create(m_types[index])); } - int currentIndex() const { return m_types.indexOf(Catalog::type(m_item.get())); } + void setCurrentIndex(int index) override { m_item.reset(Catalog::create(m_types[index])); } + int currentIndex() const override { return m_types.indexOf(Catalog::type(m_item.get())); } private: std::unique_ptr<BaseItem> m_item; //!< Current selection diff --git a/GUI/View/Sample/ISelectionForm.h b/GUI/View/Sample/ISelectionForm.h index fe6ff7db730..10d923ea758 100644 --- a/GUI/View/Sample/ISelectionForm.h +++ b/GUI/View/Sample/ISelectionForm.h @@ -56,7 +56,7 @@ protected: m_grid_layout->addWidget(m_combo, 1, 0); createContent(); } - template <typename T> void initUI(PolyPtr<T>& d) + void initUI(PolyBase& d) { m_grid_layout = new QGridLayout(this); m_grid_layout->setContentsMargins(0, 0, 0, 0); -- GitLab