Skip to content
Snippets Groups Projects
Commit a88cbb68 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

mv members

parent a0c05d51
No related branches found
No related tags found
1 merge request!2696PolyItem -> PolyPtr, with BaseItem as separate template parameter
......@@ -17,17 +17,23 @@
#include "GUI/Model/Util/UtilXML.h"
//! Holds a polymorphous item. Possible types of the item are specified by a Catalog.
class PolyBase {
public:
virtual QString piLabel() const = 0;
virtual QString piTooltip() const = 0;
virtual QStringList menuEntries() const = 0;
QString piLabel() const { return m_label; }
QString piTooltip() const { return m_tooltip; }
QStringList menuEntries() const { return m_menu_entries; }
virtual void setCurrentIndex(int index) = 0;
virtual int currentIndex() const = 0;
protected:
QString m_label; //!< A label text (short, no trailing colon)
QString m_tooltip; //!< Tooltip text
QStringList m_menu_entries; //!< List of options, usually presented as combo entries
};
//! Holds a polymorphous item. Possible types of the item are specified by a Catalog.
template <typename Catalog> class PolyPtr : public PolyBase {
public:
using BaseItem = typename Catalog::BaseItem;
......@@ -52,19 +58,12 @@ public:
m_item.reset(XML::readItemFrom<Catalog>(r, args...));
}
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) 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
QString m_label; //!< A label text (short, no trailing colon)
QString m_tooltip; //!< Tooltip text
QStringList m_menu_entries; //!< List of options, usually presented as combo entries
QVector<typename Catalog::Type> m_types = Catalog::types();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment