summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-08-05 15:49:23 (GMT)
committerLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-08-07 09:20:35 (GMT)
commit93c883b5388a5ed6e9dbd01ca6b314163576ede5 (patch)
tree250e2fdf61ba0ae7ebaaf8414834a7f9a3f4ffc6 /src/gui/graphicsview
parent43a98b3ddd8d01b8e6453efd49bb6a9064e1ba08 (diff)
downloadQt-93c883b5388a5ed6e9dbd01ca6b314163576ede5.zip
Qt-93c883b5388a5ed6e9dbd01ca6b314163576ede5.tar.gz
Qt-93c883b5388a5ed6e9dbd01ca6b314163576ede5.tar.bz2
Refactors QGraphicsItemGroup::addToGroup to use QGraphicsItem::itemTransform
This does not change the behavior of the method. Reviewed-by: andreas
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index beaf42b..8d9a1f8 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -9837,20 +9837,25 @@ void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)
}
// COMBINE
- // ### Use itemTransform() instead.
- QTransform oldSceneMatrix = item->sceneTransform();
+ bool ok;
+ QTransform itemTransform = item->itemTransform(this, &ok);
+
+ if (!ok) {
+ qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");
+ return;
+ }
+
+ QTransform newItemTransform(itemTransform);
item->setPos(mapFromItem(item, 0, 0));
item->setParentItem(this);
- QTransform newItemTransform(oldSceneMatrix);
- newItemTransform *= sceneTransform().inverted();
+
+ // removing position from translation component of the new transform
if (!item->pos().isNull())
newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
+
item->setTransform(newItemTransform);
item->d_func()->setIsMemberOfGroup(true);
prepareGeometryChange();
- QTransform itemTransform(item->transform());
- if (!item->pos().isNull())
- itemTransform *= QTransform::fromTranslate(item->x(), item->y());
d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
update();
}