diff --git a/core/include/Variable/VariableController.h b/core/include/Variable/VariableController.h index 984e738..66aab49 100644 --- a/core/include/Variable/VariableController.h +++ b/core/include/Variable/VariableController.h @@ -102,6 +102,9 @@ public slots: /// Update the temporal parameters of every selected variable to dateTime void onDateTimeOnSelection(const SqpRange &dateTime); + /// Update the temporal parameters of the specified variable + void onUpdateDateTime(std::shared_ptr variable, const SqpRange &dateTime); + void onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, const SqpRange &cacheRangeRequested, diff --git a/core/include/Variable/VariableModel.h b/core/include/Variable/VariableModel.h index f3928f8..ea0bdca 100644 --- a/core/include/Variable/VariableModel.h +++ b/core/include/Variable/VariableModel.h @@ -94,6 +94,7 @@ public: signals: void abortProgessRequested(std::shared_ptr variable); void requestVariable(const QVariantHash &productData); + void requestVariableRangeUpdate(std::shared_ptr variable, const SqpRange &range); private: class VariableModelPrivate; diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index 0a6fbb1..848d1f2 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -187,6 +187,8 @@ VariableController::VariableController(QObject *parent) connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished, impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::finalize); + connect(impl->m_VariableModel, &VariableModel::requestVariableRangeUpdate, this, + &VariableController::onUpdateDateTime); impl->m_VariableAcquisitionWorkerThread.start(); } @@ -385,21 +387,7 @@ void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) if (auto selectedVariable = impl->m_VariableModel->variable(qAsConst(selectedRows).first().row())) { - auto itVar = impl->m_VariableToIdentifierMap.find(selectedVariable); - if (itVar == impl->m_VariableToIdentifierMap.cend()) { - qCCritical(LOG_VariableController()) - << tr("Impossible to onDateTimeOnSelection request for unknown variable"); - return; - } - - // notify that rescale operation has to be done - emit rangeChanged(selectedVariable, dateTime); - - auto synchro = impl->m_VariableIdGroupIdMap.find(itVar->second) - != impl->m_VariableIdGroupIdMap.cend(); - - this->onRequestDataLoading(QVector >{selectedVariable}, - dateTime, synchro); + onUpdateDateTime(selectedVariable, dateTime); } } else if (selectedRows.size() > 1) { @@ -412,6 +400,25 @@ void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) } } +void VariableController::onUpdateDateTime(std::shared_ptr variable, + const SqpRange &dateTime) +{ + auto itVar = impl->m_VariableToIdentifierMap.find(variable); + if (itVar == impl->m_VariableToIdentifierMap.cend()) { + qCCritical(LOG_VariableController()) + << tr("Impossible to onDateTimeOnSelection request for unknown variable"); + return; + } + + // notify that rescale operation has to be done + emit rangeChanged(variable, dateTime); + + auto synchro + = impl->m_VariableIdGroupIdMap.find(itVar->second) != impl->m_VariableIdGroupIdMap.cend(); + + this->onRequestDataLoading(QVector >{variable}, dateTime, synchro); +} + void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, const SqpRange &cacheRangeRequested, QVector dataAcquired) diff --git a/core/src/Variable/VariableModel.cpp b/core/src/Variable/VariableModel.cpp index f85f179..9c91f18 100644 --- a/core/src/Variable/VariableModel.cpp +++ b/core/src/Variable/VariableModel.cpp @@ -13,6 +13,7 @@ #include #include +#include #include Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel") @@ -322,7 +323,9 @@ bool VariableModel::canDropMimeData(const QMimeData *data, Qt::DropAction action int column, const QModelIndex &parent) const { // drop of a product - return data->hasFormat(MIME_TYPE_PRODUCT_LIST); + return data->hasFormat(MIME_TYPE_PRODUCT_LIST) + || (data->hasFormat(MIME_TYPE_TIME_RANGE) && parent.isValid() + && !data->hasFormat(MIME_TYPE_VARIABLE_LIST)); } bool VariableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, @@ -341,6 +344,14 @@ bool VariableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, i dropDone = true; } + else if (data->hasFormat(MIME_TYPE_TIME_RANGE) && parent.isValid()) { + auto variable = this->variable(parent.row()); + auto range = TimeController::timeRangeForMimeData(data->data(MIME_TYPE_TIME_RANGE)); + + emit requestVariableRangeUpdate(variable, range); + + dropDone = true; + } return dropDone; }