From 90c64bed8482ab6dfde0627c317c93aab9bd9533 2017-06-19 09:05:39 From: Alexandre Leroux Date: 2017-06-19 09:05:39 Subject: [PATCH] Makes the connection between Data source controller and Variable controller - Adds a signal to prevent a variable creation request from the data source controller - Connects the signal to the slot that creates a variable in the variable controller --- diff --git a/core/include/Data/IDataProvider.h b/core/include/Data/IDataProvider.h index 0b83f2b..628d123 100644 --- a/core/include/Data/IDataProvider.h +++ b/core/include/Data/IDataProvider.h @@ -3,6 +3,8 @@ #include +#include + class DataProviderParameters; class IDataSeries; @@ -22,4 +24,7 @@ public: retrieveData(const DataProviderParameters ¶meters) const = 0; }; +// Required for using shared_ptr in signals/slots +Q_DECLARE_METATYPE(std::shared_ptr) + #endif // SCIQLOP_IDATAPROVIDER_H diff --git a/core/include/DataSource/DataSourceController.h b/core/include/DataSource/DataSourceController.h index 3aeaafc..d274f88 100644 --- a/core/include/DataSource/DataSourceController.h +++ b/core/include/DataSource/DataSourceController.h @@ -71,6 +71,15 @@ signals: /// Signal emitted when a structure has been set for a data source void dataSourceItemSet(DataSourceItem *dataSourceItem); + /** + * Signal emitted when a variable creation is asked for a product + * @param variableName the name of the variable + * @param variableProvider the provider that will be used to retrieve the data of the variable + * (can be null) + */ + void variableCreationRequested(const QString &variableName, + std::shared_ptr variableProvider); + private: void waitForFinish(); diff --git a/core/src/DataSource/DataSourceController.cpp b/core/src/DataSource/DataSourceController.cpp index e6e5043..2410176 100644 --- a/core/src/DataSource/DataSourceController.cpp +++ b/core/src/DataSource/DataSourceController.cpp @@ -86,6 +86,9 @@ void DataSourceController::loadProductItem(const QUuid &dataSourceUid, /// Retrieves the data provider of the data source (if any) auto it = impl->m_DataProviders.find(dataSourceUid); auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr; + + /// @todo retrieve timerange, and pass it to the signal + emit variableCreationRequested(productItem.name(), dataProvider); } else { qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product"); diff --git a/gui/src/SqpApplication.cpp b/gui/src/SqpApplication.cpp index dc45d7f..0df84d4 100644 --- a/gui/src/SqpApplication.cpp +++ b/gui/src/SqpApplication.cpp @@ -1,5 +1,6 @@ #include "SqpApplication.h" +#include #include #include #include @@ -14,6 +15,17 @@ public: m_VariableController{std::make_unique()}, m_VisualizationController{std::make_unique()} { + // /////////////////////////////// // + // Connections between controllers // + // /////////////////////////////// // + + // VariableController <-> DataSourceController + qRegisterMetaType >(); + connect(m_DataSourceController.get(), + SIGNAL(variableCreationRequested(const QString &, std::shared_ptr)), + m_VariableController.get(), + SLOT(createVariable(const QString &, std::shared_ptr))); + m_DataSourceController->moveToThread(&m_DataSourceControllerThread); m_VariableController->moveToThread(&m_VariableControllerThread); m_VisualizationController->moveToThread(&m_VisualizationControllerThread);