Fix recalculation the scene when move detail.

(grafted from 2a58800bc48bc82057c7bec08d007eb133849b5b)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-01-15 14:56:33 +02:00
parent 73f0f4ca58
commit 6a28f464b9
2 changed files with 30 additions and 6 deletions

View File

@ -346,14 +346,34 @@ void VToolDetail::RefreshDataInFile()
*/ */
QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if (change == ItemPositionHasChanged && scene()) if (change == ItemPositionChange && scene())
{ {
// value - this is new position. // Each time we move something we call recalculation scene rect. In some cases this can cause moving
QPointF newPos = value.toPointF(); // objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move.
static bool changeFinished = true;
if (changeFinished)
{
changeFinished = false;
MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id, this->scene()); // value - this is new position.
connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); const QPointF newPos = value.toPointF();
qApp->getUndoStack()->push(moveDet);
MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id, scene());
connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveDet);
const QList<QGraphicsView *> viewList = scene()->views();
if (not viewList.isEmpty())
{
if (QGraphicsView *view = viewList.at(0))
{
view->ensureVisible(mapToScene(boundingRect()|childrenBoundingRect()).boundingRect());
}
}
// Don't forget to update geometry, because first change never call full parse
RefreshGeometry();
changeFinished = true;
}
} }
if (change == QGraphicsItem::ItemSelectedChange) if (change == QGraphicsItem::ItemSelectedChange)

View File

@ -92,6 +92,10 @@ void MoveDetail::redo()
{ {
emit NeedLiteParsing(Document::LiteParse); emit NeedLiteParsing(Document::LiteParse);
} }
else
{
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
}
redoFlag = true; redoFlag = true;
} }
else else