QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsprocessingbatchalgorithmdialogbase.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingalgorithmdialogbase.h
3  ----------------------------------
4  Date : November 2017
5  Copyright : (C) 2017 Nyall Dawson
6  Email : nyall dot dawson at gmail 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 #ifndef QGSPROCESSINGBATCHALGORITHMDIALOGBASE_H
17 #define QGSPROCESSINGBATCHALGORITHMDIALOGBASE_H
18 
19 #include "qgis.h"
20 #include "qgis_gui.h"
22 
23 #include <QElapsedTimer>
24 
27 
29 
30 
37 class GUI_EXPORT QgsProcessingBatchAlgorithmDialogBase : public QgsProcessingAlgorithmDialogBase
38 {
39  Q_OBJECT
40 
41  public:
42 
46  QgsProcessingBatchAlgorithmDialogBase( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
47  ~QgsProcessingBatchAlgorithmDialogBase() override;
48 
49  void resetAdditionalGui() override;
50  void blockAdditionalControlsWhileRunning() override;
51 
52  public slots:
53 
57  virtual void runAsSingle() = 0;
58 
59  protected slots:
60 
61  void algExecuted( bool successful, const QVariantMap &results ) override;
62 
63  protected:
64 
65  bool isFinalized() override;
66 
71  void execute( const QList< QVariantMap > &parameters );
72 
78  virtual QgsProcessingContext *createContext( QgsProcessingFeedback *feedback ) = 0 SIP_FACTORY;
79 
83  virtual void handleAlgorithmResults( QgsProcessingAlgorithm *algorithm, QgsProcessingContext &context, QgsProcessingFeedback *feedback, const QVariantMap &parameters ) = 0;
84 
88  virtual void loadHtmlResults( const QVariantMap &results, int index ) = 0;
89 
93  virtual void createSummaryTable( const QList< QVariantMap > &results, const QList< QVariantMap > &errors ) = 0;
94 
95  private slots:
96 
97  void onTaskComplete( bool ok, const QVariantMap &results );
98  void taskTriggered( QgsTask *task );
99 
100  private:
101 
102  void executeNext();
103  void allTasksComplete( bool canceled );
104 
105  QPushButton *mButtonRunSingle = nullptr;
106 
107  int mCurrentStep = 0;
108  int mTotalSteps = 0;
109  QList< QVariantMap > mQueuedParameters;
110  QVariantMap mCurrentParameters;
111  QPointer< QgsProxyProgressTask > mProxyTask;
112  std::unique_ptr< QgsProcessingFeedback > mFeedback;
113  std::unique_ptr< QgsProcessingBatchFeedback > mBatchFeedback;
114  std::unique_ptr< QgsProcessingContext > mTaskContext;
115  QList< QVariantMap > mResults;
116  QList< QVariantMap > mErrors;
117  QElapsedTimer mTotalTimer;
118  QElapsedTimer mCurrentStepTimer;
119 };
120 
122 
123 #endif // QGSPROCESSINGBATCHALGORITHMDIALOGBASE_H
QgsProcessingFeedback
Base class for providing feedback from a processing algorithm.
Definition: qgsprocessingfeedback.h:37
algorithm
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
QgsProxyProgressTask
A QgsTask shell which proxies progress reports.
Definition: qgsproxyprogresstask.h:37
qgis.h
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:46
QgsProcessingAlgorithm
Abstract base class for processing algorithms.
Definition: qgsprocessingalgorithm.h:52
qgsprocessingalgorithmdialogbase.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsProcessingBatchFeedback
Processing feedback subclass for use when batch processing.
Definition: qgsprocessingbatch.h:32
QgsTask
Abstract base class for long running background tasks. Tasks can be controlled directly,...
Definition: qgstaskmanager.h:54