QGIS API Documentation 4.3.0-Master (d57cc4a041c)
Loading...
Searching...
No Matches
qgsmodelchildalgorithmwidgets.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelchildalgorithmwidgets.h
3 ----------------------------------------
4 begin : August 2026
5 copyright : (C) 2026 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18
19#ifndef QGSPROCESSINGMODELCHILDALGORITHMNWIDGETS_H
20#define QGSPROCESSINGMODELCHILDALGORITHMNWIDGETS_H
21
22#include <memory>
23
24#include "qgis_gui.h"
26#include "qgspanelwidget.h"
28
29#include <QDialog>
30
31#define SIP_NO_FILE
32
34class QgsProcessingModelAlgorithm;
36class QgsProcessingModelChildAlgorithm;
37class QgsProcessingModelOutput;
38class QLineEdit;
39class QgsMessageBar;
42class QgsModelChildDependenciesWidget;
44class QTabWidget;
46class QTextEdit;
47class QgsColorButton;
48class QDialogButtonBox;
49
50
60{
61 Q_OBJECT
62
63 public:
68 const QgsProcessingAlgorithm *childAlgorithm,
69 QgsProcessingModelAlgorithm *model,
70 QgsProcessingContext &context,
71 const QString &childId = QString(),
72 const QVariantMap &configuration = QVariantMap(),
73 QWidget *parent = nullptr,
74 QWidget *dialog = nullptr
75 );
76
78
82 const QgsProcessingAlgorithm *algorithm() const;
83
87 std::unique_ptr< QgsProcessingModelChildAlgorithm > createAlgorithm();
88
90
97
102
103 private:
104 void setupUi();
105 void emitChangedSignal();
106
107 std::unique_ptr< QgsProcessingAlgorithm > mAlgorithm;
108 QgsProcessingModelAlgorithm *mModel = nullptr;
109 QString mChildId;
110 QVariantMap mConfiguration;
111 QgsProcessingContext &mContext;
112 QWidget *mDialog = nullptr;
113
114 QMap< QString, QgsProcessingModelOutput > mPreviousOutputDefinitions;
115 int mBlockChangesSignal = 0;
116
117 QLineEdit *mDescriptionBox = nullptr;
118 QgsMessageBar *mMessageBar = nullptr;
119 QgsProcessingAlgorithmConfigurationWidget *mAlgorithmItem = nullptr;
120 QMap< QString, QgsProcessingModelerParameterWidget * > mWrappers;
121 QgsModelChildDependenciesWidget *mDependenciesPanel = nullptr;
122
124};
125
135{
136 Q_OBJECT
137
138 public:
143 const QgsProcessingAlgorithm *childAlgorithm,
144 QgsProcessingModelAlgorithm *model,
145 QgsProcessingContext &context,
146 const QString &childId = QString(),
147 const QVariantMap &configuration = QVariantMap(),
148 QWidget *parent = nullptr,
149 QWidget *dialog = nullptr
150 );
151
153
157 const QgsProcessingAlgorithm *algorithm() const;
158
164 void setComments( const QString &text );
165
171 QString comments() const;
172
178 void setCommentColor( const QColor &color );
179
185 QColor commentColor() const;
186
190 void switchToCommentTab();
191
198
203
207 std::unique_ptr< QgsProcessingModelChildAlgorithm > createAlgorithm();
208
209 private:
210 void setupUi();
211
212 QTabWidget *mTabWidget = nullptr;
213 QgsPanelWidgetStack *mPanelWidgetStack = nullptr;
214 QgsProcessingModelerParametersPanelWidget *mParametersPanel = nullptr;
215 QTextEdit *mCommentEdit = nullptr;
216 QgsColorButton *mCommentColorButton = nullptr;
217
219};
220
227class GUI_EXPORT QgsProcessingModelerParametersDialog : public QDialog
228{
229 Q_OBJECT
230
231 public:
236 const QgsProcessingAlgorithm *childAlgorithm,
237 QgsProcessingModelAlgorithm *model,
238 QgsProcessingContext &context,
239 const QString &childId = QString(),
240 const QVariantMap &configuration = QVariantMap(),
241 QWidget *parent = nullptr
242 );
243
245
249 const QgsProcessingAlgorithm *algorithm() const;
250
256 void setComments( const QString &comments );
257
263 QString comments() const;
264
270 void setCommentColor( const QColor &color );
271
277 QColor commentColor() const;
278
282 void switchToCommentTab();
283
290
295
299 std::unique_ptr< QgsProcessingModelChildAlgorithm > createAlgorithm();
300
301 private slots:
302 void okPressed();
303 void openHelp();
304
305 private:
306 QgsProcessingModelerParametersWidget *mWidget = nullptr;
307 QDialogButtonBox *mButtonBox = nullptr;
308};
309
310
311#endif // QGSPROCESSINGMODELCHILDALGORITHMNWIDGETS_H
A cross platform button subclass for selecting colors.
A bar for displaying non-blocking messages to the user.
A stack widget to manage multiple overlapping stacked panels.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
A configuration widget for processing algorithms allows providing additional configuration options di...
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
virtual QgsProcessingContext * processingContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return a Proc...
Contains information about the context in which a processing algorithm is executed.
QgsProcessingModelConfigWidget(QWidget *parent=nullptr)
Constructor for QgsProcessingModelConfigWidget().
A widget for customising the value of Processing algorithm parameters inside a Processing model.
void setCommentColor(const QColor &color)
Sets the algorithm's comment color.
QgsProcessingModelerParametersDialog(const QgsProcessingAlgorithm *childAlgorithm, QgsProcessingModelAlgorithm *model, QgsProcessingContext &context, const QString &childId=QString(), const QVariantMap &configuration=QVariantMap(), QWidget *parent=nullptr)
Constructor for QgsProcessingModelerParametersDialog.
QString comments() const
Returns the algorithm's comments.
std::unique_ptr< QgsProcessingModelChildAlgorithm > createAlgorithm()
Creates the child algorithm instance, populated with the current dialog parameter values and comments...
void setStateFromChildAlgorithm()
Sets widget state from the existing child algorithm definition in the model.
void setWidgetContext(const QgsProcessingParameterWidgetContext &context)
Sets the context in which the dialog is shown, e.g., the parent model algorithm, a linked map canvas,...
void setComments(const QString &comments)
Sets the algorithm's comments.
void switchToCommentTab()
Focuses the dialog on the comment editing tab.
QColor commentColor() const
Returns the algorithm's comment color.
A panel widget displaying the configuration for a child algorithm in a Processing model.
std::unique_ptr< QgsProcessingModelChildAlgorithm > createAlgorithm()
Creates the child algorithm instance populated with current widget values.
void setStateFromChildAlgorithm()
Sets widget state from the existing child algorithm definition in the model.
QgsProcessingModelerParametersPanelWidget(const QgsProcessingAlgorithm *childAlgorithm, QgsProcessingModelAlgorithm *model, QgsProcessingContext &context, const QString &childId=QString(), const QVariantMap &configuration=QVariantMap(), QWidget *parent=nullptr, QWidget *dialog=nullptr)
Constructor for QgsProcessingModelerParametersPanelWidget.
void setWidgetContext(const QgsProcessingParameterWidgetContext &context)
Sets the context in which the panel is shown, e.g., the parent model algorithm, a linked map canvas,...
A panel config widget combining parameter settings and comments for a child algorithm in a Processing...
void setCommentColor(const QColor &color)
Sets the comment's color.
void setWidgetContext(const QgsProcessingParameterWidgetContext &context)
Sets the context in which the panel is shown, e.g., the parent model algorithm, a linked map canvas,...
void setComments(const QString &text)
Sets the comment text.
QString comments() const
Returns the comment text.
std::unique_ptr< QgsProcessingModelChildAlgorithm > createAlgorithm()
Creates the child algorithm instance, populated with the current widget parameter values and comments...
void switchToCommentTab()
Focuses the widget on the comment editing tab.
QColor commentColor() const
Returns the comment's color.
void setStateFromChildAlgorithm()
Sets widget state from the existing child algorithm definition in the model.
QgsProcessingModelerParametersWidget(const QgsProcessingAlgorithm *childAlgorithm, QgsProcessingModelAlgorithm *model, QgsProcessingContext &context, const QString &childId=QString(), const QVariantMap &configuration=QVariantMap(), QWidget *parent=nullptr, QWidget *dialog=nullptr)
Constructor for QgsProcessingModelerParametersWidget.
Contains settings which reflect the context in which a Processing parameter widget is shown.
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