##// END OF EJS Templates
Drop TIME mime data on a variable
trabillard -
r933:ba45dcc66c3a
parent child
Show More
@@ -102,6 +102,9 public slots:
102 /// Update the temporal parameters of every selected variable to dateTime
102 /// Update the temporal parameters of every selected variable to dateTime
103 void onDateTimeOnSelection(const SqpRange &dateTime);
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 void onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
109 void onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
107 const SqpRange &cacheRangeRequested,
110 const SqpRange &cacheRangeRequested,
@@ -94,6 +94,7 public:
94 signals:
94 signals:
95 void abortProgessRequested(std::shared_ptr<Variable> variable);
95 void abortProgessRequested(std::shared_ptr<Variable> variable);
96 void requestVariable(const QVariantHash &productData);
96 void requestVariable(const QVariantHash &productData);
97 void requestVariableRangeUpdate(std::shared_ptr<Variable> variable, const SqpRange &range);
97
98
98 private:
99 private:
99 class VariableModelPrivate;
100 class VariableModelPrivate;
@@ -187,6 +187,8 VariableController::VariableController(QObject *parent)
187 connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished,
187 connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished,
188 impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::finalize);
188 impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::finalize);
189
189
190 connect(impl->m_VariableModel, &VariableModel::requestVariableRangeUpdate, this,
191 &VariableController::onUpdateDateTime);
190
192
191 impl->m_VariableAcquisitionWorkerThread.start();
193 impl->m_VariableAcquisitionWorkerThread.start();
192 }
194 }
@@ -385,21 +387,7 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
385 if (auto selectedVariable
387 if (auto selectedVariable
386 = impl->m_VariableModel->variable(qAsConst(selectedRows).first().row())) {
388 = impl->m_VariableModel->variable(qAsConst(selectedRows).first().row())) {
387
389
388 auto itVar = impl->m_VariableToIdentifierMap.find(selectedVariable);
390 onUpdateDateTime(selectedVariable, dateTime);
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);
403 }
391 }
404 }
392 }
405 else if (selectedRows.size() > 1) {
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 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
422 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
416 const SqpRange &cacheRangeRequested,
423 const SqpRange &cacheRangeRequested,
417 QVector<AcquisitionDataPacket> dataAcquired)
424 QVector<AcquisitionDataPacket> dataAcquired)
@@ -13,6 +13,7
13
13
14 #include <QMimeData>
14 #include <QMimeData>
15 #include <QSize>
15 #include <QSize>
16 #include <QTimer>
16 #include <unordered_map>
17 #include <unordered_map>
17
18
18 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
19 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
@@ -322,7 +323,9 bool VariableModel::canDropMimeData(const QMimeData *data, Qt::DropAction action
322 int column, const QModelIndex &parent) const
323 int column, const QModelIndex &parent) const
323 {
324 {
324 // drop of a product
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 bool VariableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
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 dropDone = true;
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 return dropDone;
356 return dropDone;
346 }
357 }
General Comments 0
You need to be logged in to leave comments. Login now