16#ifndef QGSPROCESSINGALGORITHMDIALOGBASE_H
17#define QGSPROCESSINGALGORITHMDIALOGBASE_H
19#include "ui_qgsprocessingalgorithmdialogbase.h"
20#include "ui_qgsprocessingalgorithmprogressdialogbase.h"
21#include "ui_qgsprocessingcontextoptionsbase.h"
35class QgsProcessingAlgorithmDialogBase;
36class 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;
107 enum class DialogMode :
int
112 Q_ENUM( QgsProcessingAlgorithmDialogBase::DialogMode )
117 QgsProcessingAlgorithmDialogBase(
118 QWidget *parent
SIP_TRANSFERTHIS =
nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), QgsProcessingAlgorithmDialogBase::DialogMode mode = QgsProcessingAlgorithmDialogBase::DialogMode::Single
120 ~QgsProcessingAlgorithmDialogBase()
override;
141 void setMainWidget( QgsPanelWidget *widget
SIP_TRANSFER );
147 QgsPanelWidget *mainWidget();
159 bool wasExecuted()
const {
return mExecuted; }
166 QVariantMap results()
const {
return mResults; }
172 QgsProcessingFeedback *createFeedback()
SIP_FACTORY;
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;
291 void closeEvent( QCloseEvent *e ) override;
296 QPushButton *runButton();
301 QPushButton *cancelButton();
306 QPushButton *changeParametersButton();
311 QDialogButtonBox *buttonBox();
316 QTabWidget *tabWidget();
321 void clearProgress();
328 void setExecuted(
bool executed );
333 void setExecutedAnyResult(
bool executedAnyResult );
340 void setResults( const QVariantMap &results );
345 void setInfo( const QString &message,
bool isError = false,
bool escapeHtml = true,
bool isWarning = false );
356 virtual
void resetAdditionalGui();
361 void updateRunButtonVisibility();
367 void blockControlsWhileRunning();
373 virtual
void blockAdditionalControlsWhileRunning();
378 QgsMessageBar *messageBar();
383 void hideShortHelp();
389 void setCurrentTask( QgsProcessingAlgRunnerTask *task
SIP_TRANSFER );
395 static QString formatStringForLog( const QString &
string );
402 virtual
bool isFinalized();
411 void applyContextOverrides( QgsProcessingContext *context );
422 void algorithmAboutToRun( QgsProcessingContext *context );
429 void algorithmFinished(
bool successful, const QVariantMap &result );
436 virtual
void finished(
bool successful, const QVariantMap &result, QgsProcessingContext &context, QgsProcessingFeedback *feedback );
441 virtual
void runAlgorithm();
448 virtual
void algExecuted(
bool successful, const QVariantMap &results );
453 void toggleCollapsed();
455 void splitterChanged(
int pos,
int index );
456 void mTabWidget_currentChanged(
int index );
457 void linkClicked( const QUrl &url );
458 void taskTriggered( QgsTask *task );
460 void urlClicked( const QUrl &url );
463 DialogMode mMode = DialogMode::Single;
465 QPushButton *mButtonRun =
nullptr;
466 QPushButton *mButtonClose =
nullptr;
467 QPushButton *mButtonChangeParameters =
nullptr;
468 QByteArray mSplitterState;
469 QToolButton *mButtonCollapse =
nullptr;
470 QgsMessageBar *mMessageBar =
nullptr;
471 QPushButton *mAdvancedButton =
nullptr;
472 QMenu *mAdvancedMenu =
nullptr;
473 QAction *mCopyAsQgisProcessCommand =
nullptr;
474 QAction *mPasteJsonAction =
nullptr;
475 QAction *mContextSettingsAction =
nullptr;
477 bool mExecuted = false;
478 bool mExecutedAnyResult = false;
479 QVariantMap mResults;
480 QgsPanelWidget *mMainWidget =
nullptr;
481 std::unique_ptr<QgsProcessingAlgorithm> mAlgorithm;
482 QgsProcessingAlgRunnerTask *mAlgorithmTask =
nullptr;
484 bool mHelpCollapsed = false;
486 int mMessageLoggedCount = 0;
488 Qgis::ProcessingLogLevel mLogLevel = Qgis::ProcessingLogLevel::DefaultLevel;
490 QPointer<QgsProcessingContextOptionsWidget> mContextOptionsWidget;
491 bool mOverrideDefaultContextSettings = false;
492 Qgis::InvalidGeometryCheck mGeometryCheck = Qgis::InvalidGeometryCheck::AbortOnInvalid;
493 Qgis::DistanceUnit mDistanceUnits = Qgis::DistanceUnit::Unknown;
494 Qgis::AreaUnit mAreaUnits = Qgis::AreaUnit::Unknown;
495 QString mTemporaryFolderOverride;
496 int mMaximumThreads = QThread::idealThreadCount();
498 QString formatHelp( QgsProcessingAlgorithm *
algorithm );
499 void scrollToBottomOfLog();
500 void processEvents();
510class QgsProcessingAlgorithmProgressDialog :
public QDialog,
private Ui::QgsProcessingProgressDialogBase
518 QgsProcessingAlgorithmProgressDialog( QWidget *parent =
nullptr );
523 QProgressBar *progressBar();
528 QPushButton *cancelButton();
533 QTextEdit *logTextEdit();
537 void reject()
override;
546class GUI_EXPORT QgsProcessingContextOptionsWidget :
public QgsPanelWidget,
private Ui::QgsProcessingContextOptionsBase
554 QgsProcessingContextOptionsWidget( QWidget *parent
SIP_TRANSFERTHIS =
nullptr );
559 void setFromContext(
const QgsProcessingContext *context );
579 QString temporaryFolder();
584 int maximumThreads()
const;
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.
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