19#include "moc_qgsprocessingwidgetwrapperimpl.cpp"
81#include <QPlainTextEdit>
82#include <QRadioButton>
83#include <QButtonGroup>
97 QVBoxLayout *vlayout =
new QVBoxLayout();
98 vlayout->setContentsMargins( 0, 0, 0, 0 );
100 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
104 mDefaultCheckBox->setChecked(
false );
105 vlayout->addWidget( mDefaultCheckBox );
106 setLayout( vlayout );
111 auto param = std::make_unique<QgsProcessingParameterBoolean>( name, description, mDefaultCheckBox->isChecked() );
112 param->setFlags( flags );
113 return param.release();
122QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
128 QString description = parameterDefinition()->description();
130 description = QObject::tr(
"%1 [optional]" ).arg( description );
132 mCheckBox =
new QCheckBox( description );
133 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
135 connect( mCheckBox, &QCheckBox::toggled,
this, [=] {
136 emit widgetValueHasChanged(
this );
144 mComboBox =
new QComboBox();
145 mComboBox->addItem( tr(
"Yes" ),
true );
146 mComboBox->addItem( tr(
"No" ),
false );
147 mComboBox->setToolTip( parameterDefinition()->toolTip() );
149 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();
203QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
210 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
215 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
226 QVBoxLayout *vlayout =
new QVBoxLayout();
227 vlayout->setContentsMargins( 0, 0, 0, 0 );
229 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
234 mCrsSelector->setShowAccuracyWarnings(
true );
241 vlayout->addWidget( mCrsSelector );
242 setLayout( vlayout );
247 auto param = std::make_unique<QgsProcessingParameterCrs>( name, description, mCrsSelector->crs().authid() );
248 param->setFlags( flags );
249 return param.release();
257QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
259 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
261 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
269 emit widgetValueHasChanged(
this );
277 return mProjectionSelectionWidget;
282 QWidget *w =
new QWidget();
283 w->setToolTip( parameterDefinition()->toolTip() );
285 QVBoxLayout *vl =
new QVBoxLayout();
286 vl->setContentsMargins( 0, 0, 0, 0 );
289 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
290 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
291 vl->addWidget( mUseProjectCrsCheckBox );
292 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
293 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [=] {
294 emit widgetValueHasChanged(
this );
297 vl->addWidget( mProjectionSelectionWidget );
305void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
307 if ( mUseProjectCrsCheckBox )
309 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
311 mUseProjectCrsCheckBox->setChecked(
true );
316 mUseProjectCrsCheckBox->setChecked(
false );
321 if ( mProjectionSelectionWidget )
322 mProjectionSelectionWidget->setCrs( v );
325QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
327 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
328 return QStringLiteral(
"ProjectCrs" );
329 else if ( mProjectionSelectionWidget )
330 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
335QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
337 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
340QString QgsProcessingCrsWidgetWrapper::parameterType()
const
347 return new QgsProcessingCrsWidgetWrapper( parameter, type );
352 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
364 QVBoxLayout *vlayout =
new QVBoxLayout();
365 vlayout->setContentsMargins( 0, 0, 0, 0 );
367 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
369 mDefaultLineEdit =
new QLineEdit();
372 vlayout->addWidget( mDefaultLineEdit );
374 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
376 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
377 vlayout->addWidget( mMultiLineCheckBox );
379 setLayout( vlayout );
384 auto param = std::make_unique<QgsProcessingParameterString>( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
385 param->setFlags( flags );
386 return param.release();
395QWidget *QgsProcessingStringWidgetWrapper::createWidget()
397 const QVariantMap metadata = parameterDefinition()->metadata();
398 const QVariant valueHintsVariant = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"value_hints" ) );
400 if ( valueHintsVariant.isValid() )
402 const QVariantList valueList = valueHintsVariant.toList();
403 mComboBox =
new QComboBox();
404 mComboBox->setToolTip( parameterDefinition()->toolTip() );
408 mComboBox->addItem( QString() );
410 for (
const QVariant &entry : valueList )
412 mComboBox->addItem( entry.toString(), entry.toString() );
414 mComboBox->setCurrentIndex( 0 );
416 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
417 emit widgetValueHasChanged(
this );
430 mPlainTextEdit =
new QPlainTextEdit();
431 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
433 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [=] {
434 emit widgetValueHasChanged(
this );
436 return mPlainTextEdit;
440 mLineEdit =
new QLineEdit();
441 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
443 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
444 emit widgetValueHasChanged(
this );
452 mLineEdit =
new QLineEdit();
453 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
455 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
456 emit widgetValueHasChanged(
this );
466void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
470 mLineEdit->setText( v );
471 if ( mPlainTextEdit )
472 mPlainTextEdit->setPlainText( v );
476 if ( !value.isValid() )
477 index = mComboBox->findData( QVariant() );
479 index = mComboBox->findData( v );
482 mComboBox->setCurrentIndex( index );
484 mComboBox->setCurrentIndex( 0 );
488QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
491 return mLineEdit->text();
492 else if ( mPlainTextEdit )
493 return mPlainTextEdit->toPlainText();
494 else if ( mComboBox )
495 return mComboBox->currentData();
500QString QgsProcessingStringWidgetWrapper::parameterType()
const
507 return new QgsProcessingStringWidgetWrapper( parameter, type );
512 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
525QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
534 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
537 emit widgetValueHasChanged(
this );
539 return mAuthConfigSelect;
545void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
548 if ( mAuthConfigSelect )
549 mAuthConfigSelect->setConfigId( v );
552QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
554 if ( mAuthConfigSelect )
555 return mAuthConfigSelect->configId();
560QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
567 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
577 QVBoxLayout *vlayout =
new QVBoxLayout();
578 vlayout->setContentsMargins( 0, 0, 0, 0 );
580 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
582 mTypeComboBox =
new QComboBox();
585 vlayout->addWidget( mTypeComboBox );
587 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
588 mMinLineEdit =
new QLineEdit();
589 vlayout->addWidget( mMinLineEdit );
591 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
592 mMaxLineEdit =
new QLineEdit();
593 vlayout->addWidget( mMaxLineEdit );
595 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
596 mDefaultLineEdit =
new QLineEdit();
597 vlayout->addWidget( mDefaultLineEdit );
601 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( numberParam->dataType() ) ) );
603 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
605 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
609 mMaxLineEdit->clear();
612 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
614 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
618 mMinLineEdit->clear();
621 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
624 setLayout( vlayout );
633 auto param = std::make_unique<QgsProcessingParameterNumber>( name, description, dataType, ok ? val : QVariant() );
635 if ( !mMinLineEdit->text().trimmed().isEmpty() )
640 param->setMinimum( val );
644 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
649 param->setMaximum( val );
653 param->setFlags( flags );
654 return param.release();
662QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
665 const QVariantMap metadata = numberDef->
metadata();
666 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
674 QAbstractSpinBox *spinBox =
nullptr;
679 mDoubleSpinBox->setExpressionsEnabled(
true );
680 mDoubleSpinBox->setDecimals( decimals );
685 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
686 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
687 mDoubleSpinBox->setSingleStep( singleStep );
690 spinBox = mDoubleSpinBox;
695 mSpinBox->setExpressionsEnabled(
true );
699 spinBox->setToolTip( parameterDefinition()->toolTip() );
701 double max = 999999999;
706 double min = -999999999;
711 if ( mDoubleSpinBox )
713 mDoubleSpinBox->setMinimum( min );
714 mDoubleSpinBox->setMaximum( max );
718 mSpinBox->setMinimum(
static_cast<int>( min ) );
719 mSpinBox->setMaximum(
static_cast<int>( max ) );
724 mAllowingNull =
true;
725 if ( mDoubleSpinBox )
727 mDoubleSpinBox->setShowClearButton(
true );
728 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
729 mDoubleSpinBox->setMinimum( min );
730 mDoubleSpinBox->setValue( min );
734 mSpinBox->setShowClearButton(
true );
735 const int min = mSpinBox->minimum() - 1;
736 mSpinBox->setMinimum( min );
737 mSpinBox->setValue( min );
739 spinBox->setSpecialValueText( tr(
"Not set" ) );
747 if ( mDoubleSpinBox )
751 mDoubleSpinBox->setClearValue( defaultVal );
757 mSpinBox->setClearValue( intVal );
763 if ( mDoubleSpinBox )
764 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
766 mSpinBox->setClearValue(
static_cast<int>( numberDef->
minimum() ) );
771 if ( mDoubleSpinBox )
773 mDoubleSpinBox->setValue( 0 );
774 mDoubleSpinBox->setClearValue( 0 );
778 mSpinBox->setValue( 0 );
779 mSpinBox->setClearValue( 0 );
784 if ( mDoubleSpinBox )
785 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=] { emit widgetValueHasChanged(
this ); } );
787 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [=] { emit widgetValueHasChanged(
this ); } );
795void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
797 if ( mDoubleSpinBox )
799 if ( mAllowingNull && !value.isValid() )
800 mDoubleSpinBox->clear();
804 mDoubleSpinBox->setValue( v );
809 if ( mAllowingNull && !value.isValid() )
814 mSpinBox->setValue( v );
819QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
821 if ( mDoubleSpinBox )
823 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
826 return mDoubleSpinBox->value();
830 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
833 return mSpinBox->value();
839double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
841 const double valueRange = maximum - minimum;
842 if ( valueRange <= 1.0 )
844 const double step = valueRange / 10.0;
846 return qgsRound( step, -std::floor( std::log( step ) ) );
854QString QgsProcessingNumericWidgetWrapper::parameterType()
const
861 return new QgsProcessingNumericWidgetWrapper( parameter, type );
866 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
876 QVBoxLayout *vlayout =
new QVBoxLayout();
877 vlayout->setContentsMargins( 0, 0, 0, 0 );
879 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
881 mParentLayerComboBox =
new QComboBox();
883 QString initialParent;
885 initialParent = distParam->parentParameterName();
887 if (
auto *lModel = widgetContext.
model() )
890 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
891 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
895 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
896 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
898 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
903 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
904 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
906 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
911 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
912 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
914 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
919 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
920 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
922 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
928 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
931 mParentLayerComboBox->addItem( initialParent, initialParent );
932 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
935 vlayout->addWidget( mParentLayerComboBox );
937 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
938 mMinLineEdit =
new QLineEdit();
939 vlayout->addWidget( mMinLineEdit );
941 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
942 mMaxLineEdit =
new QLineEdit();
943 vlayout->addWidget( mMaxLineEdit );
945 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
946 mDefaultLineEdit =
new QLineEdit();
947 vlayout->addWidget( mDefaultLineEdit );
951 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
952 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
953 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
956 setLayout( vlayout );
964 auto param = std::make_unique<QgsProcessingParameterDistance>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
969 param->setMinimum( val );
975 param->setMaximum( val );
978 param->setFlags( flags );
979 return param.release();
983 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
987QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
994 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
997QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1001 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1006 mLabel =
new QLabel();
1007 mUnitsCombo =
new QComboBox();
1019 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1020 QHBoxLayout *layout =
new QHBoxLayout();
1021 layout->addWidget( spin, 1 );
1022 layout->insertSpacing( 1, labelMargin / 2 );
1023 layout->insertWidget( 2, mLabel );
1024 layout->insertWidget( 3, mUnitsCombo );
1029 mWarningLabel =
new QWidget();
1030 QHBoxLayout *warningLayout =
new QHBoxLayout();
1031 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1032 QLabel *warning =
new QLabel();
1034 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1035 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1036 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1037 warningLayout->insertSpacing( 0, labelMargin / 2 );
1038 warningLayout->insertWidget( 1, warning );
1039 mWarningLabel->setLayout( warningLayout );
1040 layout->insertWidget( 4, mWarningLabel );
1042 QWidget *w =
new QWidget();
1043 layout->setContentsMargins( 0, 0, 0, 0 );
1044 w->setLayout( layout );
1058void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1060 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1067 if ( wrapper->parameterDefinition()->name() ==
static_cast<const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1069 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1071 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1091 std::unique_ptr<QgsProcessingContext> tmpContext;
1092 if ( mProcessingContextGenerator )
1093 context = mProcessingContextGenerator->processingContext();
1097 tmpContext = std::make_unique<QgsProcessingContext>();
1098 context = tmpContext.get();
1117 mUnitsCombo->hide();
1125 if ( mBaseUnit != units )
1127 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( units ) ) );
1130 mUnitsCombo->show();
1137QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1139 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1140 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1153 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1164 QVBoxLayout *vlayout =
new QVBoxLayout();
1165 vlayout->setContentsMargins( 0, 0, 0, 0 );
1167 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1169 mParentLayerComboBox =
new QComboBox();
1171 QString initialParent;
1173 initialParent = areaParam->parentParameterName();
1175 if (
auto *lModel = widgetContext.
model() )
1178 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1179 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1183 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1184 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1186 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1191 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1192 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1194 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1199 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1200 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1202 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1207 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1208 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1210 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1216 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1219 mParentLayerComboBox->addItem( initialParent, initialParent );
1220 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1223 vlayout->addWidget( mParentLayerComboBox );
1225 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1226 mMinLineEdit =
new QLineEdit();
1227 vlayout->addWidget( mMinLineEdit );
1229 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1230 mMaxLineEdit =
new QLineEdit();
1231 vlayout->addWidget( mMaxLineEdit );
1233 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1234 mDefaultLineEdit =
new QLineEdit();
1235 vlayout->addWidget( mDefaultLineEdit );
1239 mMinLineEdit->setText( QLocale().toString( areaParam->minimum() ) );
1240 mMaxLineEdit->setText( QLocale().toString( areaParam->maximum() ) );
1241 mDefaultLineEdit->setText( areaParam->defaultValueForGui().toString() );
1244 setLayout( vlayout );
1252 auto param = std::make_unique<QgsProcessingParameterArea>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1257 param->setMinimum( val );
1263 param->setMaximum( val );
1266 param->setFlags( flags );
1267 return param.release();
1276 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1280QString QgsProcessingAreaWidgetWrapper::parameterType()
const
1287 return new QgsProcessingAreaWidgetWrapper( parameter, type );
1290QWidget *QgsProcessingAreaWidgetWrapper::createWidget()
1294 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1299 mLabel =
new QLabel();
1300 mUnitsCombo =
new QComboBox();
1315 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1316 QHBoxLayout *layout =
new QHBoxLayout();
1317 layout->addWidget( spin, 1 );
1318 layout->insertSpacing( 1, labelMargin / 2 );
1319 layout->insertWidget( 2, mLabel );
1320 layout->insertWidget( 3, mUnitsCombo );
1325 mWarningLabel =
new QWidget();
1326 QHBoxLayout *warningLayout =
new QHBoxLayout();
1327 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1328 QLabel *warning =
new QLabel();
1330 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1331 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1332 warning->setToolTip( tr(
"Area is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1333 warningLayout->insertSpacing( 0, labelMargin / 2 );
1334 warningLayout->insertWidget( 1, warning );
1335 mWarningLabel->setLayout( warningLayout );
1336 layout->insertWidget( 4, mWarningLabel );
1338 QWidget *w =
new QWidget();
1339 layout->setContentsMargins( 0, 0, 0, 0 );
1340 w->setLayout( layout );
1354void QgsProcessingAreaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1356 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1387 std::unique_ptr<QgsProcessingContext> tmpContext;
1388 if ( mProcessingContextGenerator )
1389 context = mProcessingContextGenerator->processingContext();
1393 tmpContext = std::make_unique<QgsProcessingContext>();
1394 context = tmpContext.get();
1408void QgsProcessingAreaWidgetWrapper::setUnits(
Qgis::AreaUnit units )
1413 mUnitsCombo->hide();
1418 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1419 mUnitsCombo->show();
1426QVariant QgsProcessingAreaWidgetWrapper::widgetValue()
const
1428 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1429 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1442 return new QgsProcessingAreaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1453 QVBoxLayout *vlayout =
new QVBoxLayout();
1454 vlayout->setContentsMargins( 0, 0, 0, 0 );
1456 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1458 mParentLayerComboBox =
new QComboBox();
1460 QString initialParent;
1462 initialParent = volumeParam->parentParameterName();
1464 if (
auto *lModel = widgetContext.
model() )
1467 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1468 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1472 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1473 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1475 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1480 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1481 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1483 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1488 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1489 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1491 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1496 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1497 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1499 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1505 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1508 mParentLayerComboBox->addItem( initialParent, initialParent );
1509 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1512 vlayout->addWidget( mParentLayerComboBox );
1514 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1515 mMinLineEdit =
new QLineEdit();
1516 vlayout->addWidget( mMinLineEdit );
1518 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1519 mMaxLineEdit =
new QLineEdit();
1520 vlayout->addWidget( mMaxLineEdit );
1522 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1523 mDefaultLineEdit =
new QLineEdit();
1524 vlayout->addWidget( mDefaultLineEdit );
1528 mMinLineEdit->setText( QLocale().toString( volumeParam->minimum() ) );
1529 mMaxLineEdit->setText( QLocale().toString( volumeParam->maximum() ) );
1530 mDefaultLineEdit->setText( volumeParam->defaultValueForGui().toString() );
1533 setLayout( vlayout );
1541 auto param = std::make_unique<QgsProcessingParameterVolume>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1546 param->setMinimum( val );
1552 param->setMaximum( val );
1555 param->setFlags( flags );
1556 return param.release();
1565 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1569QString QgsProcessingVolumeWidgetWrapper::parameterType()
const
1576 return new QgsProcessingVolumeWidgetWrapper( parameter, type );
1579QWidget *QgsProcessingVolumeWidgetWrapper::createWidget()
1583 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1588 mLabel =
new QLabel();
1589 mUnitsCombo =
new QComboBox();
1602 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1603 QHBoxLayout *layout =
new QHBoxLayout();
1604 layout->addWidget( spin, 1 );
1605 layout->insertSpacing( 1, labelMargin / 2 );
1606 layout->insertWidget( 2, mLabel );
1607 layout->insertWidget( 3, mUnitsCombo );
1612 mWarningLabel =
new QWidget();
1613 QHBoxLayout *warningLayout =
new QHBoxLayout();
1614 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1615 QLabel *warning =
new QLabel();
1617 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1618 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1619 warning->setToolTip( tr(
"Volume is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1620 warningLayout->insertSpacing( 0, labelMargin / 2 );
1621 warningLayout->insertWidget( 1, warning );
1622 mWarningLabel->setLayout( warningLayout );
1623 layout->insertWidget( 4, mWarningLabel );
1625 QWidget *w =
new QWidget();
1626 layout->setContentsMargins( 0, 0, 0, 0 );
1627 w->setLayout( layout );
1641void QgsProcessingVolumeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1643 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1674 std::unique_ptr<QgsProcessingContext> tmpContext;
1675 if ( mProcessingContextGenerator )
1676 context = mProcessingContextGenerator->processingContext();
1680 tmpContext = std::make_unique<QgsProcessingContext>();
1681 context = tmpContext.get();
1700 mUnitsCombo->hide();
1705 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1706 mUnitsCombo->show();
1713QVariant QgsProcessingVolumeWidgetWrapper::widgetValue()
const
1715 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1716 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1729 return new QgsProcessingVolumeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1740 QVBoxLayout *vlayout =
new QVBoxLayout();
1741 vlayout->setContentsMargins( 0, 0, 0, 0 );
1743 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1744 mMinLineEdit =
new QLineEdit();
1745 vlayout->addWidget( mMinLineEdit );
1747 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1748 mMaxLineEdit =
new QLineEdit();
1749 vlayout->addWidget( mMaxLineEdit );
1751 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1752 mDefaultLineEdit =
new QLineEdit();
1753 vlayout->addWidget( mDefaultLineEdit );
1755 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1757 mUnitsCombo =
new QComboBox();
1767 vlayout->addWidget( mUnitsCombo );
1771 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1772 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1773 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1774 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationParam->defaultUnit() ) ) );
1777 setLayout( vlayout );
1785 auto param = std::make_unique<QgsProcessingParameterDuration>( name, description, ok ? val : QVariant() );
1790 param->setMinimum( val );
1796 param->setMaximum( val );
1799 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit>( mUnitsCombo->currentData().toInt() ) );
1801 param->setFlags( flags );
1802 return param.release();
1806 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1810QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1817 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1820QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1824 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1829 mUnitsCombo =
new QComboBox();
1841 QHBoxLayout *layout =
new QHBoxLayout();
1842 layout->addWidget( spin, 1 );
1843 layout->insertWidget( 1, mUnitsCombo );
1845 QWidget *w =
new QWidget();
1846 layout->setContentsMargins( 0, 0, 0, 0 );
1847 w->setLayout( layout );
1849 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationDef->
defaultUnit() ) ) );
1850 mUnitsCombo->show();
1862QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
1874QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
1876 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1877 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo )
1888void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1894 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
1898 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
1904 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1914 QVBoxLayout *vlayout =
new QVBoxLayout();
1915 vlayout->setContentsMargins( 0, 0, 0, 0 );
1917 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1919 mDefaultLineEdit =
new QLineEdit();
1923 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1926 vlayout->addWidget( mDefaultLineEdit );
1928 setLayout( vlayout );
1934 double val = mDefaultLineEdit->text().toDouble( &ok );
1935 auto param = std::make_unique<QgsProcessingParameterScale>( name, description, ok ? val : QVariant() );
1937 return param.release();
1941 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1945QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1952 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1955QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
1967 mScaleWidget->setAllowNull(
true );
1969 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
1970 mScaleWidget->setShowCurrentScaleButton(
true );
1972 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
1974 emit widgetValueHasChanged(
this );
1976 return mScaleWidget;
1985 mScaleWidget->setMapCanvas( context.
mapCanvas() );
1990QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
1992 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
1995void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1999 if ( mScaleWidget->allowNull() && !value.isValid() )
2000 mScaleWidget->setNull();
2004 mScaleWidget->setScale( v );
2011 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2022 QVBoxLayout *vlayout =
new QVBoxLayout();
2023 vlayout->setContentsMargins( 0, 0, 0, 0 );
2025 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
2027 mTypeComboBox =
new QComboBox();
2030 vlayout->addWidget( mTypeComboBox );
2032 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
2033 mMinLineEdit =
new QLineEdit();
2034 vlayout->addWidget( mMinLineEdit );
2036 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
2037 mMaxLineEdit =
new QLineEdit();
2038 vlayout->addWidget( mMaxLineEdit );
2042 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( rangeParam->dataType() ) ) );
2044 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
2045 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
2048 setLayout( vlayout );
2053 QString defaultValue;
2054 if ( mMinLineEdit->text().isEmpty() )
2056 defaultValue = QStringLiteral(
"None" );
2064 defaultValue = QStringLiteral(
"None" );
2068 if ( mMaxLineEdit->text().isEmpty() )
2070 defaultValue += QLatin1String(
",None" );
2076 defaultValue += QStringLiteral(
",%1" ).arg( ok ? QString::number( val ) : QLatin1String(
"None" ) );
2080 auto param = std::make_unique<QgsProcessingParameterRange>( name, description, dataType, defaultValue );
2081 param->setFlags( flags );
2082 return param.release();
2091QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
2100 QHBoxLayout *layout =
new QHBoxLayout();
2105 mMinSpinBox->setExpressionsEnabled(
true );
2106 mMinSpinBox->setShowClearButton(
false );
2107 mMaxSpinBox->setExpressionsEnabled(
true );
2108 mMaxSpinBox->setShowClearButton(
false );
2110 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
2111 layout->addWidget( minLabel );
2112 layout->addWidget( mMinSpinBox, 1 );
2114 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
2115 layout->addWidget( maxLabel );
2116 layout->addWidget( mMaxSpinBox, 1 );
2118 QWidget *w =
new QWidget();
2119 layout->setContentsMargins( 0, 0, 0, 0 );
2120 w->setLayout( layout );
2124 mMinSpinBox->setDecimals( 6 );
2125 mMaxSpinBox->setDecimals( 6 );
2129 mMinSpinBox->setDecimals( 0 );
2130 mMaxSpinBox->setDecimals( 0 );
2133 mMinSpinBox->setMinimum( -99999999.999999 );
2134 mMaxSpinBox->setMinimum( -99999999.999999 );
2135 mMinSpinBox->setMaximum( 99999999.999999 );
2136 mMaxSpinBox->setMaximum( 99999999.999999 );
2140 mAllowingNull =
true;
2142 const double min = mMinSpinBox->minimum() - 1;
2143 mMinSpinBox->setMinimum( min );
2144 mMaxSpinBox->setMinimum( min );
2145 mMinSpinBox->setValue( min );
2146 mMaxSpinBox->setValue( min );
2148 mMinSpinBox->setShowClearButton(
true );
2149 mMaxSpinBox->setShowClearButton(
true );
2150 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
2151 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
2154 w->setToolTip( parameterDefinition()->toolTip() );
2156 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=](
const double v ) {
2157 mBlockChangedSignal++;
2158 if ( !mAllowingNull && v > mMaxSpinBox->value() )
2159 mMaxSpinBox->setValue( v );
2160 mBlockChangedSignal--;
2162 if ( !mBlockChangedSignal )
2163 emit widgetValueHasChanged(
this );
2165 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=](
const double v ) {
2166 mBlockChangedSignal++;
2167 if ( !mAllowingNull && v < mMinSpinBox->value() )
2168 mMinSpinBox->setValue( v );
2169 mBlockChangedSignal--;
2171 if ( !mBlockChangedSignal )
2172 emit widgetValueHasChanged(
this );
2181void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2184 if ( mAllowingNull && v.empty() )
2186 mMinSpinBox->clear();
2187 mMaxSpinBox->clear();
2194 if ( mAllowingNull )
2196 mBlockChangedSignal++;
2197 if ( std::isnan( v.at( 0 ) ) )
2198 mMinSpinBox->clear();
2200 mMinSpinBox->setValue( v.at( 0 ) );
2202 if ( v.count() >= 2 )
2204 if ( std::isnan( v.at( 1 ) ) )
2205 mMaxSpinBox->clear();
2207 mMaxSpinBox->setValue( v.at( 1 ) );
2209 mBlockChangedSignal--;
2213 mBlockChangedSignal++;
2214 mMinSpinBox->setValue( v.at( 0 ) );
2215 if ( v.count() >= 2 )
2216 mMaxSpinBox->setValue( v.at( 1 ) );
2217 mBlockChangedSignal--;
2221 if ( !mBlockChangedSignal )
2222 emit widgetValueHasChanged(
this );
2225QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
2227 if ( mAllowingNull )
2230 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
2231 value = QStringLiteral(
"None" );
2233 value = QString::number( mMinSpinBox->value() );
2235 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
2236 value += QLatin1String(
",None" );
2238 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
2243 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
2246QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
2248 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
2251QString QgsProcessingRangeWidgetWrapper::parameterType()
const
2258 return new QgsProcessingRangeWidgetWrapper( parameter, type );
2263 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2274 QVBoxLayout *vlayout =
new QVBoxLayout();
2275 vlayout->setContentsMargins( 0, 0, 0, 0 );
2277 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
2280 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
2281 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
2283 vlayout->addWidget( mMatrixWidget );
2284 setLayout( vlayout );
2289 auto param = std::make_unique<QgsProcessingParameterMatrix>( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
2290 param->setFlags( flags );
2291 return param.release();
2300QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
2302 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast<const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
2303 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
2305 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [=] {
2306 emit widgetValueHasChanged(
this );
2315 return mMatrixWidget;
2321void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2324 if ( mMatrixWidget )
2325 mMatrixWidget->setValue( v );
2328QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
2330 if ( mMatrixWidget )
2331 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
2336QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
2338 return tr(
"comma delimited string of values, or an array of values" );
2341QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
2348 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
2353 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2365 QVBoxLayout *vlayout =
new QVBoxLayout();
2366 vlayout->setContentsMargins( 0, 0, 0, 0 );
2368 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
2370 mTypeComboBox =
new QComboBox();
2374 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( fileParam->behavior() ) ) );
2376 mTypeComboBox->setCurrentIndex( 0 );
2377 vlayout->addWidget( mTypeComboBox );
2379 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
2381 mFilterComboBox =
new QComboBox();
2382 mFilterComboBox->setEditable(
true );
2384 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
2385 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
2386 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
2387 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
2389 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
2391 mFilterComboBox->setCurrentIndex( 0 );
2392 vlayout->addWidget( mFilterComboBox );
2394 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2397 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
2401 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
2405 vlayout->addWidget( mDefaultFileWidget );
2407 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=] {
2415 setLayout( vlayout );
2420 auto param = std::make_unique<QgsProcessingParameterFile>( name, description );
2423 param->setFileFilter( mFilterComboBox->currentText() );
2424 if ( !mDefaultFileWidget->filePath().isEmpty() )
2425 param->setDefaultValue( mDefaultFileWidget->filePath() );
2426 param->setFlags( flags );
2427 return param.release();
2436QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2446 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2447 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2449 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
2456 mFileWidget->setFilter( fileParam->
fileFilter() );
2457 else if ( !fileParam->
extension().isEmpty() )
2458 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
2467 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
2468 emit widgetValueHasChanged(
this );
2476void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2480 mFileWidget->setFilePath( v );
2483QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2486 return mFileWidget->filePath();
2491QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2493 return tr(
"string representing a path to a file or folder" );
2496QString QgsProcessingFileWidgetWrapper::parameterType()
const
2503 return new QgsProcessingFileWidgetWrapper( parameter, type );
2508 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2519 QVBoxLayout *vlayout =
new QVBoxLayout();
2520 vlayout->setContentsMargins( 0, 0, 0, 0 );
2521 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2524 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2526 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2527 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2529 QStackedWidget *stackedWidget =
new QStackedWidget();
2530 stackedWidget->addWidget( mDefaultQgisLineEdit );
2531 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2532 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2533 vlayout->addWidget( stackedWidget );
2538 mDefaultQgisLineEdit->setExpression( expr );
2539 mDefaultPointCloudLineEdit->setExpression( expr );
2542 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2544 mParentLayerComboBox =
new QComboBox();
2545 vlayout->addWidget( mParentLayerComboBox );
2547 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2548 mExpressionTypeComboBox =
new QComboBox();
2553 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
2554 mParentLayerComboBox->clear();
2555 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2557 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2559 QString initialParent;
2561 initialParent = expParam->parentLayerParameterName();
2565 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2568 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2569 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2576 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2577 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2579 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2584 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2585 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2587 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2594 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2595 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2597 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2608 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2609 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2611 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2619 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2622 mParentLayerComboBox->addItem( initialParent, initialParent );
2623 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2627 mExpressionTypeComboBox->setCurrentIndex( -1 );
2629 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast<int>( expParam->expressionType() ) ) );
2631 mExpressionTypeComboBox->setCurrentIndex( 0 );
2633 vlayout->addWidget( mExpressionTypeComboBox );
2635 setLayout( vlayout );
2642 switch ( expressionType )
2645 expression = mDefaultQgisLineEdit->expression();
2648 expression = mDefaultPointCloudLineEdit->expression();
2651 expression = mDefaultRasterCalculatorLineEdit->expression();
2654 auto param = std::make_unique<QgsProcessingParameterExpression>( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2655 param->setFlags( flags );
2656 return param.release();
2664QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2676 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2677 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2678 mExpLineEdit->registerExpressionContextGenerator(
this );
2680 emit widgetValueHasChanged(
this );
2682 return mExpLineEdit;
2688 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2689 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2690 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [=](
const QString & ) {
2691 emit widgetValueHasChanged(
this );
2693 return mPointCloudExpLineEdit;
2698 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2699 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2702 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2704 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [=](
const QString & ) {
2705 emit widgetValueHasChanged(
this );
2707 return mRasterCalculatorExpLineEdit;
2711 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
2714 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2715 mExpBuilderWidget->init( createExpressionContext() );
2717 Q_UNUSED( changed );
2718 emit widgetValueHasChanged(
this );
2720 return mExpBuilderWidget;
2725 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2726 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2727 mFieldExpWidget->registerExpressionContextGenerator(
this );
2729 mFieldExpWidget->setAllowEmptyFieldName(
true );
2732 emit widgetValueHasChanged(
this );
2734 return mFieldExpWidget;
2742void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2754 setParentLayerWrapperValue( wrapper );
2756 setParentLayerWrapperValue( wrapper );
2772 if ( mExpBuilderWidget )
2775 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2783 std::unique_ptr<QgsProcessingContext> tmpContext;
2784 if ( mProcessingContextGenerator )
2785 context = mProcessingContextGenerator->processingContext();
2789 tmpContext = std::make_unique<QgsProcessingContext>();
2790 context = tmpContext.get();
2800 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2810 if ( mFieldExpWidget )
2811 mFieldExpWidget->setLayer(
nullptr );
2812 else if ( mExpBuilderWidget )
2813 mExpBuilderWidget->setLayer(
nullptr );
2814 else if ( mExpLineEdit )
2815 mExpLineEdit->setLayer(
nullptr );
2821 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2824 mParentLayer = std::move( ownedLayer );
2832 if ( mFieldExpWidget )
2833 mFieldExpWidget->setLayer( layer );
2834 if ( mExpBuilderWidget )
2835 mExpBuilderWidget->setLayer( layer );
2836 else if ( mExpLineEdit )
2837 mExpLineEdit->setLayer( layer );
2846 if ( mPointCloudExpLineEdit )
2847 mPointCloudExpLineEdit->setLayer(
nullptr );
2853 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2856 mParentLayer = std::move( ownedLayer );
2864 if ( mPointCloudExpLineEdit )
2865 mPointCloudExpLineEdit->setLayer( layer );
2872 if ( layers.isEmpty() )
2874 if ( mRasterCalculatorExpLineEdit )
2876 mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
2881 if ( mRasterCalculatorExpLineEdit )
2883 QVariantList layersList;
2886 layersList << layer->
name();
2888 mRasterCalculatorExpLineEdit->setLayers( layersList );
2896void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2899 if ( mFieldExpWidget )
2900 mFieldExpWidget->setExpression( v );
2901 else if ( mExpBuilderWidget )
2902 mExpBuilderWidget->setExpressionText( v );
2903 else if ( mExpLineEdit )
2904 mExpLineEdit->setExpression( v );
2905 else if ( mPointCloudExpLineEdit )
2906 mPointCloudExpLineEdit->setExpression( v );
2907 else if ( mRasterCalculatorExpLineEdit )
2908 mRasterCalculatorExpLineEdit->setExpression( v );
2911QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2913 if ( mFieldExpWidget )
2914 return mFieldExpWidget->expression();
2915 if ( mExpBuilderWidget )
2916 return mExpBuilderWidget->expressionText();
2917 else if ( mExpLineEdit )
2918 return mExpLineEdit->expression();
2919 else if ( mPointCloudExpLineEdit )
2920 return mPointCloudExpLineEdit->expression();
2921 else if ( mRasterCalculatorExpLineEdit )
2922 return mRasterCalculatorExpLineEdit->expression();
2927QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2929 return tr(
"string representation of an expression" );
2932const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
2934 if ( mFieldExpWidget && mFieldExpWidget->layer() )
2935 return mFieldExpWidget->layer();
2937 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
2938 return mExpBuilderWidget->layer();
2943QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
2950 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
2955 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2967 QHBoxLayout *hl =
new QHBoxLayout();
2968 hl->setContentsMargins( 0, 0, 0, 0 );
2970 mLineEdit =
new QLineEdit();
2971 mLineEdit->setEnabled(
false );
2972 hl->addWidget( mLineEdit, 1 );
2974 mToolButton =
new QToolButton();
2975 mToolButton->setText( QString( QChar( 0x2026 ) ) );
2976 hl->addWidget( mToolButton );
2982 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2985 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
2988void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
2990 if ( value.isValid() )
2992 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
2994 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
3000 updateSummaryText();
3004void QgsProcessingEnumPanelWidget::showDialog()
3006 QVariantList availableOptions;
3009 availableOptions.reserve( mParam->options().size() );
3011 if ( mParam->usesStaticStrings() )
3013 for ( QString o : mParam->options() )
3015 availableOptions << o;
3020 for (
int i = 0; i < mParam->options().count(); ++i )
3021 availableOptions << i;
3025 const QStringList options = mParam ? mParam->options() : QStringList();
3029 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3030 widget->setPanelTitle( mParam->description() );
3032 if ( mParam->usesStaticStrings() )
3034 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3035 const QString i = v.toString();
3036 return options.contains( i ) ? i : QString();
3041 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3042 const int i = v.toInt();
3043 return options.size() > i ? options.at( i ) : QString();
3047 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
3048 setValue( widget->selectedOptions() );
3055 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3057 dlg.setValueFormatter( [options](
const QVariant &v ) -> QString {
3058 const int i = v.toInt();
3059 return options.size() > i ? options.at( i ) : QString();
3063 setValue( dlg.selectedOptions() );
3068void QgsProcessingEnumPanelWidget::updateSummaryText()
3073 if ( mValue.empty() )
3075 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3080 values.reserve( mValue.size() );
3081 if ( mParam->usesStaticStrings() )
3083 for (
const QVariant &val : std::as_const( mValue ) )
3085 values << val.toString();
3090 const QStringList options = mParam->options();
3091 for (
const QVariant &val : std::as_const( mValue ) )
3093 const int i = val.toInt();
3094 values << ( options.size() > i ? options.at( i ) : QString() );
3098 const QString concatenated = values.join( tr(
"," ) );
3099 if ( concatenated.length() < 100 )
3100 mLineEdit->setText( concatenated );
3102 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
3110QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
3113 , mButtonGroup( new QButtonGroup( this ) )
3114 , mColumns( columns )
3116 mButtonGroup->setExclusive( !mParam->allowMultiple() );
3118 QGridLayout *l =
new QGridLayout();
3119 l->setContentsMargins( 0, 0, 0, 0 );
3121 int rows =
static_cast<int>( std::ceil( mParam->options().count() /
static_cast<double>( mColumns ) ) );
3122 for (
int i = 0; i < mParam->options().count(); ++i )
3124 QAbstractButton *button =
nullptr;
3125 if ( mParam->allowMultiple() )
3126 button =
new QCheckBox( mParam->options().at( i ) );
3128 button =
new QRadioButton( mParam->options().at( i ) );
3130 connect( button, &QAbstractButton::toggled,
this, [=] {
3131 if ( !mBlockChangedSignal )
3135 mButtons.insert( i, button );
3137 mButtonGroup->addButton( button, i );
3138 l->addWidget( button, i % rows, i / rows );
3140 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
3143 if ( mParam->allowMultiple() )
3145 setContextMenuPolicy( Qt::CustomContextMenu );
3146 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
3150QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
3152 if ( mParam->allowMultiple() )
3155 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3157 if ( it.value()->isChecked() )
3158 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
3164 if ( mParam->usesStaticStrings() )
3165 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
3167 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
3171void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
3173 mBlockChangedSignal =
true;
3174 if ( mParam->allowMultiple() )
3176 QVariantList selected;
3177 if ( value.isValid() )
3178 selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3179 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3181 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
3182 it.value()->setChecked( selected.contains( v ) );
3188 if ( v.userType() == QMetaType::Type::QVariantList )
3189 v = v.toList().value( 0 );
3191 v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
3192 if ( mButtons.contains( v ) )
3193 mButtons.value( v )->setChecked(
true );
3195 mBlockChangedSignal =
false;
3199void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
3202 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
3203 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
3204 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
3205 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
3206 popupMenu.addAction( selectAllAction );
3207 popupMenu.addAction( clearAllAction );
3208 popupMenu.exec( QCursor::pos() );
3211void QgsProcessingEnumCheckboxPanelWidget::selectAll()
3213 mBlockChangedSignal =
true;
3214 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3215 it.value()->setChecked(
true );
3216 mBlockChangedSignal =
false;
3220void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
3222 mBlockChangedSignal =
true;
3223 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3224 it.value()->setChecked(
false );
3225 mBlockChangedSignal =
false;
3237 QVBoxLayout *vlayout =
new QVBoxLayout();
3238 vlayout->setContentsMargins( 0, 0, 0, 0 );
3240 mEnumWidget =
new QgsProcessingEnumModelerWidget();
3243 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
3244 mEnumWidget->setOptions( enumParam->options() );
3245 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
3247 vlayout->addWidget( mEnumWidget );
3248 setLayout( vlayout );
3253 auto param = std::make_unique<QgsProcessingParameterEnum>( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
3255 return param.release();
3264QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
3272 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
3274 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
3275 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
3276 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
3277 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [=] {
3278 emit widgetValueHasChanged(
this );
3280 return mCheckboxPanel;
3289 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
3290 mPanel->setToolTip( parameterDefinition()->toolTip() );
3291 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [=] {
3292 emit widgetValueHasChanged(
this );
3298 mComboBox =
new QComboBox();
3301 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
3302 const QStringList options = expParam->
options();
3303 const QVariantList iconList = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"icons" ) ).toList();
3304 for (
int i = 0; i < options.count(); ++i )
3306 const QIcon icon = iconList.value( i ).value<QIcon>();
3309 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
3311 mComboBox->addItem( icon, options.at( i ), i );
3314 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3315 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
3316 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
3317 emit widgetValueHasChanged(
this );
3326void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3330 if ( !value.isValid() )
3331 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
3338 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3343 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3347 else if ( mPanel || mCheckboxPanel )
3350 if ( value.isValid() )
3356 opts.reserve( v.size() );
3357 for ( QString i : v )
3363 opts.reserve( v.size() );
3369 mPanel->setValue( opts );
3370 else if ( mCheckboxPanel )
3371 mCheckboxPanel->setValue( opts );
3375QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3378 return mComboBox->currentData();
3380 return mPanel->value();
3381 else if ( mCheckboxPanel )
3382 return mCheckboxPanel->value();
3387QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3389 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3392QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3399 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3404 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3416QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3425 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() : nullptr );
3430 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3432 emit widgetValueHasChanged(
this );
3439 mPlainComboBox =
new QComboBox();
3440 mPlainComboBox->setEditable(
true );
3441 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3442 if ( widgetContext().project() )
3446 mPlainComboBox->addItem( layout->name() );
3449 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [=](
const QString & ) {
3450 emit widgetValueHasChanged(
this );
3452 return mPlainComboBox;
3458void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3462 if ( !value.isValid() )
3463 mComboBox->setCurrentLayout(
nullptr );
3467 mComboBox->setCurrentLayout( l );
3469 mComboBox->setCurrentLayout(
nullptr );
3472 else if ( mPlainComboBox )
3475 mPlainComboBox->setCurrentText( v );
3479QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3484 return l ? l->
name() : QVariant();
3486 else if ( mPlainComboBox )
3487 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3495 if ( mPlainComboBox && context.
project() )
3499 mPlainComboBox->addItem( layout->name() );
3503QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3505 return tr(
"string representing the name of an existing print layout" );
3508QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3515 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3527 QVBoxLayout *vlayout =
new QVBoxLayout();
3528 vlayout->setContentsMargins( 0, 0, 0, 0 );
3530 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3532 mParentLayoutComboBox =
new QComboBox();
3533 QString initialParent;
3535 initialParent = itemParam->parentLayoutParameterName();
3537 if (
auto *lModel = widgetContext.
model() )
3540 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3541 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3545 mParentLayoutComboBox->addItem( definition->
description(), definition->
name() );
3546 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3548 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3554 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3557 mParentLayoutComboBox->addItem( initialParent, initialParent );
3558 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3561 vlayout->addWidget( mParentLayoutComboBox );
3562 setLayout( vlayout );
3566 auto param = std::make_unique<QgsProcessingParameterLayoutItem>( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3568 return param.release();
3577QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3588 mComboBox->setAllowEmptyItem(
true );
3589 if ( layoutParam->
itemType() >= 0 )
3592 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3594 emit widgetValueHasChanged(
this );
3601 mLineEdit =
new QLineEdit();
3602 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3603 connect( mLineEdit, &QLineEdit::textChanged,
this, [=](
const QString & ) {
3604 emit widgetValueHasChanged(
this );
3612void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3639void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3645 std::unique_ptr<QgsProcessingContext> tmpContext;
3646 if ( mProcessingContextGenerator )
3647 context = mProcessingContextGenerator->processingContext();
3651 tmpContext = std::make_unique<QgsProcessingContext>();
3652 context = tmpContext.get();
3656 setLayout( layout );
3659void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3662 mComboBox->setCurrentLayout( layout );
3665void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3669 if ( !value.isValid() )
3670 mComboBox->setItem(
nullptr );
3674 mComboBox->setItem( item );
3677 else if ( mLineEdit )
3680 mLineEdit->setText( v );
3684QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3689 return i ? i->
uuid() : QVariant();
3691 else if ( mLineEdit )
3692 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3698QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3700 return tr(
"string representing the UUID or ID of an existing print layout item" );
3703QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3710 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3715 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3722QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3729QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3731void QgsProcessingPointMapTool::deactivate()
3745 if ( e->button() == Qt::LeftButton )
3748 emit clicked( point );
3753void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3755 if ( e->key() == Qt::Key_Escape )
3768QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3771 QHBoxLayout *l =
new QHBoxLayout();
3772 l->setContentsMargins( 0, 0, 0, 0 );
3774 mLineEdit->setShowClearButton(
false );
3775 l->addWidget( mLineEdit, 1 );
3776 mButton =
new QToolButton();
3777 mButton->setText( QString( QChar( 0x2026 ) ) );
3778 l->addWidget( mButton );
3781 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3782 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::textChanged );
3783 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3784 mButton->setVisible(
false );
3787void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
3790 if ( mAllowSelectOnCanvas )
3792 mButton->setVisible(
true );
3795 mTool = std::make_unique<QgsProcessingPointMapTool>( mCanvas );
3796 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
3797 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
3801void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
3803 mLineEdit->setShowClearButton( allowNull );
3806void QgsProcessingPointPanel::setShowPointOnCanvas(
bool show )
3808 if ( mShowPointOnCanvas == show )
3811 mShowPointOnCanvas = show;
3812 if ( mShowPointOnCanvas )
3818 mMapPointRubberBand.reset();
3822void QgsProcessingPointPanel::setAllowSelectOnCanvas(
bool allow )
3824 mAllowSelectOnCanvas = allow;
3825 mButton->setVisible( mAllowSelectOnCanvas &&
static_cast<bool>( mTool ) );
3828QVariant QgsProcessingPointPanel::value()
const
3830 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
3833void QgsProcessingPointPanel::clear()
3841 QString newText = QStringLiteral(
"%1,%2" )
3842 .arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) );
3845 if ( mCrs.isValid() )
3847 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
3849 mLineEdit->setText( newText );
3853void QgsProcessingPointPanel::showEvent( QShowEvent * )
3858 if ( QWidget *parentWindow = window() )
3860 setAllowSelectOnCanvas( !parentWindow->isModal() );
3866void QgsProcessingPointPanel::selectOnCanvas()
3871 mPrevTool = mCanvas->mapTool();
3872 mCanvas->setMapTool( mTool.get() );
3874 emit toggleDialogVisibility(
false );
3877void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3879 setValue( point, mCanvas->mapSettings().destinationCrs() );
3882void QgsProcessingPointPanel::pointPicked()
3887 mCanvas->setMapTool( mPrevTool );
3889 emit toggleDialogVisibility(
true );
3892void QgsProcessingPointPanel::textChanged(
const QString &text )
3894 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3896 const QRegularExpressionMatch match = rx.match( text );
3897 if ( match.hasMatch() )
3900 const double x = match.captured( 1 ).toDouble( &xOk );
3902 const double y = match.captured( 2 ).toDouble( &yOk );
3909 if ( pointCrs.isValid() )
3927void QgsProcessingPointPanel::updateRubberBand()
3929 if ( !mShowPointOnCanvas || !mCanvas )
3932 if ( mPoint.isEmpty() )
3934 mMapPointRubberBand.reset();
3938 if ( !mMapPointRubberBand )
3941 mMapPointRubberBand->setZValue( 1000 );
3944 const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
3945 mMapPointRubberBand->setWidth( scaleFactor );
3946 mMapPointRubberBand->setIconSize( scaleFactor * 5 );
3948 mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
3949 mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
3963 QVBoxLayout *vlayout =
new QVBoxLayout();
3964 vlayout->setContentsMargins( 0, 0, 0, 0 );
3966 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3968 mDefaultLineEdit =
new QLineEdit();
3969 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3970 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
3974 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
3977 vlayout->addWidget( mDefaultLineEdit );
3978 setLayout( vlayout );
3983 auto param = std::make_unique<QgsProcessingParameterPoint>( name, description, mDefaultLineEdit->text() );
3985 return param.release();
3993QWidget *QgsProcessingPointWidgetWrapper::createWidget()
4001 mPanel =
new QgsProcessingPointPanel(
nullptr );
4002 if ( widgetContext().mapCanvas() )
4003 mPanel->setMapCanvas( widgetContext().mapCanvas() );
4006 mPanel->setAllowNull(
true );
4009 mPanel->setShowPointOnCanvas(
true );
4011 mPanel->setToolTip( parameterDefinition()->toolTip() );
4013 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [=] {
4014 emit widgetValueHasChanged(
this );
4018 setDialog( mDialog );
4024 mLineEdit =
new QLineEdit();
4025 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4026 connect( mLineEdit, &QLineEdit::textChanged,
this, [=](
const QString & ) {
4027 emit widgetValueHasChanged(
this );
4039 mPanel->setMapCanvas( context.
mapCanvas() );
4042void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
4047 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [=](
bool visible ) {
4049 mDialog->showMinimized();
4052 mDialog->showNormal();
4054 mDialog->activateWindow();
4061void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4065 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
4071 mPanel->setValue( p,
crs );
4074 else if ( mLineEdit )
4077 mLineEdit->setText( v );
4081QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
4085 return mPanel->value();
4087 else if ( mLineEdit )
4088 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
4093QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
4095 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
4098QString QgsProcessingPointWidgetWrapper::parameterType()
const
4105 return new QgsProcessingPointWidgetWrapper( parameter, type );
4110 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4122 QVBoxLayout *vlayout =
new QVBoxLayout();
4123 vlayout->setContentsMargins( 0, 0, 0, 0 );
4125 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4137 vlayout->addWidget( mGeometryWidget );
4138 setLayout( vlayout );
4144 auto param = std::make_unique<QgsProcessingParameterGeometry>( name, description, geometry.
isEmpty() ? QVariant() : geometry.asWkt() );
4146 return param.release();
4154QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
4163 mGeometryWidget->setToolTip( parameterDefinition()->toolTip() );
4165 emit widgetValueHasChanged(
this );
4167 return mGeometryWidget;
4173void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4175 if ( mGeometryWidget )
4184 mGeometryWidget->clearGeometry();
4189QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
4191 if ( mGeometryWidget )
4194 return geometry.
isEmpty() ? QVariant() : geometry.asWkt();
4202QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
4204 return tr(
"string in the Well-Known-Text format or a geometry value" );
4207QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
4214 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
4219 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4231 QVBoxLayout *vlayout =
new QVBoxLayout();
4232 vlayout->setContentsMargins( 0, 0, 0, 0 );
4234 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4237 mDefaultColorButton->setShowNull(
true );
4238 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
4244 mDefaultColorButton->setToNull();
4246 mDefaultColorButton->setColor(
c );
4247 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
4251 mDefaultColorButton->setToNull();
4252 mAllowOpacity->setChecked(
true );
4255 vlayout->addWidget( mDefaultColorButton );
4256 vlayout->addWidget( mAllowOpacity );
4257 setLayout( vlayout );
4262 auto param = std::make_unique<QgsProcessingParameterColor>( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
4264 return param.release();
4272QWidget *QgsProcessingColorWidgetWrapper::createWidget()
4282 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
4285 mColorButton->setShowNull(
true );
4288 mColorButton->setToolTip( parameterDefinition()->toolTip() );
4289 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
4296 emit widgetValueHasChanged(
this );
4299 return mColorButton;
4305void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4309 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() )
4310 || ( value.userType() == QMetaType::Type::QColor && !value.value<QColor>().isValid() ) )
4311 mColorButton->setToNull();
4315 if ( !
c.isValid() && mColorButton->showNull() )
4316 mColorButton->setToNull();
4318 mColorButton->setColor(
c );
4323QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
4326 return mColorButton->isNull() ? QVariant() : mColorButton->color();
4331QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
4333 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
4336QString QgsProcessingColorWidgetWrapper::parameterType()
const
4343 return new QgsProcessingColorWidgetWrapper( parameter, type );
4348 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4359 QVBoxLayout *vlayout =
new QVBoxLayout();
4360 vlayout->setContentsMargins( 0, 0, 0, 0 );
4362 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4364 mDefaultLineEdit =
new QLineEdit();
4367 vlayout->addWidget( mDefaultLineEdit );
4369 mSourceParamComboBox =
new QComboBox();
4370 mDestParamComboBox =
new QComboBox();
4371 QString initialSource;
4372 QString initialDest;
4377 initialSource = itemParam->sourceCrsParameterName();
4378 initialDest = itemParam->destinationCrsParameterName();
4383 mSourceParamComboBox->addItem( QString(), QString() );
4384 mDestParamComboBox->addItem( QString(), QString() );
4385 if (
auto *lModel = widgetContext.
model() )
4388 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4389 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4391 if ( definition && it->parameterName() == definition->
name() )
4395 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4396 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4397 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4399 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4401 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4403 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4408 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4411 mSourceParamComboBox->addItem( initialSource, initialSource );
4412 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4414 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4417 mDestParamComboBox->addItem( initialDest, initialDest );
4418 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4421 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4422 vlayout->addWidget( mSourceParamComboBox );
4423 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4424 vlayout->addWidget( mDestParamComboBox );
4428 mStaticSourceWidget->setCrs( sourceCrs );
4431 mStaticDestWidget->setCrs( destCrs );
4433 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4434 vlayout->addWidget( mStaticSourceWidget );
4435 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4436 vlayout->addWidget( mStaticDestWidget );
4438 setLayout( vlayout );
4443 auto param = std::make_unique<QgsProcessingParameterCoordinateOperation>( name, description, mDefaultLineEdit->text(), mSourceParamComboBox->currentText(), mDestParamComboBox->currentText(), mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(), mStaticDestWidget->
crs().isValid() ? QVariant::fromValue( mStaticDestWidget->
crs() ) : QVariant() );
4445 return param.release();
4453QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4464 mOperationWidget->setShowMakeDefault(
false );
4465 mOperationWidget->setShowFallbackOption(
false );
4466 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4467 mOperationWidget->setSourceCrs( mSourceCrs );
4468 mOperationWidget->setDestinationCrs( mDestCrs );
4469 mOperationWidget->setMapCanvas( mCanvas );
4474 mOperationWidget->setSelectedOperation( deets );
4478 emit widgetValueHasChanged(
this );
4481 return mOperationWidget;
4487 mLineEdit =
new QLineEdit();
4488 QHBoxLayout *layout =
new QHBoxLayout();
4489 layout->addWidget( mLineEdit, 1 );
4490 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
4491 emit widgetValueHasChanged(
this );
4494 QToolButton *button =
new QToolButton();
4495 button->setText( QString( QChar( 0x2026 ) ) );
4496 connect( button, &QToolButton::clicked,
this, [=] {
4497 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4500 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4501 emit widgetValueHasChanged(
this );
4504 layout->addWidget( button );
4506 QWidget *w =
new QWidget();
4507 layout->setContentsMargins( 0, 0, 0, 0 );
4508 w->setLayout( layout );
4515void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4551 if ( mOperationWidget )
4552 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4555void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4557 if ( mOperationWidget )
4559 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4562 deets.
proj = value.toString();
4563 mOperationWidget->setSelectedOperation( deets );
4568 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4570 mLineEdit->setText( value.toString() );
4575QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4577 if ( mOperationWidget )
4578 return mOperationWidget->selectedOperation().proj;
4579 else if ( mLineEdit )
4580 return mLineEdit->text();
4585QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4587 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4590void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4593 std::unique_ptr<QgsProcessingContext> tmpContext;
4594 if ( mProcessingContextGenerator )
4595 context = mProcessingContextGenerator->processingContext();
4599 tmpContext = std::make_unique<QgsProcessingContext>();
4600 context = tmpContext.get();
4604 if ( mOperationWidget )
4606 mOperationWidget->setSourceCrs( mSourceCrs );
4607 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4611void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4614 std::unique_ptr<QgsProcessingContext> tmpContext;
4615 if ( mProcessingContextGenerator )
4616 context = mProcessingContextGenerator->processingContext();
4620 tmpContext = std::make_unique<QgsProcessingContext>();
4621 context = tmpContext.get();
4625 if ( mOperationWidget )
4627 mOperationWidget->setDestinationCrs( mDestCrs );
4628 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4632QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
4639 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
4644 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4656 QHBoxLayout *hl =
new QHBoxLayout();
4657 hl->setContentsMargins( 0, 0, 0, 0 );
4659 mLineEdit =
new QLineEdit();
4660 mLineEdit->setEnabled(
false );
4661 hl->addWidget( mLineEdit, 1 );
4663 mToolButton =
new QToolButton();
4664 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4665 hl->addWidget( mToolButton );
4671 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4674 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4677void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4682void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4684 if ( value.isValid() )
4685 mValue = value.userType() == QMetaType::Type::QVariantList ? value.
toList() : QVariantList() << value;
4689 updateSummaryText();
4693void QgsProcessingFieldPanelWidget::showDialog()
4695 QVariantList availableOptions;
4696 availableOptions.reserve( mFields.size() );
4697 for (
const QgsField &field : std::as_const( mFields ) )
4699 availableOptions << field.name();
4705 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4706 widget->setPanelTitle( mParam->description() );
4708 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
4709 return v.toString();
4712 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
4713 setValue( widget->selectedOptions() );
4720 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4722 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
4723 return v.toString();
4727 setValue( dlg.selectedOptions() );
4732void QgsProcessingFieldPanelWidget::updateSummaryText()
4737 if ( mValue.empty() )
4739 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4744 values.reserve( mValue.size() );
4745 for (
const QVariant &val : std::as_const( mValue ) )
4747 values << val.toString();
4750 const QString concatenated = values.join( tr(
"," ) );
4751 if ( concatenated.length() < 100 )
4752 mLineEdit->setText( concatenated );
4754 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4766 QVBoxLayout *vlayout =
new QVBoxLayout();
4767 vlayout->setContentsMargins( 0, 0, 0, 0 );
4769 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4770 mParentLayerComboBox =
new QComboBox();
4772 QString initialParent;
4774 initialParent = fieldParam->parentLayerParameterName();
4776 if (
auto *lModel = widgetContext.
model() )
4779 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4780 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4784 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4785 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4787 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4792 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4793 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4795 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4802 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4803 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4805 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4812 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4815 mParentLayerComboBox->addItem( initialParent, initialParent );
4816 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4819 vlayout->addWidget( mParentLayerComboBox );
4821 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4822 mDataTypeComboBox =
new QComboBox();
4830 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast<int>( fieldParam->dataType() ) ) );
4832 vlayout->addWidget( mDataTypeComboBox );
4834 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4836 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4838 vlayout->addWidget( mAllowMultipleCheckBox );
4840 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4841 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4843 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4845 vlayout->addWidget( mDefaultToAllCheckBox );
4847 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [=] {
4848 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4851 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4853 mDefaultLineEdit =
new QLineEdit();
4854 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4858 mDefaultLineEdit->setText( fields.join(
';' ) );
4860 vlayout->addWidget( mDefaultLineEdit );
4862 setLayout( vlayout );
4869 QVariant defaultValue;
4870 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4872 defaultValue = mDefaultLineEdit->text();
4874 auto param = std::make_unique<QgsProcessingParameterField>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
4876 return param.release();
4884QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
4894 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
4895 mPanel->setToolTip( parameterDefinition()->toolTip() );
4896 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [=] {
4897 emit widgetValueHasChanged(
this );
4917 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4919 emit widgetValueHasChanged(
this );
4927 mLineEdit =
new QLineEdit();
4928 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
4929 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
4930 emit widgetValueHasChanged(
this );
4938void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4950 setParentLayerWrapperValue( wrapper );
4952 setParentLayerWrapperValue( wrapper );
4969 std::unique_ptr<QgsProcessingContext> tmpContext;
4970 if ( mProcessingContextGenerator )
4971 context = mProcessingContextGenerator->processingContext();
4975 tmpContext = std::make_unique<QgsProcessingContext>();
4976 context = tmpContext.get();
4981 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
4991 bool valueSet =
false;
4995 if ( layers.count() > 1 )
4997 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
4999 const QList<QgsMapLayer *> remainingLayers = layers.mid( 1 );
5005 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
5006 if ( !vlayer || !vlayer->
isValid() )
5012 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
5015 fields.
remove( fieldIdx );
5020 mComboBox->setFields( fields );
5022 mPanel->setFields( filterFields( fields ) );
5028 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
5030 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5034 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
5037 mParentLayer.reset( qobject_cast<QgsVectorLayer *>( ownedLayer.release() ) );
5038 layer = mParentLayer.get();
5046 mComboBox->setLayer( layer );
5048 mPanel->setFields( filterFields( layer->
fields() ) );
5058 const QgsFields fields = source->fields();
5060 mComboBox->setFields( fields );
5062 mPanel->setFields( filterFields( fields ) );
5071 mComboBox->setLayer(
nullptr );
5075 if ( value.isValid() && widgetContext().messageBar() )
5087 val.reserve( mPanel->fields().size() );
5088 for (
const QgsField &field : mPanel->fields() )
5089 val << field.name();
5090 setWidgetValue( val, *context );
5093 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5096void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5100 if ( !value.isValid() )
5101 mComboBox->setField( QString() );
5105 mComboBox->setField( v );
5111 if ( value.isValid() )
5114 opts.reserve( v.size() );
5115 for (
const QString &i : v )
5119 mPanel->setValue( opts );
5121 else if ( mLineEdit )
5127 mLineEdit->setText( v.join(
';' ) );
5136QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
5139 return mComboBox->currentField();
5141 return mPanel->value();
5142 else if ( mLineEdit )
5147 return mLineEdit->text().split(
';' );
5150 return mLineEdit->text();
5156QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
5158 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
5161const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
5163 if ( mComboBox && mComboBox->layer() )
5164 return mComboBox->layer();
5169QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
5182 if ( f.isNumeric() )
5187 if ( f.type() == QMetaType::Type::QString )
5192 if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
5197 if ( f.type() == QMetaType::Type::QByteArray )
5202 if ( f.type() == QMetaType::Type::Bool )
5211QString QgsProcessingFieldWidgetWrapper::parameterType()
const
5218 return new QgsProcessingFieldWidgetWrapper( parameter, type );
5223 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5234 QVBoxLayout *vlayout =
new QVBoxLayout();
5235 vlayout->setContentsMargins( 0, 0, 0, 0 );
5237 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5239 mDefaultComboBox =
new QComboBox();
5240 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
5243 for (
const QString &theme : mapThemes )
5247 mDefaultComboBox->setEditable(
true );
5251 if ( themeParam->defaultValueForGui().isValid() )
5254 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5257 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5259 vlayout->addWidget( mDefaultComboBox );
5261 setLayout( vlayout );
5266 QVariant defaultVal;
5267 if ( mDefaultComboBox->currentText().isEmpty() )
5268 defaultVal = QVariant();
5270 defaultVal = mDefaultComboBox->currentText();
5271 auto param = std::make_unique<QgsProcessingParameterMapTheme>( name, description, defaultVal );
5273 return param.release();
5282QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
5286 mComboBox =
new QComboBox();
5289 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
5292 for (
const QString &theme : mapThemes )
5304 mComboBox->setEditable(
true );
5308 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5309 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
5310 emit widgetValueHasChanged(
this );
5316void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5320 if ( !value.isValid() )
5321 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5324 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5326 const QString prev = mComboBox->currentText();
5327 mComboBox->setCurrentText( v );
5329 emit widgetValueHasChanged(
this );
5332 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5336QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5339 return mComboBox->currentData().toInt() == -1 ? QVariant() : !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5340 : mComboBox->currentData();
5345QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5347 return tr(
"map theme as a string value (e.g. 'base maps')" );
5350QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5357 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5362 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5374 QVBoxLayout *vlayout =
new QVBoxLayout();
5375 vlayout->setContentsMargins( 0, 0, 0, 0 );
5377 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5379 mTypeComboBox =
new QComboBox();
5384 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( datetimeParam->dataType() ) ) );
5386 mTypeComboBox->setCurrentIndex( 0 );
5387 vlayout->addWidget( mTypeComboBox );
5389 setLayout( vlayout );
5394 auto param = std::make_unique<QgsProcessingParameterDateTime>( name, description );
5397 return param.release();
5406QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5411 switch ( dateTimeParam->
dataType() )
5415 widget = mDateTimeEdit;
5438 widget->setToolTip( parameterDefinition()->toolTip() );
5440 if ( mDateTimeEdit )
5443 emit widgetValueHasChanged(
this );
5446 else if ( mDateEdit )
5449 emit widgetValueHasChanged(
this );
5452 else if ( mTimeEdit )
5455 emit widgetValueHasChanged(
this );
5464 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5467void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5469 if ( mDateTimeEdit )
5473 else if ( mDateEdit )
5477 else if ( mTimeEdit )
5483QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5485 if ( mDateTimeEdit )
5486 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5487 else if ( mDateEdit )
5488 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5489 else if ( mTimeEdit )
5490 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5495QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5498 if ( dateTimeParam )
5500 switch ( dateTimeParam->
dataType() )
5503 return tr(
"datetime value, or a ISO string representation of a datetime" );
5506 return tr(
"date value, or a ISO string representation of a date" );
5509 return tr(
"time value, or a ISO string representation of a time" );
5515QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5522 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5535 QVBoxLayout *vlayout =
new QVBoxLayout();
5536 vlayout->setContentsMargins( 0, 0, 0, 0 );
5538 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5539 mProviderComboBox =
new QComboBox();
5540 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
5541 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
5542 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
5544 vlayout->addWidget( mProviderComboBox );
5546 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5548 mDefaultEdit =
new QLineEdit();
5549 vlayout->addWidget( mDefaultEdit );
5550 setLayout( vlayout );
5552 if ( connectionParam )
5554 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5561 QVariant defaultVal;
5562 if ( mDefaultEdit->text().isEmpty() )
5563 defaultVal = QVariant();
5565 defaultVal = mDefaultEdit->text();
5566 auto param = std::make_unique<QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5568 return param.release();
5577QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5583 mProviderComboBox->setAllowEmptyConnection(
true );
5591 mProviderComboBox->setEditable(
true );
5595 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5596 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [=](
const QString & ) {
5597 if ( mBlockSignals )
5600 emit widgetValueHasChanged(
this );
5603 return mProviderComboBox;
5608 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5611void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5615 if ( !value.isValid() )
5616 mProviderComboBox->setCurrentIndex( -1 );
5619 if ( mProviderComboBox->isEditable() )
5621 const QString prev = mProviderComboBox->currentText();
5623 mProviderComboBox->setConnection( v );
5624 mProviderComboBox->setCurrentText( v );
5628 emit widgetValueHasChanged(
this );
5631 mProviderComboBox->setConnection( v );
5635QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5637 if ( mProviderComboBox )
5638 if ( mProviderComboBox->isEditable() )
5639 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5641 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5646QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5648 return tr(
"connection name as a string value" );
5651QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5658 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5671 QVBoxLayout *vlayout =
new QVBoxLayout();
5672 vlayout->setContentsMargins( 0, 0, 0, 0 );
5674 mConnectionParamComboBox =
new QComboBox();
5675 QString initialConnection;
5681 if (
auto *lModel = widgetContext.
model() )
5684 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5685 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5687 if ( definition && it->parameterName() == definition->
name() )
5693 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5694 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5696 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5701 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5704 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5705 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5708 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5709 vlayout->addWidget( mConnectionParamComboBox );
5711 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5713 mDefaultEdit =
new QLineEdit();
5714 vlayout->addWidget( mDefaultEdit );
5715 setLayout( vlayout );
5725 QVariant defaultVal;
5726 if ( mDefaultEdit->text().isEmpty() )
5727 defaultVal = QVariant();
5729 defaultVal = mDefaultEdit->text();
5730 auto param = std::make_unique<QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5732 return param.release();
5741QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5747 mSchemaComboBox->setAllowEmptySchema(
true );
5755 mSchemaComboBox->comboBox()->setEditable(
true );
5759 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5760 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [=](
const QString & ) {
5761 if ( mBlockSignals )
5764 emit widgetValueHasChanged( this );
5767 return mSchemaComboBox;
5772 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5779 std::unique_ptr<QgsProcessingContext> tmpContext;
5780 if ( mProcessingContextGenerator )
5781 context = mProcessingContextGenerator->processingContext();
5785 tmpContext = std::make_unique<QgsProcessingContext>();
5786 context = tmpContext.get();
5792 if ( mSchemaComboBox )
5793 mSchemaComboBox->setConnectionName( connection, qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId() );
5797 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5800void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5804 if ( !value.isValid() )
5805 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5808 if ( mSchemaComboBox->comboBox()->isEditable() )
5810 const QString prev = mSchemaComboBox->comboBox()->currentText();
5812 mSchemaComboBox->setSchema( v );
5813 mSchemaComboBox->comboBox()->setCurrentText( v );
5817 emit widgetValueHasChanged(
this );
5820 mSchemaComboBox->setSchema( v );
5824QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5826 if ( mSchemaComboBox )
5827 if ( mSchemaComboBox->comboBox()->isEditable() )
5828 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5830 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5835QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5837 return tr(
"database schema name as a string value" );
5840QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5847 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5850void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5862 setParentConnectionWrapperValue( wrapper );
5864 setParentConnectionWrapperValue( wrapper );
5887 QVBoxLayout *vlayout =
new QVBoxLayout();
5888 vlayout->setContentsMargins( 0, 0, 0, 0 );
5890 mConnectionParamComboBox =
new QComboBox();
5891 mSchemaParamComboBox =
new QComboBox();
5892 QString initialConnection;
5893 QString initialSchema;
5900 if (
auto *lModel = widgetContext.
model() )
5903 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5904 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5906 if ( definition && it->parameterName() == definition->
name() )
5911 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5912 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5914 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5919 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
5920 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5922 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5928 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5931 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5932 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5935 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
5938 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
5939 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5942 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5943 vlayout->addWidget( mConnectionParamComboBox );
5945 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
5946 vlayout->addWidget( mSchemaParamComboBox );
5948 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5950 mDefaultEdit =
new QLineEdit();
5951 vlayout->addWidget( mDefaultEdit );
5952 setLayout( vlayout );
5962 QVariant defaultVal;
5963 if ( mDefaultEdit->text().isEmpty() )
5964 defaultVal = QVariant();
5966 defaultVal = mDefaultEdit->text();
5967 auto param = std::make_unique<QgsProcessingParameterDatabaseTable>( name, description, mConnectionParamComboBox->currentData().toString(), mSchemaParamComboBox->currentData().toString(), defaultVal );
5969 return param.release();
5978QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
5984 mTableComboBox->setAllowEmptyTable(
true );
5987 mTableComboBox->comboBox()->setEditable(
true );
5989 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
5990 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [=](
const QString & ) {
5991 if ( mBlockSignals )
5994 emit widgetValueHasChanged( this );
5997 return mTableComboBox;
6002 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6009 std::unique_ptr<QgsProcessingContext> tmpContext;
6010 if ( mProcessingContextGenerator )
6011 context = mProcessingContextGenerator->processingContext();
6015 tmpContext = std::make_unique<QgsProcessingContext>();
6016 context = tmpContext.get();
6021 mProvider = qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId();
6022 if ( mTableComboBox && !mSchema.isEmpty() )
6024 mTableComboBox->setSchema( mSchema );
6025 mTableComboBox->setConnectionName( mConnection, mProvider );
6029 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6037 std::unique_ptr<QgsProcessingContext> tmpContext;
6038 if ( mProcessingContextGenerator )
6039 context = mProcessingContextGenerator->processingContext();
6043 tmpContext = std::make_unique<QgsProcessingContext>();
6044 context = tmpContext.get();
6050 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
6052 mTableComboBox->setSchema( mSchema );
6053 mTableComboBox->setConnectionName( mConnection, mProvider );
6057 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6061void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6065 if ( !value.isValid() )
6066 mTableComboBox->comboBox()->setCurrentIndex( -1 );
6069 if ( mTableComboBox->comboBox()->isEditable() )
6071 const QString prev = mTableComboBox->comboBox()->currentText();
6073 mTableComboBox->setTable( v );
6074 mTableComboBox->comboBox()->setCurrentText( v );
6078 emit widgetValueHasChanged(
this );
6081 mTableComboBox->setTable( v );
6085QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
6087 if ( mTableComboBox )
6088 if ( mTableComboBox->comboBox()->isEditable() )
6089 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
6091 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
6096QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
6098 return tr(
"database table name as a string value" );
6101QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
6108 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
6111void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6123 setParentConnectionWrapperValue( wrapper );
6125 setParentConnectionWrapperValue( wrapper );
6130 setParentSchemaWrapperValue( wrapper );
6132 setParentSchemaWrapperValue( wrapper );
6152 QVBoxLayout *vlayout =
new QVBoxLayout();
6153 vlayout->setContentsMargins( 0, 0, 0, 0 );
6155 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6158 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6161 if ( extentParam->defaultValueForGui().isValid() )
6165 mDefaultWidget->setCurrentExtent( rect,
crs );
6166 mDefaultWidget->setOutputExtentFromCurrent();
6170 mDefaultWidget->clear();
6174 vlayout->addWidget( mDefaultWidget );
6175 setLayout( vlayout );
6180 const QString defaultVal = mDefaultWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg( QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ), QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ), QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ), QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ), mDefaultWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mDefaultWidget->outputCrs().authid() ) : QString() ) : QString();
6181 auto param = std::make_unique<QgsProcessingParameterExtent>( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
6183 return param.release();
6192QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
6202 if ( widgetContext().mapCanvas() )
6203 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
6206 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6208 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6211 emit widgetValueHasChanged(
this );
6215 setDialog( mDialog );
6217 return mExtentWidget;
6227 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6230void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6237 mDialog->showMinimized();
6240 mDialog->showNormal();
6242 mDialog->activateWindow();
6249void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6251 if ( mExtentWidget )
6253 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
6254 mExtentWidget->clear();
6259 mExtentWidget->setCurrentExtent( r,
crs );
6260 mExtentWidget->setOutputExtentFromUser( r,
crs );
6265QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6267 if ( mExtentWidget )
6269 const QString val = mExtentWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg( QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ), QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ), QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ), QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ), mExtentWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mExtentWidget->outputCrs().authid() ) : QString() ) : QString();
6271 return val.isEmpty() ? QVariant() : QVariant( val );
6277QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6279 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6282QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6289 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6294 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6305 QVBoxLayout *vlayout =
new QVBoxLayout();
6306 vlayout->setContentsMargins( 0, 0, 0, 0 );
6308 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6324 for (
int i : layerParam->dataTypes() )
6326 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6330 vlayout->addWidget( mLayerTypeComboBox );
6332 setLayout( vlayout );
6337 QList<int> dataTypes;
6338 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6339 dataTypes << v.toInt();
6341 auto param = std::make_unique<QgsProcessingParameterMapLayer>( name, description );
6342 param->setDataTypes( dataTypes );
6344 return param.release();
6352QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6354 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6362 mComboBox->setEditable(
true );
6366 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6368 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [=]() {
6369 if ( mBlockSignals )
6372 emit widgetValueHasChanged(
this );
6375 setWidgetContext( widgetContext() );
6384 mComboBox->setWidgetContext( context );
6389 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6395void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6398 mComboBox->setValue( value, context );
6401QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6403 return mComboBox ? mComboBox->value() : QVariant();
6406QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6408 return tr(
"path to a map layer" );
6425QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6432 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6437 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6446 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6450QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6452 return tr(
"path to a raster layer" );
6455QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6462 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6467 Q_UNUSED( context );
6468 Q_UNUSED( widgetContext );
6469 Q_UNUSED( definition );
6483 QVBoxLayout *vlayout =
new QVBoxLayout();
6484 vlayout->setContentsMargins( 0, 0, 0, 0 );
6486 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6496 for (
int i : vectorParam->dataTypes() )
6498 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6502 vlayout->addWidget( mGeometryTypeComboBox );
6504 setLayout( vlayout );
6509 QList<int> dataTypes;
6510 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6511 dataTypes << v.toInt();
6513 auto param = std::make_unique<QgsProcessingParameterVectorLayer>( name, description, dataTypes );
6515 return param.release();
6520 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6524QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6526 return tr(
"path to a vector layer" );
6529QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6536 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6541 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6552 QVBoxLayout *vlayout =
new QVBoxLayout();
6553 vlayout->setContentsMargins( 0, 0, 0, 0 );
6555 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6565 for (
int i : sourceParam->dataTypes() )
6567 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6575 vlayout->addWidget( mGeometryTypeComboBox );
6577 setLayout( vlayout );
6582 QList<int> dataTypes;
6583 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6584 dataTypes << v.toInt();
6586 auto param = std::make_unique<QgsProcessingParameterFeatureSource>( name, description, dataTypes );
6588 return param.release();
6592 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6596QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6598 return tr(
"path to a vector layer" );
6601QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6608 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6613 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6621 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6625QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6627 return tr(
"path to a mesh layer" );
6630QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6637 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6642 Q_UNUSED( context );
6643 Q_UNUSED( widgetContext );
6644 Q_UNUSED( definition );
6655QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6659 QHBoxLayout *hl =
new QHBoxLayout();
6660 hl->setContentsMargins( 0, 0, 0, 0 );
6662 mLineEdit =
new QLineEdit();
6663 mLineEdit->setEnabled(
false );
6664 hl->addWidget( mLineEdit, 1 );
6666 mToolButton =
new QToolButton();
6667 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6668 hl->addWidget( mToolButton );
6674 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6677 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6680void QgsProcessingRasterBandPanelWidget::setBands(
const QList<int> &bands )
6685void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6690void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6692 if ( value.isValid() )
6693 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
6697 updateSummaryText();
6701void QgsProcessingRasterBandPanelWidget::showDialog()
6703 QVariantList availableOptions;
6704 availableOptions.reserve( mBands.size() );
6705 for (
int band : std::as_const( mBands ) )
6707 availableOptions << band;
6713 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6714 widget->setPanelTitle( mParam->description() );
6716 widget->setValueFormatter( [
this](
const QVariant &v ) -> QString {
6717 int band = v.toInt();
6718 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6721 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
6722 setValue( widget->selectedOptions() );
6729 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6731 dlg.setValueFormatter( [
this](
const QVariant &v ) -> QString {
6732 int band = v.toInt();
6733 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6737 setValue( dlg.selectedOptions() );
6742void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6745 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6756 QVBoxLayout *vlayout =
new QVBoxLayout();
6757 vlayout->setContentsMargins( 0, 0, 0, 0 );
6759 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6761 mDefaultLineEdit =
new QLineEdit();
6762 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6767 for (
int b : bands )
6769 defVal << QString::number( b );
6772 mDefaultLineEdit->setText( defVal.join(
';' ) );
6774 vlayout->addWidget( mDefaultLineEdit );
6776 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6777 mParentLayerComboBox =
new QComboBox();
6779 QString initialParent;
6781 initialParent = bandParam->parentLayerParameterName();
6783 if (
auto *lModel = widgetContext.
model() )
6786 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6787 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6791 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
6792 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6794 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6800 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6803 mParentLayerComboBox->addItem( initialParent, initialParent );
6804 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6807 vlayout->addWidget( mParentLayerComboBox );
6809 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6811 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6813 vlayout->addWidget( mAllowMultipleCheckBox );
6814 setLayout( vlayout );
6819 auto param = std::make_unique<QgsProcessingParameterBand>( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6821 return param.release();
6829QWidget *QgsProcessingBandWidgetWrapper::createWidget()
6839 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
6840 mPanel->setToolTip( parameterDefinition()->toolTip() );
6841 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [=] {
6842 emit widgetValueHasChanged(
this );
6851 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6853 emit widgetValueHasChanged(
this );
6861 mLineEdit =
new QLineEdit();
6862 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6863 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
6864 emit widgetValueHasChanged(
this );
6872void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6884 setParentLayerWrapperValue( wrapper );
6886 setParentLayerWrapperValue( wrapper );
6903 std::unique_ptr<QgsProcessingContext> tmpContext;
6904 if ( mProcessingContextGenerator )
6905 context = mProcessingContextGenerator->processingContext();
6909 tmpContext = std::make_unique<QgsProcessingContext>();
6910 context = tmpContext.get();
6916 if ( layer && layer->
isValid() )
6920 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
6923 mParentLayer.reset( qobject_cast<QgsRasterLayer *>( ownedLayer.release() ) );
6924 layer = mParentLayer.get();
6932 mComboBox->setLayer( layer );
6936 if ( provider && layer->
isValid() )
6941 QHash<int, QString> bandNames;
6942 for (
int i = 1; i <= nBands; ++i )
6947 mPanel->setBands( bands );
6948 mPanel->setBandNames( bandNames );
6955 mComboBox->setLayer(
nullptr );
6957 mPanel->setBands( QList<int>() );
6959 if ( value.isValid() && widgetContext().messageBar() )
6966 if ( parameterDefinition()->defaultValueForGui().isValid() )
6967 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6970void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6974 if ( !value.isValid() )
6975 mComboBox->setBand( -1 );
6979 mComboBox->setBand( v );
6985 if ( value.isValid() )
6988 opts.reserve( v.size() );
6993 mPanel->setValue( value.isValid() ? opts : QVariant() );
6995 else if ( mLineEdit )
7002 opts.reserve( v.size() );
7004 opts << QString::number( i );
7005 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
7009 if ( value.isValid() )
7017QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
7020 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
7022 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7023 else if ( mLineEdit )
7028 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
7030 res.reserve( parts.count() );
7031 for (
const QString &s : parts )
7034 int band = s.toInt( &ok );
7038 return res.
isEmpty() ? QVariant() : res;
7042 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7049QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7051 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7054QString QgsProcessingBandWidgetWrapper::parameterType()
const
7061 return new QgsProcessingBandWidgetWrapper( parameter, type );
7066 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7077 setAcceptDrops(
true );
7080void QgsProcessingMultipleLayerLineEdit::dragEnterEvent( QDragEnterEvent *event )
7082 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7083 if ( !uris.isEmpty() )
7085 event->setDropAction( Qt::CopyAction );
7087 setHighlighted(
true );
7095void QgsProcessingMultipleLayerLineEdit::dragLeaveEvent( QDragLeaveEvent *event )
7097 QgsHighlightableLineEdit::dragLeaveEvent( event );
7099 setHighlighted(
false );
7102void QgsProcessingMultipleLayerLineEdit::dropEvent( QDropEvent *event )
7104 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7105 if ( !uris.isEmpty() )
7107 event->setDropAction( Qt::CopyAction );
7109 QVariantList uriList;
7110 uriList.reserve( uris.size() );
7111 for (
const QString &uri : uris )
7112 uriList.append( QVariant( uri ) );
7113 emit layersDropped( uriList );
7116 setHighlighted(
false );
7127 QHBoxLayout *hl =
new QHBoxLayout();
7128 hl->setContentsMargins( 0, 0, 0, 0 );
7130 mLineEdit =
new QgsProcessingMultipleLayerLineEdit(
nullptr, param );
7131 mLineEdit->setEnabled(
true );
7132 mLineEdit->setReadOnly(
true );
7134 hl->addWidget( mLineEdit, 1 );
7135 connect( mLineEdit, &QgsProcessingMultipleLayerLineEdit::layersDropped,
this, &QgsProcessingMultipleLayerPanelWidget::setValue );
7137 mToolButton =
new QToolButton();
7138 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7139 hl->addWidget( mToolButton );
7145 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7148 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7151void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7153 if ( value.isValid() )
7154 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7158 updateSummaryText();
7162void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7168 if ( mValue.removeAll( layerId ) )
7170 updateSummaryText();
7177void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7183 switch ( mParam->layerType() )
7265void QgsProcessingMultipleLayerPanelWidget::showDialog()
7270 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
7271 widget->setPanelTitle( mParam->description() );
7272 widget->setProject( mProject );
7273 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
7274 setValue( widget->selectedOptions() );
7281 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7282 dlg.setProject( mProject );
7285 setValue( dlg.selectedOptions() );
7290void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7293 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7303 QVBoxLayout *vlayout =
new QVBoxLayout();
7304 vlayout->setContentsMargins( 0, 0, 0, 0 );
7306 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7307 mLayerTypeComboBox =
new QComboBox();
7321 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast<int>( layersParam->layerType() ) ) );
7323 vlayout->addWidget( mLayerTypeComboBox );
7324 setLayout( vlayout );
7329 auto param = std::make_unique<QgsProcessingParameterMultipleLayers>( name, description,
static_cast<Qgis::ProcessingSourceType>( mLayerTypeComboBox->currentData().toInt() ) );
7331 return param.release();
7339QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7343 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7344 mPanel->setToolTip( parameterDefinition()->toolTip() );
7345 mPanel->setProject( widgetContext().project() );
7347 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7348 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [=] {
7349 emit widgetValueHasChanged(
this );
7359 mPanel->setProject( context.
project() );
7361 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7365void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7370 if ( value.isValid() )
7373 opts.reserve( v.size() );
7375 opts << l->source();
7378 for (
const QVariant &v : value.toList() )
7380 if ( v.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
7382 const QgsProcessingModelChildParameterSource source = v.value<QgsProcessingModelChildParameterSource>();
7383 opts << QVariant::fromValue( source );
7388 mPanel->setValue( value.isValid() ? opts : QVariant() );
7392QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7395 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7400QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7402 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7405QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7412 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7417 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7426 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7430QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7432 return tr(
"path to a point cloud layer" );
7435QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7442 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7447 Q_UNUSED( context );
7448 Q_UNUSED( widgetContext );
7449 Q_UNUSED( definition );
7465QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7467 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7470QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7477 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7482 Q_UNUSED( context );
7483 Q_UNUSED( widgetContext );
7484 Q_UNUSED( definition );
7495 if ( mWidgetContext.project() )
7496 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7500QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7511 mComboBox->setEditable(
true );
7515 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7517 if ( mWidgetContext.project() )
7518 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7521 mComboBox->setAllowEmptyLayer(
true );
7524 if ( mBlockSignals )
7527 emit widgetValueHasChanged(
this );
7530 setWidgetContext( widgetContext() );
7534void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7540 mComboBox->setLayer(
nullptr );
7544 QVariant val = value;
7545 if ( val.userType() == qMetaTypeId<QgsProperty>() )
7557 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( val.value<QObject *>() );
7558 if ( !layer && val.userType() == QMetaType::Type::QString )
7565 mComboBox->setLayer( layer );
7570QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7572 return mComboBox && mComboBox->currentLayer() ? ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral(
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
7585 QHBoxLayout *hl =
new QHBoxLayout();
7586 hl->setContentsMargins( 0, 0, 0, 0 );
7588 mLineEdit =
new QLineEdit();
7589 mLineEdit->setEnabled(
false );
7590 hl->addWidget( mLineEdit, 1 );
7592 mToolButton =
new QToolButton();
7593 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7594 hl->addWidget( mToolButton );
7600 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7603 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7608 mAttributes = attributes;
7611void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7613 if ( value.isValid() )
7614 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7618 updateSummaryText();
7622void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7624 QVariantList availableOptions;
7625 availableOptions.reserve( mAttributes.count() );
7626 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7629 availableOptions << attr.name();
7635 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7636 widget->setPanelTitle( mParam->description() );
7638 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
7639 return v.toString();
7642 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
7643 setValue( widget->selectedOptions() );
7650 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7652 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
7653 return v.toString();
7657 setValue( dlg.selectedOptions() );
7662void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7667 if ( mValue.empty() )
7669 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7674 values.reserve( mValue.size() );
7675 for (
const QVariant &val : std::as_const( mValue ) )
7677 values << val.toString();
7680 const QString concatenated = values.join( tr(
"," ) );
7681 if ( concatenated.length() < 100 )
7682 mLineEdit->setText( concatenated );
7684 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7696 QVBoxLayout *vlayout =
new QVBoxLayout();
7697 vlayout->setContentsMargins( 0, 0, 0, 0 );
7699 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7700 mParentLayerComboBox =
new QComboBox();
7702 QString initialParent;
7704 initialParent = attrParam->parentLayerParameterName();
7706 if (
auto *lModel = widgetContext.
model() )
7709 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7710 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7714 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
7715 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7717 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7723 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7726 mParentLayerComboBox->addItem( initialParent, initialParent );
7727 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7730 vlayout->addWidget( mParentLayerComboBox );
7732 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
7734 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
7736 vlayout->addWidget( mAllowMultipleCheckBox );
7738 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
7739 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7741 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
7743 vlayout->addWidget( mDefaultToAllCheckBox );
7745 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [=] {
7746 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7749 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7751 mDefaultLineEdit =
new QLineEdit();
7752 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
7756 mDefaultLineEdit->setText( attributes.join(
';' ) );
7758 vlayout->addWidget( mDefaultLineEdit );
7760 setLayout( vlayout );
7765 QVariant defaultValue;
7766 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
7768 defaultValue = mDefaultLineEdit->text();
7770 auto param = std::make_unique<QgsProcessingParameterPointCloudAttribute>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
7772 return param.release();
7780QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
7790 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
7791 mPanel->setToolTip( parameterDefinition()->toolTip() );
7792 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [=] {
7793 emit widgetValueHasChanged(
this );
7801 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7803 emit widgetValueHasChanged(
this );
7811 mLineEdit =
new QLineEdit();
7812 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
7813 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
7814 emit widgetValueHasChanged(
this );
7822void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7834 setParentLayerWrapperValue( wrapper );
7836 setParentLayerWrapperValue( wrapper );
7853 std::unique_ptr<QgsProcessingContext> tmpContext;
7854 if ( mProcessingContextGenerator )
7855 context = mProcessingContextGenerator->processingContext();
7859 tmpContext = std::make_unique<QgsProcessingContext>();
7860 context = tmpContext.get();
7866 if ( layer && layer->
isValid() )
7870 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
7873 mParentLayer.reset( qobject_cast<QgsPointCloudLayer *>( ownedLayer.release() ) );
7874 layer = mParentLayer.get();
7882 mComboBox->setLayer( layer );
7885 mPanel->setAttributes( layer->
attributes() );
7892 mComboBox->setLayer(
nullptr );
7897 if ( value.isValid() && widgetContext().messageBar() )
7908 val.reserve( mPanel->attributes().attributes().size() );
7911 setWidgetValue( val, *context );
7914 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7917void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7921 if ( !value.isValid() )
7922 mComboBox->setAttribute( QString() );
7926 mComboBox->setAttribute( v );
7932 if ( value.isValid() )
7935 opts.reserve( v.size() );
7936 for (
const QString &i : v )
7940 mPanel->setValue( opts );
7942 else if ( mLineEdit )
7948 mLineEdit->setText( v.join(
';' ) );
7957QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
7960 return mComboBox->currentAttribute();
7962 return mPanel->value();
7963 else if ( mLineEdit )
7968 return mLineEdit->text().split(
';' );
7971 return mLineEdit->text();
7977QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
7979 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
7982QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
7989 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
7994 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8007QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8015 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8016 if ( mProcessingContextGenerator )
8017 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8018 if ( mParametersGenerator )
8019 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8020 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8022 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [=]() {
8023 if ( mBlockSignals )
8026 emit widgetValueHasChanged(
this );
8031 mOutputWidget->addOpenAfterRunningOption();
8033 return mOutputWidget;
8043void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8045 if ( mOutputWidget )
8046 mOutputWidget->setValue( value );
8049QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8051 if ( mOutputWidget )
8052 return mOutputWidget->value();
8057QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8060 if ( mOutputWidget )
8061 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
8070 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8074QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8081 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8084QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8086 return tr(
"path to layer destination" );
8094 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8098QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8105 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8108QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8110 return tr(
"path to layer destination" );
8118 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8122QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8129 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8132QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8134 return tr(
"path to layer destination" );
8142 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8146QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8153 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8156QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8158 return tr(
"path to layer destination" );
8166 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8170QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8177 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8181QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8183 return tr(
"path to file destination" );
8191 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8195QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8202 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8206QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8208 return tr(
"path to folder destination" );
8216 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8220QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8227 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8230QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8232 return tr(
"path to layer destination" );
@ Standard
Unit is a standard measurement unit.
ProcessingSourceType
Processing data source types.
@ File
Files (i.e. non map layer sources, such as text files)
@ Annotation
Annotation layers.
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ VectorTile
Vector tile layers.
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ VectorAnyGeometry
Any vector layer with geometry.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ PointCloud
Point cloud layers.
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
@ File
Parameter is a single file.
@ Folder
Parameter is a folder.
ExpressionType
Expression types.
@ RasterCalculator
Raster calculator expression.
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
ProcessingMode
Types of modes which Processing widgets can be created for.
@ Batch
Batch processing mode.
@ Standard
Standard (single-run) algorithm mode.
DistanceUnit
Units of distance.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ NauticalMiles
Nautical miles.
ProcessingFieldParameterDataType
Processing field parameter data types.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ Numeric
Accepts numeric fields.
@ DateTime
Accepts datetime fields.
@ SquareCentimeters
Square centimeters.
@ SquareInches
Square inches.
@ SquareNauticalMiles
Square nautical miles.
@ SquareMillimeters
Square millimeters.
@ SquareYards
Square yards.
@ SquareKilometers
Square kilometers.
@ SquareMeters
Square meters.
@ Unknown
Unknown areal unit.
@ SquareDegrees
Square degrees, for planar geographic CRS area measurements.
@ SquareMiles
Square miles.
@ Info
Information message.
@ AnnotationLayer
QgsAnnotationLayer.
TemporalUnit
Temporal units.
@ Milliseconds
Milliseconds.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
VolumeUnit
Units of volume.
@ CubicMeters
Cubic meters.
@ CubicDegrees
Cubic degrees, for planar geographic CRS volume measurements.
@ CubicDecimeter
Cubic decimeters.
@ Unknown
Unknown volume unit.
@ CubicCentimeter
Cubic Centimeters.
ProcessingModelChildParameterSource
Processing model child parameter sources.
@ ModelParameter
Parameter value is taken from a parent model parameter.
@ StaticValue
Parameter value is a static value.
@ Optional
Parameter is optional.
ProcessingDateTimeParameterDataType
Processing date time parameter data types.
@ DateTime
Datetime values.
ProcessingNumberParameterType
Processing numeric parameter data types.
@ Double
Double/float values.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
@ CapturePoint
Select and capture a point or a feature.
Selector widget for authentication configs.
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing.
QComboBox subclass which allows selecting multiple items.
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Qgis::DistanceUnit mapUnits
A combo box which displays the list of schemas for a specific database connection.
A combobox which displays the list of tables for a specific database connection.
A QDateEdit widget with the capability of setting/reading null dates.
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
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.
A widget which includes a line edit for entering expressions together with a button to open the expre...
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
A combobox which displays the list of fields of a given layer.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
@ DateTime
Datetime fields.
@ Date
Date or datetime fields.
@ Binary
Binary fields, since QGIS 3.34.
@ Boolean
Boolean fields, since QGIS 3.34.
@ Numeric
All numeric fields.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
void remove(int fieldIdx)
Removes the field with the given index.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A geometry is the spatial representation of a feature.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
A QgsFilterLineEdit subclass with the ability to "highlight" the edges of the widget.
A combobox 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.
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.
A combobox which displays a dynamic list of layers from a QGIS project.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
Base class for all map layer types.
A mouse event which is the result of a user interaction with a QgsMapCanvas.
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Interface for master layout type objects, such as print layouts and reports.
virtual QString name() const =0
Returns the layout's name.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
bool clearWidgets()
Removes all items from the bar.
A collection of point cloud attributes.
A combobox which displays the list of attributes of a given point cloud layer.
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.
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.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for area values.
Qgis::AreaUnit defaultUnit() const
Returns the default area unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A raster band parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
A boolean parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A color parameter for processing algorithms.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
static QString typeName()
Returns the type name for the parameter class.
A coordinate operation parameter for processing algorithms.
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.
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
A datetime (or pure date or time) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
void setFlags(Qgis::ProcessingParameterFlags flags)
Sets the flags associated with the parameter.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
QString description() const
Returns the description for the parameter.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
virtual QString type() const =0
Unique parameter type name.
QString name() const
Returns the name of the parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
A double numeric parameter for duration values.
Qgis::TemporalUnit defaultUnit() const
Returns the default duration unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
static QString typeName()
Returns the type name for the parameter class.
An expression parameter for processing algorithms.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ExpressionType expressionType() const
Returns the parameter's expression type.
A rectangular map extent parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
An input feature source (such as vector layers) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A vector layer or feature source field parameter for processing algorithms.
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
static QString typeName()
Returns the type name for the parameter class.
A geometry parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A print layout item parameter, allowing users to select a particular item from a print layout.
static QString typeName()
Returns the type name for the parameter class.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
A print layout parameter, allowing users to select a print layout.
static QString typeName()
Returns the type name for the parameter class.
A map layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
static QString typeName()
Returns the type name for the parameter class.
A table (matrix) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
static QString typeName()
Returns the type name for the parameter class.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
double maximum() const
Returns the maximum value acceptable by the parameter.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer attribute parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A point parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A data provider connection parameter for processing algorithms, allowing users to select from availab...
static QString typeName()
Returns the type name for the parameter class.
QString providerId() const
Returns the ID of the provider associated with the connections.
A numeric range parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
A raster layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool multiLine() const
Returns true if the parameter allows multiline strings.
static QString typeName()
Returns the type name for the parameter class.
A vector layer (with or without geometry) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for volume values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::VolumeUnit defaultUnit() const
Returns the default volume unit for the parameter.
Contains settings which reflect the context in which a Processing parameter widget is shown.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsProject * project() const
Returns the project associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
QgsMapLayer * activeLayer() const
Returns the current active layer.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a list of map layers.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QStringList parameterAsStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of strings (e.g.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a point cloud layer.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Utility functions for use with processing classes.
@ Annotation
Annotation layer type, since QGIS 3.22.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
void layerRemoved(const QString &layerId)
Emitted after a layer was removed from the registry.
A store for object properties.
Qgis::PropertyType propertyType() const
Returns the property type.
A combo box which displays the list of connections registered for a given provider.
A combobox widget which displays the bands present in a raster layer.
void bandChanged(int band)
Emitted when the currently selected band changes.
static QString displayBandName(QgsRasterDataProvider *provider, int band)
Returns a user-friendly band name for the specified band.
Base class for raster data providers.
virtual int bandCount() const =0
Gets number of bands.
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
A rectangle specified with double values.
A QgsGeometry with associated coordinate reference system.
Responsible for drawing transient features (e.g.
@ ICON_X
A cross is used to highlight points (x)
Stores settings for use within QGIS.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Shows a snapping marker on map canvas for the current snapping match.
A spin box with a clear button that will set the value to the defined clear value.
A QTimeEdit widget with the capability of setting/reading null date/times.
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE Qgis::DistanceUnitType unitType(Qgis::DistanceUnit unit)
Returns the type for a distance unit.
static Q_INVOKABLE Qgis::AreaUnit distanceToAreaUnit(Qgis::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding area unit, e.g., meters to square meters.
static Q_INVOKABLE Qgis::VolumeUnit distanceToVolumeUnit(Qgis::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding volume unit, e.g., meters to cubic meters.
Represents a vector layer which manages a vector based dataset.
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