summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview/qgraphicsview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsview.cpp')
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp80
1 files changed, 37 insertions, 43 deletions
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 22ec829507..9c04a3c193 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -706,56 +706,50 @@ QRegion QGraphicsViewPrivate::rubberBandRegion(const QWidget *widget, const QRec
return tmp;
}
-void QGraphicsViewPrivate::updateRubberBand(QMouseEvent *event)
+void QGraphicsViewPrivate::updateRubberBand(const QMouseEvent *event)
{
Q_Q(QGraphicsView);
- if (dragMode == QGraphicsView::RubberBandDrag && sceneInteractionAllowed) {
- storeMouseEvent(event);
- if (rubberBanding) {
- // Check for enough drag distance
- if ((mousePressViewPoint - event->pos()).manhattanLength()
- < QApplication::startDragDistance()) {
- return;
- }
+ if (dragMode != QGraphicsView::RubberBandDrag || !sceneInteractionAllowed || !rubberBanding)
+ return;
+ // Check for enough drag distance
+ if ((mousePressViewPoint - event->pos()).manhattanLength() < QApplication::startDragDistance())
+ return;
- // Update old rubberband
- if (viewportUpdateMode != QGraphicsView::NoViewportUpdate && !rubberBandRect.isEmpty()) {
- if (viewportUpdateMode != QGraphicsView::FullViewportUpdate)
- q->viewport()->update(rubberBandRegion(q->viewport(), rubberBandRect));
- else
- updateAll();
- }
+ // Update old rubberband
+ if (viewportUpdateMode != QGraphicsView::NoViewportUpdate && !rubberBandRect.isEmpty()) {
+ if (viewportUpdateMode != QGraphicsView::FullViewportUpdate)
+ q->viewport()->update(rubberBandRegion(q->viewport(), rubberBandRect));
+ else
+ updateAll();
+ }
- // Stop rubber banding if the user has let go of all buttons (even
- // if we didn't get the release events).
- if (!event->buttons()) {
- rubberBanding = false;
- rubberBandRect = QRect();
- return;
- }
+ // Stop rubber banding if the user has let go of all buttons (even
+ // if we didn't get the release events).
+ if (!event->buttons()) {
+ rubberBanding = false;
+ rubberBandRect = QRect();
+ return;
+ }
- // Update rubberband position
- const QPoint mp = q->mapFromScene(mousePressScenePoint);
- const QPoint ep = event->pos();
- rubberBandRect = QRect(qMin(mp.x(), ep.x()), qMin(mp.y(), ep.y()),
- qAbs(mp.x() - ep.x()) + 1, qAbs(mp.y() - ep.y()) + 1);
+ // Update rubberband position
+ const QPoint mp = q->mapFromScene(mousePressScenePoint);
+ const QPoint ep = event->pos();
+ rubberBandRect = QRect(qMin(mp.x(), ep.x()), qMin(mp.y(), ep.y()),
+ qAbs(mp.x() - ep.x()) + 1, qAbs(mp.y() - ep.y()) + 1);
- // Update new rubberband
- if (viewportUpdateMode != QGraphicsView::NoViewportUpdate){
- if (viewportUpdateMode != QGraphicsView::FullViewportUpdate)
- q->viewport()->update(rubberBandRegion(q->viewport(), rubberBandRect));
- else
- updateAll();
- }
- // Set the new selection area
- QPainterPath selectionArea;
- selectionArea.addPolygon(mapToScene(rubberBandRect));
- selectionArea.closeSubpath();
- if (scene)
- scene->setSelectionArea(selectionArea, rubberBandSelectionMode,
- q->viewportTransform());
- }
+ // Update new rubberband
+ if (viewportUpdateMode != QGraphicsView::NoViewportUpdate) {
+ if (viewportUpdateMode != QGraphicsView::FullViewportUpdate)
+ q->viewport()->update(rubberBandRegion(q->viewport(), rubberBandRect));
+ else
+ updateAll();
}
+ // Set the new selection area
+ QPainterPath selectionArea;
+ selectionArea.addPolygon(mapToScene(rubberBandRect));
+ selectionArea.closeSubpath();
+ if (scene)
+ scene->setSelectionArea(selectionArea, rubberBandSelectionMode, q->viewportTransform());
}
#endif