|
| 1 | +/*************************************************************************** |
| 2 | + qgsprocessingfeedback.cpp |
| 3 | + ------------------------- |
| 4 | + begin : June 2017 |
| 5 | + copyright : (C) 2017 by Nyall Dawson |
| 6 | + email : nyall dot dawson at gmail dot com |
| 7 | + ***************************************************************************/ |
| 8 | + |
| 9 | +/*************************************************************************** |
| 10 | + * * |
| 11 | + * This program is free software; you can redistribute it and/or modify * |
| 12 | + * it under the terms of the GNU General Public License as published by * |
| 13 | + * the Free Software Foundation; either version 2 of the License, or * |
| 14 | + * (at your option) any later version. * |
| 15 | + * * |
| 16 | + ***************************************************************************/ |
| 17 | + |
| 18 | +#include "qgsprocessingfeedback.h" |
| 19 | + |
| 20 | +QgsProcessingMultiStepFeedback::QgsProcessingMultiStepFeedback( int childAlgorithmCount, QgsProcessingFeedback *feedback ) |
| 21 | + : mChildSteps( childAlgorithmCount ) |
| 22 | + , mFeedback( feedback ) |
| 23 | +{ |
| 24 | + connect( mFeedback, &QgsFeedback::canceled, this, &QgsFeedback::cancel, Qt::DirectConnection ); |
| 25 | + connect( this, &QgsFeedback::progressChanged, this, &QgsProcessingMultiStepFeedback::updateOverallProgress ); |
| 26 | +} |
| 27 | + |
| 28 | +void QgsProcessingMultiStepFeedback::setCurrentStep( int step ) |
| 29 | +{ |
| 30 | + mCurrentStep = step; |
| 31 | + mFeedback->setProgress( 100.0 * static_cast< double >( mCurrentStep ) / mChildSteps ); |
| 32 | +} |
| 33 | + |
| 34 | +void QgsProcessingMultiStepFeedback::setProgressText( const QString &text ) |
| 35 | +{ |
| 36 | + mFeedback->setProgressText( text ); |
| 37 | +} |
| 38 | + |
| 39 | +void QgsProcessingMultiStepFeedback::reportError( const QString &error ) |
| 40 | +{ |
| 41 | + mFeedback->reportError( error ); |
| 42 | +} |
| 43 | + |
| 44 | +void QgsProcessingMultiStepFeedback::pushInfo( const QString &info ) |
| 45 | +{ |
| 46 | + mFeedback->pushInfo( info ); |
| 47 | +} |
| 48 | + |
| 49 | +void QgsProcessingMultiStepFeedback::pushCommandInfo( const QString &info ) |
| 50 | +{ |
| 51 | + mFeedback->pushCommandInfo( info ); |
| 52 | +} |
| 53 | + |
| 54 | +void QgsProcessingMultiStepFeedback::pushDebugInfo( const QString &info ) |
| 55 | +{ |
| 56 | + mFeedback->pushDebugInfo( info ); |
| 57 | +} |
| 58 | + |
| 59 | +void QgsProcessingMultiStepFeedback::pushConsoleInfo( const QString &info ) |
| 60 | +{ |
| 61 | + mFeedback->pushConsoleInfo( info ); |
| 62 | +} |
| 63 | + |
| 64 | +void QgsProcessingMultiStepFeedback::updateOverallProgress( double progress ) |
| 65 | +{ |
| 66 | + double baseProgress = 100.0 * static_cast< double >( mCurrentStep ) / mChildSteps; |
| 67 | + double currentAlgorithmProgress = progress / mChildSteps; |
| 68 | + mFeedback->setProgress( baseProgress + currentAlgorithmProgress ); |
| 69 | +} |
| 70 | + |
| 71 | + |
0 commit comments