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;
56 QgsProcessingAlgorithmDialogFeedback();
60 void progressTextChanged(
const QString &text );
61 void errorReported(
const QString &text,
bool fatalError );
62 void warningPushed(
const QString &text );
63 void infoPushed(
const QString &text );
64 void commandInfoPushed(
const QString &text );
65 void debugInfoPushed(
const QString &text );
66 void consoleInfoPushed(
const QString &text );
67 void formattedMessagePushed(
const QString &html );
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 );
188 Qgis::ProcessingLogLevel logLevel() const;
196 void setLogLevel(
Qgis::ProcessingLogLevel level );
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 );
231 void pushFormattedMessage( const QString &html );
236 void pushDebugInfo( const QString &message );
241 void pushCommandInfo( const QString &info );
246 void setPercentage(
double percent );
251 void setProgressText( const QString &text );
256 void pushConsoleInfo( const QString &info );
262 QDialog *createProgressDialog();
281 void copyLogToClipboard();
286 void showParameters();
288 void reject() override;
292 void closeEvent( QCloseEvent *e ) override;
297 QPushButton *runButton();
302 QPushButton *cancelButton();
307 QPushButton *changeParametersButton();
312 QDialogButtonBox *buttonBox();
317 QTabWidget *tabWidget();
322 void clearProgress();
329 void setExecuted(
bool executed );
334 void setExecutedAnyResult(
bool executedAnyResult );
341 void setResults( const QVariantMap &results );
346 void setInfo( const QString &message,
bool isError = false,
bool escapeHtml = true,
bool isWarning = false );
357 virtual
void resetAdditionalGui();
362 void updateRunButtonVisibility();
368 void blockControlsWhileRunning();
374 virtual
void blockAdditionalControlsWhileRunning();
384 void hideShortHelp();
396 static QString formatStringForLog( const QString &
string );
403 virtual
bool isFinalized();
430 void algorithmFinished(
bool successful, const QVariantMap &result );
442 virtual
void runAlgorithm();
449 virtual
void algExecuted(
bool successful, const QVariantMap &results );
454 void toggleCollapsed();
456 void splitterChanged(
int pos,
int index );
457 void mTabWidget_currentChanged(
int index );
458 void linkClicked( const QUrl &url );
459 void taskTriggered(
QgsTask *task );
461 void urlClicked( const QUrl &url );
465 DialogMode mMode = DialogMode::Single;
467 QPushButton *mButtonRun =
nullptr;
468 QPushButton *mButtonClose =
nullptr;
469 QPushButton *mButtonChangeParameters =
nullptr;
470 QByteArray mSplitterState;
471 QToolButton *mButtonCollapse =
nullptr;
473 QPushButton *mAdvancedButton =
nullptr;
474 QMenu *mAdvancedMenu =
nullptr;
475 QAction *mCopyAsQgisProcessCommand =
nullptr;
476 QAction *mPasteJsonAction =
nullptr;
477 QAction *mContextSettingsAction =
nullptr;
479 bool mExecuted = false;
480 bool mExecutedAnyResult = false;
481 QVariantMap mResults;
486 bool mHelpCollapsed = false;
488 int mMessageLoggedCount = 0;
490 Qgis::ProcessingLogLevel mLogLevel =
Qgis::ProcessingLogLevel::DefaultLevel;
492 QPointer< QgsProcessingContextOptionsWidget > mContextOptionsWidget;
493 bool mOverrideDefaultContextSettings = false;
494 Qgis::InvalidGeometryCheck mGeometryCheck =
Qgis::InvalidGeometryCheck::AbortOnInvalid;
495 Qgis::DistanceUnit mDistanceUnits =
Qgis::DistanceUnit::Unknown;
496 Qgis::AreaUnit mAreaUnits =
Qgis::AreaUnit::Unknown;
497 QString mTemporaryFolderOverride;
498 int mMaximumThreads = QThread::idealThreadCount();
501 void scrollToBottomOfLog();
502 void processEvents();
513class QgsProcessingAlgorithmProgressDialog :
public QDialog,
private Ui::QgsProcessingProgressDialogBase
522 QgsProcessingAlgorithmProgressDialog( QWidget *parent =
nullptr );
527 QProgressBar *progressBar();
532 QPushButton *cancelButton();
537 QTextEdit *logTextEdit();
541 void reject()
override;
551class GUI_EXPORT QgsProcessingContextOptionsWidget :
public QgsPanelWidget,
private Ui::QgsProcessingContextOptionsBase
560 QgsProcessingContextOptionsWidget( QWidget *parent
SIP_TRANSFERTHIS =
nullptr );
585 QString temporaryFolder();
590 int maximumThreads()
const;
The Qgis class provides global constants for use throughout the application.
DistanceUnit
Units of distance.
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
ProcessingLogLevel
Logging level for algorithms to use when pushing feedback messages.
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.
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 pushFormattedMessage(const QString &html, const QString &text)
Pushes a pre-formatted message 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