From 1b30d69dd143b6e7e901ade73d3886daa2e66766 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 21 Dec 2023 14:58:03 +0100 Subject: [PATCH] InstrumentListing using gDoc --- GUI/View/Instrument/InstrumentListing.cpp | 9 ++++----- GUI/View/Instrument/InstrumentListing.h | 4 +--- GUI/View/Instrument/InstrumentView.cpp | 3 ++- GUI/View/Instrument/InstrumentView.h | 2 -- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/GUI/View/Instrument/InstrumentListing.cpp b/GUI/View/Instrument/InstrumentListing.cpp index 031792d7af2..6dbcd49679b 100644 --- a/GUI/View/Instrument/InstrumentListing.cpp +++ b/GUI/View/Instrument/InstrumentListing.cpp @@ -21,9 +21,8 @@ #include <QMessageBox> #include <QVBoxLayout> -InstrumentListing::InstrumentListing(ProjectDocument* document) - : m_document(document) - , m_model(new InstrumentListModel(this, m_document->multiNotifier())) +InstrumentListing::InstrumentListing() + : m_model(new InstrumentListModel(this, gDoc->multiNotifier())) , m_separatorAction1(new QAction(this)) , m_separatorAction2(new QAction(this)) { @@ -141,7 +140,7 @@ void InstrumentListing::onItemSelectionChanged() QModelIndexList indexes = selectionModel()->selectedIndexes(); if (!indexes.empty()) { QModelIndex current = indexes.front(); - m_document->instrumentModel()->setSelectedIndex(current.row()); + gDoc->instrumentModel()->setSelectedIndex(current.row()); emit instrumentSelected(m_model->instrumentItemForIndex(current)); } else emit instrumentSelected(nullptr); @@ -240,7 +239,7 @@ void InstrumentListing::ensureItemSelected() void InstrumentListing::restoreSelection() { - int lastUsed = m_document->instrumentModel()->selectedIndex(); + int lastUsed = gDoc->instrumentModel()->selectedIndex(); if (lastUsed >= 0 && lastUsed < m_model->rowCount()) { QModelIndex lastUsedIndex = m_model->index(lastUsed, 0, QModelIndex()); selectionModel()->select(lastUsedIndex, QItemSelectionModel::ClearAndSelect); diff --git a/GUI/View/Instrument/InstrumentListing.h b/GUI/View/Instrument/InstrumentListing.h index 8e9af7cd2c5..59a74d0442e 100644 --- a/GUI/View/Instrument/InstrumentListing.h +++ b/GUI/View/Instrument/InstrumentListing.h @@ -20,14 +20,13 @@ class InstrumentItem; class InstrumentListModel; -class ProjectDocument; //! Instrument selector on the left side of InstrumentView. class InstrumentListing : public QListView { Q_OBJECT public: - InstrumentListing(ProjectDocument* document); + InstrumentListing(); ~InstrumentListing(); QSize sizeHint() const override; @@ -60,7 +59,6 @@ private: private: InstrumentLibrary m_instrumentLibrary; - ProjectDocument* m_document; InstrumentListModel* m_model; QAction* m_newGisasAction; QAction* m_newOffspecAction; diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp index 15e9998fcfa..b1de60967de 100644 --- a/GUI/View/Instrument/InstrumentView.cpp +++ b/GUI/View/Instrument/InstrumentView.cpp @@ -14,6 +14,7 @@ #include "GUI/View/Instrument/InstrumentView.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Instrument/DepthprobeInstrumentEditor.h" #include "GUI/View/Instrument/GISASInstrumentEditor.h" #include "GUI/View/Instrument/InstrumentListing.h" @@ -27,7 +28,7 @@ #include <QTextEdit> InstrumentView::InstrumentView() - : m_listing(new InstrumentListing(gDoc.get())) + : m_listing(new InstrumentListing) , m_scrollArea(new QScrollArea) { auto* layout = new QVBoxLayout(this); diff --git a/GUI/View/Instrument/InstrumentView.h b/GUI/View/Instrument/InstrumentView.h index 58c1be3c964..aac435d6cb0 100644 --- a/GUI/View/Instrument/InstrumentView.h +++ b/GUI/View/Instrument/InstrumentView.h @@ -15,14 +15,12 @@ #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTVIEW_H #define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTVIEW_H -#include "GUI/Model/Project/ProjectDocument.h" // ProjectDocument::Functionalities #include <QCheckBox> #include <QScrollArea> #include <QWidget> class InstrumentItem; class InstrumentListing; -class ProjectDocument; class InstrumentView : public QWidget { Q_OBJECT -- GitLab