25 #include <QVBoxLayout> 30 #include <QDialogButtonBox> 31 #include <QMessageBox> 56 QVBoxLayout *vlayout =
new QVBoxLayout();
58 QLabel *label =
new QLabel( tr(
"Description" ) );
59 vlayout->addWidget( label );
60 mDescriptionLineEdit =
new QLineEdit();
61 vlayout->addWidget( mDescriptionLineEdit );
65 mDescriptionLineEdit->setText( definition->
description() );
68 if ( mDefinitionWidget )
69 vlayout->addWidget( mDefinitionWidget );
71 vlayout->addSpacing( 20 );
72 mRequiredCheckBox =
new QCheckBox( tr(
"Mandatory" ) );
76 mRequiredCheckBox->setChecked(
true );
77 vlayout->addWidget( mRequiredCheckBox );
79 mAdvancedCheckBox =
new QCheckBox( tr(
"Advanced" ) );
83 mAdvancedCheckBox->setChecked(
false );
84 vlayout->addWidget( mAdvancedCheckBox );
86 vlayout->addStretch();
92 std::unique_ptr< QgsProcessingParameterDefinition > param;
93 QgsProcessingParameterDefinition::Flags flags =
nullptr;
95 if ( !mRequiredCheckBox->isChecked() )
97 if ( mAdvancedCheckBox->isChecked() )
100 if ( mDefinitionWidget )
104 param.reset( mDefinitionWidget->
createParameter( name, mDescriptionLineEdit->text(), flags ) );
112 param->setDescription( mDescriptionLineEdit->text() );
113 param->setFlags( flags );
117 return param.release();
132 QVBoxLayout *vLayout =
new QVBoxLayout();
134 vLayout->addWidget( mWidget );
135 QDialogButtonBox *bbox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
137 connect( bbox, &QDialogButtonBox::rejected,
this, &QgsProcessingParameterDefinitionDialog::reject );
138 vLayout->addWidget( bbox );
139 setLayout( vLayout );
140 setWindowTitle( definition ? tr(
"%1 Parameter Definition" ).arg( definition->
description() )
142 tr(
"Parameter Definition" ) );
143 setObjectName( QStringLiteral(
"QgsProcessingParameterDefinitionDialog" ) );
154 if ( mWidget->mDescriptionLineEdit->text().isEmpty() )
156 QMessageBox::warning(
this, tr(
"Unable to define parameter" ),
157 tr(
"Invalid parameter name" ) );
static QgsProcessingGuiRegistry * processingGuiRegistry()
Returns the global processing gui registry, used for registering the GUI behavior of processing algor...
Parameter is an advanced parameter which should be hidden from users by default.
QgsProcessingParameterDefinitionDialog(const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition=nullptr, const QgsProcessingAlgorithm *algorithm=nullptr, QWidget *parent=nullptr)
Constructor for QgsProcessingParameterDefinitionDialog, for a parameter of the specified type...
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
static QgsGui * instance()
Returns a pointer to the singleton instance.
Abstract base class for processing algorithms.
QgsProcessingParameterDefinition * createParameter(const QString &name=QString()) const
Returns a new instance of a parameter definition, using the current settings defined in the dialog...
Flags flags() const
Returns any flags associated with the parameter.
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
Contains settings which reflect the context in which a Processing parameter widget is shown...
Base class for the definition of processing parameters.
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...
Contains information about the context in which a processing algorithm is executed.
QString description() const
Returns the description for the parameter.
QgsProcessingAbstractParameterDefinitionWidget * createParameterDefinitionWidget(const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition=nullptr, const QgsProcessingAlgorithm *algorithm=nullptr)
Creates a new parameter definition widget allowing for configuration of an instance of a specific par...
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers, algorithms, and various parameters and outputs.