+ if (item != NULL && item->flags() & QGraphicsItem::ItemIsMovable) {
+ m_sceneClickPoint = e->scenePos();
+ m_selectedItem = item;
+ kDebug() << "///////// ITEM TYPE: " << item->type();
+ if (item->type() == 8) {
+ QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(item);
+ if (t->textInteractionFlags() == Qt::TextEditorInteraction) {
+ QGraphicsScene::mousePressEvent(e);
+ return;
+ }
+ t->setTextInteractionFlags(Qt::NoTextInteraction);
+ setCursor(Qt::ClosedHandCursor);
+ } else if (item->type() == 3 || item->type() == 13 || item->type() == 7) {
+ QRectF r;
+ if (m_selectedItem->type() == 3)
+ r = ((QGraphicsRectItem*)m_selectedItem)->rect();
+ else
+ 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());
+ // The area interested by the mouse pointer
+ QPainterPath mouseArea;
+ mouseArea.addRect(e->scenePos().toPoint().x() - 4 / m_zoom, e->scenePos().toPoint().y() - 4 / m_zoom, 8 / m_zoom, 8 / m_zoom);
+ // Check for collisions between the mouse and the borders
+ if (borderLeft.collidesWithPath(mouseArea) && borderTop.collidesWithPath(mouseArea))
+ m_resizeMode = TopLeft;
+ else if (borderLeft.collidesWithPath(mouseArea) && borderBottom.collidesWithPath(mouseArea))
+ m_resizeMode = BottomLeft;
+ else if (borderRight.collidesWithPath(mouseArea) && borderTop.collidesWithPath(mouseArea))
+ m_resizeMode = TopRight;
+ else if (borderRight.collidesWithPath(mouseArea) && borderBottom.collidesWithPath(mouseArea))
+ m_resizeMode = BottomRight;
+ else if (borderLeft.collidesWithPath(mouseArea))
+ m_resizeMode = Left;
+ else if (borderRight.collidesWithPath(mouseArea))
+ m_resizeMode = Right;
+ else if (borderTop.collidesWithPath(mouseArea))
+ m_resizeMode = Up;
+ else if (borderBottom.collidesWithPath(mouseArea))
+ m_resizeMode = Down;
+ else
+ setCursor(Qt::ClosedHandCursor);
+ }
+ }
+ QGraphicsScene::mousePressEvent(e);
+ } else if (m_tool == TITLE_RECTANGLE) {
+ m_sceneClickPoint = e->scenePos();
+ m_selectedItem = NULL;
+ } else if (m_tool == TITLE_TEXT) {
+ m_selectedItem = addText(QString());
+ emit newText((QGraphicsTextItem *) m_selectedItem);
+ m_selectedItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
+ ((QGraphicsTextItem *)m_selectedItem)->setTextInteractionFlags(Qt::TextEditorInteraction);
+ m_selectedItem->setPos(e->scenePos());
+ QGraphicsScene::mousePressEvent(e);