Skip to content
Permalink
Browse files

Batch multi item move undo commands

  • Loading branch information
nyalldawson committed Mar 11, 2020
1 parent 5011985 commit d97f02420e31d78bd5943f7c903116f88cd9f5da
@@ -70,6 +70,16 @@ Returns the scene associated with the tool.



void startMacroCommand( const QString &text );
%Docstring
Starts a macro command, containing a group of interactions in the view.
%End

void endMacroCommand();
%Docstring
Ends a macro command, containing a group of interactions in the view.
%End

signals:

void algorithmDropped( const QString &algorithmId, const QPointF &pos );
@@ -93,6 +103,16 @@ item and should have its properties displayed in any designer windows.
%Docstring
Emitted in the destructor when the view is about to be deleted,
but is still in a perfectly valid state.
%End

void macroCommandStarted( const QString &text );
%Docstring
Emitted when a macro command containing a group of interactions is started in the view.
%End

void macroCommandEnded();
%Docstring
Emitted when a macro command containing a group of interactions in the view has ended.
%End

};
@@ -238,6 +238,16 @@ QgsModelDesignerDialog::QgsModelDesignerDialog( QWidget *parent, Qt::WindowFlags
mView->setTool( mSelectTool );
mView->setFocus();

connect( mView, &QgsModelGraphicsView::macroCommandStarted, this, [ = ]( const QString & text )
{
mUndoStack->beginMacro( text );
} );
connect( mView, &QgsModelGraphicsView::macroCommandEnded, this, [ = ]
{
mUndoStack->endMacro();
} );


updateWindowTitle();
}

@@ -425,6 +425,16 @@ QgsModelSnapper *QgsModelGraphicsView::snapper()
return &mSnapper;
}

void QgsModelGraphicsView::startMacroCommand( const QString &text )
{
emit macroCommandStarted( text );
}

void QgsModelGraphicsView::endMacroCommand()
{
emit macroCommandEnded();
}


QgsModelViewSnapMarker::QgsModelViewSnapMarker()
: QGraphicsRectItem( QRectF( 0, 0, 0, 0 ) )
@@ -100,6 +100,16 @@ class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
*/
QgsModelSnapper *snapper() SIP_SKIP;

/**
* Starts a macro command, containing a group of interactions in the view.
*/
void startMacroCommand( const QString &text );

/**
* Ends a macro command, containing a group of interactions in the view.
*/
void endMacroCommand();

signals:

/**
@@ -130,6 +140,16 @@ class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
*/
void willBeDeleted();

/**
* Emitted when a macro command containing a group of interactions is started in the view.
*/
void macroCommandStarted( const QString &text );

/**
* Emitted when a macro command containing a group of interactions in the view has ended.
*/
void macroCommandEnded();

private:

//! Zoom layout from a mouse wheel event
@@ -140,5 +140,15 @@ void QgsModelViewMouseHandles::setItemRect( QGraphicsItem *item, QRectF rect )
}
}

void QgsModelViewMouseHandles::startMacroCommand( const QString &text )
{
mView->startMacroCommand( text );
}

void QgsModelViewMouseHandles::endMacroCommand()
{
mView->endMacroCommand();
}


///@endcond PRIVATE
@@ -61,6 +61,8 @@ class GUI_EXPORT QgsModelViewMouseHandles: public QgsGraphicsViewMouseHandles
void moveItem( QGraphicsItem *item, double deltaX, double deltaY ) override;
void previewItemMove( QGraphicsItem *item, double deltaX, double deltaY ) override;
void setItemRect( QGraphicsItem *item, QRectF rect ) override;
void startMacroCommand( const QString &text ) override;
void endMacroCommand() override;

public slots:

0 comments on commit d97f024

Please sign in to comment.
You can’t perform that action at this time.