From 57f45182ba3ef41a6b38a0c48aed3fa0718416b6 Mon Sep 17 00:00:00 2001 From: Joachim Wuttke <j.wuttke@fz-juelich.de> Date: Fri, 26 Jul 2024 12:33:18 +0200 Subject: [PATCH] rm 'using' --- GUI/Model/Job/ParameterTreeBuilder.cpp | 20 ++++++++++++++------ GUI/Model/Sample/Lattice2DCatalog.cpp | 4 ++-- GUI/Model/Sample/Lattice2DCatalog.h | 6 ++---- GUI/Model/Sample/ProfileCatalogs.cpp | 8 ++++---- GUI/Model/Sample/ProfileCatalogs.h | 12 ++++-------- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/GUI/Model/Job/ParameterTreeBuilder.cpp b/GUI/Model/Job/ParameterTreeBuilder.cpp index 96c223fd867..8488a6c0858 100644 --- a/GUI/Model/Job/ParameterTreeBuilder.cpp +++ b/GUI/Model/Job/ParameterTreeBuilder.cpp @@ -37,6 +37,14 @@ using std::variant; namespace { +template <typename BaseItem, typename Catalog> +ParameterLabelItem* addLabel2(ParameterLabelItem* parent, const QString& category, + const BaseItem* p) +{ + const auto title = category + " (" + Catalog::uiInfo(Catalog::type(p)).menuEntry + ")"; + return new ParameterLabelItem(title, parent); +} + template <typename Catalog> ParameterLabelItem* addLabel(ParameterLabelItem* parent, const QString& category, const typename Catalog::BaseItem* p) @@ -196,7 +204,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, addParameterItem(label, itf->kappa()); auto* pdf = itf->probabilityDistributionSelection().certainItem(); - auto* pdfLabel = addLabel<Profile1DCatalog>(label, "PDF", pdf); + auto* pdfLabel = addLabel2<Profile1DItem, Profile1DCatalog>(label, "PDF", pdf); for (auto* d : pdf->profileProperties()) addParameterItem(pdfLabel, *d); } else if (auto* itf = dynamic_cast<Interference2DParacrystalItem*>(interference)) { @@ -209,10 +217,10 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, auto* pdf1 = itf->probabilityDistributionSelection1().certainItem(); auto* pdf2 = itf->probabilityDistributionSelection2().certainItem(); const bool samePdfTypes = Profile2DCatalog::type(pdf1) == Profile2DCatalog::type(pdf2); - auto* pdf1Label = addLabel<Profile2DCatalog>(label, samePdfTypes ? "PDF1" : "PDF", pdf1); + auto* pdf1Label = addLabel2<Profile2DItem, Profile2DCatalog>(label, samePdfTypes ? "PDF1" : "PDF", pdf1); for (auto* d : pdf1->profileProperties()) addParameterItem(pdf1Label, *d); - auto* pdf2Label = addLabel<Profile2DCatalog>(label, samePdfTypes ? "PDF2" : "PDF", pdf2); + auto* pdf2Label = addLabel2<Profile2DItem, Profile2DCatalog>(label, samePdfTypes ? "PDF2" : "PDF", pdf2); for (auto* d : pdf2->profileProperties()) addParameterItem(pdf2Label, *d); } else if (auto* itf = dynamic_cast<Interference1DLatticeItem*>(interference)) { @@ -221,7 +229,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, addParameterItem(label, itf->rotationAngle()); auto* df = itf->decayFunctionSelection().certainItem(); - auto* dfLabel = addLabel<Profile1DCatalog>(label, "Decay function", df); + auto* dfLabel = addLabel2<Profile1DItem, Profile1DCatalog>(label, "Decay function", df); for (auto* d : df->profileProperties()) addParameterItem(dfLabel, *d); } else if (auto* itf = dynamic_cast<Interference2DLatticeItem*>(interference)) { @@ -229,7 +237,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, addLattice(label, itf); auto* df = itf->decayFunctionSelection().certainItem(); - auto* dfLabel = addLabel<Profile2DCatalog>(label, "Decay function", df); + auto* dfLabel = addLabel2<Profile2DItem, Profile2DCatalog>(label, "Decay function", df); for (auto* d : df->profileProperties()) addParameterItem(dfLabel, *d); } else if (auto* itf = dynamic_cast<InterferenceFinite2DLatticeItem*>(interference)) { @@ -293,7 +301,7 @@ void ParameterTreeBuilder::addLattice(ParameterLabelItem* parentLabel, const Interference2DAbstractLatticeItem* itf) { auto* lattice = itf->latticeTypeItem(); - auto* label = addLabel<Lattice2DCatalog>(parentLabel, "Lattice", lattice); + auto* label = addLabel2<Lattice2DItem, Lattice2DCatalog>(parentLabel, "Lattice", lattice); for (auto* d : lattice->geometryValues(!itf->xiIntegration())) addParameterItem(label, *d); } diff --git a/GUI/Model/Sample/Lattice2DCatalog.cpp b/GUI/Model/Sample/Lattice2DCatalog.cpp index d9ba0075857..27be73dda19 100644 --- a/GUI/Model/Sample/Lattice2DCatalog.cpp +++ b/GUI/Model/Sample/Lattice2DCatalog.cpp @@ -16,7 +16,7 @@ #include "Base/Util/Assert.h" #include "GUI/Model/Sample/Lattice2DItems.h" -Lattice2DCatalog::BaseItem* Lattice2DCatalog::create(Type type) +Lattice2DItem* Lattice2DCatalog::create(Type type) { switch (type) { case Type::Basic: @@ -49,7 +49,7 @@ UiInfo Lattice2DCatalog::uiInfo(Type type) } } -Lattice2DCatalog::Type Lattice2DCatalog::type(const BaseItem* item) +Lattice2DCatalog::Type Lattice2DCatalog::type(const Lattice2DItem* item) { ASSERT(item); diff --git a/GUI/Model/Sample/Lattice2DCatalog.h b/GUI/Model/Sample/Lattice2DCatalog.h index a2ab1493a78..e1963bb73f8 100644 --- a/GUI/Model/Sample/Lattice2DCatalog.h +++ b/GUI/Model/Sample/Lattice2DCatalog.h @@ -22,13 +22,11 @@ class Lattice2DItem; class Lattice2DCatalog { public: - using BaseItem = Lattice2DItem; - // Do not change the numbering! It is serialized! enum class Type : uint8_t { Basic = 1, Square = 2, Hexagonal }; //! Creates the item of the given type. - static BaseItem* create(Type type); + static Lattice2DItem* create(Type type); //! List of available types, sorted as expected in the UI. static QVector<Type> types(); @@ -37,7 +35,7 @@ public: static UiInfo uiInfo(Type t); //! Returns the enum type of the given item. - static Type type(const BaseItem* item); + static Type type(const Lattice2DItem* item); }; #endif // BORNAGAIN_GUI_MODEL_SAMPLE_LATTICE2DCATALOG_H diff --git a/GUI/Model/Sample/ProfileCatalogs.cpp b/GUI/Model/Sample/ProfileCatalogs.cpp index db1e736c73f..af63d4bdfaf 100644 --- a/GUI/Model/Sample/ProfileCatalogs.cpp +++ b/GUI/Model/Sample/ProfileCatalogs.cpp @@ -16,7 +16,7 @@ #include "Base/Util/Assert.h" #include "GUI/Model/Sample/ProfileItems.h" -Profile1DCatalog::BaseItem* Profile1DCatalog::create(Type type) +Profile1DItem* Profile1DCatalog::create(Type type) { switch (type) { case Type::Cauchy: @@ -61,7 +61,7 @@ UiInfo Profile1DCatalog::uiInfo(Type type) } } -Profile1DCatalog::Type Profile1DCatalog::type(const BaseItem* item) +Profile1DCatalog::Type Profile1DCatalog::type(const Profile1DItem* item) { ASSERT(item); @@ -82,7 +82,7 @@ Profile1DCatalog::Type Profile1DCatalog::type(const BaseItem* item) /* --------------------------------------------------------------------------------------------- */ -Profile2DCatalog::BaseItem* Profile2DCatalog::create(Type type) +Profile2DItem* Profile2DCatalog::create(Type type) { switch (type) { case Type::Cauchy: @@ -123,7 +123,7 @@ UiInfo Profile2DCatalog::uiInfo(Type type) } } -Profile2DCatalog::Type Profile2DCatalog::type(const BaseItem* item) +Profile2DCatalog::Type Profile2DCatalog::type(const Profile2DItem* item) { ASSERT(item); diff --git a/GUI/Model/Sample/ProfileCatalogs.h b/GUI/Model/Sample/ProfileCatalogs.h index fe762f4af43..f2684ba18a4 100644 --- a/GUI/Model/Sample/ProfileCatalogs.h +++ b/GUI/Model/Sample/ProfileCatalogs.h @@ -23,8 +23,6 @@ class Profile2DItem; class Profile1DCatalog { public: - using BaseItem = Profile1DItem; - // Do not change the numbering! It is serialized! enum class Type : uint8_t { Cauchy = 1, @@ -36,7 +34,7 @@ public: }; //! Creates the item of the given type. - static BaseItem* create(Type type); + static Profile1DItem* create(Type type); //! List of available types, sorted as expected in the UI. static QVector<Type> types(); @@ -45,18 +43,16 @@ public: static UiInfo uiInfo(Type t); //! Returns the enum type of the given item. - static Type type(const BaseItem* item); + static Type type(const Profile1DItem* item); }; class Profile2DCatalog { public: - using BaseItem = Profile2DItem; - // Do not change the numbering! It is serialized! enum class Type : uint8_t { Cauchy = 1, Gauss = 2, Gate = 3, Cone = 4, Voigt = 5 }; //! Creates the item of the given type. - static BaseItem* create(Type type); + static Profile2DItem* create(Type type); //! List of available types, sorted as expected in the UI. static QVector<Type> types(); @@ -65,7 +61,7 @@ public: static UiInfo uiInfo(Type t); //! Returns the enum type of the given item. - static Type type(const BaseItem* item); + static Type type(const Profile2DItem* item); }; #endif // BORNAGAIN_GUI_MODEL_SAMPLE_PROFILECATALOGS_H -- GitLab