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

shorter template arg name

parent 014ea8e9
No related branches found
No related tags found
1 merge request!2364rename SelectionProperty -> PolyItem
......@@ -47,11 +47,10 @@ public:
//! The current selection will be initialized with the first type in the catalog types. The
//! optional arguments are the arguments which may be necessary for the creation method in the
//! catalog.
template <typename... ArgsForCreation>
void initWithArgs(const QString& label, const QString& tooltip,
typename Catalog::Type currentType, ArgsForCreation... argsForCreation)
template <typename... Args> void initWithArgs(const QString& label, const QString& tooltip,
typename Catalog::Type currentType, Args... args)
{
initFieldsAndSetter(label, tooltip, argsForCreation...);
initFieldsAndSetter(label, tooltip, args...);
int index = Catalog::types().indexOf(currentType);
setCurrentIndex(index);
}
......@@ -87,14 +86,10 @@ public:
CatalogedType* certainItem() const { return m_p.get(); }
//! Directly set the new item.
void setCertainItem(CatalogedType* t)
{
m_p.reset(t);
}
void setCertainItem(CatalogedType* t) { m_p.reset(t); }
//! Directly set the new item.
template <typename S>
S* setCertainItem()
template <typename S> S* setCertainItem()
{
auto* s = new S();
if (s != nullptr && m_initializer)
......@@ -119,15 +114,14 @@ public:
//! Deserializes the catalog index of the currently selected type, creates a new
//! object of this type and calls main deserialization method of the selected class.
template <typename... ArgsForCreation>
void readFrom(QXmlStreamReader* r, ArgsForCreation... argsForCreation)
template <typename... Args> void readFrom(QXmlStreamReader* r, Args... args)
{
const uint sel_ver = XML::readUIntAttribute(r, XML::Attrib::selection_version);
Q_UNUSED(sel_ver)
const uint typeIndex = XML::readUIntAttribute(r, XML::Attrib::type);
const auto type = static_cast<typename Catalog::Type>(typeIndex);
auto* p = Catalog::create(type, argsForCreation...);
auto* p = Catalog::create(type, args...);
if (p) {
if (m_initializer)
m_initializer(p, m_p.get());
......@@ -144,9 +138,8 @@ public:
int currentIndex() const { return m_types.indexOf(Catalog::type(m_p.get())); }
private:
template <typename... ArgsForCreation>
void initFieldsAndSetter(const QString& label, const QString& tooltip,
ArgsForCreation... argsForCreation)
template <typename... Args>
void initFieldsAndSetter(const QString& label, const QString& tooltip, Args... args)
{
m_label = label;
m_tooltip = tooltip;
......@@ -154,8 +147,8 @@ private:
for (const auto type : m_types)
m_options << Catalog::uiInfo(type).menuEntry;
currentIndexSetter = [this, argsForCreation...](int current) {
auto* p = Catalog::create(m_types[current], argsForCreation...);
currentIndexSetter = [this, args...](int current) {
auto* p = Catalog::create(m_types[current], args...);
if (m_initializer)
m_initializer(p, m_p.get());
m_p.reset(p);
......
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