QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsprocessingalgorithmdialogbase.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingalgorithmdialogbase.cpp
3  ------------------------------------
4  Date : November 2017
5  Copyright : (C) 2017 Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 #include "qgssettings.h"
18 #include "qgshelp.h"
19 #include "qgsmessagebar.h"
20 #include "qgsgui.h"
23 #include "qgstaskmanager.h"
25 #include "qgsstringutils.h"
26 #include <QToolButton>
27 #include <QDesktopServices>
28 #include <QScrollBar>
29 #include <QApplication>
30 #include <QClipboard>
31 #include <QFileDialog>
32 
33 
35 
36 void QgsProcessingAlgorithmDialogFeedback::setProgressText( const QString &text )
37 {
38  emit progressTextChanged( text );
39 }
40 
41 void QgsProcessingAlgorithmDialogFeedback::reportError( const QString &error, bool fatalError )
42 {
43  emit errorReported( error, fatalError );
44 }
45 
46 void QgsProcessingAlgorithmDialogFeedback::pushInfo( const QString &info )
47 {
48  emit infoPushed( info );
49 }
50 
51 void QgsProcessingAlgorithmDialogFeedback::pushCommandInfo( const QString &info )
52 {
53  emit commandInfoPushed( info );
54 }
55 
56 void QgsProcessingAlgorithmDialogFeedback::pushDebugInfo( const QString &info )
57 {
58  emit debugInfoPushed( info );
59 }
60 
61 void QgsProcessingAlgorithmDialogFeedback::pushConsoleInfo( const QString &info )
62 {
63  emit consoleInfoPushed( info );
64 }
65 
66 //
67 // QgsProcessingAlgorithmDialogBase
68 //
69 
70 QgsProcessingAlgorithmDialogBase::QgsProcessingAlgorithmDialogBase( QWidget *parent, Qt::WindowFlags flags )
71  : QDialog( parent, flags )
72 {
73  setupUi( this );
74 
75  //don't collapse parameters panel
76  splitter->setCollapsible( 0, false );
77 
78  // add collapse button to splitter
79  QSplitterHandle *splitterHandle = splitter->handle( 1 );
80  QVBoxLayout *handleLayout = new QVBoxLayout();
81  handleLayout->setContentsMargins( 0, 0, 0, 0 );
82  mButtonCollapse = new QToolButton( splitterHandle );
83  mButtonCollapse->setAutoRaise( true );
84  mButtonCollapse->setFixedSize( 12, 12 );
85  mButtonCollapse->setCursor( Qt::ArrowCursor );
86  handleLayout->addWidget( mButtonCollapse );
87  handleLayout->addStretch();
88  splitterHandle->setLayout( handleLayout );
89 
91 
92  QgsSettings settings;
93  splitter->restoreState( settings.value( QStringLiteral( "/Processing/dialogBaseSplitter" ), QByteArray() ).toByteArray() );
94  mSplitterState = splitter->saveState();
95  splitterChanged( 0, 0 );
96 
97  connect( mButtonBox, &QDialogButtonBox::rejected, this, &QgsProcessingAlgorithmDialogBase::closeClicked );
98  connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsProcessingAlgorithmDialogBase::runAlgorithm );
99 
100  // Rename OK button to Run
101  mButtonRun = mButtonBox->button( QDialogButtonBox::Ok );
102  mButtonRun->setText( tr( "Run" ) );
103 
104  buttonCancel->setEnabled( false );
105  mButtonClose = mButtonBox->button( QDialogButtonBox::Close );
106 
107  connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsProcessingAlgorithmDialogBase::openHelp );
108  connect( mButtonCollapse, &QToolButton::clicked, this, &QgsProcessingAlgorithmDialogBase::toggleCollapsed );
109  connect( splitter, &QSplitter::splitterMoved, this, &QgsProcessingAlgorithmDialogBase::splitterChanged );
110 
111  connect( mButtonSaveLog, &QToolButton::clicked, this, &QgsProcessingAlgorithmDialogBase::saveLog );
112  connect( mButtonCopyLog, &QToolButton::clicked, this, &QgsProcessingAlgorithmDialogBase::copyLogToClipboard );
113  connect( mButtonClearLog, &QToolButton::clicked, this, &QgsProcessingAlgorithmDialogBase::clearLog );
114 
115  mMessageBar = new QgsMessageBar();
116  mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
117  verticalLayout->insertWidget( 0, mMessageBar );
118 
119  connect( QgsApplication::taskManager(), &QgsTaskManager::taskTriggered, this, &QgsProcessingAlgorithmDialogBase::taskTriggered );
120 }
121 
122 QgsProcessingAlgorithmDialogBase::~QgsProcessingAlgorithmDialogBase() = default;
123 
124 void QgsProcessingAlgorithmDialogBase::setAlgorithm( QgsProcessingAlgorithm *algorithm )
125 {
126  mAlgorithm.reset( algorithm );
127  QString title;
129  {
130  title = QgsStringUtils::capitalize( mAlgorithm->displayName(), QgsStringUtils::TitleCase );
131  }
132  else
133  {
134  title = mAlgorithm->displayName();
135  }
136  setWindowTitle( title );
137 
138  QString algHelp = formatHelp( algorithm );
139  if ( algHelp.isEmpty() )
140  textShortHelp->hide();
141  else
142  {
143  textShortHelp->document()->setDefaultStyleSheet( QStringLiteral( ".summary { margin-left: 10px; margin-right: 10px; }\n"
144  "h2 { color: #555555; padding-bottom: 15px; }\n"
145  "a { text - decoration: none; color: #3498db; font-weight: bold; }\n"
146  "p { color: #666666; }\n"
147  "b { color: #333333; }\n"
148  "dl dd { margin - bottom: 5px; }" ) );
149  textShortHelp->setHtml( algHelp );
150  connect( textShortHelp, &QTextBrowser::anchorClicked, this, &QgsProcessingAlgorithmDialogBase::linkClicked );
151  }
152 
153  if ( algorithm->helpUrl().isEmpty() && algorithm->provider()->helpId().isEmpty() )
154  {
155  mButtonBox->removeButton( mButtonBox->button( QDialogButtonBox::Help ) );
156  }
157 }
158 
160 {
161  return mAlgorithm.get();
162 }
163 
164 void QgsProcessingAlgorithmDialogBase::setMainWidget( QWidget *widget )
165 {
166  if ( mMainWidget )
167  {
168  mMainWidget->deleteLater();
169  }
170 
171  mMainWidget = widget;
172  mTabWidget->widget( 0 )->layout()->addWidget( mMainWidget );
173 }
174 
175 QWidget *QgsProcessingAlgorithmDialogBase::mainWidget()
176 {
177  return mMainWidget;
178 }
179 
180 QVariantMap QgsProcessingAlgorithmDialogBase::getParameterValues() const
181 {
182  return QVariantMap();
183 }
184 
185 void QgsProcessingAlgorithmDialogBase::saveLogToFile( const QString &path, const LogFormat format )
186 {
187  QFile logFile( path );
188  if ( !logFile.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
189  {
190  return;
191  }
192  QTextStream fout( &logFile );
193 
194  switch ( format )
195  {
196  case FormatPlainText:
197  fout << txtLog->toPlainText();
198  break;
199 
200  case FormatHtml:
201  fout << txtLog->toHtml();
202  break;
203  }
204 }
205 
206 QgsProcessingFeedback *QgsProcessingAlgorithmDialogBase::createFeedback()
207 {
208  auto feedback = qgis::make_unique< QgsProcessingAlgorithmDialogFeedback >();
209  connect( feedback.get(), &QgsProcessingFeedback::progressChanged, this, &QgsProcessingAlgorithmDialogBase::setPercentage );
210  connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::commandInfoPushed, this, &QgsProcessingAlgorithmDialogBase::pushCommandInfo );
211  connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::consoleInfoPushed, this, &QgsProcessingAlgorithmDialogBase::pushConsoleInfo );
212  connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::debugInfoPushed, this, &QgsProcessingAlgorithmDialogBase::pushDebugInfo );
213  connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::errorReported, this, &QgsProcessingAlgorithmDialogBase::reportError );
214  connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::infoPushed, this, &QgsProcessingAlgorithmDialogBase::pushInfo );
215  connect( feedback.get(), &QgsProcessingAlgorithmDialogFeedback::progressTextChanged, this, &QgsProcessingAlgorithmDialogBase::setProgressText );
216  connect( buttonCancel, &QPushButton::clicked, feedback.get(), &QgsProcessingFeedback::cancel );
217  return feedback.release();
218 }
219 
220 QDialogButtonBox *QgsProcessingAlgorithmDialogBase::buttonBox()
221 {
222  return mButtonBox;
223 }
224 
225 QTabWidget *QgsProcessingAlgorithmDialogBase::tabWidget()
226 {
227  return mTabWidget;
228 }
229 
230 void QgsProcessingAlgorithmDialogBase::showLog()
231 {
232  mTabWidget->setCurrentIndex( 1 );
233 }
234 
235 QPushButton *QgsProcessingAlgorithmDialogBase::runButton()
236 {
237  return mButtonRun;
238 }
239 
240 QPushButton *QgsProcessingAlgorithmDialogBase::cancelButton()
241 {
242  return buttonCancel;
243 }
244 
245 void QgsProcessingAlgorithmDialogBase::clearProgress()
246 {
247  progressBar->setMaximum( 0 );
248 }
249 
250 void QgsProcessingAlgorithmDialogBase::setExecuted( bool executed )
251 {
252  mExecuted = executed;
253 }
254 
255 void QgsProcessingAlgorithmDialogBase::setResults( const QVariantMap &results )
256 {
257  mResults = results;
258 }
259 
260 void QgsProcessingAlgorithmDialogBase::finished( bool, const QVariantMap &, QgsProcessingContext &, QgsProcessingFeedback * )
261 {
262 
263 }
264 
265 void QgsProcessingAlgorithmDialogBase::openHelp()
266 {
267  QUrl algHelp = mAlgorithm->helpUrl();
268  if ( algHelp.isEmpty() )
269  {
270  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() ) ) );
271  }
272 
273  if ( !algHelp.isEmpty() )
274  QDesktopServices::openUrl( algHelp );
275 }
276 
277 void QgsProcessingAlgorithmDialogBase::toggleCollapsed()
278 {
279  if ( mHelpCollapsed )
280  {
281  splitter->restoreState( mSplitterState );
282  mButtonCollapse->setArrowType( Qt::RightArrow );
283  }
284  else
285  {
286  mSplitterState = splitter->saveState();
287  splitter->setSizes( QList<int>() << 1 << 0 );
288  mButtonCollapse->setArrowType( Qt::LeftArrow );
289  }
290  mHelpCollapsed = !mHelpCollapsed;
291 }
292 
293 void QgsProcessingAlgorithmDialogBase::splitterChanged( int, int )
294 {
295  if ( splitter->sizes().at( 1 ) == 0 )
296  {
297  mHelpCollapsed = true;
298  mButtonCollapse->setArrowType( Qt::LeftArrow );
299  }
300  else
301  {
302  mHelpCollapsed = false;
303  mButtonCollapse->setArrowType( Qt::RightArrow );
304  }
305 }
306 
307 void QgsProcessingAlgorithmDialogBase::linkClicked( const QUrl &url )
308 {
309  QDesktopServices::openUrl( url.toString() );
310 }
311 
312 void QgsProcessingAlgorithmDialogBase::algExecuted( bool successful, const QVariantMap & )
313 {
314  mAlgorithmTask = nullptr;
315 
316  if ( !successful )
317  {
318  // show dialog to display errors
319  show();
320  raise();
321  setWindowState( ( windowState() & ~Qt::WindowMinimized ) | Qt::WindowActive );
322  activateWindow();
323  showLog();
324  }
325  else
326  {
327  // delete dialog if closed
328  if ( !isVisible() )
329  {
330  deleteLater();
331  }
332  }
333 }
334 
335 void QgsProcessingAlgorithmDialogBase::taskTriggered( QgsTask *task )
336 {
337  if ( task == mAlgorithmTask )
338  {
339  show();
340  raise();
341  setWindowState( ( windowState() & ~Qt::WindowMinimized ) | Qt::WindowActive );
342  activateWindow();
343  showLog();
344  }
345 }
346 
347 void QgsProcessingAlgorithmDialogBase::closeClicked()
348 {
349  reject();
350  close();
351 }
352 
353 void QgsProcessingAlgorithmDialogBase::reportError( const QString &error, bool fatalError )
354 {
355  setInfo( error, true );
356  if ( fatalError )
357  resetGui();
358  showLog();
359  processEvents();
360 }
361 
362 void QgsProcessingAlgorithmDialogBase::pushInfo( const QString &info )
363 {
364  setInfo( info );
365  processEvents();
366 }
367 
368 void QgsProcessingAlgorithmDialogBase::pushCommandInfo( const QString &command )
369 {
370  txtLog->append( QStringLiteral( "<code>%1<code>" ).arg( formatStringForLog( command.toHtmlEscaped() ) ) );
371  scrollToBottomOfLog();
372  processEvents();
373 }
374 
375 void QgsProcessingAlgorithmDialogBase::pushDebugInfo( const QString &message )
376 {
377  txtLog->append( QStringLiteral( "<span style=\"color:blue\">%1</span>" ).arg( formatStringForLog( message.toHtmlEscaped() ) ) );
378  scrollToBottomOfLog();
379  processEvents();
380 }
381 
382 void QgsProcessingAlgorithmDialogBase::pushConsoleInfo( const QString &info )
383 {
384  txtLog->append( QStringLiteral( "<code style=\"color:#777\">%1</code>" ).arg( formatStringForLog( info.toHtmlEscaped() ) ) );
385  scrollToBottomOfLog();
386  processEvents();
387 }
388 
389 QDialog *QgsProcessingAlgorithmDialogBase::createProgressDialog()
390 {
391  QgsProcessingAlgorithmProgressDialog *dialog = new QgsProcessingAlgorithmProgressDialog( this );
392  dialog->setWindowModality( Qt::ApplicationModal );
393  dialog->setWindowTitle( windowTitle() );
394  dialog->setGeometry( geometry() ); // match size/position to this dialog
395  connect( progressBar, &QProgressBar::valueChanged, dialog->progressBar(), &QProgressBar::setValue );
396  connect( dialog->cancelButton(), &QPushButton::clicked, buttonCancel, &QPushButton::click );
397  dialog->logTextEdit()->setHtml( txtLog->toHtml() );
398  connect( txtLog, &QTextEdit::textChanged, dialog, [this, dialog]()
399  {
400  dialog->logTextEdit()->setHtml( txtLog->toHtml() );
401  QScrollBar *sb = dialog->logTextEdit()->verticalScrollBar();
402  sb->setValue( sb->maximum() );
403  } );
404  return dialog;
405 }
406 
407 void QgsProcessingAlgorithmDialogBase::clearLog()
408 {
409  txtLog->clear();
410 }
411 
412 void QgsProcessingAlgorithmDialogBase::saveLog()
413 {
414  QgsSettings settings;
415  QString lastUsedDir = settings.value( QStringLiteral( "/Processing/lastUsedLogDirectory" ), QDir::homePath() ).toString();
416 
417  QString filter;
418  const QString txtExt = tr( "Text files" ) + QStringLiteral( " (*.txt *.TXT)" );
419  const QString htmlExt = tr( "HTML files" ) + QStringLiteral( " (*.html *.HTML)" );
420 
421  QString path = QFileDialog::getSaveFileName( this, tr( "Save Log to File" ), lastUsedDir, txtExt + ";;" + htmlExt, &filter );
422  if ( path.isEmpty() )
423  {
424  return;
425  }
426 
427  settings.setValue( QStringLiteral( "/Processing/lastUsedLogDirectory" ), QFileInfo( path ).path() );
428 
429  LogFormat format = FormatPlainText;
430  if ( filter == htmlExt )
431  {
432  format = FormatHtml;
433  }
434  saveLogToFile( path, format );
435 }
436 
437 void QgsProcessingAlgorithmDialogBase::copyLogToClipboard()
438 {
439  QMimeData *m = new QMimeData();
440  m->setText( txtLog->toPlainText() );
441  m->setHtml( txtLog->toHtml() );
442  QClipboard *cb = QApplication::clipboard();
443 
444 #ifdef Q_OS_LINUX
445  cb->setMimeData( m, QClipboard::Selection );
446 #endif
447  cb->setMimeData( m, QClipboard::Clipboard );
448 }
449 
450 void QgsProcessingAlgorithmDialogBase::closeEvent( QCloseEvent *e )
451 {
452  QDialog::closeEvent( e );
453 
454  if ( !mAlgorithmTask )
455  {
456  // when running a background task, the dialog is kept around and deleted only when the task
457  // completes. But if not running a task, we auto cleanup (later - gotta give callers a chance
458  // to retrieve results and execution status).
459  deleteLater();
460  }
461 }
462 
463 void QgsProcessingAlgorithmDialogBase::runAlgorithm()
464 {
465 
466 }
467 
468 void QgsProcessingAlgorithmDialogBase::setPercentage( double percent )
469 {
470  // delay setting maximum progress value until we know algorithm reports progress
471  if ( progressBar->maximum() == 0 )
472  progressBar->setMaximum( 100 );
473  progressBar->setValue( percent );
474  processEvents();
475 }
476 
477 void QgsProcessingAlgorithmDialogBase::setProgressText( const QString &text )
478 {
479  lblProgress->setText( text );
480  setInfo( text, false );
481  scrollToBottomOfLog();
482  processEvents();
483 }
484 
485 QString QgsProcessingAlgorithmDialogBase::formatHelp( QgsProcessingAlgorithm *algorithm )
486 {
487  QString text = algorithm->shortHelpString();
488  if ( !text.isEmpty() )
489  {
490  QStringList paragraphs = text.split( '\n' );
491  QString help;
492  for ( const QString &paragraph : paragraphs )
493  {
494  help += QStringLiteral( "<p>%1</p>" ).arg( paragraph );
495  }
496  return QStringLiteral( "<h2>%1</h2>%2" ).arg( algorithm->displayName(), help );
497  }
498  else if ( !algorithm->shortDescription().isEmpty() )
499  {
500  return QStringLiteral( "<h2>%1</h2><p>%2</p>" ).arg( algorithm->displayName(), algorithm->shortDescription() );
501  }
502  else
503  return QString();
504 }
505 
506 void QgsProcessingAlgorithmDialogBase::processEvents()
507 {
508  if ( mAlgorithmTask )
509  {
510  // no need to call this - the algorithm is running in a thread.
511  // in fact, calling it causes a crash on Windows when the algorithm
512  // is running in a background thread... unfortunately we need something
513  // like this for non-threadable algorithms, otherwise there's no chance
514  // for users to hit cancel or see progress updates...
515  return;
516  }
517 
518  // So that we get a chance of hitting the Abort button
519 #ifdef Q_OS_LINUX
520  // For some reason on Windows hasPendingEvents() always return true,
521  // but one iteration is actually enough on Windows to get good interactivity
522  // whereas on Linux we must allow for far more iterations.
523  // For safety limit the number of iterations
524  int nIters = 0;
525  while ( QCoreApplication::hasPendingEvents() && ++nIters < 100 )
526 #endif
527  {
528  QCoreApplication::processEvents();
529  }
530 }
531 
532 void QgsProcessingAlgorithmDialogBase::scrollToBottomOfLog()
533 {
534  QScrollBar *sb = txtLog->verticalScrollBar();
535  sb->setValue( sb->maximum() );
536 }
537 
538 void QgsProcessingAlgorithmDialogBase::resetGui()
539 {
540  lblProgress->clear();
541  progressBar->setMaximum( 100 );
542  progressBar->setValue( 0 );
543  mButtonRun->setEnabled( true );
544  mButtonClose->setEnabled( true );
545 }
546 
547 QgsMessageBar *QgsProcessingAlgorithmDialogBase::messageBar()
548 {
549  return mMessageBar;
550 }
551 
552 void QgsProcessingAlgorithmDialogBase::hideShortHelp()
553 {
554  textShortHelp->setVisible( false );
555 }
556 
557 void QgsProcessingAlgorithmDialogBase::setCurrentTask( QgsProcessingAlgRunnerTask *task )
558 {
559  mAlgorithmTask = task;
560  connect( mAlgorithmTask, &QgsProcessingAlgRunnerTask::executed, this, &QgsProcessingAlgorithmDialogBase::algExecuted );
561  QgsApplication::taskManager()->addTask( mAlgorithmTask );
562 }
563 
564 QString QgsProcessingAlgorithmDialogBase::formatStringForLog( const QString &string )
565 {
566  QString s = string;
567  s.replace( '\n', QStringLiteral( "<br>" ) );
568  return s;
569 }
570 
571 void QgsProcessingAlgorithmDialogBase::setInfo( const QString &message, bool isError, bool escapeHtml )
572 {
573  if ( isError )
574  txtLog->append( QStringLiteral( "<span style=\"color:red\">%1</span>" ).arg( escapeHtml ? formatStringForLog( message.toHtmlEscaped() ) : formatStringForLog( message ) ) );
575  else if ( escapeHtml )
576  txtLog->append( formatStringForLog( message.toHtmlEscaped() ) );
577  else
578  txtLog->append( formatStringForLog( message ) );
579  scrollToBottomOfLog();
580  processEvents();
581 }
582 
583 //
584 // QgsProcessingAlgorithmProgressDialog
585 //
586 
587 QgsProcessingAlgorithmProgressDialog::QgsProcessingAlgorithmProgressDialog( QWidget *parent )
588  : QDialog( parent )
589 {
590  setupUi( this );
591 }
592 
593 QProgressBar *QgsProcessingAlgorithmProgressDialog::progressBar()
594 {
595  return mProgressBar;
596 }
597 
598 QPushButton *QgsProcessingAlgorithmProgressDialog::cancelButton()
599 {
600  return mButtonBox->button( QDialogButtonBox::Cancel );
601 }
602 
603 QTextEdit *QgsProcessingAlgorithmProgressDialog::logTextEdit()
604 {
605  return mTxtLog;
606 }
607 
608 void QgsProcessingAlgorithmProgressDialog::reject()
609 {
610 
611 }
612 
613 
614 
Base class for providing feedback from a processing algorithm.
void taskTriggered(QgsTask *task)
Emitted when a task is triggered.
void cancel()
Tells the internal routines that the current operation should be canceled. This should be run by the ...
Definition: qgsfeedback.h:85
This class is a composition of two QSettings instances:
Definition: qgssettings.h:58
Dialog titles should be title case.
Definition: qgsgui.h:147
Simple title case conversion - does not fully grammatically parse the text and uses simple rules only...
Algorithm&#39;s display name is a static literal string, and should not be translated or automatically fo...
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Abstract base class for processing algorithms.
virtual QString helpId() const
Returns the provider help id string, used for creating QgsHelp urls for algorithms belong to this pro...
static QUrl helpUrl(const QString &key)
Returns URI of the help topic for the given key.
Definition: qgshelp.cpp:40
static QgsTaskManager * taskManager()
Returns the application&#39;s task manager, used for managing application wide background task handling...
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
static QString capitalize(const QString &string, 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.
Abstract base class for long running background tasks.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
virtual Flags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users...
static QgsGui::HigFlags higFlags()
Returns the platform&#39;s HIG flags.
Definition: qgsgui.cpp:117
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
virtual QString shortDescription() const
Returns an optional translated short description of the algorithm.
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
virtual QString displayName() const =0
Returns the translated algorithm name, which should be used for any user-visible display of the algor...
virtual QString helpUrl() const
Returns a url pointing to the algorithm&#39;s help page.
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...
Definition: qgsgui.cpp:98
QgsTask task which runs a QgsProcessingAlgorithm in a background task.
Contains information about the context in which a processing algorithm is executed.
void executed(bool successful, const QVariantMap &results)
Emitted when the algorithm has finished execution.
virtual QString shortHelpString() const
Returns a localised short helper string for the algorithm.