1067 } |
1072 } |
1068 |
1073 |
1069 /*! |
1074 /*! |
1070 Returns all items for the screen position in \a event. |
1075 Returns all items for the screen position in \a event. |
1071 */ |
1076 */ |
1072 QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &screenPos, |
1077 QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &/*screenPos*/, |
1073 const QPointF &scenePos, |
1078 const QPointF &scenePos, |
1074 QWidget *widget) const |
1079 QWidget *widget) const |
1075 { |
1080 { |
1076 Q_Q(const QGraphicsScene); |
1081 Q_Q(const QGraphicsScene); |
1077 QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0; |
1082 QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0; |
1078 if (!view) |
1083 if (!view) |
1079 return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform()); |
1084 return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform()); |
1080 |
1085 |
1081 const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)), QSizeF(1, 1)); |
1086 const QRectF pointRect(scenePos, QSizeF(1, 1)); |
1082 if (!view->isTransformed()) |
1087 if (!view->isTransformed()) |
1083 return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder); |
1088 return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder); |
1084 |
1089 |
1085 const QTransform viewTransform = view->viewportTransform(); |
1090 const QTransform viewTransform = view->viewportTransform(); |
1086 if (viewTransform.type() <= QTransform::TxScale) { |
1091 return q->items(pointRect, Qt::IntersectsItemShape, |
1087 return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, |
|
1088 Qt::DescendingOrder, viewTransform); |
|
1089 } |
|
1090 return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, |
|
1091 Qt::DescendingOrder, viewTransform); |
1092 Qt::DescendingOrder, viewTransform); |
1092 } |
1093 } |
1093 |
1094 |
1094 /*! |
1095 /*! |
1095 \internal |
1096 \internal |
5119 // method of delivering updates. |
5120 // method of delivering updates. |
5120 if (item->d_ptr->sceneTransformTranslateOnly) { |
5121 if (item->d_ptr->sceneTransformTranslateOnly) { |
5121 q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(), |
5122 q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(), |
5122 item->d_ptr->sceneTransform.dy())); |
5123 item->d_ptr->sceneTransform.dy())); |
5123 } else { |
5124 } else { |
5124 q->update(item->d_ptr->sceneTransform.mapRect(itemBoundingRect)); |
5125 QRectF rect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect); |
|
5126 if (!rect.isEmpty()) |
|
5127 q->update(rect); |
5125 } |
5128 } |
5126 } else { |
5129 } else { |
5127 QRectF dirtyRect; |
5130 QRectF dirtyRect; |
5128 bool uninitializedDirtyRect = true; |
5131 bool uninitializedDirtyRect = true; |
5129 |
5132 |
5733 sceneTouchEvent->widget()); |
5736 sceneTouchEvent->widget()); |
5734 item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first(); |
5737 item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first(); |
5735 } |
5738 } |
5736 |
5739 |
5737 if (sceneTouchEvent->deviceType() == QTouchEvent::TouchScreen) { |
5740 if (sceneTouchEvent->deviceType() == QTouchEvent::TouchScreen) { |
5738 // on touch-screens, combine this touch point with the closest one we find if it |
5741 // on touch-screens, combine this touch point with the closest one we find |
5739 // is a a direct descendent or ancestor ( |
|
5740 int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos()); |
5742 int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos()); |
5741 QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId); |
5743 QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId); |
5742 if (!item |
5744 if (!item || (closestItem && cachedItemsUnderMouse.contains(closestItem))) |
5743 || (closestItem |
|
5744 && (item->isAncestorOf(closestItem) |
|
5745 || closestItem->isAncestorOf(item)))) { |
|
5746 item = closestItem; |
5745 item = closestItem; |
5747 } |
|
5748 } |
5746 } |
5749 if (!item) |
5747 if (!item) |
5750 continue; |
5748 continue; |
5751 |
5749 |
5752 itemForTouchPointId.insert(touchPoint.id(), item); |
5750 itemForTouchPointId.insert(touchPoint.id(), item); |