Skip to content

Commit

Permalink
Batch multi item move undo commands
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 12, 2020
1 parent 5011985 commit d97f024
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
Expand Up @@ -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 );
Expand All @@ -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

};
Expand Down
10 changes: 10 additions & 0 deletions src/gui/processing/models/qgsmodeldesignerdialog.cpp
Expand Up @@ -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();
}

Expand Down
10 changes: 10 additions & 0 deletions src/gui/processing/models/qgsmodelgraphicsview.cpp
Expand Up @@ -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 ) )
Expand Down
20 changes: 20 additions & 0 deletions src/gui/processing/models/qgsmodelgraphicsview.h
Expand Up @@ -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:

/**
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/gui/processing/models/qgsmodelviewmousehandles.cpp
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/gui/processing/models/qgsmodelviewmousehandles.h
Expand Up @@ -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:

Expand Down

0 comments on commit d97f024

Please sign in to comment.