Auto status change to "Under Review"
@@ -54,6 +54,7 public: | |||
|
54 | 54 | QUrl imageTemporaryUrl(const QImage &image) const; |
|
55 | 55 | |
|
56 | 56 | void setHightlightedDragWidget(VisualizationDragWidget *dragWidget); |
|
57 | VisualizationDragWidget *getHightlightedDragWidget() const; | |
|
57 | 58 | |
|
58 | 59 | private: |
|
59 | 60 | class DragDropHelperPrivate; |
@@ -17,7 +17,8 class VisualizationDragDropContainer : public QWidget { | |||
|
17 | 17 | Q_OBJECT |
|
18 | 18 | |
|
19 | 19 | signals: |
|
20 | void dropOccured(int dropIndex, const QMimeData *mimeData); | |
|
20 | void dropOccuredInContainer(int dropIndex, const QMimeData *mimeData); | |
|
21 | void dropOccuredOnWidget(VisualizationDragWidget *dragWidget, const QMimeData *mimeData); | |
|
21 | 22 | |
|
22 | 23 | public: |
|
23 | 24 | using AcceptMimeDataFunction = std::function<bool(const QMimeData *mimeData)>; |
@@ -85,6 +85,7 private slots: | |||
|
85 | 85 | void onVariableAboutToBeRemoved(std::shared_ptr<Variable> variable); |
|
86 | 86 | |
|
87 | 87 | void dropMimeData(int index, const QMimeData *mimeData); |
|
88 | void dropMimeDataOnGraph(VisualizationDragWidget *dragWidget, const QMimeData *mimeData); | |
|
88 | 89 | }; |
|
89 | 90 | |
|
90 | 91 | #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H |
@@ -281,6 +281,11 void DragDropHelper::setHightlightedDragWidget(VisualizationDragWidget *dragWidg | |||
|
281 | 281 | impl->m_HighlightedDragWidget = dragWidget; |
|
282 | 282 | } |
|
283 | 283 | |
|
284 | VisualizationDragWidget *DragDropHelper::getHightlightedDragWidget() const | |
|
285 | { | |
|
286 | return impl->m_HighlightedDragWidget; | |
|
287 | } | |
|
288 | ||
|
284 | 289 | bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData, |
|
285 | 290 | VisualizationDragDropContainer *dropContainer) |
|
286 | 291 | { |
@@ -264,10 +264,12 void VisualizationDragDropContainer::dragMoveEvent(QDragMoveEvent *event) | |||
|
264 | 264 | |
|
265 | 265 | void VisualizationDragDropContainer::dropEvent(QDropEvent *event) |
|
266 | 266 | { |
|
267 | auto &helper = sqpApp->dragDropHelper(); | |
|
268 | ||
|
267 | 269 | if (impl->acceptMimeData(event->mimeData())) { |
|
268 |
auto dragWidget = |
|
|
270 | auto dragWidget = helper.getCurrentDragWidget(); | |
|
269 | 271 | if (impl->hasPlaceHolder()) { |
|
270 | auto &helper = sqpApp->dragDropHelper(); | |
|
272 | // drop where the placeHolder is located | |
|
271 | 273 | |
|
272 | 274 | auto droppedIndex = impl->m_Layout->indexOf(&helper.placeHolder()); |
|
273 | 275 | |
@@ -287,13 +289,22 void VisualizationDragDropContainer::dropEvent(QDropEvent *event) | |||
|
287 | 289 | |
|
288 | 290 | helper.removePlaceHolder(); |
|
289 | 291 | |
|
290 | emit dropOccured(droppedIndex, event->mimeData()); | |
|
292 | emit dropOccuredInContainer(droppedIndex, event->mimeData()); | |
|
291 | 293 | } |
|
292 | else { | |
|
293 | qCWarning(LOG_VisualizationDragDropContainer()) | |
|
294 | << tr("VisualizationDragDropContainer::dropEvent, couldn't drop because the " | |
|
295 | "placeHolder is not found."); | |
|
296 | // Q_ASSERT(false); | |
|
294 | else if (helper.getHightlightedDragWidget()) { | |
|
295 | // drop on the highlighted widget | |
|
296 | ||
|
297 | auto canMerge = impl->allowMergeMimeData(event->mimeData()); | |
|
298 | if (canMerge) { | |
|
299 | event->acceptProposedAction(); | |
|
300 | emit dropOccuredOnWidget(helper.getHightlightedDragWidget(), event->mimeData()); | |
|
301 | } | |
|
302 | else { | |
|
303 | qCWarning(LOG_VisualizationDragDropContainer()) | |
|
304 | << tr("VisualizationDragDropContainer::dropEvent, dropping on a widget, but " | |
|
305 | "the merge is forbidden."); | |
|
306 | Q_ASSERT(false); | |
|
307 | } | |
|
297 | 308 | } |
|
298 | 309 | } |
|
299 | 310 | else { |
@@ -70,7 +70,7 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *par | |||
|
70 | 70 | |
|
71 | 71 | ui->dragDropContainer->setAcceptedMimeTypes( |
|
72 | 72 | {MIME_TYPE_GRAPH, MIME_TYPE_ZONE, MIME_TYPE_VARIABLE_LIST}); |
|
73 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccured, this, | |
|
73 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, | |
|
74 | 74 | &VisualizationTabWidget::dropMimeData); |
|
75 | 75 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { |
|
76 | 76 | return sqpApp->dragDropHelper().checkMimeDataForVisualization(mimeData, |
@@ -91,8 +91,11 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *p | |||
|
91 | 91 | return sqpApp->dragDropHelper().checkMimeDataForVisualization(mimeData, |
|
92 | 92 | ui->dragDropContainer); |
|
93 | 93 | }); |
|
94 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccured, this, | |
|
94 | ||
|
95 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, | |
|
95 | 96 | &VisualizationZoneWidget::dropMimeData); |
|
97 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredOnWidget, this, | |
|
98 | &VisualizationZoneWidget::dropMimeDataOnGraph); | |
|
96 | 99 | |
|
97 | 100 | // 'Close' options : widget is deleted when closed |
|
98 | 101 | setAttribute(Qt::WA_DeleteOnClose); |
@@ -381,6 +384,31 void VisualizationZoneWidget::dropMimeData(int index, const QMimeData *mimeData) | |||
|
381 | 384 | } |
|
382 | 385 | } |
|
383 | 386 | |
|
387 | void VisualizationZoneWidget::dropMimeDataOnGraph(VisualizationDragWidget *dragWidget, | |
|
388 | const QMimeData *mimeData) | |
|
389 | { | |
|
390 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(dragWidget); | |
|
391 | if (!graphWidget) { | |
|
392 | qCWarning(LOG_VisualizationZoneWidget()) | |
|
393 | << tr("VisualizationZoneWidget::dropMimeDataOnGraph, dropping in an unknown widget, " | |
|
394 | "drop aborted"); | |
|
395 | Q_ASSERT(false); | |
|
396 | return; | |
|
397 | } | |
|
398 | ||
|
399 | if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { | |
|
400 | auto variables = sqpApp->variableController().variablesForMimeData( | |
|
401 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); | |
|
402 | for (const auto &var : variables) { | |
|
403 | graphWidget->addVariable(var, graphWidget->graphRange()); | |
|
404 | } | |
|
405 | } | |
|
406 | else { | |
|
407 | qCWarning(LOG_VisualizationZoneWidget()) | |
|
408 | << tr("VisualizationZoneWidget::dropMimeDataOnGraph, unknown MIME data received."); | |
|
409 | } | |
|
410 | } | |
|
411 | ||
|
384 | 412 | void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph( |
|
385 | 413 | int index, VisualizationZoneWidget *zoneWidget) |
|
386 | 414 | { |
General Comments 3
Pull request updated. Auto status change to "Under Review"
Changed commits: * 1 added * 0 removed Changed files: * A core/tests/meson.build
You need to be logged in to leave comments.
Login now