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