20 #include "processing/models/qgsprocessingmodelalgorithm.h"
30 #include "qgssettings.h"
64 #include <QToolButton>
66 #include <QHBoxLayout>
67 #include <QVBoxLayout>
71 #include <QPlainTextEdit>
72 #include <QRadioButton>
73 #include <QButtonGroup>
75 #include <QFileDialog>
87 QVBoxLayout *vlayout =
new QVBoxLayout();
88 vlayout->setContentsMargins( 0, 0, 0, 0 );
90 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
94 mDefaultCheckBox->setChecked(
false );
95 vlayout->addWidget( mDefaultCheckBox );
99 QgsProcessingParameterDefinition *QgsProcessingBooleanParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
101 auto param = std::make_unique< QgsProcessingParameterBoolean >( name, description, mDefaultCheckBox->isChecked() );
102 param->setFlags( flags );
103 return param.release();
113 QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
119 QString description = parameterDefinition()->description();
121 description = QObject::tr(
"%1 [optional]" ).arg( description );
123 mCheckBox =
new QCheckBox( description );
124 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
126 connect( mCheckBox, &QCheckBox::toggled,
this, [ = ]
128 emit widgetValueHasChanged(
this );
136 mComboBox =
new QComboBox();
137 mComboBox->addItem( tr(
"Yes" ),
true );
138 mComboBox->addItem( tr(
"No" ),
false );
139 mComboBox->setToolTip( parameterDefinition()->toolTip() );
141 connect( mComboBox, qOverload< int>( &QComboBox::currentIndexChanged ),
this, [ = ]
143 emit widgetValueHasChanged(
this );
152 QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
161 void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
168 mCheckBox->setChecked( v );
176 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
182 QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
187 return mCheckBox->isChecked();
191 return mComboBox->currentData();
196 QStringList QgsProcessingBooleanWidgetWrapper::compatibleParameterTypes()
const
215 QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes()
const
226 QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
233 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
238 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
249 QVBoxLayout *vlayout =
new QVBoxLayout();
250 vlayout->setContentsMargins( 0, 0, 0, 0 );
252 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
257 mCrsSelector->setShowAccuracyWarnings(
true );
264 vlayout->addWidget( mCrsSelector );
265 setLayout( vlayout );
268 QgsProcessingParameterDefinition *QgsProcessingCrsParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
270 auto param = std::make_unique< QgsProcessingParameterCrs >( name, description, mCrsSelector->crs().authid() );
271 param->setFlags( flags );
272 return param.release();
281 QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
283 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
285 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
294 emit widgetValueHasChanged(
this );
302 return mProjectionSelectionWidget;
307 QWidget *w =
new QWidget();
308 w->setToolTip( parameterDefinition()->toolTip() );
310 QVBoxLayout *vl =
new QVBoxLayout();
311 vl->setContentsMargins( 0, 0, 0, 0 );
314 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
315 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
316 vl->addWidget( mUseProjectCrsCheckBox );
317 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
318 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [ = ]
320 emit widgetValueHasChanged(
this );
323 vl->addWidget( mProjectionSelectionWidget );
331 void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
333 if ( mUseProjectCrsCheckBox )
335 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
337 mUseProjectCrsCheckBox->setChecked(
true );
342 mUseProjectCrsCheckBox->setChecked(
false );
347 if ( mProjectionSelectionWidget )
348 mProjectionSelectionWidget->setCrs( v );
351 QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
353 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
354 return QStringLiteral(
"ProjectCrs" );
355 else if ( mProjectionSelectionWidget )
356 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
361 QStringList QgsProcessingCrsWidgetWrapper::compatibleParameterTypes()
const
373 QStringList QgsProcessingCrsWidgetWrapper::compatibleOutputTypes()
const
381 QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
383 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
386 QString QgsProcessingCrsWidgetWrapper::parameterType()
const
393 return new QgsProcessingCrsWidgetWrapper( parameter, type );
398 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
411 QVBoxLayout *vlayout =
new QVBoxLayout();
412 vlayout->setContentsMargins( 0, 0, 0, 0 );
414 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
416 mDefaultLineEdit =
new QLineEdit();
419 vlayout->addWidget( mDefaultLineEdit );
421 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
423 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
424 vlayout->addWidget( mMultiLineCheckBox );
426 setLayout( vlayout );
429 QgsProcessingParameterDefinition *QgsProcessingStringParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
431 auto param = std::make_unique< QgsProcessingParameterString >( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
432 param->setFlags( flags );
433 return param.release();
444 QWidget *QgsProcessingStringWidgetWrapper::createWidget()
453 mPlainTextEdit =
new QPlainTextEdit();
454 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
456 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [ = ]
458 emit widgetValueHasChanged(
this );
460 return mPlainTextEdit;
464 mLineEdit =
new QLineEdit();
465 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
467 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
469 emit widgetValueHasChanged(
this );
477 mLineEdit =
new QLineEdit();
478 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
480 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
482 emit widgetValueHasChanged(
this );
490 void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
494 mLineEdit->setText( v );
495 if ( mPlainTextEdit )
496 mPlainTextEdit->setPlainText( v );
499 QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
502 return mLineEdit->text();
503 else if ( mPlainTextEdit )
504 return mPlainTextEdit->toPlainText();
509 QStringList QgsProcessingStringWidgetWrapper::compatibleParameterTypes()
const
524 QStringList QgsProcessingStringWidgetWrapper::compatibleOutputTypes()
const
532 QString QgsProcessingStringWidgetWrapper::parameterType()
const
539 return new QgsProcessingStringWidgetWrapper( parameter, type );
544 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
559 QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
568 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
572 emit widgetValueHasChanged(
this );
574 return mAuthConfigSelect;
580 void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
583 if ( mAuthConfigSelect )
584 mAuthConfigSelect->setConfigId( v );
587 QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
589 if ( mAuthConfigSelect )
590 return mAuthConfigSelect->configId();
595 QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleParameterTypes()
const
603 QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleOutputTypes()
const
608 QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
615 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
625 QVBoxLayout *vlayout =
new QVBoxLayout();
626 vlayout->setContentsMargins( 0, 0, 0, 0 );
628 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
630 mTypeComboBox =
new QComboBox();
633 vlayout->addWidget( mTypeComboBox );
635 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
636 mMinLineEdit =
new QLineEdit();
637 vlayout->addWidget( mMinLineEdit );
639 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
640 mMaxLineEdit =
new QLineEdit();
641 vlayout->addWidget( mMaxLineEdit );
643 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
644 mDefaultLineEdit =
new QLineEdit();
645 vlayout->addWidget( mDefaultLineEdit );
649 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( numberParam->dataType() ) );
650 mMinLineEdit->setText( QString::number( numberParam->minimum() ) );
651 mMaxLineEdit->setText( QString::number( numberParam->maximum() ) );
652 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
655 setLayout( vlayout );
658 QgsProcessingParameterDefinition *QgsProcessingNumberParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
661 double val = mDefaultLineEdit->text().toDouble( &ok );
664 auto param = std::make_unique< QgsProcessingParameterNumber >( name, description, dataType, ok ? val : QVariant() );
666 val = mMinLineEdit->text().toDouble( &ok );
669 param->setMinimum( val );
672 val = mMaxLineEdit->text().toDouble( &ok );
675 param->setMaximum( val );
678 param->setFlags( flags );
679 return param.release();
688 QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
691 const QVariantMap metadata = numberDef->
metadata();
692 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
700 QAbstractSpinBox *spinBox =
nullptr;
705 mDoubleSpinBox->setExpressionsEnabled(
true );
706 mDoubleSpinBox->setDecimals( decimals );
712 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
713 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
714 mDoubleSpinBox->setSingleStep( singleStep );
717 spinBox = mDoubleSpinBox;
722 mSpinBox->setExpressionsEnabled(
true );
726 spinBox->setToolTip( parameterDefinition()->toolTip() );
728 double max = 999999999;
733 double min = -999999999;
738 if ( mDoubleSpinBox )
740 mDoubleSpinBox->setMinimum( min );
741 mDoubleSpinBox->setMaximum( max );
745 mSpinBox->setMinimum(
static_cast< int >( min ) );
746 mSpinBox->setMaximum(
static_cast< int >( max ) );
751 mAllowingNull =
true;
752 if ( mDoubleSpinBox )
754 mDoubleSpinBox->setShowClearButton(
true );
755 const double min = mDoubleSpinBox->minimum() - 1;
756 mDoubleSpinBox->setMinimum( min );
757 mDoubleSpinBox->setValue( min );
761 mSpinBox->setShowClearButton(
true );
762 const int min = mSpinBox->minimum() - 1;
763 mSpinBox->setMinimum( min );
764 mSpinBox->setValue( min );
766 spinBox->setSpecialValueText( tr(
"Not set" ) );
774 if ( mDoubleSpinBox )
778 mDoubleSpinBox->setClearValue( defaultVal );
784 mSpinBox->setClearValue( intVal );
790 if ( mDoubleSpinBox )
791 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
793 mSpinBox->setClearValue(
static_cast< int >( numberDef->
minimum() ) );
798 if ( mDoubleSpinBox )
800 mDoubleSpinBox->setValue( 0 );
801 mDoubleSpinBox->setClearValue( 0 );
805 mSpinBox->setValue( 0 );
806 mSpinBox->setClearValue( 0 );
811 if ( mDoubleSpinBox )
812 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
814 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
822 void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
824 if ( mDoubleSpinBox )
826 if ( mAllowingNull && !value.isValid() )
827 mDoubleSpinBox->clear();
831 mDoubleSpinBox->setValue( v );
836 if ( mAllowingNull && !value.isValid() )
841 mSpinBox->setValue( v );
846 QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
848 if ( mDoubleSpinBox )
850 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
853 return mDoubleSpinBox->value();
857 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
860 return mSpinBox->value();
866 QStringList QgsProcessingNumericWidgetWrapper::compatibleParameterTypes()
const
875 QStringList QgsProcessingNumericWidgetWrapper::compatibleOutputTypes()
const
881 double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
883 const double valueRange = maximum - minimum;
884 if ( valueRange <= 1.0 )
886 const double step = valueRange / 10.0;
888 return qgsRound( step, -std::floor( std::log( step ) ) );
896 QString QgsProcessingNumericWidgetWrapper::parameterType()
const
903 return new QgsProcessingNumericWidgetWrapper( parameter, type );
908 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
918 QVBoxLayout *vlayout =
new QVBoxLayout();
919 vlayout->setContentsMargins( 0, 0, 0, 0 );
921 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
923 mParentLayerComboBox =
new QComboBox();
925 QString initialParent;
927 initialParent = distParam->parentParameterName();
929 if (
auto *lModel = widgetContext.
model() )
932 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
933 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
937 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
938 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
940 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
945 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
946 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
948 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
953 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
954 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
956 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
961 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
962 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
964 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
970 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
973 mParentLayerComboBox->addItem( initialParent, initialParent );
974 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
977 vlayout->addWidget( mParentLayerComboBox );
979 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
980 mMinLineEdit =
new QLineEdit();
981 vlayout->addWidget( mMinLineEdit );
983 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
984 mMaxLineEdit =
new QLineEdit();
985 vlayout->addWidget( mMaxLineEdit );
987 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
988 mDefaultLineEdit =
new QLineEdit();
989 vlayout->addWidget( mDefaultLineEdit );
993 mMinLineEdit->setText( QString::number( distParam->minimum() ) );
994 mMaxLineEdit->setText( QString::number( distParam->maximum() ) );
995 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
998 setLayout( vlayout );
1001 QgsProcessingParameterDefinition *QgsProcessingDistanceParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1004 double val = mDefaultLineEdit->text().toDouble( &ok );
1006 auto param = std::make_unique< QgsProcessingParameterDistance >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1008 val = mMinLineEdit->text().toDouble( &ok );
1011 param->setMinimum( val );
1014 val = mMaxLineEdit->text().toFloat( &ok );
1017 param->setMaximum( val );
1020 param->setFlags( flags );
1021 return param.release();
1025 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1030 QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
1037 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
1040 QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1044 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1049 mLabel =
new QLabel();
1050 mUnitsCombo =
new QComboBox();
1058 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1059 QHBoxLayout *layout =
new QHBoxLayout();
1060 layout->addWidget( spin, 1 );
1061 layout->insertSpacing( 1, labelMargin / 2 );
1062 layout->insertWidget( 2, mLabel );
1063 layout->insertWidget( 3, mUnitsCombo );
1068 mWarningLabel =
new QWidget();
1069 QHBoxLayout *warningLayout =
new QHBoxLayout();
1070 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1071 QLabel *warning =
new QLabel();
1073 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1074 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1075 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1076 warningLayout->insertSpacing( 0, labelMargin / 2 );
1077 warningLayout->insertWidget( 1, warning );
1078 mWarningLabel->setLayout( warningLayout );
1079 layout->insertWidget( 4, mWarningLabel );
1081 QWidget *w =
new QWidget();
1082 layout->setContentsMargins( 0, 0, 0, 0 );
1083 w->setLayout( layout );
1098 void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1100 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1107 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1109 setUnitParameterValue( wrapper->parameterValue() );
1112 setUnitParameterValue( wrapper->parameterValue() );
1126 void QgsProcessingDistanceWidgetWrapper::setUnitParameterValue(
const QVariant &value )
1132 std::unique_ptr< QgsProcessingContext > tmpContext;
1133 if ( mProcessingContextGenerator )
1134 context = mProcessingContextGenerator->processingContext();
1138 tmpContext = std::make_unique< QgsProcessingContext >();
1139 context = tmpContext.get();
1156 mUnitsCombo->hide();
1161 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( units ) );
1162 mUnitsCombo->show();
1169 QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1171 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1172 if ( val.type() == QVariant::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1185 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1195 QVBoxLayout *vlayout =
new QVBoxLayout();
1196 vlayout->setContentsMargins( 0, 0, 0, 0 );
1198 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1200 mDefaultLineEdit =
new QLineEdit();
1204 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1207 vlayout->addWidget( mDefaultLineEdit );
1209 setLayout( vlayout );
1212 QgsProcessingParameterDefinition *QgsProcessingScaleParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1215 double val = mDefaultLineEdit->text().toDouble( &ok );
1216 auto param = std::make_unique< QgsProcessingParameterScale >( name, description, ok ? val : QVariant() );
1217 param->setFlags( flags );
1218 return param.release();
1222 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1227 QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1234 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1237 QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
1249 mScaleWidget->setAllowNull(
true );
1251 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
1252 mScaleWidget->setShowCurrentScaleButton(
true );
1254 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
1257 emit widgetValueHasChanged(
this );
1259 return mScaleWidget;
1268 mScaleWidget->setMapCanvas( context.
mapCanvas() );
1273 QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
1275 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
1278 void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1282 if ( mScaleWidget->allowNull() && !value.isValid() )
1283 mScaleWidget->setNull();
1287 mScaleWidget->setScale( v );
1294 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1305 QVBoxLayout *vlayout =
new QVBoxLayout();
1306 vlayout->setContentsMargins( 0, 0, 0, 0 );
1308 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
1310 mTypeComboBox =
new QComboBox();
1313 vlayout->addWidget( mTypeComboBox );
1315 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1316 mMinLineEdit =
new QLineEdit();
1317 vlayout->addWidget( mMinLineEdit );
1319 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1320 mMaxLineEdit =
new QLineEdit();
1321 vlayout->addWidget( mMaxLineEdit );
1325 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( rangeParam->dataType() ) );
1327 mMinLineEdit->setText( QString::number( range.at( 0 ) ) );
1328 mMaxLineEdit->setText( QString::number( range.at( 1 ) ) );
1331 setLayout( vlayout );
1334 QgsProcessingParameterDefinition *QgsProcessingRangeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1336 QString defaultValue;
1337 if ( mMinLineEdit->text().isEmpty() )
1339 defaultValue = QStringLiteral(
"None" );
1343 defaultValue = mMinLineEdit->text();
1346 if ( mMaxLineEdit->text().isEmpty() )
1348 defaultValue += QLatin1String(
",None" );
1352 defaultValue += QStringLiteral(
"," ) + mMaxLineEdit->text();
1356 auto param = std::make_unique< QgsProcessingParameterRange >( name, description, dataType, defaultValue );
1357 param->setFlags( flags );
1358 return param.release();
1368 QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
1377 QHBoxLayout *layout =
new QHBoxLayout();
1382 mMinSpinBox->setExpressionsEnabled(
true );
1383 mMinSpinBox->setShowClearButton(
false );
1384 mMaxSpinBox->setExpressionsEnabled(
true );
1385 mMaxSpinBox->setShowClearButton(
false );
1387 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
1388 layout->addWidget( minLabel );
1389 layout->addWidget( mMinSpinBox, 1 );
1391 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
1392 layout->addWidget( maxLabel );
1393 layout->addWidget( mMaxSpinBox, 1 );
1395 QWidget *w =
new QWidget();
1396 layout->setContentsMargins( 0, 0, 0, 0 );
1397 w->setLayout( layout );
1401 mMinSpinBox->setDecimals( 6 );
1402 mMaxSpinBox->setDecimals( 6 );
1406 mMinSpinBox->setDecimals( 0 );
1407 mMaxSpinBox->setDecimals( 0 );
1410 mMinSpinBox->setMinimum( -99999999.999999 );
1411 mMaxSpinBox->setMinimum( -99999999.999999 );
1412 mMinSpinBox->setMaximum( 99999999.999999 );
1413 mMaxSpinBox->setMaximum( 99999999.999999 );
1417 mAllowingNull =
true;
1419 const double min = mMinSpinBox->minimum() - 1;
1420 mMinSpinBox->setMinimum( min );
1421 mMaxSpinBox->setMinimum( min );
1422 mMinSpinBox->setValue( min );
1423 mMaxSpinBox->setValue( min );
1425 mMinSpinBox->setShowClearButton(
true );
1426 mMaxSpinBox->setShowClearButton(
true );
1427 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
1428 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
1431 w->setToolTip( parameterDefinition()->toolTip() );
1433 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1435 mBlockChangedSignal++;
1436 if ( !mAllowingNull && v > mMaxSpinBox->value() )
1437 mMaxSpinBox->setValue( v );
1438 mBlockChangedSignal--;
1440 if ( !mBlockChangedSignal )
1441 emit widgetValueHasChanged(
this );
1443 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1445 mBlockChangedSignal++;
1446 if ( !mAllowingNull && v < mMinSpinBox->value() )
1447 mMinSpinBox->setValue( v );
1448 mBlockChangedSignal--;
1450 if ( !mBlockChangedSignal )
1451 emit widgetValueHasChanged(
this );
1460 void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1463 if ( mAllowingNull && v.empty() )
1465 mMinSpinBox->clear();
1466 mMaxSpinBox->clear();
1473 if ( mAllowingNull )
1475 mBlockChangedSignal++;
1476 if ( std::isnan( v.at( 0 ) ) )
1477 mMinSpinBox->clear();
1479 mMinSpinBox->setValue( v.at( 0 ) );
1481 if ( v.count() >= 2 )
1483 if ( std::isnan( v.at( 1 ) ) )
1484 mMaxSpinBox->clear();
1486 mMaxSpinBox->setValue( v.at( 1 ) );
1488 mBlockChangedSignal--;
1492 mBlockChangedSignal++;
1493 mMinSpinBox->setValue( v.at( 0 ) );
1494 if ( v.count() >= 2 )
1495 mMaxSpinBox->setValue( v.at( 1 ) );
1496 mBlockChangedSignal--;
1500 if ( !mBlockChangedSignal )
1501 emit widgetValueHasChanged(
this );
1504 QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
1506 if ( mAllowingNull )
1509 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
1510 value = QStringLiteral(
"None" );
1512 value = QString::number( mMinSpinBox->value() );
1514 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
1515 value += QLatin1String(
",None" );
1517 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
1522 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
1525 QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
const
1527 return QStringList()
1532 QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
const
1537 QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
1539 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
1542 QString QgsProcessingRangeWidgetWrapper::parameterType()
const
1549 return new QgsProcessingRangeWidgetWrapper( parameter, type );
1554 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1565 QVBoxLayout *vlayout =
new QVBoxLayout();
1566 vlayout->setContentsMargins( 0, 0, 0, 0 );
1568 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
1571 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
1572 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
1574 vlayout->addWidget( mMatrixWidget );
1575 setLayout( vlayout );
1578 QgsProcessingParameterDefinition *QgsProcessingMatrixParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1580 auto param = std::make_unique< QgsProcessingParameterMatrix >( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
1581 param->setFlags( flags );
1582 return param.release();
1592 QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
1594 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast< const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
1595 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
1597 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [ = ]
1599 emit widgetValueHasChanged(
this );
1608 return mMatrixWidget;
1614 void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1617 if ( mMatrixWidget )
1618 mMatrixWidget->setValue( v );
1621 QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
1623 if ( mMatrixWidget )
1624 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
1629 QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
const
1631 return QStringList()
1635 QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
const
1637 return QStringList();
1640 QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
1642 return tr(
"comma delimited string of values, or an array of values" );
1645 QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
1652 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
1657 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1669 QVBoxLayout *vlayout =
new QVBoxLayout();
1670 vlayout->setContentsMargins( 0, 0, 0, 0 );
1672 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
1674 mTypeComboBox =
new QComboBox();
1678 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( fileParam->behavior() ) );
1680 mTypeComboBox->setCurrentIndex( 0 );
1681 vlayout->addWidget( mTypeComboBox );
1683 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
1685 mFilterComboBox =
new QComboBox();
1686 mFilterComboBox->setEditable(
true );
1688 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
1689 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
1690 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
1691 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
1693 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
1695 mFilterComboBox->setCurrentIndex( 0 );
1696 vlayout->addWidget( mFilterComboBox );
1698 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1701 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
1705 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
1709 vlayout->addWidget( mDefaultFileWidget );
1711 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ]
1720 setLayout( vlayout );
1723 QgsProcessingParameterDefinition *QgsProcessingFileParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1725 auto param = std::make_unique< QgsProcessingParameterFile >( name, description );
1728 param->setFileFilter( mFilterComboBox->currentText() );
1729 if ( !mDefaultFileWidget->filePath().isEmpty() )
1730 param->setDefaultValue( mDefaultFileWidget->filePath() );
1731 param->setFlags( flags );
1732 return param.release();
1742 QWidget *QgsProcessingFileWidgetWrapper::createWidget()
1752 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
1753 mFileWidget->setDialogTitle( parameterDefinition()->description() );
1755 mFileWidget->setDefaultRoot( QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
1762 mFileWidget->setFilter( fileParam->
fileFilter() );
1763 else if ( !fileParam->
extension().isEmpty() )
1764 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
1774 QgsSettings().setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
1775 emit widgetValueHasChanged(
this );
1783 void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1787 mFileWidget->setFilePath( v );
1790 QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
1793 return mFileWidget->filePath();
1798 QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
const
1800 return QStringList()
1805 QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
const
1815 QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
1817 return tr(
"string representing a path to a file or folder" );
1820 QString QgsProcessingFileWidgetWrapper::parameterType()
const
1827 return new QgsProcessingFileWidgetWrapper( parameter, type );
1832 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1844 QVBoxLayout *vlayout =
new QVBoxLayout();
1845 vlayout->setContentsMargins( 0, 0, 0, 0 );
1846 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1849 mDefaultLineEdit->registerExpressionContextGenerator(
this );
1853 vlayout->addWidget( mDefaultLineEdit );
1855 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
1857 mParentLayerComboBox =
new QComboBox();
1858 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
1860 QString initialParent;
1862 initialParent = expParam->parentLayerParameterName();
1864 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
1867 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
1868 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1872 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1873 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1875 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1880 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1881 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1883 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1889 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
1892 mParentLayerComboBox->addItem( initialParent, initialParent );
1893 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1896 vlayout->addWidget( mParentLayerComboBox );
1897 setLayout( vlayout );
1900 QgsProcessingParameterDefinition *QgsProcessingExpressionParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1902 auto param = std::make_unique< QgsProcessingParameterExpression >( name, description, mDefaultLineEdit->expression(), mParentLayerComboBox->currentData().toString() );
1903 param->setFlags( flags );
1904 return param.release();
1913 QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
1925 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
1926 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
1927 mExpLineEdit->registerExpressionContextGenerator(
this );
1930 emit widgetValueHasChanged(
this );
1932 return mExpLineEdit;
1936 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
1939 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
1940 mExpBuilderWidget->init( createExpressionContext() );
1943 Q_UNUSED( changed );
1944 emit widgetValueHasChanged(
this );
1946 return mExpBuilderWidget;
1951 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
1952 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
1953 mFieldExpWidget->registerExpressionContextGenerator(
this );
1955 mFieldExpWidget->setAllowEmptyFieldName(
true );
1959 emit widgetValueHasChanged(
this );
1961 return mFieldExpWidget;
1969 void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1979 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterExpression *
>( parameterDefinition() )->parentLayerParameterName() )
1981 setParentLayerWrapperValue( wrapper );
1984 setParentLayerWrapperValue( wrapper );
2000 if ( mExpBuilderWidget )
2003 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2011 std::unique_ptr< QgsProcessingContext > tmpContext;
2012 if ( mProcessingContextGenerator )
2013 context = mProcessingContextGenerator->processingContext();
2017 tmpContext = std::make_unique< QgsProcessingContext >();
2018 context = tmpContext.get();
2032 if ( mFieldExpWidget )
2033 mFieldExpWidget->setLayer(
nullptr );
2034 else if ( mExpBuilderWidget )
2035 mExpBuilderWidget->setLayer(
nullptr );
2036 else if ( mExpLineEdit )
2037 mExpLineEdit->setLayer(
nullptr );
2043 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
2046 mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
2047 layer = mParentLayer.get();
2054 if ( mFieldExpWidget )
2055 mFieldExpWidget->setLayer( layer );
2056 if ( mExpBuilderWidget )
2057 mExpBuilderWidget->setLayer( layer );
2058 else if ( mExpLineEdit )
2059 mExpLineEdit->setLayer( layer );
2062 void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2065 if ( mFieldExpWidget )
2066 mFieldExpWidget->setExpression( v );
2067 else if ( mExpBuilderWidget )
2068 mExpBuilderWidget->setExpressionText( v );
2069 else if ( mExpLineEdit )
2070 mExpLineEdit->setExpression( v );
2073 QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2075 if ( mFieldExpWidget )
2076 return mFieldExpWidget->expression();
2077 if ( mExpBuilderWidget )
2078 return mExpBuilderWidget->expressionText();
2079 else if ( mExpLineEdit )
2080 return mExpLineEdit->expression();
2085 QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
const
2087 return QStringList()
2096 QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
const
2098 return QStringList()
2103 QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2105 return tr(
"string representation of an expression" );
2108 const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
2110 if ( mFieldExpWidget && mFieldExpWidget->layer() )
2111 return mFieldExpWidget->layer();
2113 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
2114 return mExpBuilderWidget->layer();
2119 QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
2126 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
2131 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2144 QHBoxLayout *hl =
new QHBoxLayout();
2145 hl->setContentsMargins( 0, 0, 0, 0 );
2147 mLineEdit =
new QLineEdit();
2148 mLineEdit->setEnabled(
false );
2149 hl->addWidget( mLineEdit, 1 );
2151 mToolButton =
new QToolButton();
2152 mToolButton->setText( QString( QChar( 0x2026 ) ) );
2153 hl->addWidget( mToolButton );
2159 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2162 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
2165 void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
2167 if ( value.isValid() )
2169 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
2171 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
2177 updateSummaryText();
2181 void QgsProcessingEnumPanelWidget::showDialog()
2183 QVariantList availableOptions;
2186 availableOptions.reserve( mParam->options().size() );
2187 for (
int i = 0; i < mParam->options().count(); ++i )
2188 availableOptions << i;
2191 const QStringList options = mParam ? mParam->options() : QStringList();
2195 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
2196 widget->setPanelTitle( mParam->description() );
2198 if ( mParam->usesStaticStrings() )
2200 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
2202 const QString i = v.toString();
2203 return options.contains( i ) ? i : QString();
2208 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
2210 const int i = v.toInt();
2211 return options.size() > i ? options.at( i ) : QString();
2215 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
2217 setValue( widget->selectedOptions() );
2224 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
2226 dlg.setValueFormatter( [options](
const QVariant & v ) -> QString
2228 const int i = v.toInt();
2229 return options.size() > i ? options.at( i ) : QString();
2233 setValue( dlg.selectedOptions() );
2238 void QgsProcessingEnumPanelWidget::updateSummaryText()
2241 mLineEdit->setText( tr(
"%1 options selected" ).arg( mValue.count() ) );
2248 QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
2251 , mButtonGroup( new QButtonGroup( this ) )
2252 , mColumns( columns )
2254 mButtonGroup->setExclusive( !mParam->allowMultiple() );
2256 QGridLayout *l =
new QGridLayout();
2257 l->setContentsMargins( 0, 0, 0, 0 );
2259 int rows =
static_cast< int >( std::ceil( mParam->options().count() /
static_cast< double >( mColumns ) ) );
2260 for (
int i = 0; i < mParam->options().count(); ++i )
2262 QAbstractButton *button =
nullptr;
2263 if ( mParam->allowMultiple() )
2264 button =
new QCheckBox( mParam->options().at( i ) );
2266 button =
new QRadioButton( mParam->options().at( i ) );
2268 connect( button, &QAbstractButton::toggled,
this, [ = ]
2270 if ( !mBlockChangedSignal )
2274 mButtons.insert( i, button );
2276 mButtonGroup->addButton( button, i );
2277 l->addWidget( button, i % rows, i / rows );
2279 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
2282 if ( mParam->allowMultiple() )
2284 setContextMenuPolicy( Qt::CustomContextMenu );
2285 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
2289 QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
2291 if ( mParam->allowMultiple() )
2294 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2296 if ( it.value()->isChecked() )
2297 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
2303 if ( mParam->usesStaticStrings() )
2304 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
2306 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
2310 void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
2312 mBlockChangedSignal =
true;
2313 if ( mParam->allowMultiple() )
2315 QVariantList selected;
2316 if ( value.isValid() )
2317 selected = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
2318 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2320 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
2321 it.value()->setChecked( selected.contains( v ) );
2327 if ( v.type() == QVariant::List )
2328 v = v.toList().value( 0 );
2330 v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
2331 if ( mButtons.contains( v ) )
2332 mButtons.value( v )->setChecked(
true );
2334 mBlockChangedSignal =
false;
2338 void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
2341 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
2342 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
2343 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
2344 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
2345 popupMenu.addAction( selectAllAction );
2346 popupMenu.addAction( clearAllAction );
2347 popupMenu.exec( QCursor::pos() );
2350 void QgsProcessingEnumCheckboxPanelWidget::selectAll()
2352 mBlockChangedSignal =
true;
2353 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2354 it.value()->setChecked(
true );
2355 mBlockChangedSignal =
false;
2359 void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
2361 mBlockChangedSignal =
true;
2362 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2363 it.value()->setChecked(
false );
2364 mBlockChangedSignal =
false;
2376 QVBoxLayout *vlayout =
new QVBoxLayout();
2377 vlayout->setContentsMargins( 0, 0, 0, 0 );
2379 mEnumWidget =
new QgsProcessingEnumModelerWidget();
2382 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
2383 mEnumWidget->setOptions( enumParam->options() );
2384 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
2386 vlayout->addWidget( mEnumWidget );
2387 setLayout( vlayout );
2390 QgsProcessingParameterDefinition *QgsProcessingEnumParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
2392 auto param = std::make_unique< QgsProcessingParameterEnum >( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
2394 return param.release();
2404 QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
2412 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
2414 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
2415 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
2416 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
2417 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [ = ]
2419 emit widgetValueHasChanged(
this );
2421 return mCheckboxPanel;
2430 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
2431 mPanel->setToolTip( parameterDefinition()->toolTip() );
2432 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [ = ]
2434 emit widgetValueHasChanged(
this );
2440 mComboBox =
new QComboBox();
2443 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
2444 const QStringList options = expParam->
options();
2445 for (
int i = 0; i < options.count(); ++i )
2448 mComboBox->addItem( options.at( i ), options.at( i ) );
2450 mComboBox->addItem( options.at( i ), i );
2453 mComboBox->setToolTip( parameterDefinition()->toolTip() );
2454 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2456 emit widgetValueHasChanged(
this );
2465 void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2469 if ( !value.isValid() )
2470 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
2477 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
2482 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
2486 else if ( mPanel || mCheckboxPanel )
2489 if ( value.isValid() )
2495 opts.reserve( v.size() );
2496 for ( QString i : v )
2502 opts.reserve( v.size() );
2508 mPanel->setValue( opts );
2509 else if ( mCheckboxPanel )
2510 mCheckboxPanel->setValue( opts );
2514 QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
2517 return mComboBox->currentData();
2519 return mPanel->value();
2520 else if ( mCheckboxPanel )
2521 return mCheckboxPanel->value();
2526 QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
const
2528 return QStringList()
2534 QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
const
2536 return QStringList()
2541 QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
2543 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
2546 QString QgsProcessingEnumWidgetWrapper::parameterType()
const
2553 return new QgsProcessingEnumWidgetWrapper( parameter, type );
2558 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2571 QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
2580 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() :
nullptr );
2582 mComboBox->setAllowEmptyLayout(
true );
2585 mComboBox->setToolTip( parameterDefinition()->toolTip() );
2588 emit widgetValueHasChanged(
this );
2595 mPlainComboBox =
new QComboBox();
2596 mPlainComboBox->setEditable(
true );
2597 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
2598 if ( widgetContext().project() )
2602 mPlainComboBox->addItem( layout->name() );
2605 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
2607 emit widgetValueHasChanged(
this );
2609 return mPlainComboBox;
2615 void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2619 if ( !value.isValid() )
2620 mComboBox->setCurrentLayout(
nullptr );
2624 mComboBox->setCurrentLayout( l );
2626 mComboBox->setCurrentLayout(
nullptr );
2629 else if ( mPlainComboBox )
2632 mPlainComboBox->setCurrentText( v );
2636 QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
2641 return l ? l->
name() : QVariant();
2643 else if ( mPlainComboBox )
2644 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
2652 if ( mPlainComboBox && context.
project() )
2656 mPlainComboBox->addItem( layout->name() );
2660 QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
const
2662 return QStringList()
2667 QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
const
2669 return QStringList()
2673 QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
2675 return tr(
"string representing the name of an existing print layout" );
2678 QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
2685 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
2699 QVBoxLayout *vlayout =
new QVBoxLayout();
2700 vlayout->setContentsMargins( 0, 0, 0, 0 );
2702 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
2704 mParentLayoutComboBox =
new QComboBox();
2705 QString initialParent;
2707 initialParent = itemParam->parentLayoutParameterName();
2709 if (
auto *lModel = widgetContext.
model() )
2712 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
2713 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2717 mParentLayoutComboBox-> addItem( definition->
description(), definition->
name() );
2718 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2720 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
2726 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
2729 mParentLayoutComboBox->addItem( initialParent, initialParent );
2730 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
2733 vlayout->addWidget( mParentLayoutComboBox );
2734 setLayout( vlayout );
2736 QgsProcessingParameterDefinition *QgsProcessingLayoutItemParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
2738 auto param = std::make_unique< QgsProcessingParameterLayoutItem >( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
2740 return param.release();
2750 QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
2761 mComboBox->setAllowEmptyItem(
true );
2762 if ( layoutParam->
itemType() >= 0 )
2765 mComboBox->setToolTip( parameterDefinition()->toolTip() );
2768 emit widgetValueHasChanged(
this );
2775 mLineEdit =
new QLineEdit();
2776 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
2777 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
2779 emit widgetValueHasChanged(
this );
2787 void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2797 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterLayoutItem *
>( parameterDefinition() )->parentLayoutParameterName() )
2799 setLayoutParameterValue( wrapper->parameterValue() );
2802 setLayoutParameterValue( wrapper->parameterValue() );
2815 void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
2821 std::unique_ptr< QgsProcessingContext > tmpContext;
2822 if ( mProcessingContextGenerator )
2823 context = mProcessingContextGenerator->processingContext();
2827 tmpContext = std::make_unique< QgsProcessingContext >();
2828 context = tmpContext.get();
2832 setLayout( layout );
2835 void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
2838 mComboBox->setCurrentLayout( layout );
2841 void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2845 if ( !value.isValid() )
2846 mComboBox->setItem(
nullptr );
2850 mComboBox->setItem( item );
2853 else if ( mLineEdit )
2856 mLineEdit->setText( v );
2860 QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
2865 return i ? i->
uuid() : QVariant();
2867 else if ( mLineEdit )
2868 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
2873 QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
const
2875 return QStringList()
2880 QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
const
2882 return QStringList()
2886 QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
2888 return tr(
"string representing the UUID or ID of an existing print layout item" );
2891 QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
2898 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
2903 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2910 QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
2917 QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
2919 void QgsProcessingPointMapTool::deactivate()
2933 if ( e->button() == Qt::LeftButton )
2936 emit clicked( point );
2941 void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
2943 if ( e->key() == Qt::Key_Escape )
2958 QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
2961 QHBoxLayout *l =
new QHBoxLayout();
2962 l->setContentsMargins( 0, 0, 0, 0 );
2964 mLineEdit->setShowClearButton(
false );
2965 l->addWidget( mLineEdit, 1 );
2966 mButton =
new QToolButton();
2967 mButton->setText( QString( QChar( 0x2026 ) ) );
2968 l->addWidget( mButton );
2971 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
2972 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
2973 mButton->setVisible(
false );
2976 void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
2979 mButton->setVisible(
true );
2982 mTool = std::make_unique< QgsProcessingPointMapTool >( mCanvas );
2983 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
2984 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
2987 void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
2989 mLineEdit->setShowClearButton( allowNull );
2992 QVariant QgsProcessingPointPanel::value()
const
2994 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
2997 void QgsProcessingPointPanel::clear()
3004 QString newText = QStringLiteral(
"%1,%2" )
3005 .arg( QString::number( point.
x(),
'f' ),
3006 QString::number( point.
y(),
'f' ) );
3009 if ( mCrs.isValid() )
3011 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
3013 mLineEdit->setText( newText );
3016 void QgsProcessingPointPanel::selectOnCanvas()
3021 mPrevTool = mCanvas->mapTool();
3022 mCanvas->setMapTool( mTool.get() );
3024 emit toggleDialogVisibility(
false );
3027 void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3029 setValue( point, mCanvas->mapSettings().destinationCrs() );
3032 void QgsProcessingPointPanel::pointPicked()
3037 mCanvas->setMapTool( mPrevTool );
3039 emit toggleDialogVisibility(
true );
3051 QVBoxLayout *vlayout =
new QVBoxLayout();
3052 vlayout->setContentsMargins( 0, 0, 0, 0 );
3054 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3056 mDefaultLineEdit =
new QLineEdit();
3057 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3058 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
3062 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
3065 vlayout->addWidget( mDefaultLineEdit );
3066 setLayout( vlayout );
3069 QgsProcessingParameterDefinition *QgsProcessingPointParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3071 auto param = std::make_unique< QgsProcessingParameterPoint >( name, description, mDefaultLineEdit->text() );
3073 return param.release();
3082 QWidget *QgsProcessingPointWidgetWrapper::createWidget()
3090 mPanel =
new QgsProcessingPointPanel(
nullptr );
3091 if ( widgetContext().mapCanvas() )
3092 mPanel->setMapCanvas( widgetContext().mapCanvas() );
3095 mPanel->setAllowNull(
true );
3097 mPanel->setToolTip( parameterDefinition()->toolTip() );
3099 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [ = ]
3101 emit widgetValueHasChanged(
this );
3105 setDialog( mDialog );
3111 mLineEdit =
new QLineEdit();
3112 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3113 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3115 emit widgetValueHasChanged(
this );
3127 mPanel->setMapCanvas( context.
mapCanvas() );
3130 void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
3135 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ](
bool visible )
3138 mDialog->showMinimized();
3141 mDialog->showNormal();
3143 mDialog->activateWindow();
3150 void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3154 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
3160 mPanel->setValue( p,
crs );
3163 else if ( mLineEdit )
3166 mLineEdit->setText( v );
3170 QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
3174 return mPanel->value();
3176 else if ( mLineEdit )
3177 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3182 QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
const
3184 return QStringList()
3189 QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
const
3191 return QStringList()
3195 QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
3197 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
3200 QString QgsProcessingPointWidgetWrapper::parameterType()
const
3207 return new QgsProcessingPointWidgetWrapper( parameter, type );
3212 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3224 QVBoxLayout *vlayout =
new QVBoxLayout();
3225 vlayout->setContentsMargins( 0, 0, 0, 0 );
3227 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3229 mDefaultLineEdit =
new QLineEdit();
3230 mDefaultLineEdit->setToolTip( tr(
"Geometry as WKT" ) );
3231 mDefaultLineEdit->setPlaceholderText( tr(
"Geometry as WKT" ) );
3236 mDefaultLineEdit->setText( g.
asWkt() );
3239 vlayout->addWidget( mDefaultLineEdit );
3240 setLayout( vlayout );
3243 QgsProcessingParameterDefinition *QgsProcessingGeometryParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3245 auto param = std::make_unique< QgsProcessingParameterGeometry >( name, description, mDefaultLineEdit->text() );
3247 return param.release();
3256 QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
3264 mLineEdit =
new QLineEdit();
3265 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
3266 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
3268 emit widgetValueHasChanged(
this );
3276 void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3282 mLineEdit->setText( g.
asWkt() );
3288 QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
3291 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3296 QStringList QgsProcessingGeometryWidgetWrapper::compatibleParameterTypes()
const
3298 return QStringList()
3305 QStringList QgsProcessingGeometryWidgetWrapper::compatibleOutputTypes()
const
3307 return QStringList()
3311 QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
3313 return tr(
"string in the Well-Known-Text format or a geometry value" );
3316 QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
3323 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
3328 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3340 QVBoxLayout *vlayout =
new QVBoxLayout();
3341 vlayout->setContentsMargins( 0, 0, 0, 0 );
3343 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3346 mDefaultColorButton->setShowNull(
true );
3347 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
3353 mDefaultColorButton->setToNull();
3355 mDefaultColorButton->setColor(
c );
3356 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
3360 mDefaultColorButton->setToNull();
3361 mAllowOpacity->setChecked(
true );
3364 vlayout->addWidget( mDefaultColorButton );
3365 vlayout->addWidget( mAllowOpacity );
3366 setLayout( vlayout );
3369 QgsProcessingParameterDefinition *QgsProcessingColorParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3371 auto param = std::make_unique< QgsProcessingParameterColor >( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
3373 return param.release();
3382 QWidget *QgsProcessingColorWidgetWrapper::createWidget()
3392 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
3395 mColorButton->setShowNull(
true );
3398 mColorButton->setToolTip( parameterDefinition()->toolTip() );
3399 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
3407 emit widgetValueHasChanged(
this );
3410 return mColorButton;
3416 void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3420 if ( !value.isValid() ||
3421 ( value.type() == QVariant::String && value.toString().isEmpty() )
3422 || ( value.type() == QVariant::Color && !value.value< QColor >().isValid() ) )
3423 mColorButton->setToNull();
3427 if ( !
c.isValid() && mColorButton->showNull() )
3428 mColorButton->setToNull();
3430 mColorButton->setColor(
c );
3435 QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
3438 return mColorButton->isNull() ? QVariant() : mColorButton->color();
3443 QStringList QgsProcessingColorWidgetWrapper::compatibleParameterTypes()
const
3445 return QStringList()
3450 QStringList QgsProcessingColorWidgetWrapper::compatibleOutputTypes()
const
3452 return QStringList()
3456 QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
3458 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
3461 QString QgsProcessingColorWidgetWrapper::parameterType()
const
3468 return new QgsProcessingColorWidgetWrapper( parameter, type );
3473 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3484 QVBoxLayout *vlayout =
new QVBoxLayout();
3485 vlayout->setContentsMargins( 0, 0, 0, 0 );
3487 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3489 mDefaultLineEdit =
new QLineEdit();
3492 vlayout->addWidget( mDefaultLineEdit );
3494 mSourceParamComboBox =
new QComboBox();
3495 mDestParamComboBox =
new QComboBox();
3496 QString initialSource;
3497 QString initialDest;
3502 initialSource = itemParam->sourceCrsParameterName();
3503 initialDest = itemParam->destinationCrsParameterName();
3508 mSourceParamComboBox->addItem( QString(), QString() );
3509 mDestParamComboBox->addItem( QString(), QString() );
3510 if (
auto *lModel = widgetContext.
model() )
3513 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3514 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3516 if ( definition && it->parameterName() == definition->
name() )
3520 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
3521 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
3522 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
3524 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
3526 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
3528 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
3533 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
3536 mSourceParamComboBox->addItem( initialSource, initialSource );
3537 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
3539 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
3542 mDestParamComboBox->addItem( initialDest, initialDest );
3543 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
3546 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
3547 vlayout->addWidget( mSourceParamComboBox );
3548 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
3549 vlayout->addWidget( mDestParamComboBox );
3553 mStaticSourceWidget->setCrs( sourceCrs );
3556 mStaticDestWidget->setCrs( destCrs );
3558 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
3559 vlayout->addWidget( mStaticSourceWidget );
3560 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
3561 vlayout->addWidget( mStaticDestWidget );
3563 setLayout( vlayout );
3566 QgsProcessingParameterDefinition *QgsProcessingCoordinateOperationParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3568 auto param = std::make_unique< QgsProcessingParameterCoordinateOperation >( name, description, mDefaultLineEdit->text(),
3569 mSourceParamComboBox->currentText(),
3570 mDestParamComboBox->currentText(),
3571 mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
3572 mStaticDestWidget->crs().isValid() ? QVariant::fromValue( mStaticDestWidget->crs() ) : QVariant() );
3574 return param.release();
3583 QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
3594 mOperationWidget->setShowMakeDefault(
false );
3595 mOperationWidget->setShowFallbackOption(
false );
3596 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
3597 mOperationWidget->setSourceCrs( mSourceCrs );
3598 mOperationWidget->setDestinationCrs( mDestCrs );
3599 mOperationWidget->setMapCanvas( mCanvas );
3604 mOperationWidget->setSelectedOperation( deets );
3609 emit widgetValueHasChanged(
this );
3612 return mOperationWidget;
3618 mLineEdit =
new QLineEdit();
3619 QHBoxLayout *layout =
new QHBoxLayout();
3620 layout->addWidget( mLineEdit, 1 );
3621 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
3623 emit widgetValueHasChanged(
this );
3626 QToolButton *button =
new QToolButton();
3627 button->setText( QString( QChar( 0x2026 ) ) );
3628 connect( button, &QToolButton::clicked,
this, [ = ]
3630 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
3633 mLineEdit->setText( dlg.selectedDatumTransform().proj );
3634 emit widgetValueHasChanged(
this );
3637 layout->addWidget( button );
3639 QWidget *w =
new QWidget();
3640 layout->setContentsMargins( 0, 0, 0, 0 );
3641 w->setLayout( layout );
3649 void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3661 setSourceCrsParameterValue( wrapper->parameterValue() );
3664 setSourceCrsParameterValue( wrapper->parameterValue() );
3669 setDestinationCrsParameterValue( wrapper->parameterValue() );
3672 setDestinationCrsParameterValue( wrapper->parameterValue() );
3687 if ( mOperationWidget )
3688 mOperationWidget->setMapCanvas( context.
mapCanvas() );
3691 void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
3693 if ( mOperationWidget )
3695 if ( !value.isValid() ||
3696 ( value.type() == QVariant::String ) )
3699 deets.
proj = value.toString();
3700 mOperationWidget->setSelectedOperation( deets );
3705 if ( !value.isValid() ||
3706 ( value.type() == QVariant::String ) )
3708 mLineEdit->setText( value.toString() );
3713 QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
3715 if ( mOperationWidget )
3716 return mOperationWidget->selectedOperation().proj;
3717 else if ( mLineEdit )
3718 return mLineEdit->text();
3723 QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleParameterTypes()
const
3725 return QStringList()
3730 QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleOutputTypes()
const
3732 return QStringList()
3736 QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
3738 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
3741 void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
3744 std::unique_ptr< QgsProcessingContext > tmpContext;
3745 if ( mProcessingContextGenerator )
3746 context = mProcessingContextGenerator->processingContext();
3750 tmpContext = std::make_unique< QgsProcessingContext >();
3751 context = tmpContext.get();
3755 if ( mOperationWidget )
3757 mOperationWidget->setSourceCrs( mSourceCrs );
3758 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
3762 void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
3765 std::unique_ptr< QgsProcessingContext > tmpContext;
3766 if ( mProcessingContextGenerator )
3767 context = mProcessingContextGenerator->processingContext();
3771 tmpContext = std::make_unique< QgsProcessingContext >();
3772 context = tmpContext.get();
3776 if ( mOperationWidget )
3778 mOperationWidget->setDestinationCrs( mDestCrs );
3779 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
3783 QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
3790 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
3795 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3808 QHBoxLayout *hl =
new QHBoxLayout();
3809 hl->setContentsMargins( 0, 0, 0, 0 );
3811 mLineEdit =
new QLineEdit();
3812 mLineEdit->setEnabled(
false );
3813 hl->addWidget( mLineEdit, 1 );
3815 mToolButton =
new QToolButton();
3816 mToolButton->setText( QString( QChar( 0x2026 ) ) );
3817 hl->addWidget( mToolButton );
3823 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3826 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
3829 void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
3834 void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
3836 if ( value.isValid() )
3837 mValue = value.type() == QVariant::List ? value.
toList() : QVariantList() << value;
3841 updateSummaryText();
3845 void QgsProcessingFieldPanelWidget::showDialog()
3847 QVariantList availableOptions;
3848 QStringList fieldNames;
3849 availableOptions.reserve( mFields.size() );
3858 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3859 widget->setPanelTitle( mParam->description() );
3861 widget->setValueFormatter( [](
const QVariant & v ) -> QString
3863 return v.toString();
3866 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
3868 setValue( widget->selectedOptions() );
3875 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3877 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
3879 return v.toString();
3883 setValue( dlg.selectedOptions() );
3888 void QgsProcessingFieldPanelWidget::updateSummaryText()
3891 mLineEdit->setText( tr(
"%1 options selected" ).arg( mValue.count() ) );
3902 QVBoxLayout *vlayout =
new QVBoxLayout();
3903 vlayout->setContentsMargins( 0, 0, 0, 0 );
3905 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
3906 mParentLayerComboBox =
new QComboBox();
3908 QString initialParent;
3910 initialParent = fieldParam->parentLayerParameterName();
3912 if (
auto *lModel = widgetContext.
model() )
3915 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3916 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3920 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
3921 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3923 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
3928 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
3929 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3931 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
3938 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
3939 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3941 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
3948 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
3951 mParentLayerComboBox->addItem( initialParent, initialParent );
3952 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
3955 vlayout->addWidget( mParentLayerComboBox );
3957 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
3958 mDataTypeComboBox =
new QComboBox();
3964 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData( fieldParam->dataType() ) );
3966 vlayout->addWidget( mDataTypeComboBox );
3968 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
3970 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
3972 vlayout->addWidget( mAllowMultipleCheckBox );
3974 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
3975 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
3977 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
3979 vlayout->addWidget( mDefaultToAllCheckBox );
3981 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
3983 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
3986 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3988 mDefaultLineEdit =
new QLineEdit();
3989 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
3993 mDefaultLineEdit->setText( fields.join(
';' ) );
3995 vlayout->addWidget( mDefaultLineEdit );
3997 setLayout( vlayout );
4000 QgsProcessingParameterDefinition *QgsProcessingFieldParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4003 auto param = std::make_unique< QgsProcessingParameterField >( name, description, mDefaultLineEdit->text(), mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
4005 return param.release();
4014 QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
4024 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
4025 mPanel->setToolTip( parameterDefinition()->toolTip() );
4026 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [ = ]
4028 emit widgetValueHasChanged(
this );
4044 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4047 emit widgetValueHasChanged(
this );
4055 mLineEdit =
new QLineEdit();
4056 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
4057 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4059 emit widgetValueHasChanged(
this );
4068 void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4078 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterField *
>( parameterDefinition() )->parentLayerParameterName() )
4080 setParentLayerWrapperValue( wrapper );
4083 setParentLayerWrapperValue( wrapper );
4100 std::unique_ptr< QgsProcessingContext > tmpContext;
4101 if ( mProcessingContextGenerator )
4102 context = mProcessingContextGenerator->processingContext();
4106 tmpContext = std::make_unique< QgsProcessingContext >();
4107 context = tmpContext.get();
4122 bool valueSet =
false;
4126 if ( layers.count() > 1 )
4128 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
4130 const QList< QgsMapLayer * > remainingLayers = layers.mid( 1 );
4136 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer );
4137 if ( !vlayer || !vlayer->
isValid() )
4143 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
4146 fields.
remove( fieldIdx );
4151 mComboBox->setFields( fields );
4153 mPanel->setFields( filterFields( fields ) );
4159 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
4161 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
4165 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
4168 mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
4169 layer = mParentLayer.get();
4177 mComboBox->setLayer( layer );
4179 mPanel->setFields( filterFields( layer->
fields() ) );
4189 const QgsFields fields = source->fields();
4191 mComboBox->setFields( fields );
4193 mPanel->setFields( filterFields( fields ) );
4202 mComboBox->setLayer(
nullptr );
4206 if ( value.isValid() && widgetContext().messageBar() )
4209 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent field could not be populated" ),
4210 Qgis::MessageLevel::Info );
4219 val.reserve( mPanel->fields().size() );
4222 setWidgetValue( val, *context );
4225 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
4228 void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4232 if ( !value.isValid() )
4233 mComboBox->setField( QString() );
4237 mComboBox->setField( v );
4243 if ( value.isValid() )
4246 opts.reserve( v.size() );
4247 for (
const QString &i : v )
4251 mPanel->setValue( opts );
4253 else if ( mLineEdit )
4259 mLineEdit->setText( v.join(
';' ) );
4268 QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
4271 return mComboBox->currentField();
4273 return mPanel->value();
4274 else if ( mLineEdit )
4279 return mLineEdit->text().split(
';' );
4282 return mLineEdit->text();
4288 QStringList QgsProcessingFieldWidgetWrapper::compatibleParameterTypes()
const
4290 return QStringList()
4295 QStringList QgsProcessingFieldWidgetWrapper::compatibleOutputTypes()
const
4297 return QStringList()
4301 QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
4303 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
4306 const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
4308 if ( mComboBox && mComboBox->layer() )
4309 return mComboBox->layer();
4314 QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
4327 if ( f.isNumeric() )
4332 if ( f.type() == QVariant::String )
4337 if ( f.type() == QVariant::Date || f.type() == QVariant::Time || f.type() == QVariant::DateTime )
4346 QString QgsProcessingFieldWidgetWrapper::parameterType()
const
4353 return new QgsProcessingFieldWidgetWrapper( parameter, type );
4358 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4369 QVBoxLayout *vlayout =
new QVBoxLayout();
4370 vlayout->setContentsMargins( 0, 0, 0, 0 );
4372 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4374 mDefaultComboBox =
new QComboBox();
4375 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
4378 for (
const QString &theme : mapThemes )
4382 mDefaultComboBox->setEditable(
true );
4386 if ( themeParam->defaultValueForGui().isValid() )
4389 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
4392 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
4394 vlayout->addWidget( mDefaultComboBox );
4396 setLayout( vlayout );
4399 QgsProcessingParameterDefinition *QgsProcessingMapThemeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4401 QVariant defaultVal;
4402 if ( mDefaultComboBox->currentText().isEmpty() )
4403 defaultVal = QVariant();
4405 defaultVal = mDefaultComboBox->currentText();
4406 auto param = std::make_unique< QgsProcessingParameterMapTheme>( name, description, defaultVal );
4408 return param.release();
4418 QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
4422 mComboBox =
new QComboBox();
4425 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
4428 for (
const QString &theme : mapThemes )
4440 mComboBox->setEditable(
true );
4444 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4445 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
4447 emit widgetValueHasChanged(
this );
4453 void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4457 if ( !value.isValid() )
4458 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
4461 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
4463 const QString prev = mComboBox->currentText();
4464 mComboBox->setCurrentText( v );
4466 emit widgetValueHasChanged(
this );
4469 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
4473 QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
4476 return mComboBox->currentData().toInt() == -1 ? QVariant() :
4477 !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
4478 : mComboBox->currentData();
4483 QStringList QgsProcessingMapThemeWidgetWrapper::compatibleParameterTypes()
const
4485 return QStringList()
4490 QStringList QgsProcessingMapThemeWidgetWrapper::compatibleOutputTypes()
const
4492 return QStringList()
4496 QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
4498 return tr(
"map theme as a string value (e.g. 'base maps')" );
4501 QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
4508 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
4513 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4526 QVBoxLayout *vlayout =
new QVBoxLayout();
4527 vlayout->setContentsMargins( 0, 0, 0, 0 );
4529 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
4531 mTypeComboBox =
new QComboBox();
4536 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( datetimeParam->dataType() ) );
4538 mTypeComboBox->setCurrentIndex( 0 );
4539 vlayout->addWidget( mTypeComboBox );
4541 setLayout( vlayout );
4544 QgsProcessingParameterDefinition *QgsProcessingDateTimeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4546 auto param = std::make_unique< QgsProcessingParameterDateTime >( name, description );
4549 return param.release();
4559 QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
4564 switch ( dateTimeParam->
dataType() )
4568 widget = mDateTimeEdit;
4591 widget->setToolTip( parameterDefinition()->toolTip() );
4593 if ( mDateTimeEdit )
4597 emit widgetValueHasChanged(
this );
4600 else if ( mDateEdit )
4604 emit widgetValueHasChanged(
this );
4607 else if ( mTimeEdit )
4611 emit widgetValueHasChanged(
this );
4620 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4623 void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4625 if ( mDateTimeEdit )
4629 else if ( mDateEdit )
4633 else if ( mTimeEdit )
4639 QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
4641 if ( mDateTimeEdit )
4642 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
4643 else if ( mDateEdit )
4644 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
4645 else if ( mTimeEdit )
4646 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
4651 QStringList QgsProcessingDateTimeWidgetWrapper::compatibleParameterTypes()
const
4653 return QStringList()
4658 QStringList QgsProcessingDateTimeWidgetWrapper::compatibleOutputTypes()
const
4660 return QStringList()
4664 QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
4667 if ( dateTimeParam )
4669 switch ( dateTimeParam->
dataType() )
4672 return tr(
"datetime value, or a ISO string representation of a datetime" );
4675 return tr(
"date value, or a ISO string representation of a date" );
4678 return tr(
"time value, or a ISO string representation of a time" );
4684 QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
4691 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
4705 QVBoxLayout *vlayout =
new QVBoxLayout();
4706 vlayout->setContentsMargins( 0, 0, 0, 0 );
4708 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
4709 mProviderComboBox =
new QComboBox();
4710 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
4711 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
4712 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
4714 vlayout->addWidget( mProviderComboBox );
4716 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4718 mDefaultEdit =
new QLineEdit();
4719 vlayout->addWidget( mDefaultEdit );
4720 setLayout( vlayout );
4722 if ( connectionParam )
4724 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
4729 QgsProcessingParameterDefinition *QgsProcessingProviderConnectionParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4731 QVariant defaultVal;
4732 if ( mDefaultEdit->text().isEmpty() )
4733 defaultVal = QVariant();
4735 defaultVal = mDefaultEdit->text();
4736 auto param = std::make_unique< QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
4738 return param.release();
4748 QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
4754 mProviderComboBox->setAllowEmptyConnection(
true );
4762 mProviderComboBox->setEditable(
true );
4766 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
4767 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [ = ](
const QString & )
4769 if ( mBlockSignals )
4772 emit widgetValueHasChanged(
this );
4775 return mProviderComboBox;
4780 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4783 void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4787 if ( !value.isValid() )
4788 mProviderComboBox->setCurrentIndex( -1 );
4791 if ( mProviderComboBox->isEditable() )
4793 const QString prev = mProviderComboBox->currentText();
4795 mProviderComboBox->setConnection( v );
4796 mProviderComboBox->setCurrentText( v );
4800 emit widgetValueHasChanged(
this );
4803 mProviderComboBox->setConnection( v );
4807 QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
4809 if ( mProviderComboBox )
4810 if ( mProviderComboBox->isEditable() )
4811 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
4813 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
4818 QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleParameterTypes()
const
4820 return QStringList()
4826 QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleOutputTypes()
const
4828 return QStringList()
4832 QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
4834 return tr(
"connection name as a string value" );
4837 QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
4844 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
4859 QVBoxLayout *vlayout =
new QVBoxLayout();
4860 vlayout->setContentsMargins( 0, 0, 0, 0 );
4862 mConnectionParamComboBox =
new QComboBox();
4863 QString initialConnection;
4869 if (
auto *lModel = widgetContext.
model() )
4872 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4873 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4875 if ( definition && it->parameterName() == definition->
name() )
4881 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
4882 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
4884 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
4889 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
4892 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
4893 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
4896 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
4897 vlayout->addWidget( mConnectionParamComboBox );
4899 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4901 mDefaultEdit =
new QLineEdit();
4902 vlayout->addWidget( mDefaultEdit );
4903 setLayout( vlayout );
4911 QgsProcessingParameterDefinition *QgsProcessingDatabaseSchemaParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4913 QVariant defaultVal;
4914 if ( mDefaultEdit->text().isEmpty() )
4915 defaultVal = QVariant();
4917 defaultVal = mDefaultEdit->text();
4918 auto param = std::make_unique< QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
4920 return param.release();
4930 QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
4936 mSchemaComboBox->setAllowEmptySchema(
true );
4944 mSchemaComboBox->comboBox()->setEditable(
true );
4948 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
4949 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
4951 if ( mBlockSignals )
4954 emit widgetValueHasChanged( this );
4957 return mSchemaComboBox;
4962 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4969 std::unique_ptr< QgsProcessingContext > tmpContext;
4970 if ( mProcessingContextGenerator )
4971 context = mProcessingContextGenerator->processingContext();
4975 tmpContext = std::make_unique< QgsProcessingContext >();
4976 context = tmpContext.get();
4982 if ( mSchemaComboBox )
4983 mSchemaComboBox->setConnectionName( connection, qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId() );
4987 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
4990 void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4994 if ( !value.isValid() )
4995 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
4998 if ( mSchemaComboBox->comboBox()->isEditable() )
5000 const QString prev = mSchemaComboBox->comboBox()->currentText();
5002 mSchemaComboBox->setSchema( v );
5003 mSchemaComboBox->comboBox()->setCurrentText( v );
5007 emit widgetValueHasChanged(
this );
5010 mSchemaComboBox->setSchema( v );
5014 QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5016 if ( mSchemaComboBox )
5017 if ( mSchemaComboBox->comboBox()->isEditable() )
5018 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5020 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5025 QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleParameterTypes()
const
5027 return QStringList()
5033 QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleOutputTypes()
const
5035 return QStringList()
5039 QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5041 return tr(
"database schema name as a string value" );
5044 QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5051 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5054 void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5066 setParentConnectionWrapperValue( wrapper );
5069 setParentConnectionWrapperValue( wrapper );
5093 QVBoxLayout *vlayout =
new QVBoxLayout();
5094 vlayout->setContentsMargins( 0, 0, 0, 0 );
5096 mConnectionParamComboBox =
new QComboBox();
5097 mSchemaParamComboBox =
new QComboBox();
5098 QString initialConnection;
5099 QString initialSchema;
5106 if (
auto *lModel = widgetContext.
model() )
5109 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5110 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5112 if ( definition && it->parameterName() == definition->
name() )
5117 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5118 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5120 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5125 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
5126 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5128 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5134 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5137 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5138 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5141 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
5144 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
5145 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5148 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5149 vlayout->addWidget( mConnectionParamComboBox );
5151 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
5152 vlayout->addWidget( mSchemaParamComboBox );
5154 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5156 mDefaultEdit =
new QLineEdit();
5157 vlayout->addWidget( mDefaultEdit );
5158 setLayout( vlayout );
5166 QgsProcessingParameterDefinition *QgsProcessingDatabaseTableParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5168 QVariant defaultVal;
5169 if ( mDefaultEdit->text().isEmpty() )
5170 defaultVal = QVariant();
5172 defaultVal = mDefaultEdit->text();
5173 auto param = std::make_unique< QgsProcessingParameterDatabaseTable>( name, description,
5174 mConnectionParamComboBox->currentData().toString(),
5175 mSchemaParamComboBox->currentData().toString(),
5178 return param.release();
5188 QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
5194 mTableComboBox->setAllowEmptyTable(
true );
5197 mTableComboBox->comboBox()->setEditable(
true );
5199 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
5200 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
5202 if ( mBlockSignals )
5205 emit widgetValueHasChanged( this );
5208 return mTableComboBox;
5213 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5220 std::unique_ptr< QgsProcessingContext > tmpContext;
5221 if ( mProcessingContextGenerator )
5222 context = mProcessingContextGenerator->processingContext();
5226 tmpContext = std::make_unique< QgsProcessingContext >();
5227 context = tmpContext.get();
5232 mProvider = qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId();
5233 if ( mTableComboBox && !mSchema.isEmpty() )
5235 mTableComboBox->setSchema( mSchema );
5236 mTableComboBox->setConnectionName( mConnection, mProvider );
5240 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5248 std::unique_ptr< QgsProcessingContext > tmpContext;
5249 if ( mProcessingContextGenerator )
5250 context = mProcessingContextGenerator->processingContext();
5254 tmpContext = std::make_unique< QgsProcessingContext >();
5255 context = tmpContext.get();
5261 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
5263 mTableComboBox->setSchema( mSchema );
5264 mTableComboBox->setConnectionName( mConnection, mProvider );
5268 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5273 void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5277 if ( !value.isValid() )
5278 mTableComboBox->comboBox()->setCurrentIndex( -1 );
5281 if ( mTableComboBox->comboBox()->isEditable() )
5283 const QString prev = mTableComboBox->comboBox()->currentText();
5285 mTableComboBox->setTable( v );
5286 mTableComboBox->comboBox()->setCurrentText( v );
5290 emit widgetValueHasChanged(
this );
5293 mTableComboBox->setTable( v );
5297 QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
5299 if ( mTableComboBox )
5300 if ( mTableComboBox->comboBox()->isEditable() )
5301 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
5303 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
5308 QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleParameterTypes()
const
5310 return QStringList()
5316 QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleOutputTypes()
const
5318 return QStringList()
5322 QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
5324 return tr(
"database table name as a string value" );
5327 QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
5334 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
5337 void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5349 setParentConnectionWrapperValue( wrapper );
5352 setParentConnectionWrapperValue( wrapper );
5357 setParentSchemaWrapperValue( wrapper );
5360 setParentSchemaWrapperValue( wrapper );
5380 QVBoxLayout *vlayout =
new QVBoxLayout();
5381 vlayout->setContentsMargins( 0, 0, 0, 0 );
5383 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5386 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
5389 if ( extentParam->defaultValueForGui().isValid() )
5393 mDefaultWidget->setCurrentExtent( rect,
crs );
5394 mDefaultWidget->setOutputExtentFromCurrent();
5398 mDefaultWidget->clear();
5402 vlayout->addWidget( mDefaultWidget );
5403 setLayout( vlayout );
5406 QgsProcessingParameterDefinition *QgsProcessingExtentParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5408 const QString defaultVal = mDefaultWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
5409 QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ),
5410 QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ),
5411 QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ),
5412 QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ),
5413 mDefaultWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mDefaultWidget->outputCrs().authid() ) : QString()
5415 auto param = std::make_unique< QgsProcessingParameterExtent >( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
5417 return param.release();
5428 QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
5438 if ( widgetContext().mapCanvas() )
5439 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
5442 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
5444 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
5448 emit widgetValueHasChanged(
this );
5452 setDialog( mDialog );
5454 return mExtentWidget;
5464 mExtentWidget->setMapCanvas( context.
mapCanvas() );
5467 void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
5475 mDialog->showMinimized();
5478 mDialog->showNormal();
5480 mDialog->activateWindow();
5487 void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5489 if ( mExtentWidget )
5491 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
5492 mExtentWidget->clear();
5497 mExtentWidget->setCurrentExtent( r,
crs );
5498 mExtentWidget->setOutputExtentFromUser( r,
crs );
5503 QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
5505 if ( mExtentWidget )
5507 const QString val = mExtentWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
5508 QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ),
5509 QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ),
5510 QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ),
5511 QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ),
5512 mExtentWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mExtentWidget->outputCrs().authid() ) : QString()
5515 return val.isEmpty() ? QVariant() : QVariant( val );
5521 QStringList QgsProcessingExtentWidgetWrapper::compatibleParameterTypes()
const
5523 return QStringList()
5534 QStringList QgsProcessingExtentWidgetWrapper::compatibleOutputTypes()
const
5536 return QStringList()
5543 QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
5545 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
5548 QString QgsProcessingExtentWidgetWrapper::parameterType()
const
5555 return new QgsProcessingExtentWidgetWrapper( parameter, type );
5560 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5572 QVBoxLayout *vlayout =
new QVBoxLayout();
5573 vlayout->setContentsMargins( 0, 0, 0, 0 );
5575 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
5587 for (
int i : layerParam->dataTypes() )
5589 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
5593 vlayout->addWidget( mLayerTypeComboBox );
5595 setLayout( vlayout );
5598 QgsProcessingParameterDefinition *QgsProcessingMapLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5600 QList< int > dataTypes;
5601 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
5602 dataTypes << v.toInt();
5604 auto param = std::make_unique< QgsProcessingParameterMapLayer >( name, description );
5605 param->setDataTypes( dataTypes );
5607 return param.release();
5616 QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
5618 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
5626 mComboBox->setEditable(
true );
5630 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5632 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [ = ]()
5634 if ( mBlockSignals )
5637 emit widgetValueHasChanged(
this );
5640 setWidgetContext( widgetContext() );
5649 mComboBox->setWidgetContext( context );
5654 if ( !parameterDefinition()->defaultValueForGui().isValid() )
5660 void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5663 mComboBox->setValue( value, context );
5666 QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
5668 return mComboBox ? mComboBox->value() : QVariant();
5671 QStringList QgsProcessingMapLayerWidgetWrapper::compatibleParameterTypes()
const
5673 return QStringList()
5682 QStringList QgsProcessingMapLayerWidgetWrapper::compatibleOutputTypes()
const
5684 return QStringList()
5692 QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
5694 return tr(
"path to a map layer" );
5697 QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
5704 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
5709 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5718 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
5723 QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleParameterTypes()
const
5725 return QStringList()
5732 QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleOutputTypes()
const
5734 return QStringList()
5742 QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
5744 return tr(
"path to a raster layer" );
5747 QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
5754 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
5759 Q_UNUSED( context );
5760 Q_UNUSED( widgetContext );
5761 Q_UNUSED( definition );
5775 QVBoxLayout *vlayout =
new QVBoxLayout();
5776 vlayout->setContentsMargins( 0, 0, 0, 0 );
5778 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
5788 for (
int i : vectorParam->dataTypes() )
5790 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
5794 vlayout->addWidget( mGeometryTypeComboBox );
5796 setLayout( vlayout );
5799 QgsProcessingParameterDefinition *QgsProcessingVectorLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5801 QList< int > dataTypes;
5802 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
5803 dataTypes << v.toInt();
5805 auto param = std::make_unique< QgsProcessingParameterVectorLayer >( name, description, dataTypes );
5807 return param.release();
5812 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
5817 QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleParameterTypes()
const
5819 return QStringList()
5826 QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleOutputTypes()
const
5828 return QStringList()
5836 QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
5838 return tr(
"path to a vector layer" );
5844 return param->dataTypes();
5846 return QList< int >();
5849 QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
5856 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
5861 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5873 QVBoxLayout *vlayout =
new QVBoxLayout();
5874 vlayout->setContentsMargins( 0, 0, 0, 0 );
5876 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
5886 for (
int i : sourceParam->dataTypes() )
5888 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
5896 vlayout->addWidget( mGeometryTypeComboBox );
5898 setLayout( vlayout );
5901 QgsProcessingParameterDefinition *QgsProcessingFeatureSourceParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5903 QList< int > dataTypes;
5904 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
5905 dataTypes << v.toInt();
5907 auto param = std::make_unique< QgsProcessingParameterFeatureSource >( name, description, dataTypes );
5909 return param.release();
5913 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
5918 QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleParameterTypes()
const
5920 return QStringList()
5928 QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleOutputTypes()
const
5930 return QStringList()
5938 QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
5940 return tr(
"path to a vector layer" );
5946 return param->dataTypes();
5948 return QList< int >();
5951 QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
5958 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
5963 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5971 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
5976 QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleParameterTypes()
const
5978 return QStringList()
5985 QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleOutputTypes()
const
5987 return QStringList()
5995 QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
5997 return tr(
"path to a mesh layer" );
6000 QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6007 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6012 Q_UNUSED( context );
6013 Q_UNUSED( widgetContext );
6014 Q_UNUSED( definition );
6026 QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6030 QHBoxLayout *hl =
new QHBoxLayout();
6031 hl->setContentsMargins( 0, 0, 0, 0 );
6033 mLineEdit =
new QLineEdit();
6034 mLineEdit->setEnabled(
false );
6035 hl->addWidget( mLineEdit, 1 );
6037 mToolButton =
new QToolButton();
6038 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6039 hl->addWidget( mToolButton );
6045 mLineEdit->setText( tr(
"%1 bands selected" ).arg( 0 ) );
6048 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6051 void QgsProcessingRasterBandPanelWidget::setBands(
const QList< int > &bands )
6056 void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6061 void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6063 if ( value.isValid() )
6064 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
6068 updateSummaryText();
6072 void QgsProcessingRasterBandPanelWidget::showDialog()
6074 QVariantList availableOptions;
6075 QStringList fieldNames;
6076 availableOptions.reserve( mBands.size() );
6077 for (
int band : std::as_const( mBands ) )
6079 availableOptions << band;
6085 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6086 widget->setPanelTitle( mParam->description() );
6088 widget->setValueFormatter( [
this](
const QVariant & v ) -> QString
6090 int band = v.toInt();
6091 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6094 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
6096 setValue( widget->selectedOptions() );
6103 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6105 dlg.setValueFormatter( [
this](
const QVariant & v ) -> QString
6107 int band = v.toInt();
6108 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6112 setValue( dlg.selectedOptions() );
6117 void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6120 mLineEdit->setText( tr(
"%1 bands selected" ).arg( mValue.count() ) );
6132 QVBoxLayout *vlayout =
new QVBoxLayout();
6133 vlayout->setContentsMargins( 0, 0, 0, 0 );
6135 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6137 mDefaultLineEdit =
new QLineEdit();
6138 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6143 for (
int b : bands )
6145 defVal << QString::number( b );
6148 mDefaultLineEdit->setText( defVal.join(
';' ) );
6150 vlayout->addWidget( mDefaultLineEdit );
6152 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6153 mParentLayerComboBox =
new QComboBox();
6155 QString initialParent;
6157 initialParent = bandParam->parentLayerParameterName();
6159 if (
auto *lModel = widgetContext.
model() )
6162 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6163 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6167 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
6168 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6170 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6176 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6179 mParentLayerComboBox->addItem( initialParent, initialParent );
6180 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6183 vlayout->addWidget( mParentLayerComboBox );
6185 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6187 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6189 vlayout->addWidget( mAllowMultipleCheckBox );
6190 setLayout( vlayout );
6193 QgsProcessingParameterDefinition *QgsProcessingBandParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6195 auto param = std::make_unique< QgsProcessingParameterBand >( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6197 return param.release();
6206 QWidget *QgsProcessingBandWidgetWrapper::createWidget()
6216 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
6217 mPanel->setToolTip( parameterDefinition()->toolTip() );
6218 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [ = ]
6220 emit widgetValueHasChanged(
this );
6229 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6232 emit widgetValueHasChanged(
this );
6240 mLineEdit =
new QLineEdit();
6241 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6242 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
6244 emit widgetValueHasChanged(
this );
6253 void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6263 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterBand *
>( parameterDefinition() )->parentLayerParameterName() )
6265 setParentLayerWrapperValue( wrapper );
6268 setParentLayerWrapperValue( wrapper );
6285 std::unique_ptr< QgsProcessingContext > tmpContext;
6286 if ( mProcessingContextGenerator )
6287 context = mProcessingContextGenerator->processingContext();
6291 tmpContext = std::make_unique< QgsProcessingContext >();
6292 context = tmpContext.get();
6298 if ( layer && layer->
isValid() )
6302 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
6305 mParentLayer.reset( qobject_cast< QgsRasterLayer * >( ownedLayer.release() ) );
6306 layer = mParentLayer.get();
6314 mComboBox->setLayer( layer );
6318 if ( provider && layer->
isValid() )
6323 QHash< int, QString > bandNames;
6324 for (
int i = 1; i <= nBands; ++i )
6329 mPanel->setBands( bands );
6330 mPanel->setBandNames( bandNames );
6337 mComboBox->setLayer(
nullptr );
6339 mPanel->setBands( QList< int >() );
6341 if ( value.isValid() && widgetContext().messageBar() )
6344 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent bands could not be populated" ),
6345 Qgis::MessageLevel::Info );
6349 if ( parameterDefinition()->defaultValueForGui().isValid() )
6350 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6353 void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6357 if ( !value.isValid() )
6358 mComboBox->setBand( -1 );
6362 mComboBox->setBand( v );
6368 if ( value.isValid() )
6371 opts.reserve( v.size() );
6376 mPanel->setValue( value.isValid() ? opts : QVariant() );
6378 else if ( mLineEdit )
6385 opts.reserve( v.size() );
6387 opts << QString::number( i );
6388 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
6392 if ( value.isValid() )
6400 QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
6403 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
6405 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
6406 else if ( mLineEdit )
6411 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
6412 const QStringList parts = mLineEdit->text().split(
';', QString::SkipEmptyParts );
6414 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
6417 res.reserve( parts.count() );
6418 for (
const QString &s : parts )
6421 int band = s.toInt( &ok );
6425 return res.
isEmpty() ? QVariant() : res;
6429 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
6436 QStringList QgsProcessingBandWidgetWrapper::compatibleParameterTypes()
const
6438 return QStringList()
6443 QStringList QgsProcessingBandWidgetWrapper::compatibleOutputTypes()
const
6445 return QStringList()
6449 QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
6451 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
6454 QString QgsProcessingBandWidgetWrapper::parameterType()
const
6461 return new QgsProcessingBandWidgetWrapper( parameter, type );
6466 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6479 QHBoxLayout *hl =
new QHBoxLayout();
6480 hl->setContentsMargins( 0, 0, 0, 0 );
6482 mLineEdit =
new QLineEdit();
6483 mLineEdit->setEnabled(
false );
6484 hl->addWidget( mLineEdit, 1 );
6486 mToolButton =
new QToolButton();
6487 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6488 hl->addWidget( mToolButton );
6494 mLineEdit->setText( tr(
"%1 inputs selected" ).arg( 0 ) );
6497 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
6500 void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
6502 if ( value.isValid() )
6503 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
6507 updateSummaryText();
6511 void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
6518 if ( mValue.removeAll( layerId ) )
6520 updateSummaryText();
6527 void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
6533 switch ( mParam->layerType() )
6651 void QgsProcessingMultipleLayerPanelWidget::showDialog()
6656 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
6657 widget->setPanelTitle( mParam->description() );
6658 widget->setProject( mProject );
6659 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
6661 setValue( widget->selectedOptions() );
6668 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
6669 dlg.setProject( mProject );
6672 setValue( dlg.selectedOptions() );
6677 void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
6680 mLineEdit->setText( tr(
"%1 inputs selected" ).arg( mValue.count() ) );
6690 QVBoxLayout *vlayout =
new QVBoxLayout();
6691 vlayout->setContentsMargins( 0, 0, 0, 0 );
6693 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
6694 mLayerTypeComboBox =
new QComboBox();
6705 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData( layersParam->layerType() ) );
6707 vlayout->addWidget( mLayerTypeComboBox );
6708 setLayout( vlayout );
6711 QgsProcessingParameterDefinition *QgsProcessingMultipleLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6713 auto param = std::make_unique< QgsProcessingParameterMultipleLayers >( name, description,
static_cast< QgsProcessing::SourceType >( mLayerTypeComboBox->currentData().toInt() ) );
6715 return param.release();
6724 QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
6728 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
6729 mPanel->setToolTip( parameterDefinition()->toolTip() );
6730 mPanel->setProject( widgetContext().project() );
6732 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
6733 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [ = ]
6735 emit widgetValueHasChanged(
this );
6745 mPanel->setProject( context.
project() );
6747 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
6751 void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6756 if ( value.isValid() )
6759 opts.reserve( v.size() );
6761 opts << l->source();
6764 for (
const QVariant &v : value.toList() )
6766 if ( v.canConvert< QgsProcessingModelChildParameterSource >() )
6768 const QgsProcessingModelChildParameterSource source = v.value< QgsProcessingModelChildParameterSource >();
6769 opts << QVariant::fromValue( source );
6774 mPanel->setValue( value.isValid() ? opts : QVariant() );
6778 QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
6781 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
6786 QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleParameterTypes()
const
6788 return QStringList()
6799 QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleOutputTypes()
const
6801 return QStringList()
6810 QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
6812 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
6815 QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
6822 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
6827 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6841 QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
6849 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
6850 if ( mProcessingContextGenerator )
6851 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
6852 if ( mParametersGenerator )
6853 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
6854 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
6856 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [ = ]()
6858 if ( mBlockSignals )
6861 emit widgetValueHasChanged(
this );
6868 mOutputWidget->addOpenAfterRunningOption();
6870 return mOutputWidget;
6880 void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
6882 if ( mOutputWidget )
6883 mOutputWidget->setValue( value );
6886 QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
6888 if ( mOutputWidget )
6889 return mOutputWidget->value();
6894 QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
6897 if ( mOutputWidget )
6898 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
6902 QStringList QgsProcessingOutputWidgetWrapper::compatibleParameterTypes()
const
6904 return QStringList()
6913 QStringList QgsProcessingOutputWidgetWrapper::compatibleOutputTypes()
const
6915 return QStringList()
6926 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
6931 QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
6938 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
6941 QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
6943 return tr(
"path to layer destination" );
6951 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
6956 QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
6963 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
6966 QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
6968 return tr(
"path to layer destination" );
6976 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
6981 QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
6988 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
6991 QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
6993 return tr(
"path to layer destination" );
7001 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
7006 QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
7013 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
7016 QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
7018 return tr(
"path to file destination" );
7026 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
7031 QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
7038 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
7041 QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
7043 return tr(
"path to folder destination" );
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.
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.
Q_GADGET QgsUnitTypes::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.
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 fieldss.
@ Date
Date or datetime fields.
@ Numeric
All numeric fields.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
void remove(int fieldIdx)
Removes the field with the given index.
int count() const
Returns number of items.
bool isEmpty() const
Checks whether the container is empty.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
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.
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.
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.
Base class for all map layer types.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
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.
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.
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 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.
@ DateTime
Datetime values.
static QString typeName()
Returns the type name for the parameter class.
Type dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
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.
@ FlagOptional
Parameter is optional.
virtual QString type() const =0
Unique parameter type name.
Flags flags() const
Returns any flags associated with the parameter.
QString name() const
Returns the name of the parameter.
void setFlags(Flags flags)
Sets the flags associated with the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the parameter class.
QgsUnitTypes::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
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.
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.
void setDataType(DataType type)
Sets 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.
DataType
Field data types.
@ DateTime
Accepts datetime fields.
@ Numeric
Accepts numeric fields.
@ String
Accepts string fields.
DataType dataType() const
Returns 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.
Behavior
Parameter behavior.
@ Folder
Parameter is a folder.
@ File
Parameter is a single file.
Behavior behavior() const
Returns the parameter behavior (e.g.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
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
Double/float values.
double maximum() const
Returns the maximum value acceptable by the parameter.
Type dataType() const
Returns the acceptable data type for the parameter.
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.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
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.
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.
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 QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
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 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 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 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 QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
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.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
SourceType
Data source types enum.
@ TypeVectorLine
Vector line layers.
@ TypeMapLayer
Any map layer type (raster or vector or mesh)
@ TypeVectorPolygon
Vector polygon layers.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ TypeRaster
Raster layers.
@ TypeVectorPoint
Vector point layers.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
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.
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.
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.
DistanceUnit
Units of distance.
@ DistanceDegrees
Degrees, for planar geographic CRS distance measurements.
@ DistanceKilometers
Kilometers.
@ DistanceMiles
Terrestrial miles.
@ DistanceUnknownUnit
Unknown distance unit.
@ DistanceYards
Imperial yards.
@ DistanceFeet
Imperial feet.
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE QgsUnitTypes::DistanceUnitType unitType(QgsUnitTypes::DistanceUnit unit)
Returns the type for a distance unit.
@ Standard
Unit is a standard measurement unit.
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
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