Add Run Selected option to right click menu for selected algorithms

This commit is contained in:
Nyall Dawson 2024-04-22 13:46:48 +10:00
parent e6fb69c41e
commit 2f5ad6b51f
9 changed files with 53 additions and 0 deletions

View File

@ -407,6 +407,13 @@ Sets the ``results`` obtained for this child algorithm for the last model execut
%Docstring %Docstring
Emitted when the user opts to run the model from this child algorithm. Emitted when the user opts to run the model from this child algorithm.
.. versionadded:: 3.38
%End
void runSelected();
%Docstring
Emitted when the user opts to run selected steps from the model.
.. versionadded:: 3.38 .. versionadded:: 3.38
%End %End

View File

@ -172,6 +172,13 @@ Emitted whenever a component of the model is changed.
%Docstring %Docstring
Emitted whenever the selected item changes. Emitted whenever the selected item changes.
If ``None``, no item is selected. If ``None``, no item is selected.
%End
void runSelected();
%Docstring
Emitted when the user opts to run selected steps from the model.
.. versionadded:: 3.38
%End %End
void runFromChild( const QString &childId ); void runFromChild( const QString &childId );

View File

@ -407,6 +407,13 @@ Sets the ``results`` obtained for this child algorithm for the last model execut
%Docstring %Docstring
Emitted when the user opts to run the model from this child algorithm. Emitted when the user opts to run the model from this child algorithm.
.. versionadded:: 3.38
%End
void runSelected();
%Docstring
Emitted when the user opts to run selected steps from the model.
.. versionadded:: 3.38 .. versionadded:: 3.38
%End %End

View File

@ -172,6 +172,13 @@ Emitted whenever a component of the model is changed.
%Docstring %Docstring
Emitted whenever the selected item changes. Emitted whenever the selected item changes.
If ``None``, no item is selected. If ``None``, no item is selected.
%End
void runSelected();
%Docstring
Emitted when the user opts to run selected steps from the model.
.. versionadded:: 3.38
%End %End
void runFromChild( const QString &childId ); void runFromChild( const QString &childId );

View File

@ -870,9 +870,18 @@ QgsModelChildAlgorithmGraphicItem::QgsModelChildAlgorithmGraphicItem( QgsProcess
void QgsModelChildAlgorithmGraphicItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event ) void QgsModelChildAlgorithmGraphicItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event )
{ {
QMenu *popupmenu = new QMenu( event->widget() ); QMenu *popupmenu = new QMenu( event->widget() );
if ( isSelected() )
{
QAction *runSelectedStepsAction = popupmenu->addAction( QObject::tr( "Run Selected Steps…" ) );
runSelectedStepsAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionStart.svg" ) ) );
connect( runSelectedStepsAction, &QAction::triggered, this, &QgsModelChildAlgorithmGraphicItem::runSelected );
}
QAction *runFromHereAction = popupmenu->addAction( QObject::tr( "Run from Here…" ) ); QAction *runFromHereAction = popupmenu->addAction( QObject::tr( "Run from Here…" ) );
runFromHereAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionStart.svg" ) ) ); runFromHereAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionStart.svg" ) ) );
connect( runFromHereAction, &QAction::triggered, this, &QgsModelChildAlgorithmGraphicItem::runFromHere ); connect( runFromHereAction, &QAction::triggered, this, &QgsModelChildAlgorithmGraphicItem::runFromHere );
popupmenu->addSeparator(); popupmenu->addSeparator();
QAction *removeAction = popupmenu->addAction( QObject::tr( "Remove" ) ); QAction *removeAction = popupmenu->addAction( QObject::tr( "Remove" ) );

View File

@ -475,6 +475,13 @@ class GUI_EXPORT QgsModelChildAlgorithmGraphicItem : public QgsModelComponentGra
*/ */
void runFromHere(); void runFromHere();
/**
* Emitted when the user opts to run selected steps from the model.
*
* \since QGIS 3.38
*/
void runSelected();
/** /**
* Emitted when the user opts to view previous results from this child algorithm. * Emitted when the user opts to view previous results from this child algorithm.
* *

View File

@ -514,6 +514,7 @@ void QgsModelDesignerDialog::setModelScene( QgsModelGraphicsScene *scene )
connect( mScene, &QgsModelGraphicsScene::componentAboutToChange, this, [ = ]( const QString & description, int id ) { beginUndoCommand( description, id ); } ); connect( mScene, &QgsModelGraphicsScene::componentAboutToChange, this, [ = ]( const QString & description, int id ) { beginUndoCommand( description, id ); } );
connect( mScene, &QgsModelGraphicsScene::componentChanged, this, [ = ] { endUndoCommand(); } ); connect( mScene, &QgsModelGraphicsScene::componentChanged, this, [ = ] { endUndoCommand(); } );
connect( mScene, &QgsModelGraphicsScene::runFromChild, this, &QgsModelDesignerDialog::runFromChild ); connect( mScene, &QgsModelGraphicsScene::runFromChild, this, &QgsModelDesignerDialog::runFromChild );
connect( mScene, &QgsModelGraphicsScene::runSelected, this, &QgsModelDesignerDialog::runSelectedSteps );
connect( mScene, &QgsModelGraphicsScene::showChildAlgorithmOutputs, this, &QgsModelDesignerDialog::showChildAlgorithmOutputs ); connect( mScene, &QgsModelGraphicsScene::showChildAlgorithmOutputs, this, &QgsModelDesignerDialog::showChildAlgorithmOutputs );
connect( mScene, &QgsModelGraphicsScene::showChildAlgorithmLog, this, &QgsModelDesignerDialog::showChildAlgorithmLog ); connect( mScene, &QgsModelGraphicsScene::showChildAlgorithmLog, this, &QgsModelDesignerDialog::showChildAlgorithmLog );

View File

@ -149,6 +149,7 @@ void QgsModelGraphicsScene::createItems( QgsProcessingModelAlgorithm *model, Qgs
{ {
emit runFromChild( childId ); emit runFromChild( childId );
} ); } );
connect( item, &QgsModelChildAlgorithmGraphicItem::runSelected, this, &QgsModelGraphicsScene::runSelected );
connect( item, &QgsModelChildAlgorithmGraphicItem::showPreviousResults, this, [this, childId] connect( item, &QgsModelChildAlgorithmGraphicItem::showPreviousResults, this, [this, childId]
{ {
emit showChildAlgorithmOutputs( childId ); emit showChildAlgorithmOutputs( childId );

View File

@ -187,6 +187,13 @@ class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene
*/ */
void selectedItemChanged( QgsModelComponentGraphicItem *selected ); void selectedItemChanged( QgsModelComponentGraphicItem *selected );
/**
* Emitted when the user opts to run selected steps from the model.
*
* \since QGIS 3.38
*/
void runSelected();
/** /**
* Emitted when the user opts to run the part of the model starting from the specified child algorithm. * Emitted when the user opts to run the part of the model starting from the specified child algorithm.
* *