Fix recalculation the scene when move detail.
(grafted from 2a58800bc48bc82057c7bec08d007eb133849b5b) --HG-- branch : develop
This commit is contained in:
parent
73f0f4ca58
commit
6a28f464b9
|
@ -346,14 +346,34 @@ void VToolDetail::RefreshDataInFile()
|
|||
*/
|
||||
QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == ItemPositionHasChanged && scene())
|
||||
if (change == ItemPositionChange && scene())
|
||||
{
|
||||
// value - this is new position.
|
||||
QPointF newPos = value.toPointF();
|
||||
// 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.
|
||||
static bool changeFinished = true;
|
||||
if (changeFinished)
|
||||
{
|
||||
changeFinished = false;
|
||||
|
||||
MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id, this->scene());
|
||||
connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveDet);
|
||||
// value - this is new position.
|
||||
const QPointF newPos = value.toPointF();
|
||||
|
||||
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)
|
||||
|
|
|
@ -92,6 +92,10 @@ void MoveDetail::redo()
|
|||
{
|
||||
emit NeedLiteParsing(Document::LiteParse);
|
||||
}
|
||||
else
|
||||
{
|
||||
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
|
||||
}
|
||||
redoFlag = true;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user