diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-04-07 19:45:41 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-04-08 21:58:41 +0200 |
commit | c8dea4a83337835323111b3372cf645b51d48edd (patch) | |
tree | 354528f43f58c256e497bd8a2d7c6225c5e83468 /src/widgets/graphicsview | |
parent | e349f787d595aa343ca86af94159b6730d55b8d5 (diff) |
Override virtual method in private class instead of downcasting
Move QGraphicsView specific code into reimplementation of now virtual
(and const) canStartScrollingAt.
Remove unhelpful comment.
Change-Id: Ib4799e48ac4f85748c77c52d29511a0490303676
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsview.cpp | 20 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsview_p.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 338d553108..37141c4166 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -615,6 +615,26 @@ void QGraphicsViewPrivate::updateScroll() /*! \internal + + * don't start scrolling when a drag mode has been set + * don't start scrolling on a movable item +*/ +bool QGraphicsViewPrivate::canStartScrollingAt(const QPoint &startPos) const +{ + Q_Q(const QGraphicsView); + if (q->dragMode() != QGraphicsView::NoDrag) + return false; + + const QGraphicsItem *childItem = q->itemAt(startPos); + + if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable)) + return false; + + return QAbstractScrollAreaPrivate::canStartScrollingAt(startPos); +} + +/*! + \internal */ void QGraphicsViewPrivate::replayLastMouseEvent() { diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h index e877e6e887..b58505b057 100644 --- a/src/widgets/graphicsview/qgraphicsview_p.h +++ b/src/widgets/graphicsview/qgraphicsview_p.h @@ -117,6 +117,7 @@ public: QTransform matrix; qint64 scrollX, scrollY; void updateScroll(); + bool canStartScrollingAt(const QPoint &startPos) const override; qreal leftIndent; qreal topIndent; |