##// END OF EJS Templates
Drop TIME mime data on a variable
trabillard -
r974:ba45dcc66c3a
parent child
Show More
@@ -102,6 +102,9 public slots:
102 102 /// Update the temporal parameters of every selected variable to dateTime
103 103 void onDateTimeOnSelection(const SqpRange &dateTime);
104 104
105 /// Update the temporal parameters of the specified variable
106 void onUpdateDateTime(std::shared_ptr<Variable> variable, const SqpRange &dateTime);
107
105 108
106 109 void onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
107 110 const SqpRange &cacheRangeRequested,
@@ -94,6 +94,7 public:
94 94 signals:
95 95 void abortProgessRequested(std::shared_ptr<Variable> variable);
96 96 void requestVariable(const QVariantHash &productData);
97 void requestVariableRangeUpdate(std::shared_ptr<Variable> variable, const SqpRange &range);
97 98
98 99 private:
99 100 class VariableModelPrivate;
@@ -187,6 +187,8 VariableController::VariableController(QObject *parent)
187 187 connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished,
188 188 impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::finalize);
189 189
190 connect(impl->m_VariableModel, &VariableModel::requestVariableRangeUpdate, this,
191 &VariableController::onUpdateDateTime);
190 192
191 193 impl->m_VariableAcquisitionWorkerThread.start();
192 194 }
@@ -385,21 +387,7 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
385 387 if (auto selectedVariable
386 388 = impl->m_VariableModel->variable(qAsConst(selectedRows).first().row())) {
387 389
388 auto itVar = impl->m_VariableToIdentifierMap.find(selectedVariable);
389 if (itVar == impl->m_VariableToIdentifierMap.cend()) {
390 qCCritical(LOG_VariableController())
391 << tr("Impossible to onDateTimeOnSelection request for unknown variable");
392 return;
393 }
394
395 // notify that rescale operation has to be done
396 emit rangeChanged(selectedVariable, dateTime);
397
398 auto synchro = impl->m_VariableIdGroupIdMap.find(itVar->second)
399 != impl->m_VariableIdGroupIdMap.cend();
400
401 this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{selectedVariable},
402 dateTime, synchro);
390 onUpdateDateTime(selectedVariable, dateTime);
403 391 }
404 392 }
405 393 else if (selectedRows.size() > 1) {
@@ -412,6 +400,25 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
412 400 }
413 401 }
414 402
403 void VariableController::onUpdateDateTime(std::shared_ptr<Variable> variable,
404 const SqpRange &dateTime)
405 {
406 auto itVar = impl->m_VariableToIdentifierMap.find(variable);
407 if (itVar == impl->m_VariableToIdentifierMap.cend()) {
408 qCCritical(LOG_VariableController())
409 << tr("Impossible to onDateTimeOnSelection request for unknown variable");
410 return;
411 }
412
413 // notify that rescale operation has to be done
414 emit rangeChanged(variable, dateTime);
415
416 auto synchro
417 = impl->m_VariableIdGroupIdMap.find(itVar->second) != impl->m_VariableIdGroupIdMap.cend();
418
419 this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{variable}, dateTime, synchro);
420 }
421
415 422 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
416 423 const SqpRange &cacheRangeRequested,
417 424 QVector<AcquisitionDataPacket> dataAcquired)
@@ -13,6 +13,7
13 13
14 14 #include <QMimeData>
15 15 #include <QSize>
16 #include <QTimer>
16 17 #include <unordered_map>
17 18
18 19 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
@@ -322,7 +323,9 bool VariableModel::canDropMimeData(const QMimeData *data, Qt::DropAction action
322 323 int column, const QModelIndex &parent) const
323 324 {
324 325 // drop of a product
325 return data->hasFormat(MIME_TYPE_PRODUCT_LIST);
326 return data->hasFormat(MIME_TYPE_PRODUCT_LIST)
327 || (data->hasFormat(MIME_TYPE_TIME_RANGE) && parent.isValid()
328 && !data->hasFormat(MIME_TYPE_VARIABLE_LIST));
326 329 }
327 330
328 331 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
341 344
342 345 dropDone = true;
343 346 }
347 else if (data->hasFormat(MIME_TYPE_TIME_RANGE) && parent.isValid()) {
348 auto variable = this->variable(parent.row());
349 auto range = TimeController::timeRangeForMimeData(data->data(MIME_TYPE_TIME_RANGE));
350
351 emit requestVariableRangeUpdate(variable, range);
352
353 dropDone = true;
354 }
344 355
345 356 return dropDone;
346 357 }
General Comments 1
Under Review
author

Auto status change to "Under Review"

You need to be logged in to leave comments. Login now