16#ifndef QGSPROCESSINGALGORITHMDIALOGBASE_H
17#define QGSPROCESSINGALGORITHMDIALOGBASE_H
21#include "ui_qgsprocessingalgorithmdialogbase.h"
22#include "ui_qgsprocessingalgorithmprogressdialogbase.h"
23#include "ui_qgsprocessingcontextoptionsbase.h"
34class QgsProcessingAlgorithmDialogBase;
35class QgsProcessingContextOptionsWidget;
57 QgsProcessingAlgorithmDialogFeedback();
61 void progressTextChanged(
const QString &text );
62 void errorReported(
const QString &text,
bool fatalError );
63 void warningPushed(
const QString &text );
64 void infoPushed(
const QString &text );
65 void commandInfoPushed(
const QString &text );
66 void debugInfoPushed(
const QString &text );
67 void consoleInfoPushed(
const QString &text );
72 void reportError(
const QString &error,
bool fatalError )
override;
74 void pushInfo(
const QString &info )
override;
109 enum class DialogMode :
int
114 Q_ENUM( QgsProcessingAlgorithmDialogBase::DialogMode )
119 QgsProcessingAlgorithmDialogBase( QWidget *parent
SIP_TRANSFERTHIS =
nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), QgsProcessingAlgorithmDialogBase::DialogMode mode = QgsProcessingAlgorithmDialogBase::DialogMode::Single );
120 ~QgsProcessingAlgorithmDialogBase()
override;
159 bool wasExecuted()
const {
return mExecuted; }
166 QVariantMap results()
const {
return mResults; }
180 void saveLogToFile( const QString &path, LogFormat format = FormatPlainText );
203 virtual
void setParameters( const QVariantMap &values );
212 void reportError( const QString &error,
bool fatalError );
217 void pushWarning( const QString &warning );
222 void pushInfo( const QString &info );
227 void pushDebugInfo( const QString &message );
232 void pushCommandInfo( const QString &info );
237 void setPercentage(
double percent );
242 void setProgressText( const QString &text );
247 void pushConsoleInfo( const QString &info );
253 QDialog *createProgressDialog();
272 void copyLogToClipboard();
277 void showParameters();
279 void reject() override;
283 void closeEvent( QCloseEvent *e ) override;
288 QPushButton *runButton();
293 QPushButton *cancelButton();
298 QPushButton *changeParametersButton();
303 QDialogButtonBox *buttonBox();
308 QTabWidget *tabWidget();
313 void clearProgress();
320 void setExecuted(
bool executed );
325 void setExecutedAnyResult(
bool executedAnyResult );
332 void setResults( const QVariantMap &results );
337 void setInfo( const QString &message,
bool isError = false,
bool escapeHtml = true,
bool isWarning = false );
348 virtual
void resetAdditionalGui();
353 void updateRunButtonVisibility();
359 void blockControlsWhileRunning();
365 virtual
void blockAdditionalControlsWhileRunning();
375 void hideShortHelp();
388 static QString formatStringForLog( const QString &
string );
395 virtual
bool isFinalized();
413 void algorithmFinished(
bool successful, const QVariantMap &result );
425 virtual
void runAlgorithm();
432 virtual
void algExecuted(
bool successful, const QVariantMap &results );
437 void toggleCollapsed();
439 void splitterChanged(
int pos,
int index );
440 void mTabWidget_currentChanged(
int index );
441 void linkClicked( const QUrl &url );
442 void taskTriggered(
QgsTask *task );
447 DialogMode mMode = DialogMode::Single;
449 QPushButton *mButtonRun =
nullptr;
450 QPushButton *mButtonClose =
nullptr;
451 QPushButton *mButtonChangeParameters =
nullptr;
452 QByteArray mSplitterState;
453 QToolButton *mButtonCollapse =
nullptr;
455 QPushButton *mAdvancedButton =
nullptr;
456 QMenu *mAdvancedMenu =
nullptr;
457 QAction *mCopyAsQgisProcessCommand =
nullptr;
458 QAction *mPasteJsonAction =
nullptr;
459 QAction *mContextSettingsAction =
nullptr;
461 bool mExecuted = false;
462 bool mExecutedAnyResult = false;
463 QVariantMap mResults;
468 bool mHelpCollapsed = false;
470 int mMessageLoggedCount = 0;
474 QPointer< QgsProcessingContextOptionsWidget > mContextOptionsWidget;
475 bool mOverrideDefaultContextSettings = false;
477 Qgis::DistanceUnit mDistanceUnits =
Qgis::DistanceUnit::Unknown;
478 Qgis::AreaUnit mAreaUnits =
Qgis::AreaUnit::Unknown;
479 QString mTemporaryFolderOverride;
480 int mMaximumThreads = QThread::idealThreadCount();
483 void scrollToBottomOfLog();
484 void processEvents();
496class QgsProcessingAlgorithmProgressDialog :
public QDialog,
private Ui::QgsProcessingProgressDialogBase
505 QgsProcessingAlgorithmProgressDialog( QWidget *parent =
nullptr );
510 QProgressBar *progressBar();
515 QPushButton *cancelButton();
520 QTextEdit *logTextEdit();
524 void reject()
override;
534class GUI_EXPORT QgsProcessingContextOptionsWidget :
public QgsPanelWidget,
private Ui::QgsProcessingContextOptionsBase
543 QgsProcessingContextOptionsWidget( QWidget *parent
SIP_TRANSFERTHIS =
nullptr );
568 QString temporaryFolder();
573 int maximumThreads()
const;
The Qgis class provides global constants for use throughout the application.
DistanceUnit
Units of distance.
This class wraps a request for features to a vector layer (or directly its vector data provider).
InvalidGeometryCheck
Handling of features with invalid geometries.
A bar for displaying non-blocking messages to the user.
QgsTask task which runs a QgsProcessingAlgorithm in a background task.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
Contains information about the context in which a processing algorithm is executed.
LogLevel
Logging level for algorithms to use when pushing feedback messages.
Base class for providing feedback from a processing algorithm.
virtual void pushCommandInfo(const QString &info)
Pushes an informational message containing a command from the algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
virtual void pushWarning(const QString &warning)
Pushes a warning informational message from the algorithm.
virtual void pushDebugInfo(const QString &info)
Pushes an informational message containing debugging helpers from the algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
virtual void pushConsoleInfo(const QString &info)
Pushes a console feedback message from the algorithm.
virtual void setProgressText(const QString &text)
Sets a progress report text string.
An interface for objects which can create sets of parameter values for processing algorithms.
Abstract base class for long running background tasks.
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