Saving position of the base point should be handled in ItemPositionChange

section.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-04 21:46:52 +02:00
parent 6d566c2715
commit 2b0e358cdd

View File

@ -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);
}
//---------------------------------------------------------------------------------------------------------------------