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;
55 QgsProcessingAlgorithmDialogFeedback();
59 void progressTextChanged(
const QString &text );
60 void errorReported(
const QString &text,
bool fatalError );
61 void warningPushed(
const QString &text );
62 void infoPushed(
const QString &text );
63 void commandInfoPushed(
const QString &text );
64 void debugInfoPushed(
const QString &text );
65 void consoleInfoPushed(
const QString &text );
66 void formattedMessagePushed(
const QString &html );
71 void reportError(
const QString &error,
bool fatalError )
override;
73 void pushInfo(
const QString &info )
override;
106 enum class DialogMode :
int
111 Q_ENUM( QgsProcessingAlgorithmDialogBase::DialogMode )
116 QgsProcessingAlgorithmDialogBase( QWidget *parent
SIP_TRANSFERTHIS =
nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), QgsProcessingAlgorithmDialogBase::DialogMode mode = QgsProcessingAlgorithmDialogBase::DialogMode::Single );
117 ~QgsProcessingAlgorithmDialogBase()
override;
156 bool wasExecuted()
const {
return mExecuted; }
163 QVariantMap results()
const {
return mResults; }
177 void saveLogToFile( const QString &path, LogFormat format = FormatPlainText );
185 Qgis::ProcessingLogLevel logLevel() const;
193 void setLogLevel(
Qgis::ProcessingLogLevel level );
200 virtual
void setParameters( const QVariantMap &values );
209 void reportError( const QString &error,
bool fatalError );
214 void pushWarning( const QString &warning );
219 void pushInfo( const QString &info );
228 void pushFormattedMessage( const QString &html );
233 void pushDebugInfo( const QString &message );
238 void pushCommandInfo( const QString &info );
243 void setPercentage(
double percent );
248 void setProgressText( const QString &text );
253 void pushConsoleInfo( const QString &info );
259 QDialog *createProgressDialog();
278 void copyLogToClipboard();
283 void showParameters();
285 void reject() override;
288 void closeEvent( QCloseEvent *e ) override;
293 QPushButton *runButton();
298 QPushButton *cancelButton();
303 QPushButton *changeParametersButton();
308 QDialogButtonBox *buttonBox();
313 QTabWidget *tabWidget();
318 void clearProgress();
325 void setExecuted(
bool executed );
330 void setExecutedAnyResult(
bool executedAnyResult );
337 void setResults( const QVariantMap &results );
342 void setInfo( const QString &message,
bool isError = false,
bool escapeHtml = true,
bool isWarning = false );
353 virtual
void resetAdditionalGui();
358 void updateRunButtonVisibility();
364 void blockControlsWhileRunning();
370 virtual
void blockAdditionalControlsWhileRunning();
380 void hideShortHelp();
392 static QString formatStringForLog( const QString &
string );
399 virtual
bool isFinalized();
426 void algorithmFinished(
bool successful, const QVariantMap &result );
438 virtual
void runAlgorithm();
445 virtual
void algExecuted(
bool successful, const QVariantMap &results );
450 void toggleCollapsed();
452 void splitterChanged(
int pos,
int index );
453 void mTabWidget_currentChanged(
int index );
454 void linkClicked( const QUrl &url );
455 void taskTriggered(
QgsTask *task );
457 void urlClicked( const QUrl &url );
460 DialogMode mMode = DialogMode::Single;
462 QPushButton *mButtonRun =
nullptr;
463 QPushButton *mButtonClose =
nullptr;
464 QPushButton *mButtonChangeParameters =
nullptr;
465 QByteArray mSplitterState;
466 QToolButton *mButtonCollapse =
nullptr;
468 QPushButton *mAdvancedButton =
nullptr;
469 QMenu *mAdvancedMenu =
nullptr;
470 QAction *mCopyAsQgisProcessCommand =
nullptr;
471 QAction *mPasteJsonAction =
nullptr;
472 QAction *mContextSettingsAction =
nullptr;
474 bool mExecuted = false;
475 bool mExecutedAnyResult = false;
476 QVariantMap mResults;
481 bool mHelpCollapsed = false;
483 int mMessageLoggedCount = 0;
485 Qgis::ProcessingLogLevel mLogLevel =
Qgis::ProcessingLogLevel::DefaultLevel;
487 QPointer<QgsProcessingContextOptionsWidget> mContextOptionsWidget;
488 bool mOverrideDefaultContextSettings = false;
489 Qgis::InvalidGeometryCheck mGeometryCheck =
Qgis::InvalidGeometryCheck::AbortOnInvalid;
490 Qgis::DistanceUnit mDistanceUnits =
Qgis::DistanceUnit::Unknown;
491 Qgis::AreaUnit mAreaUnits =
Qgis::AreaUnit::Unknown;
492 QString mTemporaryFolderOverride;
493 int mMaximumThreads = QThread::idealThreadCount();
496 void scrollToBottomOfLog();
497 void processEvents();
507class QgsProcessingAlgorithmProgressDialog :
public QDialog,
private Ui::QgsProcessingProgressDialogBase
515 QgsProcessingAlgorithmProgressDialog( QWidget *parent =
nullptr );
520 QProgressBar *progressBar();
525 QPushButton *cancelButton();
530 QTextEdit *logTextEdit();
534 void reject()
override;
543class GUI_EXPORT QgsProcessingContextOptionsWidget :
public QgsPanelWidget,
private Ui::QgsProcessingContextOptionsBase
551 QgsProcessingContextOptionsWidget( QWidget *parent
SIP_TRANSFERTHIS =
nullptr );
576 QString temporaryFolder();
581 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