78#include <QPlainTextEdit>
79#include <QRadioButton>
80#include <QButtonGroup>
94 QVBoxLayout *vlayout =
new QVBoxLayout();
95 vlayout->setContentsMargins( 0, 0, 0, 0 );
97 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
101 mDefaultCheckBox->setChecked(
false );
102 vlayout->addWidget( mDefaultCheckBox );
103 setLayout( vlayout );
106QgsProcessingParameterDefinition *QgsProcessingBooleanParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
108 auto param = std::make_unique< QgsProcessingParameterBoolean >( name, description, mDefaultCheckBox->isChecked() );
109 param->setFlags( flags );
110 return param.release();
120QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
126 QString description = parameterDefinition()->description();
128 description = QObject::tr(
"%1 [optional]" ).arg( description );
130 mCheckBox =
new QCheckBox( description );
131 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
133 connect( mCheckBox, &QCheckBox::toggled,
this, [ = ]
135 emit widgetValueHasChanged(
this );
143 mComboBox =
new QComboBox();
144 mComboBox->addItem( tr(
"Yes" ),
true );
145 mComboBox->addItem( tr(
"No" ),
false );
146 mComboBox->setToolTip( parameterDefinition()->toolTip() );
148 connect( mComboBox, qOverload< int>( &QComboBox::currentIndexChanged ),
this, [ = ]
150 emit widgetValueHasChanged(
this );
159QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
168void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
175 mCheckBox->setChecked( v );
183 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
189QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
194 return mCheckBox->isChecked();
198 return mComboBox->currentData();
203QStringList QgsProcessingBooleanWidgetWrapper::compatibleParameterTypes()
const
225QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes()
const
237QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
244 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
249 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
260 QVBoxLayout *vlayout =
new QVBoxLayout();
261 vlayout->setContentsMargins( 0, 0, 0, 0 );
263 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
268 mCrsSelector->setShowAccuracyWarnings(
true );
275 vlayout->addWidget( mCrsSelector );
276 setLayout( vlayout );
279QgsProcessingParameterDefinition *QgsProcessingCrsParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
281 auto param = std::make_unique< QgsProcessingParameterCrs >( name, description, mCrsSelector->crs().authid() );
282 param->setFlags( flags );
283 return param.release();
292QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
294 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
296 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
305 emit widgetValueHasChanged(
this );
313 return mProjectionSelectionWidget;
318 QWidget *w =
new QWidget();
319 w->setToolTip( parameterDefinition()->toolTip() );
321 QVBoxLayout *vl =
new QVBoxLayout();
322 vl->setContentsMargins( 0, 0, 0, 0 );
325 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
326 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
327 vl->addWidget( mUseProjectCrsCheckBox );
328 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
329 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [ = ]
331 emit widgetValueHasChanged(
this );
334 vl->addWidget( mProjectionSelectionWidget );
342void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
344 if ( mUseProjectCrsCheckBox )
346 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
348 mUseProjectCrsCheckBox->setChecked(
true );
353 mUseProjectCrsCheckBox->setChecked(
false );
358 if ( mProjectionSelectionWidget )
359 mProjectionSelectionWidget->setCrs( v );
362QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
364 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
365 return QStringLiteral(
"ProjectCrs" );
366 else if ( mProjectionSelectionWidget )
367 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
372QStringList QgsProcessingCrsWidgetWrapper::compatibleParameterTypes()
const
386QStringList QgsProcessingCrsWidgetWrapper::compatibleOutputTypes()
const
395QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
397 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
400QString QgsProcessingCrsWidgetWrapper::parameterType()
const
407 return new QgsProcessingCrsWidgetWrapper( parameter, type );
412 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
425 QVBoxLayout *vlayout =
new QVBoxLayout();
426 vlayout->setContentsMargins( 0, 0, 0, 0 );
428 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
430 mDefaultLineEdit =
new QLineEdit();
433 vlayout->addWidget( mDefaultLineEdit );
435 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
437 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
438 vlayout->addWidget( mMultiLineCheckBox );
440 setLayout( vlayout );
443QgsProcessingParameterDefinition *QgsProcessingStringParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
445 auto param = std::make_unique< QgsProcessingParameterString >( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
446 param->setFlags( flags );
447 return param.release();
458QWidget *QgsProcessingStringWidgetWrapper::createWidget()
460 const QVariantMap metadata = parameterDefinition()->metadata();
461 const QVariant valueHintsVariant = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"value_hints" ) );
463 if ( valueHintsVariant.isValid() )
465 const QVariantList valueList = valueHintsVariant.toList();
466 mComboBox =
new QComboBox();
467 mComboBox->setToolTip( parameterDefinition()->toolTip() );
471 mComboBox->addItem( QString() );
473 for (
const QVariant &entry : valueList )
475 mComboBox->addItem( entry.toString(), entry.toString() );
477 mComboBox->setCurrentIndex( 0 );
479 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
481 emit widgetValueHasChanged(
this );
494 mPlainTextEdit =
new QPlainTextEdit();
495 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
497 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [ = ]
499 emit widgetValueHasChanged(
this );
501 return mPlainTextEdit;
505 mLineEdit =
new QLineEdit();
506 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
508 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
510 emit widgetValueHasChanged(
this );
518 mLineEdit =
new QLineEdit();
519 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
521 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
523 emit widgetValueHasChanged(
this );
533void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
537 mLineEdit->setText( v );
538 if ( mPlainTextEdit )
539 mPlainTextEdit->setPlainText( v );
543 if ( !value.isValid() )
544 index = mComboBox->findData( QVariant() );
546 index = mComboBox->findData( v );
549 mComboBox->setCurrentIndex( index );
551 mComboBox->setCurrentIndex( 0 );
555QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
558 return mLineEdit->text();
559 else if ( mPlainTextEdit )
560 return mPlainTextEdit->toPlainText();
561 else if ( mComboBox )
562 return mComboBox->currentData();
567QStringList QgsProcessingStringWidgetWrapper::compatibleParameterTypes()
const
583QStringList QgsProcessingStringWidgetWrapper::compatibleOutputTypes()
const
592QString QgsProcessingStringWidgetWrapper::parameterType()
const
599 return new QgsProcessingStringWidgetWrapper( parameter, type );
604 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
619QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
628 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
632 emit widgetValueHasChanged(
this );
634 return mAuthConfigSelect;
640void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
643 if ( mAuthConfigSelect )
644 mAuthConfigSelect->setConfigId( v );
647QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
649 if ( mAuthConfigSelect )
650 return mAuthConfigSelect->configId();
655QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleParameterTypes()
const
663QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleOutputTypes()
const
669QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
676 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
686 QVBoxLayout *vlayout =
new QVBoxLayout();
687 vlayout->setContentsMargins( 0, 0, 0, 0 );
689 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
691 mTypeComboBox =
new QComboBox();
694 vlayout->addWidget( mTypeComboBox );
696 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
697 mMinLineEdit =
new QLineEdit();
698 vlayout->addWidget( mMinLineEdit );
700 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
701 mMaxLineEdit =
new QLineEdit();
702 vlayout->addWidget( mMaxLineEdit );
704 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
705 mDefaultLineEdit =
new QLineEdit();
706 vlayout->addWidget( mDefaultLineEdit );
710 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( numberParam->dataType() ) ) );
712 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
714 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
718 mMaxLineEdit->clear();
721 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
723 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
727 mMinLineEdit->clear();
730 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
733 setLayout( vlayout );
736QgsProcessingParameterDefinition *QgsProcessingNumberParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
742 auto param = std::make_unique< QgsProcessingParameterNumber >( name, description, dataType, ok ? val : QVariant() );
744 if ( !mMinLineEdit->text().trimmed().isEmpty() )
749 param->setMinimum( val );
753 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
758 param->setMaximum( val );
762 param->setFlags( flags );
763 return param.release();
772QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
775 const QVariantMap metadata = numberDef->
metadata();
776 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
784 QAbstractSpinBox *spinBox =
nullptr;
789 mDoubleSpinBox->setExpressionsEnabled(
true );
790 mDoubleSpinBox->setDecimals( decimals );
796 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
797 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
798 mDoubleSpinBox->setSingleStep( singleStep );
801 spinBox = mDoubleSpinBox;
806 mSpinBox->setExpressionsEnabled(
true );
810 spinBox->setToolTip( parameterDefinition()->toolTip() );
812 double max = 999999999;
817 double min = -999999999;
822 if ( mDoubleSpinBox )
824 mDoubleSpinBox->setMinimum( min );
825 mDoubleSpinBox->setMaximum( max );
829 mSpinBox->setMinimum(
static_cast< int >( min ) );
830 mSpinBox->setMaximum(
static_cast< int >( max ) );
835 mAllowingNull =
true;
836 if ( mDoubleSpinBox )
838 mDoubleSpinBox->setShowClearButton(
true );
839 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
840 mDoubleSpinBox->setMinimum( min );
841 mDoubleSpinBox->setValue( min );
845 mSpinBox->setShowClearButton(
true );
846 const int min = mSpinBox->minimum() - 1;
847 mSpinBox->setMinimum( min );
848 mSpinBox->setValue( min );
850 spinBox->setSpecialValueText( tr(
"Not set" ) );
858 if ( mDoubleSpinBox )
862 mDoubleSpinBox->setClearValue( defaultVal );
868 mSpinBox->setClearValue( intVal );
874 if ( mDoubleSpinBox )
875 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
877 mSpinBox->setClearValue(
static_cast< int >( numberDef->
minimum() ) );
882 if ( mDoubleSpinBox )
884 mDoubleSpinBox->setValue( 0 );
885 mDoubleSpinBox->setClearValue( 0 );
889 mSpinBox->setValue( 0 );
890 mSpinBox->setClearValue( 0 );
895 if ( mDoubleSpinBox )
896 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
898 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
906void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
908 if ( mDoubleSpinBox )
910 if ( mAllowingNull && !value.isValid() )
911 mDoubleSpinBox->clear();
915 mDoubleSpinBox->setValue( v );
920 if ( mAllowingNull && !value.isValid() )
925 mSpinBox->setValue( v );
930QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
932 if ( mDoubleSpinBox )
934 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
937 return mDoubleSpinBox->value();
941 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
944 return mSpinBox->value();
950QStringList QgsProcessingNumericWidgetWrapper::compatibleParameterTypes()
const
960QStringList QgsProcessingNumericWidgetWrapper::compatibleOutputTypes()
const
967double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
969 const double valueRange = maximum - minimum;
970 if ( valueRange <= 1.0 )
972 const double step = valueRange / 10.0;
974 return qgsRound( step, -std::floor( std::log( step ) ) );
982QString QgsProcessingNumericWidgetWrapper::parameterType()
const
989 return new QgsProcessingNumericWidgetWrapper( parameter, type );
994 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1004 QVBoxLayout *vlayout =
new QVBoxLayout();
1005 vlayout->setContentsMargins( 0, 0, 0, 0 );
1007 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1009 mParentLayerComboBox =
new QComboBox();
1011 QString initialParent;
1013 initialParent = distParam->parentParameterName();
1015 if (
auto *lModel = widgetContext.
model() )
1018 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1019 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1023 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1024 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1026 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1031 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1032 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1034 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1039 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1040 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1042 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1047 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1048 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1050 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1056 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1059 mParentLayerComboBox->addItem( initialParent, initialParent );
1060 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1063 vlayout->addWidget( mParentLayerComboBox );
1065 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1066 mMinLineEdit =
new QLineEdit();
1067 vlayout->addWidget( mMinLineEdit );
1069 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1070 mMaxLineEdit =
new QLineEdit();
1071 vlayout->addWidget( mMaxLineEdit );
1073 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1074 mDefaultLineEdit =
new QLineEdit();
1075 vlayout->addWidget( mDefaultLineEdit );
1079 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
1080 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
1081 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
1084 setLayout( vlayout );
1087QgsProcessingParameterDefinition *QgsProcessingDistanceParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
1092 auto param = std::make_unique< QgsProcessingParameterDistance >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1097 param->setMinimum( val );
1103 param->setMaximum( val );
1106 param->setFlags( flags );
1107 return param.release();
1111 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1116QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
1123 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
1126QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1130 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1135 mLabel =
new QLabel();
1136 mUnitsCombo =
new QComboBox();
1148 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1149 QHBoxLayout *layout =
new QHBoxLayout();
1150 layout->addWidget( spin, 1 );
1151 layout->insertSpacing( 1, labelMargin / 2 );
1152 layout->insertWidget( 2, mLabel );
1153 layout->insertWidget( 3, mUnitsCombo );
1158 mWarningLabel =
new QWidget();
1159 QHBoxLayout *warningLayout =
new QHBoxLayout();
1160 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1161 QLabel *warning =
new QLabel();
1163 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1164 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1165 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1166 warningLayout->insertSpacing( 0, labelMargin / 2 );
1167 warningLayout->insertWidget( 1, warning );
1168 mWarningLabel->setLayout( warningLayout );
1169 layout->insertWidget( 4, mWarningLabel );
1171 QWidget *w =
new QWidget();
1172 layout->setContentsMargins( 0, 0, 0, 0 );
1173 w->setLayout( layout );
1188void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1190 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1197 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1199 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1202 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1222 std::unique_ptr< QgsProcessingContext > tmpContext;
1223 if ( mProcessingContextGenerator )
1224 context = mProcessingContextGenerator->processingContext();
1228 tmpContext = std::make_unique< QgsProcessingContext >();
1229 context = tmpContext.get();
1248 mUnitsCombo->hide();
1253 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( units ) ) );
1254 mUnitsCombo->show();
1261QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1263 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1264 if ( val.type() == QVariant::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1277 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1288 QVBoxLayout *vlayout =
new QVBoxLayout();
1289 vlayout->setContentsMargins( 0, 0, 0, 0 );
1291 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1292 mMinLineEdit =
new QLineEdit();
1293 vlayout->addWidget( mMinLineEdit );
1295 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1296 mMaxLineEdit =
new QLineEdit();
1297 vlayout->addWidget( mMaxLineEdit );
1299 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1300 mDefaultLineEdit =
new QLineEdit();
1301 vlayout->addWidget( mDefaultLineEdit );
1303 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1305 mUnitsCombo =
new QComboBox();
1315 vlayout->addWidget( mUnitsCombo );
1319 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1320 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1321 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1322 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast <int >( durationParam->defaultUnit() ) ) );
1325 setLayout( vlayout );
1328QgsProcessingParameterDefinition *QgsProcessingDurationParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
1333 auto param = std::make_unique< QgsProcessingParameterDuration >( name, description, ok ? val : QVariant() );
1338 param->setMinimum( val );
1344 param->setMaximum( val );
1347 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit >( mUnitsCombo->currentData().toInt() ) );
1349 param->setFlags( flags );
1350 return param.release();
1354 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1359QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1366 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1369QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1373 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1378 mUnitsCombo =
new QComboBox();
1390 QHBoxLayout *layout =
new QHBoxLayout();
1391 layout->addWidget( spin, 1 );
1392 layout->insertWidget( 1, mUnitsCombo );
1394 QWidget *w =
new QWidget();
1395 layout->setContentsMargins( 0, 0, 0, 0 );
1396 w->setLayout( layout );
1398 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( durationDef->
defaultUnit() ) ) );
1399 mUnitsCombo->show();
1412QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
1424QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
1426 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1427 if ( val.type() == QVariant::Double && mUnitsCombo )
1438void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1444 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
1448 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
1454 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1464 QVBoxLayout *vlayout =
new QVBoxLayout();
1465 vlayout->setContentsMargins( 0, 0, 0, 0 );
1467 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1469 mDefaultLineEdit =
new QLineEdit();
1473 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1476 vlayout->addWidget( mDefaultLineEdit );
1478 setLayout( vlayout );
1481QgsProcessingParameterDefinition *QgsProcessingScaleParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
1484 double val = mDefaultLineEdit->text().toDouble( &ok );
1485 auto param = std::make_unique< QgsProcessingParameterScale >( name, description, ok ? val : QVariant() );
1487 return param.release();
1491 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1496QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1503 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1506QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
1518 mScaleWidget->setAllowNull(
true );
1520 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
1521 mScaleWidget->setShowCurrentScaleButton(
true );
1523 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
1526 emit widgetValueHasChanged(
this );
1528 return mScaleWidget;
1537 mScaleWidget->setMapCanvas( context.
mapCanvas() );
1542QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
1544 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
1547void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1551 if ( mScaleWidget->allowNull() && !value.isValid() )
1552 mScaleWidget->setNull();
1556 mScaleWidget->setScale( v );
1563 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1574 QVBoxLayout *vlayout =
new QVBoxLayout();
1575 vlayout->setContentsMargins( 0, 0, 0, 0 );
1577 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
1579 mTypeComboBox =
new QComboBox();
1582 vlayout->addWidget( mTypeComboBox );
1584 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1585 mMinLineEdit =
new QLineEdit();
1586 vlayout->addWidget( mMinLineEdit );
1588 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1589 mMaxLineEdit =
new QLineEdit();
1590 vlayout->addWidget( mMaxLineEdit );
1594 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( rangeParam->dataType() ) ) );
1596 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
1597 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
1600 setLayout( vlayout );
1603QgsProcessingParameterDefinition *QgsProcessingRangeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
1605 QString defaultValue;
1606 if ( mMinLineEdit->text().isEmpty() )
1608 defaultValue = QStringLiteral(
"None" );
1616 defaultValue = QStringLiteral(
"None" );
1620 if ( mMaxLineEdit->text().isEmpty() )
1622 defaultValue += QLatin1String(
",None" );
1628 defaultValue += QStringLiteral(
",%1" ).arg( ok ? QString::number( val ) : QLatin1String(
"None" ) );
1632 auto param = std::make_unique< QgsProcessingParameterRange >( name, description, dataType, defaultValue );
1633 param->setFlags( flags );
1634 return param.release();
1644QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
1653 QHBoxLayout *layout =
new QHBoxLayout();
1658 mMinSpinBox->setExpressionsEnabled(
true );
1659 mMinSpinBox->setShowClearButton(
false );
1660 mMaxSpinBox->setExpressionsEnabled(
true );
1661 mMaxSpinBox->setShowClearButton(
false );
1663 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
1664 layout->addWidget( minLabel );
1665 layout->addWidget( mMinSpinBox, 1 );
1667 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
1668 layout->addWidget( maxLabel );
1669 layout->addWidget( mMaxSpinBox, 1 );
1671 QWidget *w =
new QWidget();
1672 layout->setContentsMargins( 0, 0, 0, 0 );
1673 w->setLayout( layout );
1677 mMinSpinBox->setDecimals( 6 );
1678 mMaxSpinBox->setDecimals( 6 );
1682 mMinSpinBox->setDecimals( 0 );
1683 mMaxSpinBox->setDecimals( 0 );
1686 mMinSpinBox->setMinimum( -99999999.999999 );
1687 mMaxSpinBox->setMinimum( -99999999.999999 );
1688 mMinSpinBox->setMaximum( 99999999.999999 );
1689 mMaxSpinBox->setMaximum( 99999999.999999 );
1693 mAllowingNull =
true;
1695 const double min = mMinSpinBox->minimum() - 1;
1696 mMinSpinBox->setMinimum( min );
1697 mMaxSpinBox->setMinimum( min );
1698 mMinSpinBox->setValue( min );
1699 mMaxSpinBox->setValue( min );
1701 mMinSpinBox->setShowClearButton(
true );
1702 mMaxSpinBox->setShowClearButton(
true );
1703 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
1704 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
1707 w->setToolTip( parameterDefinition()->toolTip() );
1709 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1711 mBlockChangedSignal++;
1712 if ( !mAllowingNull && v > mMaxSpinBox->value() )
1713 mMaxSpinBox->setValue( v );
1714 mBlockChangedSignal--;
1716 if ( !mBlockChangedSignal )
1717 emit widgetValueHasChanged(
this );
1719 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1721 mBlockChangedSignal++;
1722 if ( !mAllowingNull && v < mMinSpinBox->value() )
1723 mMinSpinBox->setValue( v );
1724 mBlockChangedSignal--;
1726 if ( !mBlockChangedSignal )
1727 emit widgetValueHasChanged(
this );
1736void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1739 if ( mAllowingNull && v.empty() )
1741 mMinSpinBox->clear();
1742 mMaxSpinBox->clear();
1749 if ( mAllowingNull )
1751 mBlockChangedSignal++;
1752 if ( std::isnan( v.at( 0 ) ) )
1753 mMinSpinBox->clear();
1755 mMinSpinBox->setValue( v.at( 0 ) );
1757 if ( v.count() >= 2 )
1759 if ( std::isnan( v.at( 1 ) ) )
1760 mMaxSpinBox->clear();
1762 mMaxSpinBox->setValue( v.at( 1 ) );
1764 mBlockChangedSignal--;
1768 mBlockChangedSignal++;
1769 mMinSpinBox->setValue( v.at( 0 ) );
1770 if ( v.count() >= 2 )
1771 mMaxSpinBox->setValue( v.at( 1 ) );
1772 mBlockChangedSignal--;
1776 if ( !mBlockChangedSignal )
1777 emit widgetValueHasChanged(
this );
1780QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
1782 if ( mAllowingNull )
1785 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
1786 value = QStringLiteral(
"None" );
1788 value = QString::number( mMinSpinBox->value() );
1790 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
1791 value += QLatin1String(
",None" );
1793 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
1798 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
1801QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
const
1803 return QStringList()
1808QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
const
1814QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
1816 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
1819QString QgsProcessingRangeWidgetWrapper::parameterType()
const
1826 return new QgsProcessingRangeWidgetWrapper( parameter, type );
1831 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1842 QVBoxLayout *vlayout =
new QVBoxLayout();
1843 vlayout->setContentsMargins( 0, 0, 0, 0 );
1845 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
1848 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
1849 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
1851 vlayout->addWidget( mMatrixWidget );
1852 setLayout( vlayout );
1855QgsProcessingParameterDefinition *QgsProcessingMatrixParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
1857 auto param = std::make_unique< QgsProcessingParameterMatrix >( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
1858 param->setFlags( flags );
1859 return param.release();
1869QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
1871 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast< const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
1872 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
1874 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [ = ]
1876 emit widgetValueHasChanged(
this );
1885 return mMatrixWidget;
1891void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1894 if ( mMatrixWidget )
1895 mMatrixWidget->setValue( v );
1898QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
1900 if ( mMatrixWidget )
1901 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
1906QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
const
1908 return QStringList()
1912QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
const
1914 return QStringList();
1917QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
1919 return tr(
"comma delimited string of values, or an array of values" );
1922QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
1929 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
1934 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1946 QVBoxLayout *vlayout =
new QVBoxLayout();
1947 vlayout->setContentsMargins( 0, 0, 0, 0 );
1949 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
1951 mTypeComboBox =
new QComboBox();
1955 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( fileParam->behavior() ) ) );
1957 mTypeComboBox->setCurrentIndex( 0 );
1958 vlayout->addWidget( mTypeComboBox );
1960 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
1962 mFilterComboBox =
new QComboBox();
1963 mFilterComboBox->setEditable(
true );
1965 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
1966 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
1967 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
1968 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
1970 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
1972 mFilterComboBox->setCurrentIndex( 0 );
1973 vlayout->addWidget( mFilterComboBox );
1975 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1978 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
1982 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
1986 vlayout->addWidget( mDefaultFileWidget );
1988 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ]
1997 setLayout( vlayout );
2000QgsProcessingParameterDefinition *QgsProcessingFileParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
2002 auto param = std::make_unique< QgsProcessingParameterFile >( name, description );
2005 param->setFileFilter( mFilterComboBox->currentText() );
2006 if ( !mDefaultFileWidget->filePath().isEmpty() )
2007 param->setDefaultValue( mDefaultFileWidget->filePath() );
2008 param->setFlags( flags );
2009 return param.release();
2019QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2029 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2030 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2032 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
2039 mFileWidget->setFilter( fileParam->
fileFilter() );
2040 else if ( !fileParam->
extension().isEmpty() )
2041 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
2051 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
2052 emit widgetValueHasChanged(
this );
2060void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2064 mFileWidget->setFilePath( v );
2067QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2070 return mFileWidget->filePath();
2075QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
const
2077 return QStringList()
2082QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
const
2093QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2095 return tr(
"string representing a path to a file or folder" );
2098QString QgsProcessingFileWidgetWrapper::parameterType()
const
2105 return new QgsProcessingFileWidgetWrapper( parameter, type );
2110 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2122 QVBoxLayout *vlayout =
new QVBoxLayout();
2123 vlayout->setContentsMargins( 0, 0, 0, 0 );
2124 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2127 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2129 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2130 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2132 QStackedWidget *stackedWidget =
new QStackedWidget();
2133 stackedWidget->addWidget( mDefaultQgisLineEdit );
2134 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2135 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2136 vlayout->addWidget( stackedWidget );
2141 mDefaultQgisLineEdit->setExpression( expr );
2142 mDefaultPointCloudLineEdit->setExpression( expr );
2145 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2147 mParentLayerComboBox =
new QComboBox();
2148 vlayout->addWidget( mParentLayerComboBox );
2150 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2151 mExpressionTypeComboBox =
new QComboBox();
2156 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2158 mParentLayerComboBox->clear();
2159 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2161 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2163 QString initialParent;
2165 initialParent = expParam->parentLayerParameterName();
2169 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2172 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2173 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2180 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2181 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2183 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2188 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2189 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2191 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2198 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2199 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2201 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2212 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2213 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2215 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2223 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2226 mParentLayerComboBox->addItem( initialParent, initialParent );
2227 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2232 mExpressionTypeComboBox->setCurrentIndex( -1 );
2234 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast< int >( expParam->expressionType() ) ) );
2236 mExpressionTypeComboBox->setCurrentIndex( 0 );
2238 vlayout->addWidget( mExpressionTypeComboBox );
2240 setLayout( vlayout );
2243QgsProcessingParameterDefinition *QgsProcessingExpressionParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
2247 switch ( expressionType )
2250 expression = mDefaultQgisLineEdit->expression();
2253 expression = mDefaultPointCloudLineEdit->expression();
2256 expression = mDefaultRasterCalculatorLineEdit->expression();
2259 auto param = std::make_unique< QgsProcessingParameterExpression >( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2260 param->setFlags( flags );
2261 return param.release();
2270QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2282 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2283 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2284 mExpLineEdit->registerExpressionContextGenerator(
this );
2287 emit widgetValueHasChanged(
this );
2289 return mExpLineEdit;
2295 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2296 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2297 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2299 emit widgetValueHasChanged(
this );
2301 return mPointCloudExpLineEdit;
2306 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2307 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2310 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2312 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2314 emit widgetValueHasChanged(
this );
2316 return mRasterCalculatorExpLineEdit;
2320 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
2323 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2324 mExpBuilderWidget->init( createExpressionContext() );
2327 Q_UNUSED( changed );
2328 emit widgetValueHasChanged(
this );
2330 return mExpBuilderWidget;
2335 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2336 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2337 mFieldExpWidget->registerExpressionContextGenerator(
this );
2339 mFieldExpWidget->setAllowEmptyFieldName(
true );
2343 emit widgetValueHasChanged(
this );
2345 return mFieldExpWidget;
2353void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2365 setParentLayerWrapperValue( wrapper );
2368 setParentLayerWrapperValue( wrapper );
2384 if ( mExpBuilderWidget )
2387 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2395 std::unique_ptr< QgsProcessingContext > tmpContext;
2396 if ( mProcessingContextGenerator )
2397 context = mProcessingContextGenerator->processingContext();
2401 tmpContext = std::make_unique< QgsProcessingContext >();
2402 context = tmpContext.get();
2412 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2422 if ( mFieldExpWidget )
2423 mFieldExpWidget->setLayer(
nullptr );
2424 else if ( mExpBuilderWidget )
2425 mExpBuilderWidget->setLayer(
nullptr );
2426 else if ( mExpLineEdit )
2427 mExpLineEdit->setLayer(
nullptr );
2433 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
2436 mParentLayer.reset( ownedLayer.release() );
2444 if ( mFieldExpWidget )
2445 mFieldExpWidget->setLayer( layer );
2446 if ( mExpBuilderWidget )
2447 mExpBuilderWidget->setLayer( layer );
2448 else if ( mExpLineEdit )
2449 mExpLineEdit->setLayer( layer );
2458 if ( mPointCloudExpLineEdit )
2459 mPointCloudExpLineEdit->setLayer(
nullptr );
2465 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
2468 mParentLayer.reset( ownedLayer.release() );
2476 if ( mPointCloudExpLineEdit )
2477 mPointCloudExpLineEdit->setLayer( layer );
2484 if ( layers.isEmpty() )
2486 if ( mRasterCalculatorExpLineEdit )
2488 mRasterCalculatorExpLineEdit->setLayers( val.type() == QVariant::List ? val.toList() : QVariantList() << val );
2493 if ( mRasterCalculatorExpLineEdit )
2495 QVariantList layersList;
2498 layersList << layer->
name();
2500 mRasterCalculatorExpLineEdit->setLayers( layersList );
2508void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2511 if ( mFieldExpWidget )
2512 mFieldExpWidget->setExpression( v );
2513 else if ( mExpBuilderWidget )
2514 mExpBuilderWidget->setExpressionText( v );
2515 else if ( mExpLineEdit )
2516 mExpLineEdit->setExpression( v );
2517 else if ( mPointCloudExpLineEdit )
2518 mPointCloudExpLineEdit->setExpression( v );
2519 else if ( mRasterCalculatorExpLineEdit )
2520 mRasterCalculatorExpLineEdit->setExpression( v );
2523QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2525 if ( mFieldExpWidget )
2526 return mFieldExpWidget->expression();
2527 if ( mExpBuilderWidget )
2528 return mExpBuilderWidget->expressionText();
2529 else if ( mExpLineEdit )
2530 return mExpLineEdit->expression();
2531 else if ( mPointCloudExpLineEdit )
2532 return mPointCloudExpLineEdit->expression();
2533 else if ( mRasterCalculatorExpLineEdit )
2534 return mRasterCalculatorExpLineEdit->expression();
2539QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
const
2541 return QStringList()
2551QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
const
2553 return QStringList()
2558QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2560 return tr(
"string representation of an expression" );
2563const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
2565 if ( mFieldExpWidget && mFieldExpWidget->layer() )
2566 return mFieldExpWidget->layer();
2568 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
2569 return mExpBuilderWidget->layer();
2574QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
2581 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
2586 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2599 QHBoxLayout *hl =
new QHBoxLayout();
2600 hl->setContentsMargins( 0, 0, 0, 0 );
2602 mLineEdit =
new QLineEdit();
2603 mLineEdit->setEnabled(
false );
2604 hl->addWidget( mLineEdit, 1 );
2606 mToolButton =
new QToolButton();
2607 mToolButton->setText( QString( QChar( 0x2026 ) ) );
2608 hl->addWidget( mToolButton );
2614 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2617 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
2620void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
2622 if ( value.isValid() )
2624 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
2626 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
2632 updateSummaryText();
2636void QgsProcessingEnumPanelWidget::showDialog()
2638 QVariantList availableOptions;
2641 availableOptions.reserve( mParam->options().size() );
2643 if ( mParam->usesStaticStrings() )
2645 for ( QString o : mParam->options() )
2647 availableOptions << o;
2652 for (
int i = 0; i < mParam->options().count(); ++i )
2653 availableOptions << i;
2657 const QStringList options = mParam ? mParam->options() : QStringList();
2661 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
2662 widget->setPanelTitle( mParam->description() );
2664 if ( mParam->usesStaticStrings() )
2666 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
2668 const QString i = v.toString();
2669 return options.contains( i ) ? i : QString();
2674 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
2676 const int i = v.toInt();
2677 return options.size() > i ? options.at( i ) : QString();
2681 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
2683 setValue( widget->selectedOptions() );
2690 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
2692 dlg.setValueFormatter( [options](
const QVariant & v ) -> QString
2694 const int i = v.toInt();
2695 return options.size() > i ? options.at( i ) : QString();
2699 setValue( dlg.selectedOptions() );
2704void QgsProcessingEnumPanelWidget::updateSummaryText()
2709 if ( mValue.empty() )
2711 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2716 values.reserve( mValue.size() );
2717 if ( mParam->usesStaticStrings() )
2719 for (
const QVariant &val : std::as_const( mValue ) )
2721 values << val.toString();
2726 const QStringList options = mParam->options();
2727 for (
const QVariant &val : std::as_const( mValue ) )
2729 const int i = val.toInt();
2730 values << ( options.size() > i ? options.at( i ) : QString() );
2734 const QString concatenated = values.join( tr(
"," ) );
2735 if ( concatenated.length() < 100 )
2736 mLineEdit->setText( concatenated );
2738 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
2746QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
2749 , mButtonGroup( new QButtonGroup( this ) )
2750 , mColumns( columns )
2752 mButtonGroup->setExclusive( !mParam->allowMultiple() );
2754 QGridLayout *l =
new QGridLayout();
2755 l->setContentsMargins( 0, 0, 0, 0 );
2757 int rows =
static_cast< int >( std::ceil( mParam->options().count() /
static_cast< double >( mColumns ) ) );
2758 for (
int i = 0; i < mParam->options().count(); ++i )
2760 QAbstractButton *button =
nullptr;
2761 if ( mParam->allowMultiple() )
2762 button =
new QCheckBox( mParam->options().at( i ) );
2764 button =
new QRadioButton( mParam->options().at( i ) );
2766 connect( button, &QAbstractButton::toggled,
this, [ = ]
2768 if ( !mBlockChangedSignal )
2772 mButtons.insert( i, button );
2774 mButtonGroup->addButton( button, i );
2775 l->addWidget( button, i % rows, i / rows );
2777 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
2780 if ( mParam->allowMultiple() )
2782 setContextMenuPolicy( Qt::CustomContextMenu );
2783 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
2787QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
2789 if ( mParam->allowMultiple() )
2792 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2794 if ( it.value()->isChecked() )
2795 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
2801 if ( mParam->usesStaticStrings() )
2802 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
2804 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
2808void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
2810 mBlockChangedSignal =
true;
2811 if ( mParam->allowMultiple() )
2813 QVariantList selected;
2814 if ( value.isValid() )
2815 selected = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
2816 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2818 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
2819 it.value()->setChecked( selected.contains( v ) );
2825 if ( v.type() == QVariant::List )
2826 v = v.toList().value( 0 );
2828 v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
2829 if ( mButtons.contains( v ) )
2830 mButtons.value( v )->setChecked(
true );
2832 mBlockChangedSignal =
false;
2836void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
2839 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
2840 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
2841 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
2842 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
2843 popupMenu.addAction( selectAllAction );
2844 popupMenu.addAction( clearAllAction );
2845 popupMenu.exec( QCursor::pos() );
2848void QgsProcessingEnumCheckboxPanelWidget::selectAll()
2850 mBlockChangedSignal =
true;
2851 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2852 it.value()->setChecked(
true );
2853 mBlockChangedSignal =
false;
2857void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
2859 mBlockChangedSignal =
true;
2860 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2861 it.value()->setChecked(
false );
2862 mBlockChangedSignal =
false;
2874 QVBoxLayout *vlayout =
new QVBoxLayout();
2875 vlayout->setContentsMargins( 0, 0, 0, 0 );
2877 mEnumWidget =
new QgsProcessingEnumModelerWidget();
2880 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
2881 mEnumWidget->setOptions( enumParam->options() );
2882 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
2884 vlayout->addWidget( mEnumWidget );
2885 setLayout( vlayout );
2888QgsProcessingParameterDefinition *QgsProcessingEnumParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
2890 auto param = std::make_unique< QgsProcessingParameterEnum >( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
2892 return param.release();
2902QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
2910 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
2912 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
2913 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
2914 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
2915 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [ = ]
2917 emit widgetValueHasChanged(
this );
2919 return mCheckboxPanel;
2928 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
2929 mPanel->setToolTip( parameterDefinition()->toolTip() );
2930 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [ = ]
2932 emit widgetValueHasChanged(
this );
2938 mComboBox =
new QComboBox();
2941 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
2942 const QStringList options = expParam->
options();
2943 const QVariantList iconList = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"icons" ) ).toList();
2944 for (
int i = 0; i < options.count(); ++i )
2946 const QIcon icon = iconList.value( i ).value< QIcon >();
2949 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
2951 mComboBox->addItem( icon, options.at( i ), i );
2954 mComboBox->setToolTip( parameterDefinition()->toolTip() );
2955 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
2956 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2958 emit widgetValueHasChanged(
this );
2967void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2971 if ( !value.isValid() )
2972 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
2979 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
2984 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
2988 else if ( mPanel || mCheckboxPanel )
2991 if ( value.isValid() )
2997 opts.reserve( v.size() );
2998 for ( QString i : v )
3004 opts.reserve( v.size() );
3010 mPanel->setValue( opts );
3011 else if ( mCheckboxPanel )
3012 mCheckboxPanel->setValue( opts );
3016QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3019 return mComboBox->currentData();
3021 return mPanel->value();
3022 else if ( mCheckboxPanel )
3023 return mCheckboxPanel->value();
3028QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
const
3030 return QStringList()
3036QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
const
3038 return QStringList()
3044QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3046 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3049QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3056 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3061 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3074QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3083 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() : nullptr );
3088 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3091 emit widgetValueHasChanged(
this );
3098 mPlainComboBox =
new QComboBox();
3099 mPlainComboBox->setEditable(
true );
3100 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3101 if ( widgetContext().project() )
3105 mPlainComboBox->addItem( layout->name() );
3108 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
3110 emit widgetValueHasChanged(
this );
3112 return mPlainComboBox;
3118void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3122 if ( !value.isValid() )
3123 mComboBox->setCurrentLayout(
nullptr );
3127 mComboBox->setCurrentLayout( l );
3129 mComboBox->setCurrentLayout(
nullptr );
3132 else if ( mPlainComboBox )
3135 mPlainComboBox->setCurrentText( v );
3139QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3144 return l ? l->
name() : QVariant();
3146 else if ( mPlainComboBox )
3147 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3155 if ( mPlainComboBox && context.
project() )
3159 mPlainComboBox->addItem( layout->name() );
3163QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
const
3165 return QStringList()
3171QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
const
3173 return QStringList()
3177QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3179 return tr(
"string representing the name of an existing print layout" );
3182QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3189 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3203 QVBoxLayout *vlayout =
new QVBoxLayout();
3204 vlayout->setContentsMargins( 0, 0, 0, 0 );
3206 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3208 mParentLayoutComboBox =
new QComboBox();
3209 QString initialParent;
3211 initialParent = itemParam->parentLayoutParameterName();
3213 if (
auto *lModel = widgetContext.
model() )
3216 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3217 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3221 mParentLayoutComboBox-> addItem( definition->
description(), definition->
name() );
3222 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3224 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3230 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3233 mParentLayoutComboBox->addItem( initialParent, initialParent );
3234 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3237 vlayout->addWidget( mParentLayoutComboBox );
3238 setLayout( vlayout );
3240QgsProcessingParameterDefinition *QgsProcessingLayoutItemParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
3242 auto param = std::make_unique< QgsProcessingParameterLayoutItem >( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3244 return param.release();
3254QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3265 mComboBox->setAllowEmptyItem(
true );
3266 if ( layoutParam->
itemType() >= 0 )
3269 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3272 emit widgetValueHasChanged(
this );
3279 mLineEdit =
new QLineEdit();
3280 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3281 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3283 emit widgetValueHasChanged(
this );
3291void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3319void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3325 std::unique_ptr< QgsProcessingContext > tmpContext;
3326 if ( mProcessingContextGenerator )
3327 context = mProcessingContextGenerator->processingContext();
3331 tmpContext = std::make_unique< QgsProcessingContext >();
3332 context = tmpContext.get();
3336 setLayout( layout );
3339void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3342 mComboBox->setCurrentLayout( layout );
3345void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3349 if ( !value.isValid() )
3350 mComboBox->setItem(
nullptr );
3354 mComboBox->setItem( item );
3357 else if ( mLineEdit )
3360 mLineEdit->setText( v );
3364QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3369 return i ? i->
uuid() : QVariant();
3371 else if ( mLineEdit )
3372 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3377QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
const
3379 return QStringList()
3384QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
const
3386 return QStringList()
3391QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3393 return tr(
"string representing the UUID or ID of an existing print layout item" );
3396QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3403 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3408 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3415QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3422QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3424void QgsProcessingPointMapTool::deactivate()
3438 if ( e->button() == Qt::LeftButton )
3441 emit clicked( point );
3446void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3448 if ( e->key() == Qt::Key_Escape )
3463QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3466 QHBoxLayout *l =
new QHBoxLayout();
3467 l->setContentsMargins( 0, 0, 0, 0 );
3469 mLineEdit->setShowClearButton(
false );
3470 l->addWidget( mLineEdit, 1 );
3471 mButton =
new QToolButton();
3472 mButton->setText( QString( QChar( 0x2026 ) ) );
3473 l->addWidget( mButton );
3476 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3477 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3478 mButton->setVisible(
false );
3481void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
3484 mButton->setVisible(
true );
3487 mTool = std::make_unique< QgsProcessingPointMapTool >( mCanvas );
3488 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
3489 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
3492void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
3494 mLineEdit->setShowClearButton( allowNull );
3497QVariant QgsProcessingPointPanel::value()
const
3499 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
3502void QgsProcessingPointPanel::clear()
3509 QString newText = QStringLiteral(
"%1,%2" )
3510 .arg( QString::number( point.
x(),
'f' ),
3511 QString::number( point.
y(),
'f' ) );
3514 if ( mCrs.isValid() )
3516 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
3518 mLineEdit->setText( newText );
3521void QgsProcessingPointPanel::selectOnCanvas()
3526 mPrevTool = mCanvas->mapTool();
3527 mCanvas->setMapTool( mTool.get() );
3529 emit toggleDialogVisibility(
false );
3532void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3534 setValue( point, mCanvas->mapSettings().destinationCrs() );
3537void QgsProcessingPointPanel::pointPicked()
3542 mCanvas->setMapTool( mPrevTool );
3544 emit toggleDialogVisibility(
true );
3556 QVBoxLayout *vlayout =
new QVBoxLayout();
3557 vlayout->setContentsMargins( 0, 0, 0, 0 );
3559 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3561 mDefaultLineEdit =
new QLineEdit();
3562 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3563 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
3567 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
3570 vlayout->addWidget( mDefaultLineEdit );
3571 setLayout( vlayout );
3574QgsProcessingParameterDefinition *QgsProcessingPointParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
3576 auto param = std::make_unique< QgsProcessingParameterPoint >( name, description, mDefaultLineEdit->text() );
3578 return param.release();
3587QWidget *QgsProcessingPointWidgetWrapper::createWidget()
3595 mPanel =
new QgsProcessingPointPanel(
nullptr );
3596 if ( widgetContext().mapCanvas() )
3597 mPanel->setMapCanvas( widgetContext().mapCanvas() );
3600 mPanel->setAllowNull(
true );
3602 mPanel->setToolTip( parameterDefinition()->toolTip() );
3604 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [ = ]
3606 emit widgetValueHasChanged(
this );
3610 setDialog( mDialog );
3616 mLineEdit =
new QLineEdit();
3617 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3618 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3620 emit widgetValueHasChanged(
this );
3632 mPanel->setMapCanvas( context.
mapCanvas() );
3635void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
3640 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ](
bool visible )
3643 mDialog->showMinimized();
3646 mDialog->showNormal();
3648 mDialog->activateWindow();
3655void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3659 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
3665 mPanel->setValue( p,
crs );
3668 else if ( mLineEdit )
3671 mLineEdit->setText( v );
3675QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
3679 return mPanel->value();
3681 else if ( mLineEdit )
3682 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3687QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
const
3689 return QStringList()
3695QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
const
3697 return QStringList()
3701QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
3703 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
3706QString QgsProcessingPointWidgetWrapper::parameterType()
const
3713 return new QgsProcessingPointWidgetWrapper( parameter, type );
3718 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3730 QVBoxLayout *vlayout =
new QVBoxLayout();
3731 vlayout->setContentsMargins( 0, 0, 0, 0 );
3733 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3735 mDefaultLineEdit =
new QLineEdit();
3736 mDefaultLineEdit->setToolTip( tr(
"Geometry as WKT" ) );
3737 mDefaultLineEdit->setPlaceholderText( tr(
"Geometry as WKT" ) );
3742 mDefaultLineEdit->setText( g.
asWkt() );
3745 vlayout->addWidget( mDefaultLineEdit );
3746 setLayout( vlayout );
3749QgsProcessingParameterDefinition *QgsProcessingGeometryParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
3751 auto param = std::make_unique< QgsProcessingParameterGeometry >( name, description, mDefaultLineEdit->text() );
3753 return param.release();
3762QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
3770 mLineEdit =
new QLineEdit();
3771 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
3772 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
3774 emit widgetValueHasChanged(
this );
3782void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3788 mLineEdit->setText( g.
asWkt() );
3794QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
3797 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3802QStringList QgsProcessingGeometryWidgetWrapper::compatibleParameterTypes()
const
3804 return QStringList()
3812QStringList QgsProcessingGeometryWidgetWrapper::compatibleOutputTypes()
const
3814 return QStringList()
3818QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
3820 return tr(
"string in the Well-Known-Text format or a geometry value" );
3823QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
3830 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
3835 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3847 QVBoxLayout *vlayout =
new QVBoxLayout();
3848 vlayout->setContentsMargins( 0, 0, 0, 0 );
3850 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3853 mDefaultColorButton->setShowNull(
true );
3854 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
3860 mDefaultColorButton->setToNull();
3862 mDefaultColorButton->setColor(
c );
3863 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
3867 mDefaultColorButton->setToNull();
3868 mAllowOpacity->setChecked(
true );
3871 vlayout->addWidget( mDefaultColorButton );
3872 vlayout->addWidget( mAllowOpacity );
3873 setLayout( vlayout );
3876QgsProcessingParameterDefinition *QgsProcessingColorParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
3878 auto param = std::make_unique< QgsProcessingParameterColor >( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
3880 return param.release();
3889QWidget *QgsProcessingColorWidgetWrapper::createWidget()
3899 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
3902 mColorButton->setShowNull(
true );
3905 mColorButton->setToolTip( parameterDefinition()->toolTip() );
3906 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
3914 emit widgetValueHasChanged(
this );
3917 return mColorButton;
3923void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3927 if ( !value.isValid() ||
3928 ( value.type() == QVariant::String && value.toString().isEmpty() )
3929 || ( value.type() == QVariant::Color && !value.value< QColor >().isValid() ) )
3930 mColorButton->setToNull();
3934 if ( !
c.isValid() && mColorButton->showNull() )
3935 mColorButton->setToNull();
3937 mColorButton->setColor(
c );
3942QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
3945 return mColorButton->isNull() ? QVariant() : mColorButton->color();
3950QStringList QgsProcessingColorWidgetWrapper::compatibleParameterTypes()
const
3952 return QStringList()
3958QStringList QgsProcessingColorWidgetWrapper::compatibleOutputTypes()
const
3960 return QStringList()
3964QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
3966 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
3969QString QgsProcessingColorWidgetWrapper::parameterType()
const
3976 return new QgsProcessingColorWidgetWrapper( parameter, type );
3981 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3992 QVBoxLayout *vlayout =
new QVBoxLayout();
3993 vlayout->setContentsMargins( 0, 0, 0, 0 );
3995 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3997 mDefaultLineEdit =
new QLineEdit();
4000 vlayout->addWidget( mDefaultLineEdit );
4002 mSourceParamComboBox =
new QComboBox();
4003 mDestParamComboBox =
new QComboBox();
4004 QString initialSource;
4005 QString initialDest;
4010 initialSource = itemParam->sourceCrsParameterName();
4011 initialDest = itemParam->destinationCrsParameterName();
4016 mSourceParamComboBox->addItem( QString(), QString() );
4017 mDestParamComboBox->addItem( QString(), QString() );
4018 if (
auto *lModel = widgetContext.
model() )
4021 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4022 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4024 if ( definition && it->parameterName() == definition->
name() )
4028 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4029 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4030 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4032 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4034 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4036 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4041 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4044 mSourceParamComboBox->addItem( initialSource, initialSource );
4045 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4047 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4050 mDestParamComboBox->addItem( initialDest, initialDest );
4051 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4054 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4055 vlayout->addWidget( mSourceParamComboBox );
4056 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4057 vlayout->addWidget( mDestParamComboBox );
4061 mStaticSourceWidget->setCrs( sourceCrs );
4064 mStaticDestWidget->setCrs( destCrs );
4066 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4067 vlayout->addWidget( mStaticSourceWidget );
4068 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4069 vlayout->addWidget( mStaticDestWidget );
4071 setLayout( vlayout );
4074QgsProcessingParameterDefinition *QgsProcessingCoordinateOperationParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
4076 auto param = std::make_unique< QgsProcessingParameterCoordinateOperation >( name, description, mDefaultLineEdit->text(),
4077 mSourceParamComboBox->currentText(),
4078 mDestParamComboBox->currentText(),
4079 mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
4080 mStaticDestWidget->
crs().isValid() ? QVariant::fromValue( mStaticDestWidget->
crs() ) : QVariant() );
4082 return param.release();
4091QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4102 mOperationWidget->setShowMakeDefault(
false );
4103 mOperationWidget->setShowFallbackOption(
false );
4104 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4105 mOperationWidget->setSourceCrs( mSourceCrs );
4106 mOperationWidget->setDestinationCrs( mDestCrs );
4107 mOperationWidget->setMapCanvas( mCanvas );
4112 mOperationWidget->setSelectedOperation( deets );
4117 emit widgetValueHasChanged(
this );
4120 return mOperationWidget;
4126 mLineEdit =
new QLineEdit();
4127 QHBoxLayout *layout =
new QHBoxLayout();
4128 layout->addWidget( mLineEdit, 1 );
4129 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4131 emit widgetValueHasChanged(
this );
4134 QToolButton *button =
new QToolButton();
4135 button->setText( QString( QChar( 0x2026 ) ) );
4136 connect( button, &QToolButton::clicked,
this, [ = ]
4138 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4141 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4142 emit widgetValueHasChanged(
this );
4145 layout->addWidget( button );
4147 QWidget *w =
new QWidget();
4148 layout->setContentsMargins( 0, 0, 0, 0 );
4149 w->setLayout( layout );
4157void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4195 if ( mOperationWidget )
4196 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4199void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4201 if ( mOperationWidget )
4203 if ( !value.isValid() ||
4204 ( value.type() == QVariant::String ) )
4207 deets.
proj = value.toString();
4208 mOperationWidget->setSelectedOperation( deets );
4213 if ( !value.isValid() ||
4214 ( value.type() == QVariant::String ) )
4216 mLineEdit->setText( value.toString() );
4221QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4223 if ( mOperationWidget )
4224 return mOperationWidget->selectedOperation().proj;
4225 else if ( mLineEdit )
4226 return mLineEdit->text();
4231QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleParameterTypes()
const
4233 return QStringList()
4238QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleOutputTypes()
const
4240 return QStringList()
4245QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4247 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4250void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4253 std::unique_ptr< QgsProcessingContext > tmpContext;
4254 if ( mProcessingContextGenerator )
4255 context = mProcessingContextGenerator->processingContext();
4259 tmpContext = std::make_unique< QgsProcessingContext >();
4260 context = tmpContext.get();
4264 if ( mOperationWidget )
4266 mOperationWidget->setSourceCrs( mSourceCrs );
4267 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4271void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4274 std::unique_ptr< QgsProcessingContext > tmpContext;
4275 if ( mProcessingContextGenerator )
4276 context = mProcessingContextGenerator->processingContext();
4280 tmpContext = std::make_unique< QgsProcessingContext >();
4281 context = tmpContext.get();
4285 if ( mOperationWidget )
4287 mOperationWidget->setDestinationCrs( mDestCrs );
4288 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4292QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
4299 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
4304 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4317 QHBoxLayout *hl =
new QHBoxLayout();
4318 hl->setContentsMargins( 0, 0, 0, 0 );
4320 mLineEdit =
new QLineEdit();
4321 mLineEdit->setEnabled(
false );
4322 hl->addWidget( mLineEdit, 1 );
4324 mToolButton =
new QToolButton();
4325 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4326 hl->addWidget( mToolButton );
4332 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4335 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4338void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4343void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4345 if ( value.isValid() )
4346 mValue = value.type() == QVariant::List ? value.
toList() : QVariantList() << value;
4350 updateSummaryText();
4354void QgsProcessingFieldPanelWidget::showDialog()
4356 QVariantList availableOptions;
4357 availableOptions.reserve( mFields.size() );
4358 for (
const QgsField &field : std::as_const( mFields ) )
4360 availableOptions << field.name();
4366 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4367 widget->setPanelTitle( mParam->description() );
4369 widget->setValueFormatter( [](
const QVariant & v ) -> QString
4371 return v.toString();
4374 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
4376 setValue( widget->selectedOptions() );
4383 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4385 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
4387 return v.toString();
4391 setValue( dlg.selectedOptions() );
4396void QgsProcessingFieldPanelWidget::updateSummaryText()
4401 if ( mValue.empty() )
4403 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4408 values.reserve( mValue.size() );
4409 for (
const QVariant &val : std::as_const( mValue ) )
4411 values << val.toString();
4414 const QString concatenated = values.join( tr(
"," ) );
4415 if ( concatenated.length() < 100 )
4416 mLineEdit->setText( concatenated );
4418 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4430 QVBoxLayout *vlayout =
new QVBoxLayout();
4431 vlayout->setContentsMargins( 0, 0, 0, 0 );
4433 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4434 mParentLayerComboBox =
new QComboBox();
4436 QString initialParent;
4438 initialParent = fieldParam->parentLayerParameterName();
4440 if (
auto *lModel = widgetContext.
model() )
4443 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4444 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4448 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4449 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4451 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4456 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4457 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4459 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4466 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4467 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4469 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4476 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4479 mParentLayerComboBox->addItem( initialParent, initialParent );
4480 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4483 vlayout->addWidget( mParentLayerComboBox );
4485 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4486 mDataTypeComboBox =
new QComboBox();
4494 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast< int >( fieldParam->dataType() ) ) );
4496 vlayout->addWidget( mDataTypeComboBox );
4498 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4500 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4502 vlayout->addWidget( mAllowMultipleCheckBox );
4504 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4505 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4507 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4509 vlayout->addWidget( mDefaultToAllCheckBox );
4511 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
4513 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4516 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4518 mDefaultLineEdit =
new QLineEdit();
4519 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4523 mDefaultLineEdit->setText( fields.join(
';' ) );
4525 vlayout->addWidget( mDefaultLineEdit );
4527 setLayout( vlayout );
4530QgsProcessingParameterDefinition *QgsProcessingFieldParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
4534 QVariant defaultValue;
4535 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4537 defaultValue = mDefaultLineEdit->text();
4539 auto param = std::make_unique< QgsProcessingParameterField >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
4541 return param.release();
4550QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
4560 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
4561 mPanel->setToolTip( parameterDefinition()->toolTip() );
4562 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [ = ]
4564 emit widgetValueHasChanged(
this );
4584 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4587 emit widgetValueHasChanged(
this );
4595 mLineEdit =
new QLineEdit();
4596 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
4597 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4599 emit widgetValueHasChanged(
this );
4608void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4620 setParentLayerWrapperValue( wrapper );
4623 setParentLayerWrapperValue( wrapper );
4640 std::unique_ptr< QgsProcessingContext > tmpContext;
4641 if ( mProcessingContextGenerator )
4642 context = mProcessingContextGenerator->processingContext();
4646 tmpContext = std::make_unique< QgsProcessingContext >();
4647 context = tmpContext.get();
4652 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
4662 bool valueSet =
false;
4666 if ( layers.count() > 1 )
4668 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
4670 const QList< QgsMapLayer * > remainingLayers = layers.mid( 1 );
4676 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer );
4677 if ( !vlayer || !vlayer->
isValid() )
4683 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
4686 fields.
remove( fieldIdx );
4691 mComboBox->setFields( fields );
4693 mPanel->setFields( filterFields( fields ) );
4699 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
4701 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
4705 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
4708 mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
4709 layer = mParentLayer.get();
4717 mComboBox->setLayer( layer );
4719 mPanel->setFields( filterFields( layer->
fields() ) );
4729 const QgsFields fields = source->fields();
4731 mComboBox->setFields( fields );
4733 mPanel->setFields( filterFields( fields ) );
4742 mComboBox->setLayer(
nullptr );
4746 if ( value.isValid() && widgetContext().messageBar() )
4749 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent field could not be populated" ),
4759 val.reserve( mPanel->fields().size() );
4760 for (
const QgsField &field : mPanel->fields() )
4761 val << field.name();
4762 setWidgetValue( val, *context );
4765 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
4768void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4772 if ( !value.isValid() )
4773 mComboBox->setField( QString() );
4777 mComboBox->setField( v );
4783 if ( value.isValid() )
4786 opts.reserve( v.size() );
4787 for (
const QString &i : v )
4791 mPanel->setValue( opts );
4793 else if ( mLineEdit )
4799 mLineEdit->setText( v.join(
';' ) );
4808QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
4811 return mComboBox->currentField();
4813 return mPanel->value();
4814 else if ( mLineEdit )
4819 return mLineEdit->text().split(
';' );
4822 return mLineEdit->text();
4828QStringList QgsProcessingFieldWidgetWrapper::compatibleParameterTypes()
const
4830 return QStringList()
4836QStringList QgsProcessingFieldWidgetWrapper::compatibleOutputTypes()
const
4838 return QStringList()
4842QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
4844 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
4847const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
4849 if ( mComboBox && mComboBox->layer() )
4850 return mComboBox->layer();
4855QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
4868 if ( f.isNumeric() )
4873 if ( f.type() == QVariant::String )
4878 if ( f.type() == QVariant::Date || f.type() == QVariant::Time || f.type() == QVariant::DateTime )
4883 if ( f.type() == QVariant::ByteArray )
4888 if ( f.type() == QVariant::Bool )
4897QString QgsProcessingFieldWidgetWrapper::parameterType()
const
4904 return new QgsProcessingFieldWidgetWrapper( parameter, type );
4909 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4920 QVBoxLayout *vlayout =
new QVBoxLayout();
4921 vlayout->setContentsMargins( 0, 0, 0, 0 );
4923 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4925 mDefaultComboBox =
new QComboBox();
4926 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
4929 for (
const QString &theme : mapThemes )
4933 mDefaultComboBox->setEditable(
true );
4937 if ( themeParam->defaultValueForGui().isValid() )
4940 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
4943 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
4945 vlayout->addWidget( mDefaultComboBox );
4947 setLayout( vlayout );
4950QgsProcessingParameterDefinition *QgsProcessingMapThemeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
4952 QVariant defaultVal;
4953 if ( mDefaultComboBox->currentText().isEmpty() )
4954 defaultVal = QVariant();
4956 defaultVal = mDefaultComboBox->currentText();
4957 auto param = std::make_unique< QgsProcessingParameterMapTheme>( name, description, defaultVal );
4959 return param.release();
4969QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
4973 mComboBox =
new QComboBox();
4976 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
4979 for (
const QString &theme : mapThemes )
4991 mComboBox->setEditable(
true );
4995 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4996 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
4998 emit widgetValueHasChanged(
this );
5004void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5008 if ( !value.isValid() )
5009 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5012 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5014 const QString prev = mComboBox->currentText();
5015 mComboBox->setCurrentText( v );
5017 emit widgetValueHasChanged(
this );
5020 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5024QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5027 return mComboBox->currentData().toInt() == -1 ? QVariant() :
5028 !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5029 : mComboBox->currentData();
5034QStringList QgsProcessingMapThemeWidgetWrapper::compatibleParameterTypes()
const
5036 return QStringList()
5042QStringList QgsProcessingMapThemeWidgetWrapper::compatibleOutputTypes()
const
5044 return QStringList()
5048QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5050 return tr(
"map theme as a string value (e.g. 'base maps')" );
5053QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5060 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5065 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5078 QVBoxLayout *vlayout =
new QVBoxLayout();
5079 vlayout->setContentsMargins( 0, 0, 0, 0 );
5081 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5083 mTypeComboBox =
new QComboBox();
5088 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast< int >( datetimeParam->dataType() ) ) );
5090 mTypeComboBox->setCurrentIndex( 0 );
5091 vlayout->addWidget( mTypeComboBox );
5093 setLayout( vlayout );
5096QgsProcessingParameterDefinition *QgsProcessingDateTimeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
5098 auto param = std::make_unique< QgsProcessingParameterDateTime >( name, description );
5101 return param.release();
5111QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5116 switch ( dateTimeParam->
dataType() )
5120 widget = mDateTimeEdit;
5143 widget->setToolTip( parameterDefinition()->toolTip() );
5145 if ( mDateTimeEdit )
5149 emit widgetValueHasChanged(
this );
5152 else if ( mDateEdit )
5156 emit widgetValueHasChanged(
this );
5159 else if ( mTimeEdit )
5163 emit widgetValueHasChanged(
this );
5172 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5175void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5177 if ( mDateTimeEdit )
5181 else if ( mDateEdit )
5185 else if ( mTimeEdit )
5191QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5193 if ( mDateTimeEdit )
5194 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5195 else if ( mDateEdit )
5196 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5197 else if ( mTimeEdit )
5198 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5203QStringList QgsProcessingDateTimeWidgetWrapper::compatibleParameterTypes()
const
5205 return QStringList()
5210QStringList QgsProcessingDateTimeWidgetWrapper::compatibleOutputTypes()
const
5212 return QStringList()
5217QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5220 if ( dateTimeParam )
5222 switch ( dateTimeParam->
dataType() )
5225 return tr(
"datetime value, or a ISO string representation of a datetime" );
5228 return tr(
"date value, or a ISO string representation of a date" );
5231 return tr(
"time value, or a ISO string representation of a time" );
5237QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5244 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5258 QVBoxLayout *vlayout =
new QVBoxLayout();
5259 vlayout->setContentsMargins( 0, 0, 0, 0 );
5261 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5262 mProviderComboBox =
new QComboBox();
5263 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
5264 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
5265 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
5267 vlayout->addWidget( mProviderComboBox );
5269 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5271 mDefaultEdit =
new QLineEdit();
5272 vlayout->addWidget( mDefaultEdit );
5273 setLayout( vlayout );
5275 if ( connectionParam )
5277 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5282QgsProcessingParameterDefinition *QgsProcessingProviderConnectionParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
5284 QVariant defaultVal;
5285 if ( mDefaultEdit->text().isEmpty() )
5286 defaultVal = QVariant();
5288 defaultVal = mDefaultEdit->text();
5289 auto param = std::make_unique< QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5291 return param.release();
5301QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5307 mProviderComboBox->setAllowEmptyConnection(
true );
5315 mProviderComboBox->setEditable(
true );
5319 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5320 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [ = ](
const QString & )
5322 if ( mBlockSignals )
5325 emit widgetValueHasChanged(
this );
5328 return mProviderComboBox;
5333 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5336void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5340 if ( !value.isValid() )
5341 mProviderComboBox->setCurrentIndex( -1 );
5344 if ( mProviderComboBox->isEditable() )
5346 const QString prev = mProviderComboBox->currentText();
5348 mProviderComboBox->setConnection( v );
5349 mProviderComboBox->setCurrentText( v );
5353 emit widgetValueHasChanged(
this );
5356 mProviderComboBox->setConnection( v );
5360QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5362 if ( mProviderComboBox )
5363 if ( mProviderComboBox->isEditable() )
5364 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5366 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5371QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleParameterTypes()
const
5373 return QStringList()
5380QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleOutputTypes()
const
5382 return QStringList()
5386QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5388 return tr(
"connection name as a string value" );
5391QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5398 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5413 QVBoxLayout *vlayout =
new QVBoxLayout();
5414 vlayout->setContentsMargins( 0, 0, 0, 0 );
5416 mConnectionParamComboBox =
new QComboBox();
5417 QString initialConnection;
5423 if (
auto *lModel = widgetContext.
model() )
5426 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5427 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5429 if ( definition && it->parameterName() == definition->
name() )
5435 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5436 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5438 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5443 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5446 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5447 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5450 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5451 vlayout->addWidget( mConnectionParamComboBox );
5453 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5455 mDefaultEdit =
new QLineEdit();
5456 vlayout->addWidget( mDefaultEdit );
5457 setLayout( vlayout );
5465QgsProcessingParameterDefinition *QgsProcessingDatabaseSchemaParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
5467 QVariant defaultVal;
5468 if ( mDefaultEdit->text().isEmpty() )
5469 defaultVal = QVariant();
5471 defaultVal = mDefaultEdit->text();
5472 auto param = std::make_unique< QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5474 return param.release();
5484QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5490 mSchemaComboBox->setAllowEmptySchema(
true );
5498 mSchemaComboBox->comboBox()->setEditable(
true );
5502 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5503 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
5505 if ( mBlockSignals )
5508 emit widgetValueHasChanged( this );
5511 return mSchemaComboBox;
5516 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5523 std::unique_ptr< QgsProcessingContext > tmpContext;
5524 if ( mProcessingContextGenerator )
5525 context = mProcessingContextGenerator->processingContext();
5529 tmpContext = std::make_unique< QgsProcessingContext >();
5530 context = tmpContext.get();
5536 if ( mSchemaComboBox )
5537 mSchemaComboBox->setConnectionName( connection, qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId() );
5541 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5544void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5548 if ( !value.isValid() )
5549 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5552 if ( mSchemaComboBox->comboBox()->isEditable() )
5554 const QString prev = mSchemaComboBox->comboBox()->currentText();
5556 mSchemaComboBox->setSchema( v );
5557 mSchemaComboBox->comboBox()->setCurrentText( v );
5561 emit widgetValueHasChanged(
this );
5564 mSchemaComboBox->setSchema( v );
5568QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5570 if ( mSchemaComboBox )
5571 if ( mSchemaComboBox->comboBox()->isEditable() )
5572 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5574 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5579QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleParameterTypes()
const
5581 return QStringList()
5588QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleOutputTypes()
const
5590 return QStringList()
5594QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5596 return tr(
"database schema name as a string value" );
5599QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5606 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5609void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5621 setParentConnectionWrapperValue( wrapper );
5624 setParentConnectionWrapperValue( wrapper );
5648 QVBoxLayout *vlayout =
new QVBoxLayout();
5649 vlayout->setContentsMargins( 0, 0, 0, 0 );
5651 mConnectionParamComboBox =
new QComboBox();
5652 mSchemaParamComboBox =
new QComboBox();
5653 QString initialConnection;
5654 QString initialSchema;
5661 if (
auto *lModel = widgetContext.
model() )
5664 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5665 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5667 if ( definition && it->parameterName() == definition->
name() )
5672 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5673 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5675 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5680 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
5681 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5683 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5689 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5692 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5693 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5696 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
5699 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
5700 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5703 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5704 vlayout->addWidget( mConnectionParamComboBox );
5706 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
5707 vlayout->addWidget( mSchemaParamComboBox );
5709 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5711 mDefaultEdit =
new QLineEdit();
5712 vlayout->addWidget( mDefaultEdit );
5713 setLayout( vlayout );
5721QgsProcessingParameterDefinition *QgsProcessingDatabaseTableParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
5723 QVariant defaultVal;
5724 if ( mDefaultEdit->text().isEmpty() )
5725 defaultVal = QVariant();
5727 defaultVal = mDefaultEdit->text();
5728 auto param = std::make_unique< QgsProcessingParameterDatabaseTable>( name, description,
5729 mConnectionParamComboBox->currentData().toString(),
5730 mSchemaParamComboBox->currentData().toString(),
5733 return param.release();
5743QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
5749 mTableComboBox->setAllowEmptyTable(
true );
5752 mTableComboBox->comboBox()->setEditable(
true );
5754 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
5755 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
5757 if ( mBlockSignals )
5760 emit widgetValueHasChanged( this );
5763 return mTableComboBox;
5768 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5775 std::unique_ptr< QgsProcessingContext > tmpContext;
5776 if ( mProcessingContextGenerator )
5777 context = mProcessingContextGenerator->processingContext();
5781 tmpContext = std::make_unique< QgsProcessingContext >();
5782 context = tmpContext.get();
5787 mProvider = qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId();
5788 if ( mTableComboBox && !mSchema.isEmpty() )
5790 mTableComboBox->setSchema( mSchema );
5791 mTableComboBox->setConnectionName( mConnection, mProvider );
5795 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5803 std::unique_ptr< QgsProcessingContext > tmpContext;
5804 if ( mProcessingContextGenerator )
5805 context = mProcessingContextGenerator->processingContext();
5809 tmpContext = std::make_unique< QgsProcessingContext >();
5810 context = tmpContext.get();
5816 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
5818 mTableComboBox->setSchema( mSchema );
5819 mTableComboBox->setConnectionName( mConnection, mProvider );
5823 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5828void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5832 if ( !value.isValid() )
5833 mTableComboBox->comboBox()->setCurrentIndex( -1 );
5836 if ( mTableComboBox->comboBox()->isEditable() )
5838 const QString prev = mTableComboBox->comboBox()->currentText();
5840 mTableComboBox->setTable( v );
5841 mTableComboBox->comboBox()->setCurrentText( v );
5845 emit widgetValueHasChanged(
this );
5848 mTableComboBox->setTable( v );
5852QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
5854 if ( mTableComboBox )
5855 if ( mTableComboBox->comboBox()->isEditable() )
5856 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
5858 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
5863QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleParameterTypes()
const
5865 return QStringList()
5871QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleOutputTypes()
const
5873 return QStringList()
5878QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
5880 return tr(
"database table name as a string value" );
5883QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
5890 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
5893void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5905 setParentConnectionWrapperValue( wrapper );
5908 setParentConnectionWrapperValue( wrapper );
5913 setParentSchemaWrapperValue( wrapper );
5916 setParentSchemaWrapperValue( wrapper );
5936 QVBoxLayout *vlayout =
new QVBoxLayout();
5937 vlayout->setContentsMargins( 0, 0, 0, 0 );
5939 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5942 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
5945 if ( extentParam->defaultValueForGui().isValid() )
5949 mDefaultWidget->setCurrentExtent( rect,
crs );
5950 mDefaultWidget->setOutputExtentFromCurrent();
5954 mDefaultWidget->clear();
5958 vlayout->addWidget( mDefaultWidget );
5959 setLayout( vlayout );
5962QgsProcessingParameterDefinition *QgsProcessingExtentParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
5964 const QString defaultVal = mDefaultWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
5965 QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ),
5966 QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ),
5967 QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ),
5968 QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ),
5969 mDefaultWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mDefaultWidget->outputCrs().authid() ) : QString()
5971 auto param = std::make_unique< QgsProcessingParameterExtent >( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
5973 return param.release();
5984QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
5994 if ( widgetContext().mapCanvas() )
5995 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
5998 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6000 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6004 emit widgetValueHasChanged(
this );
6008 setDialog( mDialog );
6010 return mExtentWidget;
6020 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6023void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6031 mDialog->showMinimized();
6034 mDialog->showNormal();
6036 mDialog->activateWindow();
6043void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6045 if ( mExtentWidget )
6047 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
6048 mExtentWidget->clear();
6053 mExtentWidget->setCurrentExtent( r,
crs );
6054 mExtentWidget->setOutputExtentFromUser( r,
crs );
6059QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6061 if ( mExtentWidget )
6063 const QString val = mExtentWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
6064 QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ),
6065 QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ),
6066 QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ),
6067 QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ),
6068 mExtentWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mExtentWidget->outputCrs().authid() ) : QString()
6071 return val.isEmpty() ? QVariant() : QVariant( val );
6077QStringList QgsProcessingExtentWidgetWrapper::compatibleParameterTypes()
const
6079 return QStringList()
6092QStringList QgsProcessingExtentWidgetWrapper::compatibleOutputTypes()
const
6094 return QStringList()
6101QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6103 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6106QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6113 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6118 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6130 QVBoxLayout *vlayout =
new QVBoxLayout();
6131 vlayout->setContentsMargins( 0, 0, 0, 0 );
6133 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6148 for (
int i : layerParam->dataTypes() )
6150 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6154 vlayout->addWidget( mLayerTypeComboBox );
6156 setLayout( vlayout );
6159QgsProcessingParameterDefinition *QgsProcessingMapLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
6161 QList< int > dataTypes;
6162 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6163 dataTypes << v.toInt();
6165 auto param = std::make_unique< QgsProcessingParameterMapLayer >( name, description );
6166 param->setDataTypes( dataTypes );
6168 return param.release();
6177QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6179 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6187 mComboBox->setEditable(
true );
6191 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6193 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [ = ]()
6195 if ( mBlockSignals )
6198 emit widgetValueHasChanged(
this );
6201 setWidgetContext( widgetContext() );
6210 mComboBox->setWidgetContext( context );
6215 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6221void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6224 mComboBox->setValue( value, context );
6227QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6229 return mComboBox ? mComboBox->value() : QVariant();
6232QStringList QgsProcessingMapLayerWidgetWrapper::compatibleParameterTypes()
const
6234 return QStringList()
6246QStringList QgsProcessingMapLayerWidgetWrapper::compatibleOutputTypes()
const
6248 return QStringList()
6256QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6258 return tr(
"path to a map layer" );
6275QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6282 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6287 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6296 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6301QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleParameterTypes()
const
6303 return QStringList()
6310QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleOutputTypes()
const
6312 return QStringList()
6320QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6322 return tr(
"path to a raster layer" );
6325QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6332 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6337 Q_UNUSED( context );
6338 Q_UNUSED( widgetContext );
6339 Q_UNUSED( definition );
6353 QVBoxLayout *vlayout =
new QVBoxLayout();
6354 vlayout->setContentsMargins( 0, 0, 0, 0 );
6356 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6366 for (
int i : vectorParam->dataTypes() )
6368 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6372 vlayout->addWidget( mGeometryTypeComboBox );
6374 setLayout( vlayout );
6377QgsProcessingParameterDefinition *QgsProcessingVectorLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
6379 QList< int > dataTypes;
6380 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6381 dataTypes << v.toInt();
6383 auto param = std::make_unique< QgsProcessingParameterVectorLayer >( name, description, dataTypes );
6385 return param.release();
6390 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6395QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleParameterTypes()
const
6397 return QStringList()
6404QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleOutputTypes()
const
6406 return QStringList()
6414QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6416 return tr(
"path to a vector layer" );
6422 return param->dataTypes();
6424 return QList< int >();
6427QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6434 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6439 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6451 QVBoxLayout *vlayout =
new QVBoxLayout();
6452 vlayout->setContentsMargins( 0, 0, 0, 0 );
6454 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6464 for (
int i : sourceParam->dataTypes() )
6466 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6474 vlayout->addWidget( mGeometryTypeComboBox );
6476 setLayout( vlayout );
6479QgsProcessingParameterDefinition *QgsProcessingFeatureSourceParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
6481 QList< int > dataTypes;
6482 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6483 dataTypes << v.toInt();
6485 auto param = std::make_unique< QgsProcessingParameterFeatureSource >( name, description, dataTypes );
6487 return param.release();
6491 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6496QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleParameterTypes()
const
6498 return QStringList()
6506QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleOutputTypes()
const
6508 return QStringList()
6516QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6518 return tr(
"path to a vector layer" );
6524 return param->dataTypes();
6526 return QList< int >();
6529QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6536 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6541 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6549 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6554QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleParameterTypes()
const
6556 return QStringList()
6563QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleOutputTypes()
const
6565 return QStringList()
6573QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6575 return tr(
"path to a mesh layer" );
6578QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6585 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6590 Q_UNUSED( context );
6591 Q_UNUSED( widgetContext );
6592 Q_UNUSED( definition );
6604QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6608 QHBoxLayout *hl =
new QHBoxLayout();
6609 hl->setContentsMargins( 0, 0, 0, 0 );
6611 mLineEdit =
new QLineEdit();
6612 mLineEdit->setEnabled(
false );
6613 hl->addWidget( mLineEdit, 1 );
6615 mToolButton =
new QToolButton();
6616 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6617 hl->addWidget( mToolButton );
6623 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6626 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6629void QgsProcessingRasterBandPanelWidget::setBands(
const QList< int > &bands )
6634void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6639void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6641 if ( value.isValid() )
6642 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
6646 updateSummaryText();
6650void QgsProcessingRasterBandPanelWidget::showDialog()
6652 QVariantList availableOptions;
6653 availableOptions.reserve( mBands.size() );
6654 for (
int band : std::as_const( mBands ) )
6656 availableOptions << band;
6662 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6663 widget->setPanelTitle( mParam->description() );
6665 widget->setValueFormatter( [
this](
const QVariant & v ) -> QString
6667 int band = v.toInt();
6668 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6671 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
6673 setValue( widget->selectedOptions() );
6680 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6682 dlg.setValueFormatter( [
this](
const QVariant & v ) -> QString
6684 int band = v.toInt();
6685 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6689 setValue( dlg.selectedOptions() );
6694void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6697 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6709 QVBoxLayout *vlayout =
new QVBoxLayout();
6710 vlayout->setContentsMargins( 0, 0, 0, 0 );
6712 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6714 mDefaultLineEdit =
new QLineEdit();
6715 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6720 for (
int b : bands )
6722 defVal << QString::number( b );
6725 mDefaultLineEdit->setText( defVal.join(
';' ) );
6727 vlayout->addWidget( mDefaultLineEdit );
6729 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6730 mParentLayerComboBox =
new QComboBox();
6732 QString initialParent;
6734 initialParent = bandParam->parentLayerParameterName();
6736 if (
auto *lModel = widgetContext.
model() )
6739 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6740 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6744 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
6745 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6747 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6753 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6756 mParentLayerComboBox->addItem( initialParent, initialParent );
6757 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6760 vlayout->addWidget( mParentLayerComboBox );
6762 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6764 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6766 vlayout->addWidget( mAllowMultipleCheckBox );
6767 setLayout( vlayout );
6770QgsProcessingParameterDefinition *QgsProcessingBandParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
6772 auto param = std::make_unique< QgsProcessingParameterBand >( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6774 return param.release();
6783QWidget *QgsProcessingBandWidgetWrapper::createWidget()
6793 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
6794 mPanel->setToolTip( parameterDefinition()->toolTip() );
6795 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [ = ]
6797 emit widgetValueHasChanged(
this );
6806 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6809 emit widgetValueHasChanged(
this );
6817 mLineEdit =
new QLineEdit();
6818 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6819 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
6821 emit widgetValueHasChanged(
this );
6830void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6842 setParentLayerWrapperValue( wrapper );
6845 setParentLayerWrapperValue( wrapper );
6862 std::unique_ptr< QgsProcessingContext > tmpContext;
6863 if ( mProcessingContextGenerator )
6864 context = mProcessingContextGenerator->processingContext();
6868 tmpContext = std::make_unique< QgsProcessingContext >();
6869 context = tmpContext.get();
6875 if ( layer && layer->
isValid() )
6879 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
6882 mParentLayer.reset( qobject_cast< QgsRasterLayer * >( ownedLayer.release() ) );
6883 layer = mParentLayer.get();
6891 mComboBox->setLayer( layer );
6895 if ( provider && layer->
isValid() )
6900 QHash< int, QString > bandNames;
6901 for (
int i = 1; i <= nBands; ++i )
6906 mPanel->setBands( bands );
6907 mPanel->setBandNames( bandNames );
6914 mComboBox->setLayer(
nullptr );
6916 mPanel->setBands( QList< int >() );
6918 if ( value.isValid() && widgetContext().messageBar() )
6921 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent bands could not be populated" ),
6926 if ( parameterDefinition()->defaultValueForGui().isValid() )
6927 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6930void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6934 if ( !value.isValid() )
6935 mComboBox->setBand( -1 );
6939 mComboBox->setBand( v );
6945 if ( value.isValid() )
6948 opts.reserve( v.size() );
6953 mPanel->setValue( value.isValid() ? opts : QVariant() );
6955 else if ( mLineEdit )
6962 opts.reserve( v.size() );
6964 opts << QString::number( i );
6965 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
6969 if ( value.isValid() )
6977QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
6980 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
6982 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
6983 else if ( mLineEdit )
6988 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
6990 res.reserve( parts.count() );
6991 for (
const QString &s : parts )
6994 int band = s.toInt( &ok );
6998 return res.
isEmpty() ? QVariant() : res;
7002 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7009QStringList QgsProcessingBandWidgetWrapper::compatibleParameterTypes()
const
7011 return QStringList()
7017QStringList QgsProcessingBandWidgetWrapper::compatibleOutputTypes()
const
7019 return QStringList()
7023QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7025 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7028QString QgsProcessingBandWidgetWrapper::parameterType()
const
7035 return new QgsProcessingBandWidgetWrapper( parameter, type );
7040 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7053 QHBoxLayout *hl =
new QHBoxLayout();
7054 hl->setContentsMargins( 0, 0, 0, 0 );
7056 mLineEdit =
new QLineEdit();
7057 mLineEdit->setEnabled(
false );
7058 hl->addWidget( mLineEdit, 1 );
7060 mToolButton =
new QToolButton();
7061 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7062 hl->addWidget( mToolButton );
7068 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7071 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7074void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7076 if ( value.isValid() )
7077 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
7081 updateSummaryText();
7085void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7092 if ( mValue.removeAll( layerId ) )
7094 updateSummaryText();
7101void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7107 switch ( mParam->layerType() )
7265void QgsProcessingMultipleLayerPanelWidget::showDialog()
7270 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
7271 widget->setPanelTitle( mParam->description() );
7272 widget->setProject( mProject );
7273 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
7275 setValue( widget->selectedOptions() );
7282 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7283 dlg.setProject( mProject );
7286 setValue( dlg.selectedOptions() );
7291void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7294 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7304 QVBoxLayout *vlayout =
new QVBoxLayout();
7305 vlayout->setContentsMargins( 0, 0, 0, 0 );
7307 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7308 mLayerTypeComboBox =
new QComboBox();
7322 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast< int >( layersParam->layerType() ) ) );
7324 vlayout->addWidget( mLayerTypeComboBox );
7325 setLayout( vlayout );
7328QgsProcessingParameterDefinition *QgsProcessingMultipleLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
7330 auto param = std::make_unique< QgsProcessingParameterMultipleLayers >( name, description,
static_cast< Qgis::ProcessingSourceType >( mLayerTypeComboBox->currentData().toInt() ) );
7332 return param.release();
7341QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7345 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7346 mPanel->setToolTip( parameterDefinition()->toolTip() );
7347 mPanel->setProject( widgetContext().project() );
7349 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7350 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [ = ]
7352 emit widgetValueHasChanged(
this );
7362 mPanel->setProject( context.
project() );
7364 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7368void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7373 if ( value.isValid() )
7376 opts.reserve( v.size() );
7378 opts << l->source();
7381 for (
const QVariant &v : value.toList() )
7383 if ( v.userType() == QMetaType::type(
"QgsProcessingModelChildParameterSource" ) )
7385 const QgsProcessingModelChildParameterSource source = v.value< QgsProcessingModelChildParameterSource >();
7386 opts << QVariant::fromValue( source );
7391 mPanel->setValue( value.isValid() ? opts : QVariant() );
7395QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7398 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7403QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleParameterTypes()
const
7405 return QStringList()
7417QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleOutputTypes()
const
7419 return QStringList()
7428QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7430 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7433QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7440 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7445 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7454 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7459QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleParameterTypes()
const
7461 return QStringList()
7468QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleOutputTypes()
const
7470 return QStringList()
7478QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7480 return tr(
"path to a point cloud layer" );
7483QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7490 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7495 Q_UNUSED( context );
7496 Q_UNUSED( widgetContext );
7497 Q_UNUSED( definition );
7514QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleParameterTypes()
const
7516 return QStringList()
7524QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleOutputTypes()
const
7526 return QStringList()
7531QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7533 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7536QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7543 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7548 Q_UNUSED( context );
7549 Q_UNUSED( widgetContext );
7550 Q_UNUSED( definition );
7561 if ( mWidgetContext.project() )
7562 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7566QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7577 mComboBox->setEditable(
true );
7581 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7583 if ( mWidgetContext.project() )
7584 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7587 mComboBox->setAllowEmptyLayer(
true );
7591 if ( mBlockSignals )
7594 emit widgetValueHasChanged(
this );
7597 setWidgetContext( widgetContext() );
7601void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7607 mComboBox->setLayer(
nullptr );
7611 QVariant val = value;
7612 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
7624 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( val.value< QObject * >() );
7625 if ( !layer && val.type() == QVariant::String )
7632 mComboBox->setLayer( layer );
7637QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7639 return mComboBox && mComboBox->currentLayer() ?
7640 ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral(
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
7653 QHBoxLayout *hl =
new QHBoxLayout();
7654 hl->setContentsMargins( 0, 0, 0, 0 );
7656 mLineEdit =
new QLineEdit();
7657 mLineEdit->setEnabled(
false );
7658 hl->addWidget( mLineEdit, 1 );
7660 mToolButton =
new QToolButton();
7661 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7662 hl->addWidget( mToolButton );
7668 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7671 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7676 mAttributes = attributes;
7679void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7681 if ( value.isValid() )
7682 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
7686 updateSummaryText();
7690void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7692 QVariantList availableOptions;
7693 availableOptions.reserve( mAttributes.count() );
7694 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7697 availableOptions << attr.name();
7703 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7704 widget->setPanelTitle( mParam->description() );
7706 widget->setValueFormatter( [](
const QVariant & v ) -> QString
7708 return v.toString();
7711 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
7713 setValue( widget->selectedOptions() );
7720 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7722 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
7724 return v.toString();
7728 setValue( dlg.selectedOptions() );
7733void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7738 if ( mValue.empty() )
7740 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7745 values.reserve( mValue.size() );
7746 for (
const QVariant &val : std::as_const( mValue ) )
7748 values << val.toString();
7751 const QString concatenated = values.join( tr(
"," ) );
7752 if ( concatenated.length() < 100 )
7753 mLineEdit->setText( concatenated );
7755 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7767 QVBoxLayout *vlayout =
new QVBoxLayout();
7768 vlayout->setContentsMargins( 0, 0, 0, 0 );
7770 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7771 mParentLayerComboBox =
new QComboBox();
7773 QString initialParent;
7775 initialParent = attrParam->parentLayerParameterName();
7777 if (
auto *lModel = widgetContext.
model() )
7780 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7781 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7785 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
7786 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7788 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7794 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7797 mParentLayerComboBox->addItem( initialParent, initialParent );
7798 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7801 vlayout->addWidget( mParentLayerComboBox );
7803 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
7805 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
7807 vlayout->addWidget( mAllowMultipleCheckBox );
7809 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
7810 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7812 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
7814 vlayout->addWidget( mDefaultToAllCheckBox );
7816 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
7818 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7821 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7823 mDefaultLineEdit =
new QLineEdit();
7824 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
7828 mDefaultLineEdit->setText( attributes.join(
';' ) );
7830 vlayout->addWidget( mDefaultLineEdit );
7832 setLayout( vlayout );
7835QgsProcessingParameterDefinition *QgsProcessingPointCloudAttributeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, Qgis::ProcessingParameterFlags flags )
const
7837 QVariant defaultValue;
7838 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
7840 defaultValue = mDefaultLineEdit->text();
7842 auto param = std::make_unique< QgsProcessingParameterPointCloudAttribute >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
7844 return param.release();
7852QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
7862 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
7863 mPanel->setToolTip( parameterDefinition()->toolTip() );
7864 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [ = ]
7866 emit widgetValueHasChanged(
this );
7874 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7877 emit widgetValueHasChanged(
this );
7885 mLineEdit =
new QLineEdit();
7886 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
7887 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
7889 emit widgetValueHasChanged(
this );
7898void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7910 setParentLayerWrapperValue( wrapper );
7913 setParentLayerWrapperValue( wrapper );
7930 std::unique_ptr< QgsProcessingContext > tmpContext;
7931 if ( mProcessingContextGenerator )
7932 context = mProcessingContextGenerator->processingContext();
7936 tmpContext = std::make_unique< QgsProcessingContext >();
7937 context = tmpContext.get();
7943 if ( layer && layer->
isValid() )
7947 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
7950 mParentLayer.reset( qobject_cast< QgsPointCloudLayer * >( ownedLayer.release() ) );
7951 layer = mParentLayer.get();
7959 mComboBox->setLayer( layer );
7962 mPanel->setAttributes( layer->
attributes() );
7969 mComboBox->setLayer(
nullptr );
7974 if ( value.isValid() && widgetContext().messageBar() )
7977 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent attributes could not be populated" ),
7986 val.reserve( mPanel->attributes().attributes().size() );
7989 setWidgetValue( val, *context );
7992 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7995void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7999 if ( !value.isValid() )
8000 mComboBox->setAttribute( QString() );
8004 mComboBox->setAttribute( v );
8010 if ( value.isValid() )
8013 opts.reserve( v.size() );
8014 for (
const QString &i : v )
8018 mPanel->setValue( opts );
8020 else if ( mLineEdit )
8026 mLineEdit->setText( v.join(
';' ) );
8035QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
8038 return mComboBox->currentAttribute();
8040 return mPanel->value();
8041 else if ( mLineEdit )
8046 return mLineEdit->text().split(
';' );
8049 return mLineEdit->text();
8055QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleParameterTypes()
const
8057 return QStringList()
8062QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleOutputTypes()
const
8064 return QStringList()
8069QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
8071 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
8074QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
8081 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
8086 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8100QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8108 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8109 if ( mProcessingContextGenerator )
8110 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8111 if ( mParametersGenerator )
8112 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8113 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8115 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [ = ]()
8117 if ( mBlockSignals )
8120 emit widgetValueHasChanged(
this );
8129 mOutputWidget->addOpenAfterRunningOption();
8131 return mOutputWidget;
8141void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8143 if ( mOutputWidget )
8144 mOutputWidget->setValue( value );
8147QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8149 if ( mOutputWidget )
8150 return mOutputWidget->value();
8155QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8158 if ( mOutputWidget )
8159 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
8163QStringList QgsProcessingOutputWidgetWrapper::compatibleParameterTypes()
const
8165 return QStringList()
8175QStringList QgsProcessingOutputWidgetWrapper::compatibleOutputTypes()
const
8177 return QStringList()
8188 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8193QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8200 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8203QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8205 return tr(
"path to layer destination" );
8213 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8218QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8225 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8228QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8230 return tr(
"path to layer destination" );
8238 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8243QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8250 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8253QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8255 return tr(
"path to layer destination" );
8263 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8268QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8275 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8278QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8280 return tr(
"path to layer destination" );
8288 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8293QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8300 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8303QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8305 return tr(
"path to file destination" );
8313 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8318QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8325 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8328QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8330 return tr(
"path to folder destination" );
8338 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8342QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8349 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8352QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8354 return tr(
"path to layer destination" );
@ Standard
Unit is a standard measurement unit.
ProcessingSourceType
Processing data source types.
@ File
Files (i.e. non map layer sources, such as text files)
@ Annotation
Annotation layers.
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ VectorTile
Vector tile layers.
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ VectorAnyGeometry
Any vector layer with geometry.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ PointCloud
Point cloud layers.
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
@ File
Parameter is a single file.
@ Folder
Parameter is a folder.
ExpressionType
Expression types.
@ RasterCalculator
Raster calculator expression (since QGIS 3.34)
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
DistanceUnit
Units of distance.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ Inches
Inches (since QGIS 3.32)
@ NauticalMiles
Nautical miles.
ProcessingFieldParameterDataType
Processing field parameter data types.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ Numeric
Accepts numeric fields.
@ DateTime
Accepts datetime fields.
@ Info
Information message.
@ AnnotationLayer
QgsAnnotationLayer.
TemporalUnit
Temporal units.
@ Milliseconds
Milliseconds.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
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.
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
void remove(int fieldIdx)
Removes the field with the given index.
int count() const
Returns number of items.
bool isEmpty() const
Checks whether the container is empty.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A geometry is the spatial representation of a feature.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
The QgsLayoutComboBox class is a combo box which displays available layouts from a QgsLayoutManager.
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
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.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Interface for master layout type objects, such as print layouts and reports.
virtual QString name() const =0
Returns the layout's name.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
bool clearWidgets()
Removes all items from the bar.
Collection of point cloud attributes.
The QgsPointCloudAttributeComboBox is a combo box which displays the list of attributes of a given po...
void attributeChanged(const QString &name)
Emitted when the currently selected attribute changes.
Attribute for point cloud data pair of name and size in bytes.
Represents a map layer supporting display of point clouds.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes available from the layer.
A class to represent a 2D point.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
Base class for all parameter definitions which represent file or layer destinations,...
Encapsulates settings relating to a feature source input to a processing algorithm.
QgsProperty source
Source definition.
WidgetType
Types of dialogs which Processing widgets can be created for.
@ Standard
Standard algorithm dialog.
@ Batch
Batch processing dialog.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A raster band parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
A boolean parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A color parameter for processing algorithms.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
static QString typeName()
Returns the type name for the parameter class.
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
static QString typeName()
Returns the type name for the parameter class.
QVariant sourceCrs() const
Returns the static source CRS, or an invalid value if this is not set.
QVariant destinationCrs() const
Returns the static destination CRS, or an invalid value if this is not set.
A coordinate reference system parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
A database table name parameter for processing algorithms, allowing users to select from existing dat...
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
A datetime (or pure date or time) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
void setFlags(Qgis::ProcessingParameterFlags flags)
Sets the flags associated with the parameter.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
QString description() const
Returns the description for the parameter.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
virtual QString type() const =0
Unique parameter type name.
QString name() const
Returns the name of the parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
A double numeric parameter for duration values.
Qgis::TemporalUnit defaultUnit() const
Returns the default duration unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
static QString typeName()
Returns the type name for the parameter class.
An expression parameter for processing algorithms.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ExpressionType expressionType() const
Returns the parameter's expression type.
A rectangular map extent parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
An input feature source (such as vector layers) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A vector layer or feature source field parameter for processing algorithms.
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
static QString typeName()
Returns the type name for the parameter class.
A geometry parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A print layout item parameter, allowing users to select a particular item from a print layout.
static QString typeName()
Returns the type name for the parameter class.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
A print layout parameter, allowing users to select a print layout.
static QString typeName()
Returns the type name for the parameter class.
A map layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
static QString typeName()
Returns the type name for the parameter class.
A table (matrix) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
static QString typeName()
Returns the type name for the parameter class.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
double maximum() const
Returns the maximum value acceptable by the parameter.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer attribute parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A point parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A data provider connection parameter for processing algorithms, allowing users to select from availab...
static QString typeName()
Returns the type name for the parameter class.
QString providerId() const
Returns the ID of the provider associated with the connections.
A numeric range parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
A raster layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool multiLine() const
Returns true if the parameter allows multiline strings.
static QString typeName()
Returns the type name for the parameter class.
A vector layer (with or without geometry) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
Contains settings which reflect the context in which a Processing parameter widget is shown,...
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsProject * project() const
Returns the project associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
QgsMapLayer * activeLayer() const
Returns the current active layer.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a list of map layers.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QStringList parameterAsStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of strings (e.g.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a point cloud layer.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Utility functions for use with processing classes.
@ Annotation
Annotation layer type, since QGIS 3.22.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
void layerRemoved(const QString &layerId)
Emitted after a layer was removed from the registry.
A store for object properties.
Qgis::PropertyType propertyType() const
Returns the property type.
The QgsProviderConnectionComboBox class is a combo box which displays the list of connections registe...
A combobox widget which displays the bands present in a raster layer.
void bandChanged(int band)
Emitted when the currently selected band changes.
static QString displayBandName(QgsRasterDataProvider *provider, int band)
Returns a user-friendly band name for the specified band.
Base class for raster data providers.
virtual int bandCount() const =0
Gets number of bands.
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
A rectangle specified with double values.
This class is a composition of two QSettings instances:
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Class that shows snapping marker on map canvas for the current snapping match.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
The QgsTimeEdit class is a QTimeEdit widget with the capability of setting/reading null date/times.
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE Qgis::DistanceUnitType unitType(Qgis::DistanceUnit unit)
Returns the type for a distance unit.
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const QgsCoordinateReferenceSystem & crs