diff --git a/core/include/Variable/VariableModel.h b/core/include/Variable/VariableModel.h index 02b204b..7fa865a 100644 --- a/core/include/Variable/VariableModel.h +++ b/core/include/Variable/VariableModel.h @@ -25,12 +25,10 @@ public: * Creates a new variable in the model * @param name the name of the new variable * @param dateTime the dateTime of the new variable - * @param defaultDataSeries the default data of the new variable * @return the pointer to the new variable */ - std::shared_ptr - createVariable(const QString &name, const SqpDateTime &dateTime, - std::shared_ptr defaultDataSeries) noexcept; + std::shared_ptr createVariable(const QString &name, + const SqpDateTime &dateTime) noexcept; std::shared_ptr variable(int index) const; diff --git a/core/src/Variable/VariableCacheController.cpp b/core/src/Variable/VariableCacheController.cpp index b5cbd3b..a648b4d 100644 --- a/core/src/Variable/VariableCacheController.cpp +++ b/core/src/Variable/VariableCacheController.cpp @@ -55,7 +55,7 @@ void VariableCacheController::addDateTime(std::shared_ptr variable, impl->m_VariableToSqpDateTimeListMap.at(variable), 0); } catch (const std::out_of_range &e) { - qCWarning(LOG_VariableCacheController()) << e.what(); + qCWarning(LOG_VariableCacheController()) << "addDateTime" << e.what(); } } } @@ -71,13 +71,12 @@ VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr // list of date time request associated to the variable // We assume that the list is ordered in a way that l(0) < l(1). We assume also a < b // (with a & b of type SqpDateTime) means ts(b) > te(a) - - try { - impl->addInCacheDataByStart(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable), - notInCache, 0, dateTime.m_TStart); + auto it = impl->m_VariableToSqpDateTimeListMap.find(variable); + if (it != impl->m_VariableToSqpDateTimeListMap.end()) { + impl->addInCacheDataByStart(dateTime, it->second, notInCache, 0, dateTime.m_TStart); } - catch (const std::out_of_range &e) { - qCWarning(LOG_VariableCacheController()) << e.what(); + else { + notInCache << dateTime; } return notInCache; diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index 88a5567..0ac0a8b 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -99,8 +99,7 @@ void VariableController::createVariable(const QString &name, /// - default data are generated for the variable, without taking into account the timerange set /// in sciqlop auto dateTime = impl->m_TimeController->dateTime(); - if (auto newVariable = impl->m_VariableModel->createVariable( - name, dateTime, generateDefaultDataSeries(*provider, dateTime))) { + if (auto newVariable = impl->m_VariableModel->createVariable(name, dateTime)) { // store the provider impl->m_VariableToProviderMap[newVariable] = provider; @@ -114,10 +113,7 @@ void VariableController::createVariable(const QString &name, }; connect(provider.get(), &IDataProvider::dataProvided, addDateTimeAcquired); - - - // store in cache - impl->m_VariableCacheController->addDateTime(newVariable, dateTime); + this->onRequestDataLoading(newVariable, dateTime); // notify the creation emit variableCreated(newVariable); diff --git a/core/src/Variable/VariableModel.cpp b/core/src/Variable/VariableModel.cpp index f03350b..9d6c6f1 100644 --- a/core/src/Variable/VariableModel.cpp +++ b/core/src/Variable/VariableModel.cpp @@ -52,9 +52,8 @@ VariableModel::VariableModel(QObject *parent) { } -std::shared_ptr -VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime, - std::shared_ptr defaultDataSeries) noexcept +std::shared_ptr VariableModel::createVariable(const QString &name, + const SqpDateTime &dateTime) noexcept { auto insertIndex = rowCount(); beginInsertRows({}, insertIndex, insertIndex); @@ -62,7 +61,6 @@ VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime, /// @todo For the moment, the other data of the variable is initialized with default values auto variable = std::make_shared(name, QStringLiteral("unit"), QStringLiteral("mission"), dateTime); - variable->setDataSeries(std::move(defaultDataSeries)); impl->m_Variables.push_back(variable);