diff options
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 117 |
1 files changed, 113 insertions, 4 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 948ff28..c0fb1bb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1131,6 +1131,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q } } + // Resolve depth. + invalidateDepthRecursively(); + if ((parent = newParent)) { if (parent->d_func()->scene && parent->d_func()->scene != scene) { // Move this item to its new parent's scene @@ -1181,8 +1184,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q } } - // Resolve depth. - invalidateDepthRecursively(); dirtySceneTransform = 1; // Restore the sub focus chain. @@ -1883,7 +1884,8 @@ void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize) d_ptr->cacheMode = mode; bool noVisualChange = (mode == NoCache && lastMode == NoCache) || (mode == NoCache && lastMode == DeviceCoordinateCache) - || (mode == DeviceCoordinateCache && lastMode == NoCache); + || (mode == DeviceCoordinateCache && lastMode == NoCache) + || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache); if (mode == NoCache) { d_ptr->removeExtraItemCache(); } else { @@ -2177,8 +2179,12 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData)); if (c) c->purge(); - if (scene) + if (scene) { +#ifndef QT_NO_GRAPHICSEFFECT + invalidateParentGraphicsEffectsRecursively(); +#endif //QT_NO_GRAPHICSEFFECT scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); + } } // Certain properties are dropped as an item becomes invisible. @@ -5226,6 +5232,8 @@ void QGraphicsItemPrivate::addChild(QGraphicsItem *child) needSortChildren = 1; // ### maybe 0 child->d_ptr->siblingIndex = children.size(); children.append(child); + if (isObject) + emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); } /*! @@ -5248,6 +5256,8 @@ void QGraphicsItemPrivate::removeChild(QGraphicsItem *child) // the child is not guaranteed to be at the index after the list is sorted. // (see ensureSortedChildren()). child->d_ptr->siblingIndex = -1; + if (isObject) + emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); } /*! @@ -7455,6 +7465,88 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) } } +void QGraphicsItemPrivate::append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item) +{ + QGraphicsItemPrivate::get(item)->setParentItemHelper(static_cast<QGraphicsObject *>(list->object), /*newParentVariant=*/0, /*thisPointerVariant=*/0); +} + +/*! + Returns a list of this item's children. + + The items are sorted by stacking order. This takes into account both the + items' insertion order and their Z-values. + +*/ +QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList() +{ + Q_Q(QGraphicsItem); + if (isObject) { + QGraphicsObject *that = static_cast<QGraphicsObject *>(q); + return QDeclarativeListProperty<QGraphicsObject>(that, &children, QGraphicsItemPrivate::append); + } else { + //QGraphicsItem is not supported for this property + return QDeclarativeListProperty<QGraphicsObject>(); + } +} + +/*! + \internal + Returns the width of the item + Reimplemented by QGraphicsWidget +*/ +qreal QGraphicsItemPrivate::width() const +{ + return 0; +} + +/*! + \internal + Set the width of the item + Reimplemented by QGraphicsWidget +*/ +void QGraphicsItemPrivate::setWidth(qreal w) +{ + Q_UNUSED(w); +} + +/*! + \internal + Reset the width of the item + Reimplemented by QGraphicsWidget +*/ +void QGraphicsItemPrivate::resetWidth() +{ +} + +/*! + \internal + Returns the height of the item + Reimplemented by QGraphicsWidget +*/ +qreal QGraphicsItemPrivate::height() const +{ + return 0; +} + +/*! + \internal + Set the height of the item + Reimplemented by QGraphicsWidget +*/ +void QGraphicsItemPrivate::setHeight(qreal h) +{ + Q_UNUSED(h); +} + +/*! + \internal + Reset the height of the item + Reimplemented by QGraphicsWidget +*/ +void QGraphicsItemPrivate::resetHeight() +{ +} + /*! \property QGraphicsObject::parent \brief the parent of the item @@ -7641,6 +7733,23 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) \sa scale, rotation, QGraphicsItem::transformOriginPoint() */ +/*! + \fn void QGraphicsObject::widthChanged() + \internal +*/ + +/*! + \fn void QGraphicsObject::heightChanged() + \internal +*/ + +/*! + + \fn QGraphicsObject::childrenChanged() + + This signal gets emitted whenever the children list changes + \internal +*/ /*! \class QAbstractGraphicsShapeItem |