mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Add "View Log" action for child algorithms
This action shows the log of that child step, regardless of whether or not it failed. This is handy for debugging model errors after testing, when you've already closed the algorithm window...!
This commit is contained in:
parent
d4369f714d
commit
e2d6b54f35
@ -407,6 +407,13 @@ Sets the ``results`` obtained for this child algorithm for the last model execut
|
||||
%Docstring
|
||||
Emitted when the user opts to view previous results from this child algorithm.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
void showLog();
|
||||
%Docstring
|
||||
Emitted when the user opts to view the previous log from this child algorithm.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
|
@ -178,6 +178,13 @@ If ``None``, no item is selected.
|
||||
%Docstring
|
||||
Emitted when the user opts to view previous results from the child algorithm with matching ID.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
void showLog( const QString &childId );
|
||||
%Docstring
|
||||
Emitted when the user opts to view the previous log from the child algorithm with matching ID.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
|
@ -407,6 +407,13 @@ Sets the ``results`` obtained for this child algorithm for the last model execut
|
||||
%Docstring
|
||||
Emitted when the user opts to view previous results from this child algorithm.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
void showLog();
|
||||
%Docstring
|
||||
Emitted when the user opts to view the previous log from this child algorithm.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
|
@ -178,6 +178,13 @@ If ``None``, no item is selected.
|
||||
%Docstring
|
||||
Emitted when the user opts to view previous results from the child algorithm with matching ID.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
void showLog( const QString &childId );
|
||||
%Docstring
|
||||
Emitted when the user opts to view the previous log from the child algorithm with matching ID.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
|
@ -33,8 +33,10 @@ QgsProcessingFeedback::QgsProcessingFeedback( bool logFeedback )
|
||||
|
||||
}
|
||||
|
||||
void QgsProcessingFeedback::setProgressText( const QString & )
|
||||
void QgsProcessingFeedback::setProgressText( const QString &text )
|
||||
{
|
||||
mHtmlLog.append( text.toHtmlEscaped().replace( '\n', QLatin1String( "<br>" ) ) + QStringLiteral( "<br/>" ) );
|
||||
mTextLog.append( text + '\n' );
|
||||
}
|
||||
|
||||
void QgsProcessingFeedback::log( const QString &htmlMessage, const QString &textMessage )
|
||||
|
@ -901,10 +901,33 @@ void QgsModelChildAlgorithmGraphicItem::contextMenuEvent( QGraphicsSceneContextM
|
||||
QAction *viewOutputLayersAction = popupmenu->addAction( QObject::tr( "View Output Layers" ) );
|
||||
viewOutputLayersAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionShowSelectedLayers.svg" ) ) );
|
||||
connect( viewOutputLayersAction, &QAction::triggered, this, &QgsModelChildAlgorithmGraphicItem::showPreviousResults );
|
||||
if ( mResults.outputs().empty() )
|
||||
viewOutputLayersAction->setEnabled( false );
|
||||
// enable this action only when the child succeeded
|
||||
switch ( mResults.executionStatus() )
|
||||
{
|
||||
case Qgis::ProcessingModelChildAlgorithmExecutionStatus::NotExecuted:
|
||||
case Qgis::ProcessingModelChildAlgorithmExecutionStatus::Failed:
|
||||
viewOutputLayersAction->setEnabled( false );
|
||||
break;
|
||||
|
||||
case Qgis::ProcessingModelChildAlgorithmExecutionStatus::Success:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QAction *viewLogAction = popupmenu->addAction( QObject::tr( "View Log…" ) );
|
||||
connect( viewLogAction, &QAction::triggered, this, &QgsModelChildAlgorithmGraphicItem::showLog );
|
||||
// enable this action even when the child failed
|
||||
switch ( mResults.executionStatus() )
|
||||
{
|
||||
case Qgis::ProcessingModelChildAlgorithmExecutionStatus::NotExecuted:
|
||||
viewLogAction->setEnabled( false );
|
||||
break;
|
||||
|
||||
case Qgis::ProcessingModelChildAlgorithmExecutionStatus::Success:
|
||||
case Qgis::ProcessingModelChildAlgorithmExecutionStatus::Failed:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
popupmenu->exec( event->screenPos() );
|
||||
|
@ -475,6 +475,13 @@ class GUI_EXPORT QgsModelChildAlgorithmGraphicItem : public QgsModelComponentGra
|
||||
*/
|
||||
void showPreviousResults();
|
||||
|
||||
/**
|
||||
* Emitted when the user opts to view the previous log from this child algorithm.
|
||||
*
|
||||
* \since QGIS 3.38
|
||||
*/
|
||||
void showLog();
|
||||
|
||||
protected:
|
||||
|
||||
QColor fillColor( State state ) const override;
|
||||
|
@ -513,6 +513,7 @@ void QgsModelDesignerDialog::setModelScene( QgsModelGraphicsScene *scene )
|
||||
connect( mScene, &QgsModelGraphicsScene::componentAboutToChange, this, [ = ]( const QString & description, int id ) { beginUndoCommand( description, id ); } );
|
||||
connect( mScene, &QgsModelGraphicsScene::componentChanged, this, [ = ] { endUndoCommand(); } );
|
||||
connect( mScene, &QgsModelGraphicsScene::showPreviousResults, this, &QgsModelDesignerDialog::showPreviousResults );
|
||||
connect( mScene, &QgsModelGraphicsScene::showLog, this, &QgsModelDesignerDialog::showLog );
|
||||
|
||||
mView->centerOn( center );
|
||||
|
||||
@ -1120,6 +1121,24 @@ void QgsModelDesignerDialog::showPreviousResults( const QString &childId )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsModelDesignerDialog::showLog( const QString &childId )
|
||||
{
|
||||
const QString childDescription = mModel->childAlgorithm( childId ).description();
|
||||
|
||||
const QgsProcessingModelChildAlgorithmResult result = mChildResults.value( childId );
|
||||
if ( result.htmlLog().isEmpty() )
|
||||
{
|
||||
mMessageBar->pushWarning( QString(), tr( "No log is available for %1" ).arg( childDescription ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QgsMessageViewer m( this, QgsGuiUtils::ModalDialogFlags, false );
|
||||
m.setWindowTitle( childDescription );
|
||||
m.setCheckBoxVisible( false );
|
||||
m.setMessageAsHtml( result.htmlLog() );
|
||||
m.exec();
|
||||
}
|
||||
|
||||
void QgsModelDesignerDialog::validate()
|
||||
{
|
||||
QStringList issues;
|
||||
|
@ -186,6 +186,7 @@ class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsMode
|
||||
void editHelp();
|
||||
void run();
|
||||
void showPreviousResults( const QString &childId );
|
||||
void showLog( const QString &childId );
|
||||
|
||||
private:
|
||||
|
||||
|
@ -149,6 +149,10 @@ void QgsModelGraphicsScene::createItems( QgsProcessingModelAlgorithm *model, Qgs
|
||||
{
|
||||
emit showPreviousResults( childId );
|
||||
} );
|
||||
connect( item, &QgsModelChildAlgorithmGraphicItem::showLog, this, [this, childId]
|
||||
{
|
||||
emit showLog( childId );
|
||||
} );
|
||||
|
||||
addCommentItemForComponent( model, it.value(), item );
|
||||
}
|
||||
|
@ -194,6 +194,13 @@ class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene
|
||||
*/
|
||||
void showPreviousResults( const QString &childId );
|
||||
|
||||
/**
|
||||
* Emitted when the user opts to view the previous log from the child algorithm with matching ID.
|
||||
*
|
||||
* \since QGIS 3.38
|
||||
*/
|
||||
void showLog( const QString &childId );
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user