43 #include <QToolButton> 45 #include <QHBoxLayout> 49 #include <QPlainTextEdit> 50 #include <QRadioButton> 51 #include <QButtonGroup> 66 QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
72 QString description = parameterDefinition()->description();
74 description = QObject::tr(
"%1 [optional]" ).arg( description );
76 mCheckBox =
new QCheckBox( description );
77 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
79 connect( mCheckBox, &QCheckBox::toggled,
this, [ = ]
81 emit widgetValueHasChanged(
this );
89 mComboBox =
new QComboBox();
90 mComboBox->addItem( tr(
"Yes" ),
true );
91 mComboBox->addItem( tr(
"No" ),
false );
92 mComboBox->setToolTip( parameterDefinition()->toolTip() );
94 connect( mComboBox, qgis::overload< int>::of( &QComboBox::currentIndexChanged ),
this, [ = ]
96 emit widgetValueHasChanged(
this );
105 QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
114 void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
121 mCheckBox->setChecked( v );
129 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
135 QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const 140 return mCheckBox->isChecked();
144 return mComboBox->currentData();
149 QStringList QgsProcessingBooleanWidgetWrapper::compatibleParameterTypes()
const 167 QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes()
const 178 QList<int> QgsProcessingBooleanWidgetWrapper::compatibleDataTypes()
const 180 return QList< int >();
183 QString QgsProcessingBooleanWidgetWrapper::parameterType()
const 190 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
204 QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
207 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
216 emit widgetValueHasChanged(
this );
224 return mProjectionSelectionWidget;
229 QWidget *w =
new QWidget();
230 w->setToolTip( parameterDefinition()->toolTip() );
232 QVBoxLayout *vl =
new QVBoxLayout();
234 vl->setContentsMargins( 0, 0, 0, 0 );
237 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
238 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
239 vl->addWidget( mUseProjectCrsCheckBox );
240 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
241 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [ = ]
243 emit widgetValueHasChanged(
this );
246 vl->addWidget( mProjectionSelectionWidget );
254 void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
256 if ( mUseProjectCrsCheckBox )
258 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
260 mUseProjectCrsCheckBox->setChecked(
true );
265 mUseProjectCrsCheckBox->setChecked(
false );
270 if ( mProjectionSelectionWidget )
271 mProjectionSelectionWidget->setCrs( v );
274 QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const 276 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
277 return QStringLiteral(
"ProjectCrs" );
278 else if ( mProjectionSelectionWidget )
279 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
284 QStringList QgsProcessingCrsWidgetWrapper::compatibleParameterTypes()
const 296 QStringList QgsProcessingCrsWidgetWrapper::compatibleOutputTypes()
const 304 QList<int> QgsProcessingCrsWidgetWrapper::compatibleDataTypes()
const 306 return QList< int >();
309 QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const 311 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
314 QString QgsProcessingCrsWidgetWrapper::parameterType()
const 321 return new QgsProcessingCrsWidgetWrapper( parameter, type );
336 QWidget *QgsProcessingStringWidgetWrapper::createWidget()
343 if ( static_cast< const QgsProcessingParameterString * >( parameterDefinition() )->multiLine() )
345 mPlainTextEdit =
new QPlainTextEdit();
346 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
348 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [ = ]
350 emit widgetValueHasChanged(
this );
352 return mPlainTextEdit;
356 mLineEdit =
new QLineEdit();
357 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
359 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
361 emit widgetValueHasChanged(
this );
369 mLineEdit =
new QLineEdit();
370 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
372 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
374 emit widgetValueHasChanged(
this );
382 void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
386 mLineEdit->setText( v );
387 if ( mPlainTextEdit )
388 mPlainTextEdit->setPlainText( v );
391 QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const 394 return mLineEdit->text();
395 else if ( mPlainTextEdit )
396 return mPlainTextEdit->toPlainText();
401 QStringList QgsProcessingStringWidgetWrapper::compatibleParameterTypes()
const 414 QStringList QgsProcessingStringWidgetWrapper::compatibleOutputTypes()
const 421 QList<int> QgsProcessingStringWidgetWrapper::compatibleDataTypes()
const 423 return QList< int >();
426 QString QgsProcessingStringWidgetWrapper::parameterType()
const 433 return new QgsProcessingStringWidgetWrapper( parameter, type );
448 QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
457 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
461 emit widgetValueHasChanged(
this );
463 return mAuthConfigSelect;
469 void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
472 if ( mAuthConfigSelect )
473 mAuthConfigSelect->setConfigId( v );
476 QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const 478 if ( mAuthConfigSelect )
479 return mAuthConfigSelect->configId();
484 QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleParameterTypes()
const 492 QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleOutputTypes()
const 497 QList<int> QgsProcessingAuthConfigWidgetWrapper::compatibleDataTypes()
const 499 return QList< int >();
502 QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const 509 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
522 QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
525 const QVariantMap metadata = numberDef->
metadata();
526 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
534 QAbstractSpinBox *spinBox =
nullptr;
539 mDoubleSpinBox->setExpressionsEnabled(
true );
540 mDoubleSpinBox->setDecimals( decimals );
546 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
547 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
548 mDoubleSpinBox->setSingleStep( singleStep );
551 spinBox = mDoubleSpinBox;
556 mSpinBox->setExpressionsEnabled(
true );
560 spinBox->setToolTip( parameterDefinition()->toolTip() );
562 double max = 999999999;
567 double min = -999999999;
572 if ( mDoubleSpinBox )
574 mDoubleSpinBox->setMinimum( min );
575 mDoubleSpinBox->setMaximum( max );
579 mSpinBox->setMinimum( static_cast< int >( min ) );
580 mSpinBox->setMaximum( static_cast< int >( max ) );
585 mAllowingNull =
true;
586 if ( mDoubleSpinBox )
588 mDoubleSpinBox->setShowClearButton(
true );
589 const double min = mDoubleSpinBox->minimum() - 1;
590 mDoubleSpinBox->setMinimum( min );
591 mDoubleSpinBox->setValue( min );
595 mSpinBox->setShowClearButton(
true );
596 const int min = mSpinBox->minimum() - 1;
597 mSpinBox->setMinimum( min );
598 mSpinBox->setValue( min );
600 spinBox->setSpecialValueText( tr(
"Not set" ) );
608 if ( mDoubleSpinBox )
610 double defaultVal = numberDef->
defaultValue().toDouble( &ok );
612 mDoubleSpinBox->setClearValue( defaultVal );
618 mSpinBox->setClearValue( intVal );
624 if ( mDoubleSpinBox )
625 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
627 mSpinBox->setClearValue( static_cast< int >( numberDef->
minimum() ) );
632 if ( mDoubleSpinBox )
634 mDoubleSpinBox->setValue( 0 );
635 mDoubleSpinBox->setClearValue( 0 );
639 mSpinBox->setValue( 0 );
640 mSpinBox->setClearValue( 0 );
645 if ( mDoubleSpinBox )
646 connect( mDoubleSpinBox, qgis::overload<double>::of( &QgsDoubleSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
648 connect( mSpinBox, qgis::overload<int>::of( &QgsSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
656 void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
658 if ( mDoubleSpinBox )
660 if ( mAllowingNull && !value.isValid() )
661 mDoubleSpinBox->clear();
665 mDoubleSpinBox->setValue( v );
670 if ( mAllowingNull && !value.isValid() )
675 mSpinBox->setValue( v );
680 QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const 682 if ( mDoubleSpinBox )
684 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
687 return mDoubleSpinBox->value();
691 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
694 return mSpinBox->value();
700 QStringList QgsProcessingNumericWidgetWrapper::compatibleParameterTypes()
const 709 QStringList QgsProcessingNumericWidgetWrapper::compatibleOutputTypes()
const 715 QList<int> QgsProcessingNumericWidgetWrapper::compatibleDataTypes()
const 717 return QList< int >();
720 double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
722 const double valueRange = maximum - minimum;
723 if ( valueRange <= 1.0 )
725 const double step = valueRange / 10.0;
727 return qgsRound( step, -std::floor( std::log( step ) ) );
735 QString QgsProcessingNumericWidgetWrapper::parameterType()
const 742 return new QgsProcessingNumericWidgetWrapper( parameter, type );
750 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
755 QString QgsProcessingDistanceWidgetWrapper::parameterType()
const 762 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
765 QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
769 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
774 mLabel =
new QLabel();
775 mUnitsCombo =
new QComboBox();
783 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().width(
'X' ) ) );
784 QHBoxLayout *layout =
new QHBoxLayout();
785 layout->addWidget( spin, 1 );
786 layout->insertSpacing( 1, labelMargin / 2 );
787 layout->insertWidget( 2, mLabel );
788 layout->insertWidget( 3, mUnitsCombo );
793 mWarningLabel =
new QWidget();
794 QHBoxLayout *warningLayout =
new QHBoxLayout();
795 warningLayout->setMargin( 0 );
796 warningLayout->setContentsMargins( 0, 0, 0, 0 );
797 QLabel *warning =
new QLabel();
799 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
800 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
801 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
802 warningLayout->insertSpacing( 0, labelMargin / 2 );
803 warningLayout->insertWidget( 1, warning );
804 mWarningLabel->setLayout( warningLayout );
805 layout->insertWidget( 4, mWarningLabel );
809 QWidget *w =
new QWidget();
810 layout->setMargin( 0 );
811 layout->setContentsMargins( 0, 0, 0, 0 );
812 w->setLayout( layout );
824 void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
826 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
833 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
835 setUnitParameterValue( wrapper->parameterValue() );
838 setUnitParameterValue( wrapper->parameterValue() );
852 void QgsProcessingDistanceWidgetWrapper::setUnitParameterValue(
const QVariant &value )
858 std::unique_ptr< QgsProcessingContext > tmpContext;
859 if ( mProcessingContextGenerator )
860 context = mProcessingContextGenerator->processingContext();
864 tmpContext = qgis::make_unique< QgsProcessingContext >();
865 context = tmpContext.get();
887 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( units ) );
895 QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const 897 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
898 if ( val.type() == QVariant::Double && mUnitsCombo && mUnitsCombo->isVisible() )
914 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
919 QString QgsProcessingScaleWidgetWrapper::parameterType()
const 926 return new QgsProcessingScaleWidgetWrapper( parameter, type );
929 QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
941 mScaleWidget->setAllowNull(
true );
943 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
944 mScaleWidget->setShowCurrentScaleButton(
true );
946 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
949 emit widgetValueHasChanged(
this );
960 mScaleWidget->setMapCanvas( context.
mapCanvas() );
965 QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const 967 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
970 void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
974 if ( mScaleWidget->allowNull() && !value.isValid() )
975 mScaleWidget->setNull();
979 mScaleWidget->setScale( v );
995 QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
1004 QHBoxLayout *layout =
new QHBoxLayout();
1009 mMinSpinBox->setExpressionsEnabled(
true );
1010 mMinSpinBox->setShowClearButton(
false );
1011 mMaxSpinBox->setExpressionsEnabled(
true );
1012 mMaxSpinBox->setShowClearButton(
false );
1014 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
1015 layout->addWidget( minLabel );
1016 layout->addWidget( mMinSpinBox, 1 );
1018 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
1019 layout->addWidget( maxLabel );
1020 layout->addWidget( mMaxSpinBox, 1 );
1022 QWidget *w =
new QWidget();
1023 layout->setMargin( 0 );
1024 layout->setContentsMargins( 0, 0, 0, 0 );
1025 w->setLayout( layout );
1029 mMinSpinBox->setDecimals( 6 );
1030 mMaxSpinBox->setDecimals( 6 );
1034 mMinSpinBox->setDecimals( 0 );
1035 mMaxSpinBox->setDecimals( 0 );
1038 mMinSpinBox->setMinimum( -99999999.999999 );
1039 mMaxSpinBox->setMinimum( -99999999.999999 );
1040 mMinSpinBox->setMaximum( 99999999.999999 );
1041 mMaxSpinBox->setMaximum( 99999999.999999 );
1043 w->setToolTip( parameterDefinition()->toolTip() );
1045 connect( mMinSpinBox, qgis::overload<double>::of( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1047 mBlockChangedSignal++;
1048 if ( v > mMaxSpinBox->value() )
1049 mMaxSpinBox->setValue( v );
1050 mBlockChangedSignal--;
1052 if ( !mBlockChangedSignal )
1053 emit widgetValueHasChanged(
this );
1055 connect( mMaxSpinBox, qgis::overload<double>::of( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1057 mBlockChangedSignal++;
1058 if ( v < mMinSpinBox->value() )
1059 mMinSpinBox->setValue( v );
1060 mBlockChangedSignal--;
1062 if ( !mBlockChangedSignal )
1063 emit widgetValueHasChanged(
this );
1072 void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1078 mBlockChangedSignal++;
1079 mMinSpinBox->setValue( v.at( 0 ) );
1080 if ( v.count() >= 2 )
1081 mMaxSpinBox->setValue( v.at( 1 ) );
1082 mBlockChangedSignal--;
1084 if ( !mBlockChangedSignal )
1085 emit widgetValueHasChanged(
this );
1088 QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const 1090 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
1093 QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
const 1095 return QStringList()
1100 QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
const 1105 QList<int> QgsProcessingRangeWidgetWrapper::compatibleDataTypes()
const 1107 return QList< int >();
1110 QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const 1112 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
1115 QString QgsProcessingRangeWidgetWrapper::parameterType()
const 1122 return new QgsProcessingRangeWidgetWrapper( parameter, type );
1137 QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
1139 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr, dynamic_cast< const QgsProcessingParameterMatrix *>( parameterDefinition() ) );
1140 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
1142 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [ = ]
1144 emit widgetValueHasChanged(
this );
1153 return mMatrixWidget;
1159 void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1162 if ( mMatrixWidget )
1163 mMatrixWidget->setValue( v );
1166 QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const 1168 if ( mMatrixWidget )
1169 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
1174 QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
const 1176 return QStringList()
1180 QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
const 1182 return QStringList();
1185 QList<int> QgsProcessingMatrixWidgetWrapper::compatibleDataTypes()
const 1187 return QList< int >();
1190 QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const 1192 return tr(
"comma delimited string of values, or an array of values" );
1195 QString QgsProcessingMatrixWidgetWrapper::parameterType()
const 1202 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
1218 QWidget *QgsProcessingFileWidgetWrapper::createWidget()
1228 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
1229 mFileWidget->setDialogTitle( parameterDefinition()->description() );
1231 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
1237 if ( !fileParam->
extension().isEmpty() )
1238 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
1248 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
1249 emit widgetValueHasChanged(
this );
1257 void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1261 mFileWidget->setFilePath( v );
1264 QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const 1267 return mFileWidget->filePath();
1272 QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
const 1274 return QStringList()
1279 QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
const 1288 QList<int> QgsProcessingFileWidgetWrapper::compatibleDataTypes()
const 1290 return QList< int >();
1293 QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const 1295 return tr(
"string representing a path to a file or folder" );
1298 QString QgsProcessingFileWidgetWrapper::parameterType()
const 1305 return new QgsProcessingFileWidgetWrapper( parameter, type );
1321 QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
1333 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
1334 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
1335 mExpLineEdit->registerExpressionContextGenerator(
this );
1338 emit widgetValueHasChanged(
this );
1340 return mExpLineEdit;
1345 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
1346 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
1347 mFieldExpWidget->registerExpressionContextGenerator(
this );
1350 emit widgetValueHasChanged(
this );
1352 return mFieldExpWidget;
1359 void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1369 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterExpression *
>( parameterDefinition() )->parentLayerParameterName() )
1371 setParentLayerWrapperValue( wrapper );
1374 setParentLayerWrapperValue( wrapper );
1391 std::unique_ptr< QgsProcessingContext > tmpContext;
1392 if ( mProcessingContextGenerator )
1393 context = mProcessingContextGenerator->processingContext();
1397 tmpContext = qgis::make_unique< QgsProcessingContext >();
1398 context = tmpContext.get();
1404 if ( mFieldExpWidget )
1405 mFieldExpWidget->setLayer(
nullptr );
1406 else if ( mExpLineEdit )
1407 mExpLineEdit->setLayer(
nullptr );
1413 std::unique_ptr< QgsMapLayer > ownedLayer( context->takeResultLayer( layer->
id() ) );
1416 mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
1417 layer = mParentLayer.get();
1424 if ( mFieldExpWidget )
1425 mFieldExpWidget->setLayer( layer );
1426 else if ( mExpLineEdit )
1427 mExpLineEdit->setLayer( layer );
1430 void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1433 if ( mFieldExpWidget )
1434 mFieldExpWidget->setExpression( v );
1435 else if ( mExpLineEdit )
1436 mExpLineEdit->setExpression( v );
1439 QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const 1441 if ( mFieldExpWidget )
1442 return mFieldExpWidget->expression();
1443 else if ( mExpLineEdit )
1444 return mExpLineEdit->expression();
1449 QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
const 1451 return QStringList()
1459 QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
const 1461 return QStringList()
1466 QList<int> QgsProcessingExpressionWidgetWrapper::compatibleDataTypes()
const 1468 return QList< int >();
1471 QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const 1473 return tr(
"string representation of an expression" );
1476 const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const 1478 if ( mFieldExpWidget && mFieldExpWidget->layer() )
1479 return mFieldExpWidget->layer();
1484 QString QgsProcessingExpressionWidgetWrapper::parameterType()
const 1491 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
1504 QHBoxLayout *hl =
new QHBoxLayout();
1506 hl->setContentsMargins( 0, 0, 0, 0 );
1508 mLineEdit =
new QLineEdit();
1509 mLineEdit->setEnabled(
false );
1510 hl->addWidget( mLineEdit, 1 );
1512 mToolButton =
new QToolButton();
1513 mToolButton->setText( tr(
"…" ) );
1514 hl->addWidget( mToolButton );
1520 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
1523 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
1526 void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
1528 if ( value.isValid() )
1529 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
1533 updateSummaryText();
1537 void QgsProcessingEnumPanelWidget::showDialog()
1539 QVariantList availableOptions;
1542 availableOptions.reserve( mParam->options().size() );
1543 for (
int i = 0; i < mParam->options().count(); ++i )
1544 availableOptions << i;
1547 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this,
nullptr );
1548 const QStringList options = mParam ? mParam->options() : QStringList();
1549 dlg.setValueFormatter( [options](
const QVariant & v ) -> QString
1551 const int i = v.toInt();
1552 return options.size() > i ? options.at( i ) : QString();
1556 setValue( dlg.selectedOptions() );
1560 void QgsProcessingEnumPanelWidget::updateSummaryText()
1563 mLineEdit->setText( tr(
"%1 options selected" ).arg( mValue.count() ) );
1570 QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
1573 , mButtonGroup( new QButtonGroup( this ) )
1574 , mColumns( columns )
1576 mButtonGroup->setExclusive( !mParam->allowMultiple() );
1578 QGridLayout *l =
new QGridLayout();
1579 l->setContentsMargins( 0, 0, 0, 0 );
1582 int rows =
static_cast< int >( std::ceil( mParam->options().count() /
static_cast< double >( mColumns ) ) );
1583 for (
int i = 0; i < mParam->options().count(); ++i )
1585 QAbstractButton *button =
nullptr;
1586 if ( mParam->allowMultiple() )
1587 button =
new QCheckBox( mParam->options().at( i ) );
1589 button =
new QRadioButton( mParam->options().at( i ) );
1591 connect( button, &QAbstractButton::toggled,
this, [ = ]
1593 if ( !mBlockChangedSignal )
1597 mButtons.insert( i, button );
1598 mButtonGroup->addButton( button, i );
1599 l->addWidget( button, i % rows, i / rows );
1601 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
1604 if ( mParam->allowMultiple() )
1606 setContextMenuPolicy( Qt::CustomContextMenu );
1607 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
1611 QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const 1613 if ( mParam->allowMultiple() )
1616 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
1618 if ( it.value()->isChecked() )
1619 value.append( it.key() );
1625 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
1629 void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
1631 mBlockChangedSignal =
true;
1632 if ( mParam->allowMultiple() )
1634 QVariantList selected;
1635 if ( value.isValid() )
1636 selected = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
1637 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
1639 it.value()->setChecked( selected.contains( it.key() ) );
1645 if ( v.type() == QVariant::List )
1646 v = v.toList().value( 0 );
1647 if ( mButtons.contains( v ) )
1648 mButtons.value( v )->setChecked(
true );
1650 mBlockChangedSignal =
false;
1654 void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
1657 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
1658 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
1659 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
1660 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
1661 popupMenu.addAction( selectAllAction );
1662 popupMenu.addAction( clearAllAction );
1663 popupMenu.exec( QCursor::pos() );
1666 void QgsProcessingEnumCheckboxPanelWidget::selectAll()
1668 mBlockChangedSignal =
true;
1669 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
1670 it.value()->setChecked(
true );
1671 mBlockChangedSignal =
false;
1675 void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
1677 mBlockChangedSignal =
true;
1678 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
1679 it.value()->setChecked(
false );
1680 mBlockChangedSignal =
false;
1695 QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
1703 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
1705 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
1706 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
1707 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
1708 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [ = ]
1710 emit widgetValueHasChanged(
this );
1712 return mCheckboxPanel;
1721 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
1722 mPanel->setToolTip( parameterDefinition()->toolTip() );
1723 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [ = ]
1725 emit widgetValueHasChanged(
this );
1731 mComboBox =
new QComboBox();
1734 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
1735 const QStringList options = expParam->
options();
1736 for (
int i = 0; i < options.count(); ++i )
1737 mComboBox->addItem( options.at( i ), i );
1739 mComboBox->setToolTip( parameterDefinition()->toolTip() );
1740 connect( mComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
1742 emit widgetValueHasChanged(
this );
1751 void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1755 if ( !value.isValid() )
1756 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
1760 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
1763 else if ( mPanel || mCheckboxPanel )
1766 if ( value.isValid() )
1769 opts.reserve( v.size() );
1774 mPanel->setValue( opts );
1775 else if ( mCheckboxPanel )
1776 mCheckboxPanel->setValue( opts );
1780 QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const 1783 return mComboBox->currentData();
1785 return mPanel->value();
1786 else if ( mCheckboxPanel )
1787 return mCheckboxPanel->value();
1792 QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
const 1794 return QStringList()
1800 QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
const 1802 return QStringList()
1807 QList<int> QgsProcessingEnumWidgetWrapper::compatibleDataTypes()
const 1809 return QList<int>();
1812 QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const 1814 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
1817 QString QgsProcessingEnumWidgetWrapper::parameterType()
const 1824 return new QgsProcessingEnumWidgetWrapper( parameter, type );
1839 QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
1848 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() :
nullptr );
1850 mComboBox->setAllowEmptyLayout(
true );
1853 mComboBox->setToolTip( parameterDefinition()->toolTip() );
1856 emit widgetValueHasChanged(
this );
1863 mLineEdit =
new QLineEdit();
1864 mLineEdit->setToolTip( tr(
"Name of an existing print layout" ) );
1865 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
1867 emit widgetValueHasChanged(
this );
1875 void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1879 if ( !value.isValid() )
1880 mComboBox->setCurrentLayout(
nullptr );
1884 mComboBox->setCurrentLayout( l );
1886 mComboBox->setCurrentLayout(
nullptr );
1889 else if ( mLineEdit )
1892 mLineEdit->setText( v );
1896 QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const 1901 return l ? l->
name() : QVariant();
1903 else if ( mLineEdit )
1904 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
1909 QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
const 1911 return QStringList()
1916 QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
const 1918 return QStringList()
1922 QList<int> QgsProcessingLayoutWidgetWrapper::compatibleDataTypes()
const 1924 return QList<int>();
1927 QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const 1929 return tr(
"string representing the name of an existing print layout" );
1932 QString QgsProcessingLayoutWidgetWrapper::parameterType()
const 1939 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
1955 QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
1966 mComboBox->setAllowEmptyItem(
true );
1967 if ( layoutParam->
itemType() >= 0 )
1968 mComboBox->setItemType( static_cast< QgsLayoutItemRegistry::ItemType >( layoutParam->
itemType() ) );
1970 mComboBox->setToolTip( parameterDefinition()->toolTip() );
1973 emit widgetValueHasChanged(
this );
1980 mLineEdit =
new QLineEdit();
1981 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
1982 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
1984 emit widgetValueHasChanged(
this );
1992 void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2001 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterLayoutItem *
>( parameterDefinition() )->parentLayoutParameterName() )
2003 setLayoutParameterValue( wrapper->parameterValue() );
2006 setLayoutParameterValue( wrapper->parameterValue() );
2019 void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
2025 std::unique_ptr< QgsProcessingContext > tmpContext;
2026 if ( mProcessingContextGenerator )
2027 context = mProcessingContextGenerator->processingContext();
2031 tmpContext = qgis::make_unique< QgsProcessingContext >();
2032 context = tmpContext.get();
2036 setLayout( layout );
2039 void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
2042 mComboBox->setCurrentLayout( layout );
2045 void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2049 if ( !value.isValid() )
2050 mComboBox->setItem(
nullptr );
2054 mComboBox->setItem( item );
2057 else if ( mLineEdit )
2060 mLineEdit->setText( v );
2064 QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const 2069 return i ? i->
uuid() : QVariant();
2071 else if ( mLineEdit )
2072 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
2077 QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
const 2079 return QStringList()
2084 QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
const 2086 return QStringList()
2090 QList<int> QgsProcessingLayoutItemWidgetWrapper::compatibleDataTypes()
const 2092 return QList<int>();
2095 QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const 2097 return tr(
"string representing the UUID or ID of an existing print layout item" );
2100 QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const 2107 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
2114 QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
2121 QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
2123 void QgsProcessingPointMapTool::deactivate()
2137 if ( e->button() == Qt::LeftButton )
2140 emit clicked( point );
2145 void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
2147 if ( e->key() == Qt::Key_Escape )
2162 QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
2165 QHBoxLayout *l =
new QHBoxLayout();
2166 l->setContentsMargins( 0, 0, 0, 0 );
2169 mLineEdit->setShowClearButton(
false );
2170 l->addWidget( mLineEdit, 1 );
2171 mButton =
new QToolButton();
2172 mButton->setText( QStringLiteral(
"…" ) );
2173 l->addWidget( mButton );
2176 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
2177 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
2178 mButton->setVisible(
false );
2181 void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
2184 mButton->setVisible(
true );
2187 mTool = qgis::make_unique< QgsProcessingPointMapTool >( mCanvas );
2188 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
2189 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
2192 void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
2194 mLineEdit->setShowClearButton( allowNull );
2197 QVariant QgsProcessingPointPanel::value()
const 2199 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
2202 void QgsProcessingPointPanel::clear()
2209 QString newText = QStringLiteral(
"%1,%2" )
2210 .arg( QString::number( point.
x(),
'f' ) )
2211 .arg( QString::number( point.
y(),
'f' ) );
2214 if ( mCrs.isValid() )
2216 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
2218 mLineEdit->setText( newText );
2221 void QgsProcessingPointPanel::selectOnCanvas()
2226 mPrevTool = mCanvas->mapTool();
2227 mCanvas->setMapTool( mTool.get() );
2229 emit toggleDialogVisibility(
false );
2232 void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
2234 setValue( point, mCanvas->mapSettings().destinationCrs() );
2237 void QgsProcessingPointPanel::pointPicked()
2242 mCanvas->setMapTool( mPrevTool );
2244 emit toggleDialogVisibility(
true );
2260 QWidget *QgsProcessingPointWidgetWrapper::createWidget()
2268 mPanel =
new QgsProcessingPointPanel(
nullptr );
2269 if ( widgetContext().mapCanvas() )
2270 mPanel->setMapCanvas( widgetContext().mapCanvas() );
2273 mPanel->setAllowNull(
true );
2275 mPanel->setToolTip( parameterDefinition()->toolTip() );
2277 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [ = ]
2279 emit widgetValueHasChanged(
this );
2283 setDialog( mDialog );
2289 mLineEdit =
new QLineEdit();
2290 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
2291 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
2293 emit widgetValueHasChanged(
this );
2305 mPanel->setMapCanvas( context.
mapCanvas() );
2308 void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
2313 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ](
bool visible )
2316 mDialog->showMinimized();
2319 mDialog->showNormal();
2321 mDialog->activateWindow();
2328 void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2332 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
2338 mPanel->setValue( p, crs );
2341 else if ( mLineEdit )
2344 mLineEdit->setText( v );
2348 QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const 2352 return mPanel->value();
2354 else if ( mLineEdit )
2355 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
2360 QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
const 2362 return QStringList()
2367 QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
const 2369 return QStringList()
2373 QList<int> QgsProcessingPointWidgetWrapper::compatibleDataTypes()
const 2375 return QList<int>();
2378 QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const 2380 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
2383 QString QgsProcessingPointWidgetWrapper::parameterType()
const 2390 return new QgsProcessingPointWidgetWrapper( parameter, type );
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static QString typeName()
Returns the type name for the parameter class.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
Base class for graphical items within a QgsLayout.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
static QString typeName()
Returns the type name for the output class.
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
This class is a composition of two QSettings instances:
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
static QString typeName()
Returns the type name for the parameter class.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
A print layout parameter, allowing users to select a print layout.
WidgetType
Types of dialogs which Processing widgets can be created for.
A class to represent a 2D point.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
An expression 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.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
static QString typeName()
Returns the type name for the parameter class.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
double minimum() const
Returns the minimum value acceptable by the parameter.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QgsUnitTypes::DistanceUnit mapUnits
QgsUnitTypes::DistanceUnit defaultUnit() const
Returns the default distance 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.
const QgsCoordinateReferenceSystem & crs
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the output class.
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
static QString typeName()
Returns the type name for the parameter class.
A numeric range parameter for processing algorithms.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
The QgsLayoutItemComboBox class is a combo box which displays items of a matching type from a layout...
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value. ...
static QString typeName()
Returns the type name for the parameter class.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
An enum based parameter for processing algorithms, allowing for selection from predefined values...
Flags flags() const
Returns any flags associated with the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariant defaultValue() const
Returns the default value for the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the output class.
Parameter is a single file.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
Degrees, for planar geographic CRS distance measurements.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
static QString typeName()
Returns the type name for the output class.
QStringList options() const
Returns the list of acceptable options for the parameter.
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 output class.
A numeric parameter for processing algorithms.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
Behavior behavior() const
Returns the parameter behavior (e.g.
DistanceUnit
Units of distance.
static Q_INVOKABLE DistanceUnitType unitType(QgsUnitTypes::DistanceUnit unit)
Returns the type for a distance unit.
QString extension() const
Returns any specified file extension for the parameter.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing.
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
static QString typeName()
Returns the type name for the parameter class.
A point parameter for processing algorithms.
Contains settings which reflect the context in which a Processing parameter widget is shown...
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to 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...
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places...
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
virtual QString uuid() const
Returns the item identification string.
This class represents a coordinate reference system (CRS).
Base class for the definition of processing parameters.
Class that shows snapping marker on map canvas for the current snapping match.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
virtual QString name() const =0
Returns the layout's name.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
Type dataType() const
Returns the acceptable data type for the parameter.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Interface for master layout type objects, such as print layouts and reports.
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
Represents a vector layer which manages a vector based data sets.
Contains information about the context in which a processing algorithm is executed.
The QgsLayoutComboBox class is a combo box which displays available layouts from a QgsLayoutManager...
static QString typeName()
Returns the type name for the output class.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
Unit is a standard measurement unit.
double maximum() const
Returns the maximum value acceptable by the parameter.
Selector widget for authentication configs.
static QString typeName()
Returns the type name for the parameter class.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Standard algorithm dialog.