diff --git a/src/core/composer/qgscomposeritemcommand.cpp b/src/core/composer/qgscomposeritemcommand.cpp index 1c4f81725d4b..dc8b5a9f4975 100644 --- a/src/core/composer/qgscomposeritemcommand.cpp +++ b/src/core/composer/qgscomposeritemcommand.cpp @@ -88,7 +88,7 @@ QgsComposerMergeCommand::~QgsComposerMergeCommand() bool QgsComposerMergeCommand::mergeWith( const QUndoCommand * command ) { const QgsComposerItemCommand* c = dynamic_cast( command ); - if ( !c ) + if ( !c || mItem != c->item() ) { return false; } diff --git a/src/core/composer/qgscomposeritemcommand.h b/src/core/composer/qgscomposeritemcommand.h index d2c841f1d466..2c60709e1bb8 100644 --- a/src/core/composer/qgscomposeritemcommand.h +++ b/src/core/composer/qgscomposeritemcommand.h @@ -46,6 +46,8 @@ class CORE_EXPORT QgsComposerItemCommand: public QUndoCommand /**Returns true if previous state and after state are valid and different*/ bool containsChange() const; + const QgsComposerItem* item() const { return mItem; } + protected: /**Target item of the command*/ QgsComposerItem* mItem; @@ -108,7 +110,8 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand ArrowOutlineWidth, ArrowHeadWidth, //item - ItemOutlineWidth + ItemOutlineWidth, + ItemMove }; QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text ); diff --git a/src/gui/qgscomposerview.cpp b/src/gui/qgscomposerview.cpp index beac48184083..9c9484a9b85e 100644 --- a/src/gui/qgscomposerview.cpp +++ b/src/gui/qgscomposerview.cpp @@ -502,28 +502,36 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e ) { for ( ; itemIt != composerItemList.end(); ++itemIt ) { + ( *itemIt )->beginCommand( tr( "Item moved" ), QgsComposerMergeCommand::ItemMove ); ( *itemIt )->move( -1.0, 0.0 ); + ( *itemIt )->endCommand(); } } else if ( e->key() == Qt::Key_Right ) { for ( ; itemIt != composerItemList.end(); ++itemIt ) { + ( *itemIt )->beginCommand( tr( "Item moved" ), QgsComposerMergeCommand::ItemMove ); ( *itemIt )->move( 1.0, 0.0 ); + ( *itemIt )->endCommand(); } } else if ( e->key() == Qt::Key_Down ) { for ( ; itemIt != composerItemList.end(); ++itemIt ) { + ( *itemIt )->beginCommand( tr( "Item moved" ), QgsComposerMergeCommand::ItemMove ); ( *itemIt )->move( 0.0, 1.0 ); + ( *itemIt )->endCommand(); } } else if ( e->key() == Qt::Key_Up ) { for ( ; itemIt != composerItemList.end(); ++itemIt ) { + ( *itemIt )->beginCommand( tr( "Item moved" ), QgsComposerMergeCommand::ItemMove ); ( *itemIt )->move( 0.0, -1.0 ); + ( *itemIt )->endCommand(); } } }