From a12705d2e5f32bc04a68857e9c8e51b9f8126f19 Mon Sep 17 00:00:00 2001 From: Matthias Puchner <github@mpuchner.de> Date: Fri, 22 Oct 2021 12:08:08 +0200 Subject: [PATCH] use AbstractSelectionDescriptor --- GUI/Models/ItemWithParticles.cpp | 4 ++-- GUI/Models/ParticleLayoutItem.cpp | 4 ++-- GUI/Views/SampleDesigner/SampleEditorController.cpp | 5 +++++ GUI/Views/SampleDesigner/SampleEditorController.h | 7 ++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/GUI/Models/ItemWithParticles.cpp b/GUI/Models/ItemWithParticles.cpp index 2955bb49b23..84bd20420e0 100644 --- a/GUI/Models/ItemWithParticles.cpp +++ b/GUI/Models/ItemWithParticles.cpp @@ -103,14 +103,14 @@ SelectionDescriptor<RotationItem*> ItemWithParticles::rotationMethod() d.currentItem = [=]() -> RotationItem* { return rotationItem(); }; - d.setCurrentIndex = [=](int current) { + d.currentIndexSetter = [=](int current) { if (auto item = getItem(T_TRANSFORMATION)) model()->removeItem(item); if (current > 0) createTransformationItem()->setRotationType(map[current].second); }; - d.currentIndex = [=]() { + d.currentIndexGetter = [=]() { auto item = rotationItem(); if (item == nullptr) return 0; diff --git a/GUI/Models/ParticleLayoutItem.cpp b/GUI/Models/ParticleLayoutItem.cpp index b1babb1589c..de0d5f97deb 100644 --- a/GUI/Models/ParticleLayoutItem.cpp +++ b/GUI/Models/ParticleLayoutItem.cpp @@ -129,7 +129,7 @@ SelectionDescriptor<InterferenceItem*> ParticleLayoutItem::interference() const d.currentItem = [=] { return dynamic_cast<InterferenceItem*>(getItem(T_INTERFERENCE)); }; - d.setCurrentIndex = [=](int current) { + d.currentIndexSetter = [=](int current) { if (auto item = getItem(T_INTERFERENCE)) model()->removeItem(item); if (current > 0) @@ -137,7 +137,7 @@ SelectionDescriptor<InterferenceItem*> ParticleLayoutItem::interference() const T_INTERFERENCE); }; - d.currentIndex = [=]() { + d.currentIndexGetter = [=]() { if (auto item = dynamic_cast<InterferenceItem*>(getItem(T_INTERFERENCE))) for (int i = 1; i < map.size(); i++) if (map[i].second == item->modelType()) diff --git a/GUI/Views/SampleDesigner/SampleEditorController.cpp b/GUI/Views/SampleDesigner/SampleEditorController.cpp index 1f281a688b8..d54b9181348 100644 --- a/GUI/Views/SampleDesigner/SampleEditorController.cpp +++ b/GUI/Views/SampleDesigner/SampleEditorController.cpp @@ -226,6 +226,11 @@ void SampleEditorController::setInt(int newValue, UIntDescriptor d) d.set(newValue); } +void SampleEditorController::setCurrentIndex(int index, const AbstractSelectionDescriptor& d) +{ + d.setCurrentIndex(index); +} + QUndoStack* SampleEditorController::undoStack() { return &m_undoStack; diff --git a/GUI/Views/SampleDesigner/SampleEditorController.h b/GUI/Views/SampleDesigner/SampleEditorController.h index 8cc63bb025f..838b0ac34a0 100644 --- a/GUI/Views/SampleDesigner/SampleEditorController.h +++ b/GUI/Views/SampleDesigner/SampleEditorController.h @@ -29,6 +29,7 @@ class ParticleCompositionItem; class DoubleDescriptor; class UIntDescriptor; class ItemWithMaterial; +class AbstractSelectionDescriptor; //! Class to modify a sample from the layer oriented sample editor. //! @@ -72,11 +73,7 @@ public: void setDoubleFromUndo(double newValue, const QString& path); void setInt(int newValue, UIntDescriptor d); - template <typename SelectionDescriptorClass> - void setCurrentIndex(int index, SelectionDescriptorClass d) - { - d.setCurrentIndex(index); - } + void setCurrentIndex(int index, const AbstractSelectionDescriptor& d); void selectMaterial(ItemWithMaterial* item, const QString& newMaterialIdentifier); void setMaterialValue(ItemWithMaterial* item, double newValue, DoubleDescriptor d); -- GitLab