summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsitem.cpp
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-21 12:00:07 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-21 12:00:07 (GMT)
commit8d00a0a21f245d15962191e0690d3619735d118b (patch)
tree7aaa66528f0ee40d0d2d885f94835d0f09ea4a68 /src/gui/graphicsview/qgraphicsitem.cpp
parent97cec103793a4b9aae8337ffc2ce9a2bd98fb5fc (diff)
parent508b447075fb852e61ddf88c92c9099dad292747 (diff)
downloadQt-8d00a0a21f245d15962191e0690d3619735d118b.zip
Qt-8d00a0a21f245d15962191e0690d3619735d118b.tar.gz
Qt-8d00a0a21f245d15962191e0690d3619735d118b.tar.bz2
Merge commit 'qt/master' into kinetic-graphicseffect
Conflicts: src/gui/graphicsview/graphicsview.pri
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 2b3d453..db24c77 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1011,7 +1011,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent)
}
// Resolve depth.
- resolveDepth(parent ? parent->d_ptr->depth : -1);
+ invalidateDepthRecursively();
dirtySceneTransform = 1;
// Restore the sub focus chain.
@@ -4511,14 +4511,42 @@ bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping, bool ignore
/*!
\internal
+*/
+int QGraphicsItemPrivate::depth() const
+{
+ if (itemDepth == -1)
+ const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
+
+ return itemDepth;
+}
- Resolves the stacking depth of this object and all its children.
+/*!
+ \internal
*/
-void QGraphicsItemPrivate::resolveDepth(int parentDepth)
+void QGraphicsItemPrivate::invalidateDepthRecursively()
{
- depth = parentDepth + 1;
+ if (itemDepth == -1)
+ return;
+
+ itemDepth = -1;
for (int i = 0; i < children.size(); ++i)
- children.at(i)->d_ptr->resolveDepth(depth);
+ children.at(i)->d_ptr->invalidateDepthRecursively();
+}
+
+/*!
+ \internal
+
+ Resolves the stacking depth of this object and all its ancestors.
+*/
+void QGraphicsItemPrivate::resolveDepth()
+{
+ if (!parent)
+ itemDepth = 0;
+ else {
+ if (parent->d_ptr->itemDepth == -1)
+ parent->d_ptr->resolveDepth();
+ itemDepth = parent->d_ptr->itemDepth + 1;
+ }
}
/*!
@@ -5695,8 +5723,8 @@ QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) con
return const_cast<QGraphicsItem *>(this);
const QGraphicsItem *thisw = this;
const QGraphicsItem *otherw = other;
- int thisDepth = d_ptr->depth;
- int otherDepth = other->d_ptr->depth;
+ int thisDepth = d_ptr->depth();
+ int otherDepth = other->d_ptr->depth();
while (thisDepth > otherDepth) {
thisw = thisw->d_ptr->parent;
--thisDepth;