@@ -577,7 +577,7 @@ void QgsLayoutMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
577
577
if ( mCurrentMouseMoveAction == QgsLayoutMouseHandles::MoveItem )
578
578
{
579
579
// move selected items
580
- QUndoCommand *parentCommand = new QUndoCommand ( tr ( " Change item position" ) );
580
+ mLayout -> undoStack ()-> beginMacro ( tr ( " Change item position" ) );
581
581
582
582
QPointF mEndHandleMovePos = scenePos ();
583
583
@@ -593,30 +593,24 @@ void QgsLayoutMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
593
593
// don't move locked items
594
594
continue ;
595
595
}
596
- #if 0 //TODO
597
- QgsComposerItemCommand *subcommand = new QgsComposerItemCommand( item, QLatin1String( "" ), parentCommand );
598
- subcommand->savePreviousState();
599
- #endif
596
+
597
+ mLayout ->undoStack ()->beginCommand ( item, QString () );
600
598
601
599
// need to convert delta from layout units -> item units
602
600
QgsLayoutPoint itemPos = item->positionWithUnits ();
603
601
QgsLayoutPoint deltaPos = mLayout ->convertFromLayoutUnits ( QPointF ( deltaX, deltaY ), itemPos.units () );
604
602
itemPos.setX ( itemPos.x () + deltaPos.x () );
605
603
itemPos.setY ( itemPos.y () + deltaPos.y () );
606
604
item->attemptMove ( itemPos );
607
- #if 0
608
- subcommand->saveAfterState();
609
- #endif
605
+
606
+ mLayout ->undoStack ()->endCommand ();
610
607
}
611
- #if 0
612
- mLayout->undoStack()->push( parentCommand );
613
- mLayout->project()->setDirty( true );
614
- #endif
608
+ mLayout ->undoStack ()->endMacro ();
615
609
}
616
610
else if ( mCurrentMouseMoveAction != QgsLayoutMouseHandles::NoAction )
617
611
{
618
612
// resize selected items
619
- QUndoCommand *parentCommand = new QUndoCommand ( tr ( " Change item size" ) );
613
+ mLayout -> undoStack ()-> beginMacro ( tr ( " Change item size" ) );
620
614
621
615
// resize all selected items
622
616
const QList<QgsLayoutItem *> selectedItems = mLayout ->selectedLayoutItems ( false );
@@ -627,10 +621,9 @@ void QgsLayoutMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
627
621
// don't resize locked items or deselectable items (e.g., items which make up an item group)
628
622
continue ;
629
623
}
630
- #if 0
631
- QgsComposerItemCommand *subcommand = new QgsComposerItemCommand( item, QLatin1String( "" ), parentCommand );
632
- subcommand->savePreviousState();
633
- #endif
624
+
625
+ mLayout ->undoStack ()->beginCommand ( item, QString () );
626
+
634
627
QRectF itemRect;
635
628
if ( selectedItems.size () == 1 )
636
629
{
@@ -653,14 +646,10 @@ void QgsLayoutMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
653
646
654
647
QgsLayoutSize itemSize = mLayout ->convertFromLayoutUnits ( itemRect.size (), item->sizeWithUnits ().units () );
655
648
item->attemptResize ( itemSize );
656
- #if 0
657
- subcommand->saveAfterState();
658
- #endif
649
+
650
+ mLayout ->undoStack ()->endCommand ();
659
651
}
660
- #if 0
661
- mLayout->undoStack()->push( parentCommand );
662
- mLayout->project()->setDirty( true );
663
- #endif
652
+ mLayout ->undoStack ()->endMacro ();
664
653
}
665
654
666
655
#if 0
0 commit comments