QGIS API Documentation 3.99.0-Master (a8882ad4560)
Loading...
Searching...
No Matches
qgsfeedback.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsfeedback.cpp
3 --------------------------------------
4 Date : December 2025
5 Copyright : (C) 2025 by Even Rouault
6 Email : event dot rouault at spatialys dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsfeedback.h"
17
18#include "moc_qgsfeedback.cpp"
19
21
22/* static */
23std::unique_ptr<QgsFeedback> QgsFeedback::createScaledFeedback(
24 QgsFeedback *parentFeedback, double startPercentage, double endPercentage )
25{
26 auto scaledFeedback = std::make_unique<QgsFeedback>();
27 if ( parentFeedback )
28 {
29 const double ratio = ( endPercentage - startPercentage ) / 100.0;
30 QObject::connect( scaledFeedback.get(), &QgsFeedback::progressChanged,
31 parentFeedback, [parentFeedback, startPercentage, ratio]( double progress )
32 {
33 parentFeedback->setProgress( startPercentage + progress * ratio );
34 } );
35 QObject::connect( scaledFeedback.get(), &QgsFeedback::canceled,
36 parentFeedback, &QgsFeedback::cancel );
37 }
38 return scaledFeedback;
39}
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
void canceled()
Internal routines can connect to this signal if they use event loop.
QgsFeedback(QObject *parent=nullptr)
Construct a feedback object.
Definition qgsfeedback.h:48
void cancel()
Tells the internal routines that the current operation should be canceled. This should be run by the ...
static std::unique_ptr< QgsFeedback > createScaledFeedback(QgsFeedback *parentFeedback, double startPercentage, double endPercentage)
Returns a feedback object whose [0, 100] progression range will be mapped to parentFeedback [startPer...
double progress() const
Returns the current progress reported by the feedback object.
Definition qgsfeedback.h:79
~QgsFeedback() override