Skip to content
Snippets Groups Projects
Commit 87a0f42e authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

pointerize member, fwd decl

parent 1b30d69d
No related branches found
No related tags found
1 merge request!2263make full use of gDoc being global
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
// ************************************************************************************************ // ************************************************************************************************
#include "GUI/View/Instrument/InstrumentListing.h" #include "GUI/View/Instrument/InstrumentListing.h"
#include "GUI/Model/Device/InstrumentLibrary.h"
#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Project/ProjectDocument.h"
#include "GUI/View/Instrument/InstrumentLibraryEditor.h" #include "GUI/View/Instrument/InstrumentLibraryEditor.h"
#include "GUI/View/Instrument/InstrumentListModel.h" #include "GUI/View/Instrument/InstrumentListModel.h"
...@@ -22,11 +23,12 @@ ...@@ -22,11 +23,12 @@
#include <QVBoxLayout> #include <QVBoxLayout>
InstrumentListing::InstrumentListing() 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_separatorAction1(new QAction(this))
, m_separatorAction2(new QAction(this)) , m_separatorAction2(new QAction(this))
{ {
m_instrumentLibrary.load(); m_instrumentLibrary->load();
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
setViewMode(QListView::IconMode); setViewMode(QListView::IconMode);
...@@ -104,7 +106,7 @@ InstrumentListing::InstrumentListing() ...@@ -104,7 +106,7 @@ InstrumentListing::InstrumentListing()
InstrumentListing::~InstrumentListing() InstrumentListing::~InstrumentListing()
{ {
m_instrumentLibrary.saveIfModified(); m_instrumentLibrary->saveIfModified();
} }
QSize InstrumentListing::sizeHint() const QSize InstrumentListing::sizeHint() const
...@@ -199,19 +201,19 @@ void InstrumentListing::onStoreInLibrary() ...@@ -199,19 +201,19 @@ void InstrumentListing::onStoreInLibrary()
QModelIndex idx = selectionModel()->selectedIndexes().front(); QModelIndex idx = selectionModel()->selectedIndexes().front();
InstrumentItem* instrument = m_model->instrumentItemForIndex(idx); InstrumentItem* instrument = m_model->instrumentItemForIndex(idx);
InstrumentLibraryEditor dlg(GUI::Global::mainWindow, &m_instrumentLibrary); InstrumentLibraryEditor dlg(GUI::Global::mainWindow, m_instrumentLibrary.get());
dlg.execAdd(*instrument); dlg.execAdd(*instrument);
} }
void InstrumentListing::onLoadFromLibrary() void InstrumentListing::onLoadFromLibrary()
{ {
if (m_instrumentLibrary.isEmpty()) { if (m_instrumentLibrary->isEmpty()) {
QMessageBox::information(GUI::Global::mainWindow, "Select from library", QMessageBox::information(GUI::Global::mainWindow, "Select from library",
"The library does not contain instruments so far."); "The library does not contain instruments so far.");
return; return;
} }
InstrumentLibraryEditor dlg(GUI::Global::mainWindow, &m_instrumentLibrary); InstrumentLibraryEditor dlg(GUI::Global::mainWindow, m_instrumentLibrary.get());
auto* instrumentToCopy = dlg.execChoose(); auto* instrumentToCopy = dlg.execChoose();
if (instrumentToCopy == nullptr) if (instrumentToCopy == nullptr)
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
#ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H
#define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H #define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H
#include "GUI/Model/Device/InstrumentLibrary.h"
#include <QListView> #include <QListView>
class InstrumentItem; class InstrumentItem;
class InstrumentLibrary;
class InstrumentListModel; class InstrumentListModel;
//! Instrument selector on the left side of InstrumentView. //! Instrument selector on the left side of InstrumentView.
...@@ -58,7 +58,7 @@ private: ...@@ -58,7 +58,7 @@ private:
void restoreSelection(); void restoreSelection();
private: private:
InstrumentLibrary m_instrumentLibrary; std::unique_ptr<InstrumentLibrary> m_instrumentLibrary;
InstrumentListModel* m_model; InstrumentListModel* m_model;
QAction* m_newGisasAction; QAction* m_newGisasAction;
QAction* m_newOffspecAction; QAction* m_newOffspecAction;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment