diff --git a/GUI/Model/Material/MaterialModel.cpp b/GUI/Model/Material/MaterialModel.cpp index 80ade671442ab72297e005bbe625aad2f87594c9..9a6eb9099dbab6cf7afd33d19a8a3b51e05de04d 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 4d85a090259da1897f9a7537cb9e152f62720917..cc7d36761850ec8c659bbdb37a2593bdbf736819 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 86d0f9d84a1b549726f0c75ed23e015aab1e95d7..0000000000000000000000000000000000000000 --- 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 8af46ae41f99362baf7230ffc0f60b7fcd046f45..0000000000000000000000000000000000000000 --- 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 e649f1fd42dda992e24479a879ebfc4a1bd9b3cb..2a78c677afcf4a2f773076efd08c012b3b69f5b3 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 6bef3d85162c3295d4a342f7fc157ba88d4c75a3..2299291f3e6977de61ca1e0f23c8666f462239eb 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 a76424ec82d9209400ce230e7a895f6ec82b14b5..b5e638a814dc0b68e07bdfe4362c59f4af39bc58 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"