diff --git a/GUI/Model/Device/InstrumentLibrary.cpp b/GUI/Model/Device/InstrumentLibrary.cpp index 47007dad973de70ee0aca0dfb3a94a70eb8fa7a1..99ed93da528fe6067e1a69233960a833e3657ebf 100644 --- a/GUI/Model/Device/InstrumentLibrary.cpp +++ b/GUI/Model/Device/InstrumentLibrary.cpp @@ -34,7 +34,7 @@ QString instrumentLibraryFilePath() InstrumentLibrary::InstrumentLibrary() - : m_ec(&m_instrumentItems) + : m_ec(&m_instrumentModel) , m_modified(false) { QObject::connect(&m_ec, &InstrumentsEditController::instrumentChanged, @@ -45,7 +45,7 @@ InstrumentLibrary::InstrumentLibrary() QString InstrumentLibrary::suggestName(const QString& name) const { - return m_instrumentItems.suggestInstrumentName(name); + return m_instrumentModel.suggestInstrumentName(name); } InstrumentItem* InstrumentLibrary::addItemCopy(const QString& name, @@ -56,12 +56,12 @@ InstrumentItem* InstrumentLibrary::addItemCopy(const QString& name, bool InstrumentLibrary::isEmpty() const { - return m_instrumentItems.instrumentItems().isEmpty(); + return m_instrumentModel.instrumentItems().isEmpty(); } QList<InstrumentItem*> InstrumentLibrary::instrumentItems() const { - return m_instrumentItems.instrumentItems().toList(); + return m_instrumentModel.instrumentItems().toList(); } InstrumentsEditController* InstrumentLibrary::editController() @@ -85,7 +85,7 @@ bool InstrumentLibrary::saveIfModified() writer.writeAttribute(XML_VERSION_TAG, "2"); writer.writeStartElement(XML_INSTRUMENT_COLLECTION_TAG); - m_instrumentItems.writeTo(&writer); + m_instrumentModel.writeTo(&writer); writer.writeEndElement(); writer.writeEndElement(); @@ -99,7 +99,7 @@ bool InstrumentLibrary::saveIfModified() bool InstrumentLibrary::load() { m_modified = false; - m_instrumentItems.clear(); + m_instrumentModel.clear(); QFile file(instrumentLibraryFilePath()); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) @@ -119,7 +119,7 @@ bool InstrumentLibrary::load() reader.readNextStartElement(); if (reader.name().toString() == XML_INSTRUMENT_COLLECTION_TAG) { - m_instrumentItems.readFrom(&reader); + m_instrumentModel.readFrom(&reader); XML::gotoEndElementOfTag(&reader, XML_INSTRUMENT_COLLECTION_TAG); } } @@ -127,22 +127,22 @@ bool InstrumentLibrary::load() } if (reader.hasError()) { - m_instrumentItems.clear(); + m_instrumentModel.clear(); return false; } file.close(); return true; } catch (const std::exception&) { - m_instrumentItems.clear(); + m_instrumentModel.clear(); return false; } catch (const DeserializationException&) { - m_instrumentItems.clear(); + m_instrumentModel.clear(); return false; } } -InstrumentCollection* InstrumentLibrary::instrumentCollection() +InstrumentModel* InstrumentLibrary::instrumentModel() { - return &m_instrumentItems; + return &m_instrumentModel; } diff --git a/GUI/Model/Device/InstrumentLibrary.h b/GUI/Model/Device/InstrumentLibrary.h index cdc3fdff7ddf3f9ebf862c6540305cd4b2133c94..c1c1f3f8a738bdad92a412776c14c3d37a71bba2 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/InstrumentCollection.h" +#include "GUI/Model/Device/InstrumentModel.h" #include "GUI/Model/Device/InstrumentsEditController.h" class InstrumentLibrary { @@ -32,12 +32,12 @@ public: bool saveIfModified(); bool load(); - InstrumentCollection* instrumentCollection(); + InstrumentModel* instrumentModel(); InstrumentsEditController* editController(); private: - InstrumentCollection m_instrumentItems; + InstrumentModel m_instrumentModel; InstrumentsEditController m_ec; bool m_modified; }; diff --git a/GUI/Model/Device/InstrumentCollection.cpp b/GUI/Model/Device/InstrumentModel.cpp similarity index 71% rename from GUI/Model/Device/InstrumentCollection.cpp rename to GUI/Model/Device/InstrumentModel.cpp index 7e7c9d030fcb2b4e59f15c92666db031adc9f1ef..5cfb612670d71e0c3b129ca4e041b16ecac9d9e8 100644 --- a/GUI/Model/Device/InstrumentCollection.cpp +++ b/GUI/Model/Device/InstrumentModel.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Device/InstrumentCollection.cpp -//! @brief Implement class InstrumentCollection +//! @file GUI/Model/Device/InstrumentModel.cpp +//! @brief Implement class InstrumentModel //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,7 +12,7 @@ // // ************************************************************************************************ -#include "GUI/Model/Device/InstrumentCollection.h" +#include "GUI/Model/Device/InstrumentModel.h" #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Util/String.h" #include <QUuid> @@ -25,14 +25,14 @@ const QString Instrument("Instrument"); } // namespace Tag } // namespace -InstrumentCollection::~InstrumentCollection() {} +InstrumentModel::~InstrumentModel() {} -void InstrumentCollection::clear() +void InstrumentModel::clear() { m_instruments.clear(); } -void InstrumentCollection::writeTo(QXmlStreamWriter* w) const +void InstrumentModel::writeTo(QXmlStreamWriter* w) const { XML::writeAttribute(w, XML::Attrib::version, uint(1)); @@ -44,7 +44,7 @@ void InstrumentCollection::writeTo(QXmlStreamWriter* w) const } } -void InstrumentCollection::readFrom(QXmlStreamReader* r) +void InstrumentModel::readFrom(QXmlStreamReader* r) { m_instruments.clear(); @@ -64,12 +64,12 @@ void InstrumentCollection::readFrom(QXmlStreamReader* r) } } -void InstrumentCollection::emplace_back(InstrumentItem* item) +void InstrumentModel::emplace_back(InstrumentItem* item) { addEmptyInstrumentSelection().setCurrentItem(item); } -InstrumentItem* InstrumentCollection::insertItemCopy(const InstrumentItem& source) +InstrumentItem* InstrumentModel::insertItemCopy(const InstrumentItem& source) { auto* copy = source.createItemCopy(); copy->setId(QUuid::createUuid().toString()); @@ -77,7 +77,7 @@ InstrumentItem* InstrumentCollection::insertItemCopy(const InstrumentItem& sourc return copy; } -QVector<InstrumentItem*> InstrumentCollection::instrumentItems() const +QVector<InstrumentItem*> InstrumentModel::instrumentItems() const { QVector<InstrumentItem*> output; for (const auto& sel : m_instruments) @@ -85,7 +85,7 @@ QVector<InstrumentItem*> InstrumentCollection::instrumentItems() const return output; } -QStringList InstrumentCollection::instrumentNames() const +QStringList InstrumentModel::instrumentNames() const { QStringList existingNames; for (const auto* item : instrumentItems()) @@ -93,19 +93,19 @@ QStringList InstrumentCollection::instrumentNames() const return existingNames; } -SelectionProperty<InstrumentItemCatalog>& InstrumentCollection::addEmptyInstrumentSelection() +SelectionProperty<InstrumentItemCatalog>& InstrumentModel::addEmptyInstrumentSelection() { SelectionProperty<InstrumentItemCatalog> newInstrumentSelection; m_instruments.push_back(std::move(newInstrumentSelection)); return m_instruments.back(); } -QString InstrumentCollection::suggestInstrumentName(const QString& baseName) const +QString InstrumentModel::suggestInstrumentName(const QString& baseName) const { return GUI::Util::String::suggestName(instrumentNames(), baseName); } -QVector<InstrumentItem*> InstrumentCollection::instrumentItems( +QVector<InstrumentItem*> InstrumentModel::instrumentItems( const std::function<bool(const InstrumentItem*)>& accept) const { QVector<InstrumentItem*> result; @@ -116,7 +116,7 @@ QVector<InstrumentItem*> InstrumentCollection::instrumentItems( return result; } -QVector<Instrument2DItem*> InstrumentCollection::instrument2DItems() const +QVector<Instrument2DItem*> InstrumentModel::instrument2DItems() const { QVector<Instrument2DItem*> result; for (auto* p : instrumentItems()) @@ -126,7 +126,7 @@ QVector<Instrument2DItem*> InstrumentCollection::instrument2DItems() const return result; } -InstrumentItem* InstrumentCollection::findInstrumentItemById(const QString& instrumentId) const +InstrumentItem* InstrumentModel::findInstrumentItemById(const QString& instrumentId) const { for (auto* instrument : instrumentItems()) if (instrument->id() == instrumentId) @@ -135,12 +135,12 @@ InstrumentItem* InstrumentCollection::findInstrumentItemById(const QString& inst return nullptr; } -bool InstrumentCollection::instrumentExists(const QString& instrumentId) const +bool InstrumentModel::instrumentExists(const QString& instrumentId) const { return findInstrumentItemById(instrumentId) != nullptr; } -void InstrumentCollection::removeInstrument(InstrumentItem* instrument) +void InstrumentModel::removeInstrument(InstrumentItem* instrument) { for (size_t i = 0; i < m_instruments.size(); i++) if (m_instruments[i].currentItem() == instrument) diff --git a/GUI/Model/Device/InstrumentCollection.h b/GUI/Model/Device/InstrumentModel.h similarity index 85% rename from GUI/Model/Device/InstrumentCollection.h rename to GUI/Model/Device/InstrumentModel.h index 36bcf55650cd770a1ee243fc21fd7cfd9673f6a7..a389d09c4a4125354d180587947f2740eb2b4b95 100644 --- a/GUI/Model/Device/InstrumentCollection.h +++ b/GUI/Model/Device/InstrumentModel.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Device/InstrumentCollection.h -//! @brief Defines class InstrumentCollection +//! @file GUI/Model/Device/InstrumentModel.h +//! @brief Defines class InstrumentModel //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTCOLLECTION_H -#define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTCOLLECTION_H +#ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H +#define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H #include "GUI/Model/CatDevice/InstrumentItemCatalog.h" #include "GUI/Model/Descriptor/SelectionProperty.h" @@ -26,9 +26,9 @@ class InstrumentItem; class Instrument2DItem; -class InstrumentCollection { +class InstrumentModel { public: - ~InstrumentCollection(); + ~InstrumentModel(); template <typename T> T* addInstrumentItem() @@ -67,4 +67,4 @@ private: std::vector<SelectionProperty<InstrumentItemCatalog>> m_instruments; }; -#endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTCOLLECTION_H +#endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTMODEL_H diff --git a/GUI/Model/Device/InstrumentsEditController.cpp b/GUI/Model/Device/InstrumentsEditController.cpp index da6fec519d230244b6c69741a7e13129a9d0dcf8..8cdee227a3b75a8865912f98292482c6db81b0ea 100644 --- a/GUI/Model/Device/InstrumentsEditController.cpp +++ b/GUI/Model/Device/InstrumentsEditController.cpp @@ -15,12 +15,12 @@ #include "GUI/Model/Device/InstrumentsEditController.h" #include "GUI/Model/Device/InstrumentItems.h" -InstrumentsEditController::InstrumentsEditController(InstrumentCollection* instruments) +InstrumentsEditController::InstrumentsEditController(InstrumentModel* instruments) : m_instruments(instruments) { } -InstrumentCollection* InstrumentsEditController::instrumentCollection() +InstrumentModel* InstrumentsEditController::instrumentModel() { return m_instruments; } diff --git a/GUI/Model/Device/InstrumentsEditController.h b/GUI/Model/Device/InstrumentsEditController.h index ebd9db7137f3c878f12b042c1c3b83d55449fd03..ac107152cb6e419414713ef660580d5eaa26bfd8 100644 --- a/GUI/Model/Device/InstrumentsEditController.h +++ b/GUI/Model/Device/InstrumentsEditController.h @@ -15,10 +15,10 @@ #ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSEDITCONTROLLER_H #define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSEDITCONTROLLER_H -#include "GUI/Model/Device/InstrumentCollection.h" +#include "GUI/Model/Device/InstrumentModel.h" #include <QObject> -class InstrumentCollection; +class InstrumentModel; class InstrumentItem; class RealItem; @@ -41,10 +41,10 @@ class InstrumentsEditController : public QObject { Q_OBJECT public: - InstrumentsEditController(InstrumentCollection* instruments); + InstrumentsEditController(InstrumentModel* instruments); //! The list of existing instruments. - InstrumentCollection* instrumentCollection(); + InstrumentModel* instrumentModel(); //! Add an instrument and emit the respective signal. template <typename T> @@ -82,7 +82,7 @@ signals: void instrumentNameChanged(const InstrumentItem* instrument); private: - InstrumentCollection* m_instruments; //!< The edited/controlled instruments. This pointer is + InstrumentModel* m_instruments; //!< The edited/controlled instruments. This pointer is //!< borrowed, not owned. }; diff --git a/GUI/Model/FromCore/ItemizeSimulation.cpp b/GUI/Model/FromCore/ItemizeSimulation.cpp index f81059333dcf3ecd3e6247f6cce7de6008cadf7a..ac6cde805fccb4698b19a6df218c2dd3dcc99317 100644 --- a/GUI/Model/FromCore/ItemizeSimulation.cpp +++ b/GUI/Model/FromCore/ItemizeSimulation.cpp @@ -32,7 +32,7 @@ #include "GUI/Model/Device/BackgroundItems.h" #include "GUI/Model/Device/BeamAngleItems.h" #include "GUI/Model/Device/BeamWavelengthItem.h" -#include "GUI/Model/Device/InstrumentCollection.h" +#include "GUI/Model/Device/InstrumentModel.h" #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Model/Device/MaskItems.h" #include "GUI/Model/Device/RectangularDetectorItem.h" @@ -500,7 +500,7 @@ SpecularInstrumentItem* createSpecularInstrumentItem(const SpecularSimulation& s } // namespace -InstrumentCollection* GUI::Transform::FromCore::itemizeInstruments(const ISimulation& simulation) +InstrumentModel* GUI::Transform::FromCore::itemizeInstruments(const ISimulation& simulation) { InstrumentItem* item; @@ -515,9 +515,9 @@ InstrumentCollection* GUI::Transform::FromCore::itemizeInstruments(const ISimula setBackground(item, simulation); - auto* collection = new InstrumentCollection; - collection->emplace_back(item); - return collection; + auto* model = new InstrumentModel; + model->emplace_back(item); + return model; } SimulationOptionsItem* GUI::Transform::FromCore::itemizeOptions(const ISimulation& simulation) diff --git a/GUI/Model/FromCore/ItemizeSimulation.h b/GUI/Model/FromCore/ItemizeSimulation.h index d651bc6a38af01e2b8a1562e8b64714bacb7ef85..2a2c18c1efec79309e5c9c6c43aa8f7233f73e52 100644 --- a/GUI/Model/FromCore/ItemizeSimulation.h +++ b/GUI/Model/FromCore/ItemizeSimulation.h @@ -17,13 +17,13 @@ class SimulationOptionsItem; class ISimulation; -class InstrumentCollection; +class InstrumentModel; //! Contains set of methods to populate GUI models with content from domain. namespace GUI::Transform::FromCore { -InstrumentCollection* itemizeInstruments(const ISimulation& simulation); +InstrumentModel* itemizeInstruments(const ISimulation& simulation); SimulationOptionsItem* itemizeOptions(const ISimulation& simulation); diff --git a/GUI/Model/Model/ApplicationModels.h b/GUI/Model/Model/ApplicationModels.h index 311b2be752777262eb9d0c4753e062372ba92550..f6363270aad9340cbcacbdefeb83d625dabf066e 100644 --- a/GUI/Model/Model/ApplicationModels.h +++ b/GUI/Model/Model/ApplicationModels.h @@ -22,7 +22,7 @@ class SessionModel; class DataItem; class DocumentModel; -class InstrumentCollection; +class InstrumentModel; class MessageService; class ApplicationModels : public QObject { diff --git a/GUI/Model/Project/LinkInstrumentManager.h b/GUI/Model/Project/LinkInstrumentManager.h index df0258b3d6a6f3671b59ede54ee2848e8972456b..6a4e32c3409b200b50e05223a98148906febaf49 100644 --- a/GUI/Model/Project/LinkInstrumentManager.h +++ b/GUI/Model/Project/LinkInstrumentManager.h @@ -24,7 +24,7 @@ class InstrumentItem; class ProjectDocument; class RealItem; -//! The LinkInstrumentManager class provides communication between InstrumentCollection and +//! The LinkInstrumentManager class provides communication between InstrumentModel and //! RealModel. Particularly, it notifies RealItem about changes in linked instruments //! to adjust axes of IntensityDataItem. diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index d4d253d982f249595dabd894c01fd186cf1dfa97..7ef6f8e3efb0969cc96947017b24afb6d7a22b5c 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -120,9 +120,9 @@ void ProjectDocument::setProjectFileName(const QString& projectFileName) setProjectDir(GUI::Project::Utils::projectDir(projectFileName)); } -InstrumentCollection* ProjectDocument::collectedItems() const +InstrumentModel* ProjectDocument::collectedItems() const { - return const_cast<InstrumentCollection*>(&m_instruments); + return const_cast<InstrumentModel*>(&m_instruments); } SampleModel* ProjectDocument::sampleModel() diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h index e035c8466982cb48ea9dee542edf4f7f991bff18..7112e700df07a9f8220d284952d6b15c21f8fd94 100644 --- a/GUI/Model/Project/ProjectDocument.h +++ b/GUI/Model/Project/ProjectDocument.h @@ -70,7 +70,7 @@ public: QString projectFileName() const; void setProjectFileName(const QString& projectFileName); - InstrumentCollection* collectedItems() const; + InstrumentModel* collectedItems() const; SampleModel* sampleModel(); RealModel* realModel() const; JobModel* jobModel() const; @@ -145,7 +145,7 @@ private: SimulationOptionsItem m_simulationOptionsItem; SampleModel m_sampleItems; InstrumentsEditController m_instrumentEditController; - InstrumentCollection m_instruments; + InstrumentModel m_instruments; }; Q_DECLARE_OPERATORS_FOR_FLAGS(ProjectDocument::Functionalities) diff --git a/GUI/View/Import/RealDataSelectorWidget.h b/GUI/View/Import/RealDataSelectorWidget.h index c99343cabb6a20abff3f6b73ee79b4eb952c6f75..5123b3d34291a2d234ff80083869b1baf57ea6cf 100644 --- a/GUI/View/Import/RealDataSelectorWidget.h +++ b/GUI/View/Import/RealDataSelectorWidget.h @@ -23,7 +23,7 @@ class RealDataPropertiesWidget; class RealDataItemSelectorWidget; -class InstrumentCollection; +class InstrumentModel; class RealModel; class RealDataSelectorActions; class RealItem; diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.cpp b/GUI/View/Instrument/InstrumentLibraryEditor.cpp index 2e2d4e286b941918eef3be6d79b2f0ea49b0495a..bb4610395d33a486603d77f888a0b9818c986580 100644 --- a/GUI/View/Instrument/InstrumentLibraryEditor.cpp +++ b/GUI/View/Instrument/InstrumentLibraryEditor.cpp @@ -36,7 +36,7 @@ InstrumentLibraryEditor::InstrumentLibraryEditor(QWidget* parent) : QDialog(parent) , m_ui(new Ui::InstrumentLibraryEditor) - , m_treeModel(new TreeModel(this, gSessionData->instrumentLibrary.instrumentCollection())) + , m_treeModel(new TreeModel(this, gSessionData->instrumentLibrary.instrumentModel())) , m_chosenItem(nullptr) { m_ui->setupUi(this); @@ -266,7 +266,7 @@ void InstrumentLibraryEditor::onInstrumentChangedByEditor() /*********************************************************************************************/ -InstrumentLibraryEditor::TreeModel::TreeModel(QObject* parent, InstrumentCollection* model) +InstrumentLibraryEditor::TreeModel::TreeModel(QObject* parent, InstrumentModel* model) : InstrumentsTreeModel(parent, model) , m_newInstrument(nullptr) { diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.h b/GUI/View/Instrument/InstrumentLibraryEditor.h index 50524accc3838561852c762857cd750eae9db4bb..e847dc2429bd10679ef7f0d5e6826c08a154e02d 100644 --- a/GUI/View/Instrument/InstrumentLibraryEditor.h +++ b/GUI/View/Instrument/InstrumentLibraryEditor.h @@ -60,7 +60,7 @@ private: //! * creates a HTML text for the Display role class TreeModel : public InstrumentsTreeModel { public: - TreeModel(QObject* parent, InstrumentCollection* model); + TreeModel(QObject* parent, InstrumentModel* model); //! Set the instrument which shall have a "NEW" sign in its icon void setNewInstrument(InstrumentItem* addedInstrument); diff --git a/GUI/View/Instrument/InstrumentListModel.cpp b/GUI/View/Instrument/InstrumentListModel.cpp index 4ef68812bf6532cd8c85c546898404b5eec05cea..ee8b49955e22977eca401b12e14a0a6b81a6b99b 100644 --- a/GUI/View/Instrument/InstrumentListModel.cpp +++ b/GUI/View/Instrument/InstrumentListModel.cpp @@ -71,12 +71,12 @@ InstrumentListModel::InstrumentListModel(QObject* parent, InstrumentsEditControl int InstrumentListModel::rowCount(const QModelIndex&) const { - return m_ec->instrumentCollection()->instrumentItems().size(); + return m_ec->instrumentModel()->instrumentItems().size(); } QVariant InstrumentListModel::data(const QModelIndex& index, int role) const { - QVector<InstrumentItem*> instruments = m_ec->instrumentCollection()->instrumentItems(); + QVector<InstrumentItem*> instruments = m_ec->instrumentModel()->instrumentItems(); if (!index.isValid() || index.row() >= instruments.size() || index.row() < 0) return {}; @@ -104,7 +104,7 @@ InstrumentItem* InstrumentListModel::instrumentItemForIndex(const QModelIndex& i if (!index.isValid()) return nullptr; - QVector<InstrumentItem*> instruments = m_ec->instrumentCollection()->instrumentItems(); + QVector<InstrumentItem*> instruments = m_ec->instrumentModel()->instrumentItems(); if (index.row() >= 0 && index.row() < instruments.size()) return instruments[index.row()]; return nullptr; @@ -149,8 +149,8 @@ QModelIndex InstrumentListModel::copyInstrument(const QModelIndex& source) QModelIndex InstrumentListModel::copyInstrument(const InstrumentItem* source) { const QString copyName = - m_ec->instrumentCollection()->suggestInstrumentName(source->instrumentName()); - const int row = m_ec->instrumentCollection()->instrumentItems().size(); + m_ec->instrumentModel()->suggestInstrumentName(source->instrumentName()); + const int row = m_ec->instrumentModel()->instrumentItems().size(); beginInsertRows(QModelIndex(), row, row); m_ec->addInstrumentItemCopy(source, copyName); @@ -163,8 +163,8 @@ template <class Instrument> QModelIndex InstrumentListModel::addNewInstrument() { const QString name = - m_ec->instrumentCollection()->suggestInstrumentName(defaultInstrumentName<Instrument>()); - const int row = m_ec->instrumentCollection()->instrumentItems().size(); + m_ec->instrumentModel()->suggestInstrumentName(defaultInstrumentName<Instrument>()); + const int row = m_ec->instrumentModel()->instrumentItems().size(); beginInsertRows(QModelIndex(), row, row); auto* instrument = m_ec->addInstrumentItem<Instrument>(); @@ -176,7 +176,7 @@ QModelIndex InstrumentListModel::addNewInstrument() void InstrumentListModel::onInstrumentNameChanged(const InstrumentItem* instrument) { - const auto instruments = m_ec->instrumentCollection()->instrumentItems(); + const auto instruments = m_ec->instrumentModel()->instrumentItems(); if (const auto row = instruments.indexOf(const_cast<InstrumentItem*>(instrument)); row != -1) emit dataChanged(index(row, 0), index(row, 0)); } diff --git a/GUI/View/Instrument/InstrumentListModel.h b/GUI/View/Instrument/InstrumentListModel.h index 54d227d3394dc8f4ce6bb5be36bed3cb9c1f17bb..2951bb21c869558918b2fa819906d79dd90e3378 100644 --- a/GUI/View/Instrument/InstrumentListModel.h +++ b/GUI/View/Instrument/InstrumentListModel.h @@ -19,7 +19,7 @@ #include <QIcon> class InstrumentItem; -class InstrumentCollection; +class InstrumentModel; class InstrumentsEditController; //! List model for instruments. diff --git a/GUI/View/Instrument/InstrumentListView.h b/GUI/View/Instrument/InstrumentListView.h index fe7e9988409d346e6e82abdcbbdef7b117e32853..02bd7535c5b89fe942a95950963adc37dc9977b9 100644 --- a/GUI/View/Instrument/InstrumentListView.h +++ b/GUI/View/Instrument/InstrumentListView.h @@ -17,7 +17,7 @@ #include <QWidget> -class InstrumentCollection; +class InstrumentModel; class QAction; class QListView; class InstrumentItem; diff --git a/GUI/View/Instrument/InstrumentsTreeModel.cpp b/GUI/View/Instrument/InstrumentsTreeModel.cpp index bb73494cdb12a561618afc3f512ad77ea3a60894..7d26f9f2e8522aba753d4db05de1cf0b4711e00c 100644 --- a/GUI/View/Instrument/InstrumentsTreeModel.cpp +++ b/GUI/View/Instrument/InstrumentsTreeModel.cpp @@ -14,13 +14,13 @@ #include "GUI/View/Instrument/InstrumentsTreeModel.h" #include "GUI/Application/ApplicationSettings.h" -#include "GUI/Model/Device/InstrumentCollection.h" +#include "GUI/Model/Device/InstrumentModel.h" #include "GUI/Model/Device/InstrumentItems.h" #include <QApplication> #include <QtCore> #include <QtGui> -InstrumentsTreeModel::InstrumentsTreeModel(QObject* parent, InstrumentCollection* model) +InstrumentsTreeModel::InstrumentsTreeModel(QObject* parent, InstrumentModel* model) : QAbstractItemModel(parent) , m_model(model) , m_visibleTypes(All) @@ -47,19 +47,6 @@ void InstrumentsTreeModel::setTypeEnabled(InstrumentType type, bool b) } } -void InstrumentsTreeModel::refreshAfterModelChange() -{ - // for (auto rank : m_visibleRanks) { - // if (!m_items[rank - 1].isEmpty()) { - // beginRemoveRows(indexOfHeadline(rank), 0, m_items[rank - 1].size() - 1); - // m_items[rank - 1] = m_model->InstrumentCollection(rank); - // endRemoveRows(); - // } - // } - // - // updateSubscriptions(); -} - void InstrumentsTreeModel::clear() { beginResetModel(); diff --git a/GUI/View/Instrument/InstrumentsTreeModel.h b/GUI/View/Instrument/InstrumentsTreeModel.h index df8b4eb31b19da2ec5a45c04d47975cfbe176765..6895b48ad79bbaad027ffa13cb4402ecc5768cc2 100644 --- a/GUI/View/Instrument/InstrumentsTreeModel.h +++ b/GUI/View/Instrument/InstrumentsTreeModel.h @@ -18,13 +18,13 @@ #include <QAbstractItemModel> #include <QSet> -class InstrumentCollection; +class InstrumentModel; class InstrumentItem; //! Tree model for instrument item selection. Used e.g. for the instrument library. class InstrumentsTreeModel : public QAbstractItemModel { public: - InstrumentsTreeModel(QObject* parent, InstrumentCollection* model); + InstrumentsTreeModel(QObject* parent, InstrumentModel* model); enum InstrumentType { None = 0x0, @@ -52,7 +52,6 @@ public: QModelIndex indexForItem(InstrumentItem* item) const; void removeItem(InstrumentItem* item); - void refreshAfterModelChange(); //! The topmost visible item. Can be null of course. InstrumentItem* topMostItem() const; @@ -68,7 +67,7 @@ private: QVector<InstrumentItem*> instrumentItems(InstrumentType type) const; private: - InstrumentCollection* m_model = nullptr; + InstrumentModel* m_model = nullptr; VisibleInstrumentTypes m_visibleTypes; bool m_namesAreEditable; bool m_enableEmptyHeadlines; diff --git a/Tests/Suite/GUI/Check.cpp b/Tests/Suite/GUI/Check.cpp index f6bc995bf13d6f745d918abe836001d1955d86a1..42e503014a728ac1d6fe11b961b0a2e578641ea8 100644 --- a/Tests/Suite/GUI/Check.cpp +++ b/Tests/Suite/GUI/Check.cpp @@ -19,7 +19,7 @@ #include "Device/Histo/DiffUtil.h" #include "Device/Histo/SimulationResult.h" #include "Device/IO/IOFactory.h" -#include "GUI/Model/Device/InstrumentCollection.h" +#include "GUI/Model/Device/InstrumentModel.h" #include "GUI/Model/FromCore/ItemizeSample.h" #include "GUI/Model/FromCore/ItemizeSimulation.h" #include "GUI/Model/Sample/SampleItem.h" @@ -35,7 +35,7 @@ std::unique_ptr<ISimulation> indirectSimulation(const ISimulation& sim) { std::unique_ptr<SampleItem> sampleItem(GUI::Transform::FromCore::itemizeSample(*sim.sample())); - std::unique_ptr<InstrumentCollection> instrumentItems( + std::unique_ptr<InstrumentModel> instrumentItems( GUI::Transform::FromCore::itemizeInstruments(sim)); std::unique_ptr<SimulationOptionsItem> optionsItem( diff --git a/Tests/Unit/GUI/TestDetectorItems.cpp b/Tests/Unit/GUI/TestDetectorItems.cpp index 3abd3d7ba78514029f7b756b1a4fbd029662fc2c..3e3b2e6c454328446a77b34c3178dfb9fcf304cd 100644 --- a/Tests/Unit/GUI/TestDetectorItems.cpp +++ b/Tests/Unit/GUI/TestDetectorItems.cpp @@ -2,7 +2,7 @@ #include "Device/Detector/IDetector.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" #include "Device/Resolution/ResolutionFunction2DGaussian.h" -#include "GUI/Model/Device/InstrumentCollection.h" +#include "GUI/Model/Device/InstrumentModel.h" #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Model/Device/RectangularDetectorItem.h" #include "GUI/Model/Device/ResolutionFunctionItems.h" @@ -12,7 +12,7 @@ TEST(TestDetectorItems, resolutionFunction) { - InstrumentCollection model; + InstrumentModel model; auto* instrument = model.addInstrumentItem<GISASInstrumentItem>(); DetectorItem* detectorItem = instrument->detectorItem(); diff --git a/Tests/Unit/GUI/TestSessionModel.cpp b/Tests/Unit/GUI/TestSessionModel.cpp index e01e2261c668f46cecd87e1212969254a142606a..b7450f66c3c56d8fc3136a231d07bc476a1115aa 100644 --- a/Tests/Unit/GUI/TestSessionModel.cpp +++ b/Tests/Unit/GUI/TestSessionModel.cpp @@ -1,7 +1,7 @@ #include "GUI/Model/BaseItem/PropertyItem.h" #include "GUI/Model/Data/DataItem.h" #include "GUI/Model/Data/RealItem.h" -#include "GUI/Model/Device/InstrumentCollection.h" +#include "GUI/Model/Device/InstrumentModel.h" #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Model/Device/MaskItems.h" #include "GUI/Model/Job/JobItem.h" @@ -50,7 +50,7 @@ TEST(TestSessionModel, copyItem) sample1->setSampleName("sample1"); sample1->addStandardMaterials(); - InstrumentCollection instrumentItems; + InstrumentModel instrumentItems; auto* instrument1 = instrumentItems.addInstrumentItem<GISASInstrumentItem>(); instrument1->setInstrumentName("instrument1");