From c808b1ccca4bd9f304e3a0a5a35aafa0a54363e3 Mon Sep 17 00:00:00 2001 From: Matthias Puchner <github@mpuchner.de> Date: Mon, 29 Nov 2021 15:02:42 +0100 Subject: [PATCH] rm obsolete MaterialModelStore --- GUI/Model/Material/MaterialModel.cpp | 9 ---- GUI/Model/Material/MaterialModel.h | 1 - GUI/Model/Material/MaterialModelStore.cpp | 46 ------------------- GUI/Model/Material/MaterialModelStore.h | 30 ------------ GUI/Model/Sample/ItemWithMaterial.cpp | 1 - .../MaterialEditor/MaterialEditorDialog.cpp | 1 - .../SampleDesigner/MaterialInplaceForm.cpp | 1 - 7 files changed, 89 deletions(-) delete mode 100644 GUI/Model/Material/MaterialModelStore.cpp delete mode 100644 GUI/Model/Material/MaterialModelStore.h diff --git a/GUI/Model/Material/MaterialModel.cpp b/GUI/Model/Material/MaterialModel.cpp index 80ade671442..9a6eb9099db 100644 --- a/GUI/Model/Material/MaterialModel.cpp +++ b/GUI/Model/Material/MaterialModel.cpp @@ -14,7 +14,6 @@ #include "GUI/Model/Material/MaterialModel.h" #include "GUI/Model/Material/MaterialItem.h" -#include "GUI/Model/Material/MaterialModelStore.h" #include <QColor> #include <QUuid> #include <random> @@ -47,14 +46,6 @@ MaterialModel::MaterialModel(QObject* parent) : SessionModel(GUI::Session::XML::MaterialModelTag, parent) { setObjectName(GUI::Session::XML::MaterialModelTag); - if (GUI::Model::MaterialModelStore::materialModel() == nullptr) - GUI::Model::MaterialModelStore::subscribe(this); -} - -MaterialModel::~MaterialModel() -{ - if (GUI::Model::MaterialModelStore::materialModel() == this) - GUI::Model::MaterialModelStore::unsubscribe(this); } void MaterialModel::clear() diff --git a/GUI/Model/Material/MaterialModel.h b/GUI/Model/Material/MaterialModel.h index 4d85a090259..cc7d3676185 100644 --- a/GUI/Model/Material/MaterialModel.h +++ b/GUI/Model/Material/MaterialModel.h @@ -24,7 +24,6 @@ class MaterialModel : public SessionModel { public: explicit MaterialModel(QObject* parent = nullptr); - ~MaterialModel() override; void clear() override; diff --git a/GUI/Model/Material/MaterialModelStore.cpp b/GUI/Model/Material/MaterialModelStore.cpp deleted file mode 100644 index 86d0f9d84a1..00000000000 --- a/GUI/Model/Material/MaterialModelStore.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Model/Material/MaterialModelStore.cpp -//! @brief Implements namespace MaterialModelStore -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/Model/Material/MaterialModelStore.h" -#include "GUI/Util/Error.h" - -namespace { -MaterialModel* theMaterialModel = nullptr; -} - -namespace GUI::Model::MaterialModelStore { - -MaterialModel* materialModel() -{ - return theMaterialModel; -} - -void subscribe(MaterialModel* materialModel) -{ - if (theMaterialModel != nullptr) - throw Error("GUI::Model::MaterialModelStore::subscribe() -> Error. Attempt to subscribe " - "MaterialModel twice."); - - theMaterialModel = materialModel; -} - -void unsubscribe(MaterialModel* materialModel) -{ - if (theMaterialModel != materialModel) - throw Error("GUI::Model::MaterialModelStore::unsubscribe -> Error. Attempt to unsubscribe " - "MaterialModel before it was subscribed."); - - theMaterialModel = nullptr; -} -} // namespace GUI::Model::MaterialModelStore diff --git a/GUI/Model/Material/MaterialModelStore.h b/GUI/Model/Material/MaterialModelStore.h deleted file mode 100644 index 8af46ae41f9..00000000000 --- a/GUI/Model/Material/MaterialModelStore.h +++ /dev/null @@ -1,30 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Model/Material/MaterialModelStore.h -//! @brief Defines namespace GUI::Model::MaterialModelStore -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODELSTORE_H -#define BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODELSTORE_H - -class MaterialModel; - -//! The MaterialModelStore holds an instance of the MaterialModel class - -namespace GUI::Model::MaterialModelStore { - -MaterialModel* materialModel(); -void subscribe(MaterialModel* materialModel); -void unsubscribe(MaterialModel* materialModel); - -} // namespace GUI::Model::MaterialModelStore - -#endif // BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODELSTORE_H diff --git a/GUI/Model/Sample/ItemWithMaterial.cpp b/GUI/Model/Sample/ItemWithMaterial.cpp index e649f1fd42d..2a78c677afc 100644 --- a/GUI/Model/Sample/ItemWithMaterial.cpp +++ b/GUI/Model/Sample/ItemWithMaterial.cpp @@ -18,7 +18,6 @@ #include "GUI/Model/Material/MaterialItem.h" #include "GUI/Model/Material/MaterialItemContainer.h" #include "GUI/Model/Material/MaterialModel.h" -#include "GUI/Model/Material/MaterialModelStore.h" #include <QColor> void ItemWithMaterial::setMaterial(const MaterialItem* materialItem) diff --git a/GUI/View/MaterialEditor/MaterialEditorDialog.cpp b/GUI/View/MaterialEditor/MaterialEditorDialog.cpp index 6bef3d85162..2299291f3e6 100644 --- a/GUI/View/MaterialEditor/MaterialEditorDialog.cpp +++ b/GUI/View/MaterialEditor/MaterialEditorDialog.cpp @@ -16,7 +16,6 @@ #include "GUI/Application/ApplicationSettings.h" #include "GUI/Model/Material/MaterialItem.h" #include "GUI/Model/Material/MaterialModel.h" -#include "GUI/Model/Material/MaterialModelStore.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Sample/ItemWithMaterial.h" #include "GUI/Model/Sample/SampleModel.h" diff --git a/GUI/View/SampleDesigner/MaterialInplaceForm.cpp b/GUI/View/SampleDesigner/MaterialInplaceForm.cpp index a76424ec82d..b5e638a814d 100644 --- a/GUI/View/SampleDesigner/MaterialInplaceForm.cpp +++ b/GUI/View/SampleDesigner/MaterialInplaceForm.cpp @@ -15,7 +15,6 @@ #include "GUI/View/SampleDesigner/MaterialInplaceForm.h" #include "GUI/Model/Material/MaterialItem.h" #include "GUI/Model/Material/MaterialModel.h" -#include "GUI/Model/Material/MaterialModelStore.h" #include "GUI/Model/Sample/ItemWithMaterial.h" #include "GUI/Model/Session/ModelPath.h" #include "GUI/Model/State/SessionData.h" -- GitLab