Auto status change to "Under Review"
@@ -54,6 +54,7 public: | |||||
54 | QUrl imageTemporaryUrl(const QImage &image) const; |
|
54 | QUrl imageTemporaryUrl(const QImage &image) const; | |
55 |
|
55 | |||
56 | void setHightlightedDragWidget(VisualizationDragWidget *dragWidget); |
|
56 | void setHightlightedDragWidget(VisualizationDragWidget *dragWidget); | |
|
57 | VisualizationDragWidget *getHightlightedDragWidget() const; | |||
57 |
|
58 | |||
58 | private: |
|
59 | private: | |
59 | class DragDropHelperPrivate; |
|
60 | class DragDropHelperPrivate; |
@@ -17,7 +17,8 class VisualizationDragDropContainer : public QWidget { | |||||
17 | Q_OBJECT |
|
17 | Q_OBJECT | |
18 |
|
18 | |||
19 | signals: |
|
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 | public: |
|
23 | public: | |
23 | using AcceptMimeDataFunction = std::function<bool(const QMimeData *mimeData)>; |
|
24 | using AcceptMimeDataFunction = std::function<bool(const QMimeData *mimeData)>; |
@@ -85,6 +85,7 private slots: | |||||
85 | void onVariableAboutToBeRemoved(std::shared_ptr<Variable> variable); |
|
85 | void onVariableAboutToBeRemoved(std::shared_ptr<Variable> variable); | |
86 |
|
86 | |||
87 | void dropMimeData(int index, const QMimeData *mimeData); |
|
87 | void dropMimeData(int index, const QMimeData *mimeData); | |
|
88 | void dropMimeDataOnGraph(VisualizationDragWidget *dragWidget, const QMimeData *mimeData); | |||
88 | }; |
|
89 | }; | |
89 |
|
90 | |||
90 | #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H |
|
91 | #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H |
@@ -281,6 +281,11 void DragDropHelper::setHightlightedDragWidget(VisualizationDragWidget *dragWidg | |||||
281 | impl->m_HighlightedDragWidget = dragWidget; |
|
281 | impl->m_HighlightedDragWidget = dragWidget; | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
|
284 | VisualizationDragWidget *DragDropHelper::getHightlightedDragWidget() const | |||
|
285 | { | |||
|
286 | return impl->m_HighlightedDragWidget; | |||
|
287 | } | |||
|
288 | ||||
284 | bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData, |
|
289 | bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData, | |
285 | VisualizationDragDropContainer *dropContainer) |
|
290 | VisualizationDragDropContainer *dropContainer) | |
286 | { |
|
291 | { |
@@ -264,10 +264,12 void VisualizationDragDropContainer::dragMoveEvent(QDragMoveEvent *event) | |||||
264 |
|
264 | |||
265 | void VisualizationDragDropContainer::dropEvent(QDropEvent *event) |
|
265 | void VisualizationDragDropContainer::dropEvent(QDropEvent *event) | |
266 | { |
|
266 | { | |
|
267 | auto &helper = sqpApp->dragDropHelper(); | |||
|
268 | ||||
267 | if (impl->acceptMimeData(event->mimeData())) { |
|
269 | if (impl->acceptMimeData(event->mimeData())) { | |
268 |
auto dragWidget = |
|
270 | auto dragWidget = helper.getCurrentDragWidget(); | |
269 | if (impl->hasPlaceHolder()) { |
|
271 | if (impl->hasPlaceHolder()) { | |
270 | auto &helper = sqpApp->dragDropHelper(); |
|
272 | // drop where the placeHolder is located | |
271 |
|
273 | |||
272 | auto droppedIndex = impl->m_Layout->indexOf(&helper.placeHolder()); |
|
274 | auto droppedIndex = impl->m_Layout->indexOf(&helper.placeHolder()); | |
273 |
|
275 | |||
@@ -287,13 +289,22 void VisualizationDragDropContainer::dropEvent(QDropEvent *event) | |||||
287 |
|
289 | |||
288 | helper.removePlaceHolder(); |
|
290 | helper.removePlaceHolder(); | |
289 |
|
291 | |||
290 | emit dropOccured(droppedIndex, event->mimeData()); |
|
292 | emit dropOccuredInContainer(droppedIndex, event->mimeData()); | |
|
293 | } | |||
|
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()); | |||
291 | } |
|
301 | } | |
292 | else { |
|
302 | else { | |
293 | qCWarning(LOG_VisualizationDragDropContainer()) |
|
303 | qCWarning(LOG_VisualizationDragDropContainer()) | |
294 |
<< tr("VisualizationDragDropContainer::dropEvent, |
|
304 | << tr("VisualizationDragDropContainer::dropEvent, dropping on a widget, but " | |
295 |
" |
|
305 | "the merge is forbidden."); | |
296 |
|
|
306 | Q_ASSERT(false); | |
|
307 | } | |||
297 | } |
|
308 | } | |
298 | } |
|
309 | } | |
299 | else { |
|
310 | else { |
@@ -70,7 +70,7 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *par | |||||
70 |
|
70 | |||
71 | ui->dragDropContainer->setAcceptedMimeTypes( |
|
71 | ui->dragDropContainer->setAcceptedMimeTypes( | |
72 | {MIME_TYPE_GRAPH, MIME_TYPE_ZONE, MIME_TYPE_VARIABLE_LIST}); |
|
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 | &VisualizationTabWidget::dropMimeData); |
|
74 | &VisualizationTabWidget::dropMimeData); | |
75 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { |
|
75 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { | |
76 | return sqpApp->dragDropHelper().checkMimeDataForVisualization(mimeData, |
|
76 | return sqpApp->dragDropHelper().checkMimeDataForVisualization(mimeData, |
@@ -91,8 +91,11 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *p | |||||
91 | return sqpApp->dragDropHelper().checkMimeDataForVisualization(mimeData, |
|
91 | return sqpApp->dragDropHelper().checkMimeDataForVisualization(mimeData, | |
92 | ui->dragDropContainer); |
|
92 | ui->dragDropContainer); | |
93 | }); |
|
93 | }); | |
94 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccured, this, |
|
94 | ||
|
95 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, | |||
95 | &VisualizationZoneWidget::dropMimeData); |
|
96 | &VisualizationZoneWidget::dropMimeData); | |
|
97 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredOnWidget, this, | |||
|
98 | &VisualizationZoneWidget::dropMimeDataOnGraph); | |||
96 |
|
99 | |||
97 | // 'Close' options : widget is deleted when closed |
|
100 | // 'Close' options : widget is deleted when closed | |
98 | setAttribute(Qt::WA_DeleteOnClose); |
|
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 | void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph( |
|
412 | void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph( | |
385 | int index, VisualizationZoneWidget *zoneWidget) |
|
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