From 93c883b5388a5ed6e9dbd01ca6b314163576ede5 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Wed, 5 Aug 2009 17:49:23 +0200 Subject: Refactors QGraphicsItemGroup::addToGroup to use QGraphicsItem::itemTransform This does not change the behavior of the method. Reviewed-by: andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 19 ++++++++++++------- 1 file 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(); } -- cgit v0.12