20 #include "processing/models/qgsprocessingmodelalgorithm.h"    50 #include <QToolButton>    52 #include <QHBoxLayout>    53 #include <QVBoxLayout>    57 #include <QPlainTextEdit>    58 #include <QRadioButton>    59 #include <QButtonGroup>    72   QVBoxLayout *vlayout = 
new QVBoxLayout();
    73   vlayout->setMargin( 0 );
    74   vlayout->setContentsMargins( 0, 0, 0, 0 );
    76   mDefaultCheckBox = 
new QCheckBox( tr( 
"Checked" ) );
    80     mDefaultCheckBox->setChecked( 
false );
    81   vlayout->addWidget( mDefaultCheckBox );
    85 QgsProcessingParameterDefinition *QgsProcessingBooleanParameterDefinitionWidget::createParameter( 
const QString &name, 
const QString &description, QgsProcessingParameterDefinition::Flags flags )
 const    87   auto param = qgis::make_unique< QgsProcessingParameterBoolean >( name, description, mDefaultCheckBox->isChecked() );
    89   return param.release();
    99 QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
   105       QString description = parameterDefinition()->description();
   107         description = QObject::tr( 
"%1 [optional]" ).arg( description );
   109       mCheckBox = 
new QCheckBox( description );
   110       mCheckBox->setToolTip( parameterDefinition()->toolTip() );
   112       connect( mCheckBox, &QCheckBox::toggled, 
this, [ = ]
   114         emit widgetValueHasChanged( 
this );
   122       mComboBox = 
new QComboBox();
   123       mComboBox->addItem( tr( 
"Yes" ), 
true );
   124       mComboBox->addItem( tr( 
"No" ), 
false );
   125       mComboBox->setToolTip( parameterDefinition()->toolTip() );
   127       connect( mComboBox, qgis::overload< int>::of( &QComboBox::currentIndexChanged ), 
this, [ = ]
   129         emit widgetValueHasChanged( 
this );
   138 QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
   147 void QgsProcessingBooleanWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
   154       mCheckBox->setChecked( v );
   162       mComboBox->setCurrentIndex( mComboBox->findData( v ) );
   168 QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
 const   173       return mCheckBox->isChecked();
   177       return mComboBox->currentData();
   182 QStringList QgsProcessingBooleanWidgetWrapper::compatibleParameterTypes()
 const   200 QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes()
 const   211 QList<int> QgsProcessingBooleanWidgetWrapper::compatibleDataTypes()
 const   213   return QList< int >();
   216 QString QgsProcessingBooleanWidgetWrapper::parameterType()
 const   223   return new QgsProcessingBooleanWidgetWrapper( parameter, type );
   228   return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition, algorithm );
   242 QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
   245   mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
   254     emit widgetValueHasChanged( 
this );
   262       return mProjectionSelectionWidget;
   267       QWidget *w = 
new QWidget();
   268       w->setToolTip( parameterDefinition()->toolTip() );
   270       QVBoxLayout *vl = 
new QVBoxLayout();
   272       vl->setContentsMargins( 0, 0, 0, 0 );
   275       mUseProjectCrsCheckBox = 
new QCheckBox( tr( 
"Use project CRS" ) );
   276       mUseProjectCrsCheckBox->setToolTip( tr( 
"Always use the current project CRS when running the model" ) );
   277       vl->addWidget( mUseProjectCrsCheckBox );
   278       connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
   279       connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, 
this, [ = ]
   281         emit widgetValueHasChanged( 
this );
   284       vl->addWidget( mProjectionSelectionWidget );
   292 void QgsProcessingCrsWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
   294   if ( mUseProjectCrsCheckBox )
   296     if ( value.toString().compare( QLatin1String( 
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
   298       mUseProjectCrsCheckBox->setChecked( 
true );
   303       mUseProjectCrsCheckBox->setChecked( 
false );
   308   if ( mProjectionSelectionWidget )
   309     mProjectionSelectionWidget->setCrs( v );
   312 QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
 const   314   if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
   315     return QStringLiteral( 
"ProjectCrs" );
   316   else if ( mProjectionSelectionWidget )
   317     return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
   322 QStringList QgsProcessingCrsWidgetWrapper::compatibleParameterTypes()
 const   334 QStringList QgsProcessingCrsWidgetWrapper::compatibleOutputTypes()
 const   342 QList<int> QgsProcessingCrsWidgetWrapper::compatibleDataTypes()
 const   344   return QList< int >();
   347 QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
 const   349   return tr( 
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
   352 QString QgsProcessingCrsWidgetWrapper::parameterType()
 const   359   return new QgsProcessingCrsWidgetWrapper( parameter, type );
   372   QVBoxLayout *vlayout = 
new QVBoxLayout();
   373   vlayout->setMargin( 0 );
   374   vlayout->setContentsMargins( 0, 0, 0, 0 );
   376   vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
   378   mDefaultLineEdit = 
new QLineEdit();
   381   vlayout->addWidget( mDefaultLineEdit );
   383   mMultiLineCheckBox = 
new QCheckBox( tr( 
"Multiline input" ) );
   385     mMultiLineCheckBox->setChecked( stringParam->multiLine() );
   386   vlayout->addWidget( mMultiLineCheckBox );
   388   setLayout( vlayout );
   391 QgsProcessingParameterDefinition *QgsProcessingStringParameterDefinitionWidget::createParameter( 
const QString &name, 
const QString &description, QgsProcessingParameterDefinition::Flags flags )
 const   393   auto param = qgis::make_unique< QgsProcessingParameterString >( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
   395   return param.release();
   406 QWidget *QgsProcessingStringWidgetWrapper::createWidget()
   413       if ( static_cast< const QgsProcessingParameterString * >( parameterDefinition() )->multiLine() )
   415         mPlainTextEdit = 
new QPlainTextEdit();
   416         mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
   418         connect( mPlainTextEdit, &QPlainTextEdit::textChanged, 
this, [ = ]
   420           emit widgetValueHasChanged( 
this );
   422         return mPlainTextEdit;
   426         mLineEdit = 
new QLineEdit();
   427         mLineEdit->setToolTip( parameterDefinition()->toolTip() );
   429         connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
   431           emit widgetValueHasChanged( 
this );
   439       mLineEdit = 
new QLineEdit();
   440       mLineEdit->setToolTip( parameterDefinition()->toolTip() );
   442       connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
   444         emit widgetValueHasChanged( 
this );
   452 void QgsProcessingStringWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
   456     mLineEdit->setText( v );
   457   if ( mPlainTextEdit )
   458     mPlainTextEdit->setPlainText( v );
   461 QVariant QgsProcessingStringWidgetWrapper::widgetValue()
 const   464     return mLineEdit->text();
   465   else if ( mPlainTextEdit )
   466     return mPlainTextEdit->toPlainText();
   471 QStringList QgsProcessingStringWidgetWrapper::compatibleParameterTypes()
 const   485 QStringList QgsProcessingStringWidgetWrapper::compatibleOutputTypes()
 const   492 QList<int> QgsProcessingStringWidgetWrapper::compatibleDataTypes()
 const   494   return QList< int >();
   497 QString QgsProcessingStringWidgetWrapper::parameterType()
 const   504   return new QgsProcessingStringWidgetWrapper( parameter, type );
   509   return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition, algorithm );
   524 QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
   532       mAuthConfigSelect = 
new QgsAuthConfigSelect();
   533       mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
   537         emit widgetValueHasChanged( 
this );
   539       return mAuthConfigSelect;
   545 void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
   548   if ( mAuthConfigSelect )
   549     mAuthConfigSelect->setConfigId( v );
   552 QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
 const   554   if ( mAuthConfigSelect )
   555     return mAuthConfigSelect->configId();
   560 QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleParameterTypes()
 const   568 QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleOutputTypes()
 const   573 QList<int> QgsProcessingAuthConfigWidgetWrapper::compatibleDataTypes()
 const   575   return QList< int >();
   578 QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
 const   585   return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
   598 QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
   601   const QVariantMap metadata = numberDef->
metadata();
   602   const int decimals = metadata.value( QStringLiteral( 
"widget_wrapper" ) ).toMap().value( QStringLiteral( 
"decimals" ), 6 ).toInt();
   610       QAbstractSpinBox *spinBox = 
nullptr;
   615           mDoubleSpinBox->setExpressionsEnabled( 
true );
   616           mDoubleSpinBox->setDecimals( decimals );
   622             double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
   623             singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
   624             mDoubleSpinBox->setSingleStep( singleStep );
   627           spinBox = mDoubleSpinBox;
   632           mSpinBox->setExpressionsEnabled( 
true );
   636       spinBox->setToolTip( parameterDefinition()->toolTip() );
   638       double max = 999999999;
   643       double min = -999999999;
   648       if ( mDoubleSpinBox )
   650         mDoubleSpinBox->setMinimum( min );
   651         mDoubleSpinBox->setMaximum( max );
   655         mSpinBox->setMinimum( static_cast< int >( min ) );
   656         mSpinBox->setMaximum( static_cast< int >( max ) );
   661         mAllowingNull = 
true;
   662         if ( mDoubleSpinBox )
   664           mDoubleSpinBox->setShowClearButton( 
true );
   665           const double min = mDoubleSpinBox->minimum() - 1;
   666           mDoubleSpinBox->setMinimum( min );
   667           mDoubleSpinBox->setValue( min );
   671           mSpinBox->setShowClearButton( 
true );
   672           const int min = mSpinBox->minimum() - 1;
   673           mSpinBox->setMinimum( min );
   674           mSpinBox->setValue( min );
   676         spinBox->setSpecialValueText( tr( 
"Not set" ) );
   684           if ( mDoubleSpinBox )
   686             double defaultVal = numberDef->
defaultValue().toDouble( &ok );
   688               mDoubleSpinBox->setClearValue( defaultVal );
   694               mSpinBox->setClearValue( intVal );
   700           if ( mDoubleSpinBox )
   701             mDoubleSpinBox->setClearValue( numberDef->
minimum() );
   703             mSpinBox->setClearValue( static_cast< int >( numberDef->
minimum() ) );
   708           if ( mDoubleSpinBox )
   710             mDoubleSpinBox->setValue( 0 );
   711             mDoubleSpinBox->setClearValue( 0 );
   715             mSpinBox->setValue( 0 );
   716             mSpinBox->setClearValue( 0 );
   721       if ( mDoubleSpinBox )
   722         connect( mDoubleSpinBox, qgis::overload<double>::of( &QgsDoubleSpinBox::valueChanged ), 
this, [ = ] { emit widgetValueHasChanged( 
this ); } );
   724         connect( mSpinBox, qgis::overload<int>::of( &QgsSpinBox::valueChanged ), 
this, [ = ] { emit widgetValueHasChanged( 
this ); } );
   732 void QgsProcessingNumericWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
   734   if ( mDoubleSpinBox )
   736     if ( mAllowingNull && !value.isValid() )
   737       mDoubleSpinBox->clear();
   741       mDoubleSpinBox->setValue( v );
   746     if ( mAllowingNull && !value.isValid() )
   751       mSpinBox->setValue( v );
   756 QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
 const   758   if ( mDoubleSpinBox )
   760     if ( mAllowingNull && 
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
   763       return mDoubleSpinBox->value();
   767     if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
   770       return mSpinBox->value();
   776 QStringList QgsProcessingNumericWidgetWrapper::compatibleParameterTypes()
 const   785 QStringList QgsProcessingNumericWidgetWrapper::compatibleOutputTypes()
 const   791 QList<int> QgsProcessingNumericWidgetWrapper::compatibleDataTypes()
 const   793   return QList< int >();
   796 double QgsProcessingNumericWidgetWrapper::calculateStep( 
const double minimum, 
const double maximum )
   798   const double valueRange = maximum - minimum;
   799   if ( valueRange <= 1.0 )
   801     const double step = valueRange / 10.0;
   803     return qgsRound( step, -std::floor( std::log( step ) ) );
   811 QString QgsProcessingNumericWidgetWrapper::parameterType()
 const   818   return new QgsProcessingNumericWidgetWrapper( parameter, type );
   826   : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
   831 QString QgsProcessingDistanceWidgetWrapper::parameterType()
 const   838   return new QgsProcessingDistanceWidgetWrapper( parameter, type );
   841 QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
   845   QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
   850       mLabel = 
new QLabel();
   851       mUnitsCombo = 
new QComboBox();
   859 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)   860       const int labelMargin = 
static_cast< int >( std::round( mUnitsCombo->fontMetrics().width( 
'X' ) ) );
   862       const int labelMargin = 
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance( 
'X' ) ) );
   864       QHBoxLayout *layout = 
new QHBoxLayout();
   865       layout->addWidget( spin, 1 );
   866       layout->insertSpacing( 1, labelMargin / 2 );
   867       layout->insertWidget( 2, mLabel );
   868       layout->insertWidget( 3, mUnitsCombo );
   873       mWarningLabel = 
new QWidget();
   874       QHBoxLayout *warningLayout = 
new QHBoxLayout();
   875       warningLayout->setMargin( 0 );
   876       warningLayout->setContentsMargins( 0, 0, 0, 0 );
   877       QLabel *warning = 
new QLabel();
   879       const int size = 
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
   880       warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
   881       warning->setToolTip( tr( 
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
   882       warningLayout->insertSpacing( 0, labelMargin / 2 );
   883       warningLayout->insertWidget( 1, warning );
   884       mWarningLabel->setLayout( warningLayout );
   885       layout->insertWidget( 4, mWarningLabel );
   887       QWidget *w = 
new QWidget();
   888       layout->setMargin( 0 );
   889       layout->setContentsMargins( 0, 0, 0, 0 );
   890       w->setLayout( layout );
   905 void QgsProcessingDistanceWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
   907   QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
   914         if ( wrapper->parameterDefinition()->name() == 
static_cast< const QgsProcessingParameterDistance * 
>( parameterDefinition() )->parentParameterName() )
   916           setUnitParameterValue( wrapper->parameterValue() );
   919             setUnitParameterValue( wrapper->parameterValue() );
   933 void QgsProcessingDistanceWidgetWrapper::setUnitParameterValue( 
const QVariant &value )
   939   std::unique_ptr< QgsProcessingContext > tmpContext;
   940   if ( mProcessingContextGenerator )
   941     context = mProcessingContextGenerator->processingContext();
   945     tmpContext = qgis::make_unique< QgsProcessingContext >();
   946     context = tmpContext.get();
   968     mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( units ) );
   976 QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
 const   978   const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
   979   if ( val.type() == QVariant::Double && mUnitsCombo && mUnitsCombo->isVisible() )
   995   : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
  1000 QString QgsProcessingScaleWidgetWrapper::parameterType()
 const  1007   return new QgsProcessingScaleWidgetWrapper( parameter, type );
  1010 QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
  1022         mScaleWidget->setAllowNull( 
true );
  1024       mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
  1025       mScaleWidget->setShowCurrentScaleButton( 
true );
  1027       mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
  1030         emit widgetValueHasChanged( 
this );
  1032       return mScaleWidget;
  1041     mScaleWidget->setMapCanvas( context.
mapCanvas() );
  1046 QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
 const  1048   return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
  1051 void QgsProcessingScaleWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  1055     if ( mScaleWidget->allowNull() && !value.isValid() )
  1056       mScaleWidget->setNull();
  1060       mScaleWidget->setScale( v );
  1076 QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
  1085       QHBoxLayout *layout = 
new QHBoxLayout();
  1090       mMinSpinBox->setExpressionsEnabled( 
true );
  1091       mMinSpinBox->setShowClearButton( 
false );
  1092       mMaxSpinBox->setExpressionsEnabled( 
true );
  1093       mMaxSpinBox->setShowClearButton( 
false );
  1095       QLabel *minLabel = 
new QLabel( tr( 
"Min" ) );
  1096       layout->addWidget( minLabel );
  1097       layout->addWidget( mMinSpinBox, 1 );
  1099       QLabel *maxLabel = 
new QLabel( tr( 
"Max" ) );
  1100       layout->addWidget( maxLabel );
  1101       layout->addWidget( mMaxSpinBox, 1 );
  1103       QWidget *w = 
new QWidget();
  1104       layout->setMargin( 0 );
  1105       layout->setContentsMargins( 0, 0, 0, 0 );
  1106       w->setLayout( layout );
  1110         mMinSpinBox->setDecimals( 6 );
  1111         mMaxSpinBox->setDecimals( 6 );
  1115         mMinSpinBox->setDecimals( 0 );
  1116         mMaxSpinBox->setDecimals( 0 );
  1119       mMinSpinBox->setMinimum( -99999999.999999 );
  1120       mMaxSpinBox->setMinimum( -99999999.999999 );
  1121       mMinSpinBox->setMaximum( 99999999.999999 );
  1122       mMaxSpinBox->setMaximum( 99999999.999999 );
  1126         mAllowingNull = 
true;
  1128         const double min = mMinSpinBox->minimum() - 1;
  1129         mMinSpinBox->setMinimum( min );
  1130         mMaxSpinBox->setMinimum( min );
  1131         mMinSpinBox->setValue( min );
  1132         mMaxSpinBox->setValue( min );
  1134         mMinSpinBox->setShowClearButton( 
true );
  1135         mMaxSpinBox->setShowClearButton( 
true );
  1136         mMinSpinBox->setSpecialValueText( tr( 
"Not set" ) );
  1137         mMaxSpinBox->setSpecialValueText( tr( 
"Not set" ) );
  1140       w->setToolTip( parameterDefinition()->toolTip() );
  1142       connect( mMinSpinBox, qgis::overload<double>::of( &QgsDoubleSpinBox::valueChanged ), 
this, [ = ]( 
const double v )
  1144         mBlockChangedSignal++;
  1145         if ( !mAllowingNull && v > mMaxSpinBox->value() )
  1146           mMaxSpinBox->setValue( v );
  1147         mBlockChangedSignal--;
  1149         if ( !mBlockChangedSignal )
  1150           emit widgetValueHasChanged( 
this );
  1152       connect( mMaxSpinBox, qgis::overload<double>::of( &QgsDoubleSpinBox::valueChanged ), 
this, [ = ]( 
const double v )
  1154         mBlockChangedSignal++;
  1155         if ( !mAllowingNull && v < mMinSpinBox->value() )
  1156           mMinSpinBox->setValue( v );
  1157         mBlockChangedSignal--;
  1159         if ( !mBlockChangedSignal )
  1160           emit widgetValueHasChanged( 
this );
  1169 void QgsProcessingRangeWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  1172   if ( mAllowingNull && v.empty() )
  1174     mMinSpinBox->clear();
  1175     mMaxSpinBox->clear();
  1182     if ( mAllowingNull )
  1184       mBlockChangedSignal++;
  1185       if ( std::isnan( v.at( 0 ) ) )
  1186         mMinSpinBox->clear();
  1188         mMinSpinBox->setValue( v.at( 0 ) );
  1190       if ( v.count() >= 2 )
  1192         if ( std::isnan( v.at( 1 ) ) )
  1193           mMaxSpinBox->clear();
  1195           mMaxSpinBox->setValue( v.at( 1 ) );
  1197       mBlockChangedSignal--;
  1201       mBlockChangedSignal++;
  1202       mMinSpinBox->setValue( v.at( 0 ) );
  1203       if ( v.count() >= 2 )
  1204         mMaxSpinBox->setValue( v.at( 1 ) );
  1205       mBlockChangedSignal--;
  1209   if ( !mBlockChangedSignal )
  1210     emit widgetValueHasChanged( 
this );
  1213 QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
 const  1215   if ( mAllowingNull )
  1218     if ( 
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
  1219       value = QStringLiteral( 
"None" );
  1221       value = QStringLiteral( 
"%1" ).arg( mMinSpinBox->value() );
  1223     if ( 
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
  1224       value += QStringLiteral( 
",None" );
  1226       value += QStringLiteral( 
",%1" ).arg( mMaxSpinBox->value() );
  1231     return QStringLiteral( 
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
  1234 QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
 const  1236   return QStringList()
  1241 QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
 const  1246 QList<int> QgsProcessingRangeWidgetWrapper::compatibleDataTypes()
 const  1248   return QList< int >();
  1251 QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
 const  1253   return tr( 
"string as two comma delimited floats, e.g. '1,10'" );
  1256 QString QgsProcessingRangeWidgetWrapper::parameterType()
 const  1263   return new QgsProcessingRangeWidgetWrapper( parameter, type );
  1278 QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
  1280   mMatrixWidget = 
new QgsProcessingMatrixParameterPanel( 
nullptr, dynamic_cast< const QgsProcessingParameterMatrix *>( parameterDefinition() ) );
  1281   mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
  1283   connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed, 
this, [ = ]
  1285     emit widgetValueHasChanged( 
this );
  1294       return mMatrixWidget;
  1300 void QgsProcessingMatrixWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  1303   if ( mMatrixWidget )
  1304     mMatrixWidget->setValue( v );
  1307 QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
 const  1309   if ( mMatrixWidget )
  1310     return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
  1315 QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
 const  1317   return QStringList()
  1321 QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
 const  1323   return QStringList();
  1326 QList<int> QgsProcessingMatrixWidgetWrapper::compatibleDataTypes()
 const  1328   return QList< int >();
  1331 QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
 const  1333   return tr( 
"comma delimited string of values, or an array of values" );
  1336 QString QgsProcessingMatrixWidgetWrapper::parameterType()
 const  1343   return new QgsProcessingMatrixWidgetWrapper( parameter, type );
  1357   QVBoxLayout *vlayout = 
new QVBoxLayout();
  1358   vlayout->setMargin( 0 );
  1359   vlayout->setContentsMargins( 0, 0, 0, 0 );
  1361   vlayout->addWidget( 
new QLabel( tr( 
"Type" ) ) );
  1363   mTypeComboBox = 
new QComboBox();
  1367     mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( fileParam->behavior() ) );
  1369     mTypeComboBox->setCurrentIndex( 0 );
  1370   vlayout->addWidget( mTypeComboBox );
  1372   vlayout->addWidget( 
new QLabel( tr( 
"File filter" ) ) );
  1374   mFilterComboBox = 
new QComboBox();
  1375   mFilterComboBox->setEditable( 
true );
  1377   mFilterComboBox->addItem( tr( 
"All Files (*.*)" ) );
  1378   mFilterComboBox->addItem( tr( 
"CSV Files (*.csv)" ) );
  1379   mFilterComboBox->addItem( tr( 
"HTML Files (*.html *.htm)" ) );
  1380   mFilterComboBox->addItem( tr( 
"Text Files (*.txt)" ) );
  1382     mFilterComboBox->setCurrentText( fileParam->fileFilter() );
  1384     mFilterComboBox->setCurrentIndex( 0 );
  1385   vlayout->addWidget( mFilterComboBox );
  1387   vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
  1390   mDefaultFileWidget->lineEdit()->setShowClearButton( 
true );
  1394     mDefaultFileWidget->setFilePath( fileParam->defaultValue().toString() );
  1398   vlayout->addWidget( mDefaultFileWidget );
  1400   connect( mTypeComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), 
this, [ = ]
  1406   mFilterComboBox->setEnabled( static_cast< QgsProcessingParameterFile::Behavior >( mTypeComboBox->currentData().toInt() ) == 
QgsProcessingParameterFile::File );
  1409   setLayout( vlayout );
  1412 QgsProcessingParameterDefinition *QgsProcessingFileParameterDefinitionWidget::createParameter( 
const QString &name, 
const QString &description, QgsProcessingParameterDefinition::Flags flags )
 const  1414   auto param = qgis::make_unique< QgsProcessingParameterFile >( name, description );
  1415   param->setBehavior( static_cast< QgsProcessingParameterFile::Behavior>( mTypeComboBox->currentData().toInt() ) );
  1417     param->setFileFilter( mFilterComboBox->currentText() );
  1418   if ( !mDefaultFileWidget->filePath().isEmpty() )
  1420   param->setFlags( flags );
  1421   return param.release();
  1431 QWidget *QgsProcessingFileWidgetWrapper::createWidget()
  1441       mFileWidget->setToolTip( parameterDefinition()->toolTip() );
  1442       mFileWidget->setDialogTitle( parameterDefinition()->description() );
  1444       mFileWidget->setDefaultRoot( 
QgsSettings().value( QStringLiteral( 
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
  1451             mFileWidget->setFilter( fileParam->
fileFilter() );
  1452           else if ( !fileParam->
extension().isEmpty() )
  1453             mFileWidget->setFilter( tr( 
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral( 
" (*." ) + fileParam->
extension().toLower() + 
')' );
  1463         QgsSettings().
setValue( QStringLiteral( 
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
  1464         emit widgetValueHasChanged( 
this );
  1472 void QgsProcessingFileWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  1476     mFileWidget->setFilePath( v );
  1479 QVariant QgsProcessingFileWidgetWrapper::widgetValue()
 const  1482     return mFileWidget->filePath();
  1487 QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
 const  1489   return QStringList()
  1494 QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
 const  1503 QList<int> QgsProcessingFileWidgetWrapper::compatibleDataTypes()
 const  1505   return QList< int >();
  1508 QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
 const  1510   return tr( 
"string representing a path to a file or folder" );
  1513 QString QgsProcessingFileWidgetWrapper::parameterType()
 const  1520   return new QgsProcessingFileWidgetWrapper( parameter, type );
  1525   return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition, algorithm );
  1541 QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
  1553         mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
  1554         mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
  1555         mExpLineEdit->registerExpressionContextGenerator( 
this );
  1558           emit widgetValueHasChanged( 
this );
  1560         return mExpLineEdit;
  1565         mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
  1566         mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
  1567         mFieldExpWidget->registerExpressionContextGenerator( 
this );
  1570           emit widgetValueHasChanged( 
this );
  1572         return mFieldExpWidget;
  1579 void QgsProcessingExpressionWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
  1589         if ( wrapper->parameterDefinition()->name() == 
static_cast< const QgsProcessingParameterExpression * 
>( parameterDefinition() )->parentLayerParameterName() )
  1591           setParentLayerWrapperValue( wrapper );
  1594             setParentLayerWrapperValue( wrapper );
  1611   std::unique_ptr< QgsProcessingContext > tmpContext;
  1612   if ( mProcessingContextGenerator )
  1613     context = mProcessingContextGenerator->processingContext();
  1617     tmpContext = qgis::make_unique< QgsProcessingContext >();
  1618     context = tmpContext.get();
  1624     if ( mFieldExpWidget )
  1625       mFieldExpWidget->setLayer( 
nullptr );
  1626     else if ( mExpLineEdit )
  1627       mExpLineEdit->setLayer( 
nullptr );
  1633   std::unique_ptr< QgsMapLayer > ownedLayer( context->takeResultLayer( layer->
id() ) );
  1636     mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
  1637     layer = mParentLayer.get();
  1644   if ( mFieldExpWidget )
  1645     mFieldExpWidget->setLayer( layer );
  1646   else if ( mExpLineEdit )
  1647     mExpLineEdit->setLayer( layer );
  1650 void QgsProcessingExpressionWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  1653   if ( mFieldExpWidget )
  1654     mFieldExpWidget->setExpression( v );
  1655   else if ( mExpLineEdit )
  1656     mExpLineEdit->setExpression( v );
  1659 QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
 const  1661   if ( mFieldExpWidget )
  1662     return mFieldExpWidget->expression();
  1663   else if ( mExpLineEdit )
  1664     return mExpLineEdit->expression();
  1669 QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
 const  1671   return QStringList()
  1679 QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
 const  1681   return QStringList()
  1686 QList<int> QgsProcessingExpressionWidgetWrapper::compatibleDataTypes()
 const  1688   return QList< int >();
  1691 QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
 const  1693   return tr( 
"string representation of an expression" );
  1696 const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
 const  1698   if ( mFieldExpWidget && mFieldExpWidget->layer() )
  1699     return mFieldExpWidget->layer();
  1704 QString QgsProcessingExpressionWidgetWrapper::parameterType()
 const  1711   return new QgsProcessingExpressionWidgetWrapper( parameter, type );
  1724   QHBoxLayout *hl = 
new QHBoxLayout();
  1726   hl->setContentsMargins( 0, 0, 0, 0 );
  1728   mLineEdit = 
new QLineEdit();
  1729   mLineEdit->setEnabled( 
false );
  1730   hl->addWidget( mLineEdit, 1 );
  1732   mToolButton = 
new QToolButton();
  1733   mToolButton->setText( QString( QChar( 0x2026 ) ) );
  1734   hl->addWidget( mToolButton );
  1740     mLineEdit->setText( tr( 
"%1 options selected" ).arg( 0 ) );
  1743   connect( mToolButton, &QToolButton::clicked, 
this, &QgsProcessingEnumPanelWidget::showDialog );
  1746 void QgsProcessingEnumPanelWidget::setValue( 
const QVariant &value )
  1748   if ( value.isValid() )
  1749     mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
  1753   updateSummaryText();
  1757 void QgsProcessingEnumPanelWidget::showDialog()
  1759   QVariantList availableOptions;
  1762     availableOptions.reserve( mParam->options().size() );
  1763     for ( 
int i = 0; i < mParam->options().count(); ++i )
  1764       availableOptions << i;
  1767   QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue, 
this, 
nullptr );
  1768   const QStringList options = mParam ? mParam->options() : QStringList();
  1769   dlg.setValueFormatter( [options]( 
const QVariant & v ) -> QString
  1771     const int i = v.toInt();
  1772     return options.size() > i ? options.at( i ) : QString();
  1776     setValue( dlg.selectedOptions() );
  1780 void QgsProcessingEnumPanelWidget::updateSummaryText()
  1783     mLineEdit->setText( tr( 
"%1 options selected" ).arg( mValue.count() ) );
  1790 QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent, 
const QgsProcessingParameterEnum *param, 
int columns )
  1793   , mButtonGroup( new QButtonGroup( this ) )
  1794   , mColumns( columns )
  1796   mButtonGroup->setExclusive( !mParam->allowMultiple() );
  1798   QGridLayout *l = 
new QGridLayout();
  1799   l->setContentsMargins( 0, 0, 0, 0 );
  1802   int rows = 
static_cast< int >( std::ceil( mParam->options().count() / 
static_cast< double >( mColumns ) ) );
  1803   for ( 
int i = 0; i < mParam->options().count(); ++i )
  1805     QAbstractButton *button = 
nullptr;
  1806     if ( mParam->allowMultiple() )
  1807       button = 
new QCheckBox( mParam->options().at( i ) );
  1809       button = 
new QRadioButton( mParam->options().at( i ) );
  1811     connect( button, &QAbstractButton::toggled, 
this, [ = ]
  1813       if ( !mBlockChangedSignal )
  1817     mButtons.insert( i, button );
  1818     mButtonGroup->addButton( button, i );
  1819     l->addWidget( button, i % rows, i / rows );
  1821   l->addItem( 
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
  1824   if ( mParam->allowMultiple() )
  1826     setContextMenuPolicy( Qt::CustomContextMenu );
  1827     connect( 
this, &QWidget::customContextMenuRequested, 
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
  1831 QVariant QgsProcessingEnumCheckboxPanelWidget::value()
 const  1833   if ( mParam->allowMultiple() )
  1836     for ( 
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
  1838       if ( it.value()->isChecked() )
  1839         value.append( it.key() );
  1845     return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
  1849 void QgsProcessingEnumCheckboxPanelWidget::setValue( 
const QVariant &value )
  1851   mBlockChangedSignal = 
true;
  1852   if ( mParam->allowMultiple() )
  1854     QVariantList selected;
  1855     if ( value.isValid() )
  1856       selected = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
  1857     for ( 
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
  1859       it.value()->setChecked( selected.contains( it.key() ) );
  1865     if ( v.type() == QVariant::List )
  1866       v = v.toList().value( 0 );
  1867     if ( mButtons.contains( v ) )
  1868       mButtons.value( v )->setChecked( 
true );
  1870   mBlockChangedSignal = 
false;
  1874 void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
  1877   QAction *selectAllAction = 
new QAction( tr( 
"Select All" ), &popupMenu );
  1878   connect( selectAllAction, &QAction::triggered, 
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
  1879   QAction *clearAllAction = 
new QAction( tr( 
"Clear Selection" ), &popupMenu );
  1880   connect( clearAllAction, &QAction::triggered, 
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
  1881   popupMenu.addAction( selectAllAction );
  1882   popupMenu.addAction( clearAllAction );
  1883   popupMenu.exec( QCursor::pos() );
  1886 void QgsProcessingEnumCheckboxPanelWidget::selectAll()
  1888   mBlockChangedSignal = 
true;
  1889   for ( 
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
  1890     it.value()->setChecked( 
true );
  1891   mBlockChangedSignal = 
false;
  1895 void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
  1897   mBlockChangedSignal = 
true;
  1898   for ( 
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
  1899     it.value()->setChecked( 
false );
  1900   mBlockChangedSignal = 
false;
  1915 QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
  1923       if ( expParam->
metadata().value( QStringLiteral( 
"widget_wrapper" ) ).toMap().value( QStringLiteral( 
"useCheckBoxes" ), 
false ).toBool() )
  1925         const int columns = expParam->
metadata().value( QStringLiteral( 
"widget_wrapper" ) ).toMap().value( QStringLiteral( 
"columns" ), 2 ).toInt();
  1926         mCheckboxPanel = 
new QgsProcessingEnumCheckboxPanelWidget( 
nullptr, expParam, columns );
  1927         mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
  1928         connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed, 
this, [ = ]
  1930           emit widgetValueHasChanged( 
this );
  1932         return mCheckboxPanel;
  1941         mPanel = 
new QgsProcessingEnumPanelWidget( 
nullptr, expParam );
  1942         mPanel->setToolTip( parameterDefinition()->toolTip() );
  1943         connect( mPanel, &QgsProcessingEnumPanelWidget::changed, 
this, [ = ]
  1945           emit widgetValueHasChanged( 
this );
  1951         mComboBox = 
new QComboBox();
  1954           mComboBox->addItem( tr( 
"[Not selected]" ), QVariant() );
  1955         const QStringList options = expParam->
options();
  1956         for ( 
int i = 0; i < options.count(); ++i )
  1957           mComboBox->addItem( options.at( i ), i );
  1959         mComboBox->setToolTip( parameterDefinition()->toolTip() );
  1960         connect( mComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), 
this, [ = ]( 
int )
  1962           emit widgetValueHasChanged( 
this );
  1971 void QgsProcessingEnumWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  1975     if ( !value.isValid() )
  1976       mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
  1980       mComboBox->setCurrentIndex( mComboBox->findData( v ) );
  1983   else if ( mPanel || mCheckboxPanel )
  1986     if ( value.isValid() )
  1989       opts.reserve( v.size() );
  1994       mPanel->setValue( opts );
  1995     else if ( mCheckboxPanel )
  1996       mCheckboxPanel->setValue( opts );
  2000 QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
 const  2003     return mComboBox->currentData();
  2005     return mPanel->value();
  2006   else if ( mCheckboxPanel )
  2007     return mCheckboxPanel->value();
  2012 QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
 const  2014   return QStringList()
  2020 QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
 const  2022   return QStringList()
  2027 QList<int> QgsProcessingEnumWidgetWrapper::compatibleDataTypes()
 const  2029   return QList<int>();
  2032 QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
 const  2034   return tr( 
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
  2037 QString QgsProcessingEnumWidgetWrapper::parameterType()
 const  2044   return new QgsProcessingEnumWidgetWrapper( parameter, type );
  2057 QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
  2066       mComboBox = 
new QgsLayoutComboBox( 
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() : 
nullptr );
  2068         mComboBox->setAllowEmptyLayout( 
true );
  2071       mComboBox->setToolTip( parameterDefinition()->toolTip() );
  2074         emit widgetValueHasChanged( 
this );
  2081       mLineEdit = 
new QLineEdit();
  2082       mLineEdit->setToolTip( tr( 
"Name of an existing print layout" ) );
  2083       connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]( 
const QString & )
  2085         emit widgetValueHasChanged( 
this );
  2093 void QgsProcessingLayoutWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  2097     if ( !value.isValid() )
  2098       mComboBox->setCurrentLayout( 
nullptr );
  2102         mComboBox->setCurrentLayout( l );
  2104         mComboBox->setCurrentLayout( 
nullptr );
  2107   else if ( mLineEdit )
  2110     mLineEdit->setText( v );
  2114 QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
 const  2119     return l ? l->
name() : QVariant();
  2121   else if ( mLineEdit )
  2122     return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
  2127 QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
 const  2129   return QStringList()
  2134 QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
 const  2136   return QStringList()
  2140 QList<int> QgsProcessingLayoutWidgetWrapper::compatibleDataTypes()
 const  2142   return QList<int>();
  2145 QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
 const  2147   return tr( 
"string representing the name of an existing print layout" );
  2150 QString QgsProcessingLayoutWidgetWrapper::parameterType()
 const  2157   return new QgsProcessingLayoutWidgetWrapper( parameter, type );
  2171   QVBoxLayout *vlayout = 
new QVBoxLayout();
  2172   vlayout->setMargin( 0 );
  2173   vlayout->setContentsMargins( 0, 0, 0, 0 );
  2175   vlayout->addWidget( 
new QLabel( tr( 
"Parent layout" ) ) );
  2177   mParentLayoutComboBox = 
new QComboBox();
  2178   QString initialParent;
  2180     initialParent = itemParam->parentLayoutParameterName();
  2182   if ( widgetContext.
model() )
  2185     const QMap<QString, QgsProcessingModelParameter> components = widgetContext.
model()->parameterComponents();
  2186     for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
  2188       if ( 
const QgsProcessingParameterLayout *definition = dynamic_cast< const QgsProcessingParameterLayout * >( widgetContext.
model()->parameterDefinition( it.value().parameterName() ) ) )
  2190         mParentLayoutComboBox-> addItem( definition->
description(), definition->
name() );
  2191         if ( !initialParent.isEmpty() && initialParent == definition->
name() )
  2193           mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
  2199   if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
  2202     mParentLayoutComboBox->addItem( initialParent, initialParent );
  2203     mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
  2206   vlayout->addWidget( mParentLayoutComboBox );
  2207   setLayout( vlayout );
  2209 QgsProcessingParameterDefinition *QgsProcessingLayoutItemParameterDefinitionWidget::createParameter( 
const QString &name, 
const QString &description, QgsProcessingParameterDefinition::Flags flags )
 const  2211   auto param = qgis::make_unique< QgsProcessingParameterLayoutItem >( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
  2213   return param.release();
  2223 QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
  2234         mComboBox->setAllowEmptyItem( 
true );
  2235       if ( layoutParam->
itemType() >= 0 )
  2236         mComboBox->setItemType( static_cast< QgsLayoutItemRegistry::ItemType >( layoutParam->
itemType() ) );
  2238       mComboBox->setToolTip( parameterDefinition()->toolTip() );
  2241         emit widgetValueHasChanged( 
this );
  2248       mLineEdit = 
new QLineEdit();
  2249       mLineEdit->setToolTip( tr( 
"UUID or ID of an existing print layout item" ) );
  2250       connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]( 
const QString & )
  2252         emit widgetValueHasChanged( 
this );
  2260 void QgsProcessingLayoutItemWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
  2270         if ( wrapper->parameterDefinition()->name() == 
static_cast< const QgsProcessingParameterLayoutItem * 
>( parameterDefinition() )->parentLayoutParameterName() )
  2272           setLayoutParameterValue( wrapper->parameterValue() );
  2275             setLayoutParameterValue( wrapper->parameterValue() );
  2288 void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue( 
const QVariant &value )
  2294   std::unique_ptr< QgsProcessingContext > tmpContext;
  2295   if ( mProcessingContextGenerator )
  2296     context = mProcessingContextGenerator->processingContext();
  2300     tmpContext = qgis::make_unique< QgsProcessingContext >();
  2301     context = tmpContext.get();
  2305   setLayout( layout );
  2308 void QgsProcessingLayoutItemWidgetWrapper::setLayout( 
QgsPrintLayout *layout )
  2311     mComboBox->setCurrentLayout( layout );
  2314 void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  2318     if ( !value.isValid() )
  2319       mComboBox->setItem( 
nullptr );
  2323       mComboBox->setItem( item );
  2326   else if ( mLineEdit )
  2329     mLineEdit->setText( v );
  2333 QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
 const  2338     return i ? i->
uuid() : QVariant();
  2340   else if ( mLineEdit )
  2341     return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
  2346 QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
 const  2348   return QStringList()
  2353 QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
 const  2355   return QStringList()
  2359 QList<int> QgsProcessingLayoutItemWidgetWrapper::compatibleDataTypes()
 const  2361   return QList<int>();
  2364 QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
 const  2366   return tr( 
"string representing the UUID or ID of an existing print layout item" );
  2369 QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
 const  2376   return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
  2381   return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition, algorithm );
  2388 QgsProcessingPointMapTool::QgsProcessingPointMapTool( 
QgsMapCanvas *canvas )
  2395 QgsProcessingPointMapTool::~QgsProcessingPointMapTool() = 
default;
  2397 void QgsProcessingPointMapTool::deactivate()
  2411   if ( e->button() == Qt::LeftButton )
  2414     emit clicked( point );
  2419 void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
  2421   if ( e->key() == Qt::Key_Escape )
  2436 QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
  2439   QHBoxLayout *l = 
new QHBoxLayout();
  2440   l->setContentsMargins( 0, 0, 0, 0 );
  2443   mLineEdit->setShowClearButton( 
false );
  2444   l->addWidget( mLineEdit, 1 );
  2445   mButton = 
new QToolButton();
  2446   mButton->setText( QString( QChar( 0x2026 ) ) );
  2447   l->addWidget( mButton );
  2450   connect( mLineEdit, &QLineEdit::textChanged, 
this, &QgsProcessingPointPanel::changed );
  2451   connect( mButton, &QToolButton::clicked, 
this, &QgsProcessingPointPanel::selectOnCanvas );
  2452   mButton->setVisible( 
false );
  2455 void QgsProcessingPointPanel::setMapCanvas( 
QgsMapCanvas *canvas )
  2458   mButton->setVisible( 
true );
  2461   mTool = qgis::make_unique< QgsProcessingPointMapTool >( mCanvas );
  2462   connect( mTool.get(), &QgsProcessingPointMapTool::clicked, 
this, &QgsProcessingPointPanel::updatePoint );
  2463   connect( mTool.get(), &QgsProcessingPointMapTool::complete, 
this, &QgsProcessingPointPanel::pointPicked );
  2466 void QgsProcessingPointPanel::setAllowNull( 
bool allowNull )
  2468   mLineEdit->setShowClearButton( allowNull );
  2471 QVariant QgsProcessingPointPanel::value()
 const  2473   return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
  2476 void QgsProcessingPointPanel::clear()
  2483   QString newText = QStringLiteral( 
"%1,%2" )
  2484                     .arg( QString::number( point.
x(), 
'f' ),
  2485                           QString::number( point.
y(), 
'f' ) );
  2488   if ( mCrs.isValid() )
  2490     newText += QStringLiteral( 
" [%1]" ).arg( mCrs.authid() );
  2492   mLineEdit->setText( newText );
  2495 void QgsProcessingPointPanel::selectOnCanvas()
  2500   mPrevTool = mCanvas->mapTool();
  2501   mCanvas->setMapTool( mTool.get() );
  2503   emit toggleDialogVisibility( 
false );
  2506 void QgsProcessingPointPanel::updatePoint( 
const QgsPointXY &point )
  2508   setValue( point, mCanvas->mapSettings().destinationCrs() );
  2511 void QgsProcessingPointPanel::pointPicked()
  2516   mCanvas->setMapTool( mPrevTool );
  2518   emit toggleDialogVisibility( 
true );
  2534 QWidget *QgsProcessingPointWidgetWrapper::createWidget()
  2542       mPanel = 
new QgsProcessingPointPanel( 
nullptr );
  2543       if ( widgetContext().mapCanvas() )
  2544         mPanel->setMapCanvas( widgetContext().mapCanvas() );
  2547         mPanel->setAllowNull( 
true );
  2549       mPanel->setToolTip( parameterDefinition()->toolTip() );
  2551       connect( mPanel, &QgsProcessingPointPanel::changed, 
this, [ = ]
  2553         emit widgetValueHasChanged( 
this );
  2557         setDialog( mDialog ); 
  2563       mLineEdit = 
new QLineEdit();
  2564       mLineEdit->setToolTip( tr( 
"Point as 'x,y'" ) );
  2565       connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]( 
const QString & )
  2567         emit widgetValueHasChanged( 
this );
  2579     mPanel->setMapCanvas( context.
mapCanvas() );
  2582 void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
  2587     connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ]( 
bool visible )
  2590         mDialog->showMinimized();
  2593         mDialog->showNormal();
  2595         mDialog->activateWindow();
  2602 void QgsProcessingPointWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  2606     if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
  2612       mPanel->setValue( p, crs );
  2615   else if ( mLineEdit )
  2618     mLineEdit->setText( v );
  2622 QVariant QgsProcessingPointWidgetWrapper::widgetValue()
 const  2626     return mPanel->value();
  2628   else if ( mLineEdit )
  2629     return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
  2634 QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
 const  2636   return QStringList()
  2641 QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
 const  2643   return QStringList()
  2647 QList<int> QgsProcessingPointWidgetWrapper::compatibleDataTypes()
 const  2649   return QList<int>();
  2652 QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
 const  2654   return tr( 
"string of the format 'x,y' or a geometry value (centroid is used)" );
  2657 QString QgsProcessingPointWidgetWrapper::parameterType()
 const  2664   return new QgsProcessingPointWidgetWrapper( parameter, type );
  2678   QVBoxLayout *vlayout = 
new QVBoxLayout();
  2679   vlayout->setMargin( 0 );
  2680   vlayout->setContentsMargins( 0, 0, 0, 0 );
  2682   vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
  2685   mDefaultColorButton->setShowNull( 
true );
  2686   mAllowOpacity = 
new QCheckBox( tr( 
"Allow opacity control" ) );
  2692       mDefaultColorButton->setToNull();
  2694       mDefaultColorButton->setColor( c );
  2695     mAllowOpacity->setChecked( colorParam->opacityEnabled() );
  2699     mDefaultColorButton->setToNull();
  2700     mAllowOpacity->setChecked( 
true );
  2703   vlayout->addWidget( mDefaultColorButton );
  2704   vlayout->addWidget( mAllowOpacity );
  2705   setLayout( vlayout );
  2708 QgsProcessingParameterDefinition *QgsProcessingColorParameterDefinitionWidget::createParameter( 
const QString &name, 
const QString &description, QgsProcessingParameterDefinition::Flags flags )
 const  2710   auto param = qgis::make_unique< QgsProcessingParameterColor >( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
  2712   return param.release();
  2721 QWidget *QgsProcessingColorWidgetWrapper::createWidget()
  2731       mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
  2734         mColorButton->setShowNull( 
true );
  2737       mColorButton->setToolTip( parameterDefinition()->toolTip() );
  2738       mColorButton->setColorDialogTitle( parameterDefinition()->description() );
  2739       if ( colorParam->
defaultValue().value< QColor >().isValid() )
  2741         mColorButton->setDefaultColor( colorParam->
defaultValue().value< QColor >() );
  2746         emit widgetValueHasChanged( 
this );
  2749       return mColorButton;
  2755 void QgsProcessingColorWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  2759     if ( !value.isValid() ||
  2760          ( value.type() == QVariant::String && value.toString().isEmpty() )
  2761          || ( value.type() == QVariant::Color && !value.value< QColor >().isValid() ) )
  2762       mColorButton->setToNull();
  2766       if ( !c.isValid() && mColorButton->showNull() )
  2767         mColorButton->setToNull();
  2769         mColorButton->setColor( c );
  2774 QVariant QgsProcessingColorWidgetWrapper::widgetValue()
 const  2777     return mColorButton->isNull() ? QVariant() : mColorButton->color();
  2782 QStringList QgsProcessingColorWidgetWrapper::compatibleParameterTypes()
 const  2784   return QStringList()
  2789 QStringList QgsProcessingColorWidgetWrapper::compatibleOutputTypes()
 const  2791   return QStringList()
  2795 QList<int> QgsProcessingColorWidgetWrapper::compatibleDataTypes()
 const  2797   return QList<int>();
  2800 QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
 const  2802   return tr( 
"color style string, e.g. #ff0000 or 255,0,0" );
  2805 QString QgsProcessingColorWidgetWrapper::parameterType()
 const  2812   return new QgsProcessingColorWidgetWrapper( parameter, type );
  2817   return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition, algorithm );
  2828   QVBoxLayout *vlayout = 
new QVBoxLayout();
  2829   vlayout->setMargin( 0 );
  2830   vlayout->setContentsMargins( 0, 0, 0, 0 );
  2832   vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
  2834   mDefaultLineEdit = 
new QLineEdit();
  2837   vlayout->addWidget( mDefaultLineEdit );
  2839   mSourceParamComboBox = 
new QComboBox();
  2840   mDestParamComboBox = 
new QComboBox();
  2841   QString initialSource;
  2842   QString initialDest;
  2847     initialSource = itemParam->sourceCrsParameterName();
  2848     initialDest = itemParam->destinationCrsParameterName();
  2853   mSourceParamComboBox->addItem( QString(), QString() );
  2854   mDestParamComboBox->addItem( QString(), QString() );
  2855   if ( widgetContext.
model() )
  2858     const QMap<QString, QgsProcessingModelParameter> components = widgetContext.
model()->parameterComponents();
  2859     for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
  2861       if ( it->parameterName() == definition->
name() )
  2865       mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
  2866       mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
  2867       if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
  2869         mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
  2871       if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
  2873         mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
  2878   if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
  2881     mSourceParamComboBox->addItem( initialSource, initialSource );
  2882     mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
  2884   if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
  2887     mDestParamComboBox->addItem( initialDest, initialDest );
  2888     mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
  2891   vlayout->addWidget( 
new QLabel( tr( 
"Source CRS parameter" ) ) );
  2892   vlayout->addWidget( mSourceParamComboBox );
  2893   vlayout->addWidget( 
new QLabel( tr( 
"Destination CRS parameter" ) ) );
  2894   vlayout->addWidget( mDestParamComboBox );
  2898   mStaticSourceWidget->setCrs( sourceCrs );
  2901   mStaticDestWidget->setCrs( destCrs );
  2903   vlayout->addWidget( 
new QLabel( tr( 
"Static source CRS" ) ) );
  2904   vlayout->addWidget( mStaticSourceWidget );
  2905   vlayout->addWidget( 
new QLabel( tr( 
"Static destination CRS" ) ) );
  2906   vlayout->addWidget( mStaticDestWidget );
  2908   setLayout( vlayout );
  2911 QgsProcessingParameterDefinition *QgsProcessingCoordinateOperationParameterDefinitionWidget::createParameter( 
const QString &name, 
const QString &description, QgsProcessingParameterDefinition::Flags flags )
 const  2913   auto param = qgis::make_unique< QgsProcessingParameterCoordinateOperation >( name, description, mDefaultLineEdit->text(),
  2914                mSourceParamComboBox->currentText(),
  2915                mDestParamComboBox->currentText(),
  2916                mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
  2917                mStaticDestWidget->crs().isValid() ? QVariant::fromValue( mStaticDestWidget->crs() ) : QVariant() );
  2919   return param.release();
  2928 QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
  2939       mOperationWidget->setShowMakeDefault( 
false );
  2940       mOperationWidget->setShowFallbackOption( 
false );
  2941       mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
  2942       mOperationWidget->setSourceCrs( mSourceCrs );
  2943       mOperationWidget->setDestinationCrs( mDestCrs );
  2944       mOperationWidget->setMapCanvas( mCanvas );
  2945       if ( !coordParam->
defaultValue().toString().isEmpty() )
  2949         mOperationWidget->setSelectedOperation( deets );
  2954         emit widgetValueHasChanged( 
this );
  2957       return mOperationWidget;
  2963       mLineEdit = 
new QLineEdit();
  2964       QHBoxLayout *layout = 
new QHBoxLayout();
  2965       layout->addWidget( mLineEdit, 1 );
  2966       connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
  2968         emit widgetValueHasChanged( 
this );
  2971       QToolButton *button = 
new QToolButton();
  2972       button->setText( QString( QChar( 0x2026 ) ) );
  2973       connect( button, &QToolButton::clicked, 
this, [ = ]
  2975         QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs, 
false, 
false, 
false, qMakePair( -1, -1 ), button, 
nullptr, mLineEdit->text(), mCanvas );
  2978           mLineEdit->setText( dlg.selectedDatumTransform().proj );
  2979           emit widgetValueHasChanged( 
this );
  2982       layout->addWidget( button );
  2984       QWidget *w = 
new QWidget();
  2985       layout->setMargin( 0 );
  2986       layout->setContentsMargins( 0, 0, 0, 0 );
  2987       w->setLayout( layout );
  2995 void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
  3007           setSourceCrsParameterValue( wrapper->parameterValue() );
  3010             setSourceCrsParameterValue( wrapper->parameterValue() );
  3015           setDestinationCrsParameterValue( wrapper->parameterValue() );
  3018             setDestinationCrsParameterValue( wrapper->parameterValue() );
  3033   if ( mOperationWidget )
  3034     mOperationWidget->setMapCanvas( context.
mapCanvas() );
  3037 void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext & )
  3039   if ( mOperationWidget )
  3041     if ( !value.isValid() ||
  3042          ( value.type() == QVariant::String ) )
  3045       deets.
proj = value.toString();
  3046       mOperationWidget->setSelectedOperation( deets );
  3051     if ( !value.isValid() ||
  3052          ( value.type() == QVariant::String ) )
  3054       mLineEdit->setText( value.toString() );
  3059 QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
 const  3061   if ( mOperationWidget )
  3062     return mOperationWidget->selectedOperation().proj;
  3063   else if ( mLineEdit )
  3064     return mLineEdit->text();
  3069 QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleParameterTypes()
 const  3071   return QStringList()
  3076 QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleOutputTypes()
 const  3078   return QStringList()
  3082 QList<int> QgsProcessingCoordinateOperationWidgetWrapper::compatibleDataTypes()
 const  3084   return QList<int>();
  3087 QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
 const  3089   return tr( 
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
  3092 void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue( 
const QVariant &value )
  3095   std::unique_ptr< QgsProcessingContext > tmpContext;
  3096   if ( mProcessingContextGenerator )
  3097     context = mProcessingContextGenerator->processingContext();
  3101     tmpContext = qgis::make_unique< QgsProcessingContext >();
  3102     context = tmpContext.get();
  3106   if ( mOperationWidget )
  3108     mOperationWidget->setSourceCrs( mSourceCrs );
  3109     mOperationWidget->setSelectedOperationUsingContext( context->transformContext() );
  3113 void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue( 
const QVariant &value )
  3116   std::unique_ptr< QgsProcessingContext > tmpContext;
  3117   if ( mProcessingContextGenerator )
  3118     context = mProcessingContextGenerator->processingContext();
  3122     tmpContext = qgis::make_unique< QgsProcessingContext >();
  3123     context = tmpContext.get();
  3127   if ( mOperationWidget )
  3129     mOperationWidget->setDestinationCrs( mDestCrs );
  3130     mOperationWidget->setSelectedOperationUsingContext( context->transformContext() );
  3134 QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
 const  3141   return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
  3146   return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition, algorithm );
  3159   QHBoxLayout *hl = 
new QHBoxLayout();
  3161   hl->setContentsMargins( 0, 0, 0, 0 );
  3163   mLineEdit = 
new QLineEdit();
  3164   mLineEdit->setEnabled( 
false );
  3165   hl->addWidget( mLineEdit, 1 );
  3167   mToolButton = 
new QToolButton();
  3168   mToolButton->setText( QString( QChar( 0x2026 ) ) );
  3169   hl->addWidget( mToolButton );
  3175     mLineEdit->setText( tr( 
"%1 options selected" ).arg( 0 ) );
  3178   connect( mToolButton, &QToolButton::clicked, 
this, &QgsProcessingFieldPanelWidget::showDialog );
  3181 void QgsProcessingFieldPanelWidget::setFields( 
const QgsFields &fields )
  3186 void QgsProcessingFieldPanelWidget::setValue( 
const QVariant &value )
  3188   if ( value.isValid() )
  3189     mValue = value.type() == QVariant::List ? value.
toList() : QVariantList() << value;
  3193   updateSummaryText();
  3197 void QgsProcessingFieldPanelWidget::showDialog()
  3199   QVariantList availableOptions;
  3200   QStringList fieldNames;
  3201   availableOptions.reserve( mFields.size() );
  3202   for ( 
const QgsField &field : qgis::as_const( mFields ) )
  3204     availableOptions << field.name();
  3207   QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue, 
this, 
nullptr );
  3208   dlg.setValueFormatter( []( 
const QVariant & v ) -> QString
  3210     return v.toString();
  3214     setValue( dlg.selectedOptions() );
  3218 void QgsProcessingFieldPanelWidget::updateSummaryText()
  3221     mLineEdit->setText( tr( 
"%1 options selected" ).arg( mValue.count() ) );
  3235 QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
  3245         mPanel = 
new QgsProcessingFieldPanelWidget( 
nullptr, fieldParam );
  3246         mPanel->setToolTip( parameterDefinition()->toolTip() );
  3247         connect( mPanel, &QgsProcessingFieldPanelWidget::changed, 
this, [ = ]
  3249           emit widgetValueHasChanged( 
this );
  3265         mComboBox->setToolTip( parameterDefinition()->toolTip() );
  3268           emit widgetValueHasChanged( 
this );
  3276       mLineEdit = 
new QLineEdit();
  3277       mLineEdit->setToolTip( QObject::tr( 
"Name of field (separate field names with ; for multiple field parameters)" ) );
  3278       connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
  3280         emit widgetValueHasChanged( 
this );
  3289 void QgsProcessingFieldWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
  3299         if ( wrapper->parameterDefinition()->name() == 
static_cast< const QgsProcessingParameterField * 
>( parameterDefinition() )->parentLayerParameterName() )
  3301           setParentLayerWrapperValue( wrapper );
  3304             setParentLayerWrapperValue( wrapper );
  3321   std::unique_ptr< QgsProcessingContext > tmpContext;
  3322   if ( mProcessingContextGenerator )
  3323     context = mProcessingContextGenerator->processingContext();
  3327     tmpContext = qgis::make_unique< QgsProcessingContext >();
  3328     context = tmpContext.get();
  3343   if ( layer && layer->
isValid() )
  3347     std::unique_ptr< QgsMapLayer > ownedLayer( context->takeResultLayer( layer->
id() ) );
  3350       mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
  3351       layer = mParentLayer.get();
  3359       mComboBox->setLayer( layer );
  3361       mPanel->setFields( filterFields( layer->
fields() ) );
  3368       const QgsFields fields = source->fields();
  3370         mComboBox->setFields( fields );
  3372         mPanel->setFields( filterFields( fields ) );
  3377         mComboBox->setLayer( 
nullptr );
  3381       if ( value.isValid() && widgetContext().
messageBar() )
  3384         widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr( 
"Could not load selected layer/table. Dependent field could not be populated" ),
  3395     val.reserve( mPanel->fields().size() );
  3396     for ( 
const QgsField &field : mPanel->fields() )
  3397       val << field.
name();
  3398     setWidgetValue( val, *context );
  3401     setWidgetValue( parameterDefinition()->defaultValue(), *context );
  3404 void QgsProcessingFieldWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  3408     if ( !value.isValid() )
  3409       mComboBox->setField( QString() );
  3413       mComboBox->setField( v );
  3419     if ( value.isValid() )
  3422       opts.reserve( v.size() );
  3423       for ( 
const QString &i : v )
  3427       mPanel->setValue( opts );
  3429   else if ( mLineEdit )
  3435       mLineEdit->setText( v.join( 
';' ) );
  3444 QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
 const  3447     return mComboBox->currentField();
  3449     return mPanel->value();
  3450   else if ( mLineEdit )
  3455       return mLineEdit->text().split( 
';' );
  3458       return mLineEdit->text();
  3464 QStringList QgsProcessingFieldWidgetWrapper::compatibleParameterTypes()
 const  3466   return QStringList()
  3471 QStringList QgsProcessingFieldWidgetWrapper::compatibleOutputTypes()
 const  3473   return QStringList()
  3477 QList<int> QgsProcessingFieldWidgetWrapper::compatibleDataTypes()
 const  3479   return QList<int>();
  3482 QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
 const  3484   return tr( 
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
  3487 const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
 const  3489   if ( mComboBox && mComboBox->layer() )
  3490     return mComboBox->layer();
  3495 QgsFields QgsProcessingFieldWidgetWrapper::filterFields( 
const QgsFields &fields )
 const  3508         if ( f.isNumeric() )
  3513         if ( f.type() == QVariant::String )
  3518         if ( f.type() == QVariant::Date || f.type() == QVariant::Time || f.type() == QVariant::DateTime )
  3527 QString QgsProcessingFieldWidgetWrapper::parameterType()
 const  3534   return new QgsProcessingFieldWidgetWrapper( parameter, type );
  3545   QVBoxLayout *vlayout = 
new QVBoxLayout();
  3546   vlayout->setMargin( 0 );
  3547   vlayout->setContentsMargins( 0, 0, 0, 0 );
  3549   vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
  3551   mDefaultComboBox = 
new QComboBox();
  3552   mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
  3555   for ( 
const QString &theme : mapThemes )
  3559   mDefaultComboBox->setEditable( 
true );
  3563     if ( themeParam->defaultValue().isValid() )
  3566       mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
  3569     mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
  3571   vlayout->addWidget( mDefaultComboBox );
  3573   setLayout( vlayout );
  3576 QgsProcessingParameterDefinition *QgsProcessingMapThemeParameterDefinitionWidget::createParameter( 
const QString &name, 
const QString &description, QgsProcessingParameterDefinition::Flags flags )
 const  3578   QVariant defaultVal;
  3579   if ( mDefaultComboBox->currentText().isEmpty() )
  3580     defaultVal = QVariant();
  3582     defaultVal = mDefaultComboBox->currentText();
  3583   auto param = qgis::make_unique< QgsProcessingParameterMapTheme>( name, description, defaultVal );
  3585   return param.release();
  3595 QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
  3599   mComboBox = 
new QComboBox();
  3602     mComboBox->addItem( tr( 
"[Not selected]" ), QVariant( -1 ) );
  3605   for ( 
const QString &theme : mapThemes )
  3617       mComboBox->setEditable( 
true );
  3621   mComboBox->setToolTip( parameterDefinition()->toolTip() );
  3622   connect( mComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), 
this, [ = ]( 
int )
  3624     emit widgetValueHasChanged( 
this );
  3630 void QgsProcessingMapThemeWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
  3634   if ( !value.isValid() )
  3635     mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
  3638     if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
  3640       const QString prev = mComboBox->currentText();
  3641       mComboBox->setCurrentText( v );
  3643         emit widgetValueHasChanged( 
this );
  3646       mComboBox->setCurrentIndex( mComboBox->findData( v ) );
  3650 QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
 const  3653     return mComboBox->currentData().toInt() == -1 ? QVariant() :
  3654            !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
  3655            : mComboBox->currentData();
  3660 QStringList QgsProcessingMapThemeWidgetWrapper::compatibleParameterTypes()
 const  3662   return QStringList()
  3667 QStringList QgsProcessingMapThemeWidgetWrapper::compatibleOutputTypes()
 const  3669   return QStringList()
  3673 QList<int> QgsProcessingMapThemeWidgetWrapper::compatibleDataTypes()
 const  3675   return QList< int >();
  3678 QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
 const  3680   return tr( 
"map theme as a string value (e.g. 'base maps')" );
  3683 QString QgsProcessingMapThemeWidgetWrapper::parameterType()
 const  3690   return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
  3695   return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition, algorithm );
 static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system. 
 
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
 
A boolean parameter for processing algorithms. 
 
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
An input file or folder parameter for processing algorithms. 
 
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value. 
 
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
 
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values. 
 
Base class for graphical items within a QgsLayout. 
 
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget. 
 
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit. 
 
static QString typeName()
Returns the type name for the output class. 
 
A vector layer or feature source field parameter for processing algorithms. 
 
DataType dataType() const
Returns the acceptable data type for the field. 
 
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes. 
 
This class is a composition of two QSettings instances: 
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget. 
 
QVariantMap metadata() const
Returns the parameter's freeform metadata. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values. 
 
A print layout parameter, allowing users to select a print layout. 
 
WidgetType
Types of dialogs which Processing widgets can be created for. 
 
A class to represent a 2D point. 
 
A color parameter for processing algorithms. 
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference) 
 
An expression parameter for processing algorithms. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
 
static QString typeName()
Returns the type name for the parameter class. 
 
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas. 
 
double minimum() const
Returns the minimum value acceptable by the parameter. 
 
Container of fields for a vector layer. 
 
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
bool allowMultiple() const
Returns true if the parameter allows multiple selected values. 
 
void setFlags(Flags flags)
Sets the flags associated with the parameter. 
 
QgsUnitTypes::DistanceUnit mapUnits
 
bool clearWidgets()
Remove all items from the bar's widget list. 
 
QgsUnitTypes::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
const QgsCoordinateReferenceSystem & crs
 
bool isValid() const
Returns the status of the layer. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QString typeName()
Returns the type name for the output class. 
 
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer. 
 
Abstract base class for processing algorithms. 
 
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
 
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point. 
 
Map canvas is a class for displaying all GIS data types on a canvas. 
 
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system 
 
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system. 
 
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
A numeric range parameter for processing algorithms. 
 
A double numeric parameter for map scale values. 
 
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 c
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
 
The QgsLayoutItemComboBox class is a combo box which displays items of a matching type from a layout...
 
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter. 
 
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value. ...
 
static QString typeName()
Returns the type name for the parameter class. 
 
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject. 
 
QgsFields fields() const FINAL
Returns the list of fields of this layer. 
 
QgsMapThemeCollection mapThemeCollection
 
QgsProperty source
Source definition. 
 
An enum based parameter for processing algorithms, allowing for selection from predefined values...
 
Flags flags() const
Returns any flags associated with the parameter. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
bool opacityEnabled() const
Returns true if the parameter allows opacity control. 
 
QVariant defaultValue() const
Returns the default value for the parameter. 
 
QVariant sourceCrs() const
Returns the static source CRS, or an invalid value if this is not set. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
A double numeric parameter for distance values. 
 
static QString typeName()
Returns the type name for the output class. 
 
Parameter is a single file. 
 
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values. 
 
Degrees, for planar geographic CRS distance measurements. 
 
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes. 
 
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
 
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false) ...
 
void setDefaultValue(const QVariant &value)
Sets the default value for the parameter. 
 
static QString typeName()
Returns the type name for the output class. 
 
QStringList options() const
Returns the list of acceptable options for the parameter. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
Encapsulate a field in an attribute table or data source. 
 
QgsProject * project() const
Returns the project associated with the widget. 
 
A print layout item parameter, allowing users to select a particular item from a print layout...
 
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::Info, int duration=5)
convenience method for pushing a message to the bar 
 
static QString typeName()
Returns the type name for the output class. 
 
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
 
A numeric parameter for processing algorithms. 
 
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes. 
 
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout. 
 
QString name() const
Returns the name of the parameter. 
 
void expressionChanged(const QString &expression)
Emitted when the expression is changed. 
 
Encapsulates settings relating to a feature source input to a processing algorithm. 
 
Behavior behavior() const
Returns the parameter behavior (e.g. 
 
QVariant destinationCrs() const
Returns the static destination CRS, or an invalid value if this is not set. 
 
DistanceUnit
Units of distance. 
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnitType unitType(QgsUnitTypes::DistanceUnit unit)
Returns the type for a distance unit. 
 
QString extension() const
Returns any specified file extension for the parameter. 
 
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering. 
 
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing. 
 
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with. 
 
A point parameter for processing algorithms. 
 
Contains settings which reflect the context in which a Processing parameter widget is shown...
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value. 
 
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
 
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
 
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places...
 
static QString typeName()
Returns the type name for the output class. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
static QgsProject * instance()
Returns the QgsProject singleton instance. 
 
virtual QString uuid() const
Returns the item identification string. 
 
This class represents a coordinate reference system (CRS). 
 
Base class for the definition of processing parameters. 
 
QList< QgsField > toList() const
Utility function to return a list of QgsField instances. 
 
Class that shows snapping marker on map canvas for the current snapping match. 
 
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value. 
 
virtual QString name() const =0
Returns the layout's name. 
 
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value. 
 
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source. 
 
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value. 
 
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor. 
 
Behavior
Parameter behavior. 
 
Type dataType() const
Returns the acceptable data type for the parameter. 
 
Print layout, a QgsLayout subclass for static or atlas-based layouts. 
 
Interface for master layout type objects, such as print layouts and reports. 
 
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units. 
 
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration 
 
Represents a vector layer which manages a vector based data sets. 
 
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
 
Contains information about the context in which a processing algorithm is executed. 
 
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
 
A string parameter for processing algorithms. 
 
The QgsLayoutComboBox class is a combo box which displays available layouts from a QgsLayoutManager...
 
QString description() const
Returns the description for the parameter. 
 
static QString typeName()
Returns the type name for the output class. 
 
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range. 
 
bool allowMultiple() const
Returns whether multiple field selections are permitted. 
 
Unit is a standard measurement unit. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
double maximum() const
Returns the maximum value acceptable by the parameter. 
 
static QString typeName()
Returns the type name for the parameter class. 
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable. 
 
Standard algorithm dialog. 
 
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.