From 2909b20da61b37da3c0a2e757ae77fffc090f706 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de> Date: Tue, 23 Jan 2024 18:33:49 +0100 Subject: [PATCH] rename class and sources GUI/Model/Device/InstrumentModel -> GUI/Model/Device/InstrumentsSet --- GUI/Model/Descriptor/SelectionProperty.h | 2 +- GUI/Model/Device/InstrumentLibrary.cpp | 2 +- GUI/Model/Device/InstrumentLibrary.h | 6 ++-- ...InstrumentModel.cpp => InstrumentsSet.cpp} | 36 +++++++++---------- .../{InstrumentModel.h => InstrumentsSet.h} | 14 ++++---- GUI/Model/Device/MultiInstrumentNotifier.cpp | 2 +- GUI/Model/Device/MultiInstrumentNotifier.h | 12 +++---- GUI/Model/Files/DatafilesSet.h | 2 +- GUI/Model/FromCore/ItemizeSimulation.cpp | 2 +- GUI/Model/Project/LinkInstrumentManager.h | 2 +- GUI/Model/Project/ProjectDocument.cpp | 8 ++--- GUI/Model/Project/ProjectDocument.h | 4 +-- GUI/View/Instrument/InstrumentsTreeModel.cpp | 4 +-- GUI/View/Instrument/InstrumentsTreeModel.h | 6 ++-- Tests/Unit/GUI/TestDatafilesModel.cpp | 4 +-- 15 files changed, 53 insertions(+), 53 deletions(-) rename GUI/Model/Device/{InstrumentModel.cpp => InstrumentsSet.cpp} (73%) rename GUI/Model/Device/{InstrumentModel.h => InstrumentsSet.h} (87%) diff --git a/GUI/Model/Descriptor/SelectionProperty.h b/GUI/Model/Descriptor/SelectionProperty.h index fa2bed2e96a..05ebd9e8b54 100644 --- a/GUI/Model/Descriptor/SelectionProperty.h +++ b/GUI/Model/Descriptor/SelectionProperty.h @@ -217,7 +217,7 @@ private: //! A special kind of owning vector, providing "standard" interfaces for //! 'std::vector<SelectionProperty<Catalog>>', used in classes that work not just with single -//! SelectionProperty but with the set of them, for example 'InstrumentModel', 'CompoundItem', +//! SelectionProperty but with the set of them, for example 'InstrumentsSet', 'CompoundItem', //! 'ParticleLayoutItems', 'MaskItems' template <typename Catalog> class SelectionVector { diff --git a/GUI/Model/Device/InstrumentLibrary.cpp b/GUI/Model/Device/InstrumentLibrary.cpp index 710cb0fec5d..db9a8f783ee 100644 --- a/GUI/Model/Device/InstrumentLibrary.cpp +++ b/GUI/Model/Device/InstrumentLibrary.cpp @@ -142,7 +142,7 @@ bool InstrumentLibrary::load() } } -InstrumentModel* InstrumentLibrary::instrumentModel() +InstrumentsSet* InstrumentLibrary::instrumentModel() { return &m_instrument_model; } diff --git a/GUI/Model/Device/InstrumentLibrary.h b/GUI/Model/Device/InstrumentLibrary.h index 68943960492..3e56ca8279e 100644 --- a/GUI/Model/Device/InstrumentLibrary.h +++ b/GUI/Model/Device/InstrumentLibrary.h @@ -15,7 +15,7 @@ #ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTLIBRARY_H #define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTLIBRARY_H -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Device/MultiInstrumentNotifier.h" class InstrumentLibrary { @@ -32,12 +32,12 @@ public: bool saveIfModified(); bool load(); - InstrumentModel* instrumentModel(); + InstrumentsSet* instrumentModel(); MultiInstrumentNotifier* editController(); private: - InstrumentModel m_instrument_model; + InstrumentsSet m_instrument_model; MultiInstrumentNotifier m_ec; bool m_modified; }; diff --git a/GUI/Model/Device/InstrumentModel.cpp b/GUI/Model/Device/InstrumentsSet.cpp similarity index 73% rename from GUI/Model/Device/InstrumentModel.cpp rename to GUI/Model/Device/InstrumentsSet.cpp index 080b55c1a49..be696b01e83 100644 --- a/GUI/Model/Device/InstrumentModel.cpp +++ b/GUI/Model/Device/InstrumentsSet.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Device/InstrumentModel.cpp -//! @brief Implement class InstrumentModel +//! @file GUI/Model/Device/InstrumentsSet.cpp +//! @brief Implement class InstrumentsSet //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,7 +12,7 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Support/Util/String.h" @@ -27,14 +27,14 @@ const QString SelectedIndex("SelectedIndex"); } // namespace Tag } // namespace -InstrumentModel::~InstrumentModel() = default; +InstrumentsSet::~InstrumentsSet() = default; -void InstrumentModel::clear() +void InstrumentsSet::clear() { m_instruments.clear(); } -void InstrumentModel::writeTo(QXmlStreamWriter* w) const +void InstrumentsSet::writeTo(QXmlStreamWriter* w) const { XML::writeAttribute(w, XML::Attrib::version, uint(1)); @@ -51,7 +51,7 @@ void InstrumentModel::writeTo(QXmlStreamWriter* w) const w->writeEndElement(); } -void InstrumentModel::readFrom(QXmlStreamReader* r) +void InstrumentsSet::readFrom(QXmlStreamReader* r) { m_instruments.clear(); @@ -76,12 +76,12 @@ void InstrumentModel::readFrom(QXmlStreamReader* r) } } -void InstrumentModel::emplace_back(InstrumentItem* item) +void InstrumentsSet::emplace_back(InstrumentItem* item) { addEmptyInstrumentSelection().setCurrentItem(item); } -InstrumentItem* InstrumentModel::insertItemCopy(const InstrumentItem& source) +InstrumentItem* InstrumentsSet::insertItemCopy(const InstrumentItem& source) { auto* copy = source.createItemCopy(); copy->setId(QUuid::createUuid().toString()); @@ -89,7 +89,7 @@ InstrumentItem* InstrumentModel::insertItemCopy(const InstrumentItem& source) return copy; } -QVector<InstrumentItem*> InstrumentModel::instrumentItems() const +QVector<InstrumentItem*> InstrumentsSet::instrumentItems() const { QVector<InstrumentItem*> output; for (const auto& sel : m_instruments) @@ -97,7 +97,7 @@ QVector<InstrumentItem*> InstrumentModel::instrumentItems() const return output; } -QStringList InstrumentModel::instrumentNames() const +QStringList InstrumentsSet::instrumentNames() const { QStringList existingNames; for (const auto* item : instrumentItems()) @@ -105,19 +105,19 @@ QStringList InstrumentModel::instrumentNames() const return existingNames; } -SelectionProperty<InstrumentItemCatalog>& InstrumentModel::addEmptyInstrumentSelection() +SelectionProperty<InstrumentItemCatalog>& InstrumentsSet::addEmptyInstrumentSelection() { m_instruments.push_back(nullptr); return m_instruments.back(); } -QString InstrumentModel::suggestInstrumentName(const QString& baseName) const +QString InstrumentsSet::suggestInstrumentName(const QString& baseName) const { return GUI::Util::String::suggestName(instrumentNames(), baseName); } QVector<InstrumentItem*> -InstrumentModel::instrumentItems(const std::function<bool(const InstrumentItem*)>& accept) const +InstrumentsSet::instrumentItems(const std::function<bool(const InstrumentItem*)>& accept) const { QVector<InstrumentItem*> result; for (auto* p : instrumentItems()) @@ -127,7 +127,7 @@ InstrumentModel::instrumentItems(const std::function<bool(const InstrumentItem*) return result; } -QVector<InstrumentItem*> InstrumentModel::instrument2DItems() const +QVector<InstrumentItem*> InstrumentsSet::instrument2DItems() const { QVector<InstrumentItem*> result; for (auto* p : instrumentItems()) @@ -137,7 +137,7 @@ QVector<InstrumentItem*> InstrumentModel::instrument2DItems() const return result; } -InstrumentItem* InstrumentModel::findInstrumentItemById(const QString& instrumentId) const +InstrumentItem* InstrumentsSet::findInstrumentItemById(const QString& instrumentId) const { for (auto* instrument : instrumentItems()) if (instrument->id() == instrumentId) @@ -146,12 +146,12 @@ InstrumentItem* InstrumentModel::findInstrumentItemById(const QString& instrumen return nullptr; } -bool InstrumentModel::instrumentExists(const QString& instrumentId) const +bool InstrumentsSet::instrumentExists(const QString& instrumentId) const { return findInstrumentItemById(instrumentId) != nullptr; } -void InstrumentModel::removeInstrument(InstrumentItem* instrument) +void InstrumentsSet::removeInstrument(InstrumentItem* instrument) { m_instruments.delete_element(instrument); } diff --git a/GUI/Model/Device/InstrumentModel.h b/GUI/Model/Device/InstrumentsSet.h similarity index 87% rename from GUI/Model/Device/InstrumentModel.h rename to GUI/Model/Device/InstrumentsSet.h index 3fad5992257..e4040af39a1 100644 --- a/GUI/Model/Device/InstrumentModel.h +++ b/GUI/Model/Device/InstrumentsSet.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Device/InstrumentModel.h -//! @brief Defines class InstrumentModel. +//! @file GUI/Model/Device/InstrumentsSet.h +//! @brief Defines class InstrumentsSet. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H -#define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H +#ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSSET_H +#define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSSET_H #include "GUI/Model/Descriptor/SelectionProperty.h" #include "GUI/Model/Device/InstrumentItemCatalog.h" @@ -25,9 +25,9 @@ class InstrumentItem; -class InstrumentModel { +class InstrumentsSet { public: - ~InstrumentModel(); + ~InstrumentsSet(); template <typename T> T* addInstrumentItem() { @@ -69,4 +69,4 @@ private: int m_selected_index = -1; }; -#endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H +#endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSSET_H diff --git a/GUI/Model/Device/MultiInstrumentNotifier.cpp b/GUI/Model/Device/MultiInstrumentNotifier.cpp index 100406df592..42b7569dfa0 100644 --- a/GUI/Model/Device/MultiInstrumentNotifier.cpp +++ b/GUI/Model/Device/MultiInstrumentNotifier.cpp @@ -15,7 +15,7 @@ #include "GUI/Model/Device/MultiInstrumentNotifier.h" #include "GUI/Model/Device/InstrumentItems.h" -MultiInstrumentNotifier::MultiInstrumentNotifier(InstrumentModel* instruments) +MultiInstrumentNotifier::MultiInstrumentNotifier(InstrumentsSet* instruments) : m_instruments(instruments) { } diff --git a/GUI/Model/Device/MultiInstrumentNotifier.h b/GUI/Model/Device/MultiInstrumentNotifier.h index 3c03f1e27ec..1a126572f80 100644 --- a/GUI/Model/Device/MultiInstrumentNotifier.h +++ b/GUI/Model/Device/MultiInstrumentNotifier.h @@ -15,12 +15,12 @@ #ifndef BORNAGAIN_GUI_MODEL_DEVICE_MULTIINSTRUMENTNOTIFIER_H #define BORNAGAIN_GUI_MODEL_DEVICE_MULTIINSTRUMENTNOTIFIER_H -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include <QObject> class DatafileItem; class InstrumentItem; -class InstrumentModel; +class InstrumentsSet; //! Class to modify the instruments list or a single instrument and provide the necessary signaling //! within BornAgain. @@ -40,10 +40,10 @@ class InstrumentModel; class MultiInstrumentNotifier : public QObject { Q_OBJECT public: - MultiInstrumentNotifier(InstrumentModel* instruments); + MultiInstrumentNotifier(InstrumentsSet* instruments); //! The list of existing instruments. - InstrumentModel* instrumentModel() { return m_instruments; } + InstrumentsSet* instrumentModel() { return m_instruments; } //! Add an instrument and emit the respective signal. template <typename T> T* addInstrumentItem(); @@ -80,8 +80,8 @@ signals: void instrumentNameChanged(const InstrumentItem* instrument); private: - InstrumentModel* m_instruments; //!< The edited/controlled instruments. This pointer is - //!< borrowed, not owned. + InstrumentsSet* m_instruments; //!< The edited/controlled instruments. This pointer is + //!< borrowed, not owned. }; template <typename T> T* MultiInstrumentNotifier::addInstrumentItem() diff --git a/GUI/Model/Files/DatafilesSet.h b/GUI/Model/Files/DatafilesSet.h index f7e78827f05..66b19b0ddce 100644 --- a/GUI/Model/Files/DatafilesSet.h +++ b/GUI/Model/Files/DatafilesSet.h @@ -22,7 +22,7 @@ class DataItem; class Datafield; class DatafileItem; -class InstrumentModel; +class InstrumentsSet; class MessageService; //! The DatafilesSet class is a model to store all imported DatafileItem's. diff --git a/GUI/Model/FromCore/ItemizeSimulation.cpp b/GUI/Model/FromCore/ItemizeSimulation.cpp index 335c9772f8b..69a44b8a373 100644 --- a/GUI/Model/FromCore/ItemizeSimulation.cpp +++ b/GUI/Model/FromCore/ItemizeSimulation.cpp @@ -37,7 +37,7 @@ #include "GUI/Model/Detector/ResolutionFunctionItems.h" #include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Device/InstrumentItems.h" -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Mask/MaskItems.h" #include "GUI/Model/Mask/MaskList.h" #include "GUI/Support/Data/SimulationOptionsItem.h" diff --git a/GUI/Model/Project/LinkInstrumentManager.h b/GUI/Model/Project/LinkInstrumentManager.h index 822260148b8..b31fbf4abed 100644 --- a/GUI/Model/Project/LinkInstrumentManager.h +++ b/GUI/Model/Project/LinkInstrumentManager.h @@ -24,7 +24,7 @@ class DatafileItem; class InstrumentItem; class ProjectDocument; -//! The LinkInstrumentManager class provides communication between InstrumentModel and +//! The LinkInstrumentManager class provides communication between InstrumentsSet and //! DatafilesSet. Particularly, it notifies DatafileItem about changes in linked instruments //! to adjust axes of Data2DItem. diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index b8c2ed983b7..47a1d8e05a1 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -39,7 +39,7 @@ namespace Tag { const QString BornAgain("BornAgain"); const QString DocumentInfo("DocumentInfo"); const QString SimulationOptions("SimulationOptions"); -const QString InstrumentModel("InstrumentModel"); +const QString InstrumentsSet("InstrumentsSet"); const QString SampleModel("SampleModel"); const QString JobsSet("JobsSet"); const QString RealModel("RealModel"); @@ -101,7 +101,7 @@ void ProjectDocument::setProjectFullPath(const QString& fullPath) setProjectDir(GUI::Project::Util::projectDir(fullPath)); } -InstrumentModel* ProjectDocument::instrumentModel() +InstrumentsSet* ProjectDocument::instrumentModel() { return &m_instrument_model; } @@ -238,7 +238,7 @@ void ProjectDocument::writeProject(QIODevice* device) w.writeEndElement(); // instruments - w.writeStartElement(Tag::InstrumentModel); + w.writeStartElement(Tag::InstrumentsSet); m_instrument_model.writeTo(&w); w.writeEndElement(); @@ -300,7 +300,7 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device, XML::gotoEndElementOfTag(&r, tag); // instruments - } else if (tag == Tag::InstrumentModel) { + } else if (tag == Tag::InstrumentsSet) { m_instrument_model.readFrom(&r); XML::gotoEndElementOfTag(&r, tag); diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h index 4756804448f..2a44cf1868e 100644 --- a/GUI/Model/Project/ProjectDocument.h +++ b/GUI/Model/Project/ProjectDocument.h @@ -55,7 +55,7 @@ public: QString projectFullPath() const; void setProjectFullPath(const QString& fullPath); - InstrumentModel* instrumentModel(); + InstrumentsSet* instrumentModel(); SampleModel* sampleModel(); DatafilesSet* realModel(); JobsSet* jobModel(); @@ -103,7 +103,7 @@ private: std::unique_ptr<LinkInstrumentManager> m_link_manager; SimulationOptionsItem m_simulation_options_item; MultiInstrumentNotifier m_instrument_edit_controller; - InstrumentModel m_instrument_model; + InstrumentsSet m_instrument_model; SampleModel m_sample_model; DatafilesSet m_real_model; JobsSet m_job_model; diff --git a/GUI/View/Instrument/InstrumentsTreeModel.cpp b/GUI/View/Instrument/InstrumentsTreeModel.cpp index 7397c0d884b..b78c5e536ee 100644 --- a/GUI/View/Instrument/InstrumentsTreeModel.cpp +++ b/GUI/View/Instrument/InstrumentsTreeModel.cpp @@ -15,7 +15,7 @@ #include "GUI/View/Instrument/InstrumentsTreeModel.h" #include "Base/Util/Assert.h" #include "GUI/Model/Device/InstrumentItems.h" -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include <QApplication> #include <QtGui> @@ -28,7 +28,7 @@ const auto types = {IType::Gisas, IType::Offspec, IType::Specular, IType::Depthp } // namespace -InstrumentsTreeModel::InstrumentsTreeModel(QObject* parent, InstrumentModel* model) +InstrumentsTreeModel::InstrumentsTreeModel(QObject* parent, InstrumentsSet* model) : QAbstractItemModel(parent) , m_model(model) , m_names_are_editable(false) diff --git a/GUI/View/Instrument/InstrumentsTreeModel.h b/GUI/View/Instrument/InstrumentsTreeModel.h index 8dfb9fd4a78..3c8c5429f5a 100644 --- a/GUI/View/Instrument/InstrumentsTreeModel.h +++ b/GUI/View/Instrument/InstrumentsTreeModel.h @@ -18,13 +18,13 @@ #include <QAbstractItemModel> class InstrumentItem; -class InstrumentModel; +class InstrumentsSet; //! Tree model for instrument item selection. Used e.g. for the instrument library. class InstrumentsTreeModel : public QAbstractItemModel { Q_OBJECT public: - InstrumentsTreeModel(QObject* parent, InstrumentModel* model); + InstrumentsTreeModel(QObject* parent, InstrumentsSet* model); enum InstrumentType { None = 0x0, @@ -64,7 +64,7 @@ private: void clear(); QVector<InstrumentItem*> instrumentItemsOfType(InstrumentType type) const; - InstrumentModel* m_model = nullptr; + InstrumentsSet* m_model = nullptr; bool m_names_are_editable; bool m_enable_empty_headlines; InstrumentItem* m_new_instrument = nullptr; diff --git a/Tests/Unit/GUI/TestDatafilesModel.cpp b/Tests/Unit/GUI/TestDatafilesModel.cpp index e989389f6eb..3afdd05a142 100644 --- a/Tests/Unit/GUI/TestDatafilesModel.cpp +++ b/Tests/Unit/GUI/TestDatafilesModel.cpp @@ -6,7 +6,7 @@ #include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Device/InstrumentItems.h" -#include "GUI/Model/Device/InstrumentModel.h" +#include "GUI/Model/Device/InstrumentsSet.h" #include "GUI/Model/Files/DatafilesSet.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/Unit/GUI/Utils.h" @@ -77,7 +77,7 @@ TEST(TestDatafilesSet, saveXMLData) const QString dir = dir_test_real_model + "/saveXMLData"; UTest::GUI::create_dir(dir); - InstrumentModel instrument_model; + InstrumentsSet instrument_model; DatafilesSet model1; Datafield df1 = UTest::GUI::makeData1D(201.); -- GitLab