From f8487192b2e2bb2cfc08d5695cc0bb8be678f836 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 21 Dec 2023 14:53:39 +0100 Subject: [PATCH] InstrumentView using gDoc --- GUI/View/Instrument/InstrumentView.cpp | 15 +++++++-------- GUI/View/Instrument/InstrumentView.h | 3 +-- GUI/View/Main/MainWindow.cpp | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp index 06b58a97e28..f3b60eeb827 100644 --- a/GUI/View/Instrument/InstrumentView.cpp +++ b/GUI/View/Instrument/InstrumentView.cpp @@ -28,10 +28,9 @@ #include <QTextEdit> #include <QWidgetAction> -InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) +InstrumentView::InstrumentView(QWidget* parent) : QWidget(parent) - , m_listing(new InstrumentListing(document)) - , m_document(document) + , m_listing(new InstrumentListing(gDoc.get())) , m_scrollArea(new QScrollArea) { auto* layout = new QVBoxLayout(this); @@ -72,7 +71,7 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) void InstrumentView::subscribeOnExternalUpdates() { - connect(m_document->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, + connect(gDoc->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, &InstrumentView::onInstrumentChangedFromExternal, Qt::UniqueConnection); } @@ -81,7 +80,7 @@ void InstrumentView::showEvent(QShowEvent*) // disconnect because when this view is visible, no other instance is modifying instruments. By // disconnecting, no additional logic is necessary to avoid recursive calls (recursive since // this view also causes instrumentChanged to be emitted). - disconnect(m_document->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, + disconnect(gDoc->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, &InstrumentView::onInstrumentChangedFromExternal); } @@ -130,7 +129,7 @@ void InstrumentView::createWidgetsForCurrentInstrument() //... All remaining content depends on instrument type - auto* ec = m_document->multiNotifier(); + auto* ec = gDoc->multiNotifier(); if (auto* ii = dynamic_cast<SpecularInstrumentItem*>(currentInstrument)) { auto* editor = new SpecularInstrumentEditor(m_scrollArea, ii, ec); connect(editor, &SpecularInstrumentEditor::dataChanged, this, @@ -165,7 +164,7 @@ void InstrumentView::onInstrumentNameEdited(const QString& newName) { auto* currentInstrument = m_listing->currentInstrumentItem(); if (currentInstrument && currentInstrument->instrumentName() != newName) - m_document->multiNotifier()->setInstrumentName(currentInstrument, newName); + gDoc->multiNotifier()->setInstrumentName(currentInstrument, newName); } void InstrumentView::onInstrumentdescriptionEdited(const QString& t) @@ -182,7 +181,7 @@ void InstrumentView::onInstrumentChangedByEditor() // uses 'MultiInstrumentNotifier::instrumentChanged' signal for two purposes: // 1) notify 'ProjectDocument' that user has changed data ==> mark project with '*' // 2) notify 'LinkInstrumentManager' ==> unlink instrument from data if they are incompatible - m_document->multiNotifier()->notifyInstrumentChanged(m_listing->currentInstrumentItem()); + gDoc->multiNotifier()->notifyInstrumentChanged(m_listing->currentInstrumentItem()); } void InstrumentView::onInstrumentChangedFromExternal(const InstrumentItem* instrument) diff --git a/GUI/View/Instrument/InstrumentView.h b/GUI/View/Instrument/InstrumentView.h index 34a67c1bb76..c15cd4b69f5 100644 --- a/GUI/View/Instrument/InstrumentView.h +++ b/GUI/View/Instrument/InstrumentView.h @@ -28,7 +28,7 @@ class ProjectDocument; class InstrumentView : public QWidget { Q_OBJECT public: - InstrumentView(QWidget* parent, ProjectDocument* document); + InstrumentView(QWidget* parent); private: void showEvent(QShowEvent*) override; @@ -43,7 +43,6 @@ private: void onSingleInstrumentModeChanged(bool newState); InstrumentListing* m_listing; - ProjectDocument* m_document; QScrollArea* m_scrollArea; QCheckBox* gisasCheck; QCheckBox* offspecCheck; diff --git a/GUI/View/Main/MainWindow.cpp b/GUI/View/Main/MainWindow.cpp index 428b2349cf3..3e66ec665de 100644 --- a/GUI/View/Main/MainWindow.cpp +++ b/GUI/View/Main/MainWindow.cpp @@ -225,7 +225,7 @@ void MainWindow::initViews() resetView(GUI::ID::ViewId::Projects, m_projectsView); if (gDoc) { - m_instrumentView = new InstrumentView(this, gDoc.get()); + m_instrumentView = new InstrumentView(this); m_sampleView = new SampleView(this, gDoc.get()); m_importDataView = new DataView(this, gDoc.get()); m_simulationView = new SimulationView(this, gDoc.get()); -- GitLab