diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp index 62bfaf1ce77b9c5a818f0f607e0556713aec1da5..b037029c7b7f33158cd32195f22822b2fe0bb576 100644 --- a/GUI/View/Instrument/InstrumentView.cpp +++ b/GUI/View/Instrument/InstrumentView.cpp @@ -86,23 +86,23 @@ void InstrumentView::createWidgetsForCurrentInstrument() m_typeLabel->setText(currentInstrument->instrumentType()); if (auto* sp = dynamic_cast<SpecularInstrumentItem*>(currentInstrument)) { auto* editor = new SpecularInstrumentEditor(m_scrollArea, sp); - connect(editor, &SpecularInstrumentEditor::dataChanged, - [=] { emit instrumentChanged(currentInstrument); }); + connect(editor, &SpecularInstrumentEditor::dataChanged, this, + &InstrumentView::onInstrumentChanged); m_scrollArea->setWidget(editor); } else if (auto* os = dynamic_cast<OffSpecularInstrumentItem*>(currentInstrument)) { auto* editor = new OffSpecularInstrumentEditor(m_scrollArea, os); - connect(editor, &OffSpecularInstrumentEditor::dataChanged, - [=] { emit instrumentChanged(currentInstrument); }); + connect(editor, &OffSpecularInstrumentEditor::dataChanged, this, + &InstrumentView::onInstrumentChanged); m_scrollArea->setWidget(editor); } else if (auto* gisas = dynamic_cast<GISASInstrumentItem*>(currentInstrument)) { auto* editor = new GISASInstrumentEditor(m_scrollArea, gisas); - connect(editor, &GISASInstrumentEditor::dataChanged, - [=] { emit instrumentChanged(currentInstrument); }); + connect(editor, &GISASInstrumentEditor::dataChanged, this, + &InstrumentView::onInstrumentChanged); m_scrollArea->setWidget(editor); } else if (auto* dp = dynamic_cast<DepthProbeInstrumentItem*>(currentInstrument)) { auto* editor = new DepthProbeInstrumentEditor(m_scrollArea, dp); - connect(editor, &DepthProbeInstrumentEditor::dataChanged, - [=] { emit instrumentChanged(currentInstrument); }); + connect(editor, &DepthProbeInstrumentEditor::dataChanged, this, + &InstrumentView::onInstrumentChanged); m_scrollArea->setWidget(editor); } else ASSERT(false); @@ -118,8 +118,12 @@ void InstrumentView::onInstrumentNameEditingFinished() { auto* currentInstrument = m_instrumentListView->currentInstrument(); auto newName = m_nameLineEdit->text(); - if (currentInstrument && currentInstrument->instrumentName() != newName) { - currentInstrument->setInstrumentName(newName); - emit instrumentChanged(currentInstrument); - } + if (currentInstrument && currentInstrument->instrumentName() != newName) + m_document->instrumentsEditController()->setInstrumentName(currentInstrument, newName); +} + +void InstrumentView::onInstrumentChanged() +{ + m_document->instrumentsEditController()->notifyInstrumentChanged( + m_instrumentListView->currentInstrument()); } diff --git a/GUI/View/Instrument/InstrumentView.h b/GUI/View/Instrument/InstrumentView.h index a57509d3bf341c0e9e1f3095d577f655a44f4951..1d26c40e55b57fff32d75c653de73e74d9374598 100644 --- a/GUI/View/Instrument/InstrumentView.h +++ b/GUI/View/Instrument/InstrumentView.h @@ -30,12 +30,10 @@ class InstrumentView : public QWidget { public: InstrumentView(QWidget* parent, ProjectDocument* document); -signals: - void instrumentChanged(InstrumentItem* instrument); - private: void createWidgetsForCurrentInstrument(); void onInstrumentNameEditingFinished(); + void onInstrumentChanged(); private: InstrumentListView* m_instrumentListView;