80#include <QPlainTextEdit>
81#include <QRadioButton>
82#include <QButtonGroup>
96 QVBoxLayout *vlayout =
new QVBoxLayout();
97 vlayout->setContentsMargins( 0, 0, 0, 0 );
99 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
103 mDefaultCheckBox->setChecked(
false );
104 vlayout->addWidget( mDefaultCheckBox );
105 setLayout( vlayout );
110 auto param = std::make_unique< QgsProcessingParameterBoolean >( name, description, mDefaultCheckBox->isChecked() );
111 param->setFlags( flags );
112 return param.release();
122QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
128 QString description = parameterDefinition()->description();
130 description = QObject::tr(
"%1 [optional]" ).arg( description );
132 mCheckBox =
new QCheckBox( description );
133 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
135 connect( mCheckBox, &QCheckBox::toggled,
this, [ = ]
137 emit widgetValueHasChanged(
this );
145 mComboBox =
new QComboBox();
146 mComboBox->addItem( tr(
"Yes" ),
true );
147 mComboBox->addItem( tr(
"No" ),
false );
148 mComboBox->setToolTip( parameterDefinition()->toolTip() );
150 connect( mComboBox, qOverload< int>( &QComboBox::currentIndexChanged ),
this, [ = ]
152 emit widgetValueHasChanged(
this );
161QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
170void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
177 mCheckBox->setChecked( v );
185 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
191QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
196 return mCheckBox->isChecked();
200 return mComboBox->currentData();
205QStringList QgsProcessingBooleanWidgetWrapper::compatibleParameterTypes()
const
229QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes()
const
241QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
248 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
253 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
264 QVBoxLayout *vlayout =
new QVBoxLayout();
265 vlayout->setContentsMargins( 0, 0, 0, 0 );
267 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
272 mCrsSelector->setShowAccuracyWarnings(
true );
279 vlayout->addWidget( mCrsSelector );
280 setLayout( vlayout );
285 auto param = std::make_unique< QgsProcessingParameterCrs >( name, description, mCrsSelector->crs().authid() );
286 param->setFlags( flags );
287 return param.release();
296QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
298 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
300 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
309 emit widgetValueHasChanged(
this );
317 return mProjectionSelectionWidget;
322 QWidget *w =
new QWidget();
323 w->setToolTip( parameterDefinition()->toolTip() );
325 QVBoxLayout *vl =
new QVBoxLayout();
326 vl->setContentsMargins( 0, 0, 0, 0 );
329 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
330 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
331 vl->addWidget( mUseProjectCrsCheckBox );
332 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
333 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [ = ]
335 emit widgetValueHasChanged(
this );
338 vl->addWidget( mProjectionSelectionWidget );
346void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
348 if ( mUseProjectCrsCheckBox )
350 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
352 mUseProjectCrsCheckBox->setChecked(
true );
357 mUseProjectCrsCheckBox->setChecked(
false );
362 if ( mProjectionSelectionWidget )
363 mProjectionSelectionWidget->setCrs( v );
366QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
368 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
369 return QStringLiteral(
"ProjectCrs" );
370 else if ( mProjectionSelectionWidget )
371 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
376QStringList QgsProcessingCrsWidgetWrapper::compatibleParameterTypes()
const
390QStringList QgsProcessingCrsWidgetWrapper::compatibleOutputTypes()
const
399QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
401 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
404QString QgsProcessingCrsWidgetWrapper::parameterType()
const
411 return new QgsProcessingCrsWidgetWrapper( parameter, type );
416 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
429 QVBoxLayout *vlayout =
new QVBoxLayout();
430 vlayout->setContentsMargins( 0, 0, 0, 0 );
432 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
434 mDefaultLineEdit =
new QLineEdit();
437 vlayout->addWidget( mDefaultLineEdit );
439 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
441 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
442 vlayout->addWidget( mMultiLineCheckBox );
444 setLayout( vlayout );
449 auto param = std::make_unique< QgsProcessingParameterString >( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
450 param->setFlags( flags );
451 return param.release();
462QWidget *QgsProcessingStringWidgetWrapper::createWidget()
464 const QVariantMap metadata = parameterDefinition()->metadata();
465 const QVariant valueHintsVariant = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"value_hints" ) );
467 if ( valueHintsVariant.isValid() )
469 const QVariantList valueList = valueHintsVariant.toList();
470 mComboBox =
new QComboBox();
471 mComboBox->setToolTip( parameterDefinition()->toolTip() );
475 mComboBox->addItem( QString() );
477 for (
const QVariant &entry : valueList )
479 mComboBox->addItem( entry.toString(), entry.toString() );
481 mComboBox->setCurrentIndex( 0 );
483 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
485 emit widgetValueHasChanged(
this );
498 mPlainTextEdit =
new QPlainTextEdit();
499 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
501 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [ = ]
503 emit widgetValueHasChanged(
this );
505 return mPlainTextEdit;
509 mLineEdit =
new QLineEdit();
510 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
512 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
514 emit widgetValueHasChanged(
this );
522 mLineEdit =
new QLineEdit();
523 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
525 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
527 emit widgetValueHasChanged(
this );
537void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
541 mLineEdit->setText( v );
542 if ( mPlainTextEdit )
543 mPlainTextEdit->setPlainText( v );
547 if ( !value.isValid() )
548 index = mComboBox->findData( QVariant() );
550 index = mComboBox->findData( v );
553 mComboBox->setCurrentIndex( index );
555 mComboBox->setCurrentIndex( 0 );
559QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
562 return mLineEdit->text();
563 else if ( mPlainTextEdit )
564 return mPlainTextEdit->toPlainText();
565 else if ( mComboBox )
566 return mComboBox->currentData();
571QStringList QgsProcessingStringWidgetWrapper::compatibleParameterTypes()
const
589QStringList QgsProcessingStringWidgetWrapper::compatibleOutputTypes()
const
598QString QgsProcessingStringWidgetWrapper::parameterType()
const
605 return new QgsProcessingStringWidgetWrapper( parameter, type );
610 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
625QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
634 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
638 emit widgetValueHasChanged(
this );
640 return mAuthConfigSelect;
646void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
649 if ( mAuthConfigSelect )
650 mAuthConfigSelect->setConfigId( v );
653QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
655 if ( mAuthConfigSelect )
656 return mAuthConfigSelect->configId();
661QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleParameterTypes()
const
669QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleOutputTypes()
const
675QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
682 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
692 QVBoxLayout *vlayout =
new QVBoxLayout();
693 vlayout->setContentsMargins( 0, 0, 0, 0 );
695 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
697 mTypeComboBox =
new QComboBox();
700 vlayout->addWidget( mTypeComboBox );
702 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
703 mMinLineEdit =
new QLineEdit();
704 vlayout->addWidget( mMinLineEdit );
706 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
707 mMaxLineEdit =
new QLineEdit();
708 vlayout->addWidget( mMaxLineEdit );
710 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
711 mDefaultLineEdit =
new QLineEdit();
712 vlayout->addWidget( mDefaultLineEdit );
716 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( numberParam->dataType() ) ) );
718 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
720 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
724 mMaxLineEdit->clear();
727 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
729 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
733 mMinLineEdit->clear();
736 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
739 setLayout( vlayout );
748 auto param = std::make_unique< QgsProcessingParameterNumber >( name, description, dataType, ok ? val : QVariant() );
750 if ( !mMinLineEdit->text().trimmed().isEmpty() )
755 param->setMinimum( val );
759 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
764 param->setMaximum( val );
768 param->setFlags( flags );
769 return param.release();
778QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
781 const QVariantMap metadata = numberDef->
metadata();
782 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
790 QAbstractSpinBox *spinBox =
nullptr;
795 mDoubleSpinBox->setExpressionsEnabled(
true );
796 mDoubleSpinBox->setDecimals( decimals );
802 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
803 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
804 mDoubleSpinBox->setSingleStep( singleStep );
807 spinBox = mDoubleSpinBox;
812 mSpinBox->setExpressionsEnabled(
true );
816 spinBox->setToolTip( parameterDefinition()->toolTip() );
818 double max = 999999999;
823 double min = -999999999;
828 if ( mDoubleSpinBox )
830 mDoubleSpinBox->setMinimum( min );
831 mDoubleSpinBox->setMaximum( max );
835 mSpinBox->setMinimum(
static_cast< int >( min ) );
836 mSpinBox->setMaximum(
static_cast< int >( max ) );
841 mAllowingNull =
true;
842 if ( mDoubleSpinBox )
844 mDoubleSpinBox->setShowClearButton(
true );
845 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
846 mDoubleSpinBox->setMinimum( min );
847 mDoubleSpinBox->setValue( min );
851 mSpinBox->setShowClearButton(
true );
852 const int min = mSpinBox->minimum() - 1;
853 mSpinBox->setMinimum( min );
854 mSpinBox->setValue( min );
856 spinBox->setSpecialValueText( tr(
"Not set" ) );
864 if ( mDoubleSpinBox )
868 mDoubleSpinBox->setClearValue( defaultVal );
874 mSpinBox->setClearValue( intVal );
880 if ( mDoubleSpinBox )
881 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
883 mSpinBox->setClearValue(
static_cast< int >( numberDef->
minimum() ) );
888 if ( mDoubleSpinBox )
890 mDoubleSpinBox->setValue( 0 );
891 mDoubleSpinBox->setClearValue( 0 );
895 mSpinBox->setValue( 0 );
896 mSpinBox->setClearValue( 0 );
901 if ( mDoubleSpinBox )
902 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
904 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
912void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
914 if ( mDoubleSpinBox )
916 if ( mAllowingNull && !value.isValid() )
917 mDoubleSpinBox->clear();
921 mDoubleSpinBox->setValue( v );
926 if ( mAllowingNull && !value.isValid() )
931 mSpinBox->setValue( v );
936QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
938 if ( mDoubleSpinBox )
940 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
943 return mDoubleSpinBox->value();
947 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
950 return mSpinBox->value();
956QStringList QgsProcessingNumericWidgetWrapper::compatibleParameterTypes()
const
967QStringList QgsProcessingNumericWidgetWrapper::compatibleOutputTypes()
const
974double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
976 const double valueRange = maximum - minimum;
977 if ( valueRange <= 1.0 )
979 const double step = valueRange / 10.0;
981 return qgsRound( step, -std::floor( std::log( step ) ) );
989QString QgsProcessingNumericWidgetWrapper::parameterType()
const
996 return new QgsProcessingNumericWidgetWrapper( parameter, type );
1001 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1011 QVBoxLayout *vlayout =
new QVBoxLayout();
1012 vlayout->setContentsMargins( 0, 0, 0, 0 );
1014 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1016 mParentLayerComboBox =
new QComboBox();
1018 QString initialParent;
1020 initialParent = distParam->parentParameterName();
1022 if (
auto *lModel = widgetContext.
model() )
1025 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1026 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1030 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1031 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1033 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1038 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1039 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1041 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1046 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1047 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1049 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1054 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1055 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1057 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1063 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1066 mParentLayerComboBox->addItem( initialParent, initialParent );
1067 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1070 vlayout->addWidget( mParentLayerComboBox );
1072 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1073 mMinLineEdit =
new QLineEdit();
1074 vlayout->addWidget( mMinLineEdit );
1076 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1077 mMaxLineEdit =
new QLineEdit();
1078 vlayout->addWidget( mMaxLineEdit );
1080 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1081 mDefaultLineEdit =
new QLineEdit();
1082 vlayout->addWidget( mDefaultLineEdit );
1086 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
1087 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
1088 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
1091 setLayout( vlayout );
1099 auto param = std::make_unique< QgsProcessingParameterDistance >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1104 param->setMinimum( val );
1110 param->setMaximum( val );
1113 param->setFlags( flags );
1114 return param.release();
1118 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1123QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
1130 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
1133QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1137 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1142 mLabel =
new QLabel();
1143 mUnitsCombo =
new QComboBox();
1155 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1156 QHBoxLayout *layout =
new QHBoxLayout();
1157 layout->addWidget( spin, 1 );
1158 layout->insertSpacing( 1, labelMargin / 2 );
1159 layout->insertWidget( 2, mLabel );
1160 layout->insertWidget( 3, mUnitsCombo );
1165 mWarningLabel =
new QWidget();
1166 QHBoxLayout *warningLayout =
new QHBoxLayout();
1167 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1168 QLabel *warning =
new QLabel();
1170 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1171 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1172 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1173 warningLayout->insertSpacing( 0, labelMargin / 2 );
1174 warningLayout->insertWidget( 1, warning );
1175 mWarningLabel->setLayout( warningLayout );
1176 layout->insertWidget( 4, mWarningLabel );
1178 QWidget *w =
new QWidget();
1179 layout->setContentsMargins( 0, 0, 0, 0 );
1180 w->setLayout( layout );
1195void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1197 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1204 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1206 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1209 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1229 std::unique_ptr< QgsProcessingContext > tmpContext;
1230 if ( mProcessingContextGenerator )
1231 context = mProcessingContextGenerator->processingContext();
1235 tmpContext = std::make_unique< QgsProcessingContext >();
1236 context = tmpContext.get();
1255 mUnitsCombo->hide();
1260 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( units ) ) );
1261 mUnitsCombo->show();
1268QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1270 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1271 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1284 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1295 QVBoxLayout *vlayout =
new QVBoxLayout();
1296 vlayout->setContentsMargins( 0, 0, 0, 0 );
1298 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1300 mParentLayerComboBox =
new QComboBox();
1302 QString initialParent;
1304 initialParent = areaParam->parentParameterName();
1306 if (
auto *lModel = widgetContext.
model() )
1309 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1310 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1314 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1315 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1317 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1322 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1323 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1325 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1330 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1331 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1333 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1338 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1339 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1341 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1347 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1350 mParentLayerComboBox->addItem( initialParent, initialParent );
1351 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1354 vlayout->addWidget( mParentLayerComboBox );
1356 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1357 mMinLineEdit =
new QLineEdit();
1358 vlayout->addWidget( mMinLineEdit );
1360 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1361 mMaxLineEdit =
new QLineEdit();
1362 vlayout->addWidget( mMaxLineEdit );
1364 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1365 mDefaultLineEdit =
new QLineEdit();
1366 vlayout->addWidget( mDefaultLineEdit );
1370 mMinLineEdit->setText( QLocale().toString( areaParam->minimum() ) );
1371 mMaxLineEdit->setText( QLocale().toString( areaParam->maximum() ) );
1372 mDefaultLineEdit->setText( areaParam->defaultValueForGui().toString() );
1375 setLayout( vlayout );
1383 auto param = std::make_unique< QgsProcessingParameterArea >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1388 param->setMinimum( val );
1394 param->setMaximum( val );
1397 param->setFlags( flags );
1398 return param.release();
1407 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1412QString QgsProcessingAreaWidgetWrapper::parameterType()
const
1419 return new QgsProcessingAreaWidgetWrapper( parameter, type );
1422QWidget *QgsProcessingAreaWidgetWrapper::createWidget()
1426 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1431 mLabel =
new QLabel();
1432 mUnitsCombo =
new QComboBox();
1447 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1448 QHBoxLayout *layout =
new QHBoxLayout();
1449 layout->addWidget( spin, 1 );
1450 layout->insertSpacing( 1, labelMargin / 2 );
1451 layout->insertWidget( 2, mLabel );
1452 layout->insertWidget( 3, mUnitsCombo );
1457 mWarningLabel =
new QWidget();
1458 QHBoxLayout *warningLayout =
new QHBoxLayout();
1459 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1460 QLabel *warning =
new QLabel();
1462 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1463 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1464 warning->setToolTip( tr(
"Area is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1465 warningLayout->insertSpacing( 0, labelMargin / 2 );
1466 warningLayout->insertWidget( 1, warning );
1467 mWarningLabel->setLayout( warningLayout );
1468 layout->insertWidget( 4, mWarningLabel );
1470 QWidget *w =
new QWidget();
1471 layout->setContentsMargins( 0, 0, 0, 0 );
1472 w->setLayout( layout );
1487void QgsProcessingAreaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1489 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1521 std::unique_ptr< QgsProcessingContext > tmpContext;
1522 if ( mProcessingContextGenerator )
1523 context = mProcessingContextGenerator->processingContext();
1527 tmpContext = std::make_unique< QgsProcessingContext >();
1528 context = tmpContext.get();
1542void QgsProcessingAreaWidgetWrapper::setUnits(
Qgis::AreaUnit units )
1547 mUnitsCombo->hide();
1552 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1553 mUnitsCombo->show();
1560QVariant QgsProcessingAreaWidgetWrapper::widgetValue()
const
1562 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1563 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1576 return new QgsProcessingAreaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1587 QVBoxLayout *vlayout =
new QVBoxLayout();
1588 vlayout->setContentsMargins( 0, 0, 0, 0 );
1590 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1592 mParentLayerComboBox =
new QComboBox();
1594 QString initialParent;
1596 initialParent = volumeParam->parentParameterName();
1598 if (
auto *lModel = widgetContext.
model() )
1601 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1602 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1606 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1607 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1609 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1614 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1615 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1617 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1622 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1623 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1625 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1630 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1631 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1633 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1639 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1642 mParentLayerComboBox->addItem( initialParent, initialParent );
1643 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1646 vlayout->addWidget( mParentLayerComboBox );
1648 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1649 mMinLineEdit =
new QLineEdit();
1650 vlayout->addWidget( mMinLineEdit );
1652 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1653 mMaxLineEdit =
new QLineEdit();
1654 vlayout->addWidget( mMaxLineEdit );
1656 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1657 mDefaultLineEdit =
new QLineEdit();
1658 vlayout->addWidget( mDefaultLineEdit );
1662 mMinLineEdit->setText( QLocale().toString( volumeParam->minimum() ) );
1663 mMaxLineEdit->setText( QLocale().toString( volumeParam->maximum() ) );
1664 mDefaultLineEdit->setText( volumeParam->defaultValueForGui().toString() );
1667 setLayout( vlayout );
1675 auto param = std::make_unique< QgsProcessingParameterVolume >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1680 param->setMinimum( val );
1686 param->setMaximum( val );
1689 param->setFlags( flags );
1690 return param.release();
1699 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1704QString QgsProcessingVolumeWidgetWrapper::parameterType()
const
1711 return new QgsProcessingVolumeWidgetWrapper( parameter, type );
1714QWidget *QgsProcessingVolumeWidgetWrapper::createWidget()
1718 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1723 mLabel =
new QLabel();
1724 mUnitsCombo =
new QComboBox();
1737 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1738 QHBoxLayout *layout =
new QHBoxLayout();
1739 layout->addWidget( spin, 1 );
1740 layout->insertSpacing( 1, labelMargin / 2 );
1741 layout->insertWidget( 2, mLabel );
1742 layout->insertWidget( 3, mUnitsCombo );
1747 mWarningLabel =
new QWidget();
1748 QHBoxLayout *warningLayout =
new QHBoxLayout();
1749 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1750 QLabel *warning =
new QLabel();
1752 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1753 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1754 warning->setToolTip( tr(
"Volume is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1755 warningLayout->insertSpacing( 0, labelMargin / 2 );
1756 warningLayout->insertWidget( 1, warning );
1757 mWarningLabel->setLayout( warningLayout );
1758 layout->insertWidget( 4, mWarningLabel );
1760 QWidget *w =
new QWidget();
1761 layout->setContentsMargins( 0, 0, 0, 0 );
1762 w->setLayout( layout );
1777void QgsProcessingVolumeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1779 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1811 std::unique_ptr< QgsProcessingContext > tmpContext;
1812 if ( mProcessingContextGenerator )
1813 context = mProcessingContextGenerator->processingContext();
1817 tmpContext = std::make_unique< QgsProcessingContext >();
1818 context = tmpContext.get();
1837 mUnitsCombo->hide();
1842 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1843 mUnitsCombo->show();
1850QVariant QgsProcessingVolumeWidgetWrapper::widgetValue()
const
1852 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1853 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1866 return new QgsProcessingVolumeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1877 QVBoxLayout *vlayout =
new QVBoxLayout();
1878 vlayout->setContentsMargins( 0, 0, 0, 0 );
1880 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1881 mMinLineEdit =
new QLineEdit();
1882 vlayout->addWidget( mMinLineEdit );
1884 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1885 mMaxLineEdit =
new QLineEdit();
1886 vlayout->addWidget( mMaxLineEdit );
1888 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1889 mDefaultLineEdit =
new QLineEdit();
1890 vlayout->addWidget( mDefaultLineEdit );
1892 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1894 mUnitsCombo =
new QComboBox();
1904 vlayout->addWidget( mUnitsCombo );
1908 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1909 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1910 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1911 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast <int >( durationParam->defaultUnit() ) ) );
1914 setLayout( vlayout );
1922 auto param = std::make_unique< QgsProcessingParameterDuration >( name, description, ok ? val : QVariant() );
1927 param->setMinimum( val );
1933 param->setMaximum( val );
1936 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit >( mUnitsCombo->currentData().toInt() ) );
1938 param->setFlags( flags );
1939 return param.release();
1943 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1948QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1955 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1958QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1962 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1967 mUnitsCombo =
new QComboBox();
1979 QHBoxLayout *layout =
new QHBoxLayout();
1980 layout->addWidget( spin, 1 );
1981 layout->insertWidget( 1, mUnitsCombo );
1983 QWidget *w =
new QWidget();
1984 layout->setContentsMargins( 0, 0, 0, 0 );
1985 w->setLayout( layout );
1987 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( durationDef->
defaultUnit() ) ) );
1988 mUnitsCombo->show();
2001QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
2013QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
2015 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
2016 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo )
2027void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2033 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
2037 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
2043 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2053 QVBoxLayout *vlayout =
new QVBoxLayout();
2054 vlayout->setContentsMargins( 0, 0, 0, 0 );
2056 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2058 mDefaultLineEdit =
new QLineEdit();
2062 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
2065 vlayout->addWidget( mDefaultLineEdit );
2067 setLayout( vlayout );
2073 double val = mDefaultLineEdit->text().toDouble( &ok );
2074 auto param = std::make_unique< QgsProcessingParameterScale >( name, description, ok ? val : QVariant() );
2076 return param.release();
2080 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
2085QString QgsProcessingScaleWidgetWrapper::parameterType()
const
2092 return new QgsProcessingScaleWidgetWrapper( parameter, type );
2095QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
2107 mScaleWidget->setAllowNull(
true );
2109 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
2110 mScaleWidget->setShowCurrentScaleButton(
true );
2112 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
2115 emit widgetValueHasChanged(
this );
2117 return mScaleWidget;
2126 mScaleWidget->setMapCanvas( context.
mapCanvas() );
2131QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
2133 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
2136void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2140 if ( mScaleWidget->allowNull() && !value.isValid() )
2141 mScaleWidget->setNull();
2145 mScaleWidget->setScale( v );
2152 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2163 QVBoxLayout *vlayout =
new QVBoxLayout();
2164 vlayout->setContentsMargins( 0, 0, 0, 0 );
2166 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
2168 mTypeComboBox =
new QComboBox();
2171 vlayout->addWidget( mTypeComboBox );
2173 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
2174 mMinLineEdit =
new QLineEdit();
2175 vlayout->addWidget( mMinLineEdit );
2177 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
2178 mMaxLineEdit =
new QLineEdit();
2179 vlayout->addWidget( mMaxLineEdit );
2183 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( rangeParam->dataType() ) ) );
2185 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
2186 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
2189 setLayout( vlayout );
2194 QString defaultValue;
2195 if ( mMinLineEdit->text().isEmpty() )
2197 defaultValue = QStringLiteral(
"None" );
2205 defaultValue = QStringLiteral(
"None" );
2209 if ( mMaxLineEdit->text().isEmpty() )
2211 defaultValue += QLatin1String(
",None" );
2217 defaultValue += QStringLiteral(
",%1" ).arg( ok ? QString::number( val ) : QLatin1String(
"None" ) );
2221 auto param = std::make_unique< QgsProcessingParameterRange >( name, description, dataType, defaultValue );
2222 param->setFlags( flags );
2223 return param.release();
2233QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
2242 QHBoxLayout *layout =
new QHBoxLayout();
2247 mMinSpinBox->setExpressionsEnabled(
true );
2248 mMinSpinBox->setShowClearButton(
false );
2249 mMaxSpinBox->setExpressionsEnabled(
true );
2250 mMaxSpinBox->setShowClearButton(
false );
2252 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
2253 layout->addWidget( minLabel );
2254 layout->addWidget( mMinSpinBox, 1 );
2256 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
2257 layout->addWidget( maxLabel );
2258 layout->addWidget( mMaxSpinBox, 1 );
2260 QWidget *w =
new QWidget();
2261 layout->setContentsMargins( 0, 0, 0, 0 );
2262 w->setLayout( layout );
2266 mMinSpinBox->setDecimals( 6 );
2267 mMaxSpinBox->setDecimals( 6 );
2271 mMinSpinBox->setDecimals( 0 );
2272 mMaxSpinBox->setDecimals( 0 );
2275 mMinSpinBox->setMinimum( -99999999.999999 );
2276 mMaxSpinBox->setMinimum( -99999999.999999 );
2277 mMinSpinBox->setMaximum( 99999999.999999 );
2278 mMaxSpinBox->setMaximum( 99999999.999999 );
2282 mAllowingNull =
true;
2284 const double min = mMinSpinBox->minimum() - 1;
2285 mMinSpinBox->setMinimum( min );
2286 mMaxSpinBox->setMinimum( min );
2287 mMinSpinBox->setValue( min );
2288 mMaxSpinBox->setValue( min );
2290 mMinSpinBox->setShowClearButton(
true );
2291 mMaxSpinBox->setShowClearButton(
true );
2292 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
2293 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
2296 w->setToolTip( parameterDefinition()->toolTip() );
2298 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
2300 mBlockChangedSignal++;
2301 if ( !mAllowingNull && v > mMaxSpinBox->value() )
2302 mMaxSpinBox->setValue( v );
2303 mBlockChangedSignal--;
2305 if ( !mBlockChangedSignal )
2306 emit widgetValueHasChanged(
this );
2308 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
2310 mBlockChangedSignal++;
2311 if ( !mAllowingNull && v < mMinSpinBox->value() )
2312 mMinSpinBox->setValue( v );
2313 mBlockChangedSignal--;
2315 if ( !mBlockChangedSignal )
2316 emit widgetValueHasChanged(
this );
2325void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2328 if ( mAllowingNull && v.empty() )
2330 mMinSpinBox->clear();
2331 mMaxSpinBox->clear();
2338 if ( mAllowingNull )
2340 mBlockChangedSignal++;
2341 if ( std::isnan( v.at( 0 ) ) )
2342 mMinSpinBox->clear();
2344 mMinSpinBox->setValue( v.at( 0 ) );
2346 if ( v.count() >= 2 )
2348 if ( std::isnan( v.at( 1 ) ) )
2349 mMaxSpinBox->clear();
2351 mMaxSpinBox->setValue( v.at( 1 ) );
2353 mBlockChangedSignal--;
2357 mBlockChangedSignal++;
2358 mMinSpinBox->setValue( v.at( 0 ) );
2359 if ( v.count() >= 2 )
2360 mMaxSpinBox->setValue( v.at( 1 ) );
2361 mBlockChangedSignal--;
2365 if ( !mBlockChangedSignal )
2366 emit widgetValueHasChanged(
this );
2369QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
2371 if ( mAllowingNull )
2374 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
2375 value = QStringLiteral(
"None" );
2377 value = QString::number( mMinSpinBox->value() );
2379 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
2380 value += QLatin1String(
",None" );
2382 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
2387 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
2390QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
const
2392 return QStringList()
2397QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
const
2403QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
2405 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
2408QString QgsProcessingRangeWidgetWrapper::parameterType()
const
2415 return new QgsProcessingRangeWidgetWrapper( parameter, type );
2420 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2431 QVBoxLayout *vlayout =
new QVBoxLayout();
2432 vlayout->setContentsMargins( 0, 0, 0, 0 );
2434 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
2437 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
2438 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
2440 vlayout->addWidget( mMatrixWidget );
2441 setLayout( vlayout );
2446 auto param = std::make_unique< QgsProcessingParameterMatrix >( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
2447 param->setFlags( flags );
2448 return param.release();
2458QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
2460 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast< const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
2461 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
2463 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [ = ]
2465 emit widgetValueHasChanged(
this );
2474 return mMatrixWidget;
2480void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2483 if ( mMatrixWidget )
2484 mMatrixWidget->setValue( v );
2487QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
2489 if ( mMatrixWidget )
2490 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
2495QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
const
2497 return QStringList()
2501QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
const
2503 return QStringList();
2506QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
2508 return tr(
"comma delimited string of values, or an array of values" );
2511QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
2518 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
2523 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2535 QVBoxLayout *vlayout =
new QVBoxLayout();
2536 vlayout->setContentsMargins( 0, 0, 0, 0 );
2538 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
2540 mTypeComboBox =
new QComboBox();
2544 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( fileParam->behavior() ) ) );
2546 mTypeComboBox->setCurrentIndex( 0 );
2547 vlayout->addWidget( mTypeComboBox );
2549 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
2551 mFilterComboBox =
new QComboBox();
2552 mFilterComboBox->setEditable(
true );
2554 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
2555 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
2556 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
2557 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
2559 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
2561 mFilterComboBox->setCurrentIndex( 0 );
2562 vlayout->addWidget( mFilterComboBox );
2564 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2567 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
2571 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
2575 vlayout->addWidget( mDefaultFileWidget );
2577 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ]
2586 setLayout( vlayout );
2591 auto param = std::make_unique< QgsProcessingParameterFile >( name, description );
2594 param->setFileFilter( mFilterComboBox->currentText() );
2595 if ( !mDefaultFileWidget->filePath().isEmpty() )
2596 param->setDefaultValue( mDefaultFileWidget->filePath() );
2597 param->setFlags( flags );
2598 return param.release();
2608QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2618 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2619 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2621 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
2628 mFileWidget->setFilter( fileParam->
fileFilter() );
2629 else if ( !fileParam->
extension().isEmpty() )
2630 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
2640 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
2641 emit widgetValueHasChanged(
this );
2649void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2653 mFileWidget->setFilePath( v );
2656QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2659 return mFileWidget->filePath();
2664QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
const
2666 return QStringList()
2671QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
const
2682QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2684 return tr(
"string representing a path to a file or folder" );
2687QString QgsProcessingFileWidgetWrapper::parameterType()
const
2694 return new QgsProcessingFileWidgetWrapper( parameter, type );
2699 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2711 QVBoxLayout *vlayout =
new QVBoxLayout();
2712 vlayout->setContentsMargins( 0, 0, 0, 0 );
2713 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2716 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2718 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2719 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2721 QStackedWidget *stackedWidget =
new QStackedWidget();
2722 stackedWidget->addWidget( mDefaultQgisLineEdit );
2723 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2724 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2725 vlayout->addWidget( stackedWidget );
2730 mDefaultQgisLineEdit->setExpression( expr );
2731 mDefaultPointCloudLineEdit->setExpression( expr );
2734 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2736 mParentLayerComboBox =
new QComboBox();
2737 vlayout->addWidget( mParentLayerComboBox );
2739 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2740 mExpressionTypeComboBox =
new QComboBox();
2745 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2747 mParentLayerComboBox->clear();
2748 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2750 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2752 QString initialParent;
2754 initialParent = expParam->parentLayerParameterName();
2758 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2761 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2762 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2769 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2770 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2772 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2777 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2778 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2780 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2787 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2788 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2790 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2801 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2802 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2804 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2812 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2815 mParentLayerComboBox->addItem( initialParent, initialParent );
2816 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2821 mExpressionTypeComboBox->setCurrentIndex( -1 );
2823 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast< int >( expParam->expressionType() ) ) );
2825 mExpressionTypeComboBox->setCurrentIndex( 0 );
2827 vlayout->addWidget( mExpressionTypeComboBox );
2829 setLayout( vlayout );
2836 switch ( expressionType )
2839 expression = mDefaultQgisLineEdit->expression();
2842 expression = mDefaultPointCloudLineEdit->expression();
2845 expression = mDefaultRasterCalculatorLineEdit->expression();
2848 auto param = std::make_unique< QgsProcessingParameterExpression >( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2849 param->setFlags( flags );
2850 return param.release();
2859QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2871 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2872 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2873 mExpLineEdit->registerExpressionContextGenerator(
this );
2876 emit widgetValueHasChanged(
this );
2878 return mExpLineEdit;
2884 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2885 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2886 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2888 emit widgetValueHasChanged(
this );
2890 return mPointCloudExpLineEdit;
2895 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2896 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2899 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2901 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2903 emit widgetValueHasChanged(
this );
2905 return mRasterCalculatorExpLineEdit;
2909 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
2912 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2913 mExpBuilderWidget->init( createExpressionContext() );
2916 Q_UNUSED( changed );
2917 emit widgetValueHasChanged(
this );
2919 return mExpBuilderWidget;
2924 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2925 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2926 mFieldExpWidget->registerExpressionContextGenerator(
this );
2928 mFieldExpWidget->setAllowEmptyFieldName(
true );
2932 emit widgetValueHasChanged(
this );
2934 return mFieldExpWidget;
2942void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2954 setParentLayerWrapperValue( wrapper );
2957 setParentLayerWrapperValue( wrapper );
2973 if ( mExpBuilderWidget )
2976 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2984 std::unique_ptr< QgsProcessingContext > tmpContext;
2985 if ( mProcessingContextGenerator )
2986 context = mProcessingContextGenerator->processingContext();
2990 tmpContext = std::make_unique< QgsProcessingContext >();
2991 context = tmpContext.get();
3001 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3011 if ( mFieldExpWidget )
3012 mFieldExpWidget->setLayer(
nullptr );
3013 else if ( mExpBuilderWidget )
3014 mExpBuilderWidget->setLayer(
nullptr );
3015 else if ( mExpLineEdit )
3016 mExpLineEdit->setLayer(
nullptr );
3022 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
3025 mParentLayer.reset( ownedLayer.release() );
3033 if ( mFieldExpWidget )
3034 mFieldExpWidget->setLayer( layer );
3035 if ( mExpBuilderWidget )
3036 mExpBuilderWidget->setLayer( layer );
3037 else if ( mExpLineEdit )
3038 mExpLineEdit->setLayer( layer );
3047 if ( mPointCloudExpLineEdit )
3048 mPointCloudExpLineEdit->setLayer(
nullptr );
3054 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
3057 mParentLayer.reset( ownedLayer.release() );
3065 if ( mPointCloudExpLineEdit )
3066 mPointCloudExpLineEdit->setLayer( layer );
3073 if ( layers.isEmpty() )
3075 if ( mRasterCalculatorExpLineEdit )
3077 mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
3082 if ( mRasterCalculatorExpLineEdit )
3084 QVariantList layersList;
3087 layersList << layer->
name();
3089 mRasterCalculatorExpLineEdit->setLayers( layersList );
3097void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3100 if ( mFieldExpWidget )
3101 mFieldExpWidget->setExpression( v );
3102 else if ( mExpBuilderWidget )
3103 mExpBuilderWidget->setExpressionText( v );
3104 else if ( mExpLineEdit )
3105 mExpLineEdit->setExpression( v );
3106 else if ( mPointCloudExpLineEdit )
3107 mPointCloudExpLineEdit->setExpression( v );
3108 else if ( mRasterCalculatorExpLineEdit )
3109 mRasterCalculatorExpLineEdit->setExpression( v );
3112QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
3114 if ( mFieldExpWidget )
3115 return mFieldExpWidget->expression();
3116 if ( mExpBuilderWidget )
3117 return mExpBuilderWidget->expressionText();
3118 else if ( mExpLineEdit )
3119 return mExpLineEdit->expression();
3120 else if ( mPointCloudExpLineEdit )
3121 return mPointCloudExpLineEdit->expression();
3122 else if ( mRasterCalculatorExpLineEdit )
3123 return mRasterCalculatorExpLineEdit->expression();
3128QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
const
3130 return QStringList()
3141QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
const
3143 return QStringList()
3149QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
3151 return tr(
"string representation of an expression" );
3154const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
3156 if ( mFieldExpWidget && mFieldExpWidget->layer() )
3157 return mFieldExpWidget->layer();
3159 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
3160 return mExpBuilderWidget->layer();
3165QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
3172 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
3177 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3190 QHBoxLayout *hl =
new QHBoxLayout();
3191 hl->setContentsMargins( 0, 0, 0, 0 );
3193 mLineEdit =
new QLineEdit();
3194 mLineEdit->setEnabled(
false );
3195 hl->addWidget( mLineEdit, 1 );
3197 mToolButton =
new QToolButton();
3198 mToolButton->setText( QString( QChar( 0x2026 ) ) );
3199 hl->addWidget( mToolButton );
3205 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3208 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
3211void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
3213 if ( value.isValid() )
3215 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3217 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
3223 updateSummaryText();
3227void QgsProcessingEnumPanelWidget::showDialog()
3229 QVariantList availableOptions;
3232 availableOptions.reserve( mParam->options().size() );
3234 if ( mParam->usesStaticStrings() )
3236 for ( QString o : mParam->options() )
3238 availableOptions << o;
3243 for (
int i = 0; i < mParam->options().count(); ++i )
3244 availableOptions << i;
3248 const QStringList options = mParam ? mParam->options() : QStringList();
3252 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3253 widget->setPanelTitle( mParam->description() );
3255 if ( mParam->usesStaticStrings() )
3257 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
3259 const QString i = v.toString();
3260 return options.contains( i ) ? i : QString();
3265 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
3267 const int i = v.toInt();
3268 return options.size() > i ? options.at( i ) : QString();
3272 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
3274 setValue( widget->selectedOptions() );
3281 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3283 dlg.setValueFormatter( [options](
const QVariant & v ) -> QString
3285 const int i = v.toInt();
3286 return options.size() > i ? options.at( i ) : QString();
3290 setValue( dlg.selectedOptions() );
3295void QgsProcessingEnumPanelWidget::updateSummaryText()
3300 if ( mValue.empty() )
3302 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3307 values.reserve( mValue.size() );
3308 if ( mParam->usesStaticStrings() )
3310 for (
const QVariant &val : std::as_const( mValue ) )
3312 values << val.toString();
3317 const QStringList options = mParam->options();
3318 for (
const QVariant &val : std::as_const( mValue ) )
3320 const int i = val.toInt();
3321 values << ( options.size() > i ? options.at( i ) : QString() );
3325 const QString concatenated = values.join( tr(
"," ) );
3326 if ( concatenated.length() < 100 )
3327 mLineEdit->setText( concatenated );
3329 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
3337QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
3340 , mButtonGroup( new QButtonGroup( this ) )
3341 , mColumns( columns )
3343 mButtonGroup->setExclusive( !mParam->allowMultiple() );
3345 QGridLayout *l =
new QGridLayout();
3346 l->setContentsMargins( 0, 0, 0, 0 );
3348 int rows =
static_cast< int >( std::ceil( mParam->options().count() /
static_cast< double >( mColumns ) ) );
3349 for (
int i = 0; i < mParam->options().count(); ++i )
3351 QAbstractButton *button =
nullptr;
3352 if ( mParam->allowMultiple() )
3353 button =
new QCheckBox( mParam->options().at( i ) );
3355 button =
new QRadioButton( mParam->options().at( i ) );
3357 connect( button, &QAbstractButton::toggled,
this, [ = ]
3359 if ( !mBlockChangedSignal )
3363 mButtons.insert( i, button );
3365 mButtonGroup->addButton( button, i );
3366 l->addWidget( button, i % rows, i / rows );
3368 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
3371 if ( mParam->allowMultiple() )
3373 setContextMenuPolicy( Qt::CustomContextMenu );
3374 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
3378QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
3380 if ( mParam->allowMultiple() )
3383 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3385 if ( it.value()->isChecked() )
3386 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
3392 if ( mParam->usesStaticStrings() )
3393 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
3395 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
3399void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
3401 mBlockChangedSignal =
true;
3402 if ( mParam->allowMultiple() )
3404 QVariantList selected;
3405 if ( value.isValid() )
3406 selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3407 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3409 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
3410 it.value()->setChecked( selected.contains( v ) );
3416 if ( v.userType() == QMetaType::Type::QVariantList )
3417 v = v.toList().value( 0 );
3419 v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
3420 if ( mButtons.contains( v ) )
3421 mButtons.value( v )->setChecked(
true );
3423 mBlockChangedSignal =
false;
3427void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
3430 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
3431 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
3432 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
3433 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
3434 popupMenu.addAction( selectAllAction );
3435 popupMenu.addAction( clearAllAction );
3436 popupMenu.exec( QCursor::pos() );
3439void QgsProcessingEnumCheckboxPanelWidget::selectAll()
3441 mBlockChangedSignal =
true;
3442 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3443 it.value()->setChecked(
true );
3444 mBlockChangedSignal =
false;
3448void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
3450 mBlockChangedSignal =
true;
3451 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3452 it.value()->setChecked(
false );
3453 mBlockChangedSignal =
false;
3465 QVBoxLayout *vlayout =
new QVBoxLayout();
3466 vlayout->setContentsMargins( 0, 0, 0, 0 );
3468 mEnumWidget =
new QgsProcessingEnumModelerWidget();
3471 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
3472 mEnumWidget->setOptions( enumParam->options() );
3473 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
3475 vlayout->addWidget( mEnumWidget );
3476 setLayout( vlayout );
3481 auto param = std::make_unique< QgsProcessingParameterEnum >( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
3483 return param.release();
3493QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
3501 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
3503 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
3504 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
3505 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
3506 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [ = ]
3508 emit widgetValueHasChanged(
this );
3510 return mCheckboxPanel;
3519 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
3520 mPanel->setToolTip( parameterDefinition()->toolTip() );
3521 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [ = ]
3523 emit widgetValueHasChanged(
this );
3529 mComboBox =
new QComboBox();
3532 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
3533 const QStringList options = expParam->
options();
3534 const QVariantList iconList = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"icons" ) ).toList();
3535 for (
int i = 0; i < options.count(); ++i )
3537 const QIcon icon = iconList.value( i ).value< QIcon >();
3540 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
3542 mComboBox->addItem( icon, options.at( i ), i );
3545 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3546 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
3547 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
3549 emit widgetValueHasChanged(
this );
3558void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3562 if ( !value.isValid() )
3563 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
3570 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3575 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3579 else if ( mPanel || mCheckboxPanel )
3582 if ( value.isValid() )
3588 opts.reserve( v.size() );
3589 for ( QString i : v )
3595 opts.reserve( v.size() );
3601 mPanel->setValue( opts );
3602 else if ( mCheckboxPanel )
3603 mCheckboxPanel->setValue( opts );
3607QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3610 return mComboBox->currentData();
3612 return mPanel->value();
3613 else if ( mCheckboxPanel )
3614 return mCheckboxPanel->value();
3619QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
const
3621 return QStringList()
3627QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
const
3629 return QStringList()
3635QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3637 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3640QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3647 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3652 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3665QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3674 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() : nullptr );
3679 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3682 emit widgetValueHasChanged(
this );
3689 mPlainComboBox =
new QComboBox();
3690 mPlainComboBox->setEditable(
true );
3691 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3692 if ( widgetContext().project() )
3696 mPlainComboBox->addItem( layout->name() );
3699 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
3701 emit widgetValueHasChanged(
this );
3703 return mPlainComboBox;
3709void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3713 if ( !value.isValid() )
3714 mComboBox->setCurrentLayout(
nullptr );
3718 mComboBox->setCurrentLayout( l );
3720 mComboBox->setCurrentLayout(
nullptr );
3723 else if ( mPlainComboBox )
3726 mPlainComboBox->setCurrentText( v );
3730QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3735 return l ? l->
name() : QVariant();
3737 else if ( mPlainComboBox )
3738 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3746 if ( mPlainComboBox && context.
project() )
3750 mPlainComboBox->addItem( layout->name() );
3754QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
const
3756 return QStringList()
3761QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
const
3763 return QStringList()
3768QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3770 return tr(
"string representing the name of an existing print layout" );
3773QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3780 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3794 QVBoxLayout *vlayout =
new QVBoxLayout();
3795 vlayout->setContentsMargins( 0, 0, 0, 0 );
3797 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3799 mParentLayoutComboBox =
new QComboBox();
3800 QString initialParent;
3802 initialParent = itemParam->parentLayoutParameterName();
3804 if (
auto *lModel = widgetContext.
model() )
3807 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3808 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3812 mParentLayoutComboBox-> addItem( definition->
description(), definition->
name() );
3813 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3815 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3821 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3824 mParentLayoutComboBox->addItem( initialParent, initialParent );
3825 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3828 vlayout->addWidget( mParentLayoutComboBox );
3829 setLayout( vlayout );
3833 auto param = std::make_unique< QgsProcessingParameterLayoutItem >( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3835 return param.release();
3845QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3856 mComboBox->setAllowEmptyItem(
true );
3857 if ( layoutParam->
itemType() >= 0 )
3860 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3863 emit widgetValueHasChanged(
this );
3870 mLineEdit =
new QLineEdit();
3871 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3872 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3874 emit widgetValueHasChanged(
this );
3882void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3910void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3916 std::unique_ptr< QgsProcessingContext > tmpContext;
3917 if ( mProcessingContextGenerator )
3918 context = mProcessingContextGenerator->processingContext();
3922 tmpContext = std::make_unique< QgsProcessingContext >();
3923 context = tmpContext.get();
3927 setLayout( layout );
3930void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3933 mComboBox->setCurrentLayout( layout );
3936void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3940 if ( !value.isValid() )
3941 mComboBox->setItem(
nullptr );
3945 mComboBox->setItem( item );
3948 else if ( mLineEdit )
3951 mLineEdit->setText( v );
3955QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3960 return i ? i->
uuid() : QVariant();
3962 else if ( mLineEdit )
3963 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3968QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
const
3970 return QStringList()
3975QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
const
3977 return QStringList()
3982QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3984 return tr(
"string representing the UUID or ID of an existing print layout item" );
3987QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3994 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3999 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4006QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
4013QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
4015void QgsProcessingPointMapTool::deactivate()
4029 if ( e->button() == Qt::LeftButton )
4032 emit clicked( point );
4037void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
4039 if ( e->key() == Qt::Key_Escape )
4054QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
4057 QHBoxLayout *l =
new QHBoxLayout();
4058 l->setContentsMargins( 0, 0, 0, 0 );
4060 mLineEdit->setShowClearButton(
false );
4061 l->addWidget( mLineEdit, 1 );
4062 mButton =
new QToolButton();
4063 mButton->setText( QString( QChar( 0x2026 ) ) );
4064 l->addWidget( mButton );
4067 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
4068 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::textChanged );
4069 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
4070 mButton->setVisible(
false );
4073void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
4076 if ( mAllowSelectOnCanvas )
4078 mButton->setVisible(
true );
4081 mTool = std::make_unique< QgsProcessingPointMapTool >( mCanvas );
4082 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
4083 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
4087void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
4089 mLineEdit->setShowClearButton( allowNull );
4092void QgsProcessingPointPanel::setShowPointOnCanvas(
bool show )
4094 if ( mShowPointOnCanvas == show )
4097 mShowPointOnCanvas = show;
4098 if ( mShowPointOnCanvas )
4104 mMapPointRubberBand.reset();
4108void QgsProcessingPointPanel::setAllowSelectOnCanvas(
bool allow )
4110 mAllowSelectOnCanvas = allow;
4111 mButton->setVisible( mAllowSelectOnCanvas &&
static_cast< bool >( mTool ) );
4114QVariant QgsProcessingPointPanel::value()
const
4116 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
4119void QgsProcessingPointPanel::clear()
4127 QString newText = QStringLiteral(
"%1,%2" )
4128 .arg( QString::number( point.
x(),
'f' ),
4129 QString::number( point.
y(),
'f' ) );
4132 if ( mCrs.isValid() )
4134 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
4136 mLineEdit->setText( newText );
4140void QgsProcessingPointPanel::showEvent( QShowEvent * )
4145 if ( QWidget *parentWindow = window() )
4147 setAllowSelectOnCanvas( !parentWindow->isModal() );
4153void QgsProcessingPointPanel::selectOnCanvas()
4158 mPrevTool = mCanvas->mapTool();
4159 mCanvas->setMapTool( mTool.get() );
4161 emit toggleDialogVisibility(
false );
4164void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
4166 setValue( point, mCanvas->mapSettings().destinationCrs() );
4169void QgsProcessingPointPanel::pointPicked()
4174 mCanvas->setMapTool( mPrevTool );
4176 emit toggleDialogVisibility(
true );
4179void QgsProcessingPointPanel::textChanged(
const QString &text )
4181 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
4183 const QRegularExpressionMatch match = rx.match( text );
4184 if ( match.hasMatch() )
4187 const double x = match.captured( 1 ).toDouble( &xOk );
4189 const double y = match.captured( 2 ).toDouble( &yOk );
4196 if ( pointCrs.isValid() )
4214void QgsProcessingPointPanel::updateRubberBand()
4216 if ( !mShowPointOnCanvas || !mCanvas )
4219 if ( mPoint.isEmpty() )
4221 mMapPointRubberBand.reset();
4225 if ( !mMapPointRubberBand )
4228 mMapPointRubberBand->setZValue( 1000 );
4231 const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
4232 mMapPointRubberBand->setWidth( scaleFactor );
4233 mMapPointRubberBand->setIconSize( scaleFactor * 5 );
4235 mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
4236 mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
4250 QVBoxLayout *vlayout =
new QVBoxLayout();
4251 vlayout->setContentsMargins( 0, 0, 0, 0 );
4253 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4255 mDefaultLineEdit =
new QLineEdit();
4256 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4257 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
4261 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
4264 vlayout->addWidget( mDefaultLineEdit );
4265 setLayout( vlayout );
4270 auto param = std::make_unique< QgsProcessingParameterPoint >( name, description, mDefaultLineEdit->text() );
4272 return param.release();
4281QWidget *QgsProcessingPointWidgetWrapper::createWidget()
4289 mPanel =
new QgsProcessingPointPanel(
nullptr );
4290 if ( widgetContext().mapCanvas() )
4291 mPanel->setMapCanvas( widgetContext().mapCanvas() );
4294 mPanel->setAllowNull(
true );
4297 mPanel->setShowPointOnCanvas(
true );
4299 mPanel->setToolTip( parameterDefinition()->toolTip() );
4301 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [ = ]
4303 emit widgetValueHasChanged(
this );
4307 setDialog( mDialog );
4313 mLineEdit =
new QLineEdit();
4314 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4315 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
4317 emit widgetValueHasChanged(
this );
4329 mPanel->setMapCanvas( context.
mapCanvas() );
4332void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
4337 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ](
bool visible )
4340 mDialog->showMinimized();
4343 mDialog->showNormal();
4345 mDialog->activateWindow();
4352void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4356 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
4362 mPanel->setValue( p,
crs );
4365 else if ( mLineEdit )
4368 mLineEdit->setText( v );
4372QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
4376 return mPanel->value();
4378 else if ( mLineEdit )
4379 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
4384QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
const
4386 return QStringList()
4391QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
const
4393 return QStringList()
4398QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
4400 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
4403QString QgsProcessingPointWidgetWrapper::parameterType()
const
4410 return new QgsProcessingPointWidgetWrapper( parameter, type );
4415 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4427 QVBoxLayout *vlayout =
new QVBoxLayout();
4428 vlayout->setContentsMargins( 0, 0, 0, 0 );
4430 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4442 vlayout->addWidget( mGeometryWidget );
4443 setLayout( vlayout );
4449 auto param = std::make_unique< QgsProcessingParameterGeometry >( name, description, geometry.
isEmpty() ? QVariant() : geometry.asWkt() );
4451 return param.release();
4460QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
4469 mGeometryWidget->setToolTip( parameterDefinition()->toolTip() );
4472 emit widgetValueHasChanged(
this );
4474 return mGeometryWidget;
4480void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4482 if ( mGeometryWidget )
4491 mGeometryWidget->clearGeometry();
4496QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
4498 if ( mGeometryWidget )
4501 return geometry.
isEmpty() ? QVariant() : geometry.asWkt();
4509QStringList QgsProcessingGeometryWidgetWrapper::compatibleParameterTypes()
const
4511 return QStringList()
4518QStringList QgsProcessingGeometryWidgetWrapper::compatibleOutputTypes()
const
4520 return QStringList()
4525QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
4527 return tr(
"string in the Well-Known-Text format or a geometry value" );
4530QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
4537 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
4542 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4554 QVBoxLayout *vlayout =
new QVBoxLayout();
4555 vlayout->setContentsMargins( 0, 0, 0, 0 );
4557 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4560 mDefaultColorButton->setShowNull(
true );
4561 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
4567 mDefaultColorButton->setToNull();
4569 mDefaultColorButton->setColor(
c );
4570 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
4574 mDefaultColorButton->setToNull();
4575 mAllowOpacity->setChecked(
true );
4578 vlayout->addWidget( mDefaultColorButton );
4579 vlayout->addWidget( mAllowOpacity );
4580 setLayout( vlayout );
4585 auto param = std::make_unique< QgsProcessingParameterColor >( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
4587 return param.release();
4596QWidget *QgsProcessingColorWidgetWrapper::createWidget()
4606 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
4609 mColorButton->setShowNull(
true );
4612 mColorButton->setToolTip( parameterDefinition()->toolTip() );
4613 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
4621 emit widgetValueHasChanged(
this );
4624 return mColorButton;
4630void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4634 if ( !value.isValid() ||
4635 ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() )
4636 || ( value.userType() == QMetaType::Type::QColor && !value.value< QColor >().isValid() ) )
4637 mColorButton->setToNull();
4641 if ( !
c.isValid() && mColorButton->showNull() )
4642 mColorButton->setToNull();
4644 mColorButton->setColor(
c );
4649QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
4652 return mColorButton->isNull() ? QVariant() : mColorButton->color();
4657QStringList QgsProcessingColorWidgetWrapper::compatibleParameterTypes()
const
4659 return QStringList()
4664QStringList QgsProcessingColorWidgetWrapper::compatibleOutputTypes()
const
4666 return QStringList()
4671QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
4673 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
4676QString QgsProcessingColorWidgetWrapper::parameterType()
const
4683 return new QgsProcessingColorWidgetWrapper( parameter, type );
4688 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4699 QVBoxLayout *vlayout =
new QVBoxLayout();
4700 vlayout->setContentsMargins( 0, 0, 0, 0 );
4702 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4704 mDefaultLineEdit =
new QLineEdit();
4707 vlayout->addWidget( mDefaultLineEdit );
4709 mSourceParamComboBox =
new QComboBox();
4710 mDestParamComboBox =
new QComboBox();
4711 QString initialSource;
4712 QString initialDest;
4717 initialSource = itemParam->sourceCrsParameterName();
4718 initialDest = itemParam->destinationCrsParameterName();
4723 mSourceParamComboBox->addItem( QString(), QString() );
4724 mDestParamComboBox->addItem( QString(), QString() );
4725 if (
auto *lModel = widgetContext.
model() )
4728 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4729 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4731 if ( definition && it->parameterName() == definition->
name() )
4735 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4736 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4737 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4739 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4741 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4743 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4748 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4751 mSourceParamComboBox->addItem( initialSource, initialSource );
4752 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4754 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4757 mDestParamComboBox->addItem( initialDest, initialDest );
4758 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4761 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4762 vlayout->addWidget( mSourceParamComboBox );
4763 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4764 vlayout->addWidget( mDestParamComboBox );
4768 mStaticSourceWidget->setCrs( sourceCrs );
4771 mStaticDestWidget->setCrs( destCrs );
4773 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4774 vlayout->addWidget( mStaticSourceWidget );
4775 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4776 vlayout->addWidget( mStaticDestWidget );
4778 setLayout( vlayout );
4783 auto param = std::make_unique< QgsProcessingParameterCoordinateOperation >( name, description, mDefaultLineEdit->text(),
4784 mSourceParamComboBox->currentText(),
4785 mDestParamComboBox->currentText(),
4786 mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
4787 mStaticDestWidget->
crs().isValid() ? QVariant::fromValue( mStaticDestWidget->
crs() ) : QVariant() );
4789 return param.release();
4798QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4809 mOperationWidget->setShowMakeDefault(
false );
4810 mOperationWidget->setShowFallbackOption(
false );
4811 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4812 mOperationWidget->setSourceCrs( mSourceCrs );
4813 mOperationWidget->setDestinationCrs( mDestCrs );
4814 mOperationWidget->setMapCanvas( mCanvas );
4819 mOperationWidget->setSelectedOperation( deets );
4824 emit widgetValueHasChanged(
this );
4827 return mOperationWidget;
4833 mLineEdit =
new QLineEdit();
4834 QHBoxLayout *layout =
new QHBoxLayout();
4835 layout->addWidget( mLineEdit, 1 );
4836 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4838 emit widgetValueHasChanged(
this );
4841 QToolButton *button =
new QToolButton();
4842 button->setText( QString( QChar( 0x2026 ) ) );
4843 connect( button, &QToolButton::clicked,
this, [ = ]
4845 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4848 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4849 emit widgetValueHasChanged(
this );
4852 layout->addWidget( button );
4854 QWidget *w =
new QWidget();
4855 layout->setContentsMargins( 0, 0, 0, 0 );
4856 w->setLayout( layout );
4864void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4902 if ( mOperationWidget )
4903 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4906void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4908 if ( mOperationWidget )
4910 if ( !value.isValid() ||
4911 ( value.userType() == QMetaType::Type::QString ) )
4914 deets.
proj = value.toString();
4915 mOperationWidget->setSelectedOperation( deets );
4920 if ( !value.isValid() ||
4921 ( value.userType() == QMetaType::Type::QString ) )
4923 mLineEdit->setText( value.toString() );
4928QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4930 if ( mOperationWidget )
4931 return mOperationWidget->selectedOperation().proj;
4932 else if ( mLineEdit )
4933 return mLineEdit->text();
4938QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleParameterTypes()
const
4940 return QStringList()
4945QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleOutputTypes()
const
4947 return QStringList()
4952QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4954 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4957void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4960 std::unique_ptr< QgsProcessingContext > tmpContext;
4961 if ( mProcessingContextGenerator )
4962 context = mProcessingContextGenerator->processingContext();
4966 tmpContext = std::make_unique< QgsProcessingContext >();
4967 context = tmpContext.get();
4971 if ( mOperationWidget )
4973 mOperationWidget->setSourceCrs( mSourceCrs );
4974 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4978void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4981 std::unique_ptr< QgsProcessingContext > tmpContext;
4982 if ( mProcessingContextGenerator )
4983 context = mProcessingContextGenerator->processingContext();
4987 tmpContext = std::make_unique< QgsProcessingContext >();
4988 context = tmpContext.get();
4992 if ( mOperationWidget )
4994 mOperationWidget->setDestinationCrs( mDestCrs );
4995 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4999QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
5006 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
5011 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5024 QHBoxLayout *hl =
new QHBoxLayout();
5025 hl->setContentsMargins( 0, 0, 0, 0 );
5027 mLineEdit =
new QLineEdit();
5028 mLineEdit->setEnabled(
false );
5029 hl->addWidget( mLineEdit, 1 );
5031 mToolButton =
new QToolButton();
5032 mToolButton->setText( QString( QChar( 0x2026 ) ) );
5033 hl->addWidget( mToolButton );
5039 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
5042 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
5045void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
5050void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
5052 if ( value.isValid() )
5053 mValue = value.userType() == QMetaType::Type::QVariantList ? value.
toList() : QVariantList() << value;
5057 updateSummaryText();
5061void QgsProcessingFieldPanelWidget::showDialog()
5063 QVariantList availableOptions;
5064 availableOptions.reserve( mFields.size() );
5065 for (
const QgsField &field : std::as_const( mFields ) )
5067 availableOptions << field.name();
5073 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
5074 widget->setPanelTitle( mParam->description() );
5076 widget->setValueFormatter( [](
const QVariant & v ) -> QString
5078 return v.toString();
5081 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
5083 setValue( widget->selectedOptions() );
5090 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
5092 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
5094 return v.toString();
5098 setValue( dlg.selectedOptions() );
5103void QgsProcessingFieldPanelWidget::updateSummaryText()
5108 if ( mValue.empty() )
5110 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
5115 values.reserve( mValue.size() );
5116 for (
const QVariant &val : std::as_const( mValue ) )
5118 values << val.toString();
5121 const QString concatenated = values.join( tr(
"," ) );
5122 if ( concatenated.length() < 100 )
5123 mLineEdit->setText( concatenated );
5125 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
5137 QVBoxLayout *vlayout =
new QVBoxLayout();
5138 vlayout->setContentsMargins( 0, 0, 0, 0 );
5140 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
5141 mParentLayerComboBox =
new QComboBox();
5143 QString initialParent;
5145 initialParent = fieldParam->parentLayerParameterName();
5147 if (
auto *lModel = widgetContext.
model() )
5150 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5151 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5155 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
5156 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
5158 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
5163 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
5164 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
5166 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
5173 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
5174 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
5176 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
5183 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
5186 mParentLayerComboBox->addItem( initialParent, initialParent );
5187 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
5190 vlayout->addWidget( mParentLayerComboBox );
5192 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
5193 mDataTypeComboBox =
new QComboBox();
5201 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast< int >( fieldParam->dataType() ) ) );
5203 vlayout->addWidget( mDataTypeComboBox );
5205 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
5207 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
5209 vlayout->addWidget( mAllowMultipleCheckBox );
5211 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
5212 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
5214 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
5216 vlayout->addWidget( mDefaultToAllCheckBox );
5218 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
5220 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
5223 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5225 mDefaultLineEdit =
new QLineEdit();
5226 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
5230 mDefaultLineEdit->setText( fields.join(
';' ) );
5232 vlayout->addWidget( mDefaultLineEdit );
5234 setLayout( vlayout );
5241 QVariant defaultValue;
5242 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
5244 defaultValue = mDefaultLineEdit->text();
5246 auto param = std::make_unique< QgsProcessingParameterField >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
5248 return param.release();
5257QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
5267 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
5268 mPanel->setToolTip( parameterDefinition()->toolTip() );
5269 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [ = ]
5271 emit widgetValueHasChanged(
this );
5291 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5294 emit widgetValueHasChanged(
this );
5302 mLineEdit =
new QLineEdit();
5303 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
5304 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
5306 emit widgetValueHasChanged(
this );
5315void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5327 setParentLayerWrapperValue( wrapper );
5330 setParentLayerWrapperValue( wrapper );
5347 std::unique_ptr< QgsProcessingContext > tmpContext;
5348 if ( mProcessingContextGenerator )
5349 context = mProcessingContextGenerator->processingContext();
5353 tmpContext = std::make_unique< QgsProcessingContext >();
5354 context = tmpContext.get();
5359 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
5369 bool valueSet =
false;
5373 if ( layers.count() > 1 )
5375 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
5377 const QList< QgsMapLayer * > remainingLayers = layers.mid( 1 );
5383 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer );
5384 if ( !vlayer || !vlayer->
isValid() )
5390 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
5393 fields.
remove( fieldIdx );
5398 mComboBox->setFields( fields );
5400 mPanel->setFields( filterFields( fields ) );
5406 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
5408 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
5412 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
5415 mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
5416 layer = mParentLayer.get();
5424 mComboBox->setLayer( layer );
5426 mPanel->setFields( filterFields( layer->
fields() ) );
5436 const QgsFields fields = source->fields();
5438 mComboBox->setFields( fields );
5440 mPanel->setFields( filterFields( fields ) );
5449 mComboBox->setLayer(
nullptr );
5453 if ( value.isValid() && widgetContext().messageBar() )
5456 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent field could not be populated" ),
5466 val.reserve( mPanel->fields().size() );
5467 for (
const QgsField &field : mPanel->fields() )
5468 val << field.name();
5469 setWidgetValue( val, *context );
5472 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5475void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5479 if ( !value.isValid() )
5480 mComboBox->setField( QString() );
5484 mComboBox->setField( v );
5490 if ( value.isValid() )
5493 opts.reserve( v.size() );
5494 for (
const QString &i : v )
5498 mPanel->setValue( opts );
5500 else if ( mLineEdit )
5506 mLineEdit->setText( v.join(
';' ) );
5515QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
5518 return mComboBox->currentField();
5520 return mPanel->value();
5521 else if ( mLineEdit )
5526 return mLineEdit->text().split(
';' );
5529 return mLineEdit->text();
5535QStringList QgsProcessingFieldWidgetWrapper::compatibleParameterTypes()
const
5537 return QStringList()
5542QStringList QgsProcessingFieldWidgetWrapper::compatibleOutputTypes()
const
5544 return QStringList()
5549QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
5551 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
5554const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
5556 if ( mComboBox && mComboBox->layer() )
5557 return mComboBox->layer();
5562QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
5575 if ( f.isNumeric() )
5580 if ( f.type() == QMetaType::Type::QString )
5585 if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
5590 if ( f.type() == QMetaType::Type::QByteArray )
5595 if ( f.type() == QMetaType::Type::Bool )
5604QString QgsProcessingFieldWidgetWrapper::parameterType()
const
5611 return new QgsProcessingFieldWidgetWrapper( parameter, type );
5616 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5627 QVBoxLayout *vlayout =
new QVBoxLayout();
5628 vlayout->setContentsMargins( 0, 0, 0, 0 );
5630 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5632 mDefaultComboBox =
new QComboBox();
5633 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
5636 for (
const QString &theme : mapThemes )
5640 mDefaultComboBox->setEditable(
true );
5644 if ( themeParam->defaultValueForGui().isValid() )
5647 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5650 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5652 vlayout->addWidget( mDefaultComboBox );
5654 setLayout( vlayout );
5659 QVariant defaultVal;
5660 if ( mDefaultComboBox->currentText().isEmpty() )
5661 defaultVal = QVariant();
5663 defaultVal = mDefaultComboBox->currentText();
5664 auto param = std::make_unique< QgsProcessingParameterMapTheme>( name, description, defaultVal );
5666 return param.release();
5676QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
5680 mComboBox =
new QComboBox();
5683 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
5686 for (
const QString &theme : mapThemes )
5698 mComboBox->setEditable(
true );
5702 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5703 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
5705 emit widgetValueHasChanged(
this );
5711void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5715 if ( !value.isValid() )
5716 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5719 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5721 const QString prev = mComboBox->currentText();
5722 mComboBox->setCurrentText( v );
5724 emit widgetValueHasChanged(
this );
5727 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5731QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5734 return mComboBox->currentData().toInt() == -1 ? QVariant() :
5735 !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5736 : mComboBox->currentData();
5741QStringList QgsProcessingMapThemeWidgetWrapper::compatibleParameterTypes()
const
5743 return QStringList()
5748QStringList QgsProcessingMapThemeWidgetWrapper::compatibleOutputTypes()
const
5750 return QStringList()
5755QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5757 return tr(
"map theme as a string value (e.g. 'base maps')" );
5760QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5767 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5772 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5785 QVBoxLayout *vlayout =
new QVBoxLayout();
5786 vlayout->setContentsMargins( 0, 0, 0, 0 );
5788 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5790 mTypeComboBox =
new QComboBox();
5795 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( datetimeParam->dataType() ) ) );
5797 mTypeComboBox->setCurrentIndex( 0 );
5798 vlayout->addWidget( mTypeComboBox );
5800 setLayout( vlayout );
5805 auto param = std::make_unique< QgsProcessingParameterDateTime >( name, description );
5808 return param.release();
5818QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5823 switch ( dateTimeParam->
dataType() )
5827 widget = mDateTimeEdit;
5850 widget->setToolTip( parameterDefinition()->toolTip() );
5852 if ( mDateTimeEdit )
5856 emit widgetValueHasChanged(
this );
5859 else if ( mDateEdit )
5863 emit widgetValueHasChanged(
this );
5866 else if ( mTimeEdit )
5870 emit widgetValueHasChanged(
this );
5879 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5882void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5884 if ( mDateTimeEdit )
5888 else if ( mDateEdit )
5892 else if ( mTimeEdit )
5898QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5900 if ( mDateTimeEdit )
5901 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5902 else if ( mDateEdit )
5903 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5904 else if ( mTimeEdit )
5905 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5910QStringList QgsProcessingDateTimeWidgetWrapper::compatibleParameterTypes()
const
5912 return QStringList()
5917QStringList QgsProcessingDateTimeWidgetWrapper::compatibleOutputTypes()
const
5919 return QStringList()
5924QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5927 if ( dateTimeParam )
5929 switch ( dateTimeParam->
dataType() )
5932 return tr(
"datetime value, or a ISO string representation of a datetime" );
5935 return tr(
"date value, or a ISO string representation of a date" );
5938 return tr(
"time value, or a ISO string representation of a time" );
5944QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5951 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5965 QVBoxLayout *vlayout =
new QVBoxLayout();
5966 vlayout->setContentsMargins( 0, 0, 0, 0 );
5968 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5969 mProviderComboBox =
new QComboBox();
5970 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
5971 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
5972 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
5974 vlayout->addWidget( mProviderComboBox );
5976 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5978 mDefaultEdit =
new QLineEdit();
5979 vlayout->addWidget( mDefaultEdit );
5980 setLayout( vlayout );
5982 if ( connectionParam )
5984 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5991 QVariant defaultVal;
5992 if ( mDefaultEdit->text().isEmpty() )
5993 defaultVal = QVariant();
5995 defaultVal = mDefaultEdit->text();
5996 auto param = std::make_unique< QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5998 return param.release();
6008QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
6014 mProviderComboBox->setAllowEmptyConnection(
true );
6022 mProviderComboBox->setEditable(
true );
6026 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
6027 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [ = ](
const QString & )
6029 if ( mBlockSignals )
6032 emit widgetValueHasChanged(
this );
6035 return mProviderComboBox;
6040 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6043void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6047 if ( !value.isValid() )
6048 mProviderComboBox->setCurrentIndex( -1 );
6051 if ( mProviderComboBox->isEditable() )
6053 const QString prev = mProviderComboBox->currentText();
6055 mProviderComboBox->setConnection( v );
6056 mProviderComboBox->setCurrentText( v );
6060 emit widgetValueHasChanged(
this );
6063 mProviderComboBox->setConnection( v );
6067QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
6069 if ( mProviderComboBox )
6070 if ( mProviderComboBox->isEditable() )
6071 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
6073 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
6078QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleParameterTypes()
const
6080 return QStringList()
6086QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleOutputTypes()
const
6088 return QStringList()
6093QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
6095 return tr(
"connection name as a string value" );
6098QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
6105 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
6120 QVBoxLayout *vlayout =
new QVBoxLayout();
6121 vlayout->setContentsMargins( 0, 0, 0, 0 );
6123 mConnectionParamComboBox =
new QComboBox();
6124 QString initialConnection;
6130 if (
auto *lModel = widgetContext.
model() )
6133 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6134 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6136 if ( definition && it->parameterName() == definition->
name() )
6142 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
6143 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6145 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6150 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
6153 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
6154 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6157 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
6158 vlayout->addWidget( mConnectionParamComboBox );
6160 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6162 mDefaultEdit =
new QLineEdit();
6163 vlayout->addWidget( mDefaultEdit );
6164 setLayout( vlayout );
6174 QVariant defaultVal;
6175 if ( mDefaultEdit->text().isEmpty() )
6176 defaultVal = QVariant();
6178 defaultVal = mDefaultEdit->text();
6179 auto param = std::make_unique< QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
6181 return param.release();
6191QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
6197 mSchemaComboBox->setAllowEmptySchema(
true );
6205 mSchemaComboBox->comboBox()->setEditable(
true );
6209 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
6210 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
6212 if ( mBlockSignals )
6215 emit widgetValueHasChanged( this );
6218 return mSchemaComboBox;
6223 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6230 std::unique_ptr< QgsProcessingContext > tmpContext;
6231 if ( mProcessingContextGenerator )
6232 context = mProcessingContextGenerator->processingContext();
6236 tmpContext = std::make_unique< QgsProcessingContext >();
6237 context = tmpContext.get();
6243 if ( mSchemaComboBox )
6244 mSchemaComboBox->setConnectionName( connection, qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId() );
6248 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6251void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6255 if ( !value.isValid() )
6256 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
6259 if ( mSchemaComboBox->comboBox()->isEditable() )
6261 const QString prev = mSchemaComboBox->comboBox()->currentText();
6263 mSchemaComboBox->setSchema( v );
6264 mSchemaComboBox->comboBox()->setCurrentText( v );
6268 emit widgetValueHasChanged(
this );
6271 mSchemaComboBox->setSchema( v );
6275QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
6277 if ( mSchemaComboBox )
6278 if ( mSchemaComboBox->comboBox()->isEditable() )
6279 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
6281 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
6286QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleParameterTypes()
const
6288 return QStringList()
6294QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleOutputTypes()
const
6296 return QStringList()
6301QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
6303 return tr(
"database schema name as a string value" );
6306QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
6313 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
6316void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6328 setParentConnectionWrapperValue( wrapper );
6331 setParentConnectionWrapperValue( wrapper );
6355 QVBoxLayout *vlayout =
new QVBoxLayout();
6356 vlayout->setContentsMargins( 0, 0, 0, 0 );
6358 mConnectionParamComboBox =
new QComboBox();
6359 mSchemaParamComboBox =
new QComboBox();
6360 QString initialConnection;
6361 QString initialSchema;
6368 if (
auto *lModel = widgetContext.
model() )
6371 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6372 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6374 if ( definition && it->parameterName() == definition->
name() )
6379 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
6380 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6382 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6387 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
6388 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6390 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6396 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
6399 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
6400 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6403 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
6406 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
6407 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6410 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
6411 vlayout->addWidget( mConnectionParamComboBox );
6413 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
6414 vlayout->addWidget( mSchemaParamComboBox );
6416 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6418 mDefaultEdit =
new QLineEdit();
6419 vlayout->addWidget( mDefaultEdit );
6420 setLayout( vlayout );
6430 QVariant defaultVal;
6431 if ( mDefaultEdit->text().isEmpty() )
6432 defaultVal = QVariant();
6434 defaultVal = mDefaultEdit->text();
6435 auto param = std::make_unique< QgsProcessingParameterDatabaseTable>( name, description,
6436 mConnectionParamComboBox->currentData().toString(),
6437 mSchemaParamComboBox->currentData().toString(),
6440 return param.release();
6450QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
6456 mTableComboBox->setAllowEmptyTable(
true );
6459 mTableComboBox->comboBox()->setEditable(
true );
6461 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
6462 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
6464 if ( mBlockSignals )
6467 emit widgetValueHasChanged( this );
6470 return mTableComboBox;
6475 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6482 std::unique_ptr< QgsProcessingContext > tmpContext;
6483 if ( mProcessingContextGenerator )
6484 context = mProcessingContextGenerator->processingContext();
6488 tmpContext = std::make_unique< QgsProcessingContext >();
6489 context = tmpContext.get();
6494 mProvider = qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId();
6495 if ( mTableComboBox && !mSchema.isEmpty() )
6497 mTableComboBox->setSchema( mSchema );
6498 mTableComboBox->setConnectionName( mConnection, mProvider );
6502 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6510 std::unique_ptr< QgsProcessingContext > tmpContext;
6511 if ( mProcessingContextGenerator )
6512 context = mProcessingContextGenerator->processingContext();
6516 tmpContext = std::make_unique< QgsProcessingContext >();
6517 context = tmpContext.get();
6523 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
6525 mTableComboBox->setSchema( mSchema );
6526 mTableComboBox->setConnectionName( mConnection, mProvider );
6530 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6535void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6539 if ( !value.isValid() )
6540 mTableComboBox->comboBox()->setCurrentIndex( -1 );
6543 if ( mTableComboBox->comboBox()->isEditable() )
6545 const QString prev = mTableComboBox->comboBox()->currentText();
6547 mTableComboBox->setTable( v );
6548 mTableComboBox->comboBox()->setCurrentText( v );
6552 emit widgetValueHasChanged(
this );
6555 mTableComboBox->setTable( v );
6559QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
6561 if ( mTableComboBox )
6562 if ( mTableComboBox->comboBox()->isEditable() )
6563 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
6565 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
6570QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleParameterTypes()
const
6572 return QStringList()
6578QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleOutputTypes()
const
6580 return QStringList()
6585QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
6587 return tr(
"database table name as a string value" );
6590QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
6597 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
6600void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6612 setParentConnectionWrapperValue( wrapper );
6615 setParentConnectionWrapperValue( wrapper );
6620 setParentSchemaWrapperValue( wrapper );
6623 setParentSchemaWrapperValue( wrapper );
6643 QVBoxLayout *vlayout =
new QVBoxLayout();
6644 vlayout->setContentsMargins( 0, 0, 0, 0 );
6646 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6649 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6652 if ( extentParam->defaultValueForGui().isValid() )
6656 mDefaultWidget->setCurrentExtent( rect,
crs );
6657 mDefaultWidget->setOutputExtentFromCurrent();
6661 mDefaultWidget->clear();
6665 vlayout->addWidget( mDefaultWidget );
6666 setLayout( vlayout );
6671 const QString defaultVal = mDefaultWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
6672 QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ),
6673 QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ),
6674 QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ),
6675 QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ),
6676 mDefaultWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mDefaultWidget->outputCrs().authid() ) : QString()
6678 auto param = std::make_unique< QgsProcessingParameterExtent >( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
6680 return param.release();
6691QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
6701 if ( widgetContext().mapCanvas() )
6702 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
6705 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6707 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6711 emit widgetValueHasChanged(
this );
6715 setDialog( mDialog );
6717 return mExtentWidget;
6727 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6730void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6738 mDialog->showMinimized();
6741 mDialog->showNormal();
6743 mDialog->activateWindow();
6750void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6752 if ( mExtentWidget )
6754 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
6755 mExtentWidget->clear();
6760 mExtentWidget->setCurrentExtent( r,
crs );
6761 mExtentWidget->setOutputExtentFromUser( r,
crs );
6766QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6768 if ( mExtentWidget )
6770 const QString val = mExtentWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
6771 QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ),
6772 QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ),
6773 QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ),
6774 QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ),
6775 mExtentWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mExtentWidget->outputCrs().authid() ) : QString()
6778 return val.isEmpty() ? QVariant() : QVariant( val );
6784QStringList QgsProcessingExtentWidgetWrapper::compatibleParameterTypes()
const
6786 return QStringList()
6798QStringList QgsProcessingExtentWidgetWrapper::compatibleOutputTypes()
const
6800 return QStringList()
6808QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6810 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6813QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6820 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6825 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6837 QVBoxLayout *vlayout =
new QVBoxLayout();
6838 vlayout->setContentsMargins( 0, 0, 0, 0 );
6840 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6855 for (
int i : layerParam->dataTypes() )
6857 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6861 vlayout->addWidget( mLayerTypeComboBox );
6863 setLayout( vlayout );
6868 QList< int > dataTypes;
6869 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6870 dataTypes << v.toInt();
6872 auto param = std::make_unique< QgsProcessingParameterMapLayer >( name, description );
6873 param->setDataTypes( dataTypes );
6875 return param.release();
6884QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6886 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6894 mComboBox->setEditable(
true );
6898 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6900 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [ = ]()
6902 if ( mBlockSignals )
6905 emit widgetValueHasChanged(
this );
6908 setWidgetContext( widgetContext() );
6917 mComboBox->setWidgetContext( context );
6922 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6928void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6931 mComboBox->setValue( value, context );
6934QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6936 return mComboBox ? mComboBox->value() : QVariant();
6939QStringList QgsProcessingMapLayerWidgetWrapper::compatibleParameterTypes()
const
6941 return QStringList()
6952QStringList QgsProcessingMapLayerWidgetWrapper::compatibleOutputTypes()
const
6954 return QStringList()
6963QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6965 return tr(
"path to a map layer" );
6982QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6989 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6994 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7003 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7008QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleParameterTypes()
const
7010 return QStringList()
7017QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleOutputTypes()
const
7019 return QStringList()
7027QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
7029 return tr(
"path to a raster layer" );
7032QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
7039 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
7044 Q_UNUSED( context );
7045 Q_UNUSED( widgetContext );
7046 Q_UNUSED( definition );
7060 QVBoxLayout *vlayout =
new QVBoxLayout();
7061 vlayout->setContentsMargins( 0, 0, 0, 0 );
7063 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
7073 for (
int i : vectorParam->dataTypes() )
7075 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
7079 vlayout->addWidget( mGeometryTypeComboBox );
7081 setLayout( vlayout );
7086 QList< int > dataTypes;
7087 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
7088 dataTypes << v.toInt();
7090 auto param = std::make_unique< QgsProcessingParameterVectorLayer >( name, description, dataTypes );
7092 return param.release();
7097 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7102QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleParameterTypes()
const
7104 return QStringList()
7111QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleOutputTypes()
const
7113 return QStringList()
7121QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
7123 return tr(
"path to a vector layer" );
7129 return param->dataTypes();
7131 return QList< int >();
7134QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
7141 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
7146 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7158 QVBoxLayout *vlayout =
new QVBoxLayout();
7159 vlayout->setContentsMargins( 0, 0, 0, 0 );
7161 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
7171 for (
int i : sourceParam->dataTypes() )
7173 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
7181 vlayout->addWidget( mGeometryTypeComboBox );
7183 setLayout( vlayout );
7188 QList< int > dataTypes;
7189 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
7190 dataTypes << v.toInt();
7192 auto param = std::make_unique< QgsProcessingParameterFeatureSource >( name, description, dataTypes );
7194 return param.release();
7198 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7203QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleParameterTypes()
const
7205 return QStringList()
7213QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleOutputTypes()
const
7215 return QStringList()
7223QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
7225 return tr(
"path to a vector layer" );
7231 return param->dataTypes();
7233 return QList< int >();
7236QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
7243 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
7248 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7256 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7261QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleParameterTypes()
const
7263 return QStringList()
7270QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleOutputTypes()
const
7272 return QStringList()
7280QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
7282 return tr(
"path to a mesh layer" );
7285QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
7292 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
7297 Q_UNUSED( context );
7298 Q_UNUSED( widgetContext );
7299 Q_UNUSED( definition );
7311QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
7315 QHBoxLayout *hl =
new QHBoxLayout();
7316 hl->setContentsMargins( 0, 0, 0, 0 );
7318 mLineEdit =
new QLineEdit();
7319 mLineEdit->setEnabled(
false );
7320 hl->addWidget( mLineEdit, 1 );
7322 mToolButton =
new QToolButton();
7323 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7324 hl->addWidget( mToolButton );
7330 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
7333 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
7336void QgsProcessingRasterBandPanelWidget::setBands(
const QList< int > &bands )
7341void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
7346void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
7348 if ( value.isValid() )
7349 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7353 updateSummaryText();
7357void QgsProcessingRasterBandPanelWidget::showDialog()
7359 QVariantList availableOptions;
7360 availableOptions.reserve( mBands.size() );
7361 for (
int band : std::as_const( mBands ) )
7363 availableOptions << band;
7369 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7370 widget->setPanelTitle( mParam->description() );
7372 widget->setValueFormatter( [
this](
const QVariant & v ) -> QString
7374 int band = v.toInt();
7375 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
7378 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
7380 setValue( widget->selectedOptions() );
7387 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7389 dlg.setValueFormatter( [
this](
const QVariant & v ) -> QString
7391 int band = v.toInt();
7392 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
7396 setValue( dlg.selectedOptions() );
7401void QgsProcessingRasterBandPanelWidget::updateSummaryText()
7404 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
7416 QVBoxLayout *vlayout =
new QVBoxLayout();
7417 vlayout->setContentsMargins( 0, 0, 0, 0 );
7419 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7421 mDefaultLineEdit =
new QLineEdit();
7422 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
7427 for (
int b : bands )
7429 defVal << QString::number( b );
7432 mDefaultLineEdit->setText( defVal.join(
';' ) );
7434 vlayout->addWidget( mDefaultLineEdit );
7436 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7437 mParentLayerComboBox =
new QComboBox();
7439 QString initialParent;
7441 initialParent = bandParam->parentLayerParameterName();
7443 if (
auto *lModel = widgetContext.
model() )
7446 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7447 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7451 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
7452 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7454 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7460 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7463 mParentLayerComboBox->addItem( initialParent, initialParent );
7464 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7467 vlayout->addWidget( mParentLayerComboBox );
7469 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
7471 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
7473 vlayout->addWidget( mAllowMultipleCheckBox );
7474 setLayout( vlayout );
7479 auto param = std::make_unique< QgsProcessingParameterBand >( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
7481 return param.release();
7490QWidget *QgsProcessingBandWidgetWrapper::createWidget()
7500 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
7501 mPanel->setToolTip( parameterDefinition()->toolTip() );
7502 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [ = ]
7504 emit widgetValueHasChanged(
this );
7513 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7516 emit widgetValueHasChanged(
this );
7524 mLineEdit =
new QLineEdit();
7525 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
7526 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
7528 emit widgetValueHasChanged(
this );
7537void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7549 setParentLayerWrapperValue( wrapper );
7552 setParentLayerWrapperValue( wrapper );
7569 std::unique_ptr< QgsProcessingContext > tmpContext;
7570 if ( mProcessingContextGenerator )
7571 context = mProcessingContextGenerator->processingContext();
7575 tmpContext = std::make_unique< QgsProcessingContext >();
7576 context = tmpContext.get();
7582 if ( layer && layer->
isValid() )
7586 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
7589 mParentLayer.reset( qobject_cast< QgsRasterLayer * >( ownedLayer.release() ) );
7590 layer = mParentLayer.get();
7598 mComboBox->setLayer( layer );
7602 if ( provider && layer->
isValid() )
7607 QHash< int, QString > bandNames;
7608 for (
int i = 1; i <= nBands; ++i )
7613 mPanel->setBands( bands );
7614 mPanel->setBandNames( bandNames );
7621 mComboBox->setLayer(
nullptr );
7623 mPanel->setBands( QList< int >() );
7625 if ( value.isValid() && widgetContext().messageBar() )
7628 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent bands could not be populated" ),
7633 if ( parameterDefinition()->defaultValueForGui().isValid() )
7634 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7637void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7641 if ( !value.isValid() )
7642 mComboBox->setBand( -1 );
7646 mComboBox->setBand( v );
7652 if ( value.isValid() )
7655 opts.reserve( v.size() );
7660 mPanel->setValue( value.isValid() ? opts : QVariant() );
7662 else if ( mLineEdit )
7669 opts.reserve( v.size() );
7671 opts << QString::number( i );
7672 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
7676 if ( value.isValid() )
7684QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
7687 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
7689 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7690 else if ( mLineEdit )
7695 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
7697 res.reserve( parts.count() );
7698 for (
const QString &s : parts )
7701 int band = s.toInt( &ok );
7705 return res.
isEmpty() ? QVariant() : res;
7709 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7716QStringList QgsProcessingBandWidgetWrapper::compatibleParameterTypes()
const
7718 return QStringList()
7723QStringList QgsProcessingBandWidgetWrapper::compatibleOutputTypes()
const
7725 return QStringList()
7730QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7732 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7735QString QgsProcessingBandWidgetWrapper::parameterType()
const
7742 return new QgsProcessingBandWidgetWrapper( parameter, type );
7747 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7758 setAcceptDrops(
true );
7761void QgsProcessingMultipleLayerLineEdit::dragEnterEvent( QDragEnterEvent *event )
7763 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7764 if ( !uris.isEmpty() )
7766 event->setDropAction( Qt::CopyAction );
7768 setHighlighted(
true );
7776void QgsProcessingMultipleLayerLineEdit::dragLeaveEvent( QDragLeaveEvent *event )
7778 QgsHighlightableLineEdit::dragLeaveEvent( event );
7780 setHighlighted(
false );
7783void QgsProcessingMultipleLayerLineEdit::dropEvent( QDropEvent *event )
7785 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7786 if ( !uris.isEmpty() )
7788 event->acceptProposedAction();
7789 QVariantList uriList;
7790 uriList.reserve( uris.size() );
7791 for (
const QString &uri : uris )
7792 uriList.append( QVariant( uri ) );
7793 emit layersDropped( uriList );
7796 setHighlighted(
false );
7807 QHBoxLayout *hl =
new QHBoxLayout();
7808 hl->setContentsMargins( 0, 0, 0, 0 );
7810 mLineEdit =
new QgsProcessingMultipleLayerLineEdit(
nullptr, param );
7811 mLineEdit->setEnabled(
true );
7812 mLineEdit->setReadOnly(
true );
7814 hl->addWidget( mLineEdit, 1 );
7815 connect( mLineEdit, &QgsProcessingMultipleLayerLineEdit::layersDropped,
this, &QgsProcessingMultipleLayerPanelWidget::setValue );
7817 mToolButton =
new QToolButton();
7818 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7819 hl->addWidget( mToolButton );
7825 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7828 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7831void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7833 if ( value.isValid() )
7834 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7838 updateSummaryText();
7842void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7849 if ( mValue.removeAll( layerId ) )
7851 updateSummaryText();
7858void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7864 switch ( mParam->layerType() )
8022void QgsProcessingMultipleLayerPanelWidget::showDialog()
8027 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
8028 widget->setPanelTitle( mParam->description() );
8029 widget->setProject( mProject );
8030 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
8032 setValue( widget->selectedOptions() );
8039 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
8040 dlg.setProject( mProject );
8043 setValue( dlg.selectedOptions() );
8048void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
8051 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
8061 QVBoxLayout *vlayout =
new QVBoxLayout();
8062 vlayout->setContentsMargins( 0, 0, 0, 0 );
8064 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
8065 mLayerTypeComboBox =
new QComboBox();
8079 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast< int >( layersParam->layerType() ) ) );
8081 vlayout->addWidget( mLayerTypeComboBox );
8082 setLayout( vlayout );
8087 auto param = std::make_unique< QgsProcessingParameterMultipleLayers >( name, description,
static_cast< Qgis::ProcessingSourceType >( mLayerTypeComboBox->currentData().toInt() ) );
8089 return param.release();
8098QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
8102 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
8103 mPanel->setToolTip( parameterDefinition()->toolTip() );
8104 mPanel->setProject( widgetContext().project() );
8106 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
8107 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [ = ]
8109 emit widgetValueHasChanged(
this );
8119 mPanel->setProject( context.
project() );
8121 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
8125void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8130 if ( value.isValid() )
8133 opts.reserve( v.size() );
8135 opts << l->source();
8138 for (
const QVariant &v : value.toList() )
8140 if ( v.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
8142 const QgsProcessingModelChildParameterSource source = v.value< QgsProcessingModelChildParameterSource >();
8143 opts << QVariant::fromValue( source );
8148 mPanel->setValue( value.isValid() ? opts : QVariant() );
8152QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
8155 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
8160QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleParameterTypes()
const
8162 return QStringList()
8173QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleOutputTypes()
const
8175 return QStringList()
8185QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
8187 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
8190QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
8197 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
8202 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8211 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
8216QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleParameterTypes()
const
8218 return QStringList()
8225QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleOutputTypes()
const
8227 return QStringList()
8235QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
8237 return tr(
"path to a point cloud layer" );
8240QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
8247 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
8252 Q_UNUSED( context );
8253 Q_UNUSED( widgetContext );
8254 Q_UNUSED( definition );
8271QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleParameterTypes()
const
8273 return QStringList()
8280QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleOutputTypes()
const
8282 return QStringList()
8288QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
8290 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
8293QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
8300 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
8305 Q_UNUSED( context );
8306 Q_UNUSED( widgetContext );
8307 Q_UNUSED( definition );
8318 if ( mWidgetContext.project() )
8319 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
8323QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
8334 mComboBox->setEditable(
true );
8338 mComboBox->setToolTip( parameterDefinition()->toolTip() );
8340 if ( mWidgetContext.project() )
8341 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
8344 mComboBox->setAllowEmptyLayer(
true );
8348 if ( mBlockSignals )
8351 emit widgetValueHasChanged(
this );
8354 setWidgetContext( widgetContext() );
8358void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8364 mComboBox->setLayer(
nullptr );
8368 QVariant val = value;
8369 if ( val.userType() == qMetaTypeId<QgsProperty>() )
8381 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( val.value< QObject * >() );
8382 if ( !layer && val.userType() == QMetaType::Type::QString )
8389 mComboBox->setLayer( layer );
8394QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
8396 return mComboBox && mComboBox->currentLayer() ?
8397 ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral(
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
8410 QHBoxLayout *hl =
new QHBoxLayout();
8411 hl->setContentsMargins( 0, 0, 0, 0 );
8413 mLineEdit =
new QLineEdit();
8414 mLineEdit->setEnabled(
false );
8415 hl->addWidget( mLineEdit, 1 );
8417 mToolButton =
new QToolButton();
8418 mToolButton->setText( QString( QChar( 0x2026 ) ) );
8419 hl->addWidget( mToolButton );
8425 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
8428 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
8433 mAttributes = attributes;
8436void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
8438 if ( value.isValid() )
8439 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
8443 updateSummaryText();
8447void QgsProcessingPointCloudAttributePanelWidget::showDialog()
8449 QVariantList availableOptions;
8450 availableOptions.reserve( mAttributes.count() );
8451 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
8454 availableOptions << attr.name();
8460 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
8461 widget->setPanelTitle( mParam->description() );
8463 widget->setValueFormatter( [](
const QVariant & v ) -> QString
8465 return v.toString();
8468 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
8470 setValue( widget->selectedOptions() );
8477 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
8479 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
8481 return v.toString();
8485 setValue( dlg.selectedOptions() );
8490void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
8495 if ( mValue.empty() )
8497 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
8502 values.reserve( mValue.size() );
8503 for (
const QVariant &val : std::as_const( mValue ) )
8505 values << val.toString();
8508 const QString concatenated = values.join( tr(
"," ) );
8509 if ( concatenated.length() < 100 )
8510 mLineEdit->setText( concatenated );
8512 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
8524 QVBoxLayout *vlayout =
new QVBoxLayout();
8525 vlayout->setContentsMargins( 0, 0, 0, 0 );
8527 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
8528 mParentLayerComboBox =
new QComboBox();
8530 QString initialParent;
8532 initialParent = attrParam->parentLayerParameterName();
8534 if (
auto *lModel = widgetContext.
model() )
8537 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
8538 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
8542 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
8543 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
8545 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
8551 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
8554 mParentLayerComboBox->addItem( initialParent, initialParent );
8555 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
8558 vlayout->addWidget( mParentLayerComboBox );
8560 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
8562 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
8564 vlayout->addWidget( mAllowMultipleCheckBox );
8566 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
8567 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
8569 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
8571 vlayout->addWidget( mDefaultToAllCheckBox );
8573 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
8575 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
8578 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
8580 mDefaultLineEdit =
new QLineEdit();
8581 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
8585 mDefaultLineEdit->setText( attributes.join(
';' ) );
8587 vlayout->addWidget( mDefaultLineEdit );
8589 setLayout( vlayout );
8594 QVariant defaultValue;
8595 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
8597 defaultValue = mDefaultLineEdit->text();
8599 auto param = std::make_unique< QgsProcessingParameterPointCloudAttribute >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
8601 return param.release();
8609QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
8619 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
8620 mPanel->setToolTip( parameterDefinition()->toolTip() );
8621 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [ = ]
8623 emit widgetValueHasChanged(
this );
8631 mComboBox->setToolTip( parameterDefinition()->toolTip() );
8634 emit widgetValueHasChanged(
this );
8642 mLineEdit =
new QLineEdit();
8643 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
8644 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
8646 emit widgetValueHasChanged(
this );
8655void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
8667 setParentLayerWrapperValue( wrapper );
8670 setParentLayerWrapperValue( wrapper );
8687 std::unique_ptr< QgsProcessingContext > tmpContext;
8688 if ( mProcessingContextGenerator )
8689 context = mProcessingContextGenerator->processingContext();
8693 tmpContext = std::make_unique< QgsProcessingContext >();
8694 context = tmpContext.get();
8700 if ( layer && layer->
isValid() )
8704 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
8707 mParentLayer.reset( qobject_cast< QgsPointCloudLayer * >( ownedLayer.release() ) );
8708 layer = mParentLayer.get();
8716 mComboBox->setLayer( layer );
8719 mPanel->setAttributes( layer->
attributes() );
8726 mComboBox->setLayer(
nullptr );
8731 if ( value.isValid() && widgetContext().messageBar() )
8734 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent attributes could not be populated" ),
8743 val.reserve( mPanel->attributes().attributes().size() );
8746 setWidgetValue( val, *context );
8749 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
8752void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8756 if ( !value.isValid() )
8757 mComboBox->setAttribute( QString() );
8761 mComboBox->setAttribute( v );
8767 if ( value.isValid() )
8770 opts.reserve( v.size() );
8771 for (
const QString &i : v )
8775 mPanel->setValue( opts );
8777 else if ( mLineEdit )
8783 mLineEdit->setText( v.join(
';' ) );
8792QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
8795 return mComboBox->currentAttribute();
8797 return mPanel->value();
8798 else if ( mLineEdit )
8803 return mLineEdit->text().split(
';' );
8806 return mLineEdit->text();
8812QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleParameterTypes()
const
8814 return QStringList()
8819QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleOutputTypes()
const
8821 return QStringList()
8826QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
8828 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
8831QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
8838 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
8843 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8857QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8865 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8866 if ( mProcessingContextGenerator )
8867 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8868 if ( mParametersGenerator )
8869 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8870 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8872 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [ = ]()
8874 if ( mBlockSignals )
8877 emit widgetValueHasChanged(
this );
8886 mOutputWidget->addOpenAfterRunningOption();
8888 return mOutputWidget;
8898void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8900 if ( mOutputWidget )
8901 mOutputWidget->setValue( value );
8904QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8906 if ( mOutputWidget )
8907 return mOutputWidget->value();
8912QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8915 if ( mOutputWidget )
8916 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
8920QStringList QgsProcessingOutputWidgetWrapper::compatibleParameterTypes()
const
8922 return QStringList()
8931QStringList QgsProcessingOutputWidgetWrapper::compatibleOutputTypes()
const
8933 return QStringList()
8945 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8950QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8957 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8960QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8962 return tr(
"path to layer destination" );
8970 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8975QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8982 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8985QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8987 return tr(
"path to layer destination" );
8995 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9000QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
9007 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
9010QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
9012 return tr(
"path to layer destination" );
9020 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9025QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
9032 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
9035QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
9037 return tr(
"path to layer destination" );
9045 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9050QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
9057 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
9060QStringList QgsProcessingFileDestinationWidgetWrapper::compatibleParameterTypes()
const
9062 return QStringList()
9067QStringList QgsProcessingFileDestinationWidgetWrapper::compatibleOutputTypes()
const
9077QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
9079 return tr(
"path to file destination" );
9087 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9092QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
9099 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
9102QStringList QgsProcessingFolderDestinationWidgetWrapper::compatibleParameterTypes()
const
9104 return QStringList()
9109QStringList QgsProcessingFolderDestinationWidgetWrapper::compatibleOutputTypes()
const
9117QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
9119 return tr(
"path to folder destination" );
9127 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9131QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
9138 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
9141QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
9143 return tr(
"path to layer destination" );
@ Standard
Unit is a standard measurement unit.
ProcessingSourceType
Processing data source types.
@ File
Files (i.e. non map layer sources, such as text files)
@ Annotation
Annotation layers.
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ VectorTile
Vector tile layers.
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ VectorAnyGeometry
Any vector layer with geometry.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ PointCloud
Point cloud layers.
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
@ File
Parameter is a single file.
@ Folder
Parameter is a folder.
ExpressionType
Expression types.
@ RasterCalculator
Raster calculator expression.
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
DistanceUnit
Units of distance.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ NauticalMiles
Nautical miles.
ProcessingFieldParameterDataType
Processing field parameter data types.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ Numeric
Accepts numeric fields.
@ DateTime
Accepts datetime fields.
@ SquareCentimeters
Square centimeters.
@ SquareInches
Square inches.
@ SquareNauticalMiles
Square nautical miles.
@ SquareMillimeters
Square millimeters.
@ SquareYards
Square yards.
@ SquareKilometers
Square kilometers.
@ SquareMeters
Square meters.
@ Unknown
Unknown areal unit.
@ SquareDegrees
Square degrees, for planar geographic CRS area measurements.
@ SquareMiles
Square miles.
@ Info
Information message.
@ AnnotationLayer
QgsAnnotationLayer.
TemporalUnit
Temporal units.
@ Milliseconds
Milliseconds.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
VolumeUnit
Units of volume.
@ CubicMeters
Cubic meters.
@ CubicDegrees
Cubic degrees, for planar geographic CRS volume measurements.
@ CubicDecimeter
Cubic decimeters.
@ Unknown
Unknown volume unit.
@ CubicCentimeter
Cubic Centimeters.
ProcessingModelChildParameterSource
Processing model child parameter sources.
@ ModelParameter
Parameter value is taken from a parent model parameter.
@ StaticValue
Parameter value is a static value.
@ Optional
Parameter is optional.
ProcessingDateTimeParameterDataType
Processing date time parameter data types.
@ DateTime
Datetime values.
ProcessingNumberParameterType
Processing numeric parameter data types.
@ Double
Double/float values.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
@ CapturePoint
Select and capture a point or a feature.
Selector widget for authentication configs.
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing.
QComboBox subclass which allows selecting multiple items.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Qgis::DistanceUnit mapUnits
The QgsDatabaseSchemaComboBox class is a combo box which displays the list of schemas for a specific ...
The QgsDatabaseTableComboBox class is a combo box which displays the list of tables for a specific da...
The QgsDateEdit class is a QDateEdit widget with the capability of setting/reading null dates.
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times.
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
void setNullRepresentation(const QString &null)
Sets the widget's null representation, which defaults to QgsApplication::nullRepresentation().
void valueChanged(const QDateTime &date)
Signal emitted whenever the value changes.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
@ DateTime
Datetime fields.
@ Date
Date or datetime fields.
@ Binary
Binary fields, since QGIS 3.34.
@ Boolean
Boolean fields, since QGIS 3.34.
@ Numeric
All numeric fields.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
void remove(int fieldIdx)
Removes the field with the given index.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A geometry is the spatial representation of a feature.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
A QgsFilterLineEdit subclass with the ability to "highlight" the edges of the widget.
The QgsLayoutComboBox class is a combo box which displays available layouts from a QgsLayoutManager.
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
void setAllowEmptyLayout(bool allowEmpty)
Sets whether an optional empty layout ("not set") option is present in the combobox.
The QgsLayoutItemComboBox class is a combo box which displays items of a matching type from a layout.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
Base class for graphical items within a QgsLayout.
virtual QString uuid() const
Returns the item identification string.
@ FilterPrintLayouts
Includes print layouts.
QList< QgsPrintLayout * > printLayouts() const
Returns a list of all print layouts contained in the manager.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
The QgsMapLayerComboBox class is a combo box which displays the list of layers.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
Base class for all map layer types.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Interface for master layout type objects, such as print layouts and reports.
virtual QString name() const =0
Returns the layout's name.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
bool clearWidgets()
Removes all items from the bar.
Collection of point cloud attributes.
The QgsPointCloudAttributeComboBox is a combo box which displays the list of attributes of a given po...
void attributeChanged(const QString &name)
Emitted when the currently selected attribute changes.
Attribute for point cloud data pair of name and size in bytes.
Represents a map layer supporting display of point clouds.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes available from the layer.
A class to represent a 2D point.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
Base class for all parameter definitions which represent file or layer destinations,...
Encapsulates settings relating to a feature source input to a processing algorithm.
QgsProperty source
Source definition.
WidgetType
Types of dialogs which Processing widgets can be created for.
@ Standard
Standard algorithm dialog.
@ Batch
Batch processing dialog.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for area values.
Qgis::AreaUnit defaultUnit() const
Returns the default area unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A raster band parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
A boolean parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A color parameter for processing algorithms.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
static QString typeName()
Returns the type name for the parameter class.
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
static QString typeName()
Returns the type name for the parameter class.
QVariant sourceCrs() const
Returns the static source CRS, or an invalid value if this is not set.
QVariant destinationCrs() const
Returns the static destination CRS, or an invalid value if this is not set.
A coordinate reference system parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
A database table name parameter for processing algorithms, allowing users to select from existing dat...
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
A datetime (or pure date or time) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
void setFlags(Qgis::ProcessingParameterFlags flags)
Sets the flags associated with the parameter.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
QString description() const
Returns the description for the parameter.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
virtual QString type() const =0
Unique parameter type name.
QString name() const
Returns the name of the parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
A double numeric parameter for duration values.
Qgis::TemporalUnit defaultUnit() const
Returns the default duration unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
static QString typeName()
Returns the type name for the parameter class.
An expression parameter for processing algorithms.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ExpressionType expressionType() const
Returns the parameter's expression type.
A rectangular map extent parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
An input feature source (such as vector layers) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A vector layer or feature source field parameter for processing algorithms.
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
static QString typeName()
Returns the type name for the parameter class.
A geometry parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A print layout item parameter, allowing users to select a particular item from a print layout.
static QString typeName()
Returns the type name for the parameter class.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
A print layout parameter, allowing users to select a print layout.
static QString typeName()
Returns the type name for the parameter class.
A map layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
static QString typeName()
Returns the type name for the parameter class.
A table (matrix) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
static QString typeName()
Returns the type name for the parameter class.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
double maximum() const
Returns the maximum value acceptable by the parameter.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer attribute parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A point parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A data provider connection parameter for processing algorithms, allowing users to select from availab...
static QString typeName()
Returns the type name for the parameter class.
QString providerId() const
Returns the ID of the provider associated with the connections.
A numeric range parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
A raster layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool multiLine() const
Returns true if the parameter allows multiline strings.
static QString typeName()
Returns the type name for the parameter class.
A vector layer (with or without geometry) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for volume values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::VolumeUnit defaultUnit() const
Returns the default volume unit for the parameter.
Contains settings which reflect the context in which a Processing parameter widget is shown,...
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsProject * project() const
Returns the project associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
QgsMapLayer * activeLayer() const
Returns the current active layer.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a list of map layers.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QStringList parameterAsStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of strings (e.g.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a point cloud layer.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Utility functions for use with processing classes.
@ Annotation
Annotation layer type, since QGIS 3.22.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
void layerRemoved(const QString &layerId)
Emitted after a layer was removed from the registry.
A store for object properties.
Qgis::PropertyType propertyType() const
Returns the property type.
The QgsProviderConnectionComboBox class is a combo box which displays the list of connections registe...
A combobox widget which displays the bands present in a raster layer.
void bandChanged(int band)
Emitted when the currently selected band changes.
static QString displayBandName(QgsRasterDataProvider *provider, int band)
Returns a user-friendly band name for the specified band.
Base class for raster data providers.
virtual int bandCount() const =0
Gets number of bands.
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
A rectangle specified with double values.
A QgsGeometry with associated coordinate reference system.
A class for drawing transient features (e.g.
@ ICON_X
A cross is used to highlight points (x)
This class is a composition of two QSettings instances:
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Class that shows snapping marker on map canvas for the current snapping match.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
The QgsTimeEdit class is a QTimeEdit widget with the capability of setting/reading null date/times.
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE Qgis::DistanceUnitType unitType(Qgis::DistanceUnit unit)
Returns the type for a distance unit.
static Q_INVOKABLE Qgis::AreaUnit distanceToAreaUnit(Qgis::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding area unit, e.g., meters to square meters.
static Q_INVOKABLE Qgis::VolumeUnit distanceToVolumeUnit(Qgis::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding volume unit, e.g., meters to cubic meters.
Represents a vector layer which manages a vector based data sets.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const QgsCoordinateReferenceSystem & crs