From de1eb7aac2ba1ecc3be8acb60438ae9ae141b67a Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Thu, 7 Mar 2024 17:48:18 +0100
Subject: [PATCH] Data2DItem hold MasksSet instead of MasksQModel

---
 GUI/Model/Data/Data2DItem.cpp  | 8 ++++----
 GUI/Model/Data/Data2DItem.h    | 4 ++--
 GUI/View/Frame/Plot2DFrame.cpp | 4 ++--
 GUI/View/Setup/MasksPanel.cpp  | 5 ++---
 GUI/View/Setup/MasksPanel.h    | 6 +++---
 5 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/GUI/Model/Data/Data2DItem.cpp b/GUI/Model/Data/Data2DItem.cpp
index 6b696e3d922..f8033c8676d 100644
--- a/GUI/Model/Data/Data2DItem.cpp
+++ b/GUI/Model/Data/Data2DItem.cpp
@@ -312,18 +312,18 @@ void Data2DItem::readFrom(QXmlStreamReader* r)
 
 MasksSet* Data2DItem::masksSet()
 {
-    return m_model ? m_model->set() : nullptr;
+    return m_model.get();
 }
 
 const MasksSet* Data2DItem::masksSet() const
 {
-    return m_model ? m_model->set() : nullptr;
+    return m_model.get();
 }
 
-MasksQModel* Data2DItem::getOrCreateModel()
+MasksSet* Data2DItem::getOrCreateModel()
 {
     if (!m_model)
-        m_model = std::make_unique<MasksQModel>(new MasksSet);
+        m_model = std::make_unique<MasksSet>();
 
     return m_model.get();
 }
diff --git a/GUI/Model/Data/Data2DItem.h b/GUI/Model/Data/Data2DItem.h
index ff56df17c5b..1294b41f5d3 100644
--- a/GUI/Model/Data/Data2DItem.h
+++ b/GUI/Model/Data/Data2DItem.h
@@ -78,7 +78,7 @@ public:
 
     MasksSet* masksSet();
     const MasksSet* masksSet() const;
-    MasksQModel* getOrCreateModel();
+    MasksSet* getOrCreateModel();
     Datafield* createMaskedField() const;
 
     MasksSet* projectionsSet();
@@ -114,7 +114,7 @@ private:
     bool m_is_interpolated;
     std::unique_ptr<ComboProperty> m_gradient;
     std::unique_ptr<AmplitudeAxisItem> m_z_axis;
-    std::unique_ptr<MasksQModel> m_model;
+    std::unique_ptr<MasksSet> m_model;
     std::unique_ptr<MasksQModel> m_proj_model;
 };
 
diff --git a/GUI/View/Frame/Plot2DFrame.cpp b/GUI/View/Frame/Plot2DFrame.cpp
index b9ea961c6e6..43602eef0b6 100644
--- a/GUI/View/Frame/Plot2DFrame.cpp
+++ b/GUI/View/Frame/Plot2DFrame.cpp
@@ -15,7 +15,7 @@
 #include "GUI/View/Frame/Plot2DFrame.h"
 #include "Base/Util/Assert.h"
 #include "GUI/Model/Data/Data2DItem.h"
-#include "GUI/Model/Mask/MasksQModel.h"
+#include "GUI/Model/Mask/MasksSet.h"
 #include "GUI/Model/Project/ProjectDocument.h"
 #include "GUI/View/Canvas/MaskEditorCanvas.h"
 #include "GUI/View/Canvas/ProjectedGraphsCanvas.h"
@@ -92,7 +92,7 @@ Plot2DFrame::Plot2DFrame(Data2DItem* item)
 void Plot2DFrame::updateFrame()
 {
     ASSERT(m_data_item);
-    MasksQModel* masks_qmodel = m_data_item->getOrCreateModel();
+    MasksSet* masks_qmodel = m_data_item->getOrCreateModel();
     ASSERT(masks_qmodel);
     m_masks_panel->updateMasksPanel(masks_qmodel);
 
diff --git a/GUI/View/Setup/MasksPanel.cpp b/GUI/View/Setup/MasksPanel.cpp
index f4fa36c070d..3bf22f3fc6d 100644
--- a/GUI/View/Setup/MasksPanel.cpp
+++ b/GUI/View/Setup/MasksPanel.cpp
@@ -15,7 +15,6 @@
 #include "GUI/View/Setup/MasksPanel.h"
 #include "Fit/Param/RealLimits.h"
 #include "GUI/Model/Mask/MaskItems.h"
-#include "GUI/Model/Mask/MasksQModel.h"
 #include "GUI/Model/Mask/MasksSet.h"
 #include "GUI/Model/Project/ProjectDocument.h"
 #include "GUI/View/Layout/LayoutUtil.h"
@@ -81,11 +80,11 @@ QSize MasksPanel::minimumSizeHint() const
     return {128, 128};
 }
 
-void MasksPanel::updateMasksPanel(MasksQModel* masks_qmodel)
+void MasksPanel::updateMasksPanel(MasksSet* masks_qmodel)
 {
     m_qlistmodel = masks_qmodel;
 
-    m_qlistview->setModel(m_qlistmodel);
+    m_qlistview->setModel(m_qlistmodel->model());
     m_qlistview->setSelectionMode(QAbstractItemView::ExtendedSelection);
 }
 
diff --git a/GUI/View/Setup/MasksPanel.h b/GUI/View/Setup/MasksPanel.h
index 6fc9afc370a..7e372463f28 100644
--- a/GUI/View/Setup/MasksPanel.h
+++ b/GUI/View/Setup/MasksPanel.h
@@ -25,7 +25,7 @@
 
 class Data2DItem;
 class MaskItem;
-class MasksQModel;
+class MasksSet;
 
 //! Panel with list of masks and parameter editor for one selected mask.
 
@@ -37,7 +37,7 @@ public:
     QSize sizeHint() const override;
     QSize minimumSizeHint() const override;
 
-    void updateMasksPanel(MasksQModel* masks_qmodel);
+    void updateMasksPanel(MasksSet* masks_qmodel);
 
 private:
     //! Set the current mask and creates the UI to edit the mask's properties
@@ -48,7 +48,7 @@ private:
                          std::function<void(bool)> setter);
 
     QListView* m_qlistview;
-    MasksQModel* m_qlistmodel;
+    MasksSet* m_qlistmodel;
     QFormLayout* m_editor_layout;
     MaskItem* m_current_mask_item; //!< the mask item whose properties shall be edited
     bool m_keep_selection = false;
-- 
GitLab