Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processing] Generalise modeler multi-step feedback proxy for use
outside of modeler This can be useful too for individual algorithms
- Loading branch information
1 parent
94a1e68
commit e6d86bb
Showing
7 changed files
with
168 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*************************************************************************** | ||
qgsprocessingfeedback.cpp | ||
------------------------- | ||
begin : June 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsprocessingfeedback.h" | ||
|
||
QgsProcessingMultiStepFeedback::QgsProcessingMultiStepFeedback( int childAlgorithmCount, QgsProcessingFeedback *feedback ) | ||
: mChildSteps( childAlgorithmCount ) | ||
, mFeedback( feedback ) | ||
{ | ||
connect( mFeedback, &QgsFeedback::canceled, this, &QgsFeedback::cancel, Qt::DirectConnection ); | ||
connect( this, &QgsFeedback::progressChanged, this, &QgsProcessingMultiStepFeedback::updateOverallProgress ); | ||
} | ||
|
||
void QgsProcessingMultiStepFeedback::setCurrentStep( int step ) | ||
{ | ||
mCurrentStep = step; | ||
mFeedback->setProgress( 100.0 * static_cast< double >( mCurrentStep ) / mChildSteps ); | ||
} | ||
|
||
void QgsProcessingMultiStepFeedback::setProgressText( const QString &text ) | ||
{ | ||
mFeedback->setProgressText( text ); | ||
} | ||
|
||
void QgsProcessingMultiStepFeedback::reportError( const QString &error ) | ||
{ | ||
mFeedback->reportError( error ); | ||
} | ||
|
||
void QgsProcessingMultiStepFeedback::pushInfo( const QString &info ) | ||
{ | ||
mFeedback->pushInfo( info ); | ||
} | ||
|
||
void QgsProcessingMultiStepFeedback::pushCommandInfo( const QString &info ) | ||
{ | ||
mFeedback->pushCommandInfo( info ); | ||
} | ||
|
||
void QgsProcessingMultiStepFeedback::pushDebugInfo( const QString &info ) | ||
{ | ||
mFeedback->pushDebugInfo( info ); | ||
} | ||
|
||
void QgsProcessingMultiStepFeedback::pushConsoleInfo( const QString &info ) | ||
{ | ||
mFeedback->pushConsoleInfo( info ); | ||
} | ||
|
||
void QgsProcessingMultiStepFeedback::updateOverallProgress( double progress ) | ||
{ | ||
double baseProgress = 100.0 * static_cast< double >( mCurrentStep ) / mChildSteps; | ||
double currentAlgorithmProgress = progress / mChildSteps; | ||
mFeedback->setProgress( baseProgress + currentAlgorithmProgress ); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters