@ -30,12 +30,14 @@
# include "UBGraphicsItemTransformUndoCommand.h"
# include "UBGraphicsItemTransformUndoCommand.h"
# include "UBResizableGraphicsItem.h"
# include "UBResizableGraphicsItem.h"
# include "domain/UBItem.h"
# include "domain/UBItem.h"
# include "domain/UBGraphicsScene.h"
# include "core/memcheck.h"
# include "core/memcheck.h"
UBGraphicsItemTransformUndoCommand : : UBGraphicsItemTransformUndoCommand ( QGraphicsItem * pItem ,
UBGraphicsItemTransformUndoCommand : : UBGraphicsItemTransformUndoCommand ( QGraphicsItem * pItem ,
const QPointF & prevPos , const QTransform & prevTransform , const qreal & prevZValue ,
const QPointF & prevPos , const QTransform & prevTransform , const qreal & prevZValue ,
const QSizeF & prevSize ) : UBUndoCommand ( )
const QSizeF & prevSize , bool setToBackground )
: UBUndoCommand ( )
{
{
mItem = pItem ;
mItem = pItem ;
mPreviousTransform = prevTransform ;
mPreviousTransform = prevTransform ;
@ -52,6 +54,8 @@ UBGraphicsItemTransformUndoCommand::UBGraphicsItemTransformUndoCommand(QGraphics
if ( resizableItem )
if ( resizableItem )
mCurrentSize = resizableItem - > size ( ) ;
mCurrentSize = resizableItem - > size ( ) ;
mSetToBackground = setToBackground ;
}
}
UBGraphicsItemTransformUndoCommand : : ~ UBGraphicsItemTransformUndoCommand ( )
UBGraphicsItemTransformUndoCommand : : ~ UBGraphicsItemTransformUndoCommand ( )
@ -61,6 +65,13 @@ UBGraphicsItemTransformUndoCommand::~UBGraphicsItemTransformUndoCommand()
void UBGraphicsItemTransformUndoCommand : : undo ( )
void UBGraphicsItemTransformUndoCommand : : undo ( )
{
{
if ( mSetToBackground ) {
UBGraphicsScene * scene = dynamic_cast < UBGraphicsScene * > ( mItem - > scene ( ) ) ;
if ( scene & & scene - > isBackgroundObject ( mItem ) ) {
scene - > unsetBackgroundObject ( ) ;
}
}
mItem - > setPos ( mPreviousPosition ) ;
mItem - > setPos ( mPreviousPosition ) ;
mItem - > setTransform ( mPreviousTransform ) ;
mItem - > setTransform ( mPreviousTransform ) ;
mItem - > setZValue ( mPreviousZValue ) ;
mItem - > setZValue ( mPreviousZValue ) ;
@ -73,6 +84,12 @@ void UBGraphicsItemTransformUndoCommand::undo()
void UBGraphicsItemTransformUndoCommand : : redo ( )
void UBGraphicsItemTransformUndoCommand : : redo ( )
{
{
if ( mSetToBackground ) {
UBGraphicsScene * scene = dynamic_cast < UBGraphicsScene * > ( mItem - > scene ( ) ) ;
if ( scene )
scene - > setAsBackgroundObject ( mItem ) ;
}
mItem - > setPos ( mCurrentPosition ) ;
mItem - > setPos ( mCurrentPosition ) ;
mItem - > setTransform ( mCurrentTransform ) ;
mItem - > setTransform ( mCurrentTransform ) ;
mItem - > setZValue ( mCurrentZValue ) ;
mItem - > setZValue ( mCurrentZValue ) ;