30#include <QDesktopServices>
32#include <QApplication>
37#include <nlohmann/json.hpp>
42QgsProcessingAlgorithmDialogFeedback::QgsProcessingAlgorithmDialogFeedback()
46void QgsProcessingAlgorithmDialogFeedback::setProgressText(
const QString &text )
49 emit progressTextChanged( text );
52void QgsProcessingAlgorithmDialogFeedback::reportError(
const QString &error,
bool fatalError )
55 emit errorReported( error, fatalError );
58void QgsProcessingAlgorithmDialogFeedback::pushWarning(
const QString &warning )
61 emit warningPushed( warning );
64void QgsProcessingAlgorithmDialogFeedback::pushInfo(
const QString &info )
67 emit infoPushed( info );
70void QgsProcessingAlgorithmDialogFeedback::pushCommandInfo(
const QString &info )
73 emit commandInfoPushed( info );
76void QgsProcessingAlgorithmDialogFeedback::pushDebugInfo(
const QString &info )
79 emit debugInfoPushed( info );
82void QgsProcessingAlgorithmDialogFeedback::pushConsoleInfo(
const QString &info )
85 emit consoleInfoPushed( info );
92QgsProcessingAlgorithmDialogBase::QgsProcessingAlgorithmDialogBase( QWidget *parent, Qt::WindowFlags flags, DialogMode mode )
93 : QDialog( parent, flags )
99 splitter->setCollapsible( 0,
false );
102 QSplitterHandle *splitterHandle = splitter->handle( 1 );
103 QVBoxLayout *handleLayout =
new QVBoxLayout();
104 handleLayout->setContentsMargins( 0, 0, 0, 0 );
105 mButtonCollapse =
new QToolButton( splitterHandle );
106 mButtonCollapse->setAutoRaise(
true );
107 mButtonCollapse->setFixedSize( 12, 12 );
108 mButtonCollapse->setCursor( Qt::ArrowCursor );
109 handleLayout->addWidget( mButtonCollapse );
110 handleLayout->addStretch();
111 splitterHandle->setLayout( handleLayout );
116 splitter->restoreState( settings.
value( QStringLiteral(
"/Processing/dialogBaseSplitter" ), QByteArray() ).toByteArray() );
117 mSplitterState = splitter->saveState();
118 splitterChanged( 0, 0 );
121 mButtonRun = mButtonBox->button( QDialogButtonBox::Ok );
122 mButtonRun->setText( tr(
"Run" ) );
125 mButtonChangeParameters = mButtonBox->button( QDialogButtonBox::Yes );
126 mButtonChangeParameters->setText( tr(
"Change Parameters" ) );
128 buttonCancel->setEnabled(
false );
129 mButtonClose = mButtonBox->button( QDialogButtonBox::Close );
133 case DialogMode::Single:
135 mAdvancedButton =
new QPushButton( tr(
"Advanced" ) );
136 mAdvancedMenu =
new QMenu(
this );
137 mAdvancedButton->setMenu( mAdvancedMenu );
139 QAction *copyAsPythonCommand =
new QAction( tr(
"Copy as Python Command" ), mAdvancedMenu );
142 mAdvancedMenu->addAction( copyAsPythonCommand );
143 connect( copyAsPythonCommand, &QAction::triggered,
this, [
this]
151 const QString command = alg->asPythonCommand( createProcessingParameters(), *context );
152 QMimeData *m =
new QMimeData();
153 m->setText( command );
154 QClipboard *cb = QApplication::clipboard();
157 cb->setMimeData( m, QClipboard::Selection );
159 cb->setMimeData( m, QClipboard::Clipboard );
163 mCopyAsQgisProcessCommand =
new QAction( tr(
"Copy as qgis_process Command" ), mAdvancedMenu );
165 mAdvancedMenu->addAction( mCopyAsQgisProcessCommand );
167 connect( mCopyAsQgisProcessCommand, &QAction::triggered,
this, [
this]
176 const QString command = alg->asQgisProcessCommand( createProcessingParameters(), *context, ok );
179 mMessageBar->pushMessage( tr(
"Current settings cannot be specified as arguments to qgis_process (Pipe parameters as JSON to qgis_process instead)" ), Qgis::MessageLevel::Warning );
183 QMimeData *m =
new QMimeData();
184 m->setText( command );
185 QClipboard *cb = QApplication::clipboard();
188 cb->setMimeData( m, QClipboard::Selection );
190 cb->setMimeData( m, QClipboard::Clipboard );
195 mAdvancedMenu->addSeparator();
197 QAction *copyAsJson =
new QAction( tr(
"Copy as JSON" ), mAdvancedMenu );
200 mAdvancedMenu->addAction( copyAsJson );
201 connect( copyAsJson, &QAction::triggered,
this, [
this]
209 const QVariantMap properties = alg->asMap( createProcessingParameters(), *context );
212 QMimeData *m =
new QMimeData();
214 QClipboard *cb = QApplication::clipboard();
217 cb->setMimeData( m, QClipboard::Selection );
219 cb->setMimeData( m, QClipboard::Clipboard );
223 mPasteJsonAction =
new QAction( tr(
"Paste Settings" ), mAdvancedMenu );
226 mAdvancedMenu->addAction( mPasteJsonAction );
227 connect( mPasteJsonAction, &QAction::triggered,
this, [
this]
229 const QString text = QApplication::clipboard()->text();
230 if ( text.isEmpty() )
233 const QVariantMap parameterValues =
QgsJsonUtils::parseJson( text ).toMap().value( QStringLiteral(
"inputs" ) ).toMap();
234 if ( parameterValues.isEmpty() )
241 setParameters( preparedValues );
244 mButtonBox->addButton( mAdvancedButton, QDialogButtonBox::ResetRole );
248 case DialogMode::Batch:
254 connect( mAdvancedMenu, &QMenu::aboutToShow,
this, [ = ]
256 mCopyAsQgisProcessCommand->setEnabled(
algorithm()
258 mPasteJsonAction->setEnabled( !QApplication::clipboard()->text().isEmpty() );
262 connect( mButtonRun, &QPushButton::clicked,
this, &QgsProcessingAlgorithmDialogBase::runAlgorithm );
263 connect( mButtonChangeParameters, &QPushButton::clicked,
this, &QgsProcessingAlgorithmDialogBase::showParameters );
264 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QgsProcessingAlgorithmDialogBase::closeClicked );
265 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsProcessingAlgorithmDialogBase::openHelp );
266 connect( mButtonCollapse, &QToolButton::clicked,
this, &QgsProcessingAlgorithmDialogBase::toggleCollapsed );
267 connect( splitter, &QSplitter::splitterMoved,
this, &QgsProcessingAlgorithmDialogBase::splitterChanged );
269 connect( mButtonSaveLog, &QToolButton::clicked,
this, &QgsProcessingAlgorithmDialogBase::saveLog );
270 connect( mButtonCopyLog, &QToolButton::clicked,
this, &QgsProcessingAlgorithmDialogBase::copyLogToClipboard );
271 connect( mButtonClearLog, &QToolButton::clicked,
this, &QgsProcessingAlgorithmDialogBase::clearLog );
273 connect( mTabWidget, &QTabWidget::currentChanged,
this, &QgsProcessingAlgorithmDialogBase::mTabWidget_currentChanged );
276 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
277 verticalLayout->insertWidget( 0, mMessageBar );
282QgsProcessingAlgorithmDialogBase::~QgsProcessingAlgorithmDialogBase() =
default;
284void QgsProcessingAlgorithmDialogBase::setParameters(
const QVariantMap & )
297 title = mAlgorithm->displayName();
299 setWindowTitle( title );
301 const QString algHelp = formatHelp(
algorithm );
302 if ( algHelp.isEmpty() )
303 textShortHelp->hide();
306 textShortHelp->document()->setDefaultStyleSheet( QStringLiteral(
".summary { margin-left: 10px; margin-right: 10px; }\n"
307 "h2 { color: #555555; padding-bottom: 15px; }\n"
308 "a { text - decoration: none; color: #3498db; font-weight: bold; }\n"
309 "p { color: #666666; }\n"
310 "b { color: #333333; }\n"
311 "dl dd { margin - bottom: 5px; }" ) );
312 textShortHelp->setHtml( algHelp );
313 connect( textShortHelp, &QTextBrowser::anchorClicked,
this, &QgsProcessingAlgorithmDialogBase::linkClicked );
314 textShortHelp->show();
319 mButtonBox->removeButton( mButtonBox->button( QDialogButtonBox::Help ) );
323 if ( !warning.isEmpty() )
325 mMessageBar->pushMessage( warning, Qgis::MessageLevel::Warning );
331 return mAlgorithm.get();
334void QgsProcessingAlgorithmDialogBase::setMainWidget(
QgsPanelWidget *widget )
338 mMainWidget->deleteLater();
341 mPanelStack->setMainPanel( widget );
344 mMainWidget = widget;
353void QgsProcessingAlgorithmDialogBase::saveLogToFile(
const QString &path,
const LogFormat format )
355 QFile logFile( path );
356 if ( !logFile.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
360 QTextStream fout( &logFile );
364 case FormatPlainText:
365 fout << txtLog->toPlainText();
369 fout << txtLog->toHtml();
376 auto feedback = std::make_unique< QgsProcessingAlgorithmDialogFeedback >();
378 connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::commandInfoPushed,
this, &QgsProcessingAlgorithmDialogBase::pushCommandInfo );
379 connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::consoleInfoPushed,
this, &QgsProcessingAlgorithmDialogBase::pushConsoleInfo );
380 connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::debugInfoPushed,
this, &QgsProcessingAlgorithmDialogBase::pushDebugInfo );
381 connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::errorReported,
this, &QgsProcessingAlgorithmDialogBase::reportError );
382 connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::warningPushed,
this, &QgsProcessingAlgorithmDialogBase::pushWarning );
383 connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::infoPushed,
this, &QgsProcessingAlgorithmDialogBase::pushInfo );
384 connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::progressTextChanged,
this, &QgsProcessingAlgorithmDialogBase::setProgressText );
386 return feedback.release();
389QDialogButtonBox *QgsProcessingAlgorithmDialogBase::buttonBox()
394QTabWidget *QgsProcessingAlgorithmDialogBase::tabWidget()
399void QgsProcessingAlgorithmDialogBase::showLog()
401 mTabWidget->setCurrentIndex( 1 );
404void QgsProcessingAlgorithmDialogBase::showParameters()
406 mTabWidget->setCurrentIndex( 0 );
409QPushButton *QgsProcessingAlgorithmDialogBase::runButton()
414QPushButton *QgsProcessingAlgorithmDialogBase::cancelButton()
419QPushButton *QgsProcessingAlgorithmDialogBase::changeParametersButton()
421 return mButtonChangeParameters;
424void QgsProcessingAlgorithmDialogBase::clearProgress()
426 progressBar->setMaximum( 0 );
429void QgsProcessingAlgorithmDialogBase::setExecuted(
bool executed )
431 mExecuted = executed;
434void QgsProcessingAlgorithmDialogBase::setExecutedAnyResult(
bool executedAnyResult )
436 mExecutedAnyResult = executedAnyResult;
439void QgsProcessingAlgorithmDialogBase::setResults(
const QVariantMap &results )
449void QgsProcessingAlgorithmDialogBase::openHelp()
451 QUrl algHelp = mAlgorithm->helpUrl();
452 if ( algHelp.isEmpty() && mAlgorithm->provider() )
454 algHelp =
QgsHelp::helpUrl( QStringLiteral(
"processing_algs/%1/%2.html#%3" ).arg( mAlgorithm->provider()->helpId(), mAlgorithm->groupId(), QStringLiteral(
"%1%2" ).arg( mAlgorithm->provider()->helpId() ).arg( mAlgorithm->name() ) ) );
457 if ( !algHelp.isEmpty() )
458 QDesktopServices::openUrl( algHelp );
461void QgsProcessingAlgorithmDialogBase::toggleCollapsed()
463 if ( mHelpCollapsed )
465 splitter->restoreState( mSplitterState );
466 mButtonCollapse->setArrowType( Qt::RightArrow );
470 mSplitterState = splitter->saveState();
471 splitter->setSizes( QList<int>() << 1 << 0 );
472 mButtonCollapse->setArrowType( Qt::LeftArrow );
474 mHelpCollapsed = !mHelpCollapsed;
477void QgsProcessingAlgorithmDialogBase::splitterChanged(
int,
int )
479 if ( splitter->sizes().at( 1 ) == 0 )
481 mHelpCollapsed =
true;
482 mButtonCollapse->setArrowType( Qt::LeftArrow );
486 mHelpCollapsed =
false;
487 mButtonCollapse->setArrowType( Qt::RightArrow );
491void QgsProcessingAlgorithmDialogBase::mTabWidget_currentChanged(
int )
493 updateRunButtonVisibility();
496void QgsProcessingAlgorithmDialogBase::linkClicked(
const QUrl &url )
498 QDesktopServices::openUrl( url.toString() );
501void QgsProcessingAlgorithmDialogBase::algExecuted(
bool successful,
const QVariantMap & )
503 mAlgorithmTask =
nullptr;
510 setWindowState( ( windowState() & ~Qt::WindowMinimized ) | Qt::WindowActive );
517 if ( isFinalized() && !isVisible() )
524void QgsProcessingAlgorithmDialogBase::taskTriggered(
QgsTask *task )
526 if ( task == mAlgorithmTask )
530 setWindowState( ( windowState() & ~Qt::WindowMinimized ) | Qt::WindowActive );
536void QgsProcessingAlgorithmDialogBase::closeClicked()
552void QgsProcessingAlgorithmDialogBase::reportError(
const QString &error,
bool fatalError )
554 setInfo( error,
true );
561void QgsProcessingAlgorithmDialogBase::pushWarning(
const QString &warning )
563 setInfo( warning,
false,
true,
true );
567void QgsProcessingAlgorithmDialogBase::pushInfo(
const QString &info )
573void QgsProcessingAlgorithmDialogBase::pushCommandInfo(
const QString &command )
575 txtLog->append( QStringLiteral(
"<code>%1<code>" ).arg( formatStringForLog( command.toHtmlEscaped() ) ) );
576 scrollToBottomOfLog();
580void QgsProcessingAlgorithmDialogBase::pushDebugInfo(
const QString &message )
582 txtLog->append( QStringLiteral(
"<span style=\"color:#777\">%1</span>" ).arg( formatStringForLog( message.toHtmlEscaped() ) ) );
583 scrollToBottomOfLog();
587void QgsProcessingAlgorithmDialogBase::pushConsoleInfo(
const QString &info )
589 txtLog->append( QStringLiteral(
"<code style=\"color:#777\">%1</code>" ).arg( formatStringForLog( info.toHtmlEscaped() ) ) );
590 scrollToBottomOfLog();
594QDialog *QgsProcessingAlgorithmDialogBase::createProgressDialog()
596 QgsProcessingAlgorithmProgressDialog *dialog =
new QgsProcessingAlgorithmProgressDialog(
this );
597 dialog->setWindowModality( Qt::ApplicationModal );
598 dialog->setWindowTitle( windowTitle() );
599 dialog->setGeometry( geometry() );
600 connect( progressBar, &QProgressBar::valueChanged, dialog->progressBar(), &QProgressBar::setValue );
601 connect( dialog->cancelButton(), &QPushButton::clicked, buttonCancel, &QPushButton::click );
602 dialog->logTextEdit()->setHtml( txtLog->toHtml() );
603 connect( txtLog, &QTextEdit::textChanged, dialog, [
this, dialog]()
605 dialog->logTextEdit()->setHtml( txtLog->toHtml() );
606 QScrollBar *sb = dialog->logTextEdit()->verticalScrollBar();
607 sb->setValue( sb->maximum() );
612void QgsProcessingAlgorithmDialogBase::clearLog()
617void QgsProcessingAlgorithmDialogBase::saveLog()
620 const QString lastUsedDir = settings.
value( QStringLiteral(
"/Processing/lastUsedLogDirectory" ), QDir::homePath() ).toString();
623 const QString txtExt = tr(
"Text files" ) + QStringLiteral(
" (*.txt *.TXT)" );
624 const QString htmlExt = tr(
"HTML files" ) + QStringLiteral(
" (*.html *.HTML)" );
626 const QString path = QFileDialog::getSaveFileName(
this, tr(
"Save Log to File" ), lastUsedDir, txtExt +
";;" + htmlExt, &filter );
627 if ( path.isEmpty() )
632 settings.
setValue( QStringLiteral(
"/Processing/lastUsedLogDirectory" ), QFileInfo( path ).path() );
634 LogFormat format = FormatPlainText;
635 if ( filter == htmlExt )
639 saveLogToFile( path, format );
642void QgsProcessingAlgorithmDialogBase::copyLogToClipboard()
644 QMimeData *m =
new QMimeData();
645 m->setText( txtLog->toPlainText() );
646 m->setHtml( txtLog->toHtml() );
647 QClipboard *cb = QApplication::clipboard();
650 cb->setMimeData( m, QClipboard::Selection );
652 cb->setMimeData( m, QClipboard::Clipboard );
655void QgsProcessingAlgorithmDialogBase::closeEvent( QCloseEvent *e )
657 if ( !mHelpCollapsed )
660 settings.
setValue( QStringLiteral(
"/Processing/dialogBaseSplitter" ), splitter->saveState() );
663 QDialog::closeEvent( e );
665 if ( !mAlgorithmTask && isFinalized() )
674void QgsProcessingAlgorithmDialogBase::runAlgorithm()
679void QgsProcessingAlgorithmDialogBase::setPercentage(
double percent )
682 if ( progressBar->maximum() == 0 )
683 progressBar->setMaximum( 100 );
684 progressBar->setValue( percent );
688void QgsProcessingAlgorithmDialogBase::setProgressText(
const QString &text )
690 lblProgress->setText( text );
691 setInfo( text,
false );
692 scrollToBottomOfLog();
699 if ( !text.isEmpty() )
701 const QStringList paragraphs = text.split(
'\n' );
703 for (
const QString ¶graph : paragraphs )
705 help += QStringLiteral(
"<p>%1</p>" ).arg( paragraph );
717void QgsProcessingAlgorithmDialogBase::processEvents()
719 if ( mAlgorithmTask )
735 while ( ++nIters < 100 )
738 QCoreApplication::processEvents();
742void QgsProcessingAlgorithmDialogBase::scrollToBottomOfLog()
744 QScrollBar *sb = txtLog->verticalScrollBar();
745 sb->setValue( sb->maximum() );
748void QgsProcessingAlgorithmDialogBase::resetGui()
750 lblProgress->clear();
751 progressBar->setMaximum( 100 );
752 progressBar->setValue( 0 );
753 mButtonRun->setEnabled(
true );
754 mButtonChangeParameters->setEnabled(
true );
755 mButtonClose->setEnabled(
true );
758 mMainWidget->setEnabled(
true );
760 updateRunButtonVisibility();
761 resetAdditionalGui();
764void QgsProcessingAlgorithmDialogBase::updateRunButtonVisibility()
767 const bool runButtonVisible = mTabWidget->currentIndex() == 0;
768 mButtonRun->setVisible( runButtonVisible );
769 mButtonChangeParameters->setVisible( !runButtonVisible && mExecutedAnyResult && mButtonChangeParameters->isEnabled() );
772void QgsProcessingAlgorithmDialogBase::resetAdditionalGui()
777void QgsProcessingAlgorithmDialogBase::blockControlsWhileRunning()
779 mButtonRun->setEnabled(
false );
780 mButtonChangeParameters->setEnabled(
false );
783 mMainWidget->setEnabled(
false );
785 blockAdditionalControlsWhileRunning();
788void QgsProcessingAlgorithmDialogBase::blockAdditionalControlsWhileRunning()
798void QgsProcessingAlgorithmDialogBase::hideShortHelp()
800 textShortHelp->setVisible(
false );
805 mAlgorithmTask = task;
810QString QgsProcessingAlgorithmDialogBase::formatStringForLog(
const QString &
string )
813 s.replace(
'\n', QLatin1String(
"<br>" ) );
817bool QgsProcessingAlgorithmDialogBase::isFinalized()
822void QgsProcessingAlgorithmDialogBase::setInfo(
const QString &message,
bool isError,
bool escapeHtml,
bool isWarning )
824 constexpr int MESSAGE_COUNT_LIMIT = 10000;
826 if ( mMessageLoggedCount == MESSAGE_COUNT_LIMIT )
828 ++mMessageLoggedCount;
832 if ( mMessageLoggedCount == MESSAGE_COUNT_LIMIT )
833 txtLog->append( QStringLiteral(
"<span style=\"color:red\">%1</span>" ).arg( tr(
"Message log truncated" ) ) );
834 else if ( isError || isWarning )
835 txtLog->append( QStringLiteral(
"<span style=\"color:%1\">%2</span>" ).arg( isError ? QStringLiteral(
"red" ) : QStringLiteral(
"#b85a20" ), escapeHtml ? formatStringForLog( message.toHtmlEscaped() ) : formatStringForLog( message ) ) );
836 else if ( escapeHtml )
837 txtLog->append( QStringLiteral(
"<span>%1</span" ).arg( formatStringForLog( message.toHtmlEscaped() ) ) );
839 txtLog->append( QStringLiteral(
"<span>%1</span>" ).arg( formatStringForLog( message ) ) );
840 scrollToBottomOfLog();
844void QgsProcessingAlgorithmDialogBase::reject()
846 if ( !mAlgorithmTask && isFinalized() )
848 setAttribute( Qt::WA_DeleteOnClose );
857QgsProcessingAlgorithmProgressDialog::QgsProcessingAlgorithmProgressDialog( QWidget *parent )
863QProgressBar *QgsProcessingAlgorithmProgressDialog::progressBar()
868QPushButton *QgsProcessingAlgorithmProgressDialog::cancelButton()
870 return mButtonBox->button( QDialogButtonBox::Cancel );
873QTextEdit *QgsProcessingAlgorithmProgressDialog::logTextEdit()
878void QgsProcessingAlgorithmProgressDialog::reject()
@ TitleCase
Simple title case conversion - does not fully grammatically parse the text and uses simple rules only...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
void cancel()
Tells the internal routines that the current operation should be canceled. This should be run by the ...
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
@ HigDialogTitleIsTitleCase
Dialog titles should be title case.
static QgsGui::HigFlags higFlags()
Returns the platform's HIG flags.
static QUrl helpUrl(const QString &key)
Returns URI of the help topic for the given key.
static QVariant parseJson(const std::string &jsonString)
Converts JSON jsonString to a QVariant, in case of parsing error an invalid QVariant is returned and ...
static json jsonFromVariant(const QVariant &v)
Converts a QVariant v to a json object.
A bar for displaying non-blocking messages to the user.
QgsTask task which runs a QgsProcessingAlgorithm in a background task.
void executed(bool successful, const QVariantMap &results)
Emitted when the algorithm has finished execution.
Abstract base class for processing algorithms.
virtual QString helpUrl() const
Returns a url pointing to the algorithm's help page.
virtual QString shortHelpString() const
Returns a localised short helper string for the algorithm.
virtual QString shortDescription() const
Returns an optional translated short description of the algorithm.
@ FlagNotAvailableInStandaloneTool
Algorithm should not be available from the standalone "qgis_process" tool. Used to flag algorithms wh...
@ FlagDisplayNameIsLiteral
Algorithm's display name is a static literal string, and should not be translated or automatically fo...
virtual QString displayName() const =0
Returns the translated algorithm name, which should be used for any user-visible display of the algor...
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
Contains information about the context in which a processing algorithm is executed.
LogLevel
Logging level for algorithms to use when pushing feedback messages.
QgsProcessingAlgorithm::Flags flags() const override
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
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.
virtual QString helpId() const
Returns the provider help id string, used for creating QgsHelp urls for algorithms belong to this pro...
virtual QString warningMessage() const
Returns an optional warning message to show users when running algorithms from this provider.
static QVariantMap preprocessQgisProcessParameters(const QVariantMap ¶meters, bool &ok, QString &error)
Pre-processes a set of parameter values for the qgis_process command.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static QString capitalize(const QString &string, Qgis::Capitalization capitalization)
Converts a string by applying capitalization rules to the string.
long addTask(QgsTask *task, int priority=0)
Adds a task to the manager.
void taskTriggered(QgsTask *task)
Emitted when a task is triggered.
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