16#ifndef QGSPROCESSINGALGORITHMDIALOGBASE_H
17#define QGSPROCESSINGALGORITHMDIALOGBASE_H
21#include "ui_qgsprocessingalgorithmdialogbase.h"
22#include "ui_qgsprocessingalgorithmprogressdialogbase.h"
31class QgsProcessingAlgorithmDialogBase;
53 QgsProcessingAlgorithmDialogFeedback();
57 void progressTextChanged(
const QString &text );
58 void errorReported(
const QString &text,
bool fatalError );
59 void warningPushed(
const QString &text );
60 void infoPushed(
const QString &text );
61 void commandInfoPushed(
const QString &text );
62 void debugInfoPushed(
const QString &text );
63 void consoleInfoPushed(
const QString &text );
68 void reportError(
const QString &error,
bool fatalError )
override;
70 void pushInfo(
const QString &info )
override;
105 enum class DialogMode :
int
110 Q_ENUM( QgsProcessingAlgorithmDialogBase::DialogMode )
115 QgsProcessingAlgorithmDialogBase( QWidget *parent
SIP_TRANSFERTHIS =
nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), QgsProcessingAlgorithmDialogBase::DialogMode mode = QgsProcessingAlgorithmDialogBase::DialogMode::Single );
116 ~QgsProcessingAlgorithmDialogBase()
override;
155 bool wasExecuted()
const {
return mExecuted; }
162 QVariantMap results()
const {
return mResults; }
176 void saveLogToFile( const QString &path, LogFormat format = FormatPlainText );
199 virtual
void setParameters( const QVariantMap &values );
208 void reportError( const QString &error,
bool fatalError );
213 void pushWarning( const QString &warning );
218 void pushInfo( const QString &info );
223 void pushDebugInfo( const QString &message );
228 void pushCommandInfo( const QString &info );
233 void setPercentage(
double percent );
238 void setProgressText( const QString &text );
243 void pushConsoleInfo( const QString &info );
249 QDialog *createProgressDialog();
268 void copyLogToClipboard();
273 void showParameters();
275 void reject() override;
279 void closeEvent( QCloseEvent *e ) override;
284 QPushButton *runButton();
289 QPushButton *cancelButton();
294 QPushButton *changeParametersButton();
299 QDialogButtonBox *buttonBox();
304 QTabWidget *tabWidget();
309 void clearProgress();
316 void setExecuted(
bool executed );
321 void setExecutedAnyResult(
bool executedAnyResult );
328 void setResults( const QVariantMap &results );
333 void setInfo( const QString &message,
bool isError = false,
bool escapeHtml = true,
bool isWarning = false );
344 virtual
void resetAdditionalGui();
349 void updateRunButtonVisibility();
355 void blockControlsWhileRunning();
361 virtual
void blockAdditionalControlsWhileRunning();
371 void hideShortHelp();
384 static QString formatStringForLog( const QString &
string );
391 virtual
bool isFinalized();
400 void algorithmFinished(
bool successful, const QVariantMap &result );
412 virtual
void runAlgorithm();
419 virtual
void algExecuted(
bool successful, const QVariantMap &results );
424 void toggleCollapsed();
426 void splitterChanged(
int pos,
int index );
427 void mTabWidget_currentChanged(
int index );
428 void linkClicked( const QUrl &url );
429 void taskTriggered(
QgsTask *task );
434 DialogMode mMode = DialogMode::Single;
436 QPushButton *mButtonRun =
nullptr;
437 QPushButton *mButtonClose =
nullptr;
438 QPushButton *mButtonChangeParameters =
nullptr;
439 QByteArray mSplitterState;
440 QToolButton *mButtonCollapse =
nullptr;
442 QPushButton *mAdvancedButton =
nullptr;
443 QMenu *mAdvancedMenu =
nullptr;
444 QAction *mCopyAsQgisProcessCommand =
nullptr;
445 QAction *mPasteJsonAction =
nullptr;
447 bool mExecuted = false;
448 bool mExecutedAnyResult = false;
449 QVariantMap mResults;
454 bool mHelpCollapsed = false;
456 int mMessageLoggedCount = 0;
461 void scrollToBottomOfLog();
462 void processEvents();
474class QgsProcessingAlgorithmProgressDialog :
public QDialog,
private Ui::QgsProcessingProgressDialogBase
483 QgsProcessingAlgorithmProgressDialog( QWidget *parent =
nullptr );
488 QProgressBar *progressBar();
493 QPushButton *cancelButton();
498 QTextEdit *logTextEdit();
502 void reject()
override;
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 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.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
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