summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorChristophe Oosterlynck <christophe.oosterlynck@dzine.be>2011-11-02 09:00:12 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2011-11-02 09:01:05 (GMT)
commit7925f107814e46deb0848d9e6016721ceebfb521 (patch)
treecc3dbee045b4cca33eecf7b531f4766ecc2bdfa3 /src/gui
parent582dec4b753b84cc69eb140290ceff346bce76b9 (diff)
downloadQt-7925f107814e46deb0848d9e6016721ceebfb521.zip
Qt-7925f107814e46deb0848d9e6016721ceebfb521.tar.gz
Qt-7925f107814e46deb0848d9e6016721ceebfb521.tar.bz2
Correction for effectiveBoundingRect() calculation for QGraphicsItem
QGraphicsItemPrivate::effectiveBoundingRect() should use ItemClipsChildrenToShape flag from the parent while looping to check for clipping and not use its own AncestorClipsChildren flag. By using AncestorClipsChildren, you're checking if one of your ancestors clips you, but you really want to know if your direct parent clips you. Merge-request: 1419 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 73e8eed..ff21296 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2845,16 +2845,23 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const
If the item has an effect, the effective rect can be larger than the item's
bouding rect, depending on the effect.
+ \a topMostEffectItem is the top most parent of which a possible QGraphicsEffect
+ should be taken into account (\a topMostEffectItem is inclusive). Any effects
+ of any ancestors of \a topMostEffectItem are not taken into consideration.
+
\sa boundingRect()
*/
QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const
{
#ifndef QT_NO_GRAPHICSEFFECT
Q_Q(const QGraphicsItem);
+ // Take into account the items own effect
QRectF brect = effectiveBoundingRect(q_ptr->boundingRect());
- if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren || topMostEffectItem == q)
+
+ if (topMostEffectItem == q)
return brect;
+ // Take into account any effects applied to the parents
const QGraphicsItem *effectParent = parent;
while (effectParent) {
QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect;
@@ -2863,10 +2870,10 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectI
const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace);
brect = effectParent->mapRectToItem(q, effectRectInParentSpace);
}
- if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
- || topMostEffectItem == effectParent) {
+ if (effectParent && (effectParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape))
+ return brect.intersected(q->mapRectFromItem(effectParent, effectParent->boundingRect()));
+ else if (topMostEffectItem == effectParent)
return brect;
- }
effectParent = effectParent->d_ptr->parent;
}