diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-08-25 12:27:27 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-08-25 12:59:20 (GMT) |
commit | 7c0d15a22266a425c9e9ac0120d6774e120fe01e (patch) | |
tree | c5838834f1f6e5e7615e2af1c157365733b2c6c7 /src/gui/graphicsview | |
parent | d2089600ea247b5d6354e8eee4becf40802c4693 (diff) | |
download | Qt-7c0d15a22266a425c9e9ac0120d6774e120fe01e.zip Qt-7c0d15a22266a425c9e9ac0120d6774e120fe01e.tar.gz Qt-7c0d15a22266a425c9e9ac0120d6774e120fe01e.tar.bz2 |
Don't rely on mapFromGlobal in QGraphicsScenePrivate::itemsAtPosition.
The old approach discovered a bug in QWidget::mapToGlobal in the context of
lighthouse, which in turn brought our eyes to
QGraphicsScenePrivate::itemsAtPosition. The implementation itself was
correct, but we can easily remove the-not-so-cheap mapToGlobal call
since we already have the scene position, which is all we need.
This functionality is heavily tested by existing auto tests, and all of
them pass.
Reviewed-by: mae
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 3c23884..4fb754c 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1074,7 +1074,7 @@ void QGraphicsScenePrivate::enableMouseTrackingOnViews() /*! Returns all items for the screen position in \a event. */ -QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &screenPos, +QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &/*screenPos*/, const QPointF &scenePos, QWidget *widget) const { @@ -1083,16 +1083,12 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &scre if (!view) return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform()); - const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)), QSizeF(1, 1)); + const QRectF pointRect(scenePos, QSizeF(1, 1)); if (!view->isTransformed()) return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder); const QTransform viewTransform = view->viewportTransform(); - if (viewTransform.type() <= QTransform::TxScale) { - return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, - Qt::DescendingOrder, viewTransform); - } - return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, + return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform); } |