Skip to content
Snippets Groups Projects
Commit 990533db authored by Matthias Puchner's avatar Matthias Puchner
Browse files

establish minimal but sufficient signaling for sample model

parent d87d3a37
No related branches found
No related tags found
1 merge request!553Remove session signaling in sample model
Pipeline #52183 failed
......@@ -115,6 +115,9 @@ void LayerOrientedSampleEditor::setCurrentSample(MultiLayerItem* multiLayerItem)
auto* ec = m_editControllers[m_currentMultiLayerItem];
connect(ec, &SampleEditorController::requestViewInRealSpace, this,
&LayerOrientedSampleEditor::requestViewInRealSpace);
connect(ec, &SampleEditorController::aboutToRemoveItem, this,
&LayerOrientedSampleEditor::aboutToRemoveItem);
connect(ec, &SampleEditorController::modified, this, &LayerOrientedSampleEditor::modified);
m_undoAction = ec->undoStack()->createUndoAction(this);
m_redoAction = ec->undoStack()->createRedoAction(this);
......
......@@ -15,6 +15,7 @@
#ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_LAYERORIENTEDSAMPLEEDITOR_H
#define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_LAYERORIENTEDSAMPLEEDITOR_H
#include "GUI/Model/Sample/SampleItem.h"
#include <QMap>
#include <QWidget>
......@@ -38,6 +39,8 @@ public:
signals:
void requestViewInRealSpace(SessionItem* itemToShow);
void requestCreateNewSample();
void aboutToRemoveItem(SampleItem item);
void modified();
private:
void updateActionEnabling();
......
......@@ -81,12 +81,24 @@ SampleView::SampleView(QWidget* parent, ProjectDocument* document)
connect(sampleSelectionView, &SampleListView::currentSampleChanged, scriptPanel,
&ScriptPanel::setCurrentSample);
connect(editor, &LayerOrientedSampleEditor::modified, scriptPanel,
&ScriptPanel::onSampleModified);
connect(editor, &LayerOrientedSampleEditor::requestViewInRealSpace, this,
&SampleView::onRequestViewInRealSpace);
connect(editor, &LayerOrientedSampleEditor::aboutToRemoveItem, this,
&SampleView::onAboutToRemoveItem);
connect(editor, &LayerOrientedSampleEditor::requestCreateNewSample,
sampleSelectionView->newSampleAction(), &QAction::trigger, Qt::QueuedConnection);
connect(editor, &LayerOrientedSampleEditor::modified, m_realSpacePanel->canvas(),
&RealSpaceCanvas::updateScene);
connect(editor, &LayerOrientedSampleEditor::modified, m_document, &ProjectDocument::setModified,
Qt::UniqueConnection);
setCentralWidget(editor);
resetLayout();
}
......@@ -105,6 +117,14 @@ void SampleView::onRequestViewInRealSpace(SessionItem* itemToView)
m_realSpacePanel->canvas()->setCurrentItem(itemToView);
}
void SampleView::onAboutToRemoveItem(SampleItem item)
{
if (m_realSpacePanel->canvas()->currentItem() == item)
m_realSpacePanel->canvas()->resetScene();
// #baMigration ++ check whether canvas shows child of removed item
}
void SampleView::toggleRealSpaceView()
{
m_docks->toggleDock(REALSPACEPANEL);
......
......@@ -15,6 +15,7 @@
#ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEVIEW_H
#define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEVIEW_H
#include "GUI/Model/Sample/SampleItem.h"
#include <QMainWindow>
class DocksController;
......@@ -42,6 +43,8 @@ private:
//! If the real space view is not visible at the moment, it will be shown.
void onRequestViewInRealSpace(SessionItem* itemToView);
void onAboutToRemoveItem(SampleItem item);
DocksController* m_docks = nullptr;
ProjectDocument* m_document = nullptr;
RealSpacePanel* m_realSpacePanel = nullptr;
......
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