1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
633 \internal |
633 \internal |
634 |
634 |
635 This method react to the \a change of the \a item and use the \a value to |
635 This method react to the \a change of the \a item and use the \a value to |
636 update the BSP tree if necessary. |
636 update the BSP tree if necessary. |
637 */ |
637 */ |
638 void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) |
638 void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) |
639 { |
639 { |
640 Q_D(QGraphicsSceneBspTreeIndex); |
640 Q_D(QGraphicsSceneBspTreeIndex); |
641 switch (change) { |
641 switch (change) { |
642 case QGraphicsItem::ItemFlagsChange: { |
642 case QGraphicsItem::ItemFlagsChange: { |
643 // Handle ItemIgnoresTransformations |
643 // Handle ItemIgnoresTransformations |
|
644 QGraphicsItem::GraphicsItemFlags newFlags = *static_cast<const QGraphicsItem::GraphicsItemFlags *>(value); |
644 bool ignoredTransform = item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations; |
645 bool ignoredTransform = item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations; |
645 bool willIgnoreTransform = value.toUInt() & QGraphicsItem::ItemIgnoresTransformations; |
646 bool willIgnoreTransform = newFlags & QGraphicsItem::ItemIgnoresTransformations; |
646 bool clipsChildren = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape; |
647 bool clipsChildren = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape; |
647 bool willClipChildren = value.toUInt() & QGraphicsItem::ItemClipsChildrenToShape; |
648 bool willClipChildren = newFlags & QGraphicsItem::ItemClipsChildrenToShape; |
648 if ((ignoredTransform != willIgnoreTransform) || (clipsChildren != willClipChildren)) { |
649 if ((ignoredTransform != willIgnoreTransform) || (clipsChildren != willClipChildren)) { |
649 QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item); |
650 QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item); |
650 // Remove item and its descendants from the index and append |
651 // Remove item and its descendants from the index and append |
651 // them to the list of unindexed items. Then, when the index |
652 // them to the list of unindexed items. Then, when the index |
652 // is updated, they will be put into the bsp-tree or the list |
653 // is updated, they will be put into the bsp-tree or the list |
659 d->invalidateSortCache(); |
660 d->invalidateSortCache(); |
660 break; |
661 break; |
661 case QGraphicsItem::ItemParentChange: { |
662 case QGraphicsItem::ItemParentChange: { |
662 d->invalidateSortCache(); |
663 d->invalidateSortCache(); |
663 // Handle ItemIgnoresTransformations |
664 // Handle ItemIgnoresTransformations |
664 QGraphicsItem *newParent = qVariantValue<QGraphicsItem *>(value); |
665 const QGraphicsItem *newParent = static_cast<const QGraphicsItem *>(value); |
665 bool ignoredTransform = item->d_ptr->itemIsUntransformable(); |
666 bool ignoredTransform = item->d_ptr->itemIsUntransformable(); |
666 bool willIgnoreTransform = (item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations) |
667 bool willIgnoreTransform = (item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations) |
667 || (newParent && newParent->d_ptr->itemIsUntransformable()); |
668 || (newParent && newParent->d_ptr->itemIsUntransformable()); |
668 bool ancestorClippedChildren = item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren; |
669 bool ancestorClippedChildren = item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren; |
669 bool ancestorWillClipChildren = newParent |
670 bool ancestorWillClipChildren = newParent |