- r = m_selectedItem->boundingRect();
- /*
- * The vertices of the rectangle (check for matrix
- * transformation); to be replaced by QTransform::map()?
- */
- QPointF itemOrigin = item->scenePos();
- QTransform transform = item->transform();
- QPointF topLeft(transform.m11() * r.toRect().left() + transform.m21() * r.toRect().top() + transform.m31() + itemOrigin.x(), transform.m22() * r.toRect().top() + transform.m12() * r.toRect().left() + transform.m32() + itemOrigin.y());
- QPointF bottomLeft(transform.m11() * r.toRect().left() + transform.m21() * r.toRect().bottom() + transform.m31() + itemOrigin.x(), transform.m22() * r.toRect().bottom() + transform.m12() * r.toRect().left() + transform.m32() + itemOrigin.y());
- QPointF topRight(transform.m11() * r.toRect().right() + transform.m21() * r.toRect().top() + transform.m31() + itemOrigin.x(), transform.m22() * r.toRect().top() + transform.m12() * r.toRect().right() + transform.m32() + itemOrigin.y());
- QPointF bottomRight(transform.m11() * r.toRect().right() + transform.m21() * r.toRect().bottom() + transform.m31() + itemOrigin.x(), transform.m22() * r.toRect().bottom() + transform.m12() * r.toRect().right() + transform.m32() + itemOrigin.y());
- // The borders (using the transformed coordinates)
- QGraphicsLineItem borderTop(topLeft.x(), topLeft.y(), topRight.x(), topRight.y());
- QGraphicsLineItem borderRight(topRight.x(), topRight.y(), bottomRight.x(), bottomRight.y());
- QGraphicsLineItem borderBottom(bottomRight.x(), bottomRight.y(), bottomLeft.x(), bottomLeft.y());
- QGraphicsLineItem borderLeft(bottomLeft.x(), bottomLeft.y(), topLeft.x(), topLeft.y());
+ r1 = m_selectedItem->boundingRect().normalized();
+
+ QList<QGraphicsView*> viewlist = views();
+ QGraphicsView *view = NULL;
+ if (viewlist.size() > 0) view = viewlist[0];
+ if (view == NULL) return;
+ // Item mapped coordinates
+ QPolygon r = m_selectedItem->deviceTransform(view->viewportTransform()).map(r1).toPolygon();
+ QPainterPath top(r.point(0));
+ top.lineTo(r.point(1));
+ QPainterPath bottom(r.point(2));
+ bottom.lineTo(r.point(3));
+ QPainterPath left(r.point(0));
+ left.lineTo(r.point(3));
+ QPainterPath right(r.point(1));
+ right.lineTo(r.point(2));
+
+