From 2b0e358cdd722260c397fb4a192a4e845fe4e5ed Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 4 Dec 2015 21:46:52 +0200 Subject: [PATCH] Saving position of the base point should be handled in ItemPositionChange section. --HG-- branch : develop --- .../toolsinglepoint/vtoolbasepoint.cpp | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index 8900e3b83..42a257796 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -127,19 +127,6 @@ void VToolBasePoint::AddToFile() QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionChange && scene()) - { - // value - this is new position. - QPointF newPos = value.toPointF(); - QRectF rect = scene()->sceneRect(); - if (rect.contains(newPos) == false) - { - // Save element into rect of scene. - newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left()))); - newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top()))); - return newPos; - } - } - if (change == ItemPositionHasChanged && scene()) { // Each time we move something we call recalculation scene rect. In some cases this can cause moving // objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move. @@ -153,17 +140,14 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene()); connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveSP); - if (scene()) + if (QGraphicsView *view = scene()->views().at(0)) { - if (QGraphicsView *view = scene()->views().at(0)) - { - view->ensureVisible(this); - } + view->ensureVisible(this); } changeFinished = true; } } - return QGraphicsItem::itemChange(change, value); + return VToolSinglePoint::itemChange(change, value); } //---------------------------------------------------------------------------------------------------------------------