78#include <QPlainTextEdit> 
   79#include <QRadioButton> 
   80#include <QButtonGroup> 
   94  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
   95  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
   97  mDefaultCheckBox = 
new QCheckBox( tr( 
"Checked" ) );
 
  101    mDefaultCheckBox->setChecked( 
false );
 
  102  vlayout->addWidget( mDefaultCheckBox );
 
  103  setLayout( vlayout );
 
  108  auto param = std::make_unique< QgsProcessingParameterBoolean >( name, description, mDefaultCheckBox->isChecked() );
 
  109  param->setFlags( flags );
 
  110  return param.release();
 
  120QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
 
  126      QString description = parameterDefinition()->description();
 
  128        description = QObject::tr( 
"%1 [optional]" ).arg( description );
 
  130      mCheckBox = 
new QCheckBox( description );
 
  131      mCheckBox->setToolTip( parameterDefinition()->toolTip() );
 
  133      connect( mCheckBox, &QCheckBox::toggled, 
this, [ = ]
 
  135        emit widgetValueHasChanged( 
this );
 
  143      mComboBox = 
new QComboBox();
 
  144      mComboBox->addItem( tr( 
"Yes" ), 
true );
 
  145      mComboBox->addItem( tr( 
"No" ), 
false );
 
  146      mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
  148      connect( mComboBox, qOverload< int>( &QComboBox::currentIndexChanged ), 
this, [ = ]
 
  150        emit widgetValueHasChanged( 
this );
 
  159QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
 
  168void QgsProcessingBooleanWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
  175      mCheckBox->setChecked( v );
 
  183      mComboBox->setCurrentIndex( mComboBox->findData( v ) );
 
  189QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
 const 
  194      return mCheckBox->isChecked();
 
  198      return mComboBox->currentData();
 
  203QStringList QgsProcessingBooleanWidgetWrapper::compatibleParameterTypes()
 const 
  225QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes()
 const 
  237QString QgsProcessingBooleanWidgetWrapper::parameterType()
 const 
  244  return new QgsProcessingBooleanWidgetWrapper( parameter, type );
 
  249  return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
  260  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
  261  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
  263  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
  268  mCrsSelector->setShowAccuracyWarnings( 
true );
 
  275  vlayout->addWidget( mCrsSelector );
 
  276  setLayout( vlayout );
 
  281  auto param = std::make_unique< QgsProcessingParameterCrs >( name, description, mCrsSelector->crs().authid() );
 
  282  param->setFlags( flags );
 
  283  return param.release();
 
  292QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
 
  294  Q_ASSERT( mProjectionSelectionWidget == 
nullptr );
 
  296  mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
 
  305    emit widgetValueHasChanged( 
this );
 
  313      return mProjectionSelectionWidget;
 
  318      QWidget *w = 
new QWidget();
 
  319      w->setToolTip( parameterDefinition()->toolTip() );
 
  321      QVBoxLayout *vl = 
new QVBoxLayout();
 
  322      vl->setContentsMargins( 0, 0, 0, 0 );
 
  325      mUseProjectCrsCheckBox = 
new QCheckBox( tr( 
"Use project CRS" ) );
 
  326      mUseProjectCrsCheckBox->setToolTip( tr( 
"Always use the current project CRS when running the model" ) );
 
  327      vl->addWidget( mUseProjectCrsCheckBox );
 
  328      connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
 
  329      connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, 
this, [ = ]
 
  331        emit widgetValueHasChanged( 
this );
 
  334      vl->addWidget( mProjectionSelectionWidget );
 
  342void QgsProcessingCrsWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
  344  if ( mUseProjectCrsCheckBox )
 
  346    if ( value.toString().compare( QLatin1String( 
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
 
  348      mUseProjectCrsCheckBox->setChecked( 
true );
 
  353      mUseProjectCrsCheckBox->setChecked( 
false );
 
  358  if ( mProjectionSelectionWidget )
 
  359    mProjectionSelectionWidget->setCrs( v );
 
  362QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
 const 
  364  if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
 
  365    return QStringLiteral( 
"ProjectCrs" );
 
  366  else if ( mProjectionSelectionWidget )
 
  367    return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
 
  372QStringList QgsProcessingCrsWidgetWrapper::compatibleParameterTypes()
 const 
  386QStringList QgsProcessingCrsWidgetWrapper::compatibleOutputTypes()
 const 
  395QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
 const 
  397  return tr( 
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
 
  400QString QgsProcessingCrsWidgetWrapper::parameterType()
 const 
  407  return new QgsProcessingCrsWidgetWrapper( parameter, type );
 
  412  return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
  425  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
  426  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
  428  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
  430  mDefaultLineEdit = 
new QLineEdit();
 
  433  vlayout->addWidget( mDefaultLineEdit );
 
  435  mMultiLineCheckBox = 
new QCheckBox( tr( 
"Multiline input" ) );
 
  437    mMultiLineCheckBox->setChecked( stringParam->multiLine() );
 
  438  vlayout->addWidget( mMultiLineCheckBox );
 
  440  setLayout( vlayout );
 
  445  auto param = std::make_unique< QgsProcessingParameterString >( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
 
  446  param->setFlags( flags );
 
  447  return param.release();
 
  458QWidget *QgsProcessingStringWidgetWrapper::createWidget()
 
  460  const QVariantMap metadata = parameterDefinition()->metadata();
 
  461  const QVariant valueHintsVariant = metadata.value( QStringLiteral( 
"widget_wrapper" ) ).toMap().value( QStringLiteral( 
"value_hints" ) );
 
  463  if ( valueHintsVariant.isValid() )
 
  465    const QVariantList valueList = valueHintsVariant.toList();
 
  466    mComboBox = 
new QComboBox();
 
  467    mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
  471      mComboBox->addItem( QString() );
 
  473    for ( 
const QVariant &entry : valueList )
 
  475      mComboBox->addItem( entry.toString(), entry.toString() );
 
  477    mComboBox->setCurrentIndex( 0 );
 
  479    connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [ = ]( 
int )
 
  481      emit widgetValueHasChanged( 
this );
 
  494          mPlainTextEdit = 
new QPlainTextEdit();
 
  495          mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
 
  497          connect( mPlainTextEdit, &QPlainTextEdit::textChanged, 
this, [ = ]
 
  499            emit widgetValueHasChanged( 
this );
 
  501          return mPlainTextEdit;
 
  505          mLineEdit = 
new QLineEdit();
 
  506          mLineEdit->setToolTip( parameterDefinition()->toolTip() );
 
  508          connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
 
  510            emit widgetValueHasChanged( 
this );
 
  518        mLineEdit = 
new QLineEdit();
 
  519        mLineEdit->setToolTip( parameterDefinition()->toolTip() );
 
  521        connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
 
  523          emit widgetValueHasChanged( 
this );
 
  533void QgsProcessingStringWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
  537    mLineEdit->setText( v );
 
  538  if ( mPlainTextEdit )
 
  539    mPlainTextEdit->setPlainText( v );
 
  543    if ( !value.isValid() )
 
  544      index = mComboBox->findData( QVariant() );
 
  546      index = mComboBox->findData( v );
 
  549      mComboBox->setCurrentIndex( index );
 
  551      mComboBox->setCurrentIndex( 0 );
 
  555QVariant QgsProcessingStringWidgetWrapper::widgetValue()
 const 
  558    return mLineEdit->text();
 
  559  else if ( mPlainTextEdit )
 
  560    return mPlainTextEdit->toPlainText();
 
  561  else if ( mComboBox )
 
  562    return mComboBox->currentData();
 
  567QStringList QgsProcessingStringWidgetWrapper::compatibleParameterTypes()
 const 
  583QStringList QgsProcessingStringWidgetWrapper::compatibleOutputTypes()
 const 
  592QString QgsProcessingStringWidgetWrapper::parameterType()
 const 
  599  return new QgsProcessingStringWidgetWrapper( parameter, type );
 
  604  return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
  619QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
 
  628      mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
 
  632        emit widgetValueHasChanged( 
this );
 
  634      return mAuthConfigSelect;
 
  640void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
  643  if ( mAuthConfigSelect )
 
  644    mAuthConfigSelect->setConfigId( v );
 
  647QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
 const 
  649  if ( mAuthConfigSelect )
 
  650    return mAuthConfigSelect->configId();
 
  655QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleParameterTypes()
 const 
  663QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleOutputTypes()
 const 
  669QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
 const 
  676  return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
 
  686  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
  687  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
  689  vlayout->addWidget( 
new QLabel( tr( 
"Number type" ) ) );
 
  691  mTypeComboBox = 
new QComboBox();
 
  694  vlayout->addWidget( mTypeComboBox );
 
  696  vlayout->addWidget( 
new QLabel( tr( 
"Minimum value" ) ) );
 
  697  mMinLineEdit = 
new QLineEdit();
 
  698  vlayout->addWidget( mMinLineEdit );
 
  700  vlayout->addWidget( 
new QLabel( tr( 
"Maximum value" ) ) );
 
  701  mMaxLineEdit = 
new QLineEdit();
 
  702  vlayout->addWidget( mMaxLineEdit );
 
  704  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
  705  mDefaultLineEdit = 
new QLineEdit();
 
  706  vlayout->addWidget( mDefaultLineEdit );
 
  710    mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( 
static_cast< int >( numberParam->dataType() ) ) );
 
  712    if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
 
  714      mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
 
  718      mMaxLineEdit->clear();
 
  721    if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
 
  723      mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
 
  727      mMinLineEdit->clear();
 
  730    mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
 
  733  setLayout( vlayout );
 
  742  auto param = std::make_unique< QgsProcessingParameterNumber >( name, description, dataType, ok ? val : QVariant() );
 
  744  if ( !mMinLineEdit->text().trimmed().isEmpty() )
 
  749      param->setMinimum( val );
 
  753  if ( !mMaxLineEdit->text().trimmed().isEmpty() )
 
  758      param->setMaximum( val );
 
  762  param->setFlags( flags );
 
  763  return param.release();
 
  772QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
 
  775  const QVariantMap metadata = numberDef->
metadata();
 
  776  const int decimals = metadata.value( QStringLiteral( 
"widget_wrapper" ) ).toMap().value( QStringLiteral( 
"decimals" ), 6 ).toInt();
 
  784      QAbstractSpinBox *spinBox = 
nullptr;
 
  789          mDoubleSpinBox->setExpressionsEnabled( 
true );
 
  790          mDoubleSpinBox->setDecimals( decimals );
 
  796            double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
 
  797            singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
 
  798            mDoubleSpinBox->setSingleStep( singleStep );
 
  801          spinBox = mDoubleSpinBox;
 
  806          mSpinBox->setExpressionsEnabled( 
true );
 
  810      spinBox->setToolTip( parameterDefinition()->toolTip() );
 
  812      double max = 999999999;
 
  817      double min = -999999999;
 
  822      if ( mDoubleSpinBox )
 
  824        mDoubleSpinBox->setMinimum( min );
 
  825        mDoubleSpinBox->setMaximum( max );
 
  829        mSpinBox->setMinimum( 
static_cast< int >( min ) );
 
  830        mSpinBox->setMaximum( 
static_cast< int >( max ) );
 
  835        mAllowingNull = 
true;
 
  836        if ( mDoubleSpinBox )
 
  838          mDoubleSpinBox->setShowClearButton( 
true );
 
  839          const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
 
  840          mDoubleSpinBox->setMinimum( min );
 
  841          mDoubleSpinBox->setValue( min );
 
  845          mSpinBox->setShowClearButton( 
true );
 
  846          const int min = mSpinBox->minimum() - 1;
 
  847          mSpinBox->setMinimum( min );
 
  848          mSpinBox->setValue( min );
 
  850        spinBox->setSpecialValueText( tr( 
"Not set" ) );
 
  858          if ( mDoubleSpinBox )
 
  862              mDoubleSpinBox->setClearValue( defaultVal );
 
  868              mSpinBox->setClearValue( intVal );
 
  874          if ( mDoubleSpinBox )
 
  875            mDoubleSpinBox->setClearValue( numberDef->
minimum() );
 
  877            mSpinBox->setClearValue( 
static_cast< int >( numberDef->
minimum() ) );
 
  882          if ( mDoubleSpinBox )
 
  884            mDoubleSpinBox->setValue( 0 );
 
  885            mDoubleSpinBox->setClearValue( 0 );
 
  889            mSpinBox->setValue( 0 );
 
  890            mSpinBox->setClearValue( 0 );
 
  895      if ( mDoubleSpinBox )
 
  896        connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, [ = ] { emit widgetValueHasChanged( 
this ); } );
 
  898        connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ), 
this, [ = ] { emit widgetValueHasChanged( 
this ); } );
 
  906void QgsProcessingNumericWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
  908  if ( mDoubleSpinBox )
 
  910    if ( mAllowingNull && !value.isValid() )
 
  911      mDoubleSpinBox->clear();
 
  915      mDoubleSpinBox->setValue( v );
 
  920    if ( mAllowingNull && !value.isValid() )
 
  925      mSpinBox->setValue( v );
 
  930QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
 const 
  932  if ( mDoubleSpinBox )
 
  934    if ( mAllowingNull && 
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
 
  937      return mDoubleSpinBox->value();
 
  941    if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
 
  944      return mSpinBox->value();
 
  950QStringList QgsProcessingNumericWidgetWrapper::compatibleParameterTypes()
 const 
  960QStringList QgsProcessingNumericWidgetWrapper::compatibleOutputTypes()
 const 
  967double QgsProcessingNumericWidgetWrapper::calculateStep( 
const double minimum, 
const double maximum )
 
  969  const double valueRange = maximum - minimum;
 
  970  if ( valueRange <= 1.0 )
 
  972    const double step = valueRange / 10.0;
 
  974    return qgsRound( step, -std::floor( std::log( step ) ) );
 
  982QString QgsProcessingNumericWidgetWrapper::parameterType()
 const 
  989  return new QgsProcessingNumericWidgetWrapper( parameter, type );
 
  994  return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 1004  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 1005  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 1007  vlayout->addWidget( 
new QLabel( tr( 
"Linked input" ) ) );
 
 1009  mParentLayerComboBox = 
new QComboBox();
 
 1011  QString initialParent;
 
 1013    initialParent = distParam->parentParameterName();
 
 1015  if ( 
auto *lModel = widgetContext.
model() )
 
 1018    const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
 
 1019    for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 1023        mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 1024        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 1026          mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 1031        mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 1032        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 1034          mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 1039        mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 1040        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 1042          mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 1047        mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 1048        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 1050          mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 1056  if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
 
 1059    mParentLayerComboBox->addItem( initialParent, initialParent );
 
 1060    mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 1063  vlayout->addWidget( mParentLayerComboBox );
 
 1065  vlayout->addWidget( 
new QLabel( tr( 
"Minimum value" ) ) );
 
 1066  mMinLineEdit = 
new QLineEdit();
 
 1067  vlayout->addWidget( mMinLineEdit );
 
 1069  vlayout->addWidget( 
new QLabel( tr( 
"Maximum value" ) ) );
 
 1070  mMaxLineEdit = 
new QLineEdit();
 
 1071  vlayout->addWidget( mMaxLineEdit );
 
 1073  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 1074  mDefaultLineEdit = 
new QLineEdit();
 
 1075  vlayout->addWidget( mDefaultLineEdit );
 
 1079    mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
 
 1080    mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
 
 1081    mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
 
 1084  setLayout( vlayout );
 
 1092  auto param = std::make_unique< QgsProcessingParameterDistance >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
 
 1097    param->setMinimum( val );
 
 1103    param->setMaximum( val );
 
 1106  param->setFlags( flags );
 
 1107  return param.release();
 
 1111  : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
 
 1116QString QgsProcessingDistanceWidgetWrapper::parameterType()
 const 
 1123  return new QgsProcessingDistanceWidgetWrapper( parameter, type );
 
 1126QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
 
 1130  QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
 
 1135      mLabel = 
new QLabel();
 
 1136      mUnitsCombo = 
new QComboBox();
 
 1148      const int labelMargin = 
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance( 
'X' ) ) );
 
 1149      QHBoxLayout *layout = 
new QHBoxLayout();
 
 1150      layout->addWidget( spin, 1 );
 
 1151      layout->insertSpacing( 1, labelMargin / 2 );
 
 1152      layout->insertWidget( 2, mLabel );
 
 1153      layout->insertWidget( 3, mUnitsCombo );
 
 1158      mWarningLabel = 
new QWidget();
 
 1159      QHBoxLayout *warningLayout = 
new QHBoxLayout();
 
 1160      warningLayout->setContentsMargins( 0, 0, 0, 0 );
 
 1161      QLabel *warning = 
new QLabel();
 
 1163      const int size = 
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
 
 1164      warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
 
 1165      warning->setToolTip( tr( 
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
 
 1166      warningLayout->insertSpacing( 0, labelMargin / 2 );
 
 1167      warningLayout->insertWidget( 1, warning );
 
 1168      mWarningLabel->setLayout( warningLayout );
 
 1169      layout->insertWidget( 4, mWarningLabel );
 
 1171      QWidget *w = 
new QWidget();
 
 1172      layout->setContentsMargins( 0, 0, 0, 0 );
 
 1173      w->setLayout( layout );
 
 1188void QgsProcessingDistanceWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 1190  QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
 
 1197        if ( wrapper->parameterDefinition()->name() == 
static_cast< const QgsProcessingParameterDistance * 
>( parameterDefinition() )->parentParameterName() )
 
 1199          setUnitParameterValue( wrapper->parameterValue(), wrapper );
 
 1202            setUnitParameterValue( wrapper->parameterValue(), wrapper );
 
 1222  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 1223  if ( mProcessingContextGenerator )
 
 1224    context = mProcessingContextGenerator->processingContext();
 
 1228    tmpContext = std::make_unique< QgsProcessingContext >();
 
 1229    context = tmpContext.get();
 
 1248    mUnitsCombo->hide();
 
 1253    mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( 
static_cast< int >( units ) ) );
 
 1254    mUnitsCombo->show();
 
 1261QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
 const 
 1263  const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
 
 1264  if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
 
 1277  return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 1288  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 1289  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 1291  vlayout->addWidget( 
new QLabel( tr( 
"Minimum value" ) ) );
 
 1292  mMinLineEdit = 
new QLineEdit();
 
 1293  vlayout->addWidget( mMinLineEdit );
 
 1295  vlayout->addWidget( 
new QLabel( tr( 
"Maximum value" ) ) );
 
 1296  mMaxLineEdit = 
new QLineEdit();
 
 1297  vlayout->addWidget( mMaxLineEdit );
 
 1299  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 1300  mDefaultLineEdit = 
new QLineEdit();
 
 1301  vlayout->addWidget( mDefaultLineEdit );
 
 1303  vlayout->addWidget( 
new QLabel( tr( 
"Default unit type" ) ) );
 
 1305  mUnitsCombo = 
new QComboBox();
 
 1315  vlayout->addWidget( mUnitsCombo );
 
 1319    mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
 
 1320    mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
 
 1321    mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
 
 1322    mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( 
static_cast <int >( durationParam->defaultUnit() ) ) );
 
 1325  setLayout( vlayout );
 
 1333  auto param = std::make_unique< QgsProcessingParameterDuration >( name, description, ok ? val : QVariant() );
 
 1338    param->setMinimum( val );
 
 1344    param->setMaximum( val );
 
 1347  param->setDefaultUnit( 
static_cast<Qgis::TemporalUnit >( mUnitsCombo->currentData().toInt() ) );
 
 1349  param->setFlags( flags );
 
 1350  return param.release();
 
 1354  : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
 
 1359QString QgsProcessingDurationWidgetWrapper::parameterType()
 const 
 1366  return new QgsProcessingDurationWidgetWrapper( parameter, type );
 
 1369QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
 
 1373  QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
 
 1378      mUnitsCombo = 
new QComboBox();
 
 1390      QHBoxLayout *layout = 
new QHBoxLayout();
 
 1391      layout->addWidget( spin, 1 );
 
 1392      layout->insertWidget( 1, mUnitsCombo );
 
 1394      QWidget *w = 
new QWidget();
 
 1395      layout->setContentsMargins( 0, 0, 0, 0 );
 
 1396      w->setLayout( layout );
 
 1398      mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( 
static_cast< int >( durationDef->
defaultUnit() ) ) );
 
 1399      mUnitsCombo->show();
 
 1412QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
 
 1424QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
 const 
 1426  const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
 
 1427  if ( val.userType() == QMetaType::Type::Double && mUnitsCombo )
 
 1438void QgsProcessingDurationWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 1444    QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
 
 1448    QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
 
 1454  return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 1464  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 1465  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 1467  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 1469  mDefaultLineEdit = 
new QLineEdit();
 
 1473    mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
 
 1476  vlayout->addWidget( mDefaultLineEdit );
 
 1478  setLayout( vlayout );
 
 1484  double val = mDefaultLineEdit->text().toDouble( &ok );
 
 1485  auto param = std::make_unique< QgsProcessingParameterScale >( name, description, ok ? val : QVariant() );
 
 1487  return param.release();
 
 1491  : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
 
 1496QString QgsProcessingScaleWidgetWrapper::parameterType()
 const 
 1503  return new QgsProcessingScaleWidgetWrapper( parameter, type );
 
 1506QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
 
 1518        mScaleWidget->setAllowNull( 
true );
 
 1520      mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
 
 1521      mScaleWidget->setShowCurrentScaleButton( 
true );
 
 1523      mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
 
 1526        emit widgetValueHasChanged( 
this );
 
 1528      return mScaleWidget;
 
 1537    mScaleWidget->setMapCanvas( context.
mapCanvas() );
 
 1542QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
 const 
 1544  return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
 
 1547void QgsProcessingScaleWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 1551    if ( mScaleWidget->allowNull() && !value.isValid() )
 
 1552      mScaleWidget->setNull();
 
 1556      mScaleWidget->setScale( v );
 
 1563  return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 1574  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 1575  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 1577  vlayout->addWidget( 
new QLabel( tr( 
"Number type" ) ) );
 
 1579  mTypeComboBox = 
new QComboBox();
 
 1582  vlayout->addWidget( mTypeComboBox );
 
 1584  vlayout->addWidget( 
new QLabel( tr( 
"Minimum value" ) ) );
 
 1585  mMinLineEdit = 
new QLineEdit();
 
 1586  vlayout->addWidget( mMinLineEdit );
 
 1588  vlayout->addWidget( 
new QLabel( tr( 
"Maximum value" ) ) );
 
 1589  mMaxLineEdit = 
new QLineEdit();
 
 1590  vlayout->addWidget( mMaxLineEdit );
 
 1594    mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( 
static_cast< int >( rangeParam->dataType() ) ) );
 
 1596    mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
 
 1597    mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
 
 1600  setLayout( vlayout );
 
 1605  QString defaultValue;
 
 1606  if ( mMinLineEdit->text().isEmpty() )
 
 1608    defaultValue = QStringLiteral( 
"None" );
 
 1616      defaultValue = QStringLiteral( 
"None" );
 
 1620  if ( mMaxLineEdit->text().isEmpty() )
 
 1622    defaultValue += QLatin1String( 
",None" );
 
 1628    defaultValue += QStringLiteral( 
",%1" ).arg( ok ? QString::number( val ) : QLatin1String( 
"None" ) );
 
 1632  auto param = std::make_unique< QgsProcessingParameterRange >( name, description, dataType, defaultValue );
 
 1633  param->setFlags( flags );
 
 1634  return param.release();
 
 1644QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
 
 1653      QHBoxLayout *layout = 
new QHBoxLayout();
 
 1658      mMinSpinBox->setExpressionsEnabled( 
true );
 
 1659      mMinSpinBox->setShowClearButton( 
false );
 
 1660      mMaxSpinBox->setExpressionsEnabled( 
true );
 
 1661      mMaxSpinBox->setShowClearButton( 
false );
 
 1663      QLabel *minLabel = 
new QLabel( tr( 
"Min" ) );
 
 1664      layout->addWidget( minLabel );
 
 1665      layout->addWidget( mMinSpinBox, 1 );
 
 1667      QLabel *maxLabel = 
new QLabel( tr( 
"Max" ) );
 
 1668      layout->addWidget( maxLabel );
 
 1669      layout->addWidget( mMaxSpinBox, 1 );
 
 1671      QWidget *w = 
new QWidget();
 
 1672      layout->setContentsMargins( 0, 0, 0, 0 );
 
 1673      w->setLayout( layout );
 
 1677        mMinSpinBox->setDecimals( 6 );
 
 1678        mMaxSpinBox->setDecimals( 6 );
 
 1682        mMinSpinBox->setDecimals( 0 );
 
 1683        mMaxSpinBox->setDecimals( 0 );
 
 1686      mMinSpinBox->setMinimum( -99999999.999999 );
 
 1687      mMaxSpinBox->setMinimum( -99999999.999999 );
 
 1688      mMinSpinBox->setMaximum( 99999999.999999 );
 
 1689      mMaxSpinBox->setMaximum( 99999999.999999 );
 
 1693        mAllowingNull = 
true;
 
 1695        const double min = mMinSpinBox->minimum() - 1;
 
 1696        mMinSpinBox->setMinimum( min );
 
 1697        mMaxSpinBox->setMinimum( min );
 
 1698        mMinSpinBox->setValue( min );
 
 1699        mMaxSpinBox->setValue( min );
 
 1701        mMinSpinBox->setShowClearButton( 
true );
 
 1702        mMaxSpinBox->setShowClearButton( 
true );
 
 1703        mMinSpinBox->setSpecialValueText( tr( 
"Not set" ) );
 
 1704        mMaxSpinBox->setSpecialValueText( tr( 
"Not set" ) );
 
 1707      w->setToolTip( parameterDefinition()->toolTip() );
 
 1709      connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, [ = ]( 
const double v )
 
 1711        mBlockChangedSignal++;
 
 1712        if ( !mAllowingNull && v > mMaxSpinBox->value() )
 
 1713          mMaxSpinBox->setValue( v );
 
 1714        mBlockChangedSignal--;
 
 1716        if ( !mBlockChangedSignal )
 
 1717          emit widgetValueHasChanged( 
this );
 
 1719      connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, [ = ]( 
const double v )
 
 1721        mBlockChangedSignal++;
 
 1722        if ( !mAllowingNull && v < mMinSpinBox->value() )
 
 1723          mMinSpinBox->setValue( v );
 
 1724        mBlockChangedSignal--;
 
 1726        if ( !mBlockChangedSignal )
 
 1727          emit widgetValueHasChanged( 
this );
 
 1736void QgsProcessingRangeWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 1739  if ( mAllowingNull && v.empty() )
 
 1741    mMinSpinBox->clear();
 
 1742    mMaxSpinBox->clear();
 
 1749    if ( mAllowingNull )
 
 1751      mBlockChangedSignal++;
 
 1752      if ( std::isnan( v.at( 0 ) ) )
 
 1753        mMinSpinBox->clear();
 
 1755        mMinSpinBox->setValue( v.at( 0 ) );
 
 1757      if ( v.count() >= 2 )
 
 1759        if ( std::isnan( v.at( 1 ) ) )
 
 1760          mMaxSpinBox->clear();
 
 1762          mMaxSpinBox->setValue( v.at( 1 ) );
 
 1764      mBlockChangedSignal--;
 
 1768      mBlockChangedSignal++;
 
 1769      mMinSpinBox->setValue( v.at( 0 ) );
 
 1770      if ( v.count() >= 2 )
 
 1771        mMaxSpinBox->setValue( v.at( 1 ) );
 
 1772      mBlockChangedSignal--;
 
 1776  if ( !mBlockChangedSignal )
 
 1777    emit widgetValueHasChanged( 
this );
 
 1780QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
 const 
 1782  if ( mAllowingNull )
 
 1785    if ( 
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
 
 1786      value = QStringLiteral( 
"None" );
 
 1788      value = QString::number( mMinSpinBox->value() );
 
 1790    if ( 
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
 
 1791      value += QLatin1String( 
",None" );
 
 1793      value += QStringLiteral( 
",%1" ).arg( mMaxSpinBox->value() );
 
 1798    return QStringLiteral( 
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
 
 1801QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
 const 
 1803  return QStringList()
 
 1808QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
 const 
 1814QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
 const 
 1816  return tr( 
"string as two comma delimited floats, e.g. '1,10'" );
 
 1819QString QgsProcessingRangeWidgetWrapper::parameterType()
 const 
 1826  return new QgsProcessingRangeWidgetWrapper( parameter, type );
 
 1831  return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 1842  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 1843  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 1845  mMatrixWidget = 
new QgsProcessingMatrixModelerWidget();
 
 1848    mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
 
 1849    mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
 
 1851  vlayout->addWidget( mMatrixWidget );
 
 1852  setLayout( vlayout );
 
 1857  auto param = std::make_unique< QgsProcessingParameterMatrix >( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
 
 1858  param->setFlags( flags );
 
 1859  return param.release();
 
 1869QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
 
 1871  mMatrixWidget = 
new QgsProcessingMatrixParameterPanel( 
nullptr, 
dynamic_cast< const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
 
 1872  mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
 
 1874  connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed, 
this, [ = ]
 
 1876    emit widgetValueHasChanged( 
this );
 
 1885      return mMatrixWidget;
 
 1891void QgsProcessingMatrixWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 1894  if ( mMatrixWidget )
 
 1895    mMatrixWidget->setValue( v );
 
 1898QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
 const 
 1900  if ( mMatrixWidget )
 
 1901    return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
 
 1906QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
 const 
 1908  return QStringList()
 
 1912QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
 const 
 1914  return QStringList();
 
 1917QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
 const 
 1919  return tr( 
"comma delimited string of values, or an array of values" );
 
 1922QString QgsProcessingMatrixWidgetWrapper::parameterType()
 const 
 1929  return new QgsProcessingMatrixWidgetWrapper( parameter, type );
 
 1934  return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 1946  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 1947  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 1949  vlayout->addWidget( 
new QLabel( tr( 
"Type" ) ) );
 
 1951  mTypeComboBox = 
new QComboBox();
 
 1955    mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( 
static_cast< int >( fileParam->behavior() ) ) );
 
 1957    mTypeComboBox->setCurrentIndex( 0 );
 
 1958  vlayout->addWidget( mTypeComboBox );
 
 1960  vlayout->addWidget( 
new QLabel( tr( 
"File filter" ) ) );
 
 1962  mFilterComboBox = 
new QComboBox();
 
 1963  mFilterComboBox->setEditable( 
true );
 
 1965  mFilterComboBox->addItem( tr( 
"All Files (*.*)" ) );
 
 1966  mFilterComboBox->addItem( tr( 
"CSV Files (*.csv)" ) );
 
 1967  mFilterComboBox->addItem( tr( 
"HTML Files (*.html *.htm)" ) );
 
 1968  mFilterComboBox->addItem( tr( 
"Text Files (*.txt)" ) );
 
 1970    mFilterComboBox->setCurrentText( fileParam->fileFilter() );
 
 1972    mFilterComboBox->setCurrentIndex( 0 );
 
 1973  vlayout->addWidget( mFilterComboBox );
 
 1975  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 1978  mDefaultFileWidget->lineEdit()->setShowClearButton( 
true );
 
 1982    mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
 
 1986  vlayout->addWidget( mDefaultFileWidget );
 
 1988  connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [ = ]
 
 1997  setLayout( vlayout );
 
 2002  auto param = std::make_unique< QgsProcessingParameterFile >( name, description );
 
 2005    param->setFileFilter( mFilterComboBox->currentText() );
 
 2006  if ( !mDefaultFileWidget->filePath().isEmpty() )
 
 2007    param->setDefaultValue( mDefaultFileWidget->filePath() );
 
 2008  param->setFlags( flags );
 
 2009  return param.release();
 
 2019QWidget *QgsProcessingFileWidgetWrapper::createWidget()
 
 2029      mFileWidget->setToolTip( parameterDefinition()->toolTip() );
 
 2030      mFileWidget->setDialogTitle( parameterDefinition()->description() );
 
 2032      mFileWidget->setDefaultRoot( 
QgsSettings().value( QStringLiteral( 
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
 
 2039            mFileWidget->setFilter( fileParam->
fileFilter() );
 
 2040          else if ( !fileParam->
extension().isEmpty() )
 
 2041            mFileWidget->setFilter( tr( 
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral( 
" (*." ) + fileParam->
extension().toLower() + 
')' );
 
 2051        QgsSettings().
setValue( QStringLiteral( 
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
 
 2052        emit widgetValueHasChanged( 
this );
 
 2060void QgsProcessingFileWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 2064    mFileWidget->setFilePath( v );
 
 2067QVariant QgsProcessingFileWidgetWrapper::widgetValue()
 const 
 2070    return mFileWidget->filePath();
 
 2075QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
 const 
 2077  return QStringList()
 
 2082QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
 const 
 2093QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
 const 
 2095  return tr( 
"string representing a path to a file or folder" );
 
 2098QString QgsProcessingFileWidgetWrapper::parameterType()
 const 
 2105  return new QgsProcessingFileWidgetWrapper( parameter, type );
 
 2110  return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 2122  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 2123  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 2124  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 2127  mDefaultQgisLineEdit->registerExpressionContextGenerator( 
this );
 
 2129  mDefaultPointCloudLineEdit = 
new QgsProcessingPointCloudExpressionLineEdit();
 
 2130  mDefaultRasterCalculatorLineEdit = 
new QgsProcessingRasterCalculatorExpressionLineEdit();
 
 2132  QStackedWidget *stackedWidget = 
new QStackedWidget();
 
 2133  stackedWidget->addWidget( mDefaultQgisLineEdit );
 
 2134  stackedWidget->addWidget( mDefaultPointCloudLineEdit );
 
 2135  stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
 
 2136  vlayout->addWidget( stackedWidget );
 
 2141    mDefaultQgisLineEdit->setExpression( expr );
 
 2142    mDefaultPointCloudLineEdit->setExpression( expr );
 
 2145  vlayout->addWidget( 
new QLabel( tr( 
"Parent layer" ) ) );
 
 2147  mParentLayerComboBox = 
new QComboBox();
 
 2148  vlayout->addWidget( mParentLayerComboBox );
 
 2150  vlayout->addWidget( 
new QLabel( tr( 
"Expression type" ) ) );
 
 2151  mExpressionTypeComboBox = 
new QComboBox();
 
 2156  connect( mExpressionTypeComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, [ = ]( 
int )
 
 2158    mParentLayerComboBox->clear();
 
 2159    mParentLayerComboBox->addItem( tr( 
"None" ), QVariant() );
 
 2161    stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
 
 2163    QString initialParent;
 
 2165      initialParent = expParam->parentLayerParameterName();
 
 2169    if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
 
 2172      const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
 
 2173      for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 2180              mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 2181              if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 2183                mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 2188              mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 2189              if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 2191                mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 2198              mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 2199              if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 2201                mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 2212              mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 2213              if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 2215                mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 2223    if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
 
 2226      mParentLayerComboBox->addItem( initialParent, initialParent );
 
 2227      mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 2232  mExpressionTypeComboBox->setCurrentIndex( -1 );
 
 2234    mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData( 
static_cast< int >( expParam->expressionType() ) ) );
 
 2236    mExpressionTypeComboBox->setCurrentIndex( 0 );
 
 2238  vlayout->addWidget( mExpressionTypeComboBox );
 
 2240  setLayout( vlayout );
 
 2247  switch ( expressionType )
 
 2250      expression = mDefaultQgisLineEdit->expression();
 
 2253      expression = mDefaultPointCloudLineEdit->expression();
 
 2256      expression = mDefaultRasterCalculatorLineEdit->expression();
 
 2259  auto param = std::make_unique< QgsProcessingParameterExpression >( name, description, expression, mParentLayerComboBox->currentData().toString(), 
false, expressionType );
 
 2260  param->setFlags( flags );
 
 2261  return param.release();
 
 2270QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
 
 2282        mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
 
 2283        mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
 
 2284        mExpLineEdit->registerExpressionContextGenerator( 
this );
 
 2287          emit widgetValueHasChanged( 
this );
 
 2289        return mExpLineEdit;
 
 2295          mPointCloudExpLineEdit = 
new QgsProcessingPointCloudExpressionLineEdit();
 
 2296          mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
 
 2297          connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged, 
this, [ = ]( 
const QString & )
 
 2299            emit widgetValueHasChanged( 
this );
 
 2301          return mPointCloudExpLineEdit;
 
 2306          mRasterCalculatorExpLineEdit = 
new QgsProcessingRasterCalculatorExpressionLineEdit();
 
 2307          mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
 
 2310            mRasterCalculatorExpLineEdit->setLayers( QVariantList() << 
"A" << 
"B" << 
"C" << 
"D" << 
"E" << 
"F" << 
"G" );
 
 2312          connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged, 
this, [ = ]( 
const QString & )
 
 2314            emit widgetValueHasChanged( 
this );
 
 2316          return mRasterCalculatorExpLineEdit;
 
 2320        if ( expParam->
metadata().value( QStringLiteral( 
"inlineEditor" ) ).toBool() )
 
 2323          mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
 
 2324          mExpBuilderWidget->init( createExpressionContext() );
 
 2327            Q_UNUSED( changed );
 
 2328            emit widgetValueHasChanged( 
this );
 
 2330          return mExpBuilderWidget;
 
 2335          mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
 
 2336          mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
 
 2337          mFieldExpWidget->registerExpressionContextGenerator( 
this );
 
 2339            mFieldExpWidget->setAllowEmptyFieldName( 
true );
 
 2343            emit widgetValueHasChanged( 
this );
 
 2345          return mFieldExpWidget;
 
 2353void QgsProcessingExpressionWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 2365          setParentLayerWrapperValue( wrapper );
 
 2368            setParentLayerWrapperValue( wrapper );
 
 2384  if ( mExpBuilderWidget )
 
 2387    mExpBuilderWidget->setExpressionContext( createExpressionContext() );
 
 2395  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 2396  if ( mProcessingContextGenerator )
 
 2397    context = mProcessingContextGenerator->processingContext();
 
 2401    tmpContext = std::make_unique< QgsProcessingContext >();
 
 2402    context = tmpContext.get();
 
 2412      if ( val.userType() == QMetaType::type( 
"QgsProcessingFeatureSourceDefinition" ) )
 
 2422        if ( mFieldExpWidget )
 
 2423          mFieldExpWidget->setLayer( 
nullptr );
 
 2424        else if ( mExpBuilderWidget )
 
 2425          mExpBuilderWidget->setLayer( 
nullptr );
 
 2426        else if ( mExpLineEdit )
 
 2427          mExpLineEdit->setLayer( 
nullptr );
 
 2433      std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
 
 2436        mParentLayer.reset( ownedLayer.release() );
 
 2444      if ( mFieldExpWidget )
 
 2445        mFieldExpWidget->setLayer( layer );
 
 2446      if ( mExpBuilderWidget )
 
 2447        mExpBuilderWidget->setLayer( layer );
 
 2448      else if ( mExpLineEdit )
 
 2449        mExpLineEdit->setLayer( layer );
 
 2458        if ( mPointCloudExpLineEdit )
 
 2459          mPointCloudExpLineEdit->setLayer( 
nullptr );
 
 2465      std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
 
 2468        mParentLayer.reset( ownedLayer.release() );
 
 2476      if ( mPointCloudExpLineEdit )
 
 2477        mPointCloudExpLineEdit->setLayer( layer );
 
 2484      if ( layers.isEmpty() )
 
 2486        if ( mRasterCalculatorExpLineEdit )
 
 2488          mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
 
 2493      if ( mRasterCalculatorExpLineEdit )
 
 2495        QVariantList layersList;
 
 2498          layersList << layer->
name();
 
 2500        mRasterCalculatorExpLineEdit->setLayers( layersList );
 
 2508void QgsProcessingExpressionWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 2511  if ( mFieldExpWidget )
 
 2512    mFieldExpWidget->setExpression( v );
 
 2513  else if ( mExpBuilderWidget )
 
 2514    mExpBuilderWidget->setExpressionText( v );
 
 2515  else if ( mExpLineEdit )
 
 2516    mExpLineEdit->setExpression( v );
 
 2517  else if ( mPointCloudExpLineEdit )
 
 2518    mPointCloudExpLineEdit->setExpression( v );
 
 2519  else if ( mRasterCalculatorExpLineEdit )
 
 2520    mRasterCalculatorExpLineEdit->setExpression( v );
 
 2523QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
 const 
 2525  if ( mFieldExpWidget )
 
 2526    return mFieldExpWidget->expression();
 
 2527  if ( mExpBuilderWidget )
 
 2528    return mExpBuilderWidget->expressionText();
 
 2529  else if ( mExpLineEdit )
 
 2530    return mExpLineEdit->expression();
 
 2531  else if ( mPointCloudExpLineEdit )
 
 2532    return mPointCloudExpLineEdit->expression();
 
 2533  else if ( mRasterCalculatorExpLineEdit )
 
 2534    return mRasterCalculatorExpLineEdit->expression();
 
 2539QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
 const 
 2541  return QStringList()
 
 2550QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
 const 
 2552  return QStringList()
 
 2558QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
 const 
 2560  return tr( 
"string representation of an expression" );
 
 2563const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
 const 
 2565  if ( mFieldExpWidget && mFieldExpWidget->layer() )
 
 2566    return mFieldExpWidget->layer();
 
 2568  if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
 
 2569    return mExpBuilderWidget->layer();
 
 2574QString QgsProcessingExpressionWidgetWrapper::parameterType()
 const 
 2581  return new QgsProcessingExpressionWidgetWrapper( parameter, type );
 
 2586  return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 2599  QHBoxLayout *hl = 
new QHBoxLayout();
 
 2600  hl->setContentsMargins( 0, 0, 0, 0 );
 
 2602  mLineEdit = 
new QLineEdit();
 
 2603  mLineEdit->setEnabled( 
false );
 
 2604  hl->addWidget( mLineEdit, 1 );
 
 2606  mToolButton = 
new QToolButton();
 
 2607  mToolButton->setText( QString( QChar( 0x2026 ) ) );
 
 2608  hl->addWidget( mToolButton );
 
 2614    mLineEdit->setText( tr( 
"%1 options selected" ).arg( 0 ) );
 
 2617  connect( mToolButton, &QToolButton::clicked, 
this, &QgsProcessingEnumPanelWidget::showDialog );
 
 2620void QgsProcessingEnumPanelWidget::setValue( 
const QVariant &value )
 
 2622  if ( value.isValid() )
 
 2624    mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
 
 2626    if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
 
 2632  updateSummaryText();
 
 2636void QgsProcessingEnumPanelWidget::showDialog()
 
 2638  QVariantList availableOptions;
 
 2641    availableOptions.reserve( mParam->options().size() );
 
 2643    if ( mParam->usesStaticStrings() )
 
 2645      for ( QString o : mParam->options() )
 
 2647        availableOptions << o;
 
 2652      for ( 
int i = 0; i < mParam->options().count(); ++i )
 
 2653        availableOptions << i;
 
 2657  const QStringList options = mParam ? mParam->options() : QStringList();
 
 2661    QgsProcessingMultipleSelectionPanelWidget *widget = 
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
 
 2662    widget->setPanelTitle( mParam->description() );
 
 2664    if ( mParam->usesStaticStrings() )
 
 2666      widget->setValueFormatter( [options]( 
const QVariant & v ) -> QString
 
 2668        const QString i = v.toString();
 
 2669        return options.contains( i ) ? i : QString();
 
 2674      widget->setValueFormatter( [options]( 
const QVariant & v ) -> QString
 
 2676        const int i = v.toInt();
 
 2677        return options.size() > i ? options.at( i ) : QString();
 
 2681    connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged, 
this, [ = ]()
 
 2683      setValue( widget->selectedOptions() );
 
 2690    QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue, 
this, Qt::WindowFlags() );
 
 2692    dlg.setValueFormatter( [options]( 
const QVariant & v ) -> QString
 
 2694      const int i = v.toInt();
 
 2695      return options.size() > i ? options.at( i ) : QString();
 
 2699      setValue( dlg.selectedOptions() );
 
 2704void QgsProcessingEnumPanelWidget::updateSummaryText()
 
 2709  if ( mValue.empty() )
 
 2711    mLineEdit->setText( tr( 
"%1 options selected" ).arg( 0 ) );
 
 2716    values.reserve( mValue.size() );
 
 2717    if ( mParam->usesStaticStrings() )
 
 2719      for ( 
const QVariant &val : std::as_const( mValue ) )
 
 2721        values << val.toString();
 
 2726      const QStringList options = mParam->options();
 
 2727      for ( 
const QVariant &val : std::as_const( mValue ) )
 
 2729        const int i = val.toInt();
 
 2730        values << ( options.size() > i ? options.at( i ) : QString() );
 
 2734    const QString concatenated = values.join( tr( 
"," ) );
 
 2735    if ( concatenated.length() < 100 )
 
 2736      mLineEdit->setText( concatenated );
 
 2738      mLineEdit->setText( tr( 
"%n option(s) selected", 
nullptr, mValue.count() ) );
 
 2746QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent, 
const QgsProcessingParameterEnum *param, 
int columns )
 
 2749  , mButtonGroup( new QButtonGroup( this ) )
 
 2750  , mColumns( columns )
 
 2752  mButtonGroup->setExclusive( !mParam->allowMultiple() );
 
 2754  QGridLayout *l = 
new QGridLayout();
 
 2755  l->setContentsMargins( 0, 0, 0, 0 );
 
 2757  int rows = 
static_cast< int >( std::ceil( mParam->options().count() / 
static_cast< double >( mColumns ) ) );
 
 2758  for ( 
int i = 0; i < mParam->options().count(); ++i )
 
 2760    QAbstractButton *button = 
nullptr;
 
 2761    if ( mParam->allowMultiple() )
 
 2762      button = 
new QCheckBox( mParam->options().at( i ) );
 
 2764      button = 
new QRadioButton( mParam->options().at( i ) );
 
 2766    connect( button, &QAbstractButton::toggled, 
this, [ = ]
 
 2768      if ( !mBlockChangedSignal )
 
 2772    mButtons.insert( i, button );
 
 2774    mButtonGroup->addButton( button, i );
 
 2775    l->addWidget( button, i % rows, i / rows );
 
 2777  l->addItem( 
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
 
 2780  if ( mParam->allowMultiple() )
 
 2782    setContextMenuPolicy( Qt::CustomContextMenu );
 
 2783    connect( 
this, &QWidget::customContextMenuRequested, 
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
 
 2787QVariant QgsProcessingEnumCheckboxPanelWidget::value()
 const 
 2789  if ( mParam->allowMultiple() )
 
 2792    for ( 
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
 
 2794      if ( it.value()->isChecked() )
 
 2795        value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
 
 2801    if ( mParam->usesStaticStrings() )
 
 2802      return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
 
 2804      return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
 
 2808void QgsProcessingEnumCheckboxPanelWidget::setValue( 
const QVariant &value )
 
 2810  mBlockChangedSignal = 
true;
 
 2811  if ( mParam->allowMultiple() )
 
 2813    QVariantList selected;
 
 2814    if ( value.isValid() )
 
 2815      selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
 
 2816    for ( 
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
 
 2818      QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
 
 2819      it.value()->setChecked( selected.contains( v ) );
 
 2825    if ( v.userType() == QMetaType::Type::QVariantList )
 
 2826      v = v.toList().value( 0 );
 
 2828    v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
 
 2829    if ( mButtons.contains( v ) )
 
 2830      mButtons.value( v )->setChecked( 
true );
 
 2832  mBlockChangedSignal = 
false;
 
 2836void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
 
 2839  QAction *selectAllAction = 
new QAction( tr( 
"Select All" ), &popupMenu );
 
 2840  connect( selectAllAction, &QAction::triggered, 
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
 
 2841  QAction *clearAllAction = 
new QAction( tr( 
"Clear Selection" ), &popupMenu );
 
 2842  connect( clearAllAction, &QAction::triggered, 
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
 
 2843  popupMenu.addAction( selectAllAction );
 
 2844  popupMenu.addAction( clearAllAction );
 
 2845  popupMenu.exec( QCursor::pos() );
 
 2848void QgsProcessingEnumCheckboxPanelWidget::selectAll()
 
 2850  mBlockChangedSignal = 
true;
 
 2851  for ( 
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
 
 2852    it.value()->setChecked( 
true );
 
 2853  mBlockChangedSignal = 
false;
 
 2857void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
 
 2859  mBlockChangedSignal = 
true;
 
 2860  for ( 
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
 
 2861    it.value()->setChecked( 
false );
 
 2862  mBlockChangedSignal = 
false;
 
 2874  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 2875  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 2877  mEnumWidget = 
new QgsProcessingEnumModelerWidget();
 
 2880    mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
 
 2881    mEnumWidget->setOptions( enumParam->options() );
 
 2882    mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
 
 2884  vlayout->addWidget( mEnumWidget );
 
 2885  setLayout( vlayout );
 
 2890  auto param = std::make_unique< QgsProcessingParameterEnum >( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
 
 2892  return param.release();
 
 2902QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
 
 2910      if ( expParam->
metadata().value( QStringLiteral( 
"widget_wrapper" ) ).toMap().value( QStringLiteral( 
"useCheckBoxes" ), 
false ).toBool() )
 
 2912        const int columns = expParam->
metadata().value( QStringLiteral( 
"widget_wrapper" ) ).toMap().value( QStringLiteral( 
"columns" ), 2 ).toInt();
 
 2913        mCheckboxPanel = 
new QgsProcessingEnumCheckboxPanelWidget( 
nullptr, expParam, columns );
 
 2914        mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
 
 2915        connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed, 
this, [ = ]
 
 2917          emit widgetValueHasChanged( 
this );
 
 2919        return mCheckboxPanel;
 
 2928        mPanel = 
new QgsProcessingEnumPanelWidget( 
nullptr, expParam );
 
 2929        mPanel->setToolTip( parameterDefinition()->toolTip() );
 
 2930        connect( mPanel, &QgsProcessingEnumPanelWidget::changed, 
this, [ = ]
 
 2932          emit widgetValueHasChanged( 
this );
 
 2938        mComboBox = 
new QComboBox();
 
 2941          mComboBox->addItem( tr( 
"[Not selected]" ), QVariant() );
 
 2942        const QStringList options = expParam->
options();
 
 2943        const QVariantList iconList = expParam->
metadata().value( QStringLiteral( 
"widget_wrapper" ) ).toMap().value( QStringLiteral( 
"icons" ) ).toList();
 
 2944        for ( 
int i = 0; i < options.count(); ++i )
 
 2946          const QIcon icon = iconList.value( i ).value< QIcon >();
 
 2949            mComboBox->addItem( icon, options.at( i ), options.at( i ) );
 
 2951            mComboBox->addItem( icon, options.at( i ), i );
 
 2954        mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 2955        mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
 
 2956        connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [ = ]( 
int )
 
 2958          emit widgetValueHasChanged( 
this );
 
 2967void QgsProcessingEnumWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 2971    if ( !value.isValid() )
 
 2972      mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
 
 2979        mComboBox->setCurrentIndex( mComboBox->findData( v ) );
 
 2984        mComboBox->setCurrentIndex( mComboBox->findData( v ) );
 
 2988  else if ( mPanel || mCheckboxPanel )
 
 2991    if ( value.isValid() )
 
 2997        opts.reserve( v.size() );
 
 2998        for ( QString i : v )
 
 3004        opts.reserve( v.size() );
 
 3010      mPanel->setValue( opts );
 
 3011    else if ( mCheckboxPanel )
 
 3012      mCheckboxPanel->setValue( opts );
 
 3016QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
 const 
 3019    return mComboBox->currentData();
 
 3021    return mPanel->value();
 
 3022  else if ( mCheckboxPanel )
 
 3023    return mCheckboxPanel->value();
 
 3028QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
 const 
 3030  return QStringList()
 
 3036QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
 const 
 3038  return QStringList()
 
 3044QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
 const 
 3046  return tr( 
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
 
 3049QString QgsProcessingEnumWidgetWrapper::parameterType()
 const 
 3056  return new QgsProcessingEnumWidgetWrapper( parameter, type );
 
 3061  return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 3074QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
 
 3083      mComboBox = 
new QgsLayoutComboBox( 
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() : nullptr );
 
 3088      mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 3091        emit widgetValueHasChanged( 
this );
 
 3098      mPlainComboBox = 
new QComboBox();
 
 3099      mPlainComboBox->setEditable( 
true );
 
 3100      mPlainComboBox->setToolTip( tr( 
"Name of an existing print layout" ) );
 
 3101      if ( widgetContext().project() )
 
 3105          mPlainComboBox->addItem( layout->name() );
 
 3108      connect( mPlainComboBox, &QComboBox::currentTextChanged, 
this, [ = ]( 
const QString & )
 
 3110        emit widgetValueHasChanged( 
this );
 
 3112      return mPlainComboBox;
 
 3118void QgsProcessingLayoutWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 3122    if ( !value.isValid() )
 
 3123      mComboBox->setCurrentLayout( 
nullptr );
 
 3127        mComboBox->setCurrentLayout( l );
 
 3129        mComboBox->setCurrentLayout( 
nullptr );
 
 3132  else if ( mPlainComboBox )
 
 3135    mPlainComboBox->setCurrentText( v );
 
 3139QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
 const 
 3144    return l ? l->
name() : QVariant();
 
 3146  else if ( mPlainComboBox )
 
 3147    return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
 
 3155  if ( mPlainComboBox && context.
project() )
 
 3159      mPlainComboBox->addItem( layout->name() );
 
 3163QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
 const 
 3165  return QStringList()
 
 3170QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
 const 
 3172  return QStringList()
 
 3177QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
 const 
 3179  return tr( 
"string representing the name of an existing print layout" );
 
 3182QString QgsProcessingLayoutWidgetWrapper::parameterType()
 const 
 3189  return new QgsProcessingLayoutWidgetWrapper( parameter, type );
 
 3203  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 3204  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 3206  vlayout->addWidget( 
new QLabel( tr( 
"Parent layout" ) ) );
 
 3208  mParentLayoutComboBox = 
new QComboBox();
 
 3209  QString initialParent;
 
 3211    initialParent = itemParam->parentLayoutParameterName();
 
 3213  if ( 
auto *lModel = widgetContext.
model() )
 
 3216    const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
 
 3217    for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 3221        mParentLayoutComboBox-> addItem( definition->
description(), definition->
name() );
 
 3222        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 3224          mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
 
 3230  if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
 
 3233    mParentLayoutComboBox->addItem( initialParent, initialParent );
 
 3234    mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
 
 3237  vlayout->addWidget( mParentLayoutComboBox );
 
 3238  setLayout( vlayout );
 
 3242  auto param = std::make_unique< QgsProcessingParameterLayoutItem >( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
 
 3244  return param.release();
 
 3254QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
 
 3265        mComboBox->setAllowEmptyItem( 
true );
 
 3266      if ( layoutParam->
itemType() >= 0 )
 
 3269      mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 3272        emit widgetValueHasChanged( 
this );
 
 3279      mLineEdit = 
new QLineEdit();
 
 3280      mLineEdit->setToolTip( tr( 
"UUID or ID of an existing print layout item" ) );
 
 3281      connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]( 
const QString & )
 
 3283        emit widgetValueHasChanged( 
this );
 
 3291void QgsProcessingLayoutItemWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 3319void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue( 
const QVariant &value )
 
 3325  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 3326  if ( mProcessingContextGenerator )
 
 3327    context = mProcessingContextGenerator->processingContext();
 
 3331    tmpContext = std::make_unique< QgsProcessingContext >();
 
 3332    context = tmpContext.get();
 
 3336  setLayout( layout );
 
 3339void QgsProcessingLayoutItemWidgetWrapper::setLayout( 
QgsPrintLayout *layout )
 
 3342    mComboBox->setCurrentLayout( layout );
 
 3345void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 3349    if ( !value.isValid() )
 
 3350      mComboBox->setItem( 
nullptr );
 
 3354      mComboBox->setItem( item );
 
 3357  else if ( mLineEdit )
 
 3360    mLineEdit->setText( v );
 
 3364QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
 const 
 3369    return i ? i->
uuid() : QVariant();
 
 3371  else if ( mLineEdit )
 
 3372    return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
 
 3377QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
 const 
 3379  return QStringList()
 
 3384QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
 const 
 3386  return QStringList()
 
 3391QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
 const 
 3393  return tr( 
"string representing the UUID or ID of an existing print layout item" );
 
 3396QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
 const 
 3403  return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
 
 3408  return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 3415QgsProcessingPointMapTool::QgsProcessingPointMapTool( 
QgsMapCanvas *canvas )
 
 3422QgsProcessingPointMapTool::~QgsProcessingPointMapTool() = 
default;
 
 3424void QgsProcessingPointMapTool::deactivate()
 
 3438  if ( e->button() == Qt::LeftButton )
 
 3441    emit clicked( point );
 
 3446void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
 
 3448  if ( e->key() == Qt::Key_Escape )
 
 3463QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
 
 3466  QHBoxLayout *l = 
new QHBoxLayout();
 
 3467  l->setContentsMargins( 0, 0, 0, 0 );
 
 3469  mLineEdit->setShowClearButton( 
false );
 
 3470  l->addWidget( mLineEdit, 1 );
 
 3471  mButton = 
new QToolButton();
 
 3472  mButton->setText( QString( QChar( 0x2026 ) ) );
 
 3473  l->addWidget( mButton );
 
 3476  connect( mLineEdit, &QLineEdit::textChanged, 
this, &QgsProcessingPointPanel::changed );
 
 3477  connect( mLineEdit, &QLineEdit::textChanged, 
this, &QgsProcessingPointPanel::textChanged );
 
 3478  connect( mButton, &QToolButton::clicked, 
this, &QgsProcessingPointPanel::selectOnCanvas );
 
 3479  mButton->setVisible( 
false );
 
 3482void QgsProcessingPointPanel::setMapCanvas( 
QgsMapCanvas *canvas )
 
 3485  mButton->setVisible( 
true );
 
 3488  mTool = std::make_unique< QgsProcessingPointMapTool >( mCanvas );
 
 3489  connect( mTool.get(), &QgsProcessingPointMapTool::clicked, 
this, &QgsProcessingPointPanel::updatePoint );
 
 3490  connect( mTool.get(), &QgsProcessingPointMapTool::complete, 
this, &QgsProcessingPointPanel::pointPicked );
 
 3493void QgsProcessingPointPanel::setAllowNull( 
bool allowNull )
 
 3495  mLineEdit->setShowClearButton( allowNull );
 
 3498void QgsProcessingPointPanel::setShowPointOnCanvas( 
bool show )
 
 3500  if ( mShowPointOnCanvas == show )
 
 3503  mShowPointOnCanvas = show;
 
 3504  if ( mShowPointOnCanvas )
 
 3510    mMapPointRubberBand.reset();
 
 3514QVariant QgsProcessingPointPanel::value()
 const 
 3516  return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
 
 3519void QgsProcessingPointPanel::clear()
 
 3527  QString newText = QStringLiteral( 
"%1,%2" )
 
 3528                    .arg( QString::number( point.
x(), 
'f' ),
 
 3529                          QString::number( point.
y(), 
'f' ) );
 
 3532  if ( mCrs.isValid() )
 
 3534    newText += QStringLiteral( 
" [%1]" ).arg( mCrs.authid() );
 
 3536  mLineEdit->setText( newText );
 
 3540void QgsProcessingPointPanel::selectOnCanvas()
 
 3545  mPrevTool = mCanvas->mapTool();
 
 3546  mCanvas->setMapTool( mTool.get() );
 
 3548  emit toggleDialogVisibility( 
false );
 
 3551void QgsProcessingPointPanel::updatePoint( 
const QgsPointXY &point )
 
 3553  setValue( point, mCanvas->mapSettings().destinationCrs() );
 
 3556void QgsProcessingPointPanel::pointPicked()
 
 3561  mCanvas->setMapTool( mPrevTool );
 
 3563  emit toggleDialogVisibility( 
true );
 
 3566void QgsProcessingPointPanel::textChanged( 
const QString &text )
 
 3568  const thread_local QRegularExpression rx( QStringLiteral( 
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
 
 3570  const QRegularExpressionMatch match = rx.match( text );
 
 3571  if ( match.hasMatch() )
 
 3574    const double x = match.captured( 1 ).toDouble( &xOk );
 
 3576    const double y = match.captured( 2 ).toDouble( &yOk );
 
 3583      if ( pointCrs.isValid() )
 
 3601void QgsProcessingPointPanel::updateRubberBand()
 
 3603  if ( !mShowPointOnCanvas || !mCanvas )
 
 3606  if ( mPoint.isEmpty() )
 
 3608    mMapPointRubberBand.reset();
 
 3612  if ( !mMapPointRubberBand )
 
 3615    mMapPointRubberBand->setZValue( 1000 );
 
 3618    const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
 
 3619    mMapPointRubberBand->setWidth( scaleFactor );
 
 3620    mMapPointRubberBand->setIconSize( scaleFactor * 5 );
 
 3622    mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
 
 3623    mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
 
 3637  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 3638  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 3640  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 3642  mDefaultLineEdit = 
new QLineEdit();
 
 3643  mDefaultLineEdit->setToolTip( tr( 
"Point as 'x,y'" ) );
 
 3644  mDefaultLineEdit->setPlaceholderText( tr( 
"Point as 'x,y'" ) );
 
 3648    mDefaultLineEdit->setText( QStringLiteral( 
"%1,%2" ).arg( QString::number( point.
x(), 
'f' ), QString::number( point.
y(), 
'f' ) ) );
 
 3651  vlayout->addWidget( mDefaultLineEdit );
 
 3652  setLayout( vlayout );
 
 3657  auto param = std::make_unique< QgsProcessingParameterPoint >( name, description, mDefaultLineEdit->text() );
 
 3659  return param.release();
 
 3668QWidget *QgsProcessingPointWidgetWrapper::createWidget()
 
 3676      mPanel = 
new QgsProcessingPointPanel( 
nullptr );
 
 3677      if ( widgetContext().mapCanvas() )
 
 3678        mPanel->setMapCanvas( widgetContext().mapCanvas() );
 
 3681        mPanel->setAllowNull( 
true );
 
 3684        mPanel->setShowPointOnCanvas( 
true );
 
 3686      mPanel->setToolTip( parameterDefinition()->toolTip() );
 
 3688      connect( mPanel, &QgsProcessingPointPanel::changed, 
this, [ = ]
 
 3690        emit widgetValueHasChanged( 
this );
 
 3694        setDialog( mDialog ); 
 
 3700      mLineEdit = 
new QLineEdit();
 
 3701      mLineEdit->setToolTip( tr( 
"Point as 'x,y'" ) );
 
 3702      connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]( 
const QString & )
 
 3704        emit widgetValueHasChanged( 
this );
 
 3716    mPanel->setMapCanvas( context.
mapCanvas() );
 
 3719void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
 
 3724    connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ]( 
bool visible )
 
 3727        mDialog->showMinimized();
 
 3730        mDialog->showNormal();
 
 3732        mDialog->activateWindow();
 
 3739void QgsProcessingPointWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 3743    if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
 
 3749      mPanel->setValue( p, 
crs );
 
 3752  else if ( mLineEdit )
 
 3755    mLineEdit->setText( v );
 
 3759QVariant QgsProcessingPointWidgetWrapper::widgetValue()
 const 
 3763    return mPanel->value();
 
 3765  else if ( mLineEdit )
 
 3766    return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
 
 3771QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
 const 
 3773  return QStringList()
 
 3778QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
 const 
 3780  return QStringList()
 
 3785QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
 const 
 3787  return tr( 
"string of the format 'x,y' or a geometry value (centroid is used)" );
 
 3790QString QgsProcessingPointWidgetWrapper::parameterType()
 const 
 3797  return new QgsProcessingPointWidgetWrapper( parameter, type );
 
 3802  return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 3814  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 3815  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 3817  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 3819  mDefaultLineEdit = 
new QLineEdit();
 
 3820  mDefaultLineEdit->setToolTip( tr( 
"Geometry as WKT" ) );
 
 3821  mDefaultLineEdit->setPlaceholderText( tr( 
"Geometry as WKT" ) );
 
 3826      mDefaultLineEdit->setText( g.
asWkt() );
 
 3829  vlayout->addWidget( mDefaultLineEdit );
 
 3830  setLayout( vlayout );
 
 3835  auto param = std::make_unique< QgsProcessingParameterGeometry >( name, description, mDefaultLineEdit->text() );
 
 3837  return param.release();
 
 3846QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
 
 3854      mLineEdit = 
new QLineEdit();
 
 3855      mLineEdit->setToolTip( parameterDefinition()->toolTip() );
 
 3856      connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
 
 3858        emit widgetValueHasChanged( 
this );
 
 3866void QgsProcessingGeometryWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 3872      mLineEdit->setText( g.
asWkt() );
 
 3878QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
 const 
 3881    return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
 
 3886QStringList QgsProcessingGeometryWidgetWrapper::compatibleParameterTypes()
 const 
 3888  return QStringList()
 
 3895QStringList QgsProcessingGeometryWidgetWrapper::compatibleOutputTypes()
 const 
 3897  return QStringList()
 
 3902QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
 const 
 3904  return tr( 
"string in the Well-Known-Text format or a geometry value" );
 
 3907QString QgsProcessingGeometryWidgetWrapper::parameterType()
 const 
 3914  return new QgsProcessingGeometryWidgetWrapper( parameter, type );
 
 3919  return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 3931  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 3932  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 3934  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 3937  mDefaultColorButton->setShowNull( 
true );
 
 3938  mAllowOpacity = 
new QCheckBox( tr( 
"Allow opacity control" ) );
 
 3944      mDefaultColorButton->setToNull();
 
 3946      mDefaultColorButton->setColor( 
c );
 
 3947    mAllowOpacity->setChecked( colorParam->opacityEnabled() );
 
 3951    mDefaultColorButton->setToNull();
 
 3952    mAllowOpacity->setChecked( 
true );
 
 3955  vlayout->addWidget( mDefaultColorButton );
 
 3956  vlayout->addWidget( mAllowOpacity );
 
 3957  setLayout( vlayout );
 
 3962  auto param = std::make_unique< QgsProcessingParameterColor >( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
 
 3964  return param.release();
 
 3973QWidget *QgsProcessingColorWidgetWrapper::createWidget()
 
 3983      mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
 
 3986        mColorButton->setShowNull( 
true );
 
 3989      mColorButton->setToolTip( parameterDefinition()->toolTip() );
 
 3990      mColorButton->setColorDialogTitle( parameterDefinition()->description() );
 
 3998        emit widgetValueHasChanged( 
this );
 
 4001      return mColorButton;
 
 4007void QgsProcessingColorWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 4011    if ( !value.isValid() ||
 
 4012         ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() )
 
 4013         || ( value.userType() == QMetaType::Type::QColor && !value.value< QColor >().isValid() ) )
 
 4014      mColorButton->setToNull();
 
 4018      if ( !
c.isValid() && mColorButton->showNull() )
 
 4019        mColorButton->setToNull();
 
 4021        mColorButton->setColor( 
c );
 
 4026QVariant QgsProcessingColorWidgetWrapper::widgetValue()
 const 
 4029    return mColorButton->isNull() ? QVariant() : mColorButton->color();
 
 4034QStringList QgsProcessingColorWidgetWrapper::compatibleParameterTypes()
 const 
 4036  return QStringList()
 
 4041QStringList QgsProcessingColorWidgetWrapper::compatibleOutputTypes()
 const 
 4043  return QStringList()
 
 4048QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
 const 
 4050  return tr( 
"color style string, e.g. #ff0000 or 255,0,0" );
 
 4053QString QgsProcessingColorWidgetWrapper::parameterType()
 const 
 4060  return new QgsProcessingColorWidgetWrapper( parameter, type );
 
 4065  return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 4076  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 4077  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 4079  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 4081  mDefaultLineEdit = 
new QLineEdit();
 
 4084  vlayout->addWidget( mDefaultLineEdit );
 
 4086  mSourceParamComboBox = 
new QComboBox();
 
 4087  mDestParamComboBox = 
new QComboBox();
 
 4088  QString initialSource;
 
 4089  QString initialDest;
 
 4094    initialSource = itemParam->sourceCrsParameterName();
 
 4095    initialDest = itemParam->destinationCrsParameterName();
 
 4100  mSourceParamComboBox->addItem( QString(), QString() );
 
 4101  mDestParamComboBox->addItem( QString(), QString() );
 
 4102  if ( 
auto *lModel = widgetContext.
model() )
 
 4105    const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
 
 4106    for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 4108      if ( definition && it->parameterName() == definition->
name() )
 
 4112      mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
 
 4113      mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
 
 4114      if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
 
 4116        mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
 
 4118      if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
 
 4120        mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
 
 4125  if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
 
 4128    mSourceParamComboBox->addItem( initialSource, initialSource );
 
 4129    mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
 
 4131  if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
 
 4134    mDestParamComboBox->addItem( initialDest, initialDest );
 
 4135    mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
 
 4138  vlayout->addWidget( 
new QLabel( tr( 
"Source CRS parameter" ) ) );
 
 4139  vlayout->addWidget( mSourceParamComboBox );
 
 4140  vlayout->addWidget( 
new QLabel( tr( 
"Destination CRS parameter" ) ) );
 
 4141  vlayout->addWidget( mDestParamComboBox );
 
 4145  mStaticSourceWidget->setCrs( sourceCrs );
 
 4148  mStaticDestWidget->setCrs( destCrs );
 
 4150  vlayout->addWidget( 
new QLabel( tr( 
"Static source CRS" ) ) );
 
 4151  vlayout->addWidget( mStaticSourceWidget );
 
 4152  vlayout->addWidget( 
new QLabel( tr( 
"Static destination CRS" ) ) );
 
 4153  vlayout->addWidget( mStaticDestWidget );
 
 4155  setLayout( vlayout );
 
 4160  auto param = std::make_unique< QgsProcessingParameterCoordinateOperation >( name, description, mDefaultLineEdit->text(),
 
 4161               mSourceParamComboBox->currentText(),
 
 4162               mDestParamComboBox->currentText(),
 
 4163               mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
 
 4164               mStaticDestWidget->
crs().isValid() ? QVariant::fromValue( mStaticDestWidget->
crs() ) : QVariant() );
 
 4166  return param.release();
 
 4175QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
 
 4186      mOperationWidget->setShowMakeDefault( 
false );
 
 4187      mOperationWidget->setShowFallbackOption( 
false );
 
 4188      mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
 
 4189      mOperationWidget->setSourceCrs( mSourceCrs );
 
 4190      mOperationWidget->setDestinationCrs( mDestCrs );
 
 4191      mOperationWidget->setMapCanvas( mCanvas );
 
 4196        mOperationWidget->setSelectedOperation( deets );
 
 4201        emit widgetValueHasChanged( 
this );
 
 4204      return mOperationWidget;
 
 4210      mLineEdit = 
new QLineEdit();
 
 4211      QHBoxLayout *layout = 
new QHBoxLayout();
 
 4212      layout->addWidget( mLineEdit, 1 );
 
 4213      connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
 
 4215        emit widgetValueHasChanged( 
this );
 
 4218      QToolButton *button = 
new QToolButton();
 
 4219      button->setText( QString( QChar( 0x2026 ) ) );
 
 4220      connect( button, &QToolButton::clicked, 
this, [ = ]
 
 4222        QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs, 
false, 
false, 
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
 
 4225          mLineEdit->setText( dlg.selectedDatumTransform().proj );
 
 4226          emit widgetValueHasChanged( 
this );
 
 4229      layout->addWidget( button );
 
 4231      QWidget *w = 
new QWidget();
 
 4232      layout->setContentsMargins( 0, 0, 0, 0 );
 
 4233      w->setLayout( layout );
 
 4241void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 4279  if ( mOperationWidget )
 
 4280    mOperationWidget->setMapCanvas( context.
mapCanvas() );
 
 4283void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext & )
 
 4285  if ( mOperationWidget )
 
 4287    if ( !value.isValid() ||
 
 4288         ( value.userType() == QMetaType::Type::QString ) )
 
 4291      deets.
proj = value.toString();
 
 4292      mOperationWidget->setSelectedOperation( deets );
 
 4297    if ( !value.isValid() ||
 
 4298         ( value.userType() == QMetaType::Type::QString ) )
 
 4300      mLineEdit->setText( value.toString() );
 
 4305QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
 const 
 4307  if ( mOperationWidget )
 
 4308    return mOperationWidget->selectedOperation().proj;
 
 4309  else if ( mLineEdit )
 
 4310    return mLineEdit->text();
 
 4315QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleParameterTypes()
 const 
 4317  return QStringList()
 
 4322QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleOutputTypes()
 const 
 4324  return QStringList()
 
 4329QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
 const 
 4331  return tr( 
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
 
 4334void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue( 
const QVariant &value )
 
 4337  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 4338  if ( mProcessingContextGenerator )
 
 4339    context = mProcessingContextGenerator->processingContext();
 
 4343    tmpContext = std::make_unique< QgsProcessingContext >();
 
 4344    context = tmpContext.get();
 
 4348  if ( mOperationWidget )
 
 4350    mOperationWidget->setSourceCrs( mSourceCrs );
 
 4351    mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
 
 4355void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue( 
const QVariant &value )
 
 4358  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 4359  if ( mProcessingContextGenerator )
 
 4360    context = mProcessingContextGenerator->processingContext();
 
 4364    tmpContext = std::make_unique< QgsProcessingContext >();
 
 4365    context = tmpContext.get();
 
 4369  if ( mOperationWidget )
 
 4371    mOperationWidget->setDestinationCrs( mDestCrs );
 
 4372    mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
 
 4376QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
 const 
 4383  return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
 
 4388  return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 4401  QHBoxLayout *hl = 
new QHBoxLayout();
 
 4402  hl->setContentsMargins( 0, 0, 0, 0 );
 
 4404  mLineEdit = 
new QLineEdit();
 
 4405  mLineEdit->setEnabled( 
false );
 
 4406  hl->addWidget( mLineEdit, 1 );
 
 4408  mToolButton = 
new QToolButton();
 
 4409  mToolButton->setText( QString( QChar( 0x2026 ) ) );
 
 4410  hl->addWidget( mToolButton );
 
 4416    mLineEdit->setText( tr( 
"%n field(s) selected", 
nullptr, 0 ) );
 
 4419  connect( mToolButton, &QToolButton::clicked, 
this, &QgsProcessingFieldPanelWidget::showDialog );
 
 4422void QgsProcessingFieldPanelWidget::setFields( 
const QgsFields &fields )
 
 4427void QgsProcessingFieldPanelWidget::setValue( 
const QVariant &value )
 
 4429  if ( value.isValid() )
 
 4430    mValue = value.userType() == QMetaType::Type::QVariantList ? value.
toList() : QVariantList() << value;
 
 4434  updateSummaryText();
 
 4438void QgsProcessingFieldPanelWidget::showDialog()
 
 4440  QVariantList availableOptions;
 
 4441  availableOptions.reserve( mFields.size() );
 
 4442  for ( 
const QgsField &field : std::as_const( mFields ) )
 
 4444    availableOptions << field.name();
 
 4450    QgsProcessingMultipleSelectionPanelWidget *widget = 
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
 
 4451    widget->setPanelTitle( mParam->description() );
 
 4453    widget->setValueFormatter( []( 
const QVariant & v ) -> QString
 
 4455      return v.toString();
 
 4458    connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged, 
this, [ = ]()
 
 4460      setValue( widget->selectedOptions() );
 
 4467    QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue, 
this, Qt::WindowFlags() );
 
 4469    dlg.setValueFormatter( []( 
const QVariant & v ) -> QString
 
 4471      return v.toString();
 
 4475      setValue( dlg.selectedOptions() );
 
 4480void QgsProcessingFieldPanelWidget::updateSummaryText()
 
 4485  if ( mValue.empty() )
 
 4487    mLineEdit->setText( tr( 
"%n field(s) selected", 
nullptr, 0 ) );
 
 4492    values.reserve( mValue.size() );
 
 4493    for ( 
const QVariant &val : std::as_const( mValue ) )
 
 4495      values << val.toString();
 
 4498    const QString concatenated = values.join( tr( 
"," ) );
 
 4499    if ( concatenated.length() < 100 )
 
 4500      mLineEdit->setText( concatenated );
 
 4502      mLineEdit->setText( tr( 
"%n field(s) selected", 
nullptr, mValue.count() ) );
 
 4514  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 4515  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 4517  vlayout->addWidget( 
new QLabel( tr( 
"Parent layer" ) ) );
 
 4518  mParentLayerComboBox = 
new QComboBox();
 
 4520  QString initialParent;
 
 4522    initialParent = fieldParam->parentLayerParameterName();
 
 4524  if ( 
auto *lModel = widgetContext.
model() )
 
 4527    const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
 
 4528    for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 4532        mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 4533        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 4535          mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 4540        mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 4541        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 4543          mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 4550          mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 4551          if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 4553            mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 4560  if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
 
 4563    mParentLayerComboBox->addItem( initialParent, initialParent );
 
 4564    mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 4567  vlayout->addWidget( mParentLayerComboBox );
 
 4569  vlayout->addWidget( 
new QLabel( tr( 
"Allowed data type" ) ) );
 
 4570  mDataTypeComboBox = 
new QComboBox();
 
 4578    mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData( 
static_cast< int >( fieldParam->dataType() ) ) );
 
 4580  vlayout->addWidget( mDataTypeComboBox );
 
 4582  mAllowMultipleCheckBox = 
new QCheckBox( tr( 
"Accept multiple fields" ) );
 
 4584    mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
 
 4586  vlayout->addWidget( mAllowMultipleCheckBox );
 
 4588  mDefaultToAllCheckBox = 
new QCheckBox( tr( 
"Select all fields by default" ) );
 
 4589  mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
 
 4591    mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
 
 4593  vlayout->addWidget( mDefaultToAllCheckBox );
 
 4595  connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged, 
this, [ = ]
 
 4597    mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
 
 4600  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 4602  mDefaultLineEdit = 
new QLineEdit();
 
 4603  mDefaultLineEdit->setToolTip( tr( 
"Default field name, or ; separated list of field names for multiple field parameters" ) );
 
 4607    mDefaultLineEdit->setText( fields.join( 
';' ) );
 
 4609  vlayout->addWidget( mDefaultLineEdit );
 
 4611  setLayout( vlayout );
 
 4618  QVariant defaultValue;
 
 4619  if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
 
 4621    defaultValue = mDefaultLineEdit->text();
 
 4623  auto param = std::make_unique< QgsProcessingParameterField >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(), 
false, mDefaultToAllCheckBox->isChecked() );
 
 4625  return param.release();
 
 4634QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
 
 4644        mPanel = 
new QgsProcessingFieldPanelWidget( 
nullptr, fieldParam );
 
 4645        mPanel->setToolTip( parameterDefinition()->toolTip() );
 
 4646        connect( mPanel, &QgsProcessingFieldPanelWidget::changed, 
this, [ = ]
 
 4648          emit widgetValueHasChanged( 
this );
 
 4668        mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 4671          emit widgetValueHasChanged( 
this );
 
 4679      mLineEdit = 
new QLineEdit();
 
 4680      mLineEdit->setToolTip( QObject::tr( 
"Name of field (separate field names with ; for multiple field parameters)" ) );
 
 4681      connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
 
 4683        emit widgetValueHasChanged( 
this );
 
 4692void QgsProcessingFieldWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 4704          setParentLayerWrapperValue( wrapper );
 
 4707            setParentLayerWrapperValue( wrapper );
 
 4724  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 4725  if ( mProcessingContextGenerator )
 
 4726    context = mProcessingContextGenerator->processingContext();
 
 4730    tmpContext = std::make_unique< QgsProcessingContext >();
 
 4731    context = tmpContext.get();
 
 4736  if ( value.userType() == QMetaType::type( 
"QgsProcessingFeatureSourceDefinition" ) )
 
 4746  bool valueSet = 
false;
 
 4750  if ( layers.count() > 1 )
 
 4752    QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
 
 4754    const  QList< QgsMapLayer * > remainingLayers = layers.mid( 1 );
 
 4760      QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer );
 
 4761      if ( !vlayer || !vlayer->
isValid() )
 
 4767      for ( 
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
 
 4770          fields.
remove( fieldIdx );
 
 4775      mComboBox->setFields( fields );
 
 4777      mPanel->setFields( filterFields( fields ) );
 
 4783  if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
 
 4785    QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
 
 4789    std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
 
 4792      mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
 
 4793      layer = mParentLayer.get();
 
 4801      mComboBox->setLayer( layer );
 
 4803      mPanel->setFields( filterFields( layer->
fields() ) );
 
 4813      const QgsFields fields = source->fields();
 
 4815        mComboBox->setFields( fields );
 
 4817        mPanel->setFields( filterFields( fields ) );
 
 4826      mComboBox->setLayer( 
nullptr );
 
 4830    if ( value.isValid() && widgetContext().messageBar() )
 
 4833      widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr( 
"Could not load selected layer/table. Dependent field could not be populated" ),
 
 4843    val.reserve( mPanel->fields().size() );
 
 4844    for ( 
const QgsField &field : mPanel->fields() )
 
 4845      val << field.name();
 
 4846    setWidgetValue( val, *context );
 
 4849    setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
 
 4852void QgsProcessingFieldWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 4856    if ( !value.isValid() )
 
 4857      mComboBox->setField( QString() );
 
 4861      mComboBox->setField( v );
 
 4867    if ( value.isValid() )
 
 4870      opts.reserve( v.size() );
 
 4871      for ( 
const QString &i : v )
 
 4875      mPanel->setValue( opts );
 
 4877  else if ( mLineEdit )
 
 4883      mLineEdit->setText( v.join( 
';' ) );
 
 4892QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
 const 
 4895    return mComboBox->currentField();
 
 4897    return mPanel->value();
 
 4898  else if ( mLineEdit )
 
 4903      return mLineEdit->text().split( 
';' );
 
 4906      return mLineEdit->text();
 
 4912QStringList QgsProcessingFieldWidgetWrapper::compatibleParameterTypes()
 const 
 4914  return QStringList()
 
 4919QStringList QgsProcessingFieldWidgetWrapper::compatibleOutputTypes()
 const 
 4921  return QStringList()
 
 4926QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
 const 
 4928  return tr( 
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
 
 4931const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
 const 
 4933  if ( mComboBox && mComboBox->layer() )
 
 4934    return mComboBox->layer();
 
 4939QgsFields QgsProcessingFieldWidgetWrapper::filterFields( 
const QgsFields &fields )
 const 
 4952        if ( f.isNumeric() )
 
 4957        if ( f.type() == QMetaType::Type::QString )
 
 4962        if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
 
 4967        if ( f.type() == QMetaType::Type::QByteArray )
 
 4972        if ( f.type() == QMetaType::Type::Bool )
 
 4981QString QgsProcessingFieldWidgetWrapper::parameterType()
 const 
 4988  return new QgsProcessingFieldWidgetWrapper( parameter, type );
 
 4993  return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 5004  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 5005  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 5007  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 5009  mDefaultComboBox = 
new QComboBox();
 
 5010  mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
 
 5013  for ( 
const QString &theme : mapThemes )
 
 5017  mDefaultComboBox->setEditable( 
true );
 
 5021    if ( themeParam->defaultValueForGui().isValid() )
 
 5024      mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
 
 5027    mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
 
 5029  vlayout->addWidget( mDefaultComboBox );
 
 5031  setLayout( vlayout );
 
 5036  QVariant defaultVal;
 
 5037  if ( mDefaultComboBox->currentText().isEmpty() )
 
 5038    defaultVal = QVariant();
 
 5040    defaultVal = mDefaultComboBox->currentText();
 
 5041  auto param = std::make_unique< QgsProcessingParameterMapTheme>( name, description, defaultVal );
 
 5043  return param.release();
 
 5053QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
 
 5057  mComboBox = 
new QComboBox();
 
 5060    mComboBox->addItem( tr( 
"[Not selected]" ), QVariant( -1 ) );
 
 5063  for ( 
const QString &theme : mapThemes )
 
 5075      mComboBox->setEditable( 
true );
 
 5079  mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 5080  connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [ = ]( 
int )
 
 5082    emit widgetValueHasChanged( 
this );
 
 5088void QgsProcessingMapThemeWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 5092  if ( !value.isValid() )
 
 5093    mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
 
 5096    if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
 
 5098      const QString prev = mComboBox->currentText();
 
 5099      mComboBox->setCurrentText( v );
 
 5101        emit widgetValueHasChanged( 
this );
 
 5104      mComboBox->setCurrentIndex( mComboBox->findData( v ) );
 
 5108QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
 const 
 5111    return mComboBox->currentData().toInt() == -1 ? QVariant() :
 
 5112           !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
 
 5113           : mComboBox->currentData();
 
 5118QStringList QgsProcessingMapThemeWidgetWrapper::compatibleParameterTypes()
 const 
 5120  return QStringList()
 
 5125QStringList QgsProcessingMapThemeWidgetWrapper::compatibleOutputTypes()
 const 
 5127  return QStringList()
 
 5132QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
 const 
 5134  return tr( 
"map theme as a string value (e.g. 'base maps')" );
 
 5137QString QgsProcessingMapThemeWidgetWrapper::parameterType()
 const 
 5144  return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
 
 5149  return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 5162  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 5163  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 5165  vlayout->addWidget( 
new QLabel( tr( 
"Type" ) ) );
 
 5167  mTypeComboBox = 
new QComboBox();
 
 5172    mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( 
static_cast< int >( datetimeParam->dataType() ) ) );
 
 5174    mTypeComboBox->setCurrentIndex( 0 );
 
 5175  vlayout->addWidget( mTypeComboBox );
 
 5177  setLayout( vlayout );
 
 5182  auto param = std::make_unique< QgsProcessingParameterDateTime >( name, description );
 
 5185  return param.release();
 
 5195QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
 
 5200  switch ( dateTimeParam->
dataType() )
 
 5204      widget = mDateTimeEdit;
 
 5227  widget->setToolTip( parameterDefinition()->toolTip() );
 
 5229  if ( mDateTimeEdit )
 
 5233      emit widgetValueHasChanged( 
this );
 
 5236  else if ( mDateEdit )
 
 5240      emit widgetValueHasChanged( 
this );
 
 5243  else if ( mTimeEdit )
 
 5247      emit widgetValueHasChanged( 
this );
 
 5256  return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 5259void QgsProcessingDateTimeWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 5261  if ( mDateTimeEdit )
 
 5265  else if ( mDateEdit )
 
 5269  else if ( mTimeEdit )
 
 5275QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
 const 
 5277  if ( mDateTimeEdit )
 
 5278    return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
 
 5279  else if ( mDateEdit )
 
 5280    return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
 
 5281  else if ( mTimeEdit )
 
 5282    return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
 
 5287QStringList QgsProcessingDateTimeWidgetWrapper::compatibleParameterTypes()
 const 
 5289  return QStringList()
 
 5294QStringList QgsProcessingDateTimeWidgetWrapper::compatibleOutputTypes()
 const 
 5296  return QStringList()
 
 5301QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
 const 
 5304  if ( dateTimeParam )
 
 5306    switch ( dateTimeParam->
dataType() )
 
 5309        return tr( 
"datetime value, or a ISO string representation of a datetime" );
 
 5312        return tr( 
"date value, or a ISO string representation of a date" );
 
 5315        return tr( 
"time value, or a ISO string representation of a time" );
 
 5321QString QgsProcessingDateTimeWidgetWrapper::parameterType()
 const 
 5328  return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
 
 5342  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 5343  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 5345  vlayout->addWidget( 
new QLabel( tr( 
"Provider" ) ) );
 
 5346  mProviderComboBox = 
new QComboBox();
 
 5347  mProviderComboBox->addItem( QObject::tr( 
"Postgres" ), QStringLiteral( 
"postgres" ) );
 
 5348  mProviderComboBox->addItem( QObject::tr( 
"GeoPackage" ), QStringLiteral( 
"ogr" ) );
 
 5349  mProviderComboBox->addItem( QObject::tr( 
"Spatialite" ), QStringLiteral( 
"spatialite" ) );
 
 5351  vlayout->addWidget( mProviderComboBox );
 
 5353  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 5355  mDefaultEdit = 
new QLineEdit();
 
 5356  vlayout->addWidget( mDefaultEdit );
 
 5357  setLayout( vlayout );
 
 5359  if ( connectionParam )
 
 5361    mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
 
 5368  QVariant defaultVal;
 
 5369  if ( mDefaultEdit->text().isEmpty() )
 
 5370    defaultVal = QVariant();
 
 5372    defaultVal = mDefaultEdit->text();
 
 5373  auto param = std::make_unique< QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
 
 5375  return param.release();
 
 5385QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
 
 5391    mProviderComboBox->setAllowEmptyConnection( 
true );
 
 5399      mProviderComboBox->setEditable( 
true );
 
 5403  mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 5404  connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged, 
this, [ = ]( 
const QString & )
 
 5406    if ( mBlockSignals )
 
 5409    emit widgetValueHasChanged( 
this );
 
 5412  return mProviderComboBox;
 
 5417  return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 5420void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 5424  if ( !value.isValid() )
 
 5425    mProviderComboBox->setCurrentIndex( -1 );
 
 5428    if ( mProviderComboBox->isEditable() )
 
 5430      const QString prev = mProviderComboBox->currentText();
 
 5432      mProviderComboBox->setConnection( v );
 
 5433      mProviderComboBox->setCurrentText( v );
 
 5437        emit widgetValueHasChanged( 
this );
 
 5440      mProviderComboBox->setConnection( v );
 
 5444QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
 const 
 5446  if ( mProviderComboBox )
 
 5447    if ( mProviderComboBox->isEditable() )
 
 5448      return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
 
 5450      return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
 
 5455QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleParameterTypes()
 const 
 5457  return QStringList()
 
 5463QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleOutputTypes()
 const 
 5465  return QStringList()
 
 5470QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
 const 
 5472  return tr( 
"connection name as a string value" );
 
 5475QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
 const 
 5482  return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
 
 5497  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 5498  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 5500  mConnectionParamComboBox = 
new QComboBox();
 
 5501  QString initialConnection;
 
 5507  if ( 
auto *lModel = widgetContext.
model() )
 
 5510    const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
 
 5511    for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 5513      if ( definition && it->parameterName() == definition->
name() )
 
 5519      mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
 
 5520      if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
 
 5522        mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
 
 5527  if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
 
 5530    mConnectionParamComboBox->addItem( initialConnection, initialConnection );
 
 5531    mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
 
 5534  vlayout->addWidget( 
new QLabel( tr( 
"Provider connection parameter" ) ) );
 
 5535  vlayout->addWidget( mConnectionParamComboBox );
 
 5537  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 5539  mDefaultEdit = 
new QLineEdit();
 
 5540  vlayout->addWidget( mDefaultEdit );
 
 5541  setLayout( vlayout );
 
 5551  QVariant defaultVal;
 
 5552  if ( mDefaultEdit->text().isEmpty() )
 
 5553    defaultVal = QVariant();
 
 5555    defaultVal = mDefaultEdit->text();
 
 5556  auto param = std::make_unique< QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
 
 5558  return param.release();
 
 5568QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
 
 5574    mSchemaComboBox->setAllowEmptySchema( 
true );
 
 5582      mSchemaComboBox->comboBox()->setEditable( 
true );
 
 5586  mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 5587  connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged, 
this, [ = ]( 
const QString & )
 
 5589    if ( mBlockSignals )
 
 5592    emit widgetValueHasChanged( this );
 
 5595  return mSchemaComboBox;
 
 5600  return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 5607  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 5608  if ( mProcessingContextGenerator )
 
 5609    context = mProcessingContextGenerator->processingContext();
 
 5613    tmpContext = std::make_unique< QgsProcessingContext >();
 
 5614    context = tmpContext.get();
 
 5620  if ( mSchemaComboBox )
 
 5621    mSchemaComboBox->setConnectionName( connection, qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId() );
 
 5625    setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
 
 5628void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 5632  if ( !value.isValid() )
 
 5633    mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
 
 5636    if ( mSchemaComboBox->comboBox()->isEditable() )
 
 5638      const QString prev = mSchemaComboBox->comboBox()->currentText();
 
 5640      mSchemaComboBox->setSchema( v );
 
 5641      mSchemaComboBox->comboBox()->setCurrentText( v );
 
 5645        emit widgetValueHasChanged( 
this );
 
 5648      mSchemaComboBox->setSchema( v );
 
 5652QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
 const 
 5654  if ( mSchemaComboBox )
 
 5655    if ( mSchemaComboBox->comboBox()->isEditable() )
 
 5656      return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
 
 5658      return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
 
 5663QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleParameterTypes()
 const 
 5665  return QStringList()
 
 5671QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleOutputTypes()
 const 
 5673  return QStringList()
 
 5678QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
 const 
 5680  return tr( 
"database schema name as a string value" );
 
 5683QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
 const 
 5690  return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
 
 5693void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 5705          setParentConnectionWrapperValue( wrapper );
 
 5708            setParentConnectionWrapperValue( wrapper );
 
 5732  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 5733  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 5735  mConnectionParamComboBox = 
new QComboBox();
 
 5736  mSchemaParamComboBox = 
new QComboBox();
 
 5737  QString initialConnection;
 
 5738  QString initialSchema;
 
 5745  if ( 
auto *lModel = widgetContext.
model() )
 
 5748    const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
 
 5749    for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 5751      if ( definition && it->parameterName() == definition->
name() )
 
 5756        mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
 
 5757        if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
 
 5759          mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
 
 5764        mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
 
 5765        if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
 
 5767          mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
 
 5773  if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
 
 5776    mConnectionParamComboBox->addItem( initialConnection, initialConnection );
 
 5777    mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
 
 5780  if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
 
 5783    mSchemaParamComboBox->addItem( initialSchema, initialSchema );
 
 5784    mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
 
 5787  vlayout->addWidget( 
new QLabel( tr( 
"Provider connection parameter" ) ) );
 
 5788  vlayout->addWidget( mConnectionParamComboBox );
 
 5790  vlayout->addWidget( 
new QLabel( tr( 
"Database schema parameter" ) ) );
 
 5791  vlayout->addWidget( mSchemaParamComboBox );
 
 5793  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 5795  mDefaultEdit = 
new QLineEdit();
 
 5796  vlayout->addWidget( mDefaultEdit );
 
 5797  setLayout( vlayout );
 
 5807  QVariant defaultVal;
 
 5808  if ( mDefaultEdit->text().isEmpty() )
 
 5809    defaultVal = QVariant();
 
 5811    defaultVal = mDefaultEdit->text();
 
 5812  auto param = std::make_unique< QgsProcessingParameterDatabaseTable>( name, description,
 
 5813               mConnectionParamComboBox->currentData().toString(),
 
 5814               mSchemaParamComboBox->currentData().toString(),
 
 5817  return param.release();
 
 5827QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
 
 5833    mTableComboBox->setAllowEmptyTable( 
true );
 
 5836    mTableComboBox->comboBox()->setEditable( 
true );
 
 5838  mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 5839  connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged, 
this, [ = ]( 
const QString & )
 
 5841    if ( mBlockSignals )
 
 5844    emit widgetValueHasChanged( this );
 
 5847  return mTableComboBox;
 
 5852  return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 5859  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 5860  if ( mProcessingContextGenerator )
 
 5861    context = mProcessingContextGenerator->processingContext();
 
 5865    tmpContext = std::make_unique< QgsProcessingContext >();
 
 5866    context = tmpContext.get();
 
 5871  mProvider = qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId();
 
 5872  if ( mTableComboBox && !mSchema.isEmpty() )
 
 5874    mTableComboBox->setSchema( mSchema );
 
 5875    mTableComboBox->setConnectionName( mConnection, mProvider );
 
 5879      setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
 
 5887  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 5888  if ( mProcessingContextGenerator )
 
 5889    context = mProcessingContextGenerator->processingContext();
 
 5893    tmpContext = std::make_unique< QgsProcessingContext >();
 
 5894    context = tmpContext.get();
 
 5900  if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
 
 5902    mTableComboBox->setSchema( mSchema );
 
 5903    mTableComboBox->setConnectionName( mConnection, mProvider );
 
 5907      setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
 
 5912void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 5916  if ( !value.isValid() )
 
 5917    mTableComboBox->comboBox()->setCurrentIndex( -1 );
 
 5920    if ( mTableComboBox->comboBox()->isEditable() )
 
 5922      const QString prev = mTableComboBox->comboBox()->currentText();
 
 5924      mTableComboBox->setTable( v );
 
 5925      mTableComboBox->comboBox()->setCurrentText( v );
 
 5929        emit widgetValueHasChanged( 
this );
 
 5932      mTableComboBox->setTable( v );
 
 5936QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
 const 
 5938  if ( mTableComboBox )
 
 5939    if ( mTableComboBox->comboBox()->isEditable() )
 
 5940      return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
 
 5942      return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
 
 5947QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleParameterTypes()
 const 
 5949  return QStringList()
 
 5955QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleOutputTypes()
 const 
 5957  return QStringList()
 
 5962QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
 const 
 5964  return tr( 
"database table name as a string value" );
 
 5967QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
 const 
 5974  return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
 
 5977void QgsProcessingDatabaseTableWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 5989          setParentConnectionWrapperValue( wrapper );
 
 5992            setParentConnectionWrapperValue( wrapper );
 
 5997          setParentSchemaWrapperValue( wrapper );
 
 6000            setParentSchemaWrapperValue( wrapper );
 
 6020  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 6021  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 6023  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 6026  mDefaultWidget->setNullValueAllowed( 
true, tr( 
"Not set" ) );
 
 6029    if ( extentParam->defaultValueForGui().isValid() )
 
 6033      mDefaultWidget->setCurrentExtent( rect, 
crs );
 
 6034      mDefaultWidget->setOutputExtentFromCurrent();
 
 6038      mDefaultWidget->clear();
 
 6042  vlayout->addWidget( mDefaultWidget );
 
 6043  setLayout( vlayout );
 
 6048  const QString defaultVal = mDefaultWidget->isValid() ? QStringLiteral( 
"%1,%2,%3,%4%5" ).arg(
 
 6049                               QString::number( mDefaultWidget->outputExtent().xMinimum(), 
'f', 9 ),
 
 6050                               QString::number( mDefaultWidget->outputExtent().xMaximum(), 
'f', 9 ),
 
 6051                               QString::number( mDefaultWidget->outputExtent().yMinimum(), 
'f', 9 ),
 
 6052                               QString::number( mDefaultWidget->outputExtent().yMaximum(), 
'f', 9 ),
 
 6053                               mDefaultWidget->outputCrs().isValid() ? QStringLiteral( 
" [%1]" ).arg( mDefaultWidget->outputCrs().authid() ) : QString()
 
 6055  auto param = std::make_unique< QgsProcessingParameterExtent >( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
 
 6057  return param.release();
 
 6068QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
 
 6078      if ( widgetContext().mapCanvas() )
 
 6079        mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
 
 6082        mExtentWidget->setNullValueAllowed( 
true, tr( 
"Not set" ) );
 
 6084      mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
 
 6088        emit widgetValueHasChanged( 
this );
 
 6092        setDialog( mDialog ); 
 
 6094      return mExtentWidget;
 
 6104    mExtentWidget->setMapCanvas( context.
mapCanvas() );
 
 6107void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
 
 6115        mDialog->showMinimized();
 
 6118        mDialog->showNormal();
 
 6120        mDialog->activateWindow();
 
 6127void QgsProcessingExtentWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 6129  if ( mExtentWidget )
 
 6131    if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
 
 6132      mExtentWidget->clear();
 
 6137      mExtentWidget->setCurrentExtent( r, 
crs );
 
 6138      mExtentWidget->setOutputExtentFromUser( r, 
crs );
 
 6143QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
 const 
 6145  if ( mExtentWidget )
 
 6147    const QString val = mExtentWidget->isValid() ? QStringLiteral( 
"%1,%2,%3,%4%5" ).arg(
 
 6148                          QString::number( mExtentWidget->outputExtent().xMinimum(), 
'f', 9 ),
 
 6149                          QString::number( mExtentWidget->outputExtent().xMaximum(), 
'f', 9 ),
 
 6150                          QString::number( mExtentWidget->outputExtent().yMinimum(), 
'f', 9 ),
 
 6151                          QString::number( mExtentWidget->outputExtent().yMaximum(), 
'f', 9 ),
 
 6152                          mExtentWidget->outputCrs().isValid() ? QStringLiteral( 
" [%1]" ).arg( mExtentWidget->outputCrs().authid() ) : QString()
 
 6155    return val.isEmpty() ? QVariant() : QVariant( val );
 
 6161QStringList QgsProcessingExtentWidgetWrapper::compatibleParameterTypes()
 const 
 6163  return QStringList()
 
 6175QStringList QgsProcessingExtentWidgetWrapper::compatibleOutputTypes()
 const 
 6177  return QStringList()
 
 6185QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
 const 
 6187  return tr( 
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
 
 6190QString QgsProcessingExtentWidgetWrapper::parameterType()
 const 
 6197  return new QgsProcessingExtentWidgetWrapper( parameter, type );
 
 6202  return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 6214  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 6215  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 6217  vlayout->addWidget( 
new QLabel( tr( 
"Layer type" ) ) );
 
 6232    for ( 
int i : layerParam->dataTypes() )
 
 6234      mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
 
 6238  vlayout->addWidget( mLayerTypeComboBox );
 
 6240  setLayout( vlayout );
 
 6245  QList< int > dataTypes;
 
 6246  for ( 
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
 
 6247    dataTypes << v.toInt();
 
 6249  auto param = std::make_unique< QgsProcessingParameterMapLayer >( name, description );
 
 6250  param->setDataTypes( dataTypes );
 
 6252  return param.release();
 
 6261QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
 
 6263  mComboBox = 
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
 
 6271      mComboBox->setEditable( 
true );
 
 6275  mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 6277  connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged, 
this, [ = ]()
 
 6279    if ( mBlockSignals )
 
 6282    emit widgetValueHasChanged( 
this );
 
 6285  setWidgetContext( widgetContext() );
 
 6294    mComboBox->setWidgetContext( context );
 
 6299      if ( !parameterDefinition()->defaultValueForGui().isValid() )
 
 6305void QgsProcessingMapLayerWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 6308    mComboBox->setValue( value, context );
 
 6311QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
 const 
 6313  return mComboBox ? mComboBox->value() : QVariant();
 
 6316QStringList QgsProcessingMapLayerWidgetWrapper::compatibleParameterTypes()
 const 
 6318  return QStringList()
 
 6329QStringList QgsProcessingMapLayerWidgetWrapper::compatibleOutputTypes()
 const 
 6331  return QStringList()
 
 6340QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
 const 
 6342  return tr( 
"path to a map layer" );
 
 6359QString QgsProcessingMapLayerWidgetWrapper::parameterType()
 const 
 6366  return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
 
 6371  return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 6380  : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
 
 6385QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleParameterTypes()
 const 
 6387  return QStringList()
 
 6394QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleOutputTypes()
 const 
 6396  return QStringList()
 
 6404QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
 const 
 6406  return tr( 
"path to a raster layer" );
 
 6409QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
 const 
 6416  return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
 
 6421  Q_UNUSED( context );
 
 6422  Q_UNUSED( widgetContext );
 
 6423  Q_UNUSED( definition );
 
 6437  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 6438  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 6440  vlayout->addWidget( 
new QLabel( tr( 
"Geometry type" ) ) );
 
 6450    for ( 
int i : vectorParam->dataTypes() )
 
 6452      mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
 
 6456  vlayout->addWidget( mGeometryTypeComboBox );
 
 6458  setLayout( vlayout );
 
 6463  QList< int > dataTypes;
 
 6464  for ( 
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
 
 6465    dataTypes << v.toInt();
 
 6467  auto param = std::make_unique< QgsProcessingParameterVectorLayer >( name, description, dataTypes );
 
 6469  return param.release();
 
 6474  : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
 
 6479QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleParameterTypes()
 const 
 6481  return QStringList()
 
 6488QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleOutputTypes()
 const 
 6490  return QStringList()
 
 6498QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
 const 
 6500  return tr( 
"path to a vector layer" );
 
 6506    return param->dataTypes();
 
 6508    return QList< int >();
 
 6511QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
 const 
 6518  return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
 
 6523  return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 6535  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 6536  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 6538  vlayout->addWidget( 
new QLabel( tr( 
"Geometry type" ) ) );
 
 6548    for ( 
int i : sourceParam->dataTypes() )
 
 6550      mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
 
 6558  vlayout->addWidget( mGeometryTypeComboBox );
 
 6560  setLayout( vlayout );
 
 6565  QList< int > dataTypes;
 
 6566  for ( 
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
 
 6567    dataTypes << v.toInt();
 
 6569  auto param = std::make_unique< QgsProcessingParameterFeatureSource >( name, description, dataTypes );
 
 6571  return param.release();
 
 6575  : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
 
 6580QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleParameterTypes()
 const 
 6582  return QStringList()
 
 6590QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleOutputTypes()
 const 
 6592  return QStringList()
 
 6600QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
 const 
 6602  return tr( 
"path to a vector layer" );
 
 6608    return param->dataTypes();
 
 6610    return QList< int >();
 
 6613QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
 const 
 6620  return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
 
 6625  return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 6633  : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
 
 6638QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleParameterTypes()
 const 
 6640  return QStringList()
 
 6647QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleOutputTypes()
 const 
 6649  return QStringList()
 
 6657QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
 const 
 6659  return tr( 
"path to a mesh layer" );
 
 6662QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
 const 
 6669  return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
 
 6674  Q_UNUSED( context );
 
 6675  Q_UNUSED( widgetContext );
 
 6676  Q_UNUSED( definition );
 
 6688QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent, 
const QgsProcessingParameterBand *param )
 
 6692  QHBoxLayout *hl = 
new QHBoxLayout();
 
 6693  hl->setContentsMargins( 0, 0, 0, 0 );
 
 6695  mLineEdit = 
new QLineEdit();
 
 6696  mLineEdit->setEnabled( 
false );
 
 6697  hl->addWidget( mLineEdit, 1 );
 
 6699  mToolButton = 
new QToolButton();
 
 6700  mToolButton->setText( QString( QChar( 0x2026 ) ) );
 
 6701  hl->addWidget( mToolButton );
 
 6707    mLineEdit->setText( tr( 
"%n band(s) selected", 
nullptr, 0 ) );
 
 6710  connect( mToolButton, &QToolButton::clicked, 
this, &QgsProcessingRasterBandPanelWidget::showDialog );
 
 6713void QgsProcessingRasterBandPanelWidget::setBands( 
const QList< int > &bands )
 
 6718void QgsProcessingRasterBandPanelWidget::setBandNames( 
const QHash<int, QString> &names )
 
 6723void QgsProcessingRasterBandPanelWidget::setValue( 
const QVariant &value )
 
 6725  if ( value.isValid() )
 
 6726    mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
 
 6730  updateSummaryText();
 
 6734void QgsProcessingRasterBandPanelWidget::showDialog()
 
 6736  QVariantList availableOptions;
 
 6737  availableOptions.reserve( mBands.size() );
 
 6738  for ( 
int band : std::as_const( mBands ) )
 
 6740    availableOptions << band;
 
 6746    QgsProcessingMultipleSelectionPanelWidget *widget = 
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
 
 6747    widget->setPanelTitle( mParam->description() );
 
 6749    widget->setValueFormatter( [
this]( 
const QVariant & v ) -> QString
 
 6751      int band = v.toInt();
 
 6752      return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
 
 6755    connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged, 
this, [ = ]()
 
 6757      setValue( widget->selectedOptions() );
 
 6764    QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue, 
this, Qt::WindowFlags() );
 
 6766    dlg.setValueFormatter( [
this]( 
const QVariant & v ) -> QString
 
 6768      int band = v.toInt();
 
 6769      return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
 
 6773      setValue( dlg.selectedOptions() );
 
 6778void QgsProcessingRasterBandPanelWidget::updateSummaryText()
 
 6781    mLineEdit->setText( tr( 
"%n band(s) selected", 
nullptr, mValue.count() ) );
 
 6793  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 6794  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 6796  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 6798  mDefaultLineEdit = 
new QLineEdit();
 
 6799  mDefaultLineEdit->setToolTip( tr( 
"Band number (separate bands with ; for multiple band parameters)" ) );
 
 6804    for ( 
int b : bands )
 
 6806      defVal << QString::number( b );
 
 6809    mDefaultLineEdit->setText( defVal.join( 
';' ) );
 
 6811  vlayout->addWidget( mDefaultLineEdit );
 
 6813  vlayout->addWidget( 
new QLabel( tr( 
"Parent layer" ) ) );
 
 6814  mParentLayerComboBox = 
new QComboBox();
 
 6816  QString initialParent;
 
 6818    initialParent = bandParam->parentLayerParameterName();
 
 6820  if ( 
auto *lModel = widgetContext.
model() )
 
 6823    const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
 
 6824    for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 6828        mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 6829        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 6831          mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 6837  if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
 
 6840    mParentLayerComboBox->addItem( initialParent, initialParent );
 
 6841    mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 6844  vlayout->addWidget( mParentLayerComboBox );
 
 6846  mAllowMultipleCheckBox = 
new QCheckBox( tr( 
"Allow multiple" ) );
 
 6848    mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
 
 6850  vlayout->addWidget( mAllowMultipleCheckBox );
 
 6851  setLayout( vlayout );
 
 6856  auto param = std::make_unique< QgsProcessingParameterBand >( name, description, mDefaultLineEdit->text().split( 
';' ), mParentLayerComboBox->currentData().toString(), 
false, mAllowMultipleCheckBox->isChecked() );
 
 6858  return param.release();
 
 6867QWidget *QgsProcessingBandWidgetWrapper::createWidget()
 
 6877        mPanel = 
new QgsProcessingRasterBandPanelWidget( 
nullptr, bandParam );
 
 6878        mPanel->setToolTip( parameterDefinition()->toolTip() );
 
 6879        connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed, 
this, [ = ]
 
 6881          emit widgetValueHasChanged( 
this );
 
 6890        mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 6893          emit widgetValueHasChanged( 
this );
 
 6901      mLineEdit = 
new QLineEdit();
 
 6902      mLineEdit->setToolTip( QObject::tr( 
"Band number (separate bands with ; for multiple band parameters)" ) );
 
 6903      connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
 
 6905        emit widgetValueHasChanged( 
this );
 
 6914void QgsProcessingBandWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 6926          setParentLayerWrapperValue( wrapper );
 
 6929            setParentLayerWrapperValue( wrapper );
 
 6946  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 6947  if ( mProcessingContextGenerator )
 
 6948    context = mProcessingContextGenerator->processingContext();
 
 6952    tmpContext = std::make_unique< QgsProcessingContext >();
 
 6953    context = tmpContext.get();
 
 6959  if ( layer && layer->
isValid() )
 
 6963    std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
 
 6966      mParentLayer.reset( qobject_cast< QgsRasterLayer * >( ownedLayer.release() ) );
 
 6967      layer = mParentLayer.get();
 
 6975      mComboBox->setLayer( layer );
 
 6979      if ( provider && layer->
isValid() )
 
 6984        QHash< int, QString > bandNames;
 
 6985        for ( 
int i = 1; i <= nBands; ++i )
 
 6990        mPanel->setBands( bands );
 
 6991        mPanel->setBandNames( bandNames );
 
 6998      mComboBox->setLayer( 
nullptr );
 
 7000      mPanel->setBands( QList< int >() );
 
 7002    if ( value.isValid() && widgetContext().messageBar() )
 
 7005      widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr( 
"Could not load selected layer/table. Dependent bands could not be populated" ),
 
 7010  if ( parameterDefinition()->defaultValueForGui().isValid() )
 
 7011    setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
 
 7014void QgsProcessingBandWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 7018    if ( !value.isValid() )
 
 7019      mComboBox->setBand( -1 );
 
 7023      mComboBox->setBand( v );
 
 7029    if ( value.isValid() )
 
 7032      opts.reserve( v.size() );
 
 7037      mPanel->setValue( value.isValid() ? opts : QVariant() );
 
 7039  else if ( mLineEdit )
 
 7046      opts.reserve( v.size() );
 
 7048        opts << QString::number( i );
 
 7049      mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join( 
';' ) : QString() );
 
 7053      if ( value.isValid() )
 
 7061QVariant QgsProcessingBandWidgetWrapper::widgetValue()
 const 
 7064    return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
 
 7066    return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
 
 7067  else if ( mLineEdit )
 
 7072      const QStringList parts = mLineEdit->text().split( 
';', Qt::SkipEmptyParts );
 
 7074      res.reserve( parts.count() );
 
 7075      for ( 
const QString &s : parts )
 
 7078        int band = s.toInt( &ok );
 
 7082      return res.
isEmpty() ? QVariant() : res;
 
 7086      return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
 
 7093QStringList QgsProcessingBandWidgetWrapper::compatibleParameterTypes()
 const 
 7095  return QStringList()
 
 7100QStringList QgsProcessingBandWidgetWrapper::compatibleOutputTypes()
 const 
 7102  return QStringList()
 
 7107QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
 const 
 7109  return tr( 
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
 
 7112QString QgsProcessingBandWidgetWrapper::parameterType()
 const 
 7119  return new QgsProcessingBandWidgetWrapper( parameter, type );
 
 7124  return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 7137  QHBoxLayout *hl = 
new QHBoxLayout();
 
 7138  hl->setContentsMargins( 0, 0, 0, 0 );
 
 7140  mLineEdit = 
new QLineEdit();
 
 7141  mLineEdit->setEnabled( 
false );
 
 7142  hl->addWidget( mLineEdit, 1 );
 
 7144  mToolButton = 
new QToolButton();
 
 7145  mToolButton->setText( QString( QChar( 0x2026 ) ) );
 
 7146  hl->addWidget( mToolButton );
 
 7152    mLineEdit->setText( tr( 
"%n input(s) selected", 
nullptr, 0 ) );
 
 7155  connect( mToolButton, &QToolButton::clicked, 
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
 
 7158void QgsProcessingMultipleLayerPanelWidget::setValue( 
const QVariant &value )
 
 7160  if ( value.isValid() )
 
 7161    mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
 
 7165  updateSummaryText();
 
 7169void QgsProcessingMultipleLayerPanelWidget::setProject( 
QgsProject *project )
 
 7176      if ( mValue.removeAll( layerId ) )
 
 7178        updateSummaryText();
 
 7185void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model, 
const QString &modelChildAlgorithmID )
 
 7191  switch ( mParam->layerType() )
 
 7349void QgsProcessingMultipleLayerPanelWidget::showDialog()
 
 7354    QgsProcessingMultipleInputPanelWidget *widget = 
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
 
 7355    widget->setPanelTitle( mParam->description() );
 
 7356    widget->setProject( mProject );
 
 7357    connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged, 
this, [ = ]()
 
 7359      setValue( widget->selectedOptions() );
 
 7366    QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel, 
this, Qt::WindowFlags() );
 
 7367    dlg.setProject( mProject );
 
 7370      setValue( dlg.selectedOptions() );
 
 7375void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
 
 7378    mLineEdit->setText( tr( 
"%n input(s) selected", 
nullptr, mValue.count() ) );
 
 7388  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 7389  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 7391  vlayout->addWidget( 
new QLabel( tr( 
"Allowed layer type" ) ) );
 
 7392  mLayerTypeComboBox = 
new QComboBox();
 
 7406    mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData( 
static_cast< int >( layersParam->layerType() ) ) );
 
 7408  vlayout->addWidget( mLayerTypeComboBox );
 
 7409  setLayout( vlayout );
 
 7414  auto param = std::make_unique< QgsProcessingParameterMultipleLayers >( name, description, 
static_cast< Qgis::ProcessingSourceType >( mLayerTypeComboBox->currentData().toInt() ) );
 
 7416  return param.release();
 
 7425QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
 
 7429  mPanel = 
new QgsProcessingMultipleLayerPanelWidget( 
nullptr, layerParam );
 
 7430  mPanel->setToolTip( parameterDefinition()->toolTip() );
 
 7431  mPanel->setProject( widgetContext().project() );
 
 7433    mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
 
 7434  connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed, 
this, [ = ]
 
 7436    emit widgetValueHasChanged( 
this );
 
 7446    mPanel->setProject( context.
project() );
 
 7448      mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
 
 7452void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 7457    if ( value.isValid() )
 
 7460      opts.reserve( v.size() );
 
 7462        opts << l->source();
 
 7465    for ( 
const QVariant &v : value.toList() )
 
 7467      if ( v.userType() == QMetaType::type( 
"QgsProcessingModelChildParameterSource" ) )
 
 7469        const QgsProcessingModelChildParameterSource source = v.value< QgsProcessingModelChildParameterSource >();
 
 7470        opts << QVariant::fromValue( source );
 
 7475      mPanel->setValue( value.isValid() ? opts : QVariant() );
 
 7479QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
 const 
 7482    return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
 
 7487QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleParameterTypes()
 const 
 7489  return QStringList()
 
 7500QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleOutputTypes()
 const 
 7502  return QStringList()
 
 7512QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
 const 
 7514  return tr( 
"an array of layer paths, or semicolon separated string of layer paths" );
 
 7517QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
 const 
 7524  return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
 
 7529  return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 7538  : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
 
 7543QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleParameterTypes()
 const 
 7545  return QStringList()
 
 7552QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleOutputTypes()
 const 
 7554  return QStringList()
 
 7562QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
 const 
 7564  return tr( 
"path to a point cloud layer" );
 
 7567QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
 const 
 7574  return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
 
 7579  Q_UNUSED( context );
 
 7580  Q_UNUSED( widgetContext );
 
 7581  Q_UNUSED( definition );
 
 7598QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleParameterTypes()
 const 
 7600  return QStringList()
 
 7607QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleOutputTypes()
 const 
 7609  return QStringList()
 
 7615QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
 const 
 7617  return tr( 
"name of an annotation layer, or \"main\" for the main annotation layer" );
 
 7620QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
 const 
 7627  return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
 
 7632  Q_UNUSED( context );
 
 7633  Q_UNUSED( widgetContext );
 
 7634  Q_UNUSED( definition );
 
 7645    if ( mWidgetContext.project() )
 
 7646      mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
 
 7650QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
 
 7661      mComboBox->setEditable( 
true );
 
 7665  mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 7667  if ( mWidgetContext.project() )
 
 7668    mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
 
 7671    mComboBox->setAllowEmptyLayer( 
true );
 
 7675    if ( mBlockSignals )
 
 7678    emit widgetValueHasChanged( 
this );
 
 7681  setWidgetContext( widgetContext() );
 
 7685void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 7691      mComboBox->setLayer( 
nullptr );
 
 7695    QVariant val = value;
 
 7696    if ( val.userType() == QMetaType::type( 
"QgsProperty" ) )
 
 7708    QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( val.value< QObject * >() );
 
 7709    if ( !layer && val.userType() == QMetaType::Type::QString )
 
 7716      mComboBox->setLayer( layer );
 
 7721QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
 const 
 7723  return mComboBox && mComboBox->currentLayer() ?
 
 7724         ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral( 
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
 
 7737  QHBoxLayout *hl = 
new QHBoxLayout();
 
 7738  hl->setContentsMargins( 0, 0, 0, 0 );
 
 7740  mLineEdit = 
new QLineEdit();
 
 7741  mLineEdit->setEnabled( 
false );
 
 7742  hl->addWidget( mLineEdit, 1 );
 
 7744  mToolButton = 
new QToolButton();
 
 7745  mToolButton->setText( QString( QChar( 0x2026 ) ) );
 
 7746  hl->addWidget( mToolButton );
 
 7752    mLineEdit->setText( tr( 
"%n attribute(s) selected", 
nullptr, 0 ) );
 
 7755  connect( mToolButton, &QToolButton::clicked, 
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
 
 7760  mAttributes = attributes;
 
 7763void QgsProcessingPointCloudAttributePanelWidget::setValue( 
const QVariant &value )
 
 7765  if ( value.isValid() )
 
 7766    mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
 
 7770  updateSummaryText();
 
 7774void QgsProcessingPointCloudAttributePanelWidget::showDialog()
 
 7776  QVariantList availableOptions;
 
 7777  availableOptions.reserve( mAttributes.count() );
 
 7778  const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
 
 7781    availableOptions << attr.name();
 
 7787    QgsProcessingMultipleSelectionPanelWidget *widget = 
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
 
 7788    widget->setPanelTitle( mParam->description() );
 
 7790    widget->setValueFormatter( []( 
const QVariant & v ) -> QString
 
 7792      return v.toString();
 
 7795    connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged, 
this, [ = ]()
 
 7797      setValue( widget->selectedOptions() );
 
 7804    QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue, 
this, Qt::WindowFlags() );
 
 7806    dlg.setValueFormatter( []( 
const QVariant & v ) -> QString
 
 7808      return v.toString();
 
 7812      setValue( dlg.selectedOptions() );
 
 7817void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
 
 7822  if ( mValue.empty() )
 
 7824    mLineEdit->setText( tr( 
"%n attribute(s) selected", 
nullptr, 0 ) );
 
 7829    values.reserve( mValue.size() );
 
 7830    for ( 
const QVariant &val : std::as_const( mValue ) )
 
 7832      values << val.toString();
 
 7835    const QString concatenated = values.join( tr( 
"," ) );
 
 7836    if ( concatenated.length() < 100 )
 
 7837      mLineEdit->setText( concatenated );
 
 7839      mLineEdit->setText( tr( 
"%n attribute(s) selected", 
nullptr, mValue.count() ) );
 
 7851  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
 7852  vlayout->setContentsMargins( 0, 0, 0, 0 );
 
 7854  vlayout->addWidget( 
new QLabel( tr( 
"Parent layer" ) ) );
 
 7855  mParentLayerComboBox = 
new QComboBox();
 
 7857  QString initialParent;
 
 7859    initialParent = attrParam->parentLayerParameterName();
 
 7861  if ( 
auto *lModel = widgetContext.
model() )
 
 7864    const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
 
 7865    for ( 
auto it = components.constBegin(); it != components.constEnd(); ++it )
 
 7869        mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
 
 7870        if ( !initialParent.isEmpty() && initialParent == definition->
name() )
 
 7872          mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 7878  if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
 
 7881    mParentLayerComboBox->addItem( initialParent, initialParent );
 
 7882    mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
 
 7885  vlayout->addWidget( mParentLayerComboBox );
 
 7887  mAllowMultipleCheckBox = 
new QCheckBox( tr( 
"Accept multiple attributes" ) );
 
 7889    mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
 
 7891  vlayout->addWidget( mAllowMultipleCheckBox );
 
 7893  mDefaultToAllCheckBox = 
new QCheckBox( tr( 
"Select all attributes by default" ) );
 
 7894  mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
 
 7896    mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
 
 7898  vlayout->addWidget( mDefaultToAllCheckBox );
 
 7900  connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged, 
this, [ = ]
 
 7902    mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
 
 7905  vlayout->addWidget( 
new QLabel( tr( 
"Default value" ) ) );
 
 7907  mDefaultLineEdit = 
new QLineEdit();
 
 7908  mDefaultLineEdit->setToolTip( tr( 
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
 
 7912    mDefaultLineEdit->setText( attributes.join( 
';' ) );
 
 7914  vlayout->addWidget( mDefaultLineEdit );
 
 7916  setLayout( vlayout );
 
 7921  QVariant defaultValue;
 
 7922  if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
 
 7924    defaultValue = mDefaultLineEdit->text();
 
 7926  auto param = std::make_unique< QgsProcessingParameterPointCloudAttribute >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(), 
false, mDefaultToAllCheckBox->isChecked() );
 
 7928  return param.release();
 
 7936QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
 
 7946        mPanel = 
new QgsProcessingPointCloudAttributePanelWidget( 
nullptr, attrParam );
 
 7947        mPanel->setToolTip( parameterDefinition()->toolTip() );
 
 7948        connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed, 
this, [ = ]
 
 7950          emit widgetValueHasChanged( 
this );
 
 7958        mComboBox->setToolTip( parameterDefinition()->toolTip() );
 
 7961          emit widgetValueHasChanged( 
this );
 
 7969      mLineEdit = 
new QLineEdit();
 
 7970      mLineEdit->setToolTip( QObject::tr( 
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
 
 7971      connect( mLineEdit, &QLineEdit::textChanged, 
this, [ = ]
 
 7973        emit widgetValueHasChanged( 
this );
 
 7982void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize( 
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
 
 7994          setParentLayerWrapperValue( wrapper );
 
 7997            setParentLayerWrapperValue( wrapper );
 
 8014  std::unique_ptr< QgsProcessingContext > tmpContext;
 
 8015  if ( mProcessingContextGenerator )
 
 8016    context = mProcessingContextGenerator->processingContext();
 
 8020    tmpContext = std::make_unique< QgsProcessingContext >();
 
 8021    context = tmpContext.get();
 
 8027  if ( layer && layer->
isValid() )
 
 8031    std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
 
 8034      mParentLayer.reset( qobject_cast< QgsPointCloudLayer * >( ownedLayer.release() ) );
 
 8035      layer = mParentLayer.get();
 
 8043      mComboBox->setLayer( layer );
 
 8046      mPanel->setAttributes( layer->
attributes() );
 
 8053      mComboBox->setLayer( 
nullptr );
 
 8058    if ( value.isValid() && widgetContext().messageBar() )
 
 8061      widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr( 
"Could not load selected layer/table. Dependent attributes could not be populated" ),
 
 8070    val.reserve( mPanel->attributes().attributes().size() );
 
 8073    setWidgetValue( val, *context );
 
 8076    setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
 
 8079void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext &context )
 
 8083    if ( !value.isValid() )
 
 8084      mComboBox->setAttribute( QString() );
 
 8088      mComboBox->setAttribute( v );
 
 8094    if ( value.isValid() )
 
 8097      opts.reserve( v.size() );
 
 8098      for ( 
const QString &i : v )
 
 8102      mPanel->setValue( opts );
 
 8104  else if ( mLineEdit )
 
 8110      mLineEdit->setText( v.join( 
';' ) );
 
 8119QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
 const 
 8122    return mComboBox->currentAttribute();
 
 8124    return mPanel->value();
 
 8125  else if ( mLineEdit )
 
 8130      return mLineEdit->text().split( 
';' );
 
 8133      return mLineEdit->text();
 
 8139QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleParameterTypes()
 const 
 8141  return QStringList()
 
 8146QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleOutputTypes()
 const 
 8148  return QStringList()
 
 8153QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
 const 
 8155  return tr( 
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
 
 8158QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
 const 
 8165  return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
 
 8170  return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition, 
algorithm );
 
 8184QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
 
 8192      mOutputWidget = 
new QgsProcessingLayerOutputDestinationWidget( destParam, 
false );
 
 8193      if ( mProcessingContextGenerator )
 
 8194        mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
 
 8195      if ( mParametersGenerator )
 
 8196        mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
 
 8197      mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
 
 8199      connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged, 
this, [ = ]()
 
 8201        if ( mBlockSignals )
 
 8204        emit widgetValueHasChanged( 
this );
 
 8213        mOutputWidget->addOpenAfterRunningOption();
 
 8215      return mOutputWidget;
 
 8225void QgsProcessingOutputWidgetWrapper::setWidgetValue( 
const QVariant &value, 
QgsProcessingContext & )
 
 8227  if ( mOutputWidget )
 
 8228    mOutputWidget->setValue( value );
 
 8231QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
 const 
 8233  if ( mOutputWidget )
 
 8234    return mOutputWidget->value();
 
 8239QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
 const 
 8242  if ( mOutputWidget )
 
 8243    res.insert( QStringLiteral( 
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
 
 8247QStringList QgsProcessingOutputWidgetWrapper::compatibleParameterTypes()
 const 
 8249  return QStringList()
 
 8258QStringList QgsProcessingOutputWidgetWrapper::compatibleOutputTypes()
 const 
 8260  return QStringList()
 
 8272  : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
 
 8277QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
 const 
 8284  return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
 
 8287QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
 const 
 8289  return tr( 
"path to layer destination" );
 
 8297  : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
 
 8302QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
 const 
 8309  return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
 
 8312QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
 const 
 8314  return tr( 
"path to layer destination" );
 
 8322  : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
 
 8327QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
 const 
 8334  return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
 
 8337QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
 const 
 8339  return tr( 
"path to layer destination" );
 
 8347  : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
 
 8352QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
 const 
 8359  return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
 
 8362QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
 const 
 8364  return tr( 
"path to layer destination" );
 
 8372  : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
 
 8377QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
 const 
 8384  return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
 
 8387QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
 const 
 8389  return tr( 
"path to file destination" );
 
 8397  : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
 
 8402QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
 const 
 8409  return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
 
 8412QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
 const 
 8414  return tr( 
"path to folder destination" );
 
 8422  : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
 
 8426QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
 const 
 8433  return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
 
 8436QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
 const 
 8438  return tr( 
"path to layer destination" );
 
@ Standard
Unit is a standard measurement unit.
 
ProcessingSourceType
Processing data source types.
 
@ File
Files (i.e. non map layer sources, such as text files)
 
@ Annotation
Annotation layers.
 
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
 
@ VectorTile
Vector tile layers.
 
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
 
@ VectorAnyGeometry
Any vector layer with geometry.
 
@ VectorPoint
Vector point layers.
 
@ VectorPolygon
Vector polygon layers.
 
@ VectorLine
Vector line layers.
 
@ PointCloud
Point cloud layers.
 
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
 
@ File
Parameter is a single file.
 
@ Folder
Parameter is a folder.
 
ExpressionType
Expression types.
 
@ RasterCalculator
Raster calculator expression (since QGIS 3.34)
 
@ Qgis
Native QGIS expression.
 
@ PointCloud
Point cloud expression.
 
DistanceUnit
Units of distance.
 
@ Centimeters
Centimeters.
 
@ Millimeters
Millimeters.
 
@ Miles
Terrestrial miles.
 
@ Unknown
Unknown distance unit.
 
@ Degrees
Degrees, for planar geographic CRS distance measurements.
 
@ Inches
Inches (since QGIS 3.32)
 
@ NauticalMiles
Nautical miles.
 
ProcessingFieldParameterDataType
Processing field parameter data types.
 
@ String
Accepts string fields.
 
@ Boolean
Accepts boolean fields, since QGIS 3.34.
 
@ Binary
Accepts binary fields, since QGIS 3.34.
 
@ Numeric
Accepts numeric fields.
 
@ DateTime
Accepts datetime fields.
 
@ Info
Information message.
 
@ AnnotationLayer
QgsAnnotationLayer.
 
TemporalUnit
Temporal units.
 
@ Milliseconds
Milliseconds.
 
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
 
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
 
ProcessingModelChildParameterSource
Processing model child parameter sources.
 
@ ModelParameter
Parameter value is taken from a parent model parameter.
 
@ StaticValue
Parameter value is a static value.
 
@ Optional
Parameter is optional.
 
ProcessingDateTimeParameterDataType
Processing date time parameter data types.
 
@ DateTime
Datetime values.
 
ProcessingNumberParameterType
Processing numeric parameter data types.
 
@ Double
Double/float values.
 
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
@ CapturePoint
Select and capture a point or a feature.
 
Selector widget for authentication configs.
 
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing.
 
QComboBox subclass which allows selecting multiple items.
 
This class represents a coordinate reference system (CRS).
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
 
Qgis::DistanceUnit mapUnits
 
The QgsDatabaseSchemaComboBox class is a combo box which displays the list of schemas for a specific ...
 
The QgsDatabaseTableComboBox class is a combo box which displays the list of tables for a specific da...
 
The QgsDateEdit class is a QDateEdit widget with the capability of setting/reading null dates.
 
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
 
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times.
 
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
 
void setNullRepresentation(const QString &null)
Sets the widget's null representation, which defaults to QgsApplication::nullRepresentation().
 
void valueChanged(const QDateTime &date)
Signal emitted whenever the value changes.
 
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
 
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
 
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
 
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
 
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer.
 
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
 
@ DateTime
Datetime fields.
 
@ Date
Date or datetime fields.
 
@ Binary
Binary fields, since QGIS 3.34.
 
@ Boolean
Boolean fields, since QGIS 3.34.
 
@ Numeric
All numeric fields.
 
Encapsulate a field in an attribute table or data source.
 
Container of fields for a vector layer.
 
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
 
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
 
void remove(int fieldIdx)
Removes the field with the given index.
 
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
 
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
 
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
 
A geometry is the spatial representation of a feature.
 
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
 
Q_INVOKABLE QString asWkt(int precision=17) const
Exports the geometry to WKT.
 
The QgsLayoutComboBox class is a combo box which displays available layouts from a QgsLayoutManager.
 
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
 
void setAllowEmptyLayout(bool allowEmpty)
Sets whether an optional empty layout ("not set") option is present in the combobox.
 
The QgsLayoutItemComboBox class is a combo box which displays items of a matching type from a layout.
 
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
 
Base class for graphical items within a QgsLayout.
 
virtual QString uuid() const
Returns the item identification string.
 
@ FilterPrintLayouts
Includes print layouts.
 
QList< QgsPrintLayout * > printLayouts() const
Returns a list of all print layouts contained in the manager.
 
Map canvas is a class for displaying all GIS data types on a canvas.
 
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
 
The QgsMapLayerComboBox class is a combo box which displays the list of layers.
 
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
 
Base class for all map layer types.
 
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
 
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
 
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
 
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
 
Interface for master layout type objects, such as print layouts and reports.
 
virtual QString name() const =0
Returns the layout's name.
 
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
 
bool clearWidgets()
Removes all items from the bar.
 
Collection of point cloud attributes.
 
The QgsPointCloudAttributeComboBox is a combo box which displays the list of attributes of a given po...
 
void attributeChanged(const QString &name)
Emitted when the currently selected attribute changes.
 
Attribute for point cloud data pair of name and size in bytes.
 
Represents a map layer supporting display of point clouds.
 
QgsPointCloudAttributeCollection attributes() const
Returns the attributes available from the layer.
 
A class to represent a 2D point.
 
Print layout, a QgsLayout subclass for static or atlas-based layouts.
 
Abstract base class for processing algorithms.
 
An interface for objects which can create Processing contexts.
 
Contains information about the context in which a processing algorithm is executed.
 
QgsExpressionContext & expressionContext()
Returns the expression context.
 
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
 
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
 
Base class for all parameter definitions which represent file or layer destinations,...
 
Encapsulates settings relating to a feature source input to a processing algorithm.
 
QgsProperty source
Source definition.
 
WidgetType
Types of dialogs which Processing widgets can be created for.
 
@ Standard
Standard algorithm dialog.
 
@ Batch
Batch processing dialog.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the output class.
 
static QString typeName()
Returns the type name for the parameter class.
 
static QString typeName()
Returns the type name for the parameter class.
 
A raster band parameter for Processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
bool allowMultiple() const
Returns whether multiple band selections are permitted.
 
A boolean parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
A color parameter for processing algorithms.
 
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
 
static QString typeName()
Returns the type name for the parameter class.
 
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
 
static QString typeName()
Returns the type name for the parameter class.
 
QVariant sourceCrs() const
Returns the static source CRS, or an invalid value if this is not set.
 
QVariant destinationCrs() const
Returns the static destination CRS, or an invalid value if this is not set.
 
A coordinate reference system parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
 
static QString typeName()
Returns the type name for the parameter class.
 
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
 
A database table name parameter for processing algorithms, allowing users to select from existing dat...
 
static QString typeName()
Returns the type name for the parameter class.
 
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
 
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
 
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
 
A datetime (or pure date or time) parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
 
Base class for the definition of processing parameters.
 
void setFlags(Qgis::ProcessingParameterFlags flags)
Sets the flags associated with the parameter.
 
QVariantMap metadata() const
Returns the parameter's freeform metadata.
 
QString description() const
Returns the description for the parameter.
 
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
 
virtual QString type() const =0
Unique parameter type name.
 
QString name() const
Returns the name of the parameter.
 
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
 
A double numeric parameter for distance values.
 
static QString typeName()
Returns the type name for the parameter class.
 
Qgis::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
 
A double numeric parameter for duration values.
 
Qgis::TemporalUnit defaultUnit() const
Returns the default duration unit for the parameter.
 
static QString typeName()
Returns the type name for the parameter class.
 
An enum based parameter for processing algorithms, allowing for selection from predefined values.
 
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
 
QStringList options() const
Returns the list of acceptable options for the parameter.
 
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
 
static QString typeName()
Returns the type name for the parameter class.
 
An expression parameter for processing algorithms.
 
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
 
static QString typeName()
Returns the type name for the parameter class.
 
Qgis::ExpressionType expressionType() const
Returns the parameter's expression type.
 
A rectangular map extent 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.
 
An input feature source (such as vector layers) parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
A vector layer or feature source field parameter for processing algorithms.
 
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
 
bool allowMultiple() const
Returns whether multiple field selections are permitted.
 
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
 
static QString typeName()
Returns the type name for the parameter class.
 
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
 
static QString typeName()
Returns the type name for the parameter class.
 
An input file or folder parameter for processing algorithms.
 
QString extension() const
Returns any specified file extension for the parameter.
 
static QString typeName()
Returns the type name for the parameter class.
 
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
 
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
 
static QString typeName()
Returns the type name for the parameter class.
 
A geometry parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
A print layout item parameter, allowing users to select a particular item from a print layout.
 
static QString typeName()
Returns the type name for the parameter class.
 
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
 
A print layout parameter, allowing users to select a print layout.
 
static QString typeName()
Returns the type name for the parameter class.
 
A map layer parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
 
static QString typeName()
Returns the type name for the parameter class.
 
A table (matrix) 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.
 
A parameter for processing algorithms which accepts multiple map layers.
 
static QString typeName()
Returns the type name for the parameter class.
 
A numeric parameter for processing algorithms.
 
double minimum() const
Returns the minimum value acceptable by the parameter.
 
double maximum() const
Returns the maximum value acceptable by the parameter.
 
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
 
static QString typeName()
Returns the type name for the parameter class.
 
A point cloud layer attribute parameter for Processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
bool allowMultiple() const
Returns whether multiple field selections are permitted.
 
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
 
static QString typeName()
Returns the type name for the parameter class.
 
A point cloud layer parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
A point parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
A data provider connection parameter for processing algorithms, allowing users to select from availab...
 
static QString typeName()
Returns the type name for the parameter class.
 
QString providerId() const
Returns the ID of the provider associated with the connections.
 
A numeric range parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
 
static QString typeName()
Returns the type name for the parameter class.
 
A raster layer parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
A double numeric parameter for map scale values.
 
static QString typeName()
Returns the type name for the parameter class.
 
A string parameter for processing algorithms.
 
static QString typeName()
Returns the type name for the parameter class.
 
bool multiLine() const
Returns true if the parameter allows multiline strings.
 
static QString typeName()
Returns the type name for the parameter class.
 
A vector layer (with or without geometry) 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.
 
Contains settings which reflect the context in which a Processing parameter widget is shown,...
 
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
 
QgsProject * project() const
Returns the project associated with the widget.
 
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
 
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
 
QgsMapLayer * activeLayer() const
Returns the current active layer.
 
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
 
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
 
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
 
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
 
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a list of map layers.
 
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
 
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
 
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
 
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
 
static QStringList parameterAsStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of strings (e.g.
 
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
 
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
 
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
 
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a point cloud layer.
 
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter 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...
 
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
 
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 ...
 
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
 
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
 
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
 
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
 
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
 
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
 
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
 
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
 
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
 
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
 
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
 
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
 
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
 
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
 
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
 
Utility functions for use with processing classes.
 
@ Annotation
Annotation layer type, since QGIS 3.22.
 
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
 
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
 
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
QgsMapThemeCollection * mapThemeCollection
 
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
 
void layerRemoved(const QString &layerId)
Emitted after a layer was removed from the registry.
 
A store for object properties.
 
Qgis::PropertyType propertyType() const
Returns the property type.
 
The QgsProviderConnectionComboBox class is a combo box which displays the list of connections registe...
 
A combobox widget which displays the bands present in a raster layer.
 
void bandChanged(int band)
Emitted when the currently selected band changes.
 
static QString displayBandName(QgsRasterDataProvider *provider, int band)
Returns a user-friendly band name for the specified band.
 
Base class for raster data providers.
 
virtual int bandCount() const =0
Gets number of bands.
 
Represents a raster layer.
 
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
 
A rectangle specified with double values.
 
A class for drawing transient features (e.g.
 
@ ICON_X
A cross is used to highlight points (x)
 
This class is a composition of two QSettings instances:
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
 
Class that shows snapping marker on map canvas for the current snapping match.
 
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
 
The QgsTimeEdit class is a QTimeEdit widget with the capability of setting/reading null date/times.
 
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
 
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
 
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
 
static Q_INVOKABLE Qgis::DistanceUnitType unitType(Qgis::DistanceUnit unit)
Returns the type for a distance unit.
 
Represents a vector layer which manages a vector based data sets.
 
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
 
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
 
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
 
const QgsCoordinateReferenceSystem & crs