19#include "moc_qgsprocessingwidgetwrapperimpl.cpp"
81#include <QPlainTextEdit>
82#include <QRadioButton>
83#include <QButtonGroup>
97 QVBoxLayout *vlayout =
new QVBoxLayout();
98 vlayout->setContentsMargins( 0, 0, 0, 0 );
100 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
104 mDefaultCheckBox->setChecked(
false );
105 vlayout->addWidget( mDefaultCheckBox );
106 setLayout( vlayout );
111 auto param = std::make_unique< QgsProcessingParameterBoolean >( name, description, mDefaultCheckBox->isChecked() );
112 param->setFlags( flags );
113 return param.release();
123QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
129 QString description = parameterDefinition()->description();
131 description = QObject::tr(
"%1 [optional]" ).arg( description );
133 mCheckBox =
new QCheckBox( description );
134 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
136 connect( mCheckBox, &QCheckBox::toggled,
this, [ = ]
138 emit widgetValueHasChanged(
this );
146 mComboBox =
new QComboBox();
147 mComboBox->addItem( tr(
"Yes" ),
true );
148 mComboBox->addItem( tr(
"No" ),
false );
149 mComboBox->setToolTip( parameterDefinition()->toolTip() );
151 connect( mComboBox, qOverload< int>( &QComboBox::currentIndexChanged ),
this, [ = ]
153 emit widgetValueHasChanged(
this );
162QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
171void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
178 mCheckBox->setChecked( v );
186 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
192QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
197 return mCheckBox->isChecked();
201 return mComboBox->currentData();
206QStringList QgsProcessingBooleanWidgetWrapper::compatibleParameterTypes()
const
230QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes()
const
242QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
249 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
254 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
265 QVBoxLayout *vlayout =
new QVBoxLayout();
266 vlayout->setContentsMargins( 0, 0, 0, 0 );
268 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
273 mCrsSelector->setShowAccuracyWarnings(
true );
280 vlayout->addWidget( mCrsSelector );
281 setLayout( vlayout );
286 auto param = std::make_unique< QgsProcessingParameterCrs >( name, description, mCrsSelector->crs().authid() );
287 param->setFlags( flags );
288 return param.release();
297QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
299 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
301 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
310 emit widgetValueHasChanged(
this );
318 return mProjectionSelectionWidget;
323 QWidget *w =
new QWidget();
324 w->setToolTip( parameterDefinition()->toolTip() );
326 QVBoxLayout *vl =
new QVBoxLayout();
327 vl->setContentsMargins( 0, 0, 0, 0 );
330 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
331 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
332 vl->addWidget( mUseProjectCrsCheckBox );
333 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
334 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [ = ]
336 emit widgetValueHasChanged(
this );
339 vl->addWidget( mProjectionSelectionWidget );
347void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
349 if ( mUseProjectCrsCheckBox )
351 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
353 mUseProjectCrsCheckBox->setChecked(
true );
358 mUseProjectCrsCheckBox->setChecked(
false );
363 if ( mProjectionSelectionWidget )
364 mProjectionSelectionWidget->setCrs( v );
367QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
369 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
370 return QStringLiteral(
"ProjectCrs" );
371 else if ( mProjectionSelectionWidget )
372 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
377QStringList QgsProcessingCrsWidgetWrapper::compatibleParameterTypes()
const
391QStringList QgsProcessingCrsWidgetWrapper::compatibleOutputTypes()
const
400QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
402 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
405QString QgsProcessingCrsWidgetWrapper::parameterType()
const
412 return new QgsProcessingCrsWidgetWrapper( parameter, type );
417 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
430 QVBoxLayout *vlayout =
new QVBoxLayout();
431 vlayout->setContentsMargins( 0, 0, 0, 0 );
433 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
435 mDefaultLineEdit =
new QLineEdit();
438 vlayout->addWidget( mDefaultLineEdit );
440 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
442 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
443 vlayout->addWidget( mMultiLineCheckBox );
445 setLayout( vlayout );
450 auto param = std::make_unique< QgsProcessingParameterString >( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
451 param->setFlags( flags );
452 return param.release();
463QWidget *QgsProcessingStringWidgetWrapper::createWidget()
465 const QVariantMap metadata = parameterDefinition()->metadata();
466 const QVariant valueHintsVariant = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"value_hints" ) );
468 if ( valueHintsVariant.isValid() )
470 const QVariantList valueList = valueHintsVariant.toList();
471 mComboBox =
new QComboBox();
472 mComboBox->setToolTip( parameterDefinition()->toolTip() );
476 mComboBox->addItem( QString() );
478 for (
const QVariant &entry : valueList )
480 mComboBox->addItem( entry.toString(), entry.toString() );
482 mComboBox->setCurrentIndex( 0 );
484 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
486 emit widgetValueHasChanged(
this );
499 mPlainTextEdit =
new QPlainTextEdit();
500 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
502 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [ = ]
504 emit widgetValueHasChanged(
this );
506 return mPlainTextEdit;
510 mLineEdit =
new QLineEdit();
511 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
513 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
515 emit widgetValueHasChanged(
this );
523 mLineEdit =
new QLineEdit();
524 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
526 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
528 emit widgetValueHasChanged(
this );
538void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
542 mLineEdit->setText( v );
543 if ( mPlainTextEdit )
544 mPlainTextEdit->setPlainText( v );
548 if ( !value.isValid() )
549 index = mComboBox->findData( QVariant() );
551 index = mComboBox->findData( v );
554 mComboBox->setCurrentIndex( index );
556 mComboBox->setCurrentIndex( 0 );
560QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
563 return mLineEdit->text();
564 else if ( mPlainTextEdit )
565 return mPlainTextEdit->toPlainText();
566 else if ( mComboBox )
567 return mComboBox->currentData();
572QStringList QgsProcessingStringWidgetWrapper::compatibleParameterTypes()
const
590QStringList QgsProcessingStringWidgetWrapper::compatibleOutputTypes()
const
599QString QgsProcessingStringWidgetWrapper::parameterType()
const
606 return new QgsProcessingStringWidgetWrapper( parameter, type );
611 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
626QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
635 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
639 emit widgetValueHasChanged(
this );
641 return mAuthConfigSelect;
647void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
650 if ( mAuthConfigSelect )
651 mAuthConfigSelect->setConfigId( v );
654QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
656 if ( mAuthConfigSelect )
657 return mAuthConfigSelect->configId();
662QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleParameterTypes()
const
670QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleOutputTypes()
const
676QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
683 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
693 QVBoxLayout *vlayout =
new QVBoxLayout();
694 vlayout->setContentsMargins( 0, 0, 0, 0 );
696 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
698 mTypeComboBox =
new QComboBox();
701 vlayout->addWidget( mTypeComboBox );
703 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
704 mMinLineEdit =
new QLineEdit();
705 vlayout->addWidget( mMinLineEdit );
707 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
708 mMaxLineEdit =
new QLineEdit();
709 vlayout->addWidget( mMaxLineEdit );
711 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
712 mDefaultLineEdit =
new QLineEdit();
713 vlayout->addWidget( mDefaultLineEdit );
717 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( numberParam->dataType() ) ) );
719 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
721 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
725 mMaxLineEdit->clear();
728 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
730 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
734 mMinLineEdit->clear();
737 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
740 setLayout( vlayout );
749 auto param = std::make_unique< QgsProcessingParameterNumber >( name, description, dataType, ok ? val : QVariant() );
751 if ( !mMinLineEdit->text().trimmed().isEmpty() )
756 param->setMinimum( val );
760 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
765 param->setMaximum( val );
769 param->setFlags( flags );
770 return param.release();
779QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
782 const QVariantMap metadata = numberDef->
metadata();
783 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
791 QAbstractSpinBox *spinBox =
nullptr;
796 mDoubleSpinBox->setExpressionsEnabled(
true );
797 mDoubleSpinBox->setDecimals( decimals );
803 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
804 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
805 mDoubleSpinBox->setSingleStep( singleStep );
808 spinBox = mDoubleSpinBox;
813 mSpinBox->setExpressionsEnabled(
true );
817 spinBox->setToolTip( parameterDefinition()->toolTip() );
819 double max = 999999999;
824 double min = -999999999;
829 if ( mDoubleSpinBox )
831 mDoubleSpinBox->setMinimum( min );
832 mDoubleSpinBox->setMaximum( max );
836 mSpinBox->setMinimum(
static_cast< int >( min ) );
837 mSpinBox->setMaximum(
static_cast< int >( max ) );
842 mAllowingNull =
true;
843 if ( mDoubleSpinBox )
845 mDoubleSpinBox->setShowClearButton(
true );
846 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
847 mDoubleSpinBox->setMinimum( min );
848 mDoubleSpinBox->setValue( min );
852 mSpinBox->setShowClearButton(
true );
853 const int min = mSpinBox->minimum() - 1;
854 mSpinBox->setMinimum( min );
855 mSpinBox->setValue( min );
857 spinBox->setSpecialValueText( tr(
"Not set" ) );
865 if ( mDoubleSpinBox )
869 mDoubleSpinBox->setClearValue( defaultVal );
875 mSpinBox->setClearValue( intVal );
881 if ( mDoubleSpinBox )
882 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
884 mSpinBox->setClearValue(
static_cast< int >( numberDef->
minimum() ) );
889 if ( mDoubleSpinBox )
891 mDoubleSpinBox->setValue( 0 );
892 mDoubleSpinBox->setClearValue( 0 );
896 mSpinBox->setValue( 0 );
897 mSpinBox->setClearValue( 0 );
902 if ( mDoubleSpinBox )
903 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
905 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
913void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
915 if ( mDoubleSpinBox )
917 if ( mAllowingNull && !value.isValid() )
918 mDoubleSpinBox->clear();
922 mDoubleSpinBox->setValue( v );
927 if ( mAllowingNull && !value.isValid() )
932 mSpinBox->setValue( v );
937QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
939 if ( mDoubleSpinBox )
941 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
944 return mDoubleSpinBox->value();
948 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
951 return mSpinBox->value();
957QStringList QgsProcessingNumericWidgetWrapper::compatibleParameterTypes()
const
968QStringList QgsProcessingNumericWidgetWrapper::compatibleOutputTypes()
const
975double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
977 const double valueRange = maximum - minimum;
978 if ( valueRange <= 1.0 )
980 const double step = valueRange / 10.0;
982 return qgsRound( step, -std::floor( std::log( step ) ) );
990QString QgsProcessingNumericWidgetWrapper::parameterType()
const
997 return new QgsProcessingNumericWidgetWrapper( parameter, type );
1002 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1012 QVBoxLayout *vlayout =
new QVBoxLayout();
1013 vlayout->setContentsMargins( 0, 0, 0, 0 );
1015 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1017 mParentLayerComboBox =
new QComboBox();
1019 QString initialParent;
1021 initialParent = distParam->parentParameterName();
1023 if (
auto *lModel = widgetContext.
model() )
1026 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1027 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1031 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1032 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1034 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1039 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1040 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1042 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1047 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1048 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1050 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1055 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1056 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1058 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1064 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1067 mParentLayerComboBox->addItem( initialParent, initialParent );
1068 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1071 vlayout->addWidget( mParentLayerComboBox );
1073 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1074 mMinLineEdit =
new QLineEdit();
1075 vlayout->addWidget( mMinLineEdit );
1077 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1078 mMaxLineEdit =
new QLineEdit();
1079 vlayout->addWidget( mMaxLineEdit );
1081 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1082 mDefaultLineEdit =
new QLineEdit();
1083 vlayout->addWidget( mDefaultLineEdit );
1087 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
1088 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
1089 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
1092 setLayout( vlayout );
1100 auto param = std::make_unique< QgsProcessingParameterDistance >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1105 param->setMinimum( val );
1111 param->setMaximum( val );
1114 param->setFlags( flags );
1115 return param.release();
1119 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1124QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
1131 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
1134QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1138 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1143 mLabel =
new QLabel();
1144 mUnitsCombo =
new QComboBox();
1156 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1157 QHBoxLayout *layout =
new QHBoxLayout();
1158 layout->addWidget( spin, 1 );
1159 layout->insertSpacing( 1, labelMargin / 2 );
1160 layout->insertWidget( 2, mLabel );
1161 layout->insertWidget( 3, mUnitsCombo );
1166 mWarningLabel =
new QWidget();
1167 QHBoxLayout *warningLayout =
new QHBoxLayout();
1168 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1169 QLabel *warning =
new QLabel();
1171 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1172 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1173 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1174 warningLayout->insertSpacing( 0, labelMargin / 2 );
1175 warningLayout->insertWidget( 1, warning );
1176 mWarningLabel->setLayout( warningLayout );
1177 layout->insertWidget( 4, mWarningLabel );
1179 QWidget *w =
new QWidget();
1180 layout->setContentsMargins( 0, 0, 0, 0 );
1181 w->setLayout( layout );
1196void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1198 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1205 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1207 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1210 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1230 std::unique_ptr< QgsProcessingContext > tmpContext;
1231 if ( mProcessingContextGenerator )
1232 context = mProcessingContextGenerator->processingContext();
1236 tmpContext = std::make_unique< QgsProcessingContext >();
1237 context = tmpContext.get();
1256 mUnitsCombo->hide();
1261 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( units ) ) );
1262 mUnitsCombo->show();
1269QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1271 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1272 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1285 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1296 QVBoxLayout *vlayout =
new QVBoxLayout();
1297 vlayout->setContentsMargins( 0, 0, 0, 0 );
1299 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1301 mParentLayerComboBox =
new QComboBox();
1303 QString initialParent;
1305 initialParent = areaParam->parentParameterName();
1307 if (
auto *lModel = widgetContext.
model() )
1310 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1311 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1315 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1316 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1318 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1323 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1324 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1326 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1331 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1332 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1334 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1339 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1340 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1342 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1348 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1351 mParentLayerComboBox->addItem( initialParent, initialParent );
1352 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1355 vlayout->addWidget( mParentLayerComboBox );
1357 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1358 mMinLineEdit =
new QLineEdit();
1359 vlayout->addWidget( mMinLineEdit );
1361 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1362 mMaxLineEdit =
new QLineEdit();
1363 vlayout->addWidget( mMaxLineEdit );
1365 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1366 mDefaultLineEdit =
new QLineEdit();
1367 vlayout->addWidget( mDefaultLineEdit );
1371 mMinLineEdit->setText( QLocale().toString( areaParam->minimum() ) );
1372 mMaxLineEdit->setText( QLocale().toString( areaParam->maximum() ) );
1373 mDefaultLineEdit->setText( areaParam->defaultValueForGui().toString() );
1376 setLayout( vlayout );
1384 auto param = std::make_unique< QgsProcessingParameterArea >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1389 param->setMinimum( val );
1395 param->setMaximum( val );
1398 param->setFlags( flags );
1399 return param.release();
1408 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1413QString QgsProcessingAreaWidgetWrapper::parameterType()
const
1420 return new QgsProcessingAreaWidgetWrapper( parameter, type );
1423QWidget *QgsProcessingAreaWidgetWrapper::createWidget()
1427 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1432 mLabel =
new QLabel();
1433 mUnitsCombo =
new QComboBox();
1448 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1449 QHBoxLayout *layout =
new QHBoxLayout();
1450 layout->addWidget( spin, 1 );
1451 layout->insertSpacing( 1, labelMargin / 2 );
1452 layout->insertWidget( 2, mLabel );
1453 layout->insertWidget( 3, mUnitsCombo );
1458 mWarningLabel =
new QWidget();
1459 QHBoxLayout *warningLayout =
new QHBoxLayout();
1460 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1461 QLabel *warning =
new QLabel();
1463 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1464 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1465 warning->setToolTip( tr(
"Area is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1466 warningLayout->insertSpacing( 0, labelMargin / 2 );
1467 warningLayout->insertWidget( 1, warning );
1468 mWarningLabel->setLayout( warningLayout );
1469 layout->insertWidget( 4, mWarningLabel );
1471 QWidget *w =
new QWidget();
1472 layout->setContentsMargins( 0, 0, 0, 0 );
1473 w->setLayout( layout );
1488void QgsProcessingAreaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1490 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1522 std::unique_ptr< QgsProcessingContext > tmpContext;
1523 if ( mProcessingContextGenerator )
1524 context = mProcessingContextGenerator->processingContext();
1528 tmpContext = std::make_unique< QgsProcessingContext >();
1529 context = tmpContext.get();
1543void QgsProcessingAreaWidgetWrapper::setUnits(
Qgis::AreaUnit units )
1548 mUnitsCombo->hide();
1553 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1554 mUnitsCombo->show();
1561QVariant QgsProcessingAreaWidgetWrapper::widgetValue()
const
1563 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1564 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1577 return new QgsProcessingAreaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1588 QVBoxLayout *vlayout =
new QVBoxLayout();
1589 vlayout->setContentsMargins( 0, 0, 0, 0 );
1591 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1593 mParentLayerComboBox =
new QComboBox();
1595 QString initialParent;
1597 initialParent = volumeParam->parentParameterName();
1599 if (
auto *lModel = widgetContext.
model() )
1602 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1603 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1607 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1608 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1610 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1615 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1616 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1618 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1623 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1624 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1626 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1631 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1632 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1634 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1640 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1643 mParentLayerComboBox->addItem( initialParent, initialParent );
1644 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1647 vlayout->addWidget( mParentLayerComboBox );
1649 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1650 mMinLineEdit =
new QLineEdit();
1651 vlayout->addWidget( mMinLineEdit );
1653 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1654 mMaxLineEdit =
new QLineEdit();
1655 vlayout->addWidget( mMaxLineEdit );
1657 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1658 mDefaultLineEdit =
new QLineEdit();
1659 vlayout->addWidget( mDefaultLineEdit );
1663 mMinLineEdit->setText( QLocale().toString( volumeParam->minimum() ) );
1664 mMaxLineEdit->setText( QLocale().toString( volumeParam->maximum() ) );
1665 mDefaultLineEdit->setText( volumeParam->defaultValueForGui().toString() );
1668 setLayout( vlayout );
1676 auto param = std::make_unique< QgsProcessingParameterVolume >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1681 param->setMinimum( val );
1687 param->setMaximum( val );
1690 param->setFlags( flags );
1691 return param.release();
1700 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1705QString QgsProcessingVolumeWidgetWrapper::parameterType()
const
1712 return new QgsProcessingVolumeWidgetWrapper( parameter, type );
1715QWidget *QgsProcessingVolumeWidgetWrapper::createWidget()
1719 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1724 mLabel =
new QLabel();
1725 mUnitsCombo =
new QComboBox();
1738 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1739 QHBoxLayout *layout =
new QHBoxLayout();
1740 layout->addWidget( spin, 1 );
1741 layout->insertSpacing( 1, labelMargin / 2 );
1742 layout->insertWidget( 2, mLabel );
1743 layout->insertWidget( 3, mUnitsCombo );
1748 mWarningLabel =
new QWidget();
1749 QHBoxLayout *warningLayout =
new QHBoxLayout();
1750 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1751 QLabel *warning =
new QLabel();
1753 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1754 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1755 warning->setToolTip( tr(
"Volume is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1756 warningLayout->insertSpacing( 0, labelMargin / 2 );
1757 warningLayout->insertWidget( 1, warning );
1758 mWarningLabel->setLayout( warningLayout );
1759 layout->insertWidget( 4, mWarningLabel );
1761 QWidget *w =
new QWidget();
1762 layout->setContentsMargins( 0, 0, 0, 0 );
1763 w->setLayout( layout );
1778void QgsProcessingVolumeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1780 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1812 std::unique_ptr< QgsProcessingContext > tmpContext;
1813 if ( mProcessingContextGenerator )
1814 context = mProcessingContextGenerator->processingContext();
1818 tmpContext = std::make_unique< QgsProcessingContext >();
1819 context = tmpContext.get();
1838 mUnitsCombo->hide();
1843 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1844 mUnitsCombo->show();
1851QVariant QgsProcessingVolumeWidgetWrapper::widgetValue()
const
1853 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1854 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1867 return new QgsProcessingVolumeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1878 QVBoxLayout *vlayout =
new QVBoxLayout();
1879 vlayout->setContentsMargins( 0, 0, 0, 0 );
1881 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1882 mMinLineEdit =
new QLineEdit();
1883 vlayout->addWidget( mMinLineEdit );
1885 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1886 mMaxLineEdit =
new QLineEdit();
1887 vlayout->addWidget( mMaxLineEdit );
1889 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1890 mDefaultLineEdit =
new QLineEdit();
1891 vlayout->addWidget( mDefaultLineEdit );
1893 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1895 mUnitsCombo =
new QComboBox();
1905 vlayout->addWidget( mUnitsCombo );
1909 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1910 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1911 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1912 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast <int >( durationParam->defaultUnit() ) ) );
1915 setLayout( vlayout );
1923 auto param = std::make_unique< QgsProcessingParameterDuration >( name, description, ok ? val : QVariant() );
1928 param->setMinimum( val );
1934 param->setMaximum( val );
1937 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit >( mUnitsCombo->currentData().toInt() ) );
1939 param->setFlags( flags );
1940 return param.release();
1944 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1949QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1956 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1959QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1963 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1968 mUnitsCombo =
new QComboBox();
1980 QHBoxLayout *layout =
new QHBoxLayout();
1981 layout->addWidget( spin, 1 );
1982 layout->insertWidget( 1, mUnitsCombo );
1984 QWidget *w =
new QWidget();
1985 layout->setContentsMargins( 0, 0, 0, 0 );
1986 w->setLayout( layout );
1988 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( durationDef->
defaultUnit() ) ) );
1989 mUnitsCombo->show();
2002QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
2014QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
2016 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
2017 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo )
2028void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2034 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
2038 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
2044 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2054 QVBoxLayout *vlayout =
new QVBoxLayout();
2055 vlayout->setContentsMargins( 0, 0, 0, 0 );
2057 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2059 mDefaultLineEdit =
new QLineEdit();
2063 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
2066 vlayout->addWidget( mDefaultLineEdit );
2068 setLayout( vlayout );
2074 double val = mDefaultLineEdit->text().toDouble( &ok );
2075 auto param = std::make_unique< QgsProcessingParameterScale >( name, description, ok ? val : QVariant() );
2077 return param.release();
2081 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
2086QString QgsProcessingScaleWidgetWrapper::parameterType()
const
2093 return new QgsProcessingScaleWidgetWrapper( parameter, type );
2096QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
2108 mScaleWidget->setAllowNull(
true );
2110 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
2111 mScaleWidget->setShowCurrentScaleButton(
true );
2113 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
2116 emit widgetValueHasChanged(
this );
2118 return mScaleWidget;
2127 mScaleWidget->setMapCanvas( context.
mapCanvas() );
2132QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
2134 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
2137void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2141 if ( mScaleWidget->allowNull() && !value.isValid() )
2142 mScaleWidget->setNull();
2146 mScaleWidget->setScale( v );
2153 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2164 QVBoxLayout *vlayout =
new QVBoxLayout();
2165 vlayout->setContentsMargins( 0, 0, 0, 0 );
2167 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
2169 mTypeComboBox =
new QComboBox();
2172 vlayout->addWidget( mTypeComboBox );
2174 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
2175 mMinLineEdit =
new QLineEdit();
2176 vlayout->addWidget( mMinLineEdit );
2178 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
2179 mMaxLineEdit =
new QLineEdit();
2180 vlayout->addWidget( mMaxLineEdit );
2184 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( rangeParam->dataType() ) ) );
2186 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
2187 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
2190 setLayout( vlayout );
2195 QString defaultValue;
2196 if ( mMinLineEdit->text().isEmpty() )
2198 defaultValue = QStringLiteral(
"None" );
2206 defaultValue = QStringLiteral(
"None" );
2210 if ( mMaxLineEdit->text().isEmpty() )
2212 defaultValue += QLatin1String(
",None" );
2218 defaultValue += QStringLiteral(
",%1" ).arg( ok ? QString::number( val ) : QLatin1String(
"None" ) );
2222 auto param = std::make_unique< QgsProcessingParameterRange >( name, description, dataType, defaultValue );
2223 param->setFlags( flags );
2224 return param.release();
2234QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
2243 QHBoxLayout *layout =
new QHBoxLayout();
2248 mMinSpinBox->setExpressionsEnabled(
true );
2249 mMinSpinBox->setShowClearButton(
false );
2250 mMaxSpinBox->setExpressionsEnabled(
true );
2251 mMaxSpinBox->setShowClearButton(
false );
2253 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
2254 layout->addWidget( minLabel );
2255 layout->addWidget( mMinSpinBox, 1 );
2257 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
2258 layout->addWidget( maxLabel );
2259 layout->addWidget( mMaxSpinBox, 1 );
2261 QWidget *w =
new QWidget();
2262 layout->setContentsMargins( 0, 0, 0, 0 );
2263 w->setLayout( layout );
2267 mMinSpinBox->setDecimals( 6 );
2268 mMaxSpinBox->setDecimals( 6 );
2272 mMinSpinBox->setDecimals( 0 );
2273 mMaxSpinBox->setDecimals( 0 );
2276 mMinSpinBox->setMinimum( -99999999.999999 );
2277 mMaxSpinBox->setMinimum( -99999999.999999 );
2278 mMinSpinBox->setMaximum( 99999999.999999 );
2279 mMaxSpinBox->setMaximum( 99999999.999999 );
2283 mAllowingNull =
true;
2285 const double min = mMinSpinBox->minimum() - 1;
2286 mMinSpinBox->setMinimum( min );
2287 mMaxSpinBox->setMinimum( min );
2288 mMinSpinBox->setValue( min );
2289 mMaxSpinBox->setValue( min );
2291 mMinSpinBox->setShowClearButton(
true );
2292 mMaxSpinBox->setShowClearButton(
true );
2293 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
2294 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
2297 w->setToolTip( parameterDefinition()->toolTip() );
2299 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
2301 mBlockChangedSignal++;
2302 if ( !mAllowingNull && v > mMaxSpinBox->value() )
2303 mMaxSpinBox->setValue( v );
2304 mBlockChangedSignal--;
2306 if ( !mBlockChangedSignal )
2307 emit widgetValueHasChanged(
this );
2309 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
2311 mBlockChangedSignal++;
2312 if ( !mAllowingNull && v < mMinSpinBox->value() )
2313 mMinSpinBox->setValue( v );
2314 mBlockChangedSignal--;
2316 if ( !mBlockChangedSignal )
2317 emit widgetValueHasChanged(
this );
2326void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2329 if ( mAllowingNull && v.empty() )
2331 mMinSpinBox->clear();
2332 mMaxSpinBox->clear();
2339 if ( mAllowingNull )
2341 mBlockChangedSignal++;
2342 if ( std::isnan( v.at( 0 ) ) )
2343 mMinSpinBox->clear();
2345 mMinSpinBox->setValue( v.at( 0 ) );
2347 if ( v.count() >= 2 )
2349 if ( std::isnan( v.at( 1 ) ) )
2350 mMaxSpinBox->clear();
2352 mMaxSpinBox->setValue( v.at( 1 ) );
2354 mBlockChangedSignal--;
2358 mBlockChangedSignal++;
2359 mMinSpinBox->setValue( v.at( 0 ) );
2360 if ( v.count() >= 2 )
2361 mMaxSpinBox->setValue( v.at( 1 ) );
2362 mBlockChangedSignal--;
2366 if ( !mBlockChangedSignal )
2367 emit widgetValueHasChanged(
this );
2370QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
2372 if ( mAllowingNull )
2375 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
2376 value = QStringLiteral(
"None" );
2378 value = QString::number( mMinSpinBox->value() );
2380 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
2381 value += QLatin1String(
",None" );
2383 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
2388 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
2391QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
const
2393 return QStringList()
2398QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
const
2404QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
2406 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
2409QString QgsProcessingRangeWidgetWrapper::parameterType()
const
2416 return new QgsProcessingRangeWidgetWrapper( parameter, type );
2421 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2432 QVBoxLayout *vlayout =
new QVBoxLayout();
2433 vlayout->setContentsMargins( 0, 0, 0, 0 );
2435 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
2438 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
2439 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
2441 vlayout->addWidget( mMatrixWidget );
2442 setLayout( vlayout );
2447 auto param = std::make_unique< QgsProcessingParameterMatrix >( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
2448 param->setFlags( flags );
2449 return param.release();
2459QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
2461 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast< const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
2462 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
2464 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [ = ]
2466 emit widgetValueHasChanged(
this );
2475 return mMatrixWidget;
2481void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2484 if ( mMatrixWidget )
2485 mMatrixWidget->setValue( v );
2488QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
2490 if ( mMatrixWidget )
2491 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
2496QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
const
2498 return QStringList()
2502QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
const
2504 return QStringList();
2507QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
2509 return tr(
"comma delimited string of values, or an array of values" );
2512QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
2519 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
2524 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2536 QVBoxLayout *vlayout =
new QVBoxLayout();
2537 vlayout->setContentsMargins( 0, 0, 0, 0 );
2539 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
2541 mTypeComboBox =
new QComboBox();
2545 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( fileParam->behavior() ) ) );
2547 mTypeComboBox->setCurrentIndex( 0 );
2548 vlayout->addWidget( mTypeComboBox );
2550 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
2552 mFilterComboBox =
new QComboBox();
2553 mFilterComboBox->setEditable(
true );
2555 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
2556 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
2557 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
2558 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
2560 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
2562 mFilterComboBox->setCurrentIndex( 0 );
2563 vlayout->addWidget( mFilterComboBox );
2565 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2568 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
2572 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
2576 vlayout->addWidget( mDefaultFileWidget );
2578 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ]
2587 setLayout( vlayout );
2592 auto param = std::make_unique< QgsProcessingParameterFile >( name, description );
2595 param->setFileFilter( mFilterComboBox->currentText() );
2596 if ( !mDefaultFileWidget->filePath().isEmpty() )
2597 param->setDefaultValue( mDefaultFileWidget->filePath() );
2598 param->setFlags( flags );
2599 return param.release();
2609QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2619 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2620 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2622 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
2629 mFileWidget->setFilter( fileParam->
fileFilter() );
2630 else if ( !fileParam->
extension().isEmpty() )
2631 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
2641 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
2642 emit widgetValueHasChanged(
this );
2650void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2654 mFileWidget->setFilePath( v );
2657QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2660 return mFileWidget->filePath();
2665QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
const
2667 return QStringList()
2672QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
const
2683QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2685 return tr(
"string representing a path to a file or folder" );
2688QString QgsProcessingFileWidgetWrapper::parameterType()
const
2695 return new QgsProcessingFileWidgetWrapper( parameter, type );
2700 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2712 QVBoxLayout *vlayout =
new QVBoxLayout();
2713 vlayout->setContentsMargins( 0, 0, 0, 0 );
2714 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2717 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2719 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2720 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2722 QStackedWidget *stackedWidget =
new QStackedWidget();
2723 stackedWidget->addWidget( mDefaultQgisLineEdit );
2724 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2725 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2726 vlayout->addWidget( stackedWidget );
2731 mDefaultQgisLineEdit->setExpression( expr );
2732 mDefaultPointCloudLineEdit->setExpression( expr );
2735 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2737 mParentLayerComboBox =
new QComboBox();
2738 vlayout->addWidget( mParentLayerComboBox );
2740 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2741 mExpressionTypeComboBox =
new QComboBox();
2746 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2748 mParentLayerComboBox->clear();
2749 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2751 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2753 QString initialParent;
2755 initialParent = expParam->parentLayerParameterName();
2759 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2762 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2763 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2770 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2771 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2773 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2778 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2779 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2781 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2788 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2789 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2791 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2802 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2803 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2805 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2813 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2816 mParentLayerComboBox->addItem( initialParent, initialParent );
2817 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2822 mExpressionTypeComboBox->setCurrentIndex( -1 );
2824 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast< int >( expParam->expressionType() ) ) );
2826 mExpressionTypeComboBox->setCurrentIndex( 0 );
2828 vlayout->addWidget( mExpressionTypeComboBox );
2830 setLayout( vlayout );
2837 switch ( expressionType )
2840 expression = mDefaultQgisLineEdit->expression();
2843 expression = mDefaultPointCloudLineEdit->expression();
2846 expression = mDefaultRasterCalculatorLineEdit->expression();
2849 auto param = std::make_unique< QgsProcessingParameterExpression >( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2850 param->setFlags( flags );
2851 return param.release();
2860QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2872 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2873 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2874 mExpLineEdit->registerExpressionContextGenerator(
this );
2877 emit widgetValueHasChanged(
this );
2879 return mExpLineEdit;
2885 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2886 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2887 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2889 emit widgetValueHasChanged(
this );
2891 return mPointCloudExpLineEdit;
2896 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2897 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2900 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2902 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2904 emit widgetValueHasChanged(
this );
2906 return mRasterCalculatorExpLineEdit;
2910 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
2913 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2914 mExpBuilderWidget->init( createExpressionContext() );
2917 Q_UNUSED( changed );
2918 emit widgetValueHasChanged(
this );
2920 return mExpBuilderWidget;
2925 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2926 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2927 mFieldExpWidget->registerExpressionContextGenerator(
this );
2929 mFieldExpWidget->setAllowEmptyFieldName(
true );
2933 emit widgetValueHasChanged(
this );
2935 return mFieldExpWidget;
2943void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2955 setParentLayerWrapperValue( wrapper );
2958 setParentLayerWrapperValue( wrapper );
2974 if ( mExpBuilderWidget )
2977 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2985 std::unique_ptr< QgsProcessingContext > tmpContext;
2986 if ( mProcessingContextGenerator )
2987 context = mProcessingContextGenerator->processingContext();
2991 tmpContext = std::make_unique< QgsProcessingContext >();
2992 context = tmpContext.get();
3002 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3012 if ( mFieldExpWidget )
3013 mFieldExpWidget->setLayer(
nullptr );
3014 else if ( mExpBuilderWidget )
3015 mExpBuilderWidget->setLayer(
nullptr );
3016 else if ( mExpLineEdit )
3017 mExpLineEdit->setLayer(
nullptr );
3023 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
3026 mParentLayer.reset( ownedLayer.release() );
3034 if ( mFieldExpWidget )
3035 mFieldExpWidget->setLayer( layer );
3036 if ( mExpBuilderWidget )
3037 mExpBuilderWidget->setLayer( layer );
3038 else if ( mExpLineEdit )
3039 mExpLineEdit->setLayer( layer );
3048 if ( mPointCloudExpLineEdit )
3049 mPointCloudExpLineEdit->setLayer(
nullptr );
3055 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
3058 mParentLayer.reset( ownedLayer.release() );
3066 if ( mPointCloudExpLineEdit )
3067 mPointCloudExpLineEdit->setLayer( layer );
3074 if ( layers.isEmpty() )
3076 if ( mRasterCalculatorExpLineEdit )
3078 mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
3083 if ( mRasterCalculatorExpLineEdit )
3085 QVariantList layersList;
3088 layersList << layer->
name();
3090 mRasterCalculatorExpLineEdit->setLayers( layersList );
3098void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3101 if ( mFieldExpWidget )
3102 mFieldExpWidget->setExpression( v );
3103 else if ( mExpBuilderWidget )
3104 mExpBuilderWidget->setExpressionText( v );
3105 else if ( mExpLineEdit )
3106 mExpLineEdit->setExpression( v );
3107 else if ( mPointCloudExpLineEdit )
3108 mPointCloudExpLineEdit->setExpression( v );
3109 else if ( mRasterCalculatorExpLineEdit )
3110 mRasterCalculatorExpLineEdit->setExpression( v );
3113QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
3115 if ( mFieldExpWidget )
3116 return mFieldExpWidget->expression();
3117 if ( mExpBuilderWidget )
3118 return mExpBuilderWidget->expressionText();
3119 else if ( mExpLineEdit )
3120 return mExpLineEdit->expression();
3121 else if ( mPointCloudExpLineEdit )
3122 return mPointCloudExpLineEdit->expression();
3123 else if ( mRasterCalculatorExpLineEdit )
3124 return mRasterCalculatorExpLineEdit->expression();
3129QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
const
3131 return QStringList()
3142QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
const
3144 return QStringList()
3150QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
3152 return tr(
"string representation of an expression" );
3155const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
3157 if ( mFieldExpWidget && mFieldExpWidget->layer() )
3158 return mFieldExpWidget->layer();
3160 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
3161 return mExpBuilderWidget->layer();
3166QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
3173 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
3178 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3191 QHBoxLayout *hl =
new QHBoxLayout();
3192 hl->setContentsMargins( 0, 0, 0, 0 );
3194 mLineEdit =
new QLineEdit();
3195 mLineEdit->setEnabled(
false );
3196 hl->addWidget( mLineEdit, 1 );
3198 mToolButton =
new QToolButton();
3199 mToolButton->setText( QString( QChar( 0x2026 ) ) );
3200 hl->addWidget( mToolButton );
3206 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3209 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
3212void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
3214 if ( value.isValid() )
3216 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3218 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
3224 updateSummaryText();
3228void QgsProcessingEnumPanelWidget::showDialog()
3230 QVariantList availableOptions;
3233 availableOptions.reserve( mParam->options().size() );
3235 if ( mParam->usesStaticStrings() )
3237 for ( QString o : mParam->options() )
3239 availableOptions << o;
3244 for (
int i = 0; i < mParam->options().count(); ++i )
3245 availableOptions << i;
3249 const QStringList options = mParam ? mParam->options() : QStringList();
3253 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3254 widget->setPanelTitle( mParam->description() );
3256 if ( mParam->usesStaticStrings() )
3258 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
3260 const QString i = v.toString();
3261 return options.contains( i ) ? i : QString();
3266 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
3268 const int i = v.toInt();
3269 return options.size() > i ? options.at( i ) : QString();
3273 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
3275 setValue( widget->selectedOptions() );
3282 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3284 dlg.setValueFormatter( [options](
const QVariant & v ) -> QString
3286 const int i = v.toInt();
3287 return options.size() > i ? options.at( i ) : QString();
3291 setValue( dlg.selectedOptions() );
3296void QgsProcessingEnumPanelWidget::updateSummaryText()
3301 if ( mValue.empty() )
3303 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3308 values.reserve( mValue.size() );
3309 if ( mParam->usesStaticStrings() )
3311 for (
const QVariant &val : std::as_const( mValue ) )
3313 values << val.toString();
3318 const QStringList options = mParam->options();
3319 for (
const QVariant &val : std::as_const( mValue ) )
3321 const int i = val.toInt();
3322 values << ( options.size() > i ? options.at( i ) : QString() );
3326 const QString concatenated = values.join( tr(
"," ) );
3327 if ( concatenated.length() < 100 )
3328 mLineEdit->setText( concatenated );
3330 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
3338QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
3341 , mButtonGroup( new QButtonGroup( this ) )
3342 , mColumns( columns )
3344 mButtonGroup->setExclusive( !mParam->allowMultiple() );
3346 QGridLayout *l =
new QGridLayout();
3347 l->setContentsMargins( 0, 0, 0, 0 );
3349 int rows =
static_cast< int >( std::ceil( mParam->options().count() /
static_cast< double >( mColumns ) ) );
3350 for (
int i = 0; i < mParam->options().count(); ++i )
3352 QAbstractButton *button =
nullptr;
3353 if ( mParam->allowMultiple() )
3354 button =
new QCheckBox( mParam->options().at( i ) );
3356 button =
new QRadioButton( mParam->options().at( i ) );
3358 connect( button, &QAbstractButton::toggled,
this, [ = ]
3360 if ( !mBlockChangedSignal )
3364 mButtons.insert( i, button );
3366 mButtonGroup->addButton( button, i );
3367 l->addWidget( button, i % rows, i / rows );
3369 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
3372 if ( mParam->allowMultiple() )
3374 setContextMenuPolicy( Qt::CustomContextMenu );
3375 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
3379QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
3381 if ( mParam->allowMultiple() )
3384 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3386 if ( it.value()->isChecked() )
3387 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
3393 if ( mParam->usesStaticStrings() )
3394 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
3396 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
3400void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
3402 mBlockChangedSignal =
true;
3403 if ( mParam->allowMultiple() )
3405 QVariantList selected;
3406 if ( value.isValid() )
3407 selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3408 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3410 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
3411 it.value()->setChecked( selected.contains( v ) );
3417 if ( v.userType() == QMetaType::Type::QVariantList )
3418 v = v.toList().value( 0 );
3420 v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
3421 if ( mButtons.contains( v ) )
3422 mButtons.value( v )->setChecked(
true );
3424 mBlockChangedSignal =
false;
3428void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
3431 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
3432 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
3433 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
3434 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
3435 popupMenu.addAction( selectAllAction );
3436 popupMenu.addAction( clearAllAction );
3437 popupMenu.exec( QCursor::pos() );
3440void QgsProcessingEnumCheckboxPanelWidget::selectAll()
3442 mBlockChangedSignal =
true;
3443 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3444 it.value()->setChecked(
true );
3445 mBlockChangedSignal =
false;
3449void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
3451 mBlockChangedSignal =
true;
3452 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3453 it.value()->setChecked(
false );
3454 mBlockChangedSignal =
false;
3466 QVBoxLayout *vlayout =
new QVBoxLayout();
3467 vlayout->setContentsMargins( 0, 0, 0, 0 );
3469 mEnumWidget =
new QgsProcessingEnumModelerWidget();
3472 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
3473 mEnumWidget->setOptions( enumParam->options() );
3474 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
3476 vlayout->addWidget( mEnumWidget );
3477 setLayout( vlayout );
3482 auto param = std::make_unique< QgsProcessingParameterEnum >( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
3484 return param.release();
3494QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
3502 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
3504 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
3505 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
3506 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
3507 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [ = ]
3509 emit widgetValueHasChanged(
this );
3511 return mCheckboxPanel;
3520 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
3521 mPanel->setToolTip( parameterDefinition()->toolTip() );
3522 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [ = ]
3524 emit widgetValueHasChanged(
this );
3530 mComboBox =
new QComboBox();
3533 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
3534 const QStringList options = expParam->
options();
3535 const QVariantList iconList = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"icons" ) ).toList();
3536 for (
int i = 0; i < options.count(); ++i )
3538 const QIcon icon = iconList.value( i ).value< QIcon >();
3541 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
3543 mComboBox->addItem( icon, options.at( i ), i );
3546 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3547 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
3548 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
3550 emit widgetValueHasChanged(
this );
3559void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3563 if ( !value.isValid() )
3564 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
3571 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3576 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3580 else if ( mPanel || mCheckboxPanel )
3583 if ( value.isValid() )
3589 opts.reserve( v.size() );
3590 for ( QString i : v )
3596 opts.reserve( v.size() );
3602 mPanel->setValue( opts );
3603 else if ( mCheckboxPanel )
3604 mCheckboxPanel->setValue( opts );
3608QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3611 return mComboBox->currentData();
3613 return mPanel->value();
3614 else if ( mCheckboxPanel )
3615 return mCheckboxPanel->value();
3620QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
const
3622 return QStringList()
3628QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
const
3630 return QStringList()
3636QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3638 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3641QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3648 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3653 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3666QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3675 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() : nullptr );
3680 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3683 emit widgetValueHasChanged(
this );
3690 mPlainComboBox =
new QComboBox();
3691 mPlainComboBox->setEditable(
true );
3692 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3693 if ( widgetContext().project() )
3697 mPlainComboBox->addItem( layout->name() );
3700 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
3702 emit widgetValueHasChanged(
this );
3704 return mPlainComboBox;
3710void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3714 if ( !value.isValid() )
3715 mComboBox->setCurrentLayout(
nullptr );
3719 mComboBox->setCurrentLayout( l );
3721 mComboBox->setCurrentLayout(
nullptr );
3724 else if ( mPlainComboBox )
3727 mPlainComboBox->setCurrentText( v );
3731QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3736 return l ? l->
name() : QVariant();
3738 else if ( mPlainComboBox )
3739 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3747 if ( mPlainComboBox && context.
project() )
3751 mPlainComboBox->addItem( layout->name() );
3755QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
const
3757 return QStringList()
3762QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
const
3764 return QStringList()
3769QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3771 return tr(
"string representing the name of an existing print layout" );
3774QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3781 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3795 QVBoxLayout *vlayout =
new QVBoxLayout();
3796 vlayout->setContentsMargins( 0, 0, 0, 0 );
3798 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3800 mParentLayoutComboBox =
new QComboBox();
3801 QString initialParent;
3803 initialParent = itemParam->parentLayoutParameterName();
3805 if (
auto *lModel = widgetContext.
model() )
3808 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3809 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3813 mParentLayoutComboBox-> addItem( definition->
description(), definition->
name() );
3814 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3816 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3822 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3825 mParentLayoutComboBox->addItem( initialParent, initialParent );
3826 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3829 vlayout->addWidget( mParentLayoutComboBox );
3830 setLayout( vlayout );
3834 auto param = std::make_unique< QgsProcessingParameterLayoutItem >( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3836 return param.release();
3846QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3857 mComboBox->setAllowEmptyItem(
true );
3858 if ( layoutParam->
itemType() >= 0 )
3861 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3864 emit widgetValueHasChanged(
this );
3871 mLineEdit =
new QLineEdit();
3872 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3873 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3875 emit widgetValueHasChanged(
this );
3883void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3911void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3917 std::unique_ptr< QgsProcessingContext > tmpContext;
3918 if ( mProcessingContextGenerator )
3919 context = mProcessingContextGenerator->processingContext();
3923 tmpContext = std::make_unique< QgsProcessingContext >();
3924 context = tmpContext.get();
3928 setLayout( layout );
3931void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3934 mComboBox->setCurrentLayout( layout );
3937void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3941 if ( !value.isValid() )
3942 mComboBox->setItem(
nullptr );
3946 mComboBox->setItem( item );
3949 else if ( mLineEdit )
3952 mLineEdit->setText( v );
3956QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3961 return i ? i->
uuid() : QVariant();
3963 else if ( mLineEdit )
3964 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3969QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
const
3971 return QStringList()
3976QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
const
3978 return QStringList()
3983QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3985 return tr(
"string representing the UUID or ID of an existing print layout item" );
3988QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3995 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
4000 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4007QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
4014QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
4016void QgsProcessingPointMapTool::deactivate()
4030 if ( e->button() == Qt::LeftButton )
4033 emit clicked( point );
4038void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
4040 if ( e->key() == Qt::Key_Escape )
4055QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
4058 QHBoxLayout *l =
new QHBoxLayout();
4059 l->setContentsMargins( 0, 0, 0, 0 );
4061 mLineEdit->setShowClearButton(
false );
4062 l->addWidget( mLineEdit, 1 );
4063 mButton =
new QToolButton();
4064 mButton->setText( QString( QChar( 0x2026 ) ) );
4065 l->addWidget( mButton );
4068 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
4069 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::textChanged );
4070 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
4071 mButton->setVisible(
false );
4074void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
4077 if ( mAllowSelectOnCanvas )
4079 mButton->setVisible(
true );
4082 mTool = std::make_unique< QgsProcessingPointMapTool >( mCanvas );
4083 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
4084 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
4088void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
4090 mLineEdit->setShowClearButton( allowNull );
4093void QgsProcessingPointPanel::setShowPointOnCanvas(
bool show )
4095 if ( mShowPointOnCanvas == show )
4098 mShowPointOnCanvas = show;
4099 if ( mShowPointOnCanvas )
4105 mMapPointRubberBand.reset();
4109void QgsProcessingPointPanel::setAllowSelectOnCanvas(
bool allow )
4111 mAllowSelectOnCanvas = allow;
4112 mButton->setVisible( mAllowSelectOnCanvas &&
static_cast< bool >( mTool ) );
4115QVariant QgsProcessingPointPanel::value()
const
4117 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
4120void QgsProcessingPointPanel::clear()
4128 QString newText = QStringLiteral(
"%1,%2" )
4129 .arg( QString::number( point.
x(),
'f' ),
4130 QString::number( point.
y(),
'f' ) );
4133 if ( mCrs.isValid() )
4135 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
4137 mLineEdit->setText( newText );
4141void QgsProcessingPointPanel::showEvent( QShowEvent * )
4146 if ( QWidget *parentWindow = window() )
4148 setAllowSelectOnCanvas( !parentWindow->isModal() );
4154void QgsProcessingPointPanel::selectOnCanvas()
4159 mPrevTool = mCanvas->mapTool();
4160 mCanvas->setMapTool( mTool.get() );
4162 emit toggleDialogVisibility(
false );
4165void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
4167 setValue( point, mCanvas->mapSettings().destinationCrs() );
4170void QgsProcessingPointPanel::pointPicked()
4175 mCanvas->setMapTool( mPrevTool );
4177 emit toggleDialogVisibility(
true );
4180void QgsProcessingPointPanel::textChanged(
const QString &text )
4182 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
4184 const QRegularExpressionMatch match = rx.match( text );
4185 if ( match.hasMatch() )
4188 const double x = match.captured( 1 ).toDouble( &xOk );
4190 const double y = match.captured( 2 ).toDouble( &yOk );
4197 if ( pointCrs.isValid() )
4215void QgsProcessingPointPanel::updateRubberBand()
4217 if ( !mShowPointOnCanvas || !mCanvas )
4220 if ( mPoint.isEmpty() )
4222 mMapPointRubberBand.reset();
4226 if ( !mMapPointRubberBand )
4229 mMapPointRubberBand->setZValue( 1000 );
4232 const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
4233 mMapPointRubberBand->setWidth( scaleFactor );
4234 mMapPointRubberBand->setIconSize( scaleFactor * 5 );
4236 mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
4237 mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
4251 QVBoxLayout *vlayout =
new QVBoxLayout();
4252 vlayout->setContentsMargins( 0, 0, 0, 0 );
4254 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4256 mDefaultLineEdit =
new QLineEdit();
4257 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4258 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
4262 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
4265 vlayout->addWidget( mDefaultLineEdit );
4266 setLayout( vlayout );
4271 auto param = std::make_unique< QgsProcessingParameterPoint >( name, description, mDefaultLineEdit->text() );
4273 return param.release();
4282QWidget *QgsProcessingPointWidgetWrapper::createWidget()
4290 mPanel =
new QgsProcessingPointPanel(
nullptr );
4291 if ( widgetContext().mapCanvas() )
4292 mPanel->setMapCanvas( widgetContext().mapCanvas() );
4295 mPanel->setAllowNull(
true );
4298 mPanel->setShowPointOnCanvas(
true );
4300 mPanel->setToolTip( parameterDefinition()->toolTip() );
4302 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [ = ]
4304 emit widgetValueHasChanged(
this );
4308 setDialog( mDialog );
4314 mLineEdit =
new QLineEdit();
4315 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4316 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
4318 emit widgetValueHasChanged(
this );
4330 mPanel->setMapCanvas( context.
mapCanvas() );
4333void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
4338 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ](
bool visible )
4341 mDialog->showMinimized();
4344 mDialog->showNormal();
4346 mDialog->activateWindow();
4353void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4357 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
4363 mPanel->setValue( p,
crs );
4366 else if ( mLineEdit )
4369 mLineEdit->setText( v );
4373QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
4377 return mPanel->value();
4379 else if ( mLineEdit )
4380 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
4385QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
const
4387 return QStringList()
4392QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
const
4394 return QStringList()
4399QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
4401 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
4404QString QgsProcessingPointWidgetWrapper::parameterType()
const
4411 return new QgsProcessingPointWidgetWrapper( parameter, type );
4416 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4428 QVBoxLayout *vlayout =
new QVBoxLayout();
4429 vlayout->setContentsMargins( 0, 0, 0, 0 );
4431 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4443 vlayout->addWidget( mGeometryWidget );
4444 setLayout( vlayout );
4450 auto param = std::make_unique< QgsProcessingParameterGeometry >( name, description, geometry.
isEmpty() ? QVariant() : geometry.asWkt() );
4452 return param.release();
4461QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
4470 mGeometryWidget->setToolTip( parameterDefinition()->toolTip() );
4473 emit widgetValueHasChanged(
this );
4475 return mGeometryWidget;
4481void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4483 if ( mGeometryWidget )
4492 mGeometryWidget->clearGeometry();
4497QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
4499 if ( mGeometryWidget )
4502 return geometry.
isEmpty() ? QVariant() : geometry.asWkt();
4510QStringList QgsProcessingGeometryWidgetWrapper::compatibleParameterTypes()
const
4512 return QStringList()
4519QStringList QgsProcessingGeometryWidgetWrapper::compatibleOutputTypes()
const
4521 return QStringList()
4526QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
4528 return tr(
"string in the Well-Known-Text format or a geometry value" );
4531QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
4538 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
4543 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4555 QVBoxLayout *vlayout =
new QVBoxLayout();
4556 vlayout->setContentsMargins( 0, 0, 0, 0 );
4558 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4561 mDefaultColorButton->setShowNull(
true );
4562 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
4568 mDefaultColorButton->setToNull();
4570 mDefaultColorButton->setColor(
c );
4571 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
4575 mDefaultColorButton->setToNull();
4576 mAllowOpacity->setChecked(
true );
4579 vlayout->addWidget( mDefaultColorButton );
4580 vlayout->addWidget( mAllowOpacity );
4581 setLayout( vlayout );
4586 auto param = std::make_unique< QgsProcessingParameterColor >( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
4588 return param.release();
4597QWidget *QgsProcessingColorWidgetWrapper::createWidget()
4607 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
4610 mColorButton->setShowNull(
true );
4613 mColorButton->setToolTip( parameterDefinition()->toolTip() );
4614 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
4622 emit widgetValueHasChanged(
this );
4625 return mColorButton;
4631void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4635 if ( !value.isValid() ||
4636 ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() )
4637 || ( value.userType() == QMetaType::Type::QColor && !value.value< QColor >().isValid() ) )
4638 mColorButton->setToNull();
4642 if ( !
c.isValid() && mColorButton->showNull() )
4643 mColorButton->setToNull();
4645 mColorButton->setColor(
c );
4650QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
4653 return mColorButton->isNull() ? QVariant() : mColorButton->color();
4658QStringList QgsProcessingColorWidgetWrapper::compatibleParameterTypes()
const
4660 return QStringList()
4665QStringList QgsProcessingColorWidgetWrapper::compatibleOutputTypes()
const
4667 return QStringList()
4672QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
4674 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
4677QString QgsProcessingColorWidgetWrapper::parameterType()
const
4684 return new QgsProcessingColorWidgetWrapper( parameter, type );
4689 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4700 QVBoxLayout *vlayout =
new QVBoxLayout();
4701 vlayout->setContentsMargins( 0, 0, 0, 0 );
4703 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4705 mDefaultLineEdit =
new QLineEdit();
4708 vlayout->addWidget( mDefaultLineEdit );
4710 mSourceParamComboBox =
new QComboBox();
4711 mDestParamComboBox =
new QComboBox();
4712 QString initialSource;
4713 QString initialDest;
4718 initialSource = itemParam->sourceCrsParameterName();
4719 initialDest = itemParam->destinationCrsParameterName();
4724 mSourceParamComboBox->addItem( QString(), QString() );
4725 mDestParamComboBox->addItem( QString(), QString() );
4726 if (
auto *lModel = widgetContext.
model() )
4729 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4730 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4732 if ( definition && it->parameterName() == definition->
name() )
4736 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4737 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4738 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4740 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4742 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4744 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4749 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4752 mSourceParamComboBox->addItem( initialSource, initialSource );
4753 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4755 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4758 mDestParamComboBox->addItem( initialDest, initialDest );
4759 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4762 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4763 vlayout->addWidget( mSourceParamComboBox );
4764 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4765 vlayout->addWidget( mDestParamComboBox );
4769 mStaticSourceWidget->setCrs( sourceCrs );
4772 mStaticDestWidget->setCrs( destCrs );
4774 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4775 vlayout->addWidget( mStaticSourceWidget );
4776 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4777 vlayout->addWidget( mStaticDestWidget );
4779 setLayout( vlayout );
4784 auto param = std::make_unique< QgsProcessingParameterCoordinateOperation >( name, description, mDefaultLineEdit->text(),
4785 mSourceParamComboBox->currentText(),
4786 mDestParamComboBox->currentText(),
4787 mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
4788 mStaticDestWidget->
crs().isValid() ? QVariant::fromValue( mStaticDestWidget->
crs() ) : QVariant() );
4790 return param.release();
4799QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4810 mOperationWidget->setShowMakeDefault(
false );
4811 mOperationWidget->setShowFallbackOption(
false );
4812 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4813 mOperationWidget->setSourceCrs( mSourceCrs );
4814 mOperationWidget->setDestinationCrs( mDestCrs );
4815 mOperationWidget->setMapCanvas( mCanvas );
4820 mOperationWidget->setSelectedOperation( deets );
4825 emit widgetValueHasChanged(
this );
4828 return mOperationWidget;
4834 mLineEdit =
new QLineEdit();
4835 QHBoxLayout *layout =
new QHBoxLayout();
4836 layout->addWidget( mLineEdit, 1 );
4837 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4839 emit widgetValueHasChanged(
this );
4842 QToolButton *button =
new QToolButton();
4843 button->setText( QString( QChar( 0x2026 ) ) );
4844 connect( button, &QToolButton::clicked,
this, [ = ]
4846 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4849 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4850 emit widgetValueHasChanged(
this );
4853 layout->addWidget( button );
4855 QWidget *w =
new QWidget();
4856 layout->setContentsMargins( 0, 0, 0, 0 );
4857 w->setLayout( layout );
4865void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4903 if ( mOperationWidget )
4904 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4907void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4909 if ( mOperationWidget )
4911 if ( !value.isValid() ||
4912 ( value.userType() == QMetaType::Type::QString ) )
4915 deets.
proj = value.toString();
4916 mOperationWidget->setSelectedOperation( deets );
4921 if ( !value.isValid() ||
4922 ( value.userType() == QMetaType::Type::QString ) )
4924 mLineEdit->setText( value.toString() );
4929QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4931 if ( mOperationWidget )
4932 return mOperationWidget->selectedOperation().proj;
4933 else if ( mLineEdit )
4934 return mLineEdit->text();
4939QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleParameterTypes()
const
4941 return QStringList()
4946QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleOutputTypes()
const
4948 return QStringList()
4953QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4955 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4958void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4961 std::unique_ptr< QgsProcessingContext > tmpContext;
4962 if ( mProcessingContextGenerator )
4963 context = mProcessingContextGenerator->processingContext();
4967 tmpContext = std::make_unique< QgsProcessingContext >();
4968 context = tmpContext.get();
4972 if ( mOperationWidget )
4974 mOperationWidget->setSourceCrs( mSourceCrs );
4975 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4979void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4982 std::unique_ptr< QgsProcessingContext > tmpContext;
4983 if ( mProcessingContextGenerator )
4984 context = mProcessingContextGenerator->processingContext();
4988 tmpContext = std::make_unique< QgsProcessingContext >();
4989 context = tmpContext.get();
4993 if ( mOperationWidget )
4995 mOperationWidget->setDestinationCrs( mDestCrs );
4996 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
5000QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
5007 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
5012 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5025 QHBoxLayout *hl =
new QHBoxLayout();
5026 hl->setContentsMargins( 0, 0, 0, 0 );
5028 mLineEdit =
new QLineEdit();
5029 mLineEdit->setEnabled(
false );
5030 hl->addWidget( mLineEdit, 1 );
5032 mToolButton =
new QToolButton();
5033 mToolButton->setText( QString( QChar( 0x2026 ) ) );
5034 hl->addWidget( mToolButton );
5040 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
5043 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
5046void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
5051void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
5053 if ( value.isValid() )
5054 mValue = value.userType() == QMetaType::Type::QVariantList ? value.
toList() : QVariantList() << value;
5058 updateSummaryText();
5062void QgsProcessingFieldPanelWidget::showDialog()
5064 QVariantList availableOptions;
5065 availableOptions.reserve( mFields.size() );
5066 for (
const QgsField &field : std::as_const( mFields ) )
5068 availableOptions << field.name();
5074 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
5075 widget->setPanelTitle( mParam->description() );
5077 widget->setValueFormatter( [](
const QVariant & v ) -> QString
5079 return v.toString();
5082 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
5084 setValue( widget->selectedOptions() );
5091 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
5093 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
5095 return v.toString();
5099 setValue( dlg.selectedOptions() );
5104void QgsProcessingFieldPanelWidget::updateSummaryText()
5109 if ( mValue.empty() )
5111 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
5116 values.reserve( mValue.size() );
5117 for (
const QVariant &val : std::as_const( mValue ) )
5119 values << val.toString();
5122 const QString concatenated = values.join( tr(
"," ) );
5123 if ( concatenated.length() < 100 )
5124 mLineEdit->setText( concatenated );
5126 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
5138 QVBoxLayout *vlayout =
new QVBoxLayout();
5139 vlayout->setContentsMargins( 0, 0, 0, 0 );
5141 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
5142 mParentLayerComboBox =
new QComboBox();
5144 QString initialParent;
5146 initialParent = fieldParam->parentLayerParameterName();
5148 if (
auto *lModel = widgetContext.
model() )
5151 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5152 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5156 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
5157 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
5159 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
5164 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
5165 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
5167 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
5174 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
5175 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
5177 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
5184 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
5187 mParentLayerComboBox->addItem( initialParent, initialParent );
5188 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
5191 vlayout->addWidget( mParentLayerComboBox );
5193 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
5194 mDataTypeComboBox =
new QComboBox();
5202 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast< int >( fieldParam->dataType() ) ) );
5204 vlayout->addWidget( mDataTypeComboBox );
5206 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
5208 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
5210 vlayout->addWidget( mAllowMultipleCheckBox );
5212 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
5213 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
5215 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
5217 vlayout->addWidget( mDefaultToAllCheckBox );
5219 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
5221 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
5224 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5226 mDefaultLineEdit =
new QLineEdit();
5227 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
5231 mDefaultLineEdit->setText( fields.join(
';' ) );
5233 vlayout->addWidget( mDefaultLineEdit );
5235 setLayout( vlayout );
5242 QVariant defaultValue;
5243 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
5245 defaultValue = mDefaultLineEdit->text();
5247 auto param = std::make_unique< QgsProcessingParameterField >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
5249 return param.release();
5258QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
5268 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
5269 mPanel->setToolTip( parameterDefinition()->toolTip() );
5270 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [ = ]
5272 emit widgetValueHasChanged(
this );
5292 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5295 emit widgetValueHasChanged(
this );
5303 mLineEdit =
new QLineEdit();
5304 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
5305 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
5307 emit widgetValueHasChanged(
this );
5316void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5328 setParentLayerWrapperValue( wrapper );
5331 setParentLayerWrapperValue( wrapper );
5348 std::unique_ptr< QgsProcessingContext > tmpContext;
5349 if ( mProcessingContextGenerator )
5350 context = mProcessingContextGenerator->processingContext();
5354 tmpContext = std::make_unique< QgsProcessingContext >();
5355 context = tmpContext.get();
5360 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
5370 bool valueSet =
false;
5374 if ( layers.count() > 1 )
5376 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
5378 const QList< QgsMapLayer * > remainingLayers = layers.mid( 1 );
5384 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer );
5385 if ( !vlayer || !vlayer->
isValid() )
5391 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
5394 fields.
remove( fieldIdx );
5399 mComboBox->setFields( fields );
5401 mPanel->setFields( filterFields( fields ) );
5407 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
5409 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
5413 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
5416 mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
5417 layer = mParentLayer.get();
5425 mComboBox->setLayer( layer );
5427 mPanel->setFields( filterFields( layer->
fields() ) );
5437 const QgsFields fields = source->fields();
5439 mComboBox->setFields( fields );
5441 mPanel->setFields( filterFields( fields ) );
5450 mComboBox->setLayer(
nullptr );
5454 if ( value.isValid() && widgetContext().messageBar() )
5457 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent field could not be populated" ),
5467 val.reserve( mPanel->fields().size() );
5468 for (
const QgsField &field : mPanel->fields() )
5469 val << field.name();
5470 setWidgetValue( val, *context );
5473 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5476void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5480 if ( !value.isValid() )
5481 mComboBox->setField( QString() );
5485 mComboBox->setField( v );
5491 if ( value.isValid() )
5494 opts.reserve( v.size() );
5495 for (
const QString &i : v )
5499 mPanel->setValue( opts );
5501 else if ( mLineEdit )
5507 mLineEdit->setText( v.join(
';' ) );
5516QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
5519 return mComboBox->currentField();
5521 return mPanel->value();
5522 else if ( mLineEdit )
5527 return mLineEdit->text().split(
';' );
5530 return mLineEdit->text();
5536QStringList QgsProcessingFieldWidgetWrapper::compatibleParameterTypes()
const
5538 return QStringList()
5543QStringList QgsProcessingFieldWidgetWrapper::compatibleOutputTypes()
const
5545 return QStringList()
5550QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
5552 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
5555const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
5557 if ( mComboBox && mComboBox->layer() )
5558 return mComboBox->layer();
5563QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
5576 if ( f.isNumeric() )
5581 if ( f.type() == QMetaType::Type::QString )
5586 if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
5591 if ( f.type() == QMetaType::Type::QByteArray )
5596 if ( f.type() == QMetaType::Type::Bool )
5605QString QgsProcessingFieldWidgetWrapper::parameterType()
const
5612 return new QgsProcessingFieldWidgetWrapper( parameter, type );
5617 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5628 QVBoxLayout *vlayout =
new QVBoxLayout();
5629 vlayout->setContentsMargins( 0, 0, 0, 0 );
5631 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5633 mDefaultComboBox =
new QComboBox();
5634 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
5637 for (
const QString &theme : mapThemes )
5641 mDefaultComboBox->setEditable(
true );
5645 if ( themeParam->defaultValueForGui().isValid() )
5648 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5651 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5653 vlayout->addWidget( mDefaultComboBox );
5655 setLayout( vlayout );
5660 QVariant defaultVal;
5661 if ( mDefaultComboBox->currentText().isEmpty() )
5662 defaultVal = QVariant();
5664 defaultVal = mDefaultComboBox->currentText();
5665 auto param = std::make_unique< QgsProcessingParameterMapTheme>( name, description, defaultVal );
5667 return param.release();
5677QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
5681 mComboBox =
new QComboBox();
5684 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
5687 for (
const QString &theme : mapThemes )
5699 mComboBox->setEditable(
true );
5703 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5704 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
5706 emit widgetValueHasChanged(
this );
5712void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5716 if ( !value.isValid() )
5717 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5720 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5722 const QString prev = mComboBox->currentText();
5723 mComboBox->setCurrentText( v );
5725 emit widgetValueHasChanged(
this );
5728 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5732QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5735 return mComboBox->currentData().toInt() == -1 ? QVariant() :
5736 !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5737 : mComboBox->currentData();
5742QStringList QgsProcessingMapThemeWidgetWrapper::compatibleParameterTypes()
const
5744 return QStringList()
5749QStringList QgsProcessingMapThemeWidgetWrapper::compatibleOutputTypes()
const
5751 return QStringList()
5756QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5758 return tr(
"map theme as a string value (e.g. 'base maps')" );
5761QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5768 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5773 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5786 QVBoxLayout *vlayout =
new QVBoxLayout();
5787 vlayout->setContentsMargins( 0, 0, 0, 0 );
5789 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5791 mTypeComboBox =
new QComboBox();
5796 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( datetimeParam->dataType() ) ) );
5798 mTypeComboBox->setCurrentIndex( 0 );
5799 vlayout->addWidget( mTypeComboBox );
5801 setLayout( vlayout );
5806 auto param = std::make_unique< QgsProcessingParameterDateTime >( name, description );
5809 return param.release();
5819QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5824 switch ( dateTimeParam->
dataType() )
5828 widget = mDateTimeEdit;
5851 widget->setToolTip( parameterDefinition()->toolTip() );
5853 if ( mDateTimeEdit )
5857 emit widgetValueHasChanged(
this );
5860 else if ( mDateEdit )
5864 emit widgetValueHasChanged(
this );
5867 else if ( mTimeEdit )
5871 emit widgetValueHasChanged(
this );
5880 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5883void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5885 if ( mDateTimeEdit )
5889 else if ( mDateEdit )
5893 else if ( mTimeEdit )
5899QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5901 if ( mDateTimeEdit )
5902 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5903 else if ( mDateEdit )
5904 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5905 else if ( mTimeEdit )
5906 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5911QStringList QgsProcessingDateTimeWidgetWrapper::compatibleParameterTypes()
const
5913 return QStringList()
5918QStringList QgsProcessingDateTimeWidgetWrapper::compatibleOutputTypes()
const
5920 return QStringList()
5925QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5928 if ( dateTimeParam )
5930 switch ( dateTimeParam->
dataType() )
5933 return tr(
"datetime value, or a ISO string representation of a datetime" );
5936 return tr(
"date value, or a ISO string representation of a date" );
5939 return tr(
"time value, or a ISO string representation of a time" );
5945QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5952 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5966 QVBoxLayout *vlayout =
new QVBoxLayout();
5967 vlayout->setContentsMargins( 0, 0, 0, 0 );
5969 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5970 mProviderComboBox =
new QComboBox();
5971 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
5972 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
5973 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
5975 vlayout->addWidget( mProviderComboBox );
5977 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5979 mDefaultEdit =
new QLineEdit();
5980 vlayout->addWidget( mDefaultEdit );
5981 setLayout( vlayout );
5983 if ( connectionParam )
5985 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5992 QVariant defaultVal;
5993 if ( mDefaultEdit->text().isEmpty() )
5994 defaultVal = QVariant();
5996 defaultVal = mDefaultEdit->text();
5997 auto param = std::make_unique< QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5999 return param.release();
6009QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
6015 mProviderComboBox->setAllowEmptyConnection(
true );
6023 mProviderComboBox->setEditable(
true );
6027 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
6028 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [ = ](
const QString & )
6030 if ( mBlockSignals )
6033 emit widgetValueHasChanged(
this );
6036 return mProviderComboBox;
6041 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6044void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6048 if ( !value.isValid() )
6049 mProviderComboBox->setCurrentIndex( -1 );
6052 if ( mProviderComboBox->isEditable() )
6054 const QString prev = mProviderComboBox->currentText();
6056 mProviderComboBox->setConnection( v );
6057 mProviderComboBox->setCurrentText( v );
6061 emit widgetValueHasChanged(
this );
6064 mProviderComboBox->setConnection( v );
6068QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
6070 if ( mProviderComboBox )
6071 if ( mProviderComboBox->isEditable() )
6072 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
6074 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
6079QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleParameterTypes()
const
6081 return QStringList()
6087QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleOutputTypes()
const
6089 return QStringList()
6094QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
6096 return tr(
"connection name as a string value" );
6099QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
6106 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
6121 QVBoxLayout *vlayout =
new QVBoxLayout();
6122 vlayout->setContentsMargins( 0, 0, 0, 0 );
6124 mConnectionParamComboBox =
new QComboBox();
6125 QString initialConnection;
6131 if (
auto *lModel = widgetContext.
model() )
6134 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6135 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6137 if ( definition && it->parameterName() == definition->
name() )
6143 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
6144 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6146 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6151 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
6154 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
6155 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6158 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
6159 vlayout->addWidget( mConnectionParamComboBox );
6161 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6163 mDefaultEdit =
new QLineEdit();
6164 vlayout->addWidget( mDefaultEdit );
6165 setLayout( vlayout );
6175 QVariant defaultVal;
6176 if ( mDefaultEdit->text().isEmpty() )
6177 defaultVal = QVariant();
6179 defaultVal = mDefaultEdit->text();
6180 auto param = std::make_unique< QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
6182 return param.release();
6192QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
6198 mSchemaComboBox->setAllowEmptySchema(
true );
6206 mSchemaComboBox->comboBox()->setEditable(
true );
6210 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
6211 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
6213 if ( mBlockSignals )
6216 emit widgetValueHasChanged( this );
6219 return mSchemaComboBox;
6224 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6231 std::unique_ptr< QgsProcessingContext > tmpContext;
6232 if ( mProcessingContextGenerator )
6233 context = mProcessingContextGenerator->processingContext();
6237 tmpContext = std::make_unique< QgsProcessingContext >();
6238 context = tmpContext.get();
6244 if ( mSchemaComboBox )
6245 mSchemaComboBox->setConnectionName( connection, qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId() );
6249 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6252void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6256 if ( !value.isValid() )
6257 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
6260 if ( mSchemaComboBox->comboBox()->isEditable() )
6262 const QString prev = mSchemaComboBox->comboBox()->currentText();
6264 mSchemaComboBox->setSchema( v );
6265 mSchemaComboBox->comboBox()->setCurrentText( v );
6269 emit widgetValueHasChanged(
this );
6272 mSchemaComboBox->setSchema( v );
6276QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
6278 if ( mSchemaComboBox )
6279 if ( mSchemaComboBox->comboBox()->isEditable() )
6280 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
6282 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
6287QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleParameterTypes()
const
6289 return QStringList()
6295QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleOutputTypes()
const
6297 return QStringList()
6302QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
6304 return tr(
"database schema name as a string value" );
6307QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
6314 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
6317void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6329 setParentConnectionWrapperValue( wrapper );
6332 setParentConnectionWrapperValue( wrapper );
6356 QVBoxLayout *vlayout =
new QVBoxLayout();
6357 vlayout->setContentsMargins( 0, 0, 0, 0 );
6359 mConnectionParamComboBox =
new QComboBox();
6360 mSchemaParamComboBox =
new QComboBox();
6361 QString initialConnection;
6362 QString initialSchema;
6369 if (
auto *lModel = widgetContext.
model() )
6372 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6373 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6375 if ( definition && it->parameterName() == definition->
name() )
6380 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
6381 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6383 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6388 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
6389 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6391 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6397 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
6400 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
6401 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6404 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
6407 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
6408 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6411 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
6412 vlayout->addWidget( mConnectionParamComboBox );
6414 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
6415 vlayout->addWidget( mSchemaParamComboBox );
6417 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6419 mDefaultEdit =
new QLineEdit();
6420 vlayout->addWidget( mDefaultEdit );
6421 setLayout( vlayout );
6431 QVariant defaultVal;
6432 if ( mDefaultEdit->text().isEmpty() )
6433 defaultVal = QVariant();
6435 defaultVal = mDefaultEdit->text();
6436 auto param = std::make_unique< QgsProcessingParameterDatabaseTable>( name, description,
6437 mConnectionParamComboBox->currentData().toString(),
6438 mSchemaParamComboBox->currentData().toString(),
6441 return param.release();
6451QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
6457 mTableComboBox->setAllowEmptyTable(
true );
6460 mTableComboBox->comboBox()->setEditable(
true );
6462 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
6463 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
6465 if ( mBlockSignals )
6468 emit widgetValueHasChanged( this );
6471 return mTableComboBox;
6476 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6483 std::unique_ptr< QgsProcessingContext > tmpContext;
6484 if ( mProcessingContextGenerator )
6485 context = mProcessingContextGenerator->processingContext();
6489 tmpContext = std::make_unique< QgsProcessingContext >();
6490 context = tmpContext.get();
6495 mProvider = qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId();
6496 if ( mTableComboBox && !mSchema.isEmpty() )
6498 mTableComboBox->setSchema( mSchema );
6499 mTableComboBox->setConnectionName( mConnection, mProvider );
6503 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6511 std::unique_ptr< QgsProcessingContext > tmpContext;
6512 if ( mProcessingContextGenerator )
6513 context = mProcessingContextGenerator->processingContext();
6517 tmpContext = std::make_unique< QgsProcessingContext >();
6518 context = tmpContext.get();
6524 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
6526 mTableComboBox->setSchema( mSchema );
6527 mTableComboBox->setConnectionName( mConnection, mProvider );
6531 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6536void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6540 if ( !value.isValid() )
6541 mTableComboBox->comboBox()->setCurrentIndex( -1 );
6544 if ( mTableComboBox->comboBox()->isEditable() )
6546 const QString prev = mTableComboBox->comboBox()->currentText();
6548 mTableComboBox->setTable( v );
6549 mTableComboBox->comboBox()->setCurrentText( v );
6553 emit widgetValueHasChanged(
this );
6556 mTableComboBox->setTable( v );
6560QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
6562 if ( mTableComboBox )
6563 if ( mTableComboBox->comboBox()->isEditable() )
6564 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
6566 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
6571QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleParameterTypes()
const
6573 return QStringList()
6579QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleOutputTypes()
const
6581 return QStringList()
6586QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
6588 return tr(
"database table name as a string value" );
6591QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
6598 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
6601void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6613 setParentConnectionWrapperValue( wrapper );
6616 setParentConnectionWrapperValue( wrapper );
6621 setParentSchemaWrapperValue( wrapper );
6624 setParentSchemaWrapperValue( wrapper );
6644 QVBoxLayout *vlayout =
new QVBoxLayout();
6645 vlayout->setContentsMargins( 0, 0, 0, 0 );
6647 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6650 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6653 if ( extentParam->defaultValueForGui().isValid() )
6657 mDefaultWidget->setCurrentExtent( rect,
crs );
6658 mDefaultWidget->setOutputExtentFromCurrent();
6662 mDefaultWidget->clear();
6666 vlayout->addWidget( mDefaultWidget );
6667 setLayout( vlayout );
6672 const QString defaultVal = mDefaultWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
6673 QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ),
6674 QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ),
6675 QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ),
6676 QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ),
6677 mDefaultWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mDefaultWidget->outputCrs().authid() ) : QString()
6679 auto param = std::make_unique< QgsProcessingParameterExtent >( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
6681 return param.release();
6692QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
6702 if ( widgetContext().mapCanvas() )
6703 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
6706 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6708 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6712 emit widgetValueHasChanged(
this );
6716 setDialog( mDialog );
6718 return mExtentWidget;
6728 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6731void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6739 mDialog->showMinimized();
6742 mDialog->showNormal();
6744 mDialog->activateWindow();
6751void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6753 if ( mExtentWidget )
6755 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
6756 mExtentWidget->clear();
6761 mExtentWidget->setCurrentExtent( r,
crs );
6762 mExtentWidget->setOutputExtentFromUser( r,
crs );
6767QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6769 if ( mExtentWidget )
6771 const QString val = mExtentWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
6772 QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ),
6773 QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ),
6774 QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ),
6775 QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ),
6776 mExtentWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mExtentWidget->outputCrs().authid() ) : QString()
6779 return val.isEmpty() ? QVariant() : QVariant( val );
6785QStringList QgsProcessingExtentWidgetWrapper::compatibleParameterTypes()
const
6787 return QStringList()
6799QStringList QgsProcessingExtentWidgetWrapper::compatibleOutputTypes()
const
6801 return QStringList()
6809QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6811 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6814QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6821 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6826 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6838 QVBoxLayout *vlayout =
new QVBoxLayout();
6839 vlayout->setContentsMargins( 0, 0, 0, 0 );
6841 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6856 for (
int i : layerParam->dataTypes() )
6858 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6862 vlayout->addWidget( mLayerTypeComboBox );
6864 setLayout( vlayout );
6869 QList< int > dataTypes;
6870 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6871 dataTypes << v.toInt();
6873 auto param = std::make_unique< QgsProcessingParameterMapLayer >( name, description );
6874 param->setDataTypes( dataTypes );
6876 return param.release();
6885QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6887 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6895 mComboBox->setEditable(
true );
6899 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6901 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [ = ]()
6903 if ( mBlockSignals )
6906 emit widgetValueHasChanged(
this );
6909 setWidgetContext( widgetContext() );
6918 mComboBox->setWidgetContext( context );
6923 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6929void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6932 mComboBox->setValue( value, context );
6935QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6937 return mComboBox ? mComboBox->value() : QVariant();
6940QStringList QgsProcessingMapLayerWidgetWrapper::compatibleParameterTypes()
const
6942 return QStringList()
6953QStringList QgsProcessingMapLayerWidgetWrapper::compatibleOutputTypes()
const
6955 return QStringList()
6964QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6966 return tr(
"path to a map layer" );
6983QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6990 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6995 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7004 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7009QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleParameterTypes()
const
7011 return QStringList()
7018QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleOutputTypes()
const
7020 return QStringList()
7028QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
7030 return tr(
"path to a raster layer" );
7033QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
7040 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
7045 Q_UNUSED( context );
7046 Q_UNUSED( widgetContext );
7047 Q_UNUSED( definition );
7061 QVBoxLayout *vlayout =
new QVBoxLayout();
7062 vlayout->setContentsMargins( 0, 0, 0, 0 );
7064 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
7074 for (
int i : vectorParam->dataTypes() )
7076 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
7080 vlayout->addWidget( mGeometryTypeComboBox );
7082 setLayout( vlayout );
7087 QList< int > dataTypes;
7088 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
7089 dataTypes << v.toInt();
7091 auto param = std::make_unique< QgsProcessingParameterVectorLayer >( name, description, dataTypes );
7093 return param.release();
7098 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7103QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleParameterTypes()
const
7105 return QStringList()
7112QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleOutputTypes()
const
7114 return QStringList()
7122QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
7124 return tr(
"path to a vector layer" );
7130 return param->dataTypes();
7132 return QList< int >();
7135QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
7142 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
7147 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7159 QVBoxLayout *vlayout =
new QVBoxLayout();
7160 vlayout->setContentsMargins( 0, 0, 0, 0 );
7162 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
7172 for (
int i : sourceParam->dataTypes() )
7174 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
7182 vlayout->addWidget( mGeometryTypeComboBox );
7184 setLayout( vlayout );
7189 QList< int > dataTypes;
7190 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
7191 dataTypes << v.toInt();
7193 auto param = std::make_unique< QgsProcessingParameterFeatureSource >( name, description, dataTypes );
7195 return param.release();
7199 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7204QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleParameterTypes()
const
7206 return QStringList()
7214QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleOutputTypes()
const
7216 return QStringList()
7224QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
7226 return tr(
"path to a vector layer" );
7232 return param->dataTypes();
7234 return QList< int >();
7237QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
7244 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
7249 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7257 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7262QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleParameterTypes()
const
7264 return QStringList()
7271QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleOutputTypes()
const
7273 return QStringList()
7281QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
7283 return tr(
"path to a mesh layer" );
7286QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
7293 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
7298 Q_UNUSED( context );
7299 Q_UNUSED( widgetContext );
7300 Q_UNUSED( definition );
7312QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
7316 QHBoxLayout *hl =
new QHBoxLayout();
7317 hl->setContentsMargins( 0, 0, 0, 0 );
7319 mLineEdit =
new QLineEdit();
7320 mLineEdit->setEnabled(
false );
7321 hl->addWidget( mLineEdit, 1 );
7323 mToolButton =
new QToolButton();
7324 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7325 hl->addWidget( mToolButton );
7331 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
7334 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
7337void QgsProcessingRasterBandPanelWidget::setBands(
const QList< int > &bands )
7342void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
7347void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
7349 if ( value.isValid() )
7350 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7354 updateSummaryText();
7358void QgsProcessingRasterBandPanelWidget::showDialog()
7360 QVariantList availableOptions;
7361 availableOptions.reserve( mBands.size() );
7362 for (
int band : std::as_const( mBands ) )
7364 availableOptions << band;
7370 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7371 widget->setPanelTitle( mParam->description() );
7373 widget->setValueFormatter( [
this](
const QVariant & v ) -> QString
7375 int band = v.toInt();
7376 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
7379 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
7381 setValue( widget->selectedOptions() );
7388 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7390 dlg.setValueFormatter( [
this](
const QVariant & v ) -> QString
7392 int band = v.toInt();
7393 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
7397 setValue( dlg.selectedOptions() );
7402void QgsProcessingRasterBandPanelWidget::updateSummaryText()
7405 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
7417 QVBoxLayout *vlayout =
new QVBoxLayout();
7418 vlayout->setContentsMargins( 0, 0, 0, 0 );
7420 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7422 mDefaultLineEdit =
new QLineEdit();
7423 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
7428 for (
int b : bands )
7430 defVal << QString::number( b );
7433 mDefaultLineEdit->setText( defVal.join(
';' ) );
7435 vlayout->addWidget( mDefaultLineEdit );
7437 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7438 mParentLayerComboBox =
new QComboBox();
7440 QString initialParent;
7442 initialParent = bandParam->parentLayerParameterName();
7444 if (
auto *lModel = widgetContext.
model() )
7447 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7448 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7452 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
7453 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7455 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7461 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7464 mParentLayerComboBox->addItem( initialParent, initialParent );
7465 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7468 vlayout->addWidget( mParentLayerComboBox );
7470 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
7472 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
7474 vlayout->addWidget( mAllowMultipleCheckBox );
7475 setLayout( vlayout );
7480 auto param = std::make_unique< QgsProcessingParameterBand >( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
7482 return param.release();
7491QWidget *QgsProcessingBandWidgetWrapper::createWidget()
7501 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
7502 mPanel->setToolTip( parameterDefinition()->toolTip() );
7503 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [ = ]
7505 emit widgetValueHasChanged(
this );
7514 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7517 emit widgetValueHasChanged(
this );
7525 mLineEdit =
new QLineEdit();
7526 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
7527 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
7529 emit widgetValueHasChanged(
this );
7538void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7550 setParentLayerWrapperValue( wrapper );
7553 setParentLayerWrapperValue( wrapper );
7570 std::unique_ptr< QgsProcessingContext > tmpContext;
7571 if ( mProcessingContextGenerator )
7572 context = mProcessingContextGenerator->processingContext();
7576 tmpContext = std::make_unique< QgsProcessingContext >();
7577 context = tmpContext.get();
7583 if ( layer && layer->
isValid() )
7587 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
7590 mParentLayer.reset( qobject_cast< QgsRasterLayer * >( ownedLayer.release() ) );
7591 layer = mParentLayer.get();
7599 mComboBox->setLayer( layer );
7603 if ( provider && layer->
isValid() )
7608 QHash< int, QString > bandNames;
7609 for (
int i = 1; i <= nBands; ++i )
7614 mPanel->setBands( bands );
7615 mPanel->setBandNames( bandNames );
7622 mComboBox->setLayer(
nullptr );
7624 mPanel->setBands( QList< int >() );
7626 if ( value.isValid() && widgetContext().messageBar() )
7629 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent bands could not be populated" ),
7634 if ( parameterDefinition()->defaultValueForGui().isValid() )
7635 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7638void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7642 if ( !value.isValid() )
7643 mComboBox->setBand( -1 );
7647 mComboBox->setBand( v );
7653 if ( value.isValid() )
7656 opts.reserve( v.size() );
7661 mPanel->setValue( value.isValid() ? opts : QVariant() );
7663 else if ( mLineEdit )
7670 opts.reserve( v.size() );
7672 opts << QString::number( i );
7673 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
7677 if ( value.isValid() )
7685QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
7688 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
7690 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7691 else if ( mLineEdit )
7696 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
7698 res.reserve( parts.count() );
7699 for (
const QString &s : parts )
7702 int band = s.toInt( &ok );
7706 return res.
isEmpty() ? QVariant() : res;
7710 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7717QStringList QgsProcessingBandWidgetWrapper::compatibleParameterTypes()
const
7719 return QStringList()
7724QStringList QgsProcessingBandWidgetWrapper::compatibleOutputTypes()
const
7726 return QStringList()
7731QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7733 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7736QString QgsProcessingBandWidgetWrapper::parameterType()
const
7743 return new QgsProcessingBandWidgetWrapper( parameter, type );
7748 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7759 setAcceptDrops(
true );
7762void QgsProcessingMultipleLayerLineEdit::dragEnterEvent( QDragEnterEvent *event )
7764 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7765 if ( !uris.isEmpty() )
7767 event->setDropAction( Qt::CopyAction );
7769 setHighlighted(
true );
7777void QgsProcessingMultipleLayerLineEdit::dragLeaveEvent( QDragLeaveEvent *event )
7779 QgsHighlightableLineEdit::dragLeaveEvent( event );
7781 setHighlighted(
false );
7784void QgsProcessingMultipleLayerLineEdit::dropEvent( QDropEvent *event )
7786 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7787 if ( !uris.isEmpty() )
7789 event->acceptProposedAction();
7790 QVariantList uriList;
7791 uriList.reserve( uris.size() );
7792 for (
const QString &uri : uris )
7793 uriList.append( QVariant( uri ) );
7794 emit layersDropped( uriList );
7797 setHighlighted(
false );
7808 QHBoxLayout *hl =
new QHBoxLayout();
7809 hl->setContentsMargins( 0, 0, 0, 0 );
7811 mLineEdit =
new QgsProcessingMultipleLayerLineEdit(
nullptr, param );
7812 mLineEdit->setEnabled(
true );
7813 mLineEdit->setReadOnly(
true );
7815 hl->addWidget( mLineEdit, 1 );
7816 connect( mLineEdit, &QgsProcessingMultipleLayerLineEdit::layersDropped,
this, &QgsProcessingMultipleLayerPanelWidget::setValue );
7818 mToolButton =
new QToolButton();
7819 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7820 hl->addWidget( mToolButton );
7826 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7829 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7832void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7834 if ( value.isValid() )
7835 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7839 updateSummaryText();
7843void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7850 if ( mValue.removeAll( layerId ) )
7852 updateSummaryText();
7859void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7865 switch ( mParam->layerType() )
8023void QgsProcessingMultipleLayerPanelWidget::showDialog()
8028 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
8029 widget->setPanelTitle( mParam->description() );
8030 widget->setProject( mProject );
8031 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
8033 setValue( widget->selectedOptions() );
8040 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
8041 dlg.setProject( mProject );
8044 setValue( dlg.selectedOptions() );
8049void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
8052 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
8062 QVBoxLayout *vlayout =
new QVBoxLayout();
8063 vlayout->setContentsMargins( 0, 0, 0, 0 );
8065 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
8066 mLayerTypeComboBox =
new QComboBox();
8080 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast< int >( layersParam->layerType() ) ) );
8082 vlayout->addWidget( mLayerTypeComboBox );
8083 setLayout( vlayout );
8088 auto param = std::make_unique< QgsProcessingParameterMultipleLayers >( name, description,
static_cast< Qgis::ProcessingSourceType >( mLayerTypeComboBox->currentData().toInt() ) );
8090 return param.release();
8099QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
8103 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
8104 mPanel->setToolTip( parameterDefinition()->toolTip() );
8105 mPanel->setProject( widgetContext().project() );
8107 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
8108 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [ = ]
8110 emit widgetValueHasChanged(
this );
8120 mPanel->setProject( context.
project() );
8122 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
8126void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8131 if ( value.isValid() )
8134 opts.reserve( v.size() );
8136 opts << l->source();
8139 for (
const QVariant &v : value.toList() )
8141 if ( v.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
8143 const QgsProcessingModelChildParameterSource source = v.value< QgsProcessingModelChildParameterSource >();
8144 opts << QVariant::fromValue( source );
8149 mPanel->setValue( value.isValid() ? opts : QVariant() );
8153QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
8156 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
8161QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleParameterTypes()
const
8163 return QStringList()
8174QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleOutputTypes()
const
8176 return QStringList()
8186QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
8188 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
8191QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
8198 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
8203 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8212 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
8217QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleParameterTypes()
const
8219 return QStringList()
8226QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleOutputTypes()
const
8228 return QStringList()
8236QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
8238 return tr(
"path to a point cloud layer" );
8241QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
8248 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
8253 Q_UNUSED( context );
8254 Q_UNUSED( widgetContext );
8255 Q_UNUSED( definition );
8272QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleParameterTypes()
const
8274 return QStringList()
8281QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleOutputTypes()
const
8283 return QStringList()
8289QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
8291 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
8294QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
8301 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
8306 Q_UNUSED( context );
8307 Q_UNUSED( widgetContext );
8308 Q_UNUSED( definition );
8319 if ( mWidgetContext.project() )
8320 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
8324QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
8335 mComboBox->setEditable(
true );
8339 mComboBox->setToolTip( parameterDefinition()->toolTip() );
8341 if ( mWidgetContext.project() )
8342 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
8345 mComboBox->setAllowEmptyLayer(
true );
8349 if ( mBlockSignals )
8352 emit widgetValueHasChanged(
this );
8355 setWidgetContext( widgetContext() );
8359void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8365 mComboBox->setLayer(
nullptr );
8369 QVariant val = value;
8370 if ( val.userType() == qMetaTypeId<QgsProperty>() )
8382 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( val.value< QObject * >() );
8383 if ( !layer && val.userType() == QMetaType::Type::QString )
8390 mComboBox->setLayer( layer );
8395QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
8397 return mComboBox && mComboBox->currentLayer() ?
8398 ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral(
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
8411 QHBoxLayout *hl =
new QHBoxLayout();
8412 hl->setContentsMargins( 0, 0, 0, 0 );
8414 mLineEdit =
new QLineEdit();
8415 mLineEdit->setEnabled(
false );
8416 hl->addWidget( mLineEdit, 1 );
8418 mToolButton =
new QToolButton();
8419 mToolButton->setText( QString( QChar( 0x2026 ) ) );
8420 hl->addWidget( mToolButton );
8426 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
8429 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
8434 mAttributes = attributes;
8437void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
8439 if ( value.isValid() )
8440 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
8444 updateSummaryText();
8448void QgsProcessingPointCloudAttributePanelWidget::showDialog()
8450 QVariantList availableOptions;
8451 availableOptions.reserve( mAttributes.count() );
8452 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
8455 availableOptions << attr.name();
8461 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
8462 widget->setPanelTitle( mParam->description() );
8464 widget->setValueFormatter( [](
const QVariant & v ) -> QString
8466 return v.toString();
8469 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
8471 setValue( widget->selectedOptions() );
8478 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
8480 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
8482 return v.toString();
8486 setValue( dlg.selectedOptions() );
8491void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
8496 if ( mValue.empty() )
8498 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
8503 values.reserve( mValue.size() );
8504 for (
const QVariant &val : std::as_const( mValue ) )
8506 values << val.toString();
8509 const QString concatenated = values.join( tr(
"," ) );
8510 if ( concatenated.length() < 100 )
8511 mLineEdit->setText( concatenated );
8513 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
8525 QVBoxLayout *vlayout =
new QVBoxLayout();
8526 vlayout->setContentsMargins( 0, 0, 0, 0 );
8528 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
8529 mParentLayerComboBox =
new QComboBox();
8531 QString initialParent;
8533 initialParent = attrParam->parentLayerParameterName();
8535 if (
auto *lModel = widgetContext.
model() )
8538 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
8539 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
8543 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
8544 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
8546 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
8552 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
8555 mParentLayerComboBox->addItem( initialParent, initialParent );
8556 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
8559 vlayout->addWidget( mParentLayerComboBox );
8561 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
8563 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
8565 vlayout->addWidget( mAllowMultipleCheckBox );
8567 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
8568 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
8570 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
8572 vlayout->addWidget( mDefaultToAllCheckBox );
8574 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
8576 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
8579 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
8581 mDefaultLineEdit =
new QLineEdit();
8582 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
8586 mDefaultLineEdit->setText( attributes.join(
';' ) );
8588 vlayout->addWidget( mDefaultLineEdit );
8590 setLayout( vlayout );
8595 QVariant defaultValue;
8596 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
8598 defaultValue = mDefaultLineEdit->text();
8600 auto param = std::make_unique< QgsProcessingParameterPointCloudAttribute >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
8602 return param.release();
8610QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
8620 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
8621 mPanel->setToolTip( parameterDefinition()->toolTip() );
8622 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [ = ]
8624 emit widgetValueHasChanged(
this );
8632 mComboBox->setToolTip( parameterDefinition()->toolTip() );
8635 emit widgetValueHasChanged(
this );
8643 mLineEdit =
new QLineEdit();
8644 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
8645 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
8647 emit widgetValueHasChanged(
this );
8656void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
8668 setParentLayerWrapperValue( wrapper );
8671 setParentLayerWrapperValue( wrapper );
8688 std::unique_ptr< QgsProcessingContext > tmpContext;
8689 if ( mProcessingContextGenerator )
8690 context = mProcessingContextGenerator->processingContext();
8694 tmpContext = std::make_unique< QgsProcessingContext >();
8695 context = tmpContext.get();
8701 if ( layer && layer->
isValid() )
8705 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
8708 mParentLayer.reset( qobject_cast< QgsPointCloudLayer * >( ownedLayer.release() ) );
8709 layer = mParentLayer.get();
8717 mComboBox->setLayer( layer );
8720 mPanel->setAttributes( layer->
attributes() );
8727 mComboBox->setLayer(
nullptr );
8732 if ( value.isValid() && widgetContext().messageBar() )
8735 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent attributes could not be populated" ),
8744 val.reserve( mPanel->attributes().attributes().size() );
8747 setWidgetValue( val, *context );
8750 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
8753void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8757 if ( !value.isValid() )
8758 mComboBox->setAttribute( QString() );
8762 mComboBox->setAttribute( v );
8768 if ( value.isValid() )
8771 opts.reserve( v.size() );
8772 for (
const QString &i : v )
8776 mPanel->setValue( opts );
8778 else if ( mLineEdit )
8784 mLineEdit->setText( v.join(
';' ) );
8793QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
8796 return mComboBox->currentAttribute();
8798 return mPanel->value();
8799 else if ( mLineEdit )
8804 return mLineEdit->text().split(
';' );
8807 return mLineEdit->text();
8813QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleParameterTypes()
const
8815 return QStringList()
8820QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleOutputTypes()
const
8822 return QStringList()
8827QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
8829 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
8832QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
8839 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
8844 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8858QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8866 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8867 if ( mProcessingContextGenerator )
8868 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8869 if ( mParametersGenerator )
8870 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8871 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8873 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [ = ]()
8875 if ( mBlockSignals )
8878 emit widgetValueHasChanged(
this );
8887 mOutputWidget->addOpenAfterRunningOption();
8889 return mOutputWidget;
8899void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8901 if ( mOutputWidget )
8902 mOutputWidget->setValue( value );
8905QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8907 if ( mOutputWidget )
8908 return mOutputWidget->value();
8913QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8916 if ( mOutputWidget )
8917 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
8921QStringList QgsProcessingOutputWidgetWrapper::compatibleParameterTypes()
const
8923 return QStringList()
8932QStringList QgsProcessingOutputWidgetWrapper::compatibleOutputTypes()
const
8934 return QStringList()
8946 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8951QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8958 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8961QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8963 return tr(
"path to layer destination" );
8971 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8976QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8983 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8986QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8988 return tr(
"path to layer destination" );
8996 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9001QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
9008 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
9011QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
9013 return tr(
"path to layer destination" );
9021 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9026QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
9033 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
9036QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
9038 return tr(
"path to layer destination" );
9046 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9051QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
9058 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
9061QStringList QgsProcessingFileDestinationWidgetWrapper::compatibleParameterTypes()
const
9063 return QStringList()
9068QStringList QgsProcessingFileDestinationWidgetWrapper::compatibleOutputTypes()
const
9078QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
9080 return tr(
"path to file destination" );
9088 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9093QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
9100 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
9103QStringList QgsProcessingFolderDestinationWidgetWrapper::compatibleParameterTypes()
const
9105 return QStringList()
9110QStringList QgsProcessingFolderDestinationWidgetWrapper::compatibleOutputTypes()
const
9118QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
9120 return tr(
"path to folder destination" );
9128 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
9132QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
9139 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
9142QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
9144 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