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, QgsProcessingParameterDefinition::Flags 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, QgsProcessingParameterDefinition::Flags 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, QgsProcessingParameterDefinition::Flags 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( 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, QgsProcessingParameterDefinition::Flags 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, QgsProcessingParameterDefinition::Flags 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() );
1202 setUnitParameterValue( wrapper->parameterValue() );
1216void QgsProcessingDistanceWidgetWrapper::setUnitParameterValue(
const QVariant &value )
1222 std::unique_ptr< QgsProcessingContext > tmpContext;
1223 if ( mProcessingContextGenerator )
1224 context = mProcessingContextGenerator->processingContext();
1228 tmpContext = std::make_unique< QgsProcessingContext >();
1229 context = tmpContext.get();
1246 mUnitsCombo->hide();
1251 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( units ) ) );
1252 mUnitsCombo->show();
1259QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1261 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1262 if ( val.type() == QVariant::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1275 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1286 QVBoxLayout *vlayout =
new QVBoxLayout();
1287 vlayout->setContentsMargins( 0, 0, 0, 0 );
1289 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1290 mMinLineEdit =
new QLineEdit();
1291 vlayout->addWidget( mMinLineEdit );
1293 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1294 mMaxLineEdit =
new QLineEdit();
1295 vlayout->addWidget( mMaxLineEdit );
1297 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1298 mDefaultLineEdit =
new QLineEdit();
1299 vlayout->addWidget( mDefaultLineEdit );
1301 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1303 mUnitsCombo =
new QComboBox();
1313 vlayout->addWidget( mUnitsCombo );
1317 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1318 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1319 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1320 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast <int >( durationParam->defaultUnit() ) ) );
1323 setLayout( vlayout );
1326QgsProcessingParameterDefinition *QgsProcessingDurationParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1331 auto param = std::make_unique< QgsProcessingParameterDuration >( name, description, ok ? val : QVariant() );
1336 param->setMinimum( val );
1342 param->setMaximum( val );
1345 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit >( mUnitsCombo->currentData().toInt() ) );
1347 param->setFlags( flags );
1348 return param.release();
1352 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1357QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1364 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1367QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1371 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1376 mUnitsCombo =
new QComboBox();
1388 QHBoxLayout *layout =
new QHBoxLayout();
1389 layout->addWidget( spin, 1 );
1390 layout->insertWidget( 1, mUnitsCombo );
1392 QWidget *w =
new QWidget();
1393 layout->setContentsMargins( 0, 0, 0, 0 );
1394 w->setLayout( layout );
1396 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( durationDef->
defaultUnit() ) ) );
1397 mUnitsCombo->show();
1410QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
1422QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
1424 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1425 if ( val.type() == QVariant::Double && mUnitsCombo )
1436void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1442 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
1446 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
1452 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1462 QVBoxLayout *vlayout =
new QVBoxLayout();
1463 vlayout->setContentsMargins( 0, 0, 0, 0 );
1465 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1467 mDefaultLineEdit =
new QLineEdit();
1471 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1474 vlayout->addWidget( mDefaultLineEdit );
1476 setLayout( vlayout );
1479QgsProcessingParameterDefinition *QgsProcessingScaleParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1482 double val = mDefaultLineEdit->text().toDouble( &ok );
1483 auto param = std::make_unique< QgsProcessingParameterScale >( name, description, ok ? val : QVariant() );
1485 return param.release();
1489 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1494QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1501 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1504QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
1516 mScaleWidget->setAllowNull(
true );
1518 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
1519 mScaleWidget->setShowCurrentScaleButton(
true );
1521 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
1524 emit widgetValueHasChanged(
this );
1526 return mScaleWidget;
1535 mScaleWidget->setMapCanvas( context.
mapCanvas() );
1540QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
1542 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
1545void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1549 if ( mScaleWidget->allowNull() && !value.isValid() )
1550 mScaleWidget->setNull();
1554 mScaleWidget->setScale( v );
1561 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1572 QVBoxLayout *vlayout =
new QVBoxLayout();
1573 vlayout->setContentsMargins( 0, 0, 0, 0 );
1575 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
1577 mTypeComboBox =
new QComboBox();
1580 vlayout->addWidget( mTypeComboBox );
1582 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1583 mMinLineEdit =
new QLineEdit();
1584 vlayout->addWidget( mMinLineEdit );
1586 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1587 mMaxLineEdit =
new QLineEdit();
1588 vlayout->addWidget( mMaxLineEdit );
1592 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( rangeParam->dataType() ) );
1594 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
1595 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
1598 setLayout( vlayout );
1601QgsProcessingParameterDefinition *QgsProcessingRangeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1603 QString defaultValue;
1604 if ( mMinLineEdit->text().isEmpty() )
1606 defaultValue = QStringLiteral(
"None" );
1614 defaultValue = QStringLiteral(
"None" );
1618 if ( mMaxLineEdit->text().isEmpty() )
1620 defaultValue += QLatin1String(
",None" );
1626 defaultValue += QStringLiteral(
",%1" ).arg( ok ? QString::number( val ) : QLatin1String(
"None" ) );
1630 auto param = std::make_unique< QgsProcessingParameterRange >( name, description, dataType, defaultValue );
1631 param->setFlags( flags );
1632 return param.release();
1642QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
1651 QHBoxLayout *layout =
new QHBoxLayout();
1656 mMinSpinBox->setExpressionsEnabled(
true );
1657 mMinSpinBox->setShowClearButton(
false );
1658 mMaxSpinBox->setExpressionsEnabled(
true );
1659 mMaxSpinBox->setShowClearButton(
false );
1661 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
1662 layout->addWidget( minLabel );
1663 layout->addWidget( mMinSpinBox, 1 );
1665 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
1666 layout->addWidget( maxLabel );
1667 layout->addWidget( mMaxSpinBox, 1 );
1669 QWidget *w =
new QWidget();
1670 layout->setContentsMargins( 0, 0, 0, 0 );
1671 w->setLayout( layout );
1675 mMinSpinBox->setDecimals( 6 );
1676 mMaxSpinBox->setDecimals( 6 );
1680 mMinSpinBox->setDecimals( 0 );
1681 mMaxSpinBox->setDecimals( 0 );
1684 mMinSpinBox->setMinimum( -99999999.999999 );
1685 mMaxSpinBox->setMinimum( -99999999.999999 );
1686 mMinSpinBox->setMaximum( 99999999.999999 );
1687 mMaxSpinBox->setMaximum( 99999999.999999 );
1691 mAllowingNull =
true;
1693 const double min = mMinSpinBox->minimum() - 1;
1694 mMinSpinBox->setMinimum( min );
1695 mMaxSpinBox->setMinimum( min );
1696 mMinSpinBox->setValue( min );
1697 mMaxSpinBox->setValue( min );
1699 mMinSpinBox->setShowClearButton(
true );
1700 mMaxSpinBox->setShowClearButton(
true );
1701 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
1702 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
1705 w->setToolTip( parameterDefinition()->toolTip() );
1707 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1709 mBlockChangedSignal++;
1710 if ( !mAllowingNull && v > mMaxSpinBox->value() )
1711 mMaxSpinBox->setValue( v );
1712 mBlockChangedSignal--;
1714 if ( !mBlockChangedSignal )
1715 emit widgetValueHasChanged(
this );
1717 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1719 mBlockChangedSignal++;
1720 if ( !mAllowingNull && v < mMinSpinBox->value() )
1721 mMinSpinBox->setValue( v );
1722 mBlockChangedSignal--;
1724 if ( !mBlockChangedSignal )
1725 emit widgetValueHasChanged(
this );
1734void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1737 if ( mAllowingNull && v.empty() )
1739 mMinSpinBox->clear();
1740 mMaxSpinBox->clear();
1747 if ( mAllowingNull )
1749 mBlockChangedSignal++;
1750 if ( std::isnan( v.at( 0 ) ) )
1751 mMinSpinBox->clear();
1753 mMinSpinBox->setValue( v.at( 0 ) );
1755 if ( v.count() >= 2 )
1757 if ( std::isnan( v.at( 1 ) ) )
1758 mMaxSpinBox->clear();
1760 mMaxSpinBox->setValue( v.at( 1 ) );
1762 mBlockChangedSignal--;
1766 mBlockChangedSignal++;
1767 mMinSpinBox->setValue( v.at( 0 ) );
1768 if ( v.count() >= 2 )
1769 mMaxSpinBox->setValue( v.at( 1 ) );
1770 mBlockChangedSignal--;
1774 if ( !mBlockChangedSignal )
1775 emit widgetValueHasChanged(
this );
1778QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
1780 if ( mAllowingNull )
1783 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
1784 value = QStringLiteral(
"None" );
1786 value = QString::number( mMinSpinBox->value() );
1788 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
1789 value += QLatin1String(
",None" );
1791 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
1796 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
1799QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
const
1801 return QStringList()
1806QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
const
1812QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
1814 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
1817QString QgsProcessingRangeWidgetWrapper::parameterType()
const
1824 return new QgsProcessingRangeWidgetWrapper( parameter, type );
1829 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1840 QVBoxLayout *vlayout =
new QVBoxLayout();
1841 vlayout->setContentsMargins( 0, 0, 0, 0 );
1843 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
1846 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
1847 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
1849 vlayout->addWidget( mMatrixWidget );
1850 setLayout( vlayout );
1853QgsProcessingParameterDefinition *QgsProcessingMatrixParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1855 auto param = std::make_unique< QgsProcessingParameterMatrix >( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
1856 param->setFlags( flags );
1857 return param.release();
1867QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
1869 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast< const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
1870 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
1872 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [ = ]
1874 emit widgetValueHasChanged(
this );
1883 return mMatrixWidget;
1889void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1892 if ( mMatrixWidget )
1893 mMatrixWidget->setValue( v );
1896QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
1898 if ( mMatrixWidget )
1899 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
1904QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
const
1906 return QStringList()
1910QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
const
1912 return QStringList();
1915QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
1917 return tr(
"comma delimited string of values, or an array of values" );
1920QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
1927 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
1932 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1944 QVBoxLayout *vlayout =
new QVBoxLayout();
1945 vlayout->setContentsMargins( 0, 0, 0, 0 );
1947 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
1949 mTypeComboBox =
new QComboBox();
1953 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( fileParam->behavior() ) );
1955 mTypeComboBox->setCurrentIndex( 0 );
1956 vlayout->addWidget( mTypeComboBox );
1958 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
1960 mFilterComboBox =
new QComboBox();
1961 mFilterComboBox->setEditable(
true );
1963 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
1964 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
1965 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
1966 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
1968 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
1970 mFilterComboBox->setCurrentIndex( 0 );
1971 vlayout->addWidget( mFilterComboBox );
1973 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1976 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
1980 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
1984 vlayout->addWidget( mDefaultFileWidget );
1986 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ]
1995 setLayout( vlayout );
1998QgsProcessingParameterDefinition *QgsProcessingFileParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
2000 auto param = std::make_unique< QgsProcessingParameterFile >( name, description );
2003 param->setFileFilter( mFilterComboBox->currentText() );
2004 if ( !mDefaultFileWidget->filePath().isEmpty() )
2005 param->setDefaultValue( mDefaultFileWidget->filePath() );
2006 param->setFlags( flags );
2007 return param.release();
2017QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2027 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2028 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2030 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
2037 mFileWidget->setFilter( fileParam->
fileFilter() );
2038 else if ( !fileParam->
extension().isEmpty() )
2039 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
2049 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
2050 emit widgetValueHasChanged(
this );
2058void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2062 mFileWidget->setFilePath( v );
2065QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2068 return mFileWidget->filePath();
2073QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
const
2075 return QStringList()
2080QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
const
2091QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2093 return tr(
"string representing a path to a file or folder" );
2096QString QgsProcessingFileWidgetWrapper::parameterType()
const
2103 return new QgsProcessingFileWidgetWrapper( parameter, type );
2108 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2120 QVBoxLayout *vlayout =
new QVBoxLayout();
2121 vlayout->setContentsMargins( 0, 0, 0, 0 );
2122 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2125 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2127 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2128 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2130 QStackedWidget *stackedWidget =
new QStackedWidget();
2131 stackedWidget->addWidget( mDefaultQgisLineEdit );
2132 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2133 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2134 vlayout->addWidget( stackedWidget );
2139 mDefaultQgisLineEdit->setExpression( expr );
2140 mDefaultPointCloudLineEdit->setExpression( expr );
2143 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2145 mParentLayerComboBox =
new QComboBox();
2146 vlayout->addWidget( mParentLayerComboBox );
2148 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2149 mExpressionTypeComboBox =
new QComboBox();
2154 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2156 mParentLayerComboBox->clear();
2157 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2159 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2161 QString initialParent;
2163 initialParent = expParam->parentLayerParameterName();
2167 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2170 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2171 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2178 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2179 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2181 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2186 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2187 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2189 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2196 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2197 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2199 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2210 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
2211 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2213 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2221 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2224 mParentLayerComboBox->addItem( initialParent, initialParent );
2225 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2230 mExpressionTypeComboBox->setCurrentIndex( -1 );
2232 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast< int >( expParam->expressionType() ) ) );
2234 mExpressionTypeComboBox->setCurrentIndex( 0 );
2236 vlayout->addWidget( mExpressionTypeComboBox );
2238 setLayout( vlayout );
2241QgsProcessingParameterDefinition *QgsProcessingExpressionParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
2245 switch ( expressionType )
2248 expression = mDefaultQgisLineEdit->expression();
2251 expression = mDefaultPointCloudLineEdit->expression();
2254 expression = mDefaultRasterCalculatorLineEdit->expression();
2257 auto param = std::make_unique< QgsProcessingParameterExpression >( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2258 param->setFlags( flags );
2259 return param.release();
2268QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2280 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2281 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2282 mExpLineEdit->registerExpressionContextGenerator(
this );
2285 emit widgetValueHasChanged(
this );
2287 return mExpLineEdit;
2293 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2294 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2295 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2297 emit widgetValueHasChanged(
this );
2299 return mPointCloudExpLineEdit;
2304 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2305 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2308 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2310 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2312 emit widgetValueHasChanged(
this );
2314 return mRasterCalculatorExpLineEdit;
2318 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
2321 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2322 mExpBuilderWidget->init( createExpressionContext() );
2325 Q_UNUSED( changed );
2326 emit widgetValueHasChanged(
this );
2328 return mExpBuilderWidget;
2333 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2334 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2335 mFieldExpWidget->registerExpressionContextGenerator(
this );
2337 mFieldExpWidget->setAllowEmptyFieldName(
true );
2341 emit widgetValueHasChanged(
this );
2343 return mFieldExpWidget;
2351void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2361 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterExpression *
>( parameterDefinition() )->parentLayerParameterName() )
2363 setParentLayerWrapperValue( wrapper );
2366 setParentLayerWrapperValue( wrapper );
2382 if ( mExpBuilderWidget )
2385 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2393 std::unique_ptr< QgsProcessingContext > tmpContext;
2394 if ( mProcessingContextGenerator )
2395 context = mProcessingContextGenerator->processingContext();
2399 tmpContext = std::make_unique< QgsProcessingContext >();
2400 context = tmpContext.get();
2410 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2420 if ( mFieldExpWidget )
2421 mFieldExpWidget->setLayer(
nullptr );
2422 else if ( mExpBuilderWidget )
2423 mExpBuilderWidget->setLayer(
nullptr );
2424 else if ( mExpLineEdit )
2425 mExpLineEdit->setLayer(
nullptr );
2431 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
2434 mParentLayer.reset( ownedLayer.release() );
2442 if ( mFieldExpWidget )
2443 mFieldExpWidget->setLayer( layer );
2444 if ( mExpBuilderWidget )
2445 mExpBuilderWidget->setLayer( layer );
2446 else if ( mExpLineEdit )
2447 mExpLineEdit->setLayer( layer );
2456 if ( mPointCloudExpLineEdit )
2457 mPointCloudExpLineEdit->setLayer(
nullptr );
2463 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
2466 mParentLayer.reset( ownedLayer.release() );
2474 if ( mPointCloudExpLineEdit )
2475 mPointCloudExpLineEdit->setLayer( layer );
2482 if ( layers.isEmpty() )
2484 if ( mRasterCalculatorExpLineEdit )
2486 mRasterCalculatorExpLineEdit->setLayers( val.type() == QVariant::List ? val.toList() : QVariantList() << val );
2491 if ( mRasterCalculatorExpLineEdit )
2493 QVariantList layersList;
2496 layersList << layer->
name();
2498 mRasterCalculatorExpLineEdit->setLayers( layersList );
2506void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2509 if ( mFieldExpWidget )
2510 mFieldExpWidget->setExpression( v );
2511 else if ( mExpBuilderWidget )
2512 mExpBuilderWidget->setExpressionText( v );
2513 else if ( mExpLineEdit )
2514 mExpLineEdit->setExpression( v );
2515 else if ( mPointCloudExpLineEdit )
2516 mPointCloudExpLineEdit->setExpression( v );
2517 else if ( mRasterCalculatorExpLineEdit )
2518 mRasterCalculatorExpLineEdit->setExpression( v );
2521QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2523 if ( mFieldExpWidget )
2524 return mFieldExpWidget->expression();
2525 if ( mExpBuilderWidget )
2526 return mExpBuilderWidget->expressionText();
2527 else if ( mExpLineEdit )
2528 return mExpLineEdit->expression();
2529 else if ( mPointCloudExpLineEdit )
2530 return mPointCloudExpLineEdit->expression();
2531 else if ( mRasterCalculatorExpLineEdit )
2532 return mRasterCalculatorExpLineEdit->expression();
2537QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
const
2539 return QStringList()
2549QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
const
2551 return QStringList()
2556QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2558 return tr(
"string representation of an expression" );
2561const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
2563 if ( mFieldExpWidget && mFieldExpWidget->layer() )
2564 return mFieldExpWidget->layer();
2566 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
2567 return mExpBuilderWidget->layer();
2572QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
2579 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
2584 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2597 QHBoxLayout *hl =
new QHBoxLayout();
2598 hl->setContentsMargins( 0, 0, 0, 0 );
2600 mLineEdit =
new QLineEdit();
2601 mLineEdit->setEnabled(
false );
2602 hl->addWidget( mLineEdit, 1 );
2604 mToolButton =
new QToolButton();
2605 mToolButton->setText( QString( QChar( 0x2026 ) ) );
2606 hl->addWidget( mToolButton );
2612 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2615 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
2618void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
2620 if ( value.isValid() )
2622 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
2624 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
2630 updateSummaryText();
2634void QgsProcessingEnumPanelWidget::showDialog()
2636 QVariantList availableOptions;
2639 availableOptions.reserve( mParam->options().size() );
2641 if ( mParam->usesStaticStrings() )
2643 for ( QString o : mParam->options() )
2645 availableOptions << o;
2650 for (
int i = 0; i < mParam->options().count(); ++i )
2651 availableOptions << i;
2655 const QStringList options = mParam ? mParam->options() : QStringList();
2659 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
2660 widget->setPanelTitle( mParam->description() );
2662 if ( mParam->usesStaticStrings() )
2664 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
2666 const QString i = v.toString();
2667 return options.contains( i ) ? i : QString();
2672 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
2674 const int i = v.toInt();
2675 return options.size() > i ? options.at( i ) : QString();
2679 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
2681 setValue( widget->selectedOptions() );
2688 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
2690 dlg.setValueFormatter( [options](
const QVariant & v ) -> QString
2692 const int i = v.toInt();
2693 return options.size() > i ? options.at( i ) : QString();
2697 setValue( dlg.selectedOptions() );
2702void QgsProcessingEnumPanelWidget::updateSummaryText()
2707 if ( mValue.empty() )
2709 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2714 values.reserve( mValue.size() );
2715 if ( mParam->usesStaticStrings() )
2717 for (
const QVariant &val : std::as_const( mValue ) )
2719 values << val.toString();
2724 const QStringList options = mParam->options();
2725 for (
const QVariant &val : std::as_const( mValue ) )
2727 const int i = val.toInt();
2728 values << ( options.size() > i ? options.at( i ) : QString() );
2732 const QString concatenated = values.join( tr(
"," ) );
2733 if ( concatenated.length() < 100 )
2734 mLineEdit->setText( concatenated );
2736 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
2744QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
2747 , mButtonGroup( new QButtonGroup( this ) )
2748 , mColumns( columns )
2750 mButtonGroup->setExclusive( !mParam->allowMultiple() );
2752 QGridLayout *l =
new QGridLayout();
2753 l->setContentsMargins( 0, 0, 0, 0 );
2755 int rows =
static_cast< int >( std::ceil( mParam->options().count() /
static_cast< double >( mColumns ) ) );
2756 for (
int i = 0; i < mParam->options().count(); ++i )
2758 QAbstractButton *button =
nullptr;
2759 if ( mParam->allowMultiple() )
2760 button =
new QCheckBox( mParam->options().at( i ) );
2762 button =
new QRadioButton( mParam->options().at( i ) );
2764 connect( button, &QAbstractButton::toggled,
this, [ = ]
2766 if ( !mBlockChangedSignal )
2770 mButtons.insert( i, button );
2772 mButtonGroup->addButton( button, i );
2773 l->addWidget( button, i % rows, i / rows );
2775 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
2778 if ( mParam->allowMultiple() )
2780 setContextMenuPolicy( Qt::CustomContextMenu );
2781 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
2785QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
2787 if ( mParam->allowMultiple() )
2790 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2792 if ( it.value()->isChecked() )
2793 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
2799 if ( mParam->usesStaticStrings() )
2800 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
2802 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
2806void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
2808 mBlockChangedSignal =
true;
2809 if ( mParam->allowMultiple() )
2811 QVariantList selected;
2812 if ( value.isValid() )
2813 selected = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
2814 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2816 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
2817 it.value()->setChecked( selected.contains( v ) );
2823 if ( v.type() == QVariant::List )
2824 v = v.toList().value( 0 );
2826 v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
2827 if ( mButtons.contains( v ) )
2828 mButtons.value( v )->setChecked(
true );
2830 mBlockChangedSignal =
false;
2834void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
2837 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
2838 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
2839 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
2840 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
2841 popupMenu.addAction( selectAllAction );
2842 popupMenu.addAction( clearAllAction );
2843 popupMenu.exec( QCursor::pos() );
2846void QgsProcessingEnumCheckboxPanelWidget::selectAll()
2848 mBlockChangedSignal =
true;
2849 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2850 it.value()->setChecked(
true );
2851 mBlockChangedSignal =
false;
2855void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
2857 mBlockChangedSignal =
true;
2858 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2859 it.value()->setChecked(
false );
2860 mBlockChangedSignal =
false;
2872 QVBoxLayout *vlayout =
new QVBoxLayout();
2873 vlayout->setContentsMargins( 0, 0, 0, 0 );
2875 mEnumWidget =
new QgsProcessingEnumModelerWidget();
2878 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
2879 mEnumWidget->setOptions( enumParam->options() );
2880 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
2882 vlayout->addWidget( mEnumWidget );
2883 setLayout( vlayout );
2886QgsProcessingParameterDefinition *QgsProcessingEnumParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
2888 auto param = std::make_unique< QgsProcessingParameterEnum >( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
2890 return param.release();
2900QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
2908 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
2910 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
2911 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
2912 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
2913 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [ = ]
2915 emit widgetValueHasChanged(
this );
2917 return mCheckboxPanel;
2926 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
2927 mPanel->setToolTip( parameterDefinition()->toolTip() );
2928 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [ = ]
2930 emit widgetValueHasChanged(
this );
2936 mComboBox =
new QComboBox();
2939 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
2940 const QStringList options = expParam->
options();
2941 const QVariantList iconList = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"icons" ) ).toList();
2942 for (
int i = 0; i < options.count(); ++i )
2944 const QIcon icon = iconList.value( i ).value< QIcon >();
2947 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
2949 mComboBox->addItem( icon, options.at( i ), i );
2952 mComboBox->setToolTip( parameterDefinition()->toolTip() );
2953 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
2954 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2956 emit widgetValueHasChanged(
this );
2965void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2969 if ( !value.isValid() )
2970 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
2977 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
2982 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
2986 else if ( mPanel || mCheckboxPanel )
2989 if ( value.isValid() )
2995 opts.reserve( v.size() );
2996 for ( QString i : v )
3002 opts.reserve( v.size() );
3008 mPanel->setValue( opts );
3009 else if ( mCheckboxPanel )
3010 mCheckboxPanel->setValue( opts );
3014QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3017 return mComboBox->currentData();
3019 return mPanel->value();
3020 else if ( mCheckboxPanel )
3021 return mCheckboxPanel->value();
3026QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
const
3028 return QStringList()
3034QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
const
3036 return QStringList()
3042QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3044 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3047QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3054 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3059 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3072QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3081 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() : nullptr );
3086 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3089 emit widgetValueHasChanged(
this );
3096 mPlainComboBox =
new QComboBox();
3097 mPlainComboBox->setEditable(
true );
3098 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3099 if ( widgetContext().project() )
3103 mPlainComboBox->addItem( layout->name() );
3106 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
3108 emit widgetValueHasChanged(
this );
3110 return mPlainComboBox;
3116void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3120 if ( !value.isValid() )
3121 mComboBox->setCurrentLayout(
nullptr );
3125 mComboBox->setCurrentLayout( l );
3127 mComboBox->setCurrentLayout(
nullptr );
3130 else if ( mPlainComboBox )
3133 mPlainComboBox->setCurrentText( v );
3137QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3142 return l ? l->
name() : QVariant();
3144 else if ( mPlainComboBox )
3145 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3153 if ( mPlainComboBox && context.
project() )
3157 mPlainComboBox->addItem( layout->name() );
3161QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
const
3163 return QStringList()
3169QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
const
3171 return QStringList()
3175QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3177 return tr(
"string representing the name of an existing print layout" );
3180QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3187 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3201 QVBoxLayout *vlayout =
new QVBoxLayout();
3202 vlayout->setContentsMargins( 0, 0, 0, 0 );
3204 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3206 mParentLayoutComboBox =
new QComboBox();
3207 QString initialParent;
3209 initialParent = itemParam->parentLayoutParameterName();
3211 if (
auto *lModel = widgetContext.
model() )
3214 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3215 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3219 mParentLayoutComboBox-> addItem( definition->
description(), definition->
name() );
3220 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3222 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3228 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3231 mParentLayoutComboBox->addItem( initialParent, initialParent );
3232 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3235 vlayout->addWidget( mParentLayoutComboBox );
3236 setLayout( vlayout );
3238QgsProcessingParameterDefinition *QgsProcessingLayoutItemParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3240 auto param = std::make_unique< QgsProcessingParameterLayoutItem >( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3242 return param.release();
3252QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3263 mComboBox->setAllowEmptyItem(
true );
3264 if ( layoutParam->
itemType() >= 0 )
3267 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3270 emit widgetValueHasChanged(
this );
3277 mLineEdit =
new QLineEdit();
3278 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3279 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3281 emit widgetValueHasChanged(
this );
3289void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3299 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterLayoutItem *
>( parameterDefinition() )->parentLayoutParameterName() )
3301 setLayoutParameterValue( wrapper->parameterValue() );
3304 setLayoutParameterValue( wrapper->parameterValue() );
3317void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3323 std::unique_ptr< QgsProcessingContext > tmpContext;
3324 if ( mProcessingContextGenerator )
3325 context = mProcessingContextGenerator->processingContext();
3329 tmpContext = std::make_unique< QgsProcessingContext >();
3330 context = tmpContext.get();
3334 setLayout( layout );
3337void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3340 mComboBox->setCurrentLayout( layout );
3343void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3347 if ( !value.isValid() )
3348 mComboBox->setItem(
nullptr );
3352 mComboBox->setItem( item );
3355 else if ( mLineEdit )
3358 mLineEdit->setText( v );
3362QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3367 return i ? i->
uuid() : QVariant();
3369 else if ( mLineEdit )
3370 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3375QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
const
3377 return QStringList()
3382QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
const
3384 return QStringList()
3389QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3391 return tr(
"string representing the UUID or ID of an existing print layout item" );
3394QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3401 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3406 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3413QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3420QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3422void QgsProcessingPointMapTool::deactivate()
3436 if ( e->button() == Qt::LeftButton )
3439 emit clicked( point );
3444void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3446 if ( e->key() == Qt::Key_Escape )
3461QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3464 QHBoxLayout *l =
new QHBoxLayout();
3465 l->setContentsMargins( 0, 0, 0, 0 );
3467 mLineEdit->setShowClearButton(
false );
3468 l->addWidget( mLineEdit, 1 );
3469 mButton =
new QToolButton();
3470 mButton->setText( QString( QChar( 0x2026 ) ) );
3471 l->addWidget( mButton );
3474 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3475 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3476 mButton->setVisible(
false );
3479void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
3482 mButton->setVisible(
true );
3485 mTool = std::make_unique< QgsProcessingPointMapTool >( mCanvas );
3486 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
3487 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
3490void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
3492 mLineEdit->setShowClearButton( allowNull );
3495QVariant QgsProcessingPointPanel::value()
const
3497 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
3500void QgsProcessingPointPanel::clear()
3507 QString newText = QStringLiteral(
"%1,%2" )
3508 .arg( QString::number( point.
x(),
'f' ),
3509 QString::number( point.
y(),
'f' ) );
3512 if ( mCrs.isValid() )
3514 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
3516 mLineEdit->setText( newText );
3519void QgsProcessingPointPanel::selectOnCanvas()
3524 mPrevTool = mCanvas->mapTool();
3525 mCanvas->setMapTool( mTool.get() );
3527 emit toggleDialogVisibility(
false );
3530void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3532 setValue( point, mCanvas->mapSettings().destinationCrs() );
3535void QgsProcessingPointPanel::pointPicked()
3540 mCanvas->setMapTool( mPrevTool );
3542 emit toggleDialogVisibility(
true );
3554 QVBoxLayout *vlayout =
new QVBoxLayout();
3555 vlayout->setContentsMargins( 0, 0, 0, 0 );
3557 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3559 mDefaultLineEdit =
new QLineEdit();
3560 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3561 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
3565 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
3568 vlayout->addWidget( mDefaultLineEdit );
3569 setLayout( vlayout );
3572QgsProcessingParameterDefinition *QgsProcessingPointParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3574 auto param = std::make_unique< QgsProcessingParameterPoint >( name, description, mDefaultLineEdit->text() );
3576 return param.release();
3585QWidget *QgsProcessingPointWidgetWrapper::createWidget()
3593 mPanel =
new QgsProcessingPointPanel(
nullptr );
3594 if ( widgetContext().mapCanvas() )
3595 mPanel->setMapCanvas( widgetContext().mapCanvas() );
3598 mPanel->setAllowNull(
true );
3600 mPanel->setToolTip( parameterDefinition()->toolTip() );
3602 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [ = ]
3604 emit widgetValueHasChanged(
this );
3608 setDialog( mDialog );
3614 mLineEdit =
new QLineEdit();
3615 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3616 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3618 emit widgetValueHasChanged(
this );
3630 mPanel->setMapCanvas( context.
mapCanvas() );
3633void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
3638 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ](
bool visible )
3641 mDialog->showMinimized();
3644 mDialog->showNormal();
3646 mDialog->activateWindow();
3653void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3657 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
3663 mPanel->setValue( p,
crs );
3666 else if ( mLineEdit )
3669 mLineEdit->setText( v );
3673QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
3677 return mPanel->value();
3679 else if ( mLineEdit )
3680 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3685QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
const
3687 return QStringList()
3693QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
const
3695 return QStringList()
3699QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
3701 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
3704QString QgsProcessingPointWidgetWrapper::parameterType()
const
3711 return new QgsProcessingPointWidgetWrapper( parameter, type );
3716 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3728 QVBoxLayout *vlayout =
new QVBoxLayout();
3729 vlayout->setContentsMargins( 0, 0, 0, 0 );
3731 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3733 mDefaultLineEdit =
new QLineEdit();
3734 mDefaultLineEdit->setToolTip( tr(
"Geometry as WKT" ) );
3735 mDefaultLineEdit->setPlaceholderText( tr(
"Geometry as WKT" ) );
3740 mDefaultLineEdit->setText( g.
asWkt() );
3743 vlayout->addWidget( mDefaultLineEdit );
3744 setLayout( vlayout );
3747QgsProcessingParameterDefinition *QgsProcessingGeometryParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3749 auto param = std::make_unique< QgsProcessingParameterGeometry >( name, description, mDefaultLineEdit->text() );
3751 return param.release();
3760QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
3768 mLineEdit =
new QLineEdit();
3769 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
3770 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
3772 emit widgetValueHasChanged(
this );
3780void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3786 mLineEdit->setText( g.
asWkt() );
3792QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
3795 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3800QStringList QgsProcessingGeometryWidgetWrapper::compatibleParameterTypes()
const
3802 return QStringList()
3810QStringList QgsProcessingGeometryWidgetWrapper::compatibleOutputTypes()
const
3812 return QStringList()
3816QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
3818 return tr(
"string in the Well-Known-Text format or a geometry value" );
3821QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
3828 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
3833 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3845 QVBoxLayout *vlayout =
new QVBoxLayout();
3846 vlayout->setContentsMargins( 0, 0, 0, 0 );
3848 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3851 mDefaultColorButton->setShowNull(
true );
3852 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
3858 mDefaultColorButton->setToNull();
3860 mDefaultColorButton->setColor(
c );
3861 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
3865 mDefaultColorButton->setToNull();
3866 mAllowOpacity->setChecked(
true );
3869 vlayout->addWidget( mDefaultColorButton );
3870 vlayout->addWidget( mAllowOpacity );
3871 setLayout( vlayout );
3874QgsProcessingParameterDefinition *QgsProcessingColorParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3876 auto param = std::make_unique< QgsProcessingParameterColor >( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
3878 return param.release();
3887QWidget *QgsProcessingColorWidgetWrapper::createWidget()
3897 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
3900 mColorButton->setShowNull(
true );
3903 mColorButton->setToolTip( parameterDefinition()->toolTip() );
3904 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
3912 emit widgetValueHasChanged(
this );
3915 return mColorButton;
3921void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3925 if ( !value.isValid() ||
3926 ( value.type() == QVariant::String && value.toString().isEmpty() )
3927 || ( value.type() == QVariant::Color && !value.value< QColor >().isValid() ) )
3928 mColorButton->setToNull();
3932 if ( !
c.isValid() && mColorButton->showNull() )
3933 mColorButton->setToNull();
3935 mColorButton->setColor(
c );
3940QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
3943 return mColorButton->isNull() ? QVariant() : mColorButton->color();
3948QStringList QgsProcessingColorWidgetWrapper::compatibleParameterTypes()
const
3950 return QStringList()
3956QStringList QgsProcessingColorWidgetWrapper::compatibleOutputTypes()
const
3958 return QStringList()
3962QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
3964 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
3967QString QgsProcessingColorWidgetWrapper::parameterType()
const
3974 return new QgsProcessingColorWidgetWrapper( parameter, type );
3979 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3990 QVBoxLayout *vlayout =
new QVBoxLayout();
3991 vlayout->setContentsMargins( 0, 0, 0, 0 );
3993 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3995 mDefaultLineEdit =
new QLineEdit();
3998 vlayout->addWidget( mDefaultLineEdit );
4000 mSourceParamComboBox =
new QComboBox();
4001 mDestParamComboBox =
new QComboBox();
4002 QString initialSource;
4003 QString initialDest;
4008 initialSource = itemParam->sourceCrsParameterName();
4009 initialDest = itemParam->destinationCrsParameterName();
4014 mSourceParamComboBox->addItem( QString(), QString() );
4015 mDestParamComboBox->addItem( QString(), QString() );
4016 if (
auto *lModel = widgetContext.
model() )
4019 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4020 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4022 if ( definition && it->parameterName() == definition->
name() )
4026 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4027 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4028 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4030 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4032 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4034 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4039 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4042 mSourceParamComboBox->addItem( initialSource, initialSource );
4043 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4045 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4048 mDestParamComboBox->addItem( initialDest, initialDest );
4049 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4052 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4053 vlayout->addWidget( mSourceParamComboBox );
4054 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4055 vlayout->addWidget( mDestParamComboBox );
4059 mStaticSourceWidget->setCrs( sourceCrs );
4062 mStaticDestWidget->setCrs( destCrs );
4064 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4065 vlayout->addWidget( mStaticSourceWidget );
4066 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4067 vlayout->addWidget( mStaticDestWidget );
4069 setLayout( vlayout );
4072QgsProcessingParameterDefinition *QgsProcessingCoordinateOperationParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4074 auto param = std::make_unique< QgsProcessingParameterCoordinateOperation >( name, description, mDefaultLineEdit->text(),
4075 mSourceParamComboBox->currentText(),
4076 mDestParamComboBox->currentText(),
4077 mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
4078 mStaticDestWidget->
crs().isValid() ? QVariant::fromValue( mStaticDestWidget->
crs() ) : QVariant() );
4080 return param.release();
4089QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4100 mOperationWidget->setShowMakeDefault(
false );
4101 mOperationWidget->setShowFallbackOption(
false );
4102 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4103 mOperationWidget->setSourceCrs( mSourceCrs );
4104 mOperationWidget->setDestinationCrs( mDestCrs );
4105 mOperationWidget->setMapCanvas( mCanvas );
4110 mOperationWidget->setSelectedOperation( deets );
4115 emit widgetValueHasChanged(
this );
4118 return mOperationWidget;
4124 mLineEdit =
new QLineEdit();
4125 QHBoxLayout *layout =
new QHBoxLayout();
4126 layout->addWidget( mLineEdit, 1 );
4127 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4129 emit widgetValueHasChanged(
this );
4132 QToolButton *button =
new QToolButton();
4133 button->setText( QString( QChar( 0x2026 ) ) );
4134 connect( button, &QToolButton::clicked,
this, [ = ]
4136 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4139 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4140 emit widgetValueHasChanged(
this );
4143 layout->addWidget( button );
4145 QWidget *w =
new QWidget();
4146 layout->setContentsMargins( 0, 0, 0, 0 );
4147 w->setLayout( layout );
4155void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4167 setSourceCrsParameterValue( wrapper->parameterValue() );
4170 setSourceCrsParameterValue( wrapper->parameterValue() );
4175 setDestinationCrsParameterValue( wrapper->parameterValue() );
4178 setDestinationCrsParameterValue( wrapper->parameterValue() );
4193 if ( mOperationWidget )
4194 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4197void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4199 if ( mOperationWidget )
4201 if ( !value.isValid() ||
4202 ( value.type() == QVariant::String ) )
4205 deets.
proj = value.toString();
4206 mOperationWidget->setSelectedOperation( deets );
4211 if ( !value.isValid() ||
4212 ( value.type() == QVariant::String ) )
4214 mLineEdit->setText( value.toString() );
4219QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4221 if ( mOperationWidget )
4222 return mOperationWidget->selectedOperation().proj;
4223 else if ( mLineEdit )
4224 return mLineEdit->text();
4229QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleParameterTypes()
const
4231 return QStringList()
4236QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleOutputTypes()
const
4238 return QStringList()
4243QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4245 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4248void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4251 std::unique_ptr< QgsProcessingContext > tmpContext;
4252 if ( mProcessingContextGenerator )
4253 context = mProcessingContextGenerator->processingContext();
4257 tmpContext = std::make_unique< QgsProcessingContext >();
4258 context = tmpContext.get();
4262 if ( mOperationWidget )
4264 mOperationWidget->setSourceCrs( mSourceCrs );
4265 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4269void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4272 std::unique_ptr< QgsProcessingContext > tmpContext;
4273 if ( mProcessingContextGenerator )
4274 context = mProcessingContextGenerator->processingContext();
4278 tmpContext = std::make_unique< QgsProcessingContext >();
4279 context = tmpContext.get();
4283 if ( mOperationWidget )
4285 mOperationWidget->setDestinationCrs( mDestCrs );
4286 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4290QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
4297 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
4302 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4315 QHBoxLayout *hl =
new QHBoxLayout();
4316 hl->setContentsMargins( 0, 0, 0, 0 );
4318 mLineEdit =
new QLineEdit();
4319 mLineEdit->setEnabled(
false );
4320 hl->addWidget( mLineEdit, 1 );
4322 mToolButton =
new QToolButton();
4323 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4324 hl->addWidget( mToolButton );
4330 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4333 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4336void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4341void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4343 if ( value.isValid() )
4344 mValue = value.type() == QVariant::List ? value.
toList() : QVariantList() << value;
4348 updateSummaryText();
4352void QgsProcessingFieldPanelWidget::showDialog()
4354 QVariantList availableOptions;
4355 availableOptions.reserve( mFields.size() );
4356 for (
const QgsField &field : std::as_const( mFields ) )
4358 availableOptions << field.name();
4364 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4365 widget->setPanelTitle( mParam->description() );
4367 widget->setValueFormatter( [](
const QVariant & v ) -> QString
4369 return v.toString();
4372 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
4374 setValue( widget->selectedOptions() );
4381 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4383 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
4385 return v.toString();
4389 setValue( dlg.selectedOptions() );
4394void QgsProcessingFieldPanelWidget::updateSummaryText()
4399 if ( mValue.empty() )
4401 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4406 values.reserve( mValue.size() );
4407 for (
const QVariant &val : std::as_const( mValue ) )
4409 values << val.toString();
4412 const QString concatenated = values.join( tr(
"," ) );
4413 if ( concatenated.length() < 100 )
4414 mLineEdit->setText( concatenated );
4416 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4428 QVBoxLayout *vlayout =
new QVBoxLayout();
4429 vlayout->setContentsMargins( 0, 0, 0, 0 );
4431 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4432 mParentLayerComboBox =
new QComboBox();
4434 QString initialParent;
4436 initialParent = fieldParam->parentLayerParameterName();
4438 if (
auto *lModel = widgetContext.
model() )
4441 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4442 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4446 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4447 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4449 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4454 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4455 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4457 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4464 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4465 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4467 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4474 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4477 mParentLayerComboBox->addItem( initialParent, initialParent );
4478 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4481 vlayout->addWidget( mParentLayerComboBox );
4483 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4484 mDataTypeComboBox =
new QComboBox();
4492 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData( fieldParam->dataType() ) );
4494 vlayout->addWidget( mDataTypeComboBox );
4496 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4498 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4500 vlayout->addWidget( mAllowMultipleCheckBox );
4502 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4503 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4505 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4507 vlayout->addWidget( mDefaultToAllCheckBox );
4509 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
4511 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4514 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4516 mDefaultLineEdit =
new QLineEdit();
4517 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4521 mDefaultLineEdit->setText( fields.join(
';' ) );
4523 vlayout->addWidget( mDefaultLineEdit );
4525 setLayout( vlayout );
4528QgsProcessingParameterDefinition *QgsProcessingFieldParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4532 QVariant defaultValue;
4533 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4535 defaultValue = mDefaultLineEdit->text();
4537 auto param = std::make_unique< QgsProcessingParameterField >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
4539 return param.release();
4548QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
4558 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
4559 mPanel->setToolTip( parameterDefinition()->toolTip() );
4560 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [ = ]
4562 emit widgetValueHasChanged(
this );
4582 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4585 emit widgetValueHasChanged(
this );
4593 mLineEdit =
new QLineEdit();
4594 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
4595 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4597 emit widgetValueHasChanged(
this );
4606void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4616 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterField *
>( parameterDefinition() )->parentLayerParameterName() )
4618 setParentLayerWrapperValue( wrapper );
4621 setParentLayerWrapperValue( wrapper );
4638 std::unique_ptr< QgsProcessingContext > tmpContext;
4639 if ( mProcessingContextGenerator )
4640 context = mProcessingContextGenerator->processingContext();
4644 tmpContext = std::make_unique< QgsProcessingContext >();
4645 context = tmpContext.get();
4650 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
4660 bool valueSet =
false;
4664 if ( layers.count() > 1 )
4666 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
4668 const QList< QgsMapLayer * > remainingLayers = layers.mid( 1 );
4674 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer );
4675 if ( !vlayer || !vlayer->
isValid() )
4681 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
4684 fields.
remove( fieldIdx );
4689 mComboBox->setFields( fields );
4691 mPanel->setFields( filterFields( fields ) );
4697 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
4699 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
4703 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
4706 mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
4707 layer = mParentLayer.get();
4715 mComboBox->setLayer( layer );
4717 mPanel->setFields( filterFields( layer->
fields() ) );
4727 const QgsFields fields = source->fields();
4729 mComboBox->setFields( fields );
4731 mPanel->setFields( filterFields( fields ) );
4740 mComboBox->setLayer(
nullptr );
4744 if ( value.isValid() && widgetContext().messageBar() )
4747 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent field could not be populated" ),
4757 val.reserve( mPanel->fields().size() );
4758 for (
const QgsField &field : mPanel->fields() )
4759 val << field.name();
4760 setWidgetValue( val, *context );
4763 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
4766void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4770 if ( !value.isValid() )
4771 mComboBox->setField( QString() );
4775 mComboBox->setField( v );
4781 if ( value.isValid() )
4784 opts.reserve( v.size() );
4785 for (
const QString &i : v )
4789 mPanel->setValue( opts );
4791 else if ( mLineEdit )
4797 mLineEdit->setText( v.join(
';' ) );
4806QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
4809 return mComboBox->currentField();
4811 return mPanel->value();
4812 else if ( mLineEdit )
4817 return mLineEdit->text().split(
';' );
4820 return mLineEdit->text();
4826QStringList QgsProcessingFieldWidgetWrapper::compatibleParameterTypes()
const
4828 return QStringList()
4834QStringList QgsProcessingFieldWidgetWrapper::compatibleOutputTypes()
const
4836 return QStringList()
4840QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
4842 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
4845const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
4847 if ( mComboBox && mComboBox->layer() )
4848 return mComboBox->layer();
4853QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
4866 if ( f.isNumeric() )
4871 if ( f.type() == QVariant::String )
4876 if ( f.type() == QVariant::Date || f.type() == QVariant::Time || f.type() == QVariant::DateTime )
4881 if ( f.type() == QVariant::ByteArray )
4886 if ( f.type() == QVariant::Bool )
4895QString QgsProcessingFieldWidgetWrapper::parameterType()
const
4902 return new QgsProcessingFieldWidgetWrapper( parameter, type );
4907 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4918 QVBoxLayout *vlayout =
new QVBoxLayout();
4919 vlayout->setContentsMargins( 0, 0, 0, 0 );
4921 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4923 mDefaultComboBox =
new QComboBox();
4924 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
4927 for (
const QString &theme : mapThemes )
4931 mDefaultComboBox->setEditable(
true );
4935 if ( themeParam->defaultValueForGui().isValid() )
4938 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
4941 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
4943 vlayout->addWidget( mDefaultComboBox );
4945 setLayout( vlayout );
4948QgsProcessingParameterDefinition *QgsProcessingMapThemeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4950 QVariant defaultVal;
4951 if ( mDefaultComboBox->currentText().isEmpty() )
4952 defaultVal = QVariant();
4954 defaultVal = mDefaultComboBox->currentText();
4955 auto param = std::make_unique< QgsProcessingParameterMapTheme>( name, description, defaultVal );
4957 return param.release();
4967QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
4971 mComboBox =
new QComboBox();
4974 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
4977 for (
const QString &theme : mapThemes )
4989 mComboBox->setEditable(
true );
4993 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4994 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
4996 emit widgetValueHasChanged(
this );
5002void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5006 if ( !value.isValid() )
5007 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5010 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5012 const QString prev = mComboBox->currentText();
5013 mComboBox->setCurrentText( v );
5015 emit widgetValueHasChanged(
this );
5018 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5022QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5025 return mComboBox->currentData().toInt() == -1 ? QVariant() :
5026 !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5027 : mComboBox->currentData();
5032QStringList QgsProcessingMapThemeWidgetWrapper::compatibleParameterTypes()
const
5034 return QStringList()
5040QStringList QgsProcessingMapThemeWidgetWrapper::compatibleOutputTypes()
const
5042 return QStringList()
5046QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5048 return tr(
"map theme as a string value (e.g. 'base maps')" );
5051QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5058 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5063 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5076 QVBoxLayout *vlayout =
new QVBoxLayout();
5077 vlayout->setContentsMargins( 0, 0, 0, 0 );
5079 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5081 mTypeComboBox =
new QComboBox();
5086 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( datetimeParam->dataType() ) );
5088 mTypeComboBox->setCurrentIndex( 0 );
5089 vlayout->addWidget( mTypeComboBox );
5091 setLayout( vlayout );
5094QgsProcessingParameterDefinition *QgsProcessingDateTimeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5096 auto param = std::make_unique< QgsProcessingParameterDateTime >( name, description );
5099 return param.release();
5109QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5114 switch ( dateTimeParam->
dataType() )
5118 widget = mDateTimeEdit;
5141 widget->setToolTip( parameterDefinition()->toolTip() );
5143 if ( mDateTimeEdit )
5147 emit widgetValueHasChanged(
this );
5150 else if ( mDateEdit )
5154 emit widgetValueHasChanged(
this );
5157 else if ( mTimeEdit )
5161 emit widgetValueHasChanged(
this );
5170 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5173void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5175 if ( mDateTimeEdit )
5179 else if ( mDateEdit )
5183 else if ( mTimeEdit )
5189QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5191 if ( mDateTimeEdit )
5192 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5193 else if ( mDateEdit )
5194 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5195 else if ( mTimeEdit )
5196 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5201QStringList QgsProcessingDateTimeWidgetWrapper::compatibleParameterTypes()
const
5203 return QStringList()
5208QStringList QgsProcessingDateTimeWidgetWrapper::compatibleOutputTypes()
const
5210 return QStringList()
5215QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5218 if ( dateTimeParam )
5220 switch ( dateTimeParam->
dataType() )
5223 return tr(
"datetime value, or a ISO string representation of a datetime" );
5226 return tr(
"date value, or a ISO string representation of a date" );
5229 return tr(
"time value, or a ISO string representation of a time" );
5235QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5242 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5256 QVBoxLayout *vlayout =
new QVBoxLayout();
5257 vlayout->setContentsMargins( 0, 0, 0, 0 );
5259 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5260 mProviderComboBox =
new QComboBox();
5261 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
5262 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
5263 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
5265 vlayout->addWidget( mProviderComboBox );
5267 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5269 mDefaultEdit =
new QLineEdit();
5270 vlayout->addWidget( mDefaultEdit );
5271 setLayout( vlayout );
5273 if ( connectionParam )
5275 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5280QgsProcessingParameterDefinition *QgsProcessingProviderConnectionParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5282 QVariant defaultVal;
5283 if ( mDefaultEdit->text().isEmpty() )
5284 defaultVal = QVariant();
5286 defaultVal = mDefaultEdit->text();
5287 auto param = std::make_unique< QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5289 return param.release();
5299QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5305 mProviderComboBox->setAllowEmptyConnection(
true );
5313 mProviderComboBox->setEditable(
true );
5317 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5318 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [ = ](
const QString & )
5320 if ( mBlockSignals )
5323 emit widgetValueHasChanged(
this );
5326 return mProviderComboBox;
5331 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5334void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5338 if ( !value.isValid() )
5339 mProviderComboBox->setCurrentIndex( -1 );
5342 if ( mProviderComboBox->isEditable() )
5344 const QString prev = mProviderComboBox->currentText();
5346 mProviderComboBox->setConnection( v );
5347 mProviderComboBox->setCurrentText( v );
5351 emit widgetValueHasChanged(
this );
5354 mProviderComboBox->setConnection( v );
5358QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5360 if ( mProviderComboBox )
5361 if ( mProviderComboBox->isEditable() )
5362 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5364 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5369QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleParameterTypes()
const
5371 return QStringList()
5378QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleOutputTypes()
const
5380 return QStringList()
5384QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5386 return tr(
"connection name as a string value" );
5389QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5396 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5411 QVBoxLayout *vlayout =
new QVBoxLayout();
5412 vlayout->setContentsMargins( 0, 0, 0, 0 );
5414 mConnectionParamComboBox =
new QComboBox();
5415 QString initialConnection;
5421 if (
auto *lModel = widgetContext.
model() )
5424 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5425 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5427 if ( definition && it->parameterName() == definition->
name() )
5433 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5434 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5436 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5441 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5444 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5445 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5448 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5449 vlayout->addWidget( mConnectionParamComboBox );
5451 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5453 mDefaultEdit =
new QLineEdit();
5454 vlayout->addWidget( mDefaultEdit );
5455 setLayout( vlayout );
5463QgsProcessingParameterDefinition *QgsProcessingDatabaseSchemaParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5465 QVariant defaultVal;
5466 if ( mDefaultEdit->text().isEmpty() )
5467 defaultVal = QVariant();
5469 defaultVal = mDefaultEdit->text();
5470 auto param = std::make_unique< QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5472 return param.release();
5482QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5488 mSchemaComboBox->setAllowEmptySchema(
true );
5496 mSchemaComboBox->comboBox()->setEditable(
true );
5500 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5501 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
5503 if ( mBlockSignals )
5506 emit widgetValueHasChanged( this );
5509 return mSchemaComboBox;
5514 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5521 std::unique_ptr< QgsProcessingContext > tmpContext;
5522 if ( mProcessingContextGenerator )
5523 context = mProcessingContextGenerator->processingContext();
5527 tmpContext = std::make_unique< QgsProcessingContext >();
5528 context = tmpContext.get();
5534 if ( mSchemaComboBox )
5535 mSchemaComboBox->setConnectionName( connection, qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId() );
5539 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5542void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5546 if ( !value.isValid() )
5547 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5550 if ( mSchemaComboBox->comboBox()->isEditable() )
5552 const QString prev = mSchemaComboBox->comboBox()->currentText();
5554 mSchemaComboBox->setSchema( v );
5555 mSchemaComboBox->comboBox()->setCurrentText( v );
5559 emit widgetValueHasChanged(
this );
5562 mSchemaComboBox->setSchema( v );
5566QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5568 if ( mSchemaComboBox )
5569 if ( mSchemaComboBox->comboBox()->isEditable() )
5570 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5572 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5577QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleParameterTypes()
const
5579 return QStringList()
5586QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleOutputTypes()
const
5588 return QStringList()
5592QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5594 return tr(
"database schema name as a string value" );
5597QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5604 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5607void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5619 setParentConnectionWrapperValue( wrapper );
5622 setParentConnectionWrapperValue( wrapper );
5646 QVBoxLayout *vlayout =
new QVBoxLayout();
5647 vlayout->setContentsMargins( 0, 0, 0, 0 );
5649 mConnectionParamComboBox =
new QComboBox();
5650 mSchemaParamComboBox =
new QComboBox();
5651 QString initialConnection;
5652 QString initialSchema;
5659 if (
auto *lModel = widgetContext.
model() )
5662 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5663 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5665 if ( definition && it->parameterName() == definition->
name() )
5670 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5671 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5673 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5678 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
5679 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5681 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5687 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5690 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5691 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5694 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
5697 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
5698 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5701 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5702 vlayout->addWidget( mConnectionParamComboBox );
5704 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
5705 vlayout->addWidget( mSchemaParamComboBox );
5707 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5709 mDefaultEdit =
new QLineEdit();
5710 vlayout->addWidget( mDefaultEdit );
5711 setLayout( vlayout );
5719QgsProcessingParameterDefinition *QgsProcessingDatabaseTableParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5721 QVariant defaultVal;
5722 if ( mDefaultEdit->text().isEmpty() )
5723 defaultVal = QVariant();
5725 defaultVal = mDefaultEdit->text();
5726 auto param = std::make_unique< QgsProcessingParameterDatabaseTable>( name, description,
5727 mConnectionParamComboBox->currentData().toString(),
5728 mSchemaParamComboBox->currentData().toString(),
5731 return param.release();
5741QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
5747 mTableComboBox->setAllowEmptyTable(
true );
5750 mTableComboBox->comboBox()->setEditable(
true );
5752 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
5753 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
5755 if ( mBlockSignals )
5758 emit widgetValueHasChanged( this );
5761 return mTableComboBox;
5766 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5773 std::unique_ptr< QgsProcessingContext > tmpContext;
5774 if ( mProcessingContextGenerator )
5775 context = mProcessingContextGenerator->processingContext();
5779 tmpContext = std::make_unique< QgsProcessingContext >();
5780 context = tmpContext.get();
5785 mProvider = qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId();
5786 if ( mTableComboBox && !mSchema.isEmpty() )
5788 mTableComboBox->setSchema( mSchema );
5789 mTableComboBox->setConnectionName( mConnection, mProvider );
5793 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5801 std::unique_ptr< QgsProcessingContext > tmpContext;
5802 if ( mProcessingContextGenerator )
5803 context = mProcessingContextGenerator->processingContext();
5807 tmpContext = std::make_unique< QgsProcessingContext >();
5808 context = tmpContext.get();
5814 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
5816 mTableComboBox->setSchema( mSchema );
5817 mTableComboBox->setConnectionName( mConnection, mProvider );
5821 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5826void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5830 if ( !value.isValid() )
5831 mTableComboBox->comboBox()->setCurrentIndex( -1 );
5834 if ( mTableComboBox->comboBox()->isEditable() )
5836 const QString prev = mTableComboBox->comboBox()->currentText();
5838 mTableComboBox->setTable( v );
5839 mTableComboBox->comboBox()->setCurrentText( v );
5843 emit widgetValueHasChanged(
this );
5846 mTableComboBox->setTable( v );
5850QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
5852 if ( mTableComboBox )
5853 if ( mTableComboBox->comboBox()->isEditable() )
5854 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
5856 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
5861QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleParameterTypes()
const
5863 return QStringList()
5869QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleOutputTypes()
const
5871 return QStringList()
5876QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
5878 return tr(
"database table name as a string value" );
5881QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
5888 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
5891void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5903 setParentConnectionWrapperValue( wrapper );
5906 setParentConnectionWrapperValue( wrapper );
5911 setParentSchemaWrapperValue( wrapper );
5914 setParentSchemaWrapperValue( wrapper );
5934 QVBoxLayout *vlayout =
new QVBoxLayout();
5935 vlayout->setContentsMargins( 0, 0, 0, 0 );
5937 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5940 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
5943 if ( extentParam->defaultValueForGui().isValid() )
5947 mDefaultWidget->setCurrentExtent( rect,
crs );
5948 mDefaultWidget->setOutputExtentFromCurrent();
5952 mDefaultWidget->clear();
5956 vlayout->addWidget( mDefaultWidget );
5957 setLayout( vlayout );
5960QgsProcessingParameterDefinition *QgsProcessingExtentParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5962 const QString defaultVal = mDefaultWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
5963 QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ),
5964 QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ),
5965 QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ),
5966 QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ),
5967 mDefaultWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mDefaultWidget->outputCrs().authid() ) : QString()
5969 auto param = std::make_unique< QgsProcessingParameterExtent >( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
5971 return param.release();
5982QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
5992 if ( widgetContext().mapCanvas() )
5993 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
5996 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
5998 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6002 emit widgetValueHasChanged(
this );
6006 setDialog( mDialog );
6008 return mExtentWidget;
6018 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6021void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6029 mDialog->showMinimized();
6032 mDialog->showNormal();
6034 mDialog->activateWindow();
6041void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6043 if ( mExtentWidget )
6045 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
6046 mExtentWidget->clear();
6051 mExtentWidget->setCurrentExtent( r,
crs );
6052 mExtentWidget->setOutputExtentFromUser( r,
crs );
6057QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6059 if ( mExtentWidget )
6061 const QString val = mExtentWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
6062 QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ),
6063 QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ),
6064 QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ),
6065 QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ),
6066 mExtentWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mExtentWidget->outputCrs().authid() ) : QString()
6069 return val.isEmpty() ? QVariant() : QVariant( val );
6075QStringList QgsProcessingExtentWidgetWrapper::compatibleParameterTypes()
const
6077 return QStringList()
6090QStringList QgsProcessingExtentWidgetWrapper::compatibleOutputTypes()
const
6092 return QStringList()
6099QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6101 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6104QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6111 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6116 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6128 QVBoxLayout *vlayout =
new QVBoxLayout();
6129 vlayout->setContentsMargins( 0, 0, 0, 0 );
6131 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6146 for (
int i : layerParam->dataTypes() )
6148 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6152 vlayout->addWidget( mLayerTypeComboBox );
6154 setLayout( vlayout );
6157QgsProcessingParameterDefinition *QgsProcessingMapLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6159 QList< int > dataTypes;
6160 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6161 dataTypes << v.toInt();
6163 auto param = std::make_unique< QgsProcessingParameterMapLayer >( name, description );
6164 param->setDataTypes( dataTypes );
6166 return param.release();
6175QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6177 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6185 mComboBox->setEditable(
true );
6189 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6191 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [ = ]()
6193 if ( mBlockSignals )
6196 emit widgetValueHasChanged(
this );
6199 setWidgetContext( widgetContext() );
6208 mComboBox->setWidgetContext( context );
6213 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6219void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6222 mComboBox->setValue( value, context );
6225QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6227 return mComboBox ? mComboBox->value() : QVariant();
6230QStringList QgsProcessingMapLayerWidgetWrapper::compatibleParameterTypes()
const
6232 return QStringList()
6244QStringList QgsProcessingMapLayerWidgetWrapper::compatibleOutputTypes()
const
6246 return QStringList()
6254QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6256 return tr(
"path to a map layer" );
6273QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6280 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6285 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6294 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6299QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleParameterTypes()
const
6301 return QStringList()
6308QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleOutputTypes()
const
6310 return QStringList()
6318QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6320 return tr(
"path to a raster layer" );
6323QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6330 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6335 Q_UNUSED( context );
6336 Q_UNUSED( widgetContext );
6337 Q_UNUSED( definition );
6351 QVBoxLayout *vlayout =
new QVBoxLayout();
6352 vlayout->setContentsMargins( 0, 0, 0, 0 );
6354 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6364 for (
int i : vectorParam->dataTypes() )
6366 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6370 vlayout->addWidget( mGeometryTypeComboBox );
6372 setLayout( vlayout );
6375QgsProcessingParameterDefinition *QgsProcessingVectorLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6377 QList< int > dataTypes;
6378 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6379 dataTypes << v.toInt();
6381 auto param = std::make_unique< QgsProcessingParameterVectorLayer >( name, description, dataTypes );
6383 return param.release();
6388 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6393QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleParameterTypes()
const
6395 return QStringList()
6402QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleOutputTypes()
const
6404 return QStringList()
6412QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6414 return tr(
"path to a vector layer" );
6420 return param->dataTypes();
6422 return QList< int >();
6425QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6432 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6437 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6449 QVBoxLayout *vlayout =
new QVBoxLayout();
6450 vlayout->setContentsMargins( 0, 0, 0, 0 );
6452 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6462 for (
int i : sourceParam->dataTypes() )
6464 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6472 vlayout->addWidget( mGeometryTypeComboBox );
6474 setLayout( vlayout );
6477QgsProcessingParameterDefinition *QgsProcessingFeatureSourceParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6479 QList< int > dataTypes;
6480 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6481 dataTypes << v.toInt();
6483 auto param = std::make_unique< QgsProcessingParameterFeatureSource >( name, description, dataTypes );
6485 return param.release();
6489 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6494QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleParameterTypes()
const
6496 return QStringList()
6504QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleOutputTypes()
const
6506 return QStringList()
6514QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6516 return tr(
"path to a vector layer" );
6522 return param->dataTypes();
6524 return QList< int >();
6527QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6534 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6539 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6547 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6552QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleParameterTypes()
const
6554 return QStringList()
6561QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleOutputTypes()
const
6563 return QStringList()
6571QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6573 return tr(
"path to a mesh layer" );
6576QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6583 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6588 Q_UNUSED( context );
6589 Q_UNUSED( widgetContext );
6590 Q_UNUSED( definition );
6602QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6606 QHBoxLayout *hl =
new QHBoxLayout();
6607 hl->setContentsMargins( 0, 0, 0, 0 );
6609 mLineEdit =
new QLineEdit();
6610 mLineEdit->setEnabled(
false );
6611 hl->addWidget( mLineEdit, 1 );
6613 mToolButton =
new QToolButton();
6614 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6615 hl->addWidget( mToolButton );
6621 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6624 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6627void QgsProcessingRasterBandPanelWidget::setBands(
const QList< int > &bands )
6632void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6637void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6639 if ( value.isValid() )
6640 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
6644 updateSummaryText();
6648void QgsProcessingRasterBandPanelWidget::showDialog()
6650 QVariantList availableOptions;
6651 availableOptions.reserve( mBands.size() );
6652 for (
int band : std::as_const( mBands ) )
6654 availableOptions << band;
6660 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6661 widget->setPanelTitle( mParam->description() );
6663 widget->setValueFormatter( [
this](
const QVariant & v ) -> QString
6665 int band = v.toInt();
6666 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6669 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
6671 setValue( widget->selectedOptions() );
6678 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6680 dlg.setValueFormatter( [
this](
const QVariant & v ) -> QString
6682 int band = v.toInt();
6683 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6687 setValue( dlg.selectedOptions() );
6692void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6695 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6707 QVBoxLayout *vlayout =
new QVBoxLayout();
6708 vlayout->setContentsMargins( 0, 0, 0, 0 );
6710 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6712 mDefaultLineEdit =
new QLineEdit();
6713 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6718 for (
int b : bands )
6720 defVal << QString::number( b );
6723 mDefaultLineEdit->setText( defVal.join(
';' ) );
6725 vlayout->addWidget( mDefaultLineEdit );
6727 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6728 mParentLayerComboBox =
new QComboBox();
6730 QString initialParent;
6732 initialParent = bandParam->parentLayerParameterName();
6734 if (
auto *lModel = widgetContext.
model() )
6737 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6738 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6742 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
6743 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6745 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6751 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6754 mParentLayerComboBox->addItem( initialParent, initialParent );
6755 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6758 vlayout->addWidget( mParentLayerComboBox );
6760 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6762 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6764 vlayout->addWidget( mAllowMultipleCheckBox );
6765 setLayout( vlayout );
6768QgsProcessingParameterDefinition *QgsProcessingBandParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6770 auto param = std::make_unique< QgsProcessingParameterBand >( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6772 return param.release();
6781QWidget *QgsProcessingBandWidgetWrapper::createWidget()
6791 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
6792 mPanel->setToolTip( parameterDefinition()->toolTip() );
6793 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [ = ]
6795 emit widgetValueHasChanged(
this );
6804 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6807 emit widgetValueHasChanged(
this );
6815 mLineEdit =
new QLineEdit();
6816 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6817 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
6819 emit widgetValueHasChanged(
this );
6828void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6838 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterBand *
>( parameterDefinition() )->parentLayerParameterName() )
6840 setParentLayerWrapperValue( wrapper );
6843 setParentLayerWrapperValue( wrapper );
6860 std::unique_ptr< QgsProcessingContext > tmpContext;
6861 if ( mProcessingContextGenerator )
6862 context = mProcessingContextGenerator->processingContext();
6866 tmpContext = std::make_unique< QgsProcessingContext >();
6867 context = tmpContext.get();
6873 if ( layer && layer->
isValid() )
6877 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
6880 mParentLayer.reset( qobject_cast< QgsRasterLayer * >( ownedLayer.release() ) );
6881 layer = mParentLayer.get();
6889 mComboBox->setLayer( layer );
6893 if ( provider && layer->
isValid() )
6898 QHash< int, QString > bandNames;
6899 for (
int i = 1; i <= nBands; ++i )
6904 mPanel->setBands( bands );
6905 mPanel->setBandNames( bandNames );
6912 mComboBox->setLayer(
nullptr );
6914 mPanel->setBands( QList< int >() );
6916 if ( value.isValid() && widgetContext().messageBar() )
6919 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent bands could not be populated" ),
6924 if ( parameterDefinition()->defaultValueForGui().isValid() )
6925 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6928void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6932 if ( !value.isValid() )
6933 mComboBox->setBand( -1 );
6937 mComboBox->setBand( v );
6943 if ( value.isValid() )
6946 opts.reserve( v.size() );
6951 mPanel->setValue( value.isValid() ? opts : QVariant() );
6953 else if ( mLineEdit )
6960 opts.reserve( v.size() );
6962 opts << QString::number( i );
6963 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
6967 if ( value.isValid() )
6975QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
6978 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
6980 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
6981 else if ( mLineEdit )
6986#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
6987 const QStringList parts = mLineEdit->text().split(
';', QString::SkipEmptyParts );
6989 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
6992 res.reserve( parts.count() );
6993 for (
const QString &s : parts )
6996 int band = s.toInt( &ok );
7000 return res.
isEmpty() ? QVariant() : res;
7004 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7011QStringList QgsProcessingBandWidgetWrapper::compatibleParameterTypes()
const
7013 return QStringList()
7019QStringList QgsProcessingBandWidgetWrapper::compatibleOutputTypes()
const
7021 return QStringList()
7025QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7027 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7030QString QgsProcessingBandWidgetWrapper::parameterType()
const
7037 return new QgsProcessingBandWidgetWrapper( parameter, type );
7042 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7055 QHBoxLayout *hl =
new QHBoxLayout();
7056 hl->setContentsMargins( 0, 0, 0, 0 );
7058 mLineEdit =
new QLineEdit();
7059 mLineEdit->setEnabled(
false );
7060 hl->addWidget( mLineEdit, 1 );
7062 mToolButton =
new QToolButton();
7063 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7064 hl->addWidget( mToolButton );
7070 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7073 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7076void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7078 if ( value.isValid() )
7079 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
7083 updateSummaryText();
7087void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7094 if ( mValue.removeAll( layerId ) )
7096 updateSummaryText();
7103void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7109 switch ( mParam->layerType() )
7267void QgsProcessingMultipleLayerPanelWidget::showDialog()
7272 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
7273 widget->setPanelTitle( mParam->description() );
7274 widget->setProject( mProject );
7275 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
7277 setValue( widget->selectedOptions() );
7284 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7285 dlg.setProject( mProject );
7288 setValue( dlg.selectedOptions() );
7293void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7296 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7306 QVBoxLayout *vlayout =
new QVBoxLayout();
7307 vlayout->setContentsMargins( 0, 0, 0, 0 );
7309 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7310 mLayerTypeComboBox =
new QComboBox();
7324 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData( layersParam->layerType() ) );
7326 vlayout->addWidget( mLayerTypeComboBox );
7327 setLayout( vlayout );
7330QgsProcessingParameterDefinition *QgsProcessingMultipleLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
7332 auto param = std::make_unique< QgsProcessingParameterMultipleLayers >( name, description,
static_cast< QgsProcessing::SourceType >( mLayerTypeComboBox->currentData().toInt() ) );
7334 return param.release();
7343QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7347 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7348 mPanel->setToolTip( parameterDefinition()->toolTip() );
7349 mPanel->setProject( widgetContext().project() );
7351 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7352 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [ = ]
7354 emit widgetValueHasChanged(
this );
7364 mPanel->setProject( context.
project() );
7366 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7370void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7375 if ( value.isValid() )
7378 opts.reserve( v.size() );
7380 opts << l->source();
7383 for (
const QVariant &v : value.toList() )
7385 if ( v.userType() == QMetaType::type(
"QgsProcessingModelChildParameterSource" ) )
7387 const QgsProcessingModelChildParameterSource source = v.value< QgsProcessingModelChildParameterSource >();
7388 opts << QVariant::fromValue( source );
7393 mPanel->setValue( value.isValid() ? opts : QVariant() );
7397QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7400 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7405QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleParameterTypes()
const
7407 return QStringList()
7419QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleOutputTypes()
const
7421 return QStringList()
7430QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7432 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7435QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7442 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7447 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7456 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7461QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleParameterTypes()
const
7463 return QStringList()
7470QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleOutputTypes()
const
7472 return QStringList()
7480QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7482 return tr(
"path to a point cloud layer" );
7485QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7492 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7497 Q_UNUSED( context );
7498 Q_UNUSED( widgetContext );
7499 Q_UNUSED( definition );
7516QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleParameterTypes()
const
7518 return QStringList()
7526QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleOutputTypes()
const
7528 return QStringList()
7533QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7535 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7538QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7545 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7550 Q_UNUSED( context );
7551 Q_UNUSED( widgetContext );
7552 Q_UNUSED( definition );
7563 if ( mWidgetContext.project() )
7564 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7568QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7579 mComboBox->setEditable(
true );
7583 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7585 if ( mWidgetContext.project() )
7586 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7589 mComboBox->setAllowEmptyLayer(
true );
7593 if ( mBlockSignals )
7596 emit widgetValueHasChanged(
this );
7599 setWidgetContext( widgetContext() );
7603void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7609 mComboBox->setLayer(
nullptr );
7613 QVariant val = value;
7614 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
7626 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( val.value< QObject * >() );
7627 if ( !layer && val.type() == QVariant::String )
7634 mComboBox->setLayer( layer );
7639QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7641 return mComboBox && mComboBox->currentLayer() ?
7642 ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral(
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
7655 QHBoxLayout *hl =
new QHBoxLayout();
7656 hl->setContentsMargins( 0, 0, 0, 0 );
7658 mLineEdit =
new QLineEdit();
7659 mLineEdit->setEnabled(
false );
7660 hl->addWidget( mLineEdit, 1 );
7662 mToolButton =
new QToolButton();
7663 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7664 hl->addWidget( mToolButton );
7670 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7673 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7678 mAttributes = attributes;
7681void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7683 if ( value.isValid() )
7684 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
7688 updateSummaryText();
7692void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7694 QVariantList availableOptions;
7695 availableOptions.reserve( mAttributes.count() );
7696 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7699 availableOptions << attr.name();
7705 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7706 widget->setPanelTitle( mParam->description() );
7708 widget->setValueFormatter( [](
const QVariant & v ) -> QString
7710 return v.toString();
7713 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
7715 setValue( widget->selectedOptions() );
7722 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7724 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
7726 return v.toString();
7730 setValue( dlg.selectedOptions() );
7735void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7740 if ( mValue.empty() )
7742 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7747 values.reserve( mValue.size() );
7748 for (
const QVariant &val : std::as_const( mValue ) )
7750 values << val.toString();
7753 const QString concatenated = values.join( tr(
"," ) );
7754 if ( concatenated.length() < 100 )
7755 mLineEdit->setText( concatenated );
7757 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7769 QVBoxLayout *vlayout =
new QVBoxLayout();
7770 vlayout->setContentsMargins( 0, 0, 0, 0 );
7772 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7773 mParentLayerComboBox =
new QComboBox();
7775 QString initialParent;
7777 initialParent = attrParam->parentLayerParameterName();
7779 if (
auto *lModel = widgetContext.
model() )
7782 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7783 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7787 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
7788 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7790 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7796 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7799 mParentLayerComboBox->addItem( initialParent, initialParent );
7800 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7803 vlayout->addWidget( mParentLayerComboBox );
7805 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
7807 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
7809 vlayout->addWidget( mAllowMultipleCheckBox );
7811 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
7812 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7814 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
7816 vlayout->addWidget( mDefaultToAllCheckBox );
7818 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
7820 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7823 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7825 mDefaultLineEdit =
new QLineEdit();
7826 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
7830 mDefaultLineEdit->setText( attributes.join(
';' ) );
7832 vlayout->addWidget( mDefaultLineEdit );
7834 setLayout( vlayout );
7837QgsProcessingParameterDefinition *QgsProcessingPointCloudAttributeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
7839 QVariant defaultValue;
7840 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
7842 defaultValue = mDefaultLineEdit->text();
7844 auto param = std::make_unique< QgsProcessingParameterPointCloudAttribute >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
7846 return param.release();
7854QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
7864 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
7865 mPanel->setToolTip( parameterDefinition()->toolTip() );
7866 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [ = ]
7868 emit widgetValueHasChanged(
this );
7876 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7879 emit widgetValueHasChanged(
this );
7887 mLineEdit =
new QLineEdit();
7888 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
7889 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
7891 emit widgetValueHasChanged(
this );
7900void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7912 setParentLayerWrapperValue( wrapper );
7915 setParentLayerWrapperValue( wrapper );
7932 std::unique_ptr< QgsProcessingContext > tmpContext;
7933 if ( mProcessingContextGenerator )
7934 context = mProcessingContextGenerator->processingContext();
7938 tmpContext = std::make_unique< QgsProcessingContext >();
7939 context = tmpContext.get();
7945 if ( layer && layer->
isValid() )
7949 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
7952 mParentLayer.reset( qobject_cast< QgsPointCloudLayer * >( ownedLayer.release() ) );
7953 layer = mParentLayer.get();
7961 mComboBox->setLayer( layer );
7964 mPanel->setAttributes( layer->
attributes() );
7971 mComboBox->setLayer(
nullptr );
7976 if ( value.isValid() && widgetContext().messageBar() )
7979 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent attributes could not be populated" ),
7988 val.reserve( mPanel->attributes().attributes().size() );
7991 setWidgetValue( val, *context );
7994 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7997void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8001 if ( !value.isValid() )
8002 mComboBox->setAttribute( QString() );
8006 mComboBox->setAttribute( v );
8012 if ( value.isValid() )
8015 opts.reserve( v.size() );
8016 for (
const QString &i : v )
8020 mPanel->setValue( opts );
8022 else if ( mLineEdit )
8028 mLineEdit->setText( v.join(
';' ) );
8037QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
8040 return mComboBox->currentAttribute();
8042 return mPanel->value();
8043 else if ( mLineEdit )
8048 return mLineEdit->text().split(
';' );
8051 return mLineEdit->text();
8057QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleParameterTypes()
const
8059 return QStringList()
8064QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleOutputTypes()
const
8066 return QStringList()
8071QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
8073 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
8076QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
8083 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
8088 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8102QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8110 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8111 if ( mProcessingContextGenerator )
8112 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8113 if ( mParametersGenerator )
8114 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8115 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8117 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [ = ]()
8119 if ( mBlockSignals )
8122 emit widgetValueHasChanged(
this );
8131 mOutputWidget->addOpenAfterRunningOption();
8133 return mOutputWidget;
8143void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8145 if ( mOutputWidget )
8146 mOutputWidget->setValue( value );
8149QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8151 if ( mOutputWidget )
8152 return mOutputWidget->value();
8157QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8160 if ( mOutputWidget )
8161 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
8165QStringList QgsProcessingOutputWidgetWrapper::compatibleParameterTypes()
const
8167 return QStringList()
8177QStringList QgsProcessingOutputWidgetWrapper::compatibleOutputTypes()
const
8179 return QStringList()
8190 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8195QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8202 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8205QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8207 return tr(
"path to layer destination" );
8215 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8220QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8227 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8230QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8232 return tr(
"path to layer destination" );
8240 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8245QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8252 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8255QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8257 return tr(
"path to layer destination" );
8265 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8270QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8277 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8280QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8282 return tr(
"path to layer destination" );
8290 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8295QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8302 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8305QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8307 return tr(
"path to file destination" );
8315 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8320QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8327 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8330QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8332 return tr(
"path to folder destination" );
8340 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8344QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8351 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8354QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8356 return tr(
"path to layer destination" );
@ Standard
Unit is a standard measurement unit.
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.
@ 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.
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.
@ DateTime
Datetime values.
static QString typeName()
Returns the type name for the parameter class.
Type dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
QString description() const
Returns the description for the parameter.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
@ FlagOptional
Parameter is optional.
virtual QString type() const =0
Unique parameter type name.
Flags flags() const
Returns any flags associated with the parameter.
QString name() const
Returns the name of the parameter.
void setFlags(Flags flags)
Sets the flags associated with the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the parameter class.
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.
void setDataType(DataType type)
Sets the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
DataType
Field data types.
@ DateTime
Accepts datetime fields.
@ Numeric
Accepts numeric fields.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
DataType dataType() const
Returns the acceptable data type for the field.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
Behavior
Parameter behavior.
@ Folder
Parameter is a folder.
@ File
Parameter is a single file.
Behavior behavior() const
Returns the parameter behavior (e.g.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
static QString typeName()
Returns the type name for the parameter class.
A geometry parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A print layout item parameter, allowing users to select a particular item from a print layout.
static QString typeName()
Returns the type name for the parameter class.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
A print layout parameter, allowing users to select a print layout.
static QString typeName()
Returns the type name for the parameter class.
A map layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
static QString typeName()
Returns the type name for the parameter class.
A table (matrix) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
static QString typeName()
Returns the type name for the parameter class.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
@ Double
Double/float values.
double maximum() const
Returns the maximum value acceptable by the parameter.
Type dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
A point 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.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A raster layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
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.
@ 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.
SourceType
Data source types enum.
@ TypePlugin
Plugin layers.
@ TypeVectorLine
Vector line layers.
@ TypeMapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ TypeVectorPolygon
Vector polygon layers.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
@ TypeAnnotation
Annotation layers.
@ TypePointCloud
Point cloud layers.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ TypeRaster
Raster layers.
@ TypeVectorTile
Vector tile layers.
@ TypeVectorPoint
Vector point layers.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
@ 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.
@ StaticProperty
Static property (QgsStaticProperty)
Type 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