76#include <QButtonGroup>
84#include <QPlainTextEdit>
85#include <QRadioButton>
89#include "moc_qgsprocessingwidgetwrapperimpl.cpp"
101 QVBoxLayout *vlayout =
new QVBoxLayout();
102 vlayout->setContentsMargins( 0, 0, 0, 0 );
104 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
108 mDefaultCheckBox->setChecked(
false );
109 vlayout->addWidget( mDefaultCheckBox );
110 setLayout( vlayout );
115 auto param = std::make_unique<QgsProcessingParameterBoolean>( name, description, mDefaultCheckBox->isChecked() );
116 param->setFlags( flags );
117 return param.release();
126QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
132 QString description = parameterDefinition()->description();
134 description = QObject::tr(
"%1 [optional]" ).arg( description );
136 mCheckBox =
new QCheckBox( description );
137 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
139 connect( mCheckBox, &QCheckBox::toggled,
this, [
this] {
140 emit widgetValueHasChanged(
this );
148 mComboBox =
new QComboBox();
149 mComboBox->addItem( tr(
"Yes" ),
true );
150 mComboBox->addItem( tr(
"No" ),
false );
151 mComboBox->setToolTip( parameterDefinition()->toolTip() );
153 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
154 emit widgetValueHasChanged(
this );
163QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
172void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
179 mCheckBox->setChecked( v );
187 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
193QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
198 return mCheckBox->isChecked();
202 return mComboBox->currentData();
207QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
214 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
219 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
230 QVBoxLayout *vlayout =
new QVBoxLayout();
231 vlayout->setContentsMargins( 0, 0, 0, 0 );
233 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
238 mCrsSelector->setShowAccuracyWarnings(
true );
245 vlayout->addWidget( mCrsSelector );
246 setLayout( vlayout );
251 auto param = std::make_unique<QgsProcessingParameterCrs>( name, description, mCrsSelector->crs().authid() );
252 param->setFlags( flags );
253 return param.release();
261QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
263 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
265 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
273 emit widgetValueHasChanged(
this );
281 return mProjectionSelectionWidget;
286 QWidget *w =
new QWidget();
287 w->setToolTip( parameterDefinition()->toolTip() );
289 QVBoxLayout *vl =
new QVBoxLayout();
290 vl->setContentsMargins( 0, 0, 0, 0 );
293 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
294 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
295 vl->addWidget( mUseProjectCrsCheckBox );
296 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
297 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [
this] {
298 emit widgetValueHasChanged(
this );
301 vl->addWidget( mProjectionSelectionWidget );
309void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
311 if ( mUseProjectCrsCheckBox )
313 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
315 mUseProjectCrsCheckBox->setChecked(
true );
320 mUseProjectCrsCheckBox->setChecked(
false );
325 if ( mProjectionSelectionWidget )
326 mProjectionSelectionWidget->setCrs( v );
329QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
331 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
332 return QStringLiteral(
"ProjectCrs" );
333 else if ( mProjectionSelectionWidget )
334 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
339QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
341 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
344QString QgsProcessingCrsWidgetWrapper::parameterType()
const
351 return new QgsProcessingCrsWidgetWrapper( parameter, type );
356 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
368 QVBoxLayout *vlayout =
new QVBoxLayout();
369 vlayout->setContentsMargins( 0, 0, 0, 0 );
371 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
373 mDefaultLineEdit =
new QLineEdit();
376 vlayout->addWidget( mDefaultLineEdit );
378 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
380 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
381 vlayout->addWidget( mMultiLineCheckBox );
383 setLayout( vlayout );
388 auto param = std::make_unique<QgsProcessingParameterString>( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
389 param->setFlags( flags );
390 return param.release();
399QWidget *QgsProcessingStringWidgetWrapper::createWidget()
401 const QVariantMap metadata = parameterDefinition()->metadata();
402 const QVariant valueHintsVariant = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"value_hints" ) );
404 if ( valueHintsVariant.isValid() )
406 const QVariantList valueList = valueHintsVariant.toList();
407 mComboBox =
new QComboBox();
408 mComboBox->setToolTip( parameterDefinition()->toolTip() );
412 mComboBox->addItem( QString() );
414 for (
const QVariant &entry : valueList )
416 mComboBox->addItem( entry.toString(), entry.toString() );
418 mComboBox->setCurrentIndex( 0 );
420 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
421 emit widgetValueHasChanged(
this );
434 mPlainTextEdit =
new QPlainTextEdit();
435 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
437 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [
this] {
438 emit widgetValueHasChanged(
this );
440 return mPlainTextEdit;
444 mLineEdit =
new QLineEdit();
445 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
447 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
448 emit widgetValueHasChanged(
this );
456 mLineEdit =
new QLineEdit();
457 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
459 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
460 emit widgetValueHasChanged(
this );
470void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
474 mLineEdit->setText( v );
475 if ( mPlainTextEdit )
476 mPlainTextEdit->setPlainText( v );
480 if ( !value.isValid() )
481 index = mComboBox->findData( QVariant() );
483 index = mComboBox->findData( v );
486 mComboBox->setCurrentIndex( index );
488 mComboBox->setCurrentIndex( 0 );
492QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
495 return mLineEdit->text();
496 else if ( mPlainTextEdit )
497 return mPlainTextEdit->toPlainText();
498 else if ( mComboBox )
499 return mComboBox->currentData();
504QString QgsProcessingStringWidgetWrapper::parameterType()
const
511 return new QgsProcessingStringWidgetWrapper( parameter, type );
516 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
529QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
538 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
541 emit widgetValueHasChanged(
this );
543 return mAuthConfigSelect;
549void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
552 if ( mAuthConfigSelect )
553 mAuthConfigSelect->setConfigId( v );
556QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
558 if ( mAuthConfigSelect )
559 return mAuthConfigSelect->configId();
564QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
571 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
581 QVBoxLayout *vlayout =
new QVBoxLayout();
582 vlayout->setContentsMargins( 0, 0, 0, 0 );
584 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
586 mTypeComboBox =
new QComboBox();
589 vlayout->addWidget( mTypeComboBox );
591 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
592 mMinLineEdit =
new QLineEdit();
593 vlayout->addWidget( mMinLineEdit );
595 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
596 mMaxLineEdit =
new QLineEdit();
597 vlayout->addWidget( mMaxLineEdit );
599 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
600 mDefaultLineEdit =
new QLineEdit();
601 vlayout->addWidget( mDefaultLineEdit );
605 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( numberParam->dataType() ) ) );
607 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
609 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
613 mMaxLineEdit->clear();
616 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
618 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
622 mMinLineEdit->clear();
625 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
628 setLayout( vlayout );
637 auto param = std::make_unique<QgsProcessingParameterNumber>( name, description, dataType, ok ? val : QVariant() );
639 if ( !mMinLineEdit->text().trimmed().isEmpty() )
644 param->setMinimum( val );
648 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
653 param->setMaximum( val );
657 param->setFlags( flags );
658 return param.release();
666QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
669 const QVariantMap metadata = numberDef->
metadata();
670 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
678 QAbstractSpinBox *spinBox =
nullptr;
683 mDoubleSpinBox->setExpressionsEnabled(
true );
684 mDoubleSpinBox->setDecimals( decimals );
689 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
690 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
691 mDoubleSpinBox->setSingleStep( singleStep );
694 spinBox = mDoubleSpinBox;
699 mSpinBox->setExpressionsEnabled(
true );
703 spinBox->setToolTip( parameterDefinition()->toolTip() );
705 double max = 999999999;
710 double min = -999999999;
715 if ( mDoubleSpinBox )
717 mDoubleSpinBox->setMinimum( min );
718 mDoubleSpinBox->setMaximum( max );
722 mSpinBox->setMinimum(
static_cast<int>( min ) );
723 mSpinBox->setMaximum(
static_cast<int>( max ) );
728 mAllowingNull =
true;
729 if ( mDoubleSpinBox )
731 mDoubleSpinBox->setShowClearButton(
true );
732 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
733 mDoubleSpinBox->setMinimum( min );
734 mDoubleSpinBox->setValue( min );
738 mSpinBox->setShowClearButton(
true );
739 const int min = mSpinBox->minimum() - 1;
740 mSpinBox->setMinimum( min );
741 mSpinBox->setValue( min );
743 spinBox->setSpecialValueText( tr(
"Not set" ) );
751 if ( mDoubleSpinBox )
755 mDoubleSpinBox->setClearValue( defaultVal );
761 mSpinBox->setClearValue( intVal );
767 if ( mDoubleSpinBox )
768 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
770 mSpinBox->setClearValue(
static_cast<int>( numberDef->
minimum() ) );
775 if ( mDoubleSpinBox )
777 mDoubleSpinBox->setValue( 0 );
778 mDoubleSpinBox->setClearValue( 0 );
782 mSpinBox->setValue( 0 );
783 mSpinBox->setClearValue( 0 );
788 if ( mDoubleSpinBox )
789 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
791 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
799void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
801 if ( mDoubleSpinBox )
803 if ( mAllowingNull && !value.isValid() )
804 mDoubleSpinBox->clear();
808 mDoubleSpinBox->setValue( v );
813 if ( mAllowingNull && !value.isValid() )
818 mSpinBox->setValue( v );
823QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
825 if ( mDoubleSpinBox )
827 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
830 return mDoubleSpinBox->value();
834 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
837 return mSpinBox->value();
843double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
845 const double valueRange = maximum - minimum;
846 if ( valueRange <= 1.0 )
848 const double step = valueRange / 10.0;
850 return qgsRound( step, -std::floor( std::log( step ) ) );
858QString QgsProcessingNumericWidgetWrapper::parameterType()
const
865 return new QgsProcessingNumericWidgetWrapper( parameter, type );
870 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
880 QVBoxLayout *vlayout =
new QVBoxLayout();
881 vlayout->setContentsMargins( 0, 0, 0, 0 );
883 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
885 mParentLayerComboBox =
new QComboBox();
887 QString initialParent;
889 initialParent = distParam->parentParameterName();
891 if (
auto *lModel = widgetContext.
model() )
894 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
895 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
899 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
900 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
902 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
907 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
908 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
910 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
915 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
916 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
918 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
923 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
924 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
926 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
932 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
935 mParentLayerComboBox->addItem( initialParent, initialParent );
936 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
939 vlayout->addWidget( mParentLayerComboBox );
941 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
942 mMinLineEdit =
new QLineEdit();
943 vlayout->addWidget( mMinLineEdit );
945 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
946 mMaxLineEdit =
new QLineEdit();
947 vlayout->addWidget( mMaxLineEdit );
949 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
950 mDefaultLineEdit =
new QLineEdit();
951 vlayout->addWidget( mDefaultLineEdit );
955 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
956 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
957 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
960 setLayout( vlayout );
968 auto param = std::make_unique<QgsProcessingParameterDistance>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
973 param->setMinimum( val );
979 param->setMaximum( val );
982 param->setFlags( flags );
983 return param.release();
987 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
991QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
998 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
1001QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1005 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1010 mLabel =
new QLabel();
1011 mUnitsCombo =
new QComboBox();
1023 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1024 QHBoxLayout *layout =
new QHBoxLayout();
1025 layout->addWidget( spin, 1 );
1026 layout->insertSpacing( 1, labelMargin / 2 );
1027 layout->insertWidget( 2, mLabel );
1028 layout->insertWidget( 3, mUnitsCombo );
1033 mWarningLabel =
new QWidget();
1034 QHBoxLayout *warningLayout =
new QHBoxLayout();
1035 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1036 QLabel *warning =
new QLabel();
1038 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1039 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1040 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1041 warningLayout->insertSpacing( 0, labelMargin / 2 );
1042 warningLayout->insertWidget( 1, warning );
1043 mWarningLabel->setLayout( warningLayout );
1044 layout->insertWidget( 4, mWarningLabel );
1046 QWidget *w =
new QWidget();
1047 layout->setContentsMargins( 0, 0, 0, 0 );
1048 w->setLayout( layout );
1062void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1064 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1071 if ( wrapper->parameterDefinition()->name() ==
static_cast<const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1073 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1075 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1095 std::unique_ptr<QgsProcessingContext> tmpContext;
1096 if ( mProcessingContextGenerator )
1097 context = mProcessingContextGenerator->processingContext();
1101 tmpContext = std::make_unique<QgsProcessingContext>();
1102 context = tmpContext.get();
1110 units = crs.mapUnits();
1121 mUnitsCombo->hide();
1129 if ( mBaseUnit != units )
1131 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( units ) ) );
1134 mUnitsCombo->show();
1141QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1143 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1144 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1157 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1168 QVBoxLayout *vlayout =
new QVBoxLayout();
1169 vlayout->setContentsMargins( 0, 0, 0, 0 );
1171 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1173 mParentLayerComboBox =
new QComboBox();
1175 QString initialParent;
1177 initialParent = areaParam->parentParameterName();
1179 if (
auto *lModel = widgetContext.
model() )
1182 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1183 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1187 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1188 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1190 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1195 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1196 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1198 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1203 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1204 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1206 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1211 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1212 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1214 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1220 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1223 mParentLayerComboBox->addItem( initialParent, initialParent );
1224 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1227 vlayout->addWidget( mParentLayerComboBox );
1229 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1230 mMinLineEdit =
new QLineEdit();
1231 vlayout->addWidget( mMinLineEdit );
1233 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1234 mMaxLineEdit =
new QLineEdit();
1235 vlayout->addWidget( mMaxLineEdit );
1237 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1238 mDefaultLineEdit =
new QLineEdit();
1239 vlayout->addWidget( mDefaultLineEdit );
1243 mMinLineEdit->setText( QLocale().toString( areaParam->minimum() ) );
1244 mMaxLineEdit->setText( QLocale().toString( areaParam->maximum() ) );
1245 mDefaultLineEdit->setText( areaParam->defaultValueForGui().toString() );
1248 setLayout( vlayout );
1256 auto param = std::make_unique<QgsProcessingParameterArea>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1261 param->setMinimum( val );
1267 param->setMaximum( val );
1270 param->setFlags( flags );
1271 return param.release();
1280 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1284QString QgsProcessingAreaWidgetWrapper::parameterType()
const
1291 return new QgsProcessingAreaWidgetWrapper( parameter, type );
1294QWidget *QgsProcessingAreaWidgetWrapper::createWidget()
1298 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1303 mLabel =
new QLabel();
1304 mUnitsCombo =
new QComboBox();
1319 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1320 QHBoxLayout *layout =
new QHBoxLayout();
1321 layout->addWidget( spin, 1 );
1322 layout->insertSpacing( 1, labelMargin / 2 );
1323 layout->insertWidget( 2, mLabel );
1324 layout->insertWidget( 3, mUnitsCombo );
1329 mWarningLabel =
new QWidget();
1330 QHBoxLayout *warningLayout =
new QHBoxLayout();
1331 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1332 QLabel *warning =
new QLabel();
1334 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1335 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1336 warning->setToolTip( tr(
"Area is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1337 warningLayout->insertSpacing( 0, labelMargin / 2 );
1338 warningLayout->insertWidget( 1, warning );
1339 mWarningLabel->setLayout( warningLayout );
1340 layout->insertWidget( 4, mWarningLabel );
1342 QWidget *w =
new QWidget();
1343 layout->setContentsMargins( 0, 0, 0, 0 );
1344 w->setLayout( layout );
1358void QgsProcessingAreaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1360 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1391 std::unique_ptr<QgsProcessingContext> tmpContext;
1392 if ( mProcessingContextGenerator )
1393 context = mProcessingContextGenerator->processingContext();
1397 tmpContext = std::make_unique<QgsProcessingContext>();
1398 context = tmpContext.get();
1406 units = QgsUnitTypes::distanceToAreaUnit( crs.mapUnits() );
1412void QgsProcessingAreaWidgetWrapper::setUnits(
Qgis::AreaUnit units )
1417 mUnitsCombo->hide();
1422 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1423 mUnitsCombo->show();
1430QVariant QgsProcessingAreaWidgetWrapper::widgetValue()
const
1432 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1433 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1446 return new QgsProcessingAreaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1457 QVBoxLayout *vlayout =
new QVBoxLayout();
1458 vlayout->setContentsMargins( 0, 0, 0, 0 );
1460 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1462 mParentLayerComboBox =
new QComboBox();
1464 QString initialParent;
1466 initialParent = volumeParam->parentParameterName();
1468 if (
auto *lModel = widgetContext.
model() )
1471 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1472 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1476 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1477 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1479 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1484 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1485 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1487 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1492 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1493 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1495 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1500 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1501 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1503 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1509 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1512 mParentLayerComboBox->addItem( initialParent, initialParent );
1513 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1516 vlayout->addWidget( mParentLayerComboBox );
1518 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1519 mMinLineEdit =
new QLineEdit();
1520 vlayout->addWidget( mMinLineEdit );
1522 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1523 mMaxLineEdit =
new QLineEdit();
1524 vlayout->addWidget( mMaxLineEdit );
1526 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1527 mDefaultLineEdit =
new QLineEdit();
1528 vlayout->addWidget( mDefaultLineEdit );
1532 mMinLineEdit->setText( QLocale().toString( volumeParam->minimum() ) );
1533 mMaxLineEdit->setText( QLocale().toString( volumeParam->maximum() ) );
1534 mDefaultLineEdit->setText( volumeParam->defaultValueForGui().toString() );
1537 setLayout( vlayout );
1545 auto param = std::make_unique<QgsProcessingParameterVolume>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1550 param->setMinimum( val );
1556 param->setMaximum( val );
1559 param->setFlags( flags );
1560 return param.release();
1569 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1573QString QgsProcessingVolumeWidgetWrapper::parameterType()
const
1580 return new QgsProcessingVolumeWidgetWrapper( parameter, type );
1583QWidget *QgsProcessingVolumeWidgetWrapper::createWidget()
1587 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1592 mLabel =
new QLabel();
1593 mUnitsCombo =
new QComboBox();
1606 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1607 QHBoxLayout *layout =
new QHBoxLayout();
1608 layout->addWidget( spin, 1 );
1609 layout->insertSpacing( 1, labelMargin / 2 );
1610 layout->insertWidget( 2, mLabel );
1611 layout->insertWidget( 3, mUnitsCombo );
1616 mWarningLabel =
new QWidget();
1617 QHBoxLayout *warningLayout =
new QHBoxLayout();
1618 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1619 QLabel *warning =
new QLabel();
1621 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1622 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1623 warning->setToolTip( tr(
"Volume is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1624 warningLayout->insertSpacing( 0, labelMargin / 2 );
1625 warningLayout->insertWidget( 1, warning );
1626 mWarningLabel->setLayout( warningLayout );
1627 layout->insertWidget( 4, mWarningLabel );
1629 QWidget *w =
new QWidget();
1630 layout->setContentsMargins( 0, 0, 0, 0 );
1631 w->setLayout( layout );
1645void QgsProcessingVolumeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1647 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1678 std::unique_ptr<QgsProcessingContext> tmpContext;
1679 if ( mProcessingContextGenerator )
1680 context = mProcessingContextGenerator->processingContext();
1684 tmpContext = std::make_unique<QgsProcessingContext>();
1685 context = tmpContext.get();
1693 units = QgsUnitTypes::distanceToVolumeUnit( crs.mapUnits() );
1704 mUnitsCombo->hide();
1709 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1710 mUnitsCombo->show();
1717QVariant QgsProcessingVolumeWidgetWrapper::widgetValue()
const
1719 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1720 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1733 return new QgsProcessingVolumeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1744 QVBoxLayout *vlayout =
new QVBoxLayout();
1745 vlayout->setContentsMargins( 0, 0, 0, 0 );
1747 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1748 mMinLineEdit =
new QLineEdit();
1749 vlayout->addWidget( mMinLineEdit );
1751 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1752 mMaxLineEdit =
new QLineEdit();
1753 vlayout->addWidget( mMaxLineEdit );
1755 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1756 mDefaultLineEdit =
new QLineEdit();
1757 vlayout->addWidget( mDefaultLineEdit );
1759 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1761 mUnitsCombo =
new QComboBox();
1771 vlayout->addWidget( mUnitsCombo );
1775 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1776 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1777 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1778 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationParam->defaultUnit() ) ) );
1781 setLayout( vlayout );
1789 auto param = std::make_unique<QgsProcessingParameterDuration>( name, description, ok ? val : QVariant() );
1794 param->setMinimum( val );
1800 param->setMaximum( val );
1803 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit>( mUnitsCombo->currentData().toInt() ) );
1805 param->setFlags( flags );
1806 return param.release();
1810 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1814QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1821 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1824QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1828 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1833 mUnitsCombo =
new QComboBox();
1845 QHBoxLayout *layout =
new QHBoxLayout();
1846 layout->addWidget( spin, 1 );
1847 layout->insertWidget( 1, mUnitsCombo );
1849 QWidget *w =
new QWidget();
1850 layout->setContentsMargins( 0, 0, 0, 0 );
1851 w->setLayout( layout );
1853 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationDef->
defaultUnit() ) ) );
1854 mUnitsCombo->show();
1866QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
1878QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
1880 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1881 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo )
1892void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1898 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
1902 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
1908 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1918 QVBoxLayout *vlayout =
new QVBoxLayout();
1919 vlayout->setContentsMargins( 0, 0, 0, 0 );
1921 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1923 mDefaultLineEdit =
new QLineEdit();
1927 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1930 vlayout->addWidget( mDefaultLineEdit );
1932 setLayout( vlayout );
1938 double val = mDefaultLineEdit->text().toDouble( &ok );
1939 auto param = std::make_unique<QgsProcessingParameterScale>( name, description, ok ? val : QVariant() );
1940 param->setFlags( flags );
1941 return param.release();
1945 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1949QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1956 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1959QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
1971 mScaleWidget->setAllowNull(
true );
1973 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
1974 mScaleWidget->setShowCurrentScaleButton(
true );
1976 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
1978 emit widgetValueHasChanged(
this );
1980 return mScaleWidget;
1989 mScaleWidget->setMapCanvas( context.
mapCanvas() );
1994QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
1996 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
1999void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2003 if ( mScaleWidget->allowNull() && !value.isValid() )
2004 mScaleWidget->setNull();
2008 mScaleWidget->setScale( v );
2015 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2026 QVBoxLayout *vlayout =
new QVBoxLayout();
2027 vlayout->setContentsMargins( 0, 0, 0, 0 );
2029 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
2031 mTypeComboBox =
new QComboBox();
2034 vlayout->addWidget( mTypeComboBox );
2036 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
2037 mMinLineEdit =
new QLineEdit();
2038 vlayout->addWidget( mMinLineEdit );
2040 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
2041 mMaxLineEdit =
new QLineEdit();
2042 vlayout->addWidget( mMaxLineEdit );
2046 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( rangeParam->dataType() ) ) );
2048 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
2049 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
2052 setLayout( vlayout );
2057 QString defaultValue;
2058 if ( mMinLineEdit->text().isEmpty() )
2060 defaultValue = QStringLiteral(
"None" );
2068 defaultValue = QStringLiteral(
"None" );
2072 if ( mMaxLineEdit->text().isEmpty() )
2074 defaultValue += QLatin1String(
",None" );
2080 defaultValue += QStringLiteral(
",%1" ).arg( ok ? QString::number( val ) : QLatin1String(
"None" ) );
2084 auto param = std::make_unique<QgsProcessingParameterRange>( name, description, dataType, defaultValue );
2085 param->setFlags( flags );
2086 return param.release();
2095QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
2104 QHBoxLayout *layout =
new QHBoxLayout();
2109 mMinSpinBox->setExpressionsEnabled(
true );
2110 mMinSpinBox->setShowClearButton(
false );
2111 mMaxSpinBox->setExpressionsEnabled(
true );
2112 mMaxSpinBox->setShowClearButton(
false );
2114 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
2115 layout->addWidget( minLabel );
2116 layout->addWidget( mMinSpinBox, 1 );
2118 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
2119 layout->addWidget( maxLabel );
2120 layout->addWidget( mMaxSpinBox, 1 );
2122 QWidget *w =
new QWidget();
2123 layout->setContentsMargins( 0, 0, 0, 0 );
2124 w->setLayout( layout );
2128 mMinSpinBox->setDecimals( 6 );
2129 mMaxSpinBox->setDecimals( 6 );
2133 mMinSpinBox->setDecimals( 0 );
2134 mMaxSpinBox->setDecimals( 0 );
2137 mMinSpinBox->setMinimum( -99999999.999999 );
2138 mMaxSpinBox->setMinimum( -99999999.999999 );
2139 mMinSpinBox->setMaximum( 99999999.999999 );
2140 mMaxSpinBox->setMaximum( 99999999.999999 );
2144 mAllowingNull =
true;
2146 const double min = mMinSpinBox->minimum() - 1;
2147 mMinSpinBox->setMinimum( min );
2148 mMaxSpinBox->setMinimum( min );
2149 mMinSpinBox->setValue( min );
2150 mMaxSpinBox->setValue( min );
2152 mMinSpinBox->setShowClearButton(
true );
2153 mMaxSpinBox->setShowClearButton(
true );
2154 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
2155 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
2158 w->setToolTip( parameterDefinition()->toolTip() );
2160 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this](
const double v ) {
2161 mBlockChangedSignal++;
2162 if ( !mAllowingNull && v > mMaxSpinBox->value() )
2163 mMaxSpinBox->setValue( v );
2164 mBlockChangedSignal--;
2166 if ( !mBlockChangedSignal )
2167 emit widgetValueHasChanged(
this );
2169 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this](
const double v ) {
2170 mBlockChangedSignal++;
2171 if ( !mAllowingNull && v < mMinSpinBox->value() )
2172 mMinSpinBox->setValue( v );
2173 mBlockChangedSignal--;
2175 if ( !mBlockChangedSignal )
2176 emit widgetValueHasChanged(
this );
2185void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2188 if ( mAllowingNull && v.empty() )
2190 mMinSpinBox->clear();
2191 mMaxSpinBox->clear();
2198 if ( mAllowingNull )
2200 mBlockChangedSignal++;
2201 if ( std::isnan( v.at( 0 ) ) )
2202 mMinSpinBox->clear();
2204 mMinSpinBox->setValue( v.at( 0 ) );
2206 if ( v.count() >= 2 )
2208 if ( std::isnan( v.at( 1 ) ) )
2209 mMaxSpinBox->clear();
2211 mMaxSpinBox->setValue( v.at( 1 ) );
2213 mBlockChangedSignal--;
2217 mBlockChangedSignal++;
2218 mMinSpinBox->setValue( v.at( 0 ) );
2219 if ( v.count() >= 2 )
2220 mMaxSpinBox->setValue( v.at( 1 ) );
2221 mBlockChangedSignal--;
2225 if ( !mBlockChangedSignal )
2226 emit widgetValueHasChanged(
this );
2229QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
2231 if ( mAllowingNull )
2234 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
2235 value = QStringLiteral(
"None" );
2237 value = QString::number( mMinSpinBox->value() );
2239 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
2240 value += QLatin1String(
",None" );
2242 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
2247 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
2250QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
2252 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
2255QString QgsProcessingRangeWidgetWrapper::parameterType()
const
2262 return new QgsProcessingRangeWidgetWrapper( parameter, type );
2267 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2278 QVBoxLayout *vlayout =
new QVBoxLayout();
2279 vlayout->setContentsMargins( 0, 0, 0, 0 );
2281 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
2284 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
2285 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
2287 vlayout->addWidget( mMatrixWidget );
2288 setLayout( vlayout );
2293 auto param = std::make_unique<QgsProcessingParameterMatrix>( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
2294 param->setFlags( flags );
2295 return param.release();
2304QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
2306 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast<const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
2307 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
2309 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [
this] {
2310 emit widgetValueHasChanged(
this );
2319 return mMatrixWidget;
2325void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2328 if ( mMatrixWidget )
2329 mMatrixWidget->setValue( v );
2332QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
2334 if ( mMatrixWidget )
2335 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
2340QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
2342 return tr(
"comma delimited string of values, or an array of values" );
2345QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
2352 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
2357 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2369 QVBoxLayout *vlayout =
new QVBoxLayout();
2370 vlayout->setContentsMargins( 0, 0, 0, 0 );
2372 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
2374 mTypeComboBox =
new QComboBox();
2378 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( fileParam->behavior() ) ) );
2380 mTypeComboBox->setCurrentIndex( 0 );
2381 vlayout->addWidget( mTypeComboBox );
2383 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
2385 mFilterComboBox =
new QComboBox();
2386 mFilterComboBox->setEditable(
true );
2388 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
2389 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
2390 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
2391 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
2393 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
2395 mFilterComboBox->setCurrentIndex( 0 );
2396 vlayout->addWidget( mFilterComboBox );
2398 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2401 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
2405 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
2409 vlayout->addWidget( mDefaultFileWidget );
2411 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2419 setLayout( vlayout );
2424 auto param = std::make_unique<QgsProcessingParameterFile>( name, description );
2427 param->setFileFilter( mFilterComboBox->currentText() );
2428 if ( !mDefaultFileWidget->filePath().isEmpty() )
2429 param->setDefaultValue( mDefaultFileWidget->filePath() );
2430 param->setFlags( flags );
2431 return param.release();
2440QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2453 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2454 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2456 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
2463 mFileWidget->setFilter( fileParam->
fileFilter() );
2464 else if ( !fileParam->
extension().isEmpty() )
2465 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
2474 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
2475 emit widgetValueHasChanged(
this );
2483void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2487 mFileWidget->setFilePath( v );
2490QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2493 return mFileWidget->filePath();
2498QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2500 return tr(
"string representing a path to a file or folder" );
2503QString QgsProcessingFileWidgetWrapper::parameterType()
const
2510 return new QgsProcessingFileWidgetWrapper( parameter, type );
2515 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2526 QVBoxLayout *vlayout =
new QVBoxLayout();
2527 vlayout->setContentsMargins( 0, 0, 0, 0 );
2528 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2531 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2533 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2534 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2536 QStackedWidget *stackedWidget =
new QStackedWidget();
2537 stackedWidget->addWidget( mDefaultQgisLineEdit );
2538 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2539 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2540 vlayout->addWidget( stackedWidget );
2545 mDefaultQgisLineEdit->setExpression( expr );
2546 mDefaultPointCloudLineEdit->setExpression( expr );
2549 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2551 mParentLayerComboBox =
new QComboBox();
2552 vlayout->addWidget( mParentLayerComboBox );
2554 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2555 mExpressionTypeComboBox =
new QComboBox();
2560 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this, stackedWidget, definition, widgetContext](
int ) {
2561 mParentLayerComboBox->clear();
2562 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2564 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2566 QString initialParent;
2568 initialParent = expParam->parentLayerParameterName();
2572 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2575 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2576 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2583 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2584 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2586 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2591 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2592 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2594 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2601 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2602 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2604 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2615 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2616 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2618 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2626 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2629 mParentLayerComboBox->addItem( initialParent, initialParent );
2630 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2634 mExpressionTypeComboBox->setCurrentIndex( -1 );
2636 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast<int>( expParam->expressionType() ) ) );
2638 mExpressionTypeComboBox->setCurrentIndex( 0 );
2640 vlayout->addWidget( mExpressionTypeComboBox );
2642 setLayout( vlayout );
2649 switch ( expressionType )
2652 expression = mDefaultQgisLineEdit->expression();
2655 expression = mDefaultPointCloudLineEdit->expression();
2658 expression = mDefaultRasterCalculatorLineEdit->expression();
2661 auto param = std::make_unique<QgsProcessingParameterExpression>( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2662 param->setFlags( flags );
2663 return param.release();
2671QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2686 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2687 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2688 mExpLineEdit->registerExpressionContextGenerator(
this );
2690 emit widgetValueHasChanged(
this );
2692 return mExpLineEdit;
2698 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2699 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2700 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [
this](
const QString & ) {
2701 emit widgetValueHasChanged(
this );
2703 return mPointCloudExpLineEdit;
2708 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2709 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2712 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2714 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [
this](
const QString & ) {
2715 emit widgetValueHasChanged(
this );
2717 return mRasterCalculatorExpLineEdit;
2721 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
2724 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2725 mExpBuilderWidget->init( createExpressionContext() );
2727 Q_UNUSED( changed );
2728 emit widgetValueHasChanged(
this );
2730 return mExpBuilderWidget;
2735 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2736 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2737 mFieldExpWidget->registerExpressionContextGenerator(
this );
2739 mFieldExpWidget->setAllowEmptyFieldName(
true );
2742 emit widgetValueHasChanged(
this );
2744 return mFieldExpWidget;
2752void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2764 setParentLayerWrapperValue( wrapper );
2766 setParentLayerWrapperValue( wrapper );
2782 if ( mExpBuilderWidget )
2785 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2793 std::unique_ptr<QgsProcessingContext> tmpContext;
2794 if ( mProcessingContextGenerator )
2795 context = mProcessingContextGenerator->processingContext();
2799 tmpContext = std::make_unique<QgsProcessingContext>();
2800 context = tmpContext.get();
2813 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2823 if ( mFieldExpWidget )
2824 mFieldExpWidget->setLayer(
nullptr );
2825 else if ( mExpBuilderWidget )
2826 mExpBuilderWidget->setLayer(
nullptr );
2827 else if ( mExpLineEdit )
2828 mExpLineEdit->setLayer(
nullptr );
2834 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2837 mParentLayer = std::move( ownedLayer );
2845 if ( mFieldExpWidget )
2846 mFieldExpWidget->setLayer( layer );
2847 if ( mExpBuilderWidget )
2848 mExpBuilderWidget->setLayer( layer );
2849 else if ( mExpLineEdit )
2850 mExpLineEdit->setLayer( layer );
2859 if ( mPointCloudExpLineEdit )
2860 mPointCloudExpLineEdit->setLayer(
nullptr );
2866 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2869 mParentLayer = std::move( ownedLayer );
2877 if ( mPointCloudExpLineEdit )
2878 mPointCloudExpLineEdit->setLayer( layer );
2885 if ( layers.isEmpty() )
2887 if ( mRasterCalculatorExpLineEdit )
2889 mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
2894 if ( mRasterCalculatorExpLineEdit )
2896 QVariantList layersList;
2899 layersList << layer->
name();
2901 mRasterCalculatorExpLineEdit->setLayers( layersList );
2909void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2912 if ( mFieldExpWidget )
2913 mFieldExpWidget->setExpression( v );
2914 else if ( mExpBuilderWidget )
2915 mExpBuilderWidget->setExpressionText( v );
2916 else if ( mExpLineEdit )
2917 mExpLineEdit->setExpression( v );
2918 else if ( mPointCloudExpLineEdit )
2919 mPointCloudExpLineEdit->setExpression( v );
2920 else if ( mRasterCalculatorExpLineEdit )
2921 mRasterCalculatorExpLineEdit->setExpression( v );
2924QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2926 if ( mFieldExpWidget )
2927 return mFieldExpWidget->expression();
2928 if ( mExpBuilderWidget )
2929 return mExpBuilderWidget->expressionText();
2930 else if ( mExpLineEdit )
2931 return mExpLineEdit->expression();
2932 else if ( mPointCloudExpLineEdit )
2933 return mPointCloudExpLineEdit->expression();
2934 else if ( mRasterCalculatorExpLineEdit )
2935 return mRasterCalculatorExpLineEdit->expression();
2940QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2942 return tr(
"string representation of an expression" );
2945const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
2947 if ( mFieldExpWidget && mFieldExpWidget->layer() )
2948 return mFieldExpWidget->layer();
2950 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
2951 return mExpBuilderWidget->layer();
2956QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
2963 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
2968 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2980 QHBoxLayout *hl =
new QHBoxLayout();
2981 hl->setContentsMargins( 0, 0, 0, 0 );
2983 mLineEdit =
new QLineEdit();
2984 mLineEdit->setEnabled(
false );
2985 hl->addWidget( mLineEdit, 1 );
2987 mToolButton =
new QToolButton();
2988 mToolButton->setText( QString( QChar( 0x2026 ) ) );
2989 hl->addWidget( mToolButton );
2995 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2998 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
3001void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
3003 if ( value.isValid() )
3005 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3007 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
3013 updateSummaryText();
3017void QgsProcessingEnumPanelWidget::showDialog()
3019 QVariantList availableOptions;
3022 availableOptions.reserve( mParam->options().size() );
3024 if ( mParam->usesStaticStrings() )
3026 for ( QString o : mParam->options() )
3028 availableOptions << o;
3033 for (
int i = 0; i < mParam->options().count(); ++i )
3034 availableOptions << i;
3038 const QStringList options = mParam ? mParam->options() : QStringList();
3042 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3043 widget->setPanelTitle( mParam->description() );
3045 if ( mParam->usesStaticStrings() )
3047 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3048 const QString i = v.toString();
3049 return options.contains( i ) ? i : QString();
3054 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3055 const int i = v.toInt();
3056 return options.size() > i ? options.at( i ) : QString();
3060 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
3061 setValue( widget->selectedOptions() );
3068 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3070 dlg.setValueFormatter( [options](
const QVariant &v ) -> QString {
3071 const int i = v.toInt();
3072 return options.size() > i ? options.at( i ) : QString();
3076 setValue( dlg.selectedOptions() );
3081void QgsProcessingEnumPanelWidget::updateSummaryText()
3086 if ( mValue.empty() )
3088 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3093 values.reserve( mValue.size() );
3094 if ( mParam->usesStaticStrings() )
3096 for (
const QVariant &val : std::as_const( mValue ) )
3098 values << val.toString();
3103 const QStringList options = mParam->options();
3104 for (
const QVariant &val : std::as_const( mValue ) )
3106 const int i = val.toInt();
3107 values << ( options.size() > i ? options.at( i ) : QString() );
3111 const QString concatenated = values.join( tr(
"," ) );
3112 if ( concatenated.length() < 100 )
3113 mLineEdit->setText( concatenated );
3115 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
3123QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
3126 , mButtonGroup( new QButtonGroup( this ) )
3127 , mColumns( columns )
3129 mButtonGroup->setExclusive( !mParam->allowMultiple() );
3131 QGridLayout *l =
new QGridLayout();
3132 l->setContentsMargins( 0, 0, 0, 0 );
3134 int rows =
static_cast<int>( std::ceil( mParam->options().count() /
static_cast<double>( mColumns ) ) );
3135 for (
int i = 0; i < mParam->options().count(); ++i )
3137 QAbstractButton *button =
nullptr;
3138 if ( mParam->allowMultiple() )
3139 button =
new QCheckBox( mParam->options().at( i ) );
3141 button =
new QRadioButton( mParam->options().at( i ) );
3143 connect( button, &QAbstractButton::toggled,
this, [
this] {
3144 if ( !mBlockChangedSignal )
3148 mButtons.insert( i, button );
3150 mButtonGroup->addButton( button, i );
3151 l->addWidget( button, i % rows, i / rows );
3153 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
3156 if ( mParam->allowMultiple() )
3158 setContextMenuPolicy( Qt::CustomContextMenu );
3159 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
3163QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
3165 if ( mParam->allowMultiple() )
3168 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3170 if ( it.value()->isChecked() )
3171 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
3177 if ( mParam->usesStaticStrings() )
3178 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
3180 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
3184void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
3186 mBlockChangedSignal =
true;
3187 if ( mParam->allowMultiple() )
3189 QVariantList selected;
3190 if ( value.isValid() )
3191 selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3192 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3194 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
3195 it.value()->setChecked( selected.contains( v ) );
3201 if ( v.userType() == QMetaType::Type::QVariantList )
3202 v = v.toList().value( 0 );
3204 v = mParam->usesStaticStrings() ?
static_cast< int >( mParam->options().indexOf( v.toString() ) ) : v;
3205 if ( mButtons.contains( v ) )
3206 mButtons.value( v )->setChecked(
true );
3208 mBlockChangedSignal =
false;
3212void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
3215 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
3216 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
3217 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
3218 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
3219 popupMenu.addAction( selectAllAction );
3220 popupMenu.addAction( clearAllAction );
3221 popupMenu.exec( QCursor::pos() );
3224void QgsProcessingEnumCheckboxPanelWidget::selectAll()
3226 mBlockChangedSignal =
true;
3227 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3228 it.value()->setChecked(
true );
3229 mBlockChangedSignal =
false;
3233void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
3235 mBlockChangedSignal =
true;
3236 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3237 it.value()->setChecked(
false );
3238 mBlockChangedSignal =
false;
3250 QVBoxLayout *vlayout =
new QVBoxLayout();
3251 vlayout->setContentsMargins( 0, 0, 0, 0 );
3253 mEnumWidget =
new QgsProcessingEnumModelerWidget();
3256 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
3257 mEnumWidget->setOptions( enumParam->options() );
3258 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
3260 vlayout->addWidget( mEnumWidget );
3261 setLayout( vlayout );
3266 auto param = std::make_unique<QgsProcessingParameterEnum>( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
3268 return param.release();
3277QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
3288 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
3290 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
3291 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
3292 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
3293 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [
this] {
3294 emit widgetValueHasChanged(
this );
3296 return mCheckboxPanel;
3305 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
3306 mPanel->setToolTip( parameterDefinition()->toolTip() );
3307 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [
this] {
3308 emit widgetValueHasChanged(
this );
3314 mComboBox =
new QComboBox();
3317 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
3318 const QStringList options = expParam->
options();
3319 const QVariantList iconList = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"icons" ) ).toList();
3320 for (
int i = 0; i < options.count(); ++i )
3322 const QIcon icon = iconList.value( i ).value<QIcon>();
3325 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
3327 mComboBox->addItem( icon, options.at( i ), i );
3330 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3331 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
3332 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
3333 emit widgetValueHasChanged(
this );
3342void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3346 if ( !value.isValid() )
3347 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
3353 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3358 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3362 else if ( mPanel || mCheckboxPanel )
3365 if ( value.isValid() )
3370 opts.reserve( v.size() );
3371 for ( QString i : v )
3377 opts.reserve( v.size() );
3383 mPanel->setValue( opts );
3384 else if ( mCheckboxPanel )
3385 mCheckboxPanel->setValue( opts );
3389QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3392 return mComboBox->currentData();
3394 return mPanel->value();
3395 else if ( mCheckboxPanel )
3396 return mCheckboxPanel->value();
3401QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3403 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3406QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3413 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3418 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3430QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3442 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() :
nullptr );
3444 mComboBox->setAllowEmptyLayout(
true );
3447 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3449 emit widgetValueHasChanged(
this );
3456 mPlainComboBox =
new QComboBox();
3457 mPlainComboBox->setEditable(
true );
3458 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3459 if ( widgetContext().project() )
3463 mPlainComboBox->addItem( layout->name() );
3466 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
3467 emit widgetValueHasChanged(
this );
3469 return mPlainComboBox;
3475void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3479 if ( !value.isValid() )
3480 mComboBox->setCurrentLayout(
nullptr );
3484 mComboBox->setCurrentLayout( l );
3486 mComboBox->setCurrentLayout(
nullptr );
3489 else if ( mPlainComboBox )
3492 mPlainComboBox->setCurrentText( v );
3496QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3501 return l ? l->
name() : QVariant();
3503 else if ( mPlainComboBox )
3504 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3512 if ( mPlainComboBox && context.
project() )
3516 mPlainComboBox->addItem( layout->name() );
3520QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3522 return tr(
"string representing the name of an existing print layout" );
3525QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3532 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3544 QVBoxLayout *vlayout =
new QVBoxLayout();
3545 vlayout->setContentsMargins( 0, 0, 0, 0 );
3547 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3549 mParentLayoutComboBox =
new QComboBox();
3550 QString initialParent;
3552 initialParent = itemParam->parentLayoutParameterName();
3554 if (
auto *lModel = widgetContext.
model() )
3557 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3558 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3562 mParentLayoutComboBox->addItem( definition->
description(), definition->
name() );
3563 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3565 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3571 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3574 mParentLayoutComboBox->addItem( initialParent, initialParent );
3575 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3578 vlayout->addWidget( mParentLayoutComboBox );
3579 setLayout( vlayout );
3583 auto param = std::make_unique<QgsProcessingParameterLayoutItem>( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3585 return param.release();
3594QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3608 mComboBox->setAllowEmptyItem(
true );
3609 if ( layoutParam->
itemType() >= 0 )
3612 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3614 emit widgetValueHasChanged(
this );
3621 mLineEdit =
new QLineEdit();
3622 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3623 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString & ) {
3624 emit widgetValueHasChanged(
this );
3632void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3659void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3665 std::unique_ptr<QgsProcessingContext> tmpContext;
3666 if ( mProcessingContextGenerator )
3667 context = mProcessingContextGenerator->processingContext();
3671 tmpContext = std::make_unique<QgsProcessingContext>();
3672 context = tmpContext.get();
3676 setLayout( layout );
3679void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3682 mComboBox->setCurrentLayout( layout );
3685void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3689 if ( !value.isValid() )
3690 mComboBox->setItem(
nullptr );
3694 mComboBox->setItem( item );
3697 else if ( mLineEdit )
3700 mLineEdit->setText( v );
3704QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3709 return i ? i->
uuid() : QVariant();
3711 else if ( mLineEdit )
3712 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3718QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3720 return tr(
"string representing the UUID or ID of an existing print layout item" );
3723QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3730 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3735 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3742QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3746 mSnapIndicator = std::make_unique<QgsSnapIndicator>( canvas );
3749QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3751void QgsProcessingPointMapTool::deactivate()
3765 if ( e->button() == Qt::LeftButton )
3768 emit clicked( point );
3773void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3775 if ( e->key() == Qt::Key_Escape )
3788QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3791 QHBoxLayout *l =
new QHBoxLayout();
3792 l->setContentsMargins( 0, 0, 0, 0 );
3794 mLineEdit->setShowClearButton(
false );
3795 l->addWidget( mLineEdit, 1 );
3796 mButton =
new QToolButton();
3797 mButton->setText( QString( QChar( 0x2026 ) ) );
3798 l->addWidget( mButton );
3801 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3802 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::textChanged );
3803 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3804 mButton->setVisible(
false );
3807void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
3810 if ( mAllowSelectOnCanvas )
3812 mButton->setVisible(
true );
3815 mTool = std::make_unique<QgsProcessingPointMapTool>( mCanvas );
3816 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
3817 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
3821void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
3823 mLineEdit->setShowClearButton( allowNull );
3826void QgsProcessingPointPanel::setShowPointOnCanvas(
bool show )
3828 if ( mShowPointOnCanvas == show )
3831 mShowPointOnCanvas = show;
3832 if ( mShowPointOnCanvas )
3838 mMapPointRubberBand.reset();
3842void QgsProcessingPointPanel::setAllowSelectOnCanvas(
bool allow )
3844 mAllowSelectOnCanvas = allow;
3845 mButton->setVisible( mAllowSelectOnCanvas &&
static_cast<bool>( mTool ) );
3848QVariant QgsProcessingPointPanel::value()
const
3850 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
3853void QgsProcessingPointPanel::clear()
3861 QString newText = QStringLiteral(
"%1,%2" )
3862 .arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) );
3865 if ( mCrs.isValid() )
3867 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
3869 mLineEdit->setText( newText );
3873void QgsProcessingPointPanel::showEvent( QShowEvent * )
3878 if ( QWidget *parentWindow = window() )
3880 setAllowSelectOnCanvas( !parentWindow->isModal() );
3886void QgsProcessingPointPanel::selectOnCanvas()
3891 mPrevTool = mCanvas->mapTool();
3892 mCanvas->setMapTool( mTool.get() );
3894 emit toggleDialogVisibility(
false );
3897void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3899 setValue( point, mCanvas->mapSettings().destinationCrs() );
3902void QgsProcessingPointPanel::pointPicked()
3907 mCanvas->setMapTool( mPrevTool );
3909 emit toggleDialogVisibility(
true );
3912void QgsProcessingPointPanel::textChanged(
const QString &text )
3914 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3916 const QRegularExpressionMatch match = rx.match( text );
3917 if ( match.hasMatch() )
3920 const double x = match.captured( 1 ).toDouble( &xOk );
3922 const double y = match.captured( 2 ).toDouble( &yOk );
3929 if ( pointCrs.isValid() )
3947void QgsProcessingPointPanel::updateRubberBand()
3949 if ( !mShowPointOnCanvas || !mCanvas )
3952 if ( mPoint.isEmpty() )
3954 mMapPointRubberBand.reset();
3958 if ( !mMapPointRubberBand )
3961 mMapPointRubberBand->setZValue( 1000 );
3964 const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
3965 mMapPointRubberBand->setWidth( scaleFactor );
3966 mMapPointRubberBand->setIconSize( scaleFactor * 5 );
3968 mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
3969 mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
3983 QVBoxLayout *vlayout =
new QVBoxLayout();
3984 vlayout->setContentsMargins( 0, 0, 0, 0 );
3986 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3988 mDefaultLineEdit =
new QLineEdit();
3989 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3990 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
3994 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
3997 vlayout->addWidget( mDefaultLineEdit );
3998 setLayout( vlayout );
4003 auto param = std::make_unique<QgsProcessingParameterPoint>( name, description, mDefaultLineEdit->text() );
4005 return param.release();
4013QWidget *QgsProcessingPointWidgetWrapper::createWidget()
4024 mPanel =
new QgsProcessingPointPanel(
nullptr );
4025 if ( widgetContext().mapCanvas() )
4026 mPanel->setMapCanvas( widgetContext().mapCanvas() );
4029 mPanel->setAllowNull(
true );
4032 mPanel->setShowPointOnCanvas(
true );
4034 mPanel->setToolTip( parameterDefinition()->toolTip() );
4036 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [
this] {
4037 emit widgetValueHasChanged(
this );
4041 setDialog( mDialog );
4047 mLineEdit =
new QLineEdit();
4048 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4049 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString & ) {
4050 emit widgetValueHasChanged(
this );
4062 mPanel->setMapCanvas( context.
mapCanvas() );
4065void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
4070 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [
this](
bool visible ) {
4072 mDialog->showMinimized();
4075 mDialog->showNormal();
4077 mDialog->activateWindow();
4084void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4088 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
4094 mPanel->setValue( p, crs );
4097 else if ( mLineEdit )
4100 mLineEdit->setText( v );
4104QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
4108 return mPanel->value();
4110 else if ( mLineEdit )
4111 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
4116QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
4118 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
4121QString QgsProcessingPointWidgetWrapper::parameterType()
const
4128 return new QgsProcessingPointWidgetWrapper( parameter, type );
4133 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4145 QVBoxLayout *vlayout =
new QVBoxLayout();
4146 vlayout->setContentsMargins( 0, 0, 0, 0 );
4148 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4160 vlayout->addWidget( mGeometryWidget );
4161 setLayout( vlayout );
4167 auto param = std::make_unique<QgsProcessingParameterGeometry>( name, description, geometry.
isEmpty() ? QVariant() : geometry.
asWkt() );
4169 return param.release();
4177QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
4186 mGeometryWidget->setToolTip( parameterDefinition()->toolTip() );
4188 emit widgetValueHasChanged(
this );
4190 return mGeometryWidget;
4196void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4198 if ( mGeometryWidget )
4207 mGeometryWidget->clearGeometry();
4212QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
4214 if ( mGeometryWidget )
4217 return geometry.
isEmpty() ? QVariant() : geometry.asWkt();
4225QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
4227 return tr(
"string in the Well-Known-Text format or a geometry value" );
4230QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
4237 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
4242 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4254 QVBoxLayout *vlayout =
new QVBoxLayout();
4255 vlayout->setContentsMargins( 0, 0, 0, 0 );
4257 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4260 mDefaultColorButton->setShowNull(
true );
4261 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
4267 mDefaultColorButton->setToNull();
4269 mDefaultColorButton->setColor(
c );
4270 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
4274 mDefaultColorButton->setToNull();
4275 mAllowOpacity->setChecked(
true );
4278 vlayout->addWidget( mDefaultColorButton );
4279 vlayout->addWidget( mAllowOpacity );
4280 setLayout( vlayout );
4285 auto param = std::make_unique<QgsProcessingParameterColor>( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
4287 return param.release();
4295QWidget *QgsProcessingColorWidgetWrapper::createWidget()
4308 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
4311 mColorButton->setShowNull(
true );
4314 mColorButton->setToolTip( parameterDefinition()->toolTip() );
4315 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
4322 emit widgetValueHasChanged(
this );
4325 return mColorButton;
4331void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4335 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() )
4336 || ( value.userType() == QMetaType::Type::QColor && !value.value<QColor>().isValid() ) )
4337 mColorButton->setToNull();
4341 if ( !
c.isValid() && mColorButton->showNull() )
4342 mColorButton->setToNull();
4344 mColorButton->setColor(
c );
4349QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
4352 return mColorButton->isNull() ? QVariant() : mColorButton->color();
4357QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
4359 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
4362QString QgsProcessingColorWidgetWrapper::parameterType()
const
4369 return new QgsProcessingColorWidgetWrapper( parameter, type );
4374 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4385 QVBoxLayout *vlayout =
new QVBoxLayout();
4386 vlayout->setContentsMargins( 0, 0, 0, 0 );
4388 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4390 mDefaultLineEdit =
new QLineEdit();
4393 vlayout->addWidget( mDefaultLineEdit );
4395 mSourceParamComboBox =
new QComboBox();
4396 mDestParamComboBox =
new QComboBox();
4397 QString initialSource;
4398 QString initialDest;
4403 initialSource = itemParam->sourceCrsParameterName();
4404 initialDest = itemParam->destinationCrsParameterName();
4409 mSourceParamComboBox->addItem( QString(), QString() );
4410 mDestParamComboBox->addItem( QString(), QString() );
4411 if (
auto *lModel = widgetContext.
model() )
4414 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4415 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4417 if ( definition && it->parameterName() == definition->
name() )
4421 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4422 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4423 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4425 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4427 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4429 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4434 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4437 mSourceParamComboBox->addItem( initialSource, initialSource );
4438 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4440 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4443 mDestParamComboBox->addItem( initialDest, initialDest );
4444 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4447 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4448 vlayout->addWidget( mSourceParamComboBox );
4449 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4450 vlayout->addWidget( mDestParamComboBox );
4454 mStaticSourceWidget->setCrs( sourceCrs );
4457 mStaticDestWidget->setCrs( destCrs );
4459 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4460 vlayout->addWidget( mStaticSourceWidget );
4461 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4462 vlayout->addWidget( mStaticDestWidget );
4464 setLayout( vlayout );
4469 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() );
4471 return param.release();
4479QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4493 mOperationWidget->setShowMakeDefault(
false );
4494 mOperationWidget->setShowFallbackOption(
false );
4495 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4496 mOperationWidget->setSourceCrs( mSourceCrs );
4497 mOperationWidget->setDestinationCrs( mDestCrs );
4498 mOperationWidget->setMapCanvas( mCanvas );
4503 mOperationWidget->setSelectedOperation( deets );
4507 emit widgetValueHasChanged(
this );
4510 return mOperationWidget;
4516 mLineEdit =
new QLineEdit();
4517 QHBoxLayout *layout =
new QHBoxLayout();
4518 layout->addWidget( mLineEdit, 1 );
4519 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
4520 emit widgetValueHasChanged(
this );
4523 QToolButton *button =
new QToolButton();
4524 button->setText( QString( QChar( 0x2026 ) ) );
4525 connect( button, &QToolButton::clicked,
this, [
this, button] {
4526 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4529 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4530 emit widgetValueHasChanged(
this );
4533 layout->addWidget( button );
4535 QWidget *w =
new QWidget();
4536 layout->setContentsMargins( 0, 0, 0, 0 );
4537 w->setLayout( layout );
4544void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4580 if ( mOperationWidget )
4581 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4584void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4586 if ( mOperationWidget )
4588 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4591 deets.
proj = value.toString();
4592 mOperationWidget->setSelectedOperation( deets );
4597 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4599 mLineEdit->setText( value.toString() );
4604QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4606 if ( mOperationWidget )
4607 return mOperationWidget->selectedOperation().proj;
4608 else if ( mLineEdit )
4609 return mLineEdit->text();
4614QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4616 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4619void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4622 std::unique_ptr<QgsProcessingContext> tmpContext;
4623 if ( mProcessingContextGenerator )
4624 context = mProcessingContextGenerator->processingContext();
4628 tmpContext = std::make_unique<QgsProcessingContext>();
4629 context = tmpContext.get();
4633 if ( mOperationWidget )
4635 mOperationWidget->setSourceCrs( mSourceCrs );
4636 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4640void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4643 std::unique_ptr<QgsProcessingContext> tmpContext;
4644 if ( mProcessingContextGenerator )
4645 context = mProcessingContextGenerator->processingContext();
4649 tmpContext = std::make_unique<QgsProcessingContext>();
4650 context = tmpContext.get();
4654 if ( mOperationWidget )
4656 mOperationWidget->setDestinationCrs( mDestCrs );
4657 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4661QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
4668 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
4673 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4685 QHBoxLayout *hl =
new QHBoxLayout();
4686 hl->setContentsMargins( 0, 0, 0, 0 );
4688 mLineEdit =
new QLineEdit();
4689 mLineEdit->setEnabled(
false );
4690 hl->addWidget( mLineEdit, 1 );
4692 mToolButton =
new QToolButton();
4693 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4694 hl->addWidget( mToolButton );
4700 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4703 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4706void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4712 QVariantList availableFields;
4713 for (
const QgsField &field : std::as_const( mFields ) )
4715 availableFields << field.name();
4717 QList<QVariant>::iterator it = std::remove_if( mValue.begin(), mValue.end(), [&availableFields](
const QVariant &value ) { return !availableFields.contains( value ); } );
4718 mValue.erase( it, mValue.end() );
4720 updateSummaryText();
4724void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4726 if ( value.isValid() )
4727 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
4731 updateSummaryText();
4735void QgsProcessingFieldPanelWidget::showDialog()
4737 QVariantList availableOptions;
4738 availableOptions.reserve( mFields.size() );
4739 for (
const QgsField &field : std::as_const( mFields ) )
4741 availableOptions << field.name();
4747 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4748 widget->setPanelTitle( mParam->description() );
4750 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
4751 return v.toString();
4754 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
4755 setValue( widget->selectedOptions() );
4762 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4764 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
4765 return v.toString();
4769 setValue( dlg.selectedOptions() );
4774void QgsProcessingFieldPanelWidget::updateSummaryText()
4779 if ( mValue.empty() )
4781 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4786 values.reserve( mValue.size() );
4787 for (
const QVariant &val : std::as_const( mValue ) )
4789 values << val.toString();
4792 const QString concatenated = values.join( tr(
"," ) );
4793 if ( concatenated.length() < 100 )
4794 mLineEdit->setText( concatenated );
4796 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4808 QVBoxLayout *vlayout =
new QVBoxLayout();
4809 vlayout->setContentsMargins( 0, 0, 0, 0 );
4811 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4812 mParentLayerComboBox =
new QComboBox();
4814 QString initialParent;
4816 initialParent = fieldParam->parentLayerParameterName();
4818 if (
auto *lModel = widgetContext.
model() )
4821 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4822 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4826 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4827 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4829 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4834 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4835 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4837 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4844 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4845 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4847 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4854 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4857 mParentLayerComboBox->addItem( initialParent, initialParent );
4858 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4861 vlayout->addWidget( mParentLayerComboBox );
4863 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4864 mDataTypeComboBox =
new QComboBox();
4872 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast<int>( fieldParam->dataType() ) ) );
4874 vlayout->addWidget( mDataTypeComboBox );
4876 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4878 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4880 vlayout->addWidget( mAllowMultipleCheckBox );
4882 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4883 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4885 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4887 vlayout->addWidget( mDefaultToAllCheckBox );
4889 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [
this] {
4890 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4893 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4895 mDefaultLineEdit =
new QLineEdit();
4896 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4900 mDefaultLineEdit->setText( fields.join(
';' ) );
4902 vlayout->addWidget( mDefaultLineEdit );
4904 setLayout( vlayout );
4911 QVariant defaultValue;
4912 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4914 defaultValue = mDefaultLineEdit->text();
4916 auto param = std::make_unique<QgsProcessingParameterField>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
4918 return param.release();
4926QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
4939 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
4940 mPanel->setToolTip( parameterDefinition()->toolTip() );
4941 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [
this] {
4942 emit widgetValueHasChanged(
this );
4962 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4964 emit widgetValueHasChanged(
this );
4972 mLineEdit =
new QLineEdit();
4973 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
4974 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
4975 emit widgetValueHasChanged(
this );
4983void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4995 setParentLayerWrapperValue( wrapper );
4997 setParentLayerWrapperValue( wrapper );
5014 std::unique_ptr<QgsProcessingContext> tmpContext;
5015 if ( mProcessingContextGenerator )
5016 context = mProcessingContextGenerator->processingContext();
5020 tmpContext = std::make_unique<QgsProcessingContext>();
5021 context = tmpContext.get();
5026 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
5036 bool valueSet =
false;
5040 if ( layers.count() > 1 )
5042 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5044 const QList<QgsMapLayer *> remainingLayers = layers.mid( 1 );
5050 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
5051 if ( !vlayer || !vlayer->
isValid() )
5057 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
5060 fields.
remove( fieldIdx );
5065 mComboBox->setFields( fields );
5067 mPanel->setFields( filterFields( fields ) );
5073 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
5075 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5079 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
5082 mParentLayer.reset( qobject_cast<QgsVectorLayer *>( ownedLayer.release() ) );
5083 layer = mParentLayer.get();
5091 mComboBox->setLayer( layer );
5093 mPanel->setFields( filterFields( layer->
fields() ) );
5103 const QgsFields fields = source->fields();
5105 mComboBox->setFields( fields );
5107 mPanel->setFields( filterFields( fields ) );
5116 mComboBox->setLayer(
nullptr );
5120 if ( value.isValid() && widgetContext().messageBar() )
5132 val.reserve( mPanel->fields().size() );
5133 for (
const QgsField &field : mPanel->fields() )
5134 val << field.name();
5135 setWidgetValue( val, *context );
5138 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5141void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5145 if ( !value.isValid() )
5146 mComboBox->setField( QString() );
5150 mComboBox->setField( v );
5156 if ( value.isValid() )
5159 opts.reserve( v.size() );
5160 for (
const QString &i : v )
5164 mPanel->setValue( opts );
5166 else if ( mLineEdit )
5172 mLineEdit->setText( v.join(
';' ) );
5181QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
5184 return mComboBox->currentField();
5186 return mPanel->value();
5187 else if ( mLineEdit )
5192 return mLineEdit->text().split(
';' );
5195 return mLineEdit->text();
5201QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
5203 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
5206const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
5208 if ( mComboBox && mComboBox->layer() )
5209 return mComboBox->layer();
5214QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
5227 if ( f.isNumeric() )
5232 if ( f.type() == QMetaType::Type::QString )
5237 if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
5242 if ( f.type() == QMetaType::Type::QByteArray )
5247 if ( f.type() == QMetaType::Type::Bool )
5256QString QgsProcessingFieldWidgetWrapper::parameterType()
const
5263 return new QgsProcessingFieldWidgetWrapper( parameter, type );
5268 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5279 QVBoxLayout *vlayout =
new QVBoxLayout();
5280 vlayout->setContentsMargins( 0, 0, 0, 0 );
5282 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5284 mDefaultComboBox =
new QComboBox();
5285 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
5288 for (
const QString &theme : mapThemes )
5292 mDefaultComboBox->setEditable(
true );
5296 if ( themeParam->defaultValueForGui().isValid() )
5299 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5302 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5304 vlayout->addWidget( mDefaultComboBox );
5306 setLayout( vlayout );
5311 QVariant defaultVal;
5312 if ( mDefaultComboBox->currentText().isEmpty() )
5313 defaultVal = QVariant();
5315 defaultVal = mDefaultComboBox->currentText();
5316 auto param = std::make_unique<QgsProcessingParameterMapTheme>( name, description, defaultVal );
5318 return param.release();
5327QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
5333 mComboBox =
new QComboBox();
5336 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
5339 for (
const QString &theme : mapThemes )
5351 mComboBox->setEditable(
true );
5355 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5356 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
5357 emit widgetValueHasChanged(
this );
5363void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5367 if ( !value.isValid() )
5368 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5371 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5373 const QString prev = mComboBox->currentText();
5374 mComboBox->setCurrentText( v );
5376 emit widgetValueHasChanged(
this );
5379 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5383QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5386 return mComboBox->currentData().toInt() == -1 ? QVariant() : !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5387 : mComboBox->currentData();
5392QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5394 return tr(
"map theme as a string value (e.g. 'base maps')" );
5397QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5404 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5409 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5421 QVBoxLayout *vlayout =
new QVBoxLayout();
5422 vlayout->setContentsMargins( 0, 0, 0, 0 );
5424 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5426 mTypeComboBox =
new QComboBox();
5431 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( datetimeParam->dataType() ) ) );
5433 mTypeComboBox->setCurrentIndex( 0 );
5434 vlayout->addWidget( mTypeComboBox );
5436 setLayout( vlayout );
5441 auto param = std::make_unique<QgsProcessingParameterDateTime>( name, description );
5444 return param.release();
5453QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5456 if ( !dateTimeParam )
5460 switch ( dateTimeParam->
dataType() )
5464 widget = mDateTimeEdit;
5489 widget->setToolTip( parameterDefinition()->toolTip() );
5491 if ( mDateTimeEdit )
5494 emit widgetValueHasChanged(
this );
5497 else if ( mDateEdit )
5500 emit widgetValueHasChanged(
this );
5503 else if ( mTimeEdit )
5506 emit widgetValueHasChanged(
this );
5515 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5518void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5520 if ( mDateTimeEdit )
5524 else if ( mDateEdit )
5528 else if ( mTimeEdit )
5534QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5536 if ( mDateTimeEdit )
5537 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5538 else if ( mDateEdit )
5539 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5540 else if ( mTimeEdit )
5541 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5546QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5549 if ( dateTimeParam )
5551 switch ( dateTimeParam->
dataType() )
5554 return tr(
"datetime value, or a ISO string representation of a datetime" );
5557 return tr(
"date value, or a ISO string representation of a date" );
5560 return tr(
"time value, or a ISO string representation of a time" );
5566QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5573 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5586 QVBoxLayout *vlayout =
new QVBoxLayout();
5587 vlayout->setContentsMargins( 0, 0, 0, 0 );
5589 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5590 mProviderComboBox =
new QComboBox();
5591 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
5592 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
5593 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
5595 vlayout->addWidget( mProviderComboBox );
5597 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5599 mDefaultEdit =
new QLineEdit();
5600 vlayout->addWidget( mDefaultEdit );
5601 setLayout( vlayout );
5603 if ( connectionParam )
5605 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5612 QVariant defaultVal;
5613 if ( mDefaultEdit->text().isEmpty() )
5614 defaultVal = QVariant();
5616 defaultVal = mDefaultEdit->text();
5617 auto param = std::make_unique<QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5619 return param.release();
5628QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5631 if ( !connectionParam )
5636 mProviderComboBox->setAllowEmptyConnection(
true );
5644 mProviderComboBox->setEditable(
true );
5648 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5649 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [
this](
const QString & ) {
5650 if ( mBlockSignals )
5653 emit widgetValueHasChanged(
this );
5656 return mProviderComboBox;
5661 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5664void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5668 if ( !value.isValid() )
5669 mProviderComboBox->setCurrentIndex( -1 );
5672 if ( mProviderComboBox->isEditable() )
5674 const QString prev = mProviderComboBox->currentText();
5676 mProviderComboBox->setConnection( v );
5677 mProviderComboBox->setCurrentText( v );
5681 emit widgetValueHasChanged(
this );
5684 mProviderComboBox->setConnection( v );
5688QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5690 if ( mProviderComboBox )
5691 if ( mProviderComboBox->isEditable() )
5692 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5694 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5699QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5701 return tr(
"connection name as a string value" );
5704QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5711 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5724 QVBoxLayout *vlayout =
new QVBoxLayout();
5725 vlayout->setContentsMargins( 0, 0, 0, 0 );
5727 mConnectionParamComboBox =
new QComboBox();
5728 QString initialConnection;
5734 if (
auto *lModel = widgetContext.
model() )
5737 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5738 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5740 if ( definition && it->parameterName() == definition->
name() )
5746 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5747 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5749 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5754 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5757 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5758 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5761 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5762 vlayout->addWidget( mConnectionParamComboBox );
5764 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5766 mDefaultEdit =
new QLineEdit();
5767 vlayout->addWidget( mDefaultEdit );
5768 setLayout( vlayout );
5778 QVariant defaultVal;
5779 if ( mDefaultEdit->text().isEmpty() )
5780 defaultVal = QVariant();
5782 defaultVal = mDefaultEdit->text();
5783 auto param = std::make_unique<QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5785 return param.release();
5794QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5802 mSchemaComboBox->setAllowEmptySchema(
true );
5810 mSchemaComboBox->comboBox()->setEditable(
true );
5814 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5815 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
5816 if ( mBlockSignals )
5819 emit widgetValueHasChanged( this );
5822 return mSchemaComboBox;
5827 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5834 std::unique_ptr<QgsProcessingContext> tmpContext;
5835 if ( mProcessingContextGenerator )
5836 context = mProcessingContextGenerator->processingContext();
5840 tmpContext = std::make_unique<QgsProcessingContext>();
5841 context = tmpContext.get();
5847 if ( mSchemaComboBox )
5848 mSchemaComboBox->setConnectionName( connection, qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId() );
5852 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5855void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5859 if ( !value.isValid() )
5860 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5863 if ( mSchemaComboBox->comboBox()->isEditable() )
5865 const QString prev = mSchemaComboBox->comboBox()->currentText();
5867 mSchemaComboBox->setSchema( v );
5868 mSchemaComboBox->comboBox()->setCurrentText( v );
5872 emit widgetValueHasChanged(
this );
5875 mSchemaComboBox->setSchema( v );
5879QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5881 if ( mSchemaComboBox )
5882 if ( mSchemaComboBox->comboBox()->isEditable() )
5883 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5885 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5890QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5892 return tr(
"database schema name as a string value" );
5895QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5902 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5905void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5917 setParentConnectionWrapperValue( wrapper );
5919 setParentConnectionWrapperValue( wrapper );
5942 QVBoxLayout *vlayout =
new QVBoxLayout();
5943 vlayout->setContentsMargins( 0, 0, 0, 0 );
5945 mConnectionParamComboBox =
new QComboBox();
5946 mSchemaParamComboBox =
new QComboBox();
5947 QString initialConnection;
5948 QString initialSchema;
5955 if (
auto *lModel = widgetContext.
model() )
5958 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5959 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5961 if ( definition && it->parameterName() == definition->
name() )
5966 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5967 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5969 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5974 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
5975 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5977 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5983 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5986 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5987 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5990 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
5993 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
5994 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5997 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5998 vlayout->addWidget( mConnectionParamComboBox );
6000 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
6001 vlayout->addWidget( mSchemaParamComboBox );
6003 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6005 mDefaultEdit =
new QLineEdit();
6006 vlayout->addWidget( mDefaultEdit );
6007 setLayout( vlayout );
6017 QVariant defaultVal;
6018 if ( mDefaultEdit->text().isEmpty() )
6019 defaultVal = QVariant();
6021 defaultVal = mDefaultEdit->text();
6022 auto param = std::make_unique<QgsProcessingParameterDatabaseTable>( name, description, mConnectionParamComboBox->currentData().toString(), mSchemaParamComboBox->currentData().toString(), defaultVal );
6024 return param.release();
6033QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
6041 mTableComboBox->setAllowEmptyTable(
true );
6044 mTableComboBox->comboBox()->setEditable(
true );
6046 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
6047 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
6048 if ( mBlockSignals )
6051 emit widgetValueHasChanged( this );
6054 return mTableComboBox;
6059 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6066 std::unique_ptr<QgsProcessingContext> tmpContext;
6067 if ( mProcessingContextGenerator )
6068 context = mProcessingContextGenerator->processingContext();
6072 tmpContext = std::make_unique<QgsProcessingContext>();
6073 context = tmpContext.get();
6078 mProvider = qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId();
6079 if ( mTableComboBox && !mSchema.isEmpty() )
6081 mTableComboBox->setSchema( mSchema );
6082 mTableComboBox->setConnectionName( mConnection, mProvider );
6086 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6094 std::unique_ptr<QgsProcessingContext> tmpContext;
6095 if ( mProcessingContextGenerator )
6096 context = mProcessingContextGenerator->processingContext();
6100 tmpContext = std::make_unique<QgsProcessingContext>();
6101 context = tmpContext.get();
6107 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
6109 mTableComboBox->setSchema( mSchema );
6110 mTableComboBox->setConnectionName( mConnection, mProvider );
6112 const QgsProcessingParameterDatabaseTable *tableParam = static_cast<const QgsProcessingParameterDatabaseTable *>( parameterDefinition() );
6113 if ( tableParam->defaultValueForGui().isValid() )
6114 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6118void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6122 if ( !value.isValid() )
6123 mTableComboBox->comboBox()->setCurrentIndex( -1 );
6126 if ( mTableComboBox->comboBox()->isEditable() )
6128 const QString prev = mTableComboBox->comboBox()->currentText();
6130 mTableComboBox->setTable( v );
6131 mTableComboBox->comboBox()->setCurrentText( v );
6135 emit widgetValueHasChanged(
this );
6138 mTableComboBox->setTable( v );
6142QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
6144 if ( mTableComboBox )
6145 if ( mTableComboBox->comboBox()->isEditable() )
6146 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
6148 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
6153QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
6155 return tr(
"database table name as a string value" );
6158QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
6165 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
6168void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6180 setParentConnectionWrapperValue( wrapper );
6182 setParentConnectionWrapperValue( wrapper );
6187 setParentSchemaWrapperValue( wrapper );
6189 setParentSchemaWrapperValue( wrapper );
6209 QVBoxLayout *vlayout =
new QVBoxLayout();
6210 vlayout->setContentsMargins( 0, 0, 0, 0 );
6212 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6215 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6218 if ( extentParam->defaultValueForGui().isValid() )
6222 mDefaultWidget->setCurrentExtent( rect, crs );
6223 mDefaultWidget->setOutputExtentFromCurrent();
6227 mDefaultWidget->clear();
6231 vlayout->addWidget( mDefaultWidget );
6232 setLayout( vlayout );
6237 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();
6238 auto param = std::make_unique<QgsProcessingParameterExtent>( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
6240 return param.release();
6249QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
6262 if ( widgetContext().mapCanvas() )
6263 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
6266 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6268 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6271 emit widgetValueHasChanged(
this );
6275 setDialog( mDialog );
6277 return mExtentWidget;
6287 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6290void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6297 mDialog->showMinimized();
6300 mDialog->showNormal();
6302 mDialog->activateWindow();
6309void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6311 if ( mExtentWidget )
6313 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
6314 mExtentWidget->clear();
6319 mExtentWidget->setCurrentExtent( r, crs );
6320 mExtentWidget->setOutputExtentFromUser( r, crs );
6325QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6327 if ( mExtentWidget )
6329 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();
6331 return val.isEmpty() ? QVariant() : QVariant( val );
6337QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6339 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6342QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6349 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6354 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6365 QVBoxLayout *vlayout =
new QVBoxLayout();
6366 vlayout->setContentsMargins( 0, 0, 0, 0 );
6368 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6384 for (
int i : layerParam->dataTypes() )
6386 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6390 vlayout->addWidget( mLayerTypeComboBox );
6392 setLayout( vlayout );
6397 QList<int> dataTypes;
6398 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6399 dataTypes << v.toInt();
6401 auto param = std::make_unique<QgsProcessingParameterMapLayer>( name, description );
6402 param->setDataTypes( dataTypes );
6404 return param.release();
6412QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6414 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6422 mComboBox->setEditable(
true );
6426 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6428 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [
this]() {
6429 if ( mBlockSignals )
6432 emit widgetValueHasChanged(
this );
6435 setWidgetContext( widgetContext() );
6444 mComboBox->setWidgetContext( context );
6449 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6455void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6458 mComboBox->setValue( value, context );
6461QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6463 return mComboBox ? mComboBox->value() : QVariant();
6466QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6468 return tr(
"path to a map layer" );
6485QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6492 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6497 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6506 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6510QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6512 return tr(
"path to a raster layer" );
6515QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6522 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6527 Q_UNUSED( context );
6528 Q_UNUSED( widgetContext );
6529 Q_UNUSED( definition );
6543 QVBoxLayout *vlayout =
new QVBoxLayout();
6544 vlayout->setContentsMargins( 0, 0, 0, 0 );
6546 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6556 for (
int i : vectorParam->dataTypes() )
6558 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6562 vlayout->addWidget( mGeometryTypeComboBox );
6564 setLayout( vlayout );
6569 QList<int> dataTypes;
6570 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6571 dataTypes << v.toInt();
6573 auto param = std::make_unique<QgsProcessingParameterVectorLayer>( name, description, dataTypes );
6575 return param.release();
6580 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6584QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6586 return tr(
"path to a vector layer" );
6589QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6596 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6601 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6612 QVBoxLayout *vlayout =
new QVBoxLayout();
6613 vlayout->setContentsMargins( 0, 0, 0, 0 );
6615 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6625 for (
int i : sourceParam->dataTypes() )
6627 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6635 vlayout->addWidget( mGeometryTypeComboBox );
6637 setLayout( vlayout );
6642 QList<int> dataTypes;
6643 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6644 dataTypes << v.toInt();
6646 auto param = std::make_unique<QgsProcessingParameterFeatureSource>( name, description, dataTypes );
6648 return param.release();
6652 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6656QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6658 return tr(
"path to a vector layer" );
6661QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6668 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6673 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6681 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6685QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6687 return tr(
"path to a mesh layer" );
6690QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6697 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6702 Q_UNUSED( context );
6703 Q_UNUSED( widgetContext );
6704 Q_UNUSED( definition );
6715QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6719 QHBoxLayout *hl =
new QHBoxLayout();
6720 hl->setContentsMargins( 0, 0, 0, 0 );
6722 mLineEdit =
new QLineEdit();
6723 mLineEdit->setEnabled(
false );
6724 hl->addWidget( mLineEdit, 1 );
6726 mToolButton =
new QToolButton();
6727 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6728 hl->addWidget( mToolButton );
6734 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6737 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6740void QgsProcessingRasterBandPanelWidget::setBands(
const QList<int> &bands )
6745void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6750void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6752 if ( value.isValid() )
6753 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
6757 updateSummaryText();
6761void QgsProcessingRasterBandPanelWidget::showDialog()
6763 QVariantList availableOptions;
6764 availableOptions.reserve( mBands.size() );
6765 for (
int band : std::as_const( mBands ) )
6767 availableOptions << band;
6773 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6774 widget->setPanelTitle( mParam->description() );
6776 widget->setValueFormatter( [
this](
const QVariant &v ) -> QString {
6777 int band = v.toInt();
6778 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6781 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
6782 setValue( widget->selectedOptions() );
6789 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6791 dlg.setValueFormatter( [
this](
const QVariant &v ) -> QString {
6792 int band = v.toInt();
6793 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6797 setValue( dlg.selectedOptions() );
6802void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6805 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6816 QVBoxLayout *vlayout =
new QVBoxLayout();
6817 vlayout->setContentsMargins( 0, 0, 0, 0 );
6819 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6821 mDefaultLineEdit =
new QLineEdit();
6822 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6827 for (
int b : bands )
6829 defVal << QString::number( b );
6832 mDefaultLineEdit->setText( defVal.join(
';' ) );
6834 vlayout->addWidget( mDefaultLineEdit );
6836 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6837 mParentLayerComboBox =
new QComboBox();
6839 QString initialParent;
6841 initialParent = bandParam->parentLayerParameterName();
6843 if (
auto *lModel = widgetContext.
model() )
6846 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6847 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6851 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
6852 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6854 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6860 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6863 mParentLayerComboBox->addItem( initialParent, initialParent );
6864 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6867 vlayout->addWidget( mParentLayerComboBox );
6869 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6871 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6873 vlayout->addWidget( mAllowMultipleCheckBox );
6874 setLayout( vlayout );
6879 auto param = std::make_unique<QgsProcessingParameterBand>( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6881 return param.release();
6889QWidget *QgsProcessingBandWidgetWrapper::createWidget()
6902 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
6903 mPanel->setToolTip( parameterDefinition()->toolTip() );
6904 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [
this] {
6905 emit widgetValueHasChanged(
this );
6914 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6916 emit widgetValueHasChanged(
this );
6924 mLineEdit =
new QLineEdit();
6925 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6926 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
6927 emit widgetValueHasChanged(
this );
6935void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6947 setParentLayerWrapperValue( wrapper );
6949 setParentLayerWrapperValue( wrapper );
6966 std::unique_ptr<QgsProcessingContext> tmpContext;
6967 if ( mProcessingContextGenerator )
6968 context = mProcessingContextGenerator->processingContext();
6972 tmpContext = std::make_unique<QgsProcessingContext>();
6973 context = tmpContext.get();
6979 if ( layer && layer->
isValid() )
6983 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
6986 mParentLayer.reset( qobject_cast<QgsRasterLayer *>( ownedLayer.release() ) );
6987 layer = mParentLayer.get();
6995 mComboBox->setLayer( layer );
6999 if ( provider && layer->
isValid() )
7004 QHash<int, QString> bandNames;
7005 for (
int i = 1; i <= nBands; ++i )
7010 mPanel->setBands( bands );
7011 mPanel->setBandNames( bandNames );
7018 mComboBox->setLayer(
nullptr );
7020 mPanel->setBands( QList<int>() );
7022 if ( value.isValid() && widgetContext().messageBar() )
7029 if ( parameterDefinition()->defaultValueForGui().isValid() )
7030 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7033void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7037 if ( !value.isValid() )
7038 mComboBox->setBand( -1 );
7042 mComboBox->setBand( v );
7048 if ( value.isValid() )
7051 opts.reserve( v.size() );
7056 mPanel->setValue( value.isValid() ? opts : QVariant() );
7058 else if ( mLineEdit )
7065 opts.reserve( v.size() );
7067 opts << QString::number( i );
7068 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
7072 if ( value.isValid() )
7080QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
7083 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
7085 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7086 else if ( mLineEdit )
7091 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
7093 res.reserve( parts.count() );
7094 for (
const QString &s : parts )
7097 int band = s.toInt( &ok );
7101 return res.
isEmpty() ? QVariant() : res;
7105 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7112QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7114 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7117QString QgsProcessingBandWidgetWrapper::parameterType()
const
7124 return new QgsProcessingBandWidgetWrapper( parameter, type );
7129 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7140 setAcceptDrops(
true );
7143void QgsProcessingMultipleLayerLineEdit::dragEnterEvent( QDragEnterEvent *event )
7145 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7146 if ( !uris.isEmpty() )
7148 event->setDropAction( Qt::CopyAction );
7150 setHighlighted(
true );
7158void QgsProcessingMultipleLayerLineEdit::dragLeaveEvent( QDragLeaveEvent *event )
7160 QgsHighlightableLineEdit::dragLeaveEvent( event );
7162 setHighlighted(
false );
7165void QgsProcessingMultipleLayerLineEdit::dropEvent( QDropEvent *event )
7167 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7168 if ( !uris.isEmpty() )
7170 event->setDropAction( Qt::CopyAction );
7172 QVariantList uriList;
7173 uriList.reserve( uris.size() );
7174 for (
const QString &uri : uris )
7175 uriList.append( QVariant( uri ) );
7176 emit layersDropped( uriList );
7179 setHighlighted(
false );
7190 QHBoxLayout *hl =
new QHBoxLayout();
7191 hl->setContentsMargins( 0, 0, 0, 0 );
7193 mLineEdit =
new QgsProcessingMultipleLayerLineEdit(
nullptr, param );
7194 mLineEdit->setEnabled(
true );
7195 mLineEdit->setReadOnly(
true );
7197 hl->addWidget( mLineEdit, 1 );
7198 connect( mLineEdit, &QgsProcessingMultipleLayerLineEdit::layersDropped,
this, &QgsProcessingMultipleLayerPanelWidget::setValue );
7200 mToolButton =
new QToolButton();
7201 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7202 hl->addWidget( mToolButton );
7208 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7211 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7214void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7216 if ( value.isValid() )
7217 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7221 updateSummaryText();
7225void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7231 if ( mValue.removeAll( layerId ) )
7233 updateSummaryText();
7240void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7246 switch ( mParam->layerType() )
7334void QgsProcessingMultipleLayerPanelWidget::showDialog()
7339 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
7340 widget->setPanelTitle( mParam->description() );
7341 widget->setProject( mProject );
7342 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
7343 setValue( widget->selectedOptions() );
7350 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7351 dlg.setProject( mProject );
7354 setValue( dlg.selectedOptions() );
7359void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7362 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7372 QVBoxLayout *vlayout =
new QVBoxLayout();
7373 vlayout->setContentsMargins( 0, 0, 0, 0 );
7375 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7376 mLayerTypeComboBox =
new QComboBox();
7390 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast<int>( layersParam->layerType() ) ) );
7392 vlayout->addWidget( mLayerTypeComboBox );
7393 setLayout( vlayout );
7398 auto param = std::make_unique<QgsProcessingParameterMultipleLayers>( name, description,
static_cast<Qgis::ProcessingSourceType>( mLayerTypeComboBox->currentData().toInt() ) );
7400 return param.release();
7408QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7412 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7413 mPanel->setToolTip( parameterDefinition()->toolTip() );
7414 mPanel->setProject( widgetContext().project() );
7416 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7417 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [
this] {
7418 emit widgetValueHasChanged(
this );
7428 mPanel->setProject( context.
project() );
7430 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7434void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7439 if ( value.isValid() )
7442 opts.reserve( v.size() );
7444 opts << l->source();
7447 for (
const QVariant &v : value.toList() )
7449 if ( v.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
7451 const QgsProcessingModelChildParameterSource source = v.value<QgsProcessingModelChildParameterSource>();
7452 opts << QVariant::fromValue( source );
7457 mPanel->setValue( value.isValid() ? opts : QVariant() );
7461QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7464 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7469QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7471 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7474QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7481 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7486 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7495 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7499QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7501 return tr(
"path to a point cloud layer" );
7504QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7511 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7516 Q_UNUSED( context );
7517 Q_UNUSED( widgetContext );
7518 Q_UNUSED( definition );
7534QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7536 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7539QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7546 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7551 Q_UNUSED( context );
7552 Q_UNUSED( widgetContext );
7553 Q_UNUSED( definition );
7564 if ( mWidgetContext.project() )
7565 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7569QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7580 mComboBox->setEditable(
true );
7584 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7586 if ( mWidgetContext.project() )
7587 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7590 mComboBox->setAllowEmptyLayer(
true );
7593 if ( mBlockSignals )
7596 emit widgetValueHasChanged(
this );
7599 setWidgetContext( widgetContext() );
7603void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7609 mComboBox->setLayer(
nullptr );
7613 QVariant val = value;
7614 if ( val.userType() == qMetaTypeId<QgsProperty>() )
7626 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( val.value<QObject *>() );
7627 if ( !layer && val.userType() == QMetaType::Type::QString )
7634 mComboBox->setLayer( layer );
7639QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7641 return mComboBox && mComboBox->currentLayer() ? ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral(
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
7654 QHBoxLayout *hl =
new QHBoxLayout();
7655 hl->setContentsMargins( 0, 0, 0, 0 );
7657 mLineEdit =
new QLineEdit();
7658 mLineEdit->setEnabled(
false );
7659 hl->addWidget( mLineEdit, 1 );
7661 mToolButton =
new QToolButton();
7662 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7663 hl->addWidget( mToolButton );
7669 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7672 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7677 mAttributes = attributes;
7680void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7682 if ( value.isValid() )
7683 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7687 updateSummaryText();
7691void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7693 QVariantList availableOptions;
7694 availableOptions.reserve( mAttributes.count() );
7695 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7698 availableOptions << attr.name();
7704 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7705 widget->setPanelTitle( mParam->description() );
7707 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
7708 return v.toString();
7711 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
7712 setValue( widget->selectedOptions() );
7719 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7721 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
7722 return v.toString();
7726 setValue( dlg.selectedOptions() );
7731void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7736 if ( mValue.empty() )
7738 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7743 values.reserve( mValue.size() );
7744 for (
const QVariant &val : std::as_const( mValue ) )
7746 values << val.toString();
7749 const QString concatenated = values.join( tr(
"," ) );
7750 if ( concatenated.length() < 100 )
7751 mLineEdit->setText( concatenated );
7753 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7765 QVBoxLayout *vlayout =
new QVBoxLayout();
7766 vlayout->setContentsMargins( 0, 0, 0, 0 );
7768 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7769 mParentLayerComboBox =
new QComboBox();
7771 QString initialParent;
7773 initialParent = attrParam->parentLayerParameterName();
7775 if (
auto *lModel = widgetContext.
model() )
7778 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7779 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7783 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
7784 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7786 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7792 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7795 mParentLayerComboBox->addItem( initialParent, initialParent );
7796 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7799 vlayout->addWidget( mParentLayerComboBox );
7801 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
7803 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
7805 vlayout->addWidget( mAllowMultipleCheckBox );
7807 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
7808 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7810 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
7812 vlayout->addWidget( mDefaultToAllCheckBox );
7814 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [
this] {
7815 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7818 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7820 mDefaultLineEdit =
new QLineEdit();
7821 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
7825 mDefaultLineEdit->setText( attributes.join(
';' ) );
7827 vlayout->addWidget( mDefaultLineEdit );
7829 setLayout( vlayout );
7834 QVariant defaultValue;
7835 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
7837 defaultValue = mDefaultLineEdit->text();
7839 auto param = std::make_unique<QgsProcessingParameterPointCloudAttribute>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
7841 return param.release();
7849QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
7862 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
7863 mPanel->setToolTip( parameterDefinition()->toolTip() );
7864 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [
this] {
7865 emit widgetValueHasChanged(
this );
7873 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7875 emit widgetValueHasChanged(
this );
7883 mLineEdit =
new QLineEdit();
7884 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
7885 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
7886 emit widgetValueHasChanged(
this );
7894void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7906 setParentLayerWrapperValue( wrapper );
7908 setParentLayerWrapperValue( wrapper );
7925 std::unique_ptr<QgsProcessingContext> tmpContext;
7926 if ( mProcessingContextGenerator )
7927 context = mProcessingContextGenerator->processingContext();
7931 tmpContext = std::make_unique<QgsProcessingContext>();
7932 context = tmpContext.get();
7938 if ( layer && layer->
isValid() )
7942 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
7945 mParentLayer.reset( qobject_cast<QgsPointCloudLayer *>( ownedLayer.release() ) );
7946 layer = mParentLayer.get();
7954 mComboBox->setLayer( layer );
7957 mPanel->setAttributes( layer->
attributes() );
7964 mComboBox->setLayer(
nullptr );
7969 if ( value.isValid() && widgetContext().messageBar() )
7980 val.reserve( mPanel->attributes().attributes().size() );
7983 setWidgetValue( val, *context );
7986 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7989void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7993 if ( !value.isValid() )
7994 mComboBox->setAttribute( QString() );
7998 mComboBox->setAttribute( v );
8004 if ( value.isValid() )
8007 opts.reserve( v.size() );
8008 for (
const QString &i : v )
8012 mPanel->setValue( opts );
8014 else if ( mLineEdit )
8020 mLineEdit->setText( v.join(
';' ) );
8029QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
8032 return mComboBox->currentAttribute();
8034 return mPanel->value();
8035 else if ( mLineEdit )
8040 return mLineEdit->text().split(
';' );
8043 return mLineEdit->text();
8049QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
8051 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
8054QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
8061 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
8066 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8079QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8087 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8088 if ( mProcessingContextGenerator )
8089 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8090 if ( mParametersGenerator )
8091 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8092 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8094 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [
this]() {
8095 if ( mBlockSignals )
8098 emit widgetValueHasChanged(
this );
8103 mOutputWidget->addOpenAfterRunningOption();
8105 return mOutputWidget;
8115void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8117 if ( mOutputWidget )
8118 mOutputWidget->setValue( value );
8121QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8123 if ( mOutputWidget )
8124 return mOutputWidget->value();
8129QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8132 if ( mOutputWidget )
8133 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
8142 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8146QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8153 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8156QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8158 return tr(
"path to layer destination" );
8166 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8170QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8177 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8180QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8182 return tr(
"path to layer destination" );
8190 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8194QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8201 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8204QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8206 return tr(
"path to layer destination" );
8214 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8218QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8225 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8228QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8230 return tr(
"path to layer destination" );
8238 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8242QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8249 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8253QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8255 return tr(
"path to file destination" );
8263 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8267QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8274 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8278QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8280 return tr(
"path to folder destination" );
8288 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8292QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8299 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8302QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8304 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).
@ TiledScene
Tiled scene layers.
@ 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.
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.
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...
Q_INVOKABLE QString asWkt(int precision=17) const
Exports the geometry to WKT.
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.
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.
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.
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.
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).