make moving between items with different parents work a bit better ;)

svn path=/trunk/KDE/kdelibs/; revision=1031762
This commit is contained in:
Aaron J. Seigo 2009-10-05 22:44:08 +00:00
parent cfd8409432
commit 70b3847210

View File

@ -166,7 +166,15 @@ void ItemBackground::setTargetItem(QGraphicsItem *target)
d->target = target;
if (target) {
setZValue(target->zValue() - 1);
setParentItem(target->parentItem());
if (parentItem() != target->parentItem()) {
QTransform t = transform();
setTransform(QTransform());
QRectF geom = mapToScene(geometry()).boundingRect();
setParentItem(target->parentItem());
setGeometry(mapFromScene(geom).boundingRect());
setTransform(t);
}
QRectF rect = target->boundingRect();
rect.moveTopLeft(target->pos());
setTarget(rect);