From 2747f200ce27599af74f01cb629ec8930bae7b44 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 4 Nov 2009 11:18:40 +0100 Subject: Provide hook that's called when items' stacking order is changed. This is required by the QtDeclarative module. As an isolated change, this is just a noop. It takes effect when somebody reimpements the private virtual function. Reviewed-by: Alan Alpert --- src/gui/graphicsview/qgraphicsitem.cpp | 16 ++++++++++++++++ src/gui/graphicsview/qgraphicsitem_p.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index e69a295..e014763 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4345,6 +4345,12 @@ void QGraphicsItem::stackBefore(const QGraphicsItem *sibling) ++index; } d_ptr->siblingIndex = siblingIndex; + for (int i = 0; i < siblings->size(); ++i) { + int &index = siblings->at(i)->d_ptr->siblingIndex; + if (i != siblingIndex && index >= siblingIndex && index <= myIndex) + siblings->at(i)->d_ptr->siblingOrderChange(); + } + d_ptr->siblingOrderChange(); } } @@ -5342,6 +5348,16 @@ void QGraphicsItemPrivate::subFocusItemChange() /*! \internal + Subclasses can reimplement this function to be notified when its + siblingIndex order is changed. +*/ +void QGraphicsItemPrivate::siblingOrderChange() +{ +} + +/*! + \internal + Tells us if it is a proxy widget */ bool QGraphicsItemPrivate::isProxyWidget() const diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 92d45f6..977fa96 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -431,6 +431,7 @@ public: static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); void ensureSequentialSiblingIndex(); inline void sendScenePosChange(); + virtual void siblingOrderChange(); QPainterPath cachedClipPath; QRectF childrenBoundingRect; -- cgit v0.12