##// END OF EJS Templates
Updates variable creation to pass metadata...
Alexandre Leroux -
r410:af1b645db780
parent child
Show More
@@ -74,10 +74,12 signals:
74 /**
74 /**
75 * Signal emitted when a variable creation is asked for a product
75 * Signal emitted when a variable creation is asked for a product
76 * @param variableName the name of the variable
76 * @param variableName the name of the variable
77 * @param variableMetadata the metadata of the variable
77 * @param variableProvider the provider that will be used to retrieve the data of the variable
78 * @param variableProvider the provider that will be used to retrieve the data of the variable
78 * (can be null)
79 * (can be null)
79 */
80 */
80 void variableCreationRequested(const QString &variableName,
81 void variableCreationRequested(const QString &variableName,
82 const QVariantHash &variableMetadata,
81 std::shared_ptr<IDataProvider> variableProvider);
83 std::shared_ptr<IDataProvider> variableProvider);
82
84
83 private:
85 private:
@@ -60,9 +60,11 public slots:
60 /**
60 /**
61 * Creates a new variable and adds it to the model
61 * Creates a new variable and adds it to the model
62 * @param name the name of the new variable
62 * @param name the name of the new variable
63 * @param metadata the metadata of the new variable
63 * @param provider the data provider for the new variable
64 * @param provider the data provider for the new variable
64 */
65 */
65 void createVariable(const QString &name, std::shared_ptr<IDataProvider> provider) noexcept;
66 void createVariable(const QString &name, const QVariantHash &metadata,
67 std::shared_ptr<IDataProvider> provider) noexcept;
66
68
67 /// Update the temporal parameters of every selected variable to dateTime
69 /// Update the temporal parameters of every selected variable to dateTime
68 void onDateTimeOnSelection(const SqpDateTime &dateTime);
70 void onDateTimeOnSelection(const SqpDateTime &dateTime);
@@ -29,10 +29,11 public:
29 * Creates a new variable in the model
29 * Creates a new variable in the model
30 * @param name the name of the new variable
30 * @param name the name of the new variable
31 * @param dateTime the dateTime of the new variable
31 * @param dateTime the dateTime of the new variable
32 * @param metadata the metadata associated to the new variable
32 * @return the pointer to the new variable
33 * @return the pointer to the new variable
33 */
34 */
34 std::shared_ptr<Variable> createVariable(const QString &name,
35 std::shared_ptr<Variable> createVariable(const QString &name, const SqpDateTime &dateTime,
35 const SqpDateTime &dateTime) noexcept;
36 const QVariantHash &metadata) noexcept;
36
37
37 /**
38 /**
38 * Deletes a variable from the model, if it exists
39 * Deletes a variable from the model, if it exists
@@ -94,7 +94,7 void DataSourceController::loadProductItem(const QUuid &dataSourceUid,
94 auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr;
94 auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr;
95
95
96 /// @todo retrieve timerange, and pass it to the signal
96 /// @todo retrieve timerange, and pass it to the signal
97 emit variableCreationRequested(productItem.name(), dataProvider);
97 emit variableCreationRequested(productItem.name(), productItem.data(), dataProvider);
98 }
98 }
99 else {
99 else {
100 qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product");
100 qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product");
@@ -102,7 +102,7 void VariableController::deleteVariables(
102 }
102 }
103 }
103 }
104
104
105 void VariableController::createVariable(const QString &name,
105 void VariableController::createVariable(const QString &name, const QVariantHash &metadata,
106 std::shared_ptr<IDataProvider> provider) noexcept
106 std::shared_ptr<IDataProvider> provider) noexcept
107 {
107 {
108
108
@@ -119,7 +119,8 void VariableController::createVariable(const QString &name,
119 /// - default data are generated for the variable, without taking into account the timerange set
119 /// - default data are generated for the variable, without taking into account the timerange set
120 /// in sciqlop
120 /// in sciqlop
121 auto dateTime = impl->m_TimeController->dateTime();
121 auto dateTime = impl->m_TimeController->dateTime();
122 if (auto newVariable = impl->m_VariableModel->createVariable(name, dateTime)) {
122
123 if (auto newVariable = impl->m_VariableModel->createVariable(name, dateTime, metadata)) {
123 auto identifier = QUuid::createUuid();
124 auto identifier = QUuid::createUuid();
124
125
125 // store the provider
126 // store the provider
@@ -60,12 +60,13 VariableModel::VariableModel(QObject *parent)
60 }
60 }
61
61
62 std::shared_ptr<Variable> VariableModel::createVariable(const QString &name,
62 std::shared_ptr<Variable> VariableModel::createVariable(const QString &name,
63 const SqpDateTime &dateTime) noexcept
63 const SqpDateTime &dateTime,
64 const QVariantHash &metadata) noexcept
64 {
65 {
65 auto insertIndex = rowCount();
66 auto insertIndex = rowCount();
66 beginInsertRows({}, insertIndex, insertIndex);
67 beginInsertRows({}, insertIndex, insertIndex);
67
68
68 auto variable = std::make_shared<Variable>(name, dateTime);
69 auto variable = std::make_shared<Variable>(name, dateTime, metadata);
69
70
70 impl->m_Variables.push_back(variable);
71 impl->m_Variables.push_back(variable);
71 connect(variable.get(), &Variable::updated, this, &VariableModel::onVariableUpdated);
72 connect(variable.get(), &Variable::updated, this, &VariableModel::onVariableUpdated);
@@ -26,9 +26,11 public:
26
26
27 // VariableController <-> DataSourceController
27 // VariableController <-> DataSourceController
28 connect(m_DataSourceController.get(),
28 connect(m_DataSourceController.get(),
29 SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)),
29 SIGNAL(variableCreationRequested(const QString &, const QVariantHash &,
30 std::shared_ptr<IDataProvider>)),
30 m_VariableController.get(),
31 m_VariableController.get(),
31 SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>)));
32 SLOT(createVariable(const QString &, const QVariantHash &,
33 std::shared_ptr<IDataProvider>)));
32
34
33 // VariableController <-> VisualizationController
35 // VariableController <-> VisualizationController
34 connect(m_VariableController.get(),
36 connect(m_VariableController.get(),
General Comments 0
You need to be logged in to leave comments. Login now