From a99b8b976014966de2d2bb04cd2dd1581ae9ef83 2017-07-04 07:41:26 From: Alexandre Leroux Date: 2017-07-04 07:41:26 Subject: [PATCH] Variable deletion (7) Makes connections to remove variable from visualization when it's deleted from the controller --- diff --git a/app/src/MainWindow.cpp b/app/src/MainWindow.cpp index 6fbd08b..05951cb 100644 --- a/app/src/MainWindow.cpp +++ b/app/src/MainWindow.cpp @@ -173,6 +173,10 @@ MainWindow::MainWindow(QWidget *parent) auto timeWidget = new TimeWidget{}; mainToolBar->addWidget(timeWidget); + // Controllers / controllers connections + connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)), + &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime))); + // Widgets / controllers connections // DataSource @@ -183,8 +187,10 @@ MainWindow::MainWindow(QWidget *parent) connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(), SLOT(onTimeToUpdate(SqpDateTime))); - connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)), - &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime))); + // Visualization + connect(&sqpApp->visualizationController(), + SIGNAL(variableAboutToBeDeleted(std::shared_ptr)), m_Ui->view, + SLOT(onVariableAboutToBeDeleted(std::shared_ptr))); // Widgets / widgets connections diff --git a/core/include/Variable/VariableController.h b/core/include/Variable/VariableController.h index 4334755..f7bcf49 100644 --- a/core/include/Variable/VariableController.h +++ b/core/include/Variable/VariableController.h @@ -34,6 +34,7 @@ public: * Deletes from the controller the variable passed in parameter. * * Delete a variable includes: + * - the deletion of the various references to the variable in SciQlop * - the deletion of the model variable * - the deletion of the provider associated with the variable * - removing the cache associated with the variable @@ -50,6 +51,8 @@ public: void deleteVariables(const QVector > &variables) noexcept; signals: + /// Signal emitted when a variable is about to be deleted from the controller + void variableAboutToBeDeleted(std::shared_ptr variable); /// Signal emitted when a variable has been created void variableCreated(std::shared_ptr variable); diff --git a/gui/src/SqpApplication.cpp b/gui/src/SqpApplication.cpp index 4c221ba..a1554ca 100644 --- a/gui/src/SqpApplication.cpp +++ b/gui/src/SqpApplication.cpp @@ -32,6 +32,10 @@ public: connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr)), m_VisualizationController.get(), SIGNAL(variableCreated(std::shared_ptr))); + connect(m_VariableController.get(), + SIGNAL(variableAboutToBeDeleted(std::shared_ptr)), + m_VisualizationController.get(), + SIGNAL(variableAboutToBeDeleted(std::shared_ptr)), Qt::DirectConnection); m_DataSourceController->moveToThread(&m_DataSourceControllerThread); m_VariableController->moveToThread(&m_VariableControllerThread); diff --git a/gui/src/Variable/VariableInspectorWidget.cpp b/gui/src/Variable/VariableInspectorWidget.cpp index d26beb4..fe00434 100644 --- a/gui/src/Variable/VariableInspectorWidget.cpp +++ b/gui/src/Variable/VariableInspectorWidget.cpp @@ -68,8 +68,8 @@ void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept // Adds menu-specific actions if (!selectedVariables.isEmpty()) { // 'Delete' action - auto deleteFun = []() { - /// @todo ALX : call variable deletion + auto deleteFun = [&selectedVariables]() { + sqpApp->variableController().deleteVariables(selectedVariables); }; tableMenu.addSeparator();