diff --git a/GUI/View/Instrument/InstrumentListing.cpp b/GUI/View/Instrument/InstrumentListing.cpp index 6dbcd49679b3a6ee4aa2e91ee34ab1fa39da5767..ca33a202e4ff78adf48b15dd2b1a85dbe5f14263 100644 --- a/GUI/View/Instrument/InstrumentListing.cpp +++ b/GUI/View/Instrument/InstrumentListing.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/View/Instrument/InstrumentListing.h" +#include "GUI/Model/Device/InstrumentLibrary.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Instrument/InstrumentLibraryEditor.h" #include "GUI/View/Instrument/InstrumentListModel.h" @@ -22,11 +23,12 @@ #include <QVBoxLayout> InstrumentListing::InstrumentListing() - : m_model(new InstrumentListModel(this, gDoc->multiNotifier())) + : m_instrumentLibrary(std::make_unique<InstrumentLibrary>()) + , m_model(new InstrumentListModel(this, gDoc->multiNotifier())) , m_separatorAction1(new QAction(this)) , m_separatorAction2(new QAction(this)) { - m_instrumentLibrary.load(); + m_instrumentLibrary->load(); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); setViewMode(QListView::IconMode); @@ -104,7 +106,7 @@ InstrumentListing::InstrumentListing() InstrumentListing::~InstrumentListing() { - m_instrumentLibrary.saveIfModified(); + m_instrumentLibrary->saveIfModified(); } QSize InstrumentListing::sizeHint() const @@ -199,19 +201,19 @@ void InstrumentListing::onStoreInLibrary() QModelIndex idx = selectionModel()->selectedIndexes().front(); InstrumentItem* instrument = m_model->instrumentItemForIndex(idx); - InstrumentLibraryEditor dlg(GUI::Global::mainWindow, &m_instrumentLibrary); + InstrumentLibraryEditor dlg(GUI::Global::mainWindow, m_instrumentLibrary.get()); dlg.execAdd(*instrument); } void InstrumentListing::onLoadFromLibrary() { - if (m_instrumentLibrary.isEmpty()) { + if (m_instrumentLibrary->isEmpty()) { QMessageBox::information(GUI::Global::mainWindow, "Select from library", "The library does not contain instruments so far."); return; } - InstrumentLibraryEditor dlg(GUI::Global::mainWindow, &m_instrumentLibrary); + InstrumentLibraryEditor dlg(GUI::Global::mainWindow, m_instrumentLibrary.get()); auto* instrumentToCopy = dlg.execChoose(); if (instrumentToCopy == nullptr) diff --git a/GUI/View/Instrument/InstrumentListing.h b/GUI/View/Instrument/InstrumentListing.h index 59a74d0442e81354d67708ca1fe48278e26f7972..f0f44adea1b3e013714ae6cc509990350b6a3f18 100644 --- a/GUI/View/Instrument/InstrumentListing.h +++ b/GUI/View/Instrument/InstrumentListing.h @@ -15,10 +15,10 @@ #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H #define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H -#include "GUI/Model/Device/InstrumentLibrary.h" #include <QListView> class InstrumentItem; +class InstrumentLibrary; class InstrumentListModel; //! Instrument selector on the left side of InstrumentView. @@ -58,7 +58,7 @@ private: void restoreSelection(); private: - InstrumentLibrary m_instrumentLibrary; + std::unique_ptr<InstrumentLibrary> m_instrumentLibrary; InstrumentListModel* m_model; QAction* m_newGisasAction; QAction* m_newOffspecAction;