summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-12-05 19:55:27 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-12 12:01:16 +0100
commit686dcce5fb2eef4adebfc2a247e96574ec062473 (patch)
tree13f5b2518d09945ecb0ffd6b2667d67591f2b823 /src
parent8d2679673e6268f826abe6d4ef1734e9d69edab5 (diff)
Make QGraphicsViewPrivate::updateRubberBand more readable
This patch changes QGraphicsViewPrivate::updateRubberBand to return at once in case some of the first conditions (which were needed to do something with the rubberband) are not true. The indentation after these ifs is fixed, and there are a few style fixes, but beside the first 2 ifs, there are only white-space and new-line changes. Change-Id: I7e2edb7bfd334b35ee8ab246f733d854bff7e0f7 Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name> Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp77
1 files changed, 36 insertions, 41 deletions
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index dca84f3f1b..9c04a3c193 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -709,52 +709,47 @@ QRegion QGraphicsViewPrivate::rubberBandRegion(const QWidget *widget, const QRec
void QGraphicsViewPrivate::updateRubberBand(const QMouseEvent *event)
{
Q_Q(QGraphicsView);
- if (dragMode == QGraphicsView::RubberBandDrag && sceneInteractionAllowed) {
- 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