Fix recalculation the scene when move detail.
--HG-- branch : release
This commit is contained in:
parent
7695361b0f
commit
68b723148c
|
@ -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.
|
||||||
|
const QPointF newPos = value.toPointF();
|
||||||
|
|
||||||
|
MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id, scene());
|
||||||
connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||||
qApp->getUndoStack()->push(moveDet);
|
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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user