##// END OF EJS Templates
Fixes for review
trabillard -
r849:3f7ba55eb4d2
parent child
Show More
@@ -1,5 +1,5
1 #ifndef VISUALIZATIONDRAGDROPCONTAINER_H
1 #ifndef SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H
2 #define VISUALIZATIONDRAGDROPCONTAINER_H
2 #define SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QMimeData>
5 #include <QMimeData>
@@ -39,4 +39,4 private slots:
39 void startDrag(VisualizationDragWidget *dragWidget, const QPoint &dragPosition);
39 void startDrag(VisualizationDragWidget *dragWidget, const QPoint &dragPosition);
40 };
40 };
41
41
42 #endif // VISUALIZATIONDRAGDROPCONTAINER_H
42 #endif // SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H
@@ -1,5 +1,5
1 #ifndef VISUALIZATIONDRAGWIDGET_H
1 #ifndef SCIQLOP_VISUALIZATIONDRAGWIDGET_H
2 #define VISUALIZATIONDRAGWIDGET_H
2 #define SCIQLOP_VISUALIZATIONDRAGWIDGET_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QMimeData>
5 #include <QMimeData>
@@ -26,4 +26,4 signals:
26 void dragDetected(VisualizationDragWidget *dragWidget, const QPoint &dragPosition);
26 void dragDetected(VisualizationDragWidget *dragWidget, const QPoint &dragPosition);
27 };
27 };
28
28
29 #endif // VISUALIZATIONDRAGWIDGET_H
29 #endif // SCIQLOP_VISUALIZATIONDRAGWIDGET_H
@@ -71,7 +71,6 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
71 auto adustNum = 18; // to be safe, in case of scrollbar on the side
71 auto adustNum = 18; // to be safe, in case of scrollbar on the side
72 auto containerRect = QRect(QPoint(), container->contentsRect().size())
72 auto containerRect = QRect(QPoint(), container->contentsRect().size())
73 .adjusted(adustNum, adustNum, -adustNum, -adustNum);
73 .adjusted(adustNum, adustNum, -adustNum, -adustNum);
74 qDebug() << containerRect << container->mapFromGlobal(QCursor::pos());
75 return containerRect.contains(container->mapFromGlobal(QCursor::pos()));
74 return containerRect.contains(container->mapFromGlobal(QCursor::pos()));
76 }
75 }
77 };
76 };
@@ -114,8 +113,7 int VisualizationDragDropContainer::countDragWidget() const
114 {
113 {
115 auto nbGraph = 0;
114 auto nbGraph = 0;
116 for (auto child : children()) {
115 for (auto child : children()) {
117 auto widget = qobject_cast<VisualizationDragWidget *>(child);
116 if (qobject_cast<VisualizationDragWidget *>(child)) {
118 if (widget) {
119 nbGraph += 1;
117 nbGraph += 1;
120 }
118 }
121 }
119 }
@@ -129,7 +127,7 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidg
129 auto &helper = sqpApp->dragDropHelper();
127 auto &helper = sqpApp->dragDropHelper();
130
128
131 // Note: The management of the drag object is done by Qt
129 // Note: The management of the drag object is done by Qt
132 auto *drag = new QDrag{dragWidget};
130 auto drag = new QDrag{dragWidget};
133 drag->setHotSpot(dragPosition);
131 drag->setHotSpot(dragPosition);
134
132
135 auto mimeData = dragWidget->mimeData();
133 auto mimeData = dragWidget->mimeData();
@@ -189,8 +187,9 void VisualizationDragDropContainer::dragEnterEvent(QDragEnterEvent *event)
189 }
187 }
190 }
188 }
191 }
189 }
192 else
190 else {
193 event->ignore();
191 event->ignore();
192 }
194
193
195 QWidget::dragEnterEvent(event);
194 QWidget::dragEnterEvent(event);
196 }
195 }
@@ -206,7 +205,7 void VisualizationDragDropContainer::dragLeaveEvent(QDragLeaveEvent *event)
206
205
207 bool isInternal = true;
206 bool isInternal = true;
208 if (isInternal) {
207 if (isInternal) {
209 // Only if the drag is strated from the visualization
208 // Only if the drag is started from the visualization
210 // Show the drag widget at its original place
209 // Show the drag widget at its original place
211 // So the drag widget doesn't stay hidden if the drop occurs outside the visualization
210 // So the drag widget doesn't stay hidden if the drop occurs outside the visualization
212 // drop zone (It is not possible to catch a drop event outside of the application)
211 // drop zone (It is not possible to catch a drop event outside of the application)
@@ -264,8 +263,9 void VisualizationDragDropContainer::dragMoveEvent(QDragMoveEvent *event)
264 }
263 }
265 }
264 }
266 }
265 }
267 else
266 else {
268 event->ignore();
267 event->ignore();
268 }
269
269
270 QWidget::dragMoveEvent(event);
270 QWidget::dragMoveEvent(event);
271 }
271 }
@@ -286,7 +286,6 void VisualizationDragDropContainer::dropEvent(QDropEvent *event)
286 }
286 }
287
287
288 dragWidget->setVisible(true);
288 dragWidget->setVisible(true);
289 dragWidget->setStyleSheet("");
290
289
291 event->acceptProposedAction();
290 event->acceptProposedAction();
292
291
@@ -295,8 +294,9 void VisualizationDragDropContainer::dropEvent(QDropEvent *event)
295 emit dropOccured(droppedIndex, event->mimeData());
294 emit dropOccured(droppedIndex, event->mimeData());
296 }
295 }
297 }
296 }
298 else
297 else {
299 event->ignore();
298 event->ignore();
299 }
300
300
301 QWidget::dropEvent(event);
301 QWidget::dropEvent(event);
302 }
302 }
@@ -97,9 +97,9 VisualizationGraphWidget::~VisualizationGraphWidget()
97 VisualizationZoneWidget *VisualizationGraphWidget::parentZoneWidget() const noexcept
97 VisualizationZoneWidget *VisualizationGraphWidget::parentZoneWidget() const noexcept
98 {
98 {
99 auto parent = parentWidget();
99 auto parent = parentWidget();
100 do {
100 while (parent != nullptr && !qobject_cast<VisualizationZoneWidget *>(parent)) {
101 parent = parent->parentWidget();
101 parent = parent->parentWidget();
102 } while (parent != nullptr && !qobject_cast<VisualizationZoneWidget *>(parent));
102 }
103
103
104 return qobject_cast<VisualizationZoneWidget *>(parent);
104 return qobject_cast<VisualizationZoneWidget *>(parent);
105 }
105 }
@@ -231,7 +231,7 QString VisualizationGraphWidget::name() const
231
231
232 QMimeData *VisualizationGraphWidget::mimeData() const
232 QMimeData *VisualizationGraphWidget::mimeData() const
233 {
233 {
234 auto *mimeData = new QMimeData;
234 auto mimeData = new QMimeData;
235 mimeData->setData(DragDropHelper::MIME_TYPE_GRAPH, QByteArray());
235 mimeData->setData(DragDropHelper::MIME_TYPE_GRAPH, QByteArray());
236
236
237 return mimeData;
237 return mimeData;
@@ -314,7 +314,7 QString VisualizationZoneWidget::name() const
314
314
315 QMimeData *VisualizationZoneWidget::mimeData() const
315 QMimeData *VisualizationZoneWidget::mimeData() const
316 {
316 {
317 auto *mimeData = new QMimeData;
317 auto mimeData = new QMimeData;
318 mimeData->setData(DragDropHelper::MIME_TYPE_ZONE, QByteArray());
318 mimeData->setData(DragDropHelper::MIME_TYPE_ZONE, QByteArray());
319
319
320 return mimeData;
320 return mimeData;
General Comments 6
Approved

Status change > Approved

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