mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Add undo/redo for item move with cursor. Prevent item command merge for different items
This commit is contained in:
parent
0a9204c40d
commit
663f5ad0a1
@ -88,7 +88,7 @@ QgsComposerMergeCommand::~QgsComposerMergeCommand()
|
||||
bool QgsComposerMergeCommand::mergeWith( const QUndoCommand * command )
|
||||
{
|
||||
const QgsComposerItemCommand* c = dynamic_cast<const QgsComposerItemCommand*>( command );
|
||||
if ( !c )
|
||||
if ( !c || mItem != c->item() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -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 );
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user