19#include "moc_qgsprocessingwidgetwrapperimpl.cpp"
81#include <QPlainTextEdit>
82#include <QRadioButton>
83#include <QButtonGroup>
97 QVBoxLayout *vlayout =
new QVBoxLayout();
98 vlayout->setContentsMargins( 0, 0, 0, 0 );
100 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
104 mDefaultCheckBox->setChecked(
false );
105 vlayout->addWidget( mDefaultCheckBox );
106 setLayout( vlayout );
111 auto param = std::make_unique<QgsProcessingParameterBoolean>( name, description, mDefaultCheckBox->isChecked() );
112 param->setFlags( flags );
113 return param.release();
122QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
128 QString description = parameterDefinition()->description();
130 description = QObject::tr(
"%1 [optional]" ).arg( description );
132 mCheckBox =
new QCheckBox( description );
133 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
135 connect( mCheckBox, &QCheckBox::toggled,
this, [=] {
136 emit widgetValueHasChanged(
this );
144 mComboBox =
new QComboBox();
145 mComboBox->addItem( tr(
"Yes" ),
true );
146 mComboBox->addItem( tr(
"No" ),
false );
147 mComboBox->setToolTip( parameterDefinition()->toolTip() );
149 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=] {
150 emit widgetValueHasChanged(
this );
159QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
168void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
175 mCheckBox->setChecked( v );
183 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
189QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
194 return mCheckBox->isChecked();
198 return mComboBox->currentData();
203QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
210 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
215 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
226 QVBoxLayout *vlayout =
new QVBoxLayout();
227 vlayout->setContentsMargins( 0, 0, 0, 0 );
229 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
234 mCrsSelector->setShowAccuracyWarnings(
true );
241 vlayout->addWidget( mCrsSelector );
242 setLayout( vlayout );
247 auto param = std::make_unique<QgsProcessingParameterCrs>( name, description, mCrsSelector->crs().authid() );
248 param->setFlags( flags );
249 return param.release();
257QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
259 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
261 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
269 emit widgetValueHasChanged(
this );
277 return mProjectionSelectionWidget;
282 QWidget *w =
new QWidget();
283 w->setToolTip( parameterDefinition()->toolTip() );
285 QVBoxLayout *vl =
new QVBoxLayout();
286 vl->setContentsMargins( 0, 0, 0, 0 );
289 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
290 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
291 vl->addWidget( mUseProjectCrsCheckBox );
292 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
293 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [=] {
294 emit widgetValueHasChanged(
this );
297 vl->addWidget( mProjectionSelectionWidget );
305void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
307 if ( mUseProjectCrsCheckBox )
309 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
311 mUseProjectCrsCheckBox->setChecked(
true );
316 mUseProjectCrsCheckBox->setChecked(
false );
321 if ( mProjectionSelectionWidget )
322 mProjectionSelectionWidget->setCrs( v );
325QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
327 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
328 return QStringLiteral(
"ProjectCrs" );
329 else if ( mProjectionSelectionWidget )
330 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
335QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
337 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
340QString QgsProcessingCrsWidgetWrapper::parameterType()
const
347 return new QgsProcessingCrsWidgetWrapper( parameter, type );
352 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
364 QVBoxLayout *vlayout =
new QVBoxLayout();
365 vlayout->setContentsMargins( 0, 0, 0, 0 );
367 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
369 mDefaultLineEdit =
new QLineEdit();
372 vlayout->addWidget( mDefaultLineEdit );
374 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
376 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
377 vlayout->addWidget( mMultiLineCheckBox );
379 setLayout( vlayout );
384 auto param = std::make_unique<QgsProcessingParameterString>( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
385 param->setFlags( flags );
386 return param.release();
395QWidget *QgsProcessingStringWidgetWrapper::createWidget()
397 const QVariantMap metadata = parameterDefinition()->metadata();
398 const QVariant valueHintsVariant = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"value_hints" ) );
400 if ( valueHintsVariant.isValid() )
402 const QVariantList valueList = valueHintsVariant.toList();
403 mComboBox =
new QComboBox();
404 mComboBox->setToolTip( parameterDefinition()->toolTip() );
408 mComboBox->addItem( QString() );
410 for (
const QVariant &entry : valueList )
412 mComboBox->addItem( entry.toString(), entry.toString() );
414 mComboBox->setCurrentIndex( 0 );
416 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
417 emit widgetValueHasChanged(
this );
430 mPlainTextEdit =
new QPlainTextEdit();
431 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
433 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [=] {
434 emit widgetValueHasChanged(
this );
436 return mPlainTextEdit;
440 mLineEdit =
new QLineEdit();
441 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
443 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
444 emit widgetValueHasChanged(
this );
452 mLineEdit =
new QLineEdit();
453 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
455 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
456 emit widgetValueHasChanged(
this );
466void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
470 mLineEdit->setText( v );
471 if ( mPlainTextEdit )
472 mPlainTextEdit->setPlainText( v );
476 if ( !value.isValid() )
477 index = mComboBox->findData( QVariant() );
479 index = mComboBox->findData( v );
482 mComboBox->setCurrentIndex( index );
484 mComboBox->setCurrentIndex( 0 );
488QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
491 return mLineEdit->text();
492 else if ( mPlainTextEdit )
493 return mPlainTextEdit->toPlainText();
494 else if ( mComboBox )
495 return mComboBox->currentData();
500QString QgsProcessingStringWidgetWrapper::parameterType()
const
507 return new QgsProcessingStringWidgetWrapper( parameter, type );
512 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
525QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
534 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
537 emit widgetValueHasChanged(
this );
539 return mAuthConfigSelect;
545void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
548 if ( mAuthConfigSelect )
549 mAuthConfigSelect->setConfigId( v );
552QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
554 if ( mAuthConfigSelect )
555 return mAuthConfigSelect->configId();
560QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
567 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
577 QVBoxLayout *vlayout =
new QVBoxLayout();
578 vlayout->setContentsMargins( 0, 0, 0, 0 );
580 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
582 mTypeComboBox =
new QComboBox();
585 vlayout->addWidget( mTypeComboBox );
587 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
588 mMinLineEdit =
new QLineEdit();
589 vlayout->addWidget( mMinLineEdit );
591 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
592 mMaxLineEdit =
new QLineEdit();
593 vlayout->addWidget( mMaxLineEdit );
595 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
596 mDefaultLineEdit =
new QLineEdit();
597 vlayout->addWidget( mDefaultLineEdit );
601 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( numberParam->dataType() ) ) );
603 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
605 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
609 mMaxLineEdit->clear();
612 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
614 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
618 mMinLineEdit->clear();
621 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
624 setLayout( vlayout );
633 auto param = std::make_unique<QgsProcessingParameterNumber>( name, description, dataType, ok ? val : QVariant() );
635 if ( !mMinLineEdit->text().trimmed().isEmpty() )
640 param->setMinimum( val );
644 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
649 param->setMaximum( val );
653 param->setFlags( flags );
654 return param.release();
662QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
665 const QVariantMap metadata = numberDef->
metadata();
666 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
674 QAbstractSpinBox *spinBox =
nullptr;
679 mDoubleSpinBox->setExpressionsEnabled(
true );
680 mDoubleSpinBox->setDecimals( decimals );
685 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
686 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
687 mDoubleSpinBox->setSingleStep( singleStep );
690 spinBox = mDoubleSpinBox;
695 mSpinBox->setExpressionsEnabled(
true );
699 spinBox->setToolTip( parameterDefinition()->toolTip() );
701 double max = 999999999;
706 double min = -999999999;
711 if ( mDoubleSpinBox )
713 mDoubleSpinBox->setMinimum( min );
714 mDoubleSpinBox->setMaximum( max );
718 mSpinBox->setMinimum(
static_cast<int>( min ) );
719 mSpinBox->setMaximum(
static_cast<int>( max ) );
724 mAllowingNull =
true;
725 if ( mDoubleSpinBox )
727 mDoubleSpinBox->setShowClearButton(
true );
728 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
729 mDoubleSpinBox->setMinimum( min );
730 mDoubleSpinBox->setValue( min );
734 mSpinBox->setShowClearButton(
true );
735 const int min = mSpinBox->minimum() - 1;
736 mSpinBox->setMinimum( min );
737 mSpinBox->setValue( min );
739 spinBox->setSpecialValueText( tr(
"Not set" ) );
747 if ( mDoubleSpinBox )
751 mDoubleSpinBox->setClearValue( defaultVal );
757 mSpinBox->setClearValue( intVal );
763 if ( mDoubleSpinBox )
764 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
766 mSpinBox->setClearValue(
static_cast<int>( numberDef->
minimum() ) );
771 if ( mDoubleSpinBox )
773 mDoubleSpinBox->setValue( 0 );
774 mDoubleSpinBox->setClearValue( 0 );
778 mSpinBox->setValue( 0 );
779 mSpinBox->setClearValue( 0 );
784 if ( mDoubleSpinBox )
785 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=] { emit widgetValueHasChanged(
this ); } );
787 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [=] { emit widgetValueHasChanged(
this ); } );
795void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
797 if ( mDoubleSpinBox )
799 if ( mAllowingNull && !value.isValid() )
800 mDoubleSpinBox->clear();
804 mDoubleSpinBox->setValue( v );
809 if ( mAllowingNull && !value.isValid() )
814 mSpinBox->setValue( v );
819QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
821 if ( mDoubleSpinBox )
823 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
826 return mDoubleSpinBox->value();
830 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
833 return mSpinBox->value();
839double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
841 const double valueRange = maximum - minimum;
842 if ( valueRange <= 1.0 )
844 const double step = valueRange / 10.0;
846 return qgsRound( step, -std::floor( std::log( step ) ) );
854QString QgsProcessingNumericWidgetWrapper::parameterType()
const
861 return new QgsProcessingNumericWidgetWrapper( parameter, type );
866 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
876 QVBoxLayout *vlayout =
new QVBoxLayout();
877 vlayout->setContentsMargins( 0, 0, 0, 0 );
879 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
881 mParentLayerComboBox =
new QComboBox();
883 QString initialParent;
885 initialParent = distParam->parentParameterName();
887 if (
auto *lModel = widgetContext.
model() )
890 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
891 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
895 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
896 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
898 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
903 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
904 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
906 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
911 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
912 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
914 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
919 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
920 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
922 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
928 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
931 mParentLayerComboBox->addItem( initialParent, initialParent );
932 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
935 vlayout->addWidget( mParentLayerComboBox );
937 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
938 mMinLineEdit =
new QLineEdit();
939 vlayout->addWidget( mMinLineEdit );
941 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
942 mMaxLineEdit =
new QLineEdit();
943 vlayout->addWidget( mMaxLineEdit );
945 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
946 mDefaultLineEdit =
new QLineEdit();
947 vlayout->addWidget( mDefaultLineEdit );
951 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
952 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
953 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
956 setLayout( vlayout );
964 auto param = std::make_unique<QgsProcessingParameterDistance>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
969 param->setMinimum( val );
975 param->setMaximum( val );
978 param->setFlags( flags );
979 return param.release();
983 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
987QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
994 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
997QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1001 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1006 mLabel =
new QLabel();
1007 mUnitsCombo =
new QComboBox();
1019 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1020 QHBoxLayout *layout =
new QHBoxLayout();
1021 layout->addWidget( spin, 1 );
1022 layout->insertSpacing( 1, labelMargin / 2 );
1023 layout->insertWidget( 2, mLabel );
1024 layout->insertWidget( 3, mUnitsCombo );
1029 mWarningLabel =
new QWidget();
1030 QHBoxLayout *warningLayout =
new QHBoxLayout();
1031 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1032 QLabel *warning =
new QLabel();
1034 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1035 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1036 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1037 warningLayout->insertSpacing( 0, labelMargin / 2 );
1038 warningLayout->insertWidget( 1, warning );
1039 mWarningLabel->setLayout( warningLayout );
1040 layout->insertWidget( 4, mWarningLabel );
1042 QWidget *w =
new QWidget();
1043 layout->setContentsMargins( 0, 0, 0, 0 );
1044 w->setLayout( layout );
1058void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1060 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1067 if ( wrapper->parameterDefinition()->name() ==
static_cast<const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1069 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1071 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1091 std::unique_ptr<QgsProcessingContext> tmpContext;
1092 if ( mProcessingContextGenerator )
1093 context = mProcessingContextGenerator->processingContext();
1097 tmpContext = std::make_unique<QgsProcessingContext>();
1098 context = tmpContext.get();
1117 mUnitsCombo->hide();
1122 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( units ) ) );
1123 mUnitsCombo->show();
1130QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1132 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1133 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1146 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1157 QVBoxLayout *vlayout =
new QVBoxLayout();
1158 vlayout->setContentsMargins( 0, 0, 0, 0 );
1160 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1162 mParentLayerComboBox =
new QComboBox();
1164 QString initialParent;
1166 initialParent = areaParam->parentParameterName();
1168 if (
auto *lModel = widgetContext.
model() )
1171 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1172 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1176 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1177 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1179 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1184 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1185 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1187 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1192 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1193 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1195 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1200 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1201 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1203 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1209 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1212 mParentLayerComboBox->addItem( initialParent, initialParent );
1213 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1216 vlayout->addWidget( mParentLayerComboBox );
1218 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1219 mMinLineEdit =
new QLineEdit();
1220 vlayout->addWidget( mMinLineEdit );
1222 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1223 mMaxLineEdit =
new QLineEdit();
1224 vlayout->addWidget( mMaxLineEdit );
1226 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1227 mDefaultLineEdit =
new QLineEdit();
1228 vlayout->addWidget( mDefaultLineEdit );
1232 mMinLineEdit->setText( QLocale().toString( areaParam->minimum() ) );
1233 mMaxLineEdit->setText( QLocale().toString( areaParam->maximum() ) );
1234 mDefaultLineEdit->setText( areaParam->defaultValueForGui().toString() );
1237 setLayout( vlayout );
1245 auto param = std::make_unique<QgsProcessingParameterArea>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1250 param->setMinimum( val );
1256 param->setMaximum( val );
1259 param->setFlags( flags );
1260 return param.release();
1269 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1273QString QgsProcessingAreaWidgetWrapper::parameterType()
const
1280 return new QgsProcessingAreaWidgetWrapper( parameter, type );
1283QWidget *QgsProcessingAreaWidgetWrapper::createWidget()
1287 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1292 mLabel =
new QLabel();
1293 mUnitsCombo =
new QComboBox();
1308 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1309 QHBoxLayout *layout =
new QHBoxLayout();
1310 layout->addWidget( spin, 1 );
1311 layout->insertSpacing( 1, labelMargin / 2 );
1312 layout->insertWidget( 2, mLabel );
1313 layout->insertWidget( 3, mUnitsCombo );
1318 mWarningLabel =
new QWidget();
1319 QHBoxLayout *warningLayout =
new QHBoxLayout();
1320 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1321 QLabel *warning =
new QLabel();
1323 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1324 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1325 warning->setToolTip( tr(
"Area is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1326 warningLayout->insertSpacing( 0, labelMargin / 2 );
1327 warningLayout->insertWidget( 1, warning );
1328 mWarningLabel->setLayout( warningLayout );
1329 layout->insertWidget( 4, mWarningLabel );
1331 QWidget *w =
new QWidget();
1332 layout->setContentsMargins( 0, 0, 0, 0 );
1333 w->setLayout( layout );
1347void QgsProcessingAreaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1349 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1380 std::unique_ptr<QgsProcessingContext> tmpContext;
1381 if ( mProcessingContextGenerator )
1382 context = mProcessingContextGenerator->processingContext();
1386 tmpContext = std::make_unique<QgsProcessingContext>();
1387 context = tmpContext.get();
1401void QgsProcessingAreaWidgetWrapper::setUnits(
Qgis::AreaUnit units )
1406 mUnitsCombo->hide();
1411 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1412 mUnitsCombo->show();
1419QVariant QgsProcessingAreaWidgetWrapper::widgetValue()
const
1421 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1422 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1435 return new QgsProcessingAreaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1446 QVBoxLayout *vlayout =
new QVBoxLayout();
1447 vlayout->setContentsMargins( 0, 0, 0, 0 );
1449 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1451 mParentLayerComboBox =
new QComboBox();
1453 QString initialParent;
1455 initialParent = volumeParam->parentParameterName();
1457 if (
auto *lModel = widgetContext.
model() )
1460 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1461 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1465 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1466 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1468 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1473 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1474 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1476 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1481 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1482 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1484 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1489 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1490 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1492 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1498 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1501 mParentLayerComboBox->addItem( initialParent, initialParent );
1502 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1505 vlayout->addWidget( mParentLayerComboBox );
1507 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1508 mMinLineEdit =
new QLineEdit();
1509 vlayout->addWidget( mMinLineEdit );
1511 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1512 mMaxLineEdit =
new QLineEdit();
1513 vlayout->addWidget( mMaxLineEdit );
1515 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1516 mDefaultLineEdit =
new QLineEdit();
1517 vlayout->addWidget( mDefaultLineEdit );
1521 mMinLineEdit->setText( QLocale().toString( volumeParam->minimum() ) );
1522 mMaxLineEdit->setText( QLocale().toString( volumeParam->maximum() ) );
1523 mDefaultLineEdit->setText( volumeParam->defaultValueForGui().toString() );
1526 setLayout( vlayout );
1534 auto param = std::make_unique<QgsProcessingParameterVolume>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1539 param->setMinimum( val );
1545 param->setMaximum( val );
1548 param->setFlags( flags );
1549 return param.release();
1558 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1562QString QgsProcessingVolumeWidgetWrapper::parameterType()
const
1569 return new QgsProcessingVolumeWidgetWrapper( parameter, type );
1572QWidget *QgsProcessingVolumeWidgetWrapper::createWidget()
1576 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1581 mLabel =
new QLabel();
1582 mUnitsCombo =
new QComboBox();
1595 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1596 QHBoxLayout *layout =
new QHBoxLayout();
1597 layout->addWidget( spin, 1 );
1598 layout->insertSpacing( 1, labelMargin / 2 );
1599 layout->insertWidget( 2, mLabel );
1600 layout->insertWidget( 3, mUnitsCombo );
1605 mWarningLabel =
new QWidget();
1606 QHBoxLayout *warningLayout =
new QHBoxLayout();
1607 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1608 QLabel *warning =
new QLabel();
1610 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1611 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1612 warning->setToolTip( tr(
"Volume is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1613 warningLayout->insertSpacing( 0, labelMargin / 2 );
1614 warningLayout->insertWidget( 1, warning );
1615 mWarningLabel->setLayout( warningLayout );
1616 layout->insertWidget( 4, mWarningLabel );
1618 QWidget *w =
new QWidget();
1619 layout->setContentsMargins( 0, 0, 0, 0 );
1620 w->setLayout( layout );
1634void QgsProcessingVolumeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1636 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1667 std::unique_ptr<QgsProcessingContext> tmpContext;
1668 if ( mProcessingContextGenerator )
1669 context = mProcessingContextGenerator->processingContext();
1673 tmpContext = std::make_unique<QgsProcessingContext>();
1674 context = tmpContext.get();
1693 mUnitsCombo->hide();
1698 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1699 mUnitsCombo->show();
1706QVariant QgsProcessingVolumeWidgetWrapper::widgetValue()
const
1708 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1709 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1722 return new QgsProcessingVolumeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1733 QVBoxLayout *vlayout =
new QVBoxLayout();
1734 vlayout->setContentsMargins( 0, 0, 0, 0 );
1736 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1737 mMinLineEdit =
new QLineEdit();
1738 vlayout->addWidget( mMinLineEdit );
1740 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1741 mMaxLineEdit =
new QLineEdit();
1742 vlayout->addWidget( mMaxLineEdit );
1744 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1745 mDefaultLineEdit =
new QLineEdit();
1746 vlayout->addWidget( mDefaultLineEdit );
1748 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1750 mUnitsCombo =
new QComboBox();
1760 vlayout->addWidget( mUnitsCombo );
1764 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1765 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1766 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1767 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationParam->defaultUnit() ) ) );
1770 setLayout( vlayout );
1778 auto param = std::make_unique<QgsProcessingParameterDuration>( name, description, ok ? val : QVariant() );
1783 param->setMinimum( val );
1789 param->setMaximum( val );
1792 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit>( mUnitsCombo->currentData().toInt() ) );
1794 param->setFlags( flags );
1795 return param.release();
1799 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1803QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1810 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1813QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1817 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1822 mUnitsCombo =
new QComboBox();
1834 QHBoxLayout *layout =
new QHBoxLayout();
1835 layout->addWidget( spin, 1 );
1836 layout->insertWidget( 1, mUnitsCombo );
1838 QWidget *w =
new QWidget();
1839 layout->setContentsMargins( 0, 0, 0, 0 );
1840 w->setLayout( layout );
1842 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationDef->
defaultUnit() ) ) );
1843 mUnitsCombo->show();
1855QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
1867QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
1869 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1870 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo )
1881void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1887 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
1891 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
1897 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1907 QVBoxLayout *vlayout =
new QVBoxLayout();
1908 vlayout->setContentsMargins( 0, 0, 0, 0 );
1910 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1912 mDefaultLineEdit =
new QLineEdit();
1916 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1919 vlayout->addWidget( mDefaultLineEdit );
1921 setLayout( vlayout );
1927 double val = mDefaultLineEdit->text().toDouble( &ok );
1928 auto param = std::make_unique<QgsProcessingParameterScale>( name, description, ok ? val : QVariant() );
1930 return param.release();
1934 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1938QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1945 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1948QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
1960 mScaleWidget->setAllowNull(
true );
1962 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
1963 mScaleWidget->setShowCurrentScaleButton(
true );
1965 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
1967 emit widgetValueHasChanged(
this );
1969 return mScaleWidget;
1978 mScaleWidget->setMapCanvas( context.
mapCanvas() );
1983QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
1985 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
1988void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1992 if ( mScaleWidget->allowNull() && !value.isValid() )
1993 mScaleWidget->setNull();
1997 mScaleWidget->setScale( v );
2004 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2015 QVBoxLayout *vlayout =
new QVBoxLayout();
2016 vlayout->setContentsMargins( 0, 0, 0, 0 );
2018 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
2020 mTypeComboBox =
new QComboBox();
2023 vlayout->addWidget( mTypeComboBox );
2025 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
2026 mMinLineEdit =
new QLineEdit();
2027 vlayout->addWidget( mMinLineEdit );
2029 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
2030 mMaxLineEdit =
new QLineEdit();
2031 vlayout->addWidget( mMaxLineEdit );
2035 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( rangeParam->dataType() ) ) );
2037 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
2038 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
2041 setLayout( vlayout );
2046 QString defaultValue;
2047 if ( mMinLineEdit->text().isEmpty() )
2049 defaultValue = QStringLiteral(
"None" );
2057 defaultValue = QStringLiteral(
"None" );
2061 if ( mMaxLineEdit->text().isEmpty() )
2063 defaultValue += QLatin1String(
",None" );
2069 defaultValue += QStringLiteral(
",%1" ).arg( ok ? QString::number( val ) : QLatin1String(
"None" ) );
2073 auto param = std::make_unique<QgsProcessingParameterRange>( name, description, dataType, defaultValue );
2074 param->setFlags( flags );
2075 return param.release();
2084QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
2093 QHBoxLayout *layout =
new QHBoxLayout();
2098 mMinSpinBox->setExpressionsEnabled(
true );
2099 mMinSpinBox->setShowClearButton(
false );
2100 mMaxSpinBox->setExpressionsEnabled(
true );
2101 mMaxSpinBox->setShowClearButton(
false );
2103 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
2104 layout->addWidget( minLabel );
2105 layout->addWidget( mMinSpinBox, 1 );
2107 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
2108 layout->addWidget( maxLabel );
2109 layout->addWidget( mMaxSpinBox, 1 );
2111 QWidget *w =
new QWidget();
2112 layout->setContentsMargins( 0, 0, 0, 0 );
2113 w->setLayout( layout );
2117 mMinSpinBox->setDecimals( 6 );
2118 mMaxSpinBox->setDecimals( 6 );
2122 mMinSpinBox->setDecimals( 0 );
2123 mMaxSpinBox->setDecimals( 0 );
2126 mMinSpinBox->setMinimum( -99999999.999999 );
2127 mMaxSpinBox->setMinimum( -99999999.999999 );
2128 mMinSpinBox->setMaximum( 99999999.999999 );
2129 mMaxSpinBox->setMaximum( 99999999.999999 );
2133 mAllowingNull =
true;
2135 const double min = mMinSpinBox->minimum() - 1;
2136 mMinSpinBox->setMinimum( min );
2137 mMaxSpinBox->setMinimum( min );
2138 mMinSpinBox->setValue( min );
2139 mMaxSpinBox->setValue( min );
2141 mMinSpinBox->setShowClearButton(
true );
2142 mMaxSpinBox->setShowClearButton(
true );
2143 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
2144 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
2147 w->setToolTip( parameterDefinition()->toolTip() );
2149 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=](
const double v ) {
2150 mBlockChangedSignal++;
2151 if ( !mAllowingNull && v > mMaxSpinBox->value() )
2152 mMaxSpinBox->setValue( v );
2153 mBlockChangedSignal--;
2155 if ( !mBlockChangedSignal )
2156 emit widgetValueHasChanged(
this );
2158 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=](
const double v ) {
2159 mBlockChangedSignal++;
2160 if ( !mAllowingNull && v < mMinSpinBox->value() )
2161 mMinSpinBox->setValue( v );
2162 mBlockChangedSignal--;
2164 if ( !mBlockChangedSignal )
2165 emit widgetValueHasChanged(
this );
2174void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2177 if ( mAllowingNull && v.empty() )
2179 mMinSpinBox->clear();
2180 mMaxSpinBox->clear();
2187 if ( mAllowingNull )
2189 mBlockChangedSignal++;
2190 if ( std::isnan( v.at( 0 ) ) )
2191 mMinSpinBox->clear();
2193 mMinSpinBox->setValue( v.at( 0 ) );
2195 if ( v.count() >= 2 )
2197 if ( std::isnan( v.at( 1 ) ) )
2198 mMaxSpinBox->clear();
2200 mMaxSpinBox->setValue( v.at( 1 ) );
2202 mBlockChangedSignal--;
2206 mBlockChangedSignal++;
2207 mMinSpinBox->setValue( v.at( 0 ) );
2208 if ( v.count() >= 2 )
2209 mMaxSpinBox->setValue( v.at( 1 ) );
2210 mBlockChangedSignal--;
2214 if ( !mBlockChangedSignal )
2215 emit widgetValueHasChanged(
this );
2218QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
2220 if ( mAllowingNull )
2223 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
2224 value = QStringLiteral(
"None" );
2226 value = QString::number( mMinSpinBox->value() );
2228 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
2229 value += QLatin1String(
",None" );
2231 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
2236 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
2239QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
2241 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
2244QString QgsProcessingRangeWidgetWrapper::parameterType()
const
2251 return new QgsProcessingRangeWidgetWrapper( parameter, type );
2256 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2267 QVBoxLayout *vlayout =
new QVBoxLayout();
2268 vlayout->setContentsMargins( 0, 0, 0, 0 );
2270 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
2273 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
2274 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
2276 vlayout->addWidget( mMatrixWidget );
2277 setLayout( vlayout );
2282 auto param = std::make_unique<QgsProcessingParameterMatrix>( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
2283 param->setFlags( flags );
2284 return param.release();
2293QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
2295 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast<const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
2296 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
2298 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [=] {
2299 emit widgetValueHasChanged(
this );
2308 return mMatrixWidget;
2314void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2317 if ( mMatrixWidget )
2318 mMatrixWidget->setValue( v );
2321QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
2323 if ( mMatrixWidget )
2324 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
2329QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
2331 return tr(
"comma delimited string of values, or an array of values" );
2334QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
2341 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
2346 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2358 QVBoxLayout *vlayout =
new QVBoxLayout();
2359 vlayout->setContentsMargins( 0, 0, 0, 0 );
2361 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
2363 mTypeComboBox =
new QComboBox();
2367 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( fileParam->behavior() ) ) );
2369 mTypeComboBox->setCurrentIndex( 0 );
2370 vlayout->addWidget( mTypeComboBox );
2372 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
2374 mFilterComboBox =
new QComboBox();
2375 mFilterComboBox->setEditable(
true );
2377 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
2378 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
2379 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
2380 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
2382 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
2384 mFilterComboBox->setCurrentIndex( 0 );
2385 vlayout->addWidget( mFilterComboBox );
2387 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2390 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
2394 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
2398 vlayout->addWidget( mDefaultFileWidget );
2400 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=] {
2408 setLayout( vlayout );
2413 auto param = std::make_unique<QgsProcessingParameterFile>( name, description );
2416 param->setFileFilter( mFilterComboBox->currentText() );
2417 if ( !mDefaultFileWidget->filePath().isEmpty() )
2418 param->setDefaultValue( mDefaultFileWidget->filePath() );
2419 param->setFlags( flags );
2420 return param.release();
2429QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2439 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2440 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2442 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
2449 mFileWidget->setFilter( fileParam->
fileFilter() );
2450 else if ( !fileParam->
extension().isEmpty() )
2451 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
2460 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
2461 emit widgetValueHasChanged(
this );
2469void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2473 mFileWidget->setFilePath( v );
2476QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2479 return mFileWidget->filePath();
2484QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2486 return tr(
"string representing a path to a file or folder" );
2489QString QgsProcessingFileWidgetWrapper::parameterType()
const
2496 return new QgsProcessingFileWidgetWrapper( parameter, type );
2501 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2512 QVBoxLayout *vlayout =
new QVBoxLayout();
2513 vlayout->setContentsMargins( 0, 0, 0, 0 );
2514 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2517 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2519 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2520 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2522 QStackedWidget *stackedWidget =
new QStackedWidget();
2523 stackedWidget->addWidget( mDefaultQgisLineEdit );
2524 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2525 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2526 vlayout->addWidget( stackedWidget );
2531 mDefaultQgisLineEdit->setExpression( expr );
2532 mDefaultPointCloudLineEdit->setExpression( expr );
2535 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2537 mParentLayerComboBox =
new QComboBox();
2538 vlayout->addWidget( mParentLayerComboBox );
2540 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2541 mExpressionTypeComboBox =
new QComboBox();
2546 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
2547 mParentLayerComboBox->clear();
2548 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2550 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2552 QString initialParent;
2554 initialParent = expParam->parentLayerParameterName();
2558 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2561 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2562 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2569 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2570 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2572 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2577 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2578 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2580 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2587 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2588 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2590 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 );
2612 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2615 mParentLayerComboBox->addItem( initialParent, initialParent );
2616 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2620 mExpressionTypeComboBox->setCurrentIndex( -1 );
2622 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast<int>( expParam->expressionType() ) ) );
2624 mExpressionTypeComboBox->setCurrentIndex( 0 );
2626 vlayout->addWidget( mExpressionTypeComboBox );
2628 setLayout( vlayout );
2635 switch ( expressionType )
2638 expression = mDefaultQgisLineEdit->expression();
2641 expression = mDefaultPointCloudLineEdit->expression();
2644 expression = mDefaultRasterCalculatorLineEdit->expression();
2647 auto param = std::make_unique<QgsProcessingParameterExpression>( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2648 param->setFlags( flags );
2649 return param.release();
2657QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2669 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2670 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2671 mExpLineEdit->registerExpressionContextGenerator(
this );
2673 emit widgetValueHasChanged(
this );
2675 return mExpLineEdit;
2681 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2682 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2683 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [=](
const QString & ) {
2684 emit widgetValueHasChanged(
this );
2686 return mPointCloudExpLineEdit;
2691 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2692 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2695 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2697 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [=](
const QString & ) {
2698 emit widgetValueHasChanged(
this );
2700 return mRasterCalculatorExpLineEdit;
2704 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
2707 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2708 mExpBuilderWidget->init( createExpressionContext() );
2710 Q_UNUSED( changed );
2711 emit widgetValueHasChanged(
this );
2713 return mExpBuilderWidget;
2718 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2719 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2720 mFieldExpWidget->registerExpressionContextGenerator(
this );
2722 mFieldExpWidget->setAllowEmptyFieldName(
true );
2725 emit widgetValueHasChanged(
this );
2727 return mFieldExpWidget;
2735void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2747 setParentLayerWrapperValue( wrapper );
2749 setParentLayerWrapperValue( wrapper );
2765 if ( mExpBuilderWidget )
2768 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2776 std::unique_ptr<QgsProcessingContext> tmpContext;
2777 if ( mProcessingContextGenerator )
2778 context = mProcessingContextGenerator->processingContext();
2782 tmpContext = std::make_unique<QgsProcessingContext>();
2783 context = tmpContext.get();
2793 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2803 if ( mFieldExpWidget )
2804 mFieldExpWidget->setLayer(
nullptr );
2805 else if ( mExpBuilderWidget )
2806 mExpBuilderWidget->setLayer(
nullptr );
2807 else if ( mExpLineEdit )
2808 mExpLineEdit->setLayer(
nullptr );
2814 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2817 mParentLayer = std::move( ownedLayer );
2825 if ( mFieldExpWidget )
2826 mFieldExpWidget->setLayer( layer );
2827 if ( mExpBuilderWidget )
2828 mExpBuilderWidget->setLayer( layer );
2829 else if ( mExpLineEdit )
2830 mExpLineEdit->setLayer( layer );
2839 if ( mPointCloudExpLineEdit )
2840 mPointCloudExpLineEdit->setLayer(
nullptr );
2846 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2849 mParentLayer = std::move( ownedLayer );
2857 if ( mPointCloudExpLineEdit )
2858 mPointCloudExpLineEdit->setLayer( layer );
2865 if ( layers.isEmpty() )
2867 if ( mRasterCalculatorExpLineEdit )
2869 mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
2874 if ( mRasterCalculatorExpLineEdit )
2876 QVariantList layersList;
2879 layersList << layer->
name();
2881 mRasterCalculatorExpLineEdit->setLayers( layersList );
2889void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2892 if ( mFieldExpWidget )
2893 mFieldExpWidget->setExpression( v );
2894 else if ( mExpBuilderWidget )
2895 mExpBuilderWidget->setExpressionText( v );
2896 else if ( mExpLineEdit )
2897 mExpLineEdit->setExpression( v );
2898 else if ( mPointCloudExpLineEdit )
2899 mPointCloudExpLineEdit->setExpression( v );
2900 else if ( mRasterCalculatorExpLineEdit )
2901 mRasterCalculatorExpLineEdit->setExpression( v );
2904QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2906 if ( mFieldExpWidget )
2907 return mFieldExpWidget->expression();
2908 if ( mExpBuilderWidget )
2909 return mExpBuilderWidget->expressionText();
2910 else if ( mExpLineEdit )
2911 return mExpLineEdit->expression();
2912 else if ( mPointCloudExpLineEdit )
2913 return mPointCloudExpLineEdit->expression();
2914 else if ( mRasterCalculatorExpLineEdit )
2915 return mRasterCalculatorExpLineEdit->expression();
2920QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2922 return tr(
"string representation of an expression" );
2925const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
2927 if ( mFieldExpWidget && mFieldExpWidget->layer() )
2928 return mFieldExpWidget->layer();
2930 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
2931 return mExpBuilderWidget->layer();
2936QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
2943 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
2948 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2960 QHBoxLayout *hl =
new QHBoxLayout();
2961 hl->setContentsMargins( 0, 0, 0, 0 );
2963 mLineEdit =
new QLineEdit();
2964 mLineEdit->setEnabled(
false );
2965 hl->addWidget( mLineEdit, 1 );
2967 mToolButton =
new QToolButton();
2968 mToolButton->setText( QString( QChar( 0x2026 ) ) );
2969 hl->addWidget( mToolButton );
2975 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2978 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
2981void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
2983 if ( value.isValid() )
2985 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
2987 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
2993 updateSummaryText();
2997void QgsProcessingEnumPanelWidget::showDialog()
2999 QVariantList availableOptions;
3002 availableOptions.reserve( mParam->options().size() );
3004 if ( mParam->usesStaticStrings() )
3006 for ( QString o : mParam->options() )
3008 availableOptions << o;
3013 for (
int i = 0; i < mParam->options().count(); ++i )
3014 availableOptions << i;
3018 const QStringList options = mParam ? mParam->options() : QStringList();
3022 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3023 widget->setPanelTitle( mParam->description() );
3025 if ( mParam->usesStaticStrings() )
3027 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3028 const QString i = v.toString();
3029 return options.contains( i ) ? i : QString();
3034 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3035 const int i = v.toInt();
3036 return options.size() > i ? options.at( i ) : QString();
3040 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
3041 setValue( widget->selectedOptions() );
3048 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3050 dlg.setValueFormatter( [options](
const QVariant &v ) -> QString {
3051 const int i = v.toInt();
3052 return options.size() > i ? options.at( i ) : QString();
3056 setValue( dlg.selectedOptions() );
3061void QgsProcessingEnumPanelWidget::updateSummaryText()
3066 if ( mValue.empty() )
3068 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3073 values.reserve( mValue.size() );
3074 if ( mParam->usesStaticStrings() )
3076 for (
const QVariant &val : std::as_const( mValue ) )
3078 values << val.toString();
3083 const QStringList options = mParam->options();
3084 for (
const QVariant &val : std::as_const( mValue ) )
3086 const int i = val.toInt();
3087 values << ( options.size() > i ? options.at( i ) : QString() );
3091 const QString concatenated = values.join( tr(
"," ) );
3092 if ( concatenated.length() < 100 )
3093 mLineEdit->setText( concatenated );
3095 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
3103QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
3106 , mButtonGroup( new QButtonGroup( this ) )
3107 , mColumns( columns )
3109 mButtonGroup->setExclusive( !mParam->allowMultiple() );
3111 QGridLayout *l =
new QGridLayout();
3112 l->setContentsMargins( 0, 0, 0, 0 );
3114 int rows =
static_cast<int>( std::ceil( mParam->options().count() /
static_cast<double>( mColumns ) ) );
3115 for (
int i = 0; i < mParam->options().count(); ++i )
3117 QAbstractButton *button =
nullptr;
3118 if ( mParam->allowMultiple() )
3119 button =
new QCheckBox( mParam->options().at( i ) );
3121 button =
new QRadioButton( mParam->options().at( i ) );
3123 connect( button, &QAbstractButton::toggled,
this, [=] {
3124 if ( !mBlockChangedSignal )
3128 mButtons.insert( i, button );
3130 mButtonGroup->addButton( button, i );
3131 l->addWidget( button, i % rows, i / rows );
3133 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
3136 if ( mParam->allowMultiple() )
3138 setContextMenuPolicy( Qt::CustomContextMenu );
3139 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
3143QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
3145 if ( mParam->allowMultiple() )
3148 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3150 if ( it.value()->isChecked() )
3151 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
3157 if ( mParam->usesStaticStrings() )
3158 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
3160 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
3164void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
3166 mBlockChangedSignal =
true;
3167 if ( mParam->allowMultiple() )
3169 QVariantList selected;
3170 if ( value.isValid() )
3171 selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3172 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3174 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
3175 it.value()->setChecked( selected.contains( v ) );
3181 if ( v.userType() == QMetaType::Type::QVariantList )
3182 v = v.toList().value( 0 );
3184 v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
3185 if ( mButtons.contains( v ) )
3186 mButtons.value( v )->setChecked(
true );
3188 mBlockChangedSignal =
false;
3192void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
3195 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
3196 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
3197 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
3198 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
3199 popupMenu.addAction( selectAllAction );
3200 popupMenu.addAction( clearAllAction );
3201 popupMenu.exec( QCursor::pos() );
3204void QgsProcessingEnumCheckboxPanelWidget::selectAll()
3206 mBlockChangedSignal =
true;
3207 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3208 it.value()->setChecked(
true );
3209 mBlockChangedSignal =
false;
3213void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
3215 mBlockChangedSignal =
true;
3216 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3217 it.value()->setChecked(
false );
3218 mBlockChangedSignal =
false;
3230 QVBoxLayout *vlayout =
new QVBoxLayout();
3231 vlayout->setContentsMargins( 0, 0, 0, 0 );
3233 mEnumWidget =
new QgsProcessingEnumModelerWidget();
3236 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
3237 mEnumWidget->setOptions( enumParam->options() );
3238 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
3240 vlayout->addWidget( mEnumWidget );
3241 setLayout( vlayout );
3246 auto param = std::make_unique<QgsProcessingParameterEnum>( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
3248 return param.release();
3257QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
3265 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
3267 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
3268 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
3269 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
3270 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [=] {
3271 emit widgetValueHasChanged(
this );
3273 return mCheckboxPanel;
3282 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
3283 mPanel->setToolTip( parameterDefinition()->toolTip() );
3284 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [=] {
3285 emit widgetValueHasChanged(
this );
3291 mComboBox =
new QComboBox();
3294 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
3295 const QStringList options = expParam->
options();
3296 const QVariantList iconList = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"icons" ) ).toList();
3297 for (
int i = 0; i < options.count(); ++i )
3299 const QIcon icon = iconList.value( i ).value<QIcon>();
3302 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
3304 mComboBox->addItem( icon, options.at( i ), i );
3307 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3308 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
3309 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
3310 emit widgetValueHasChanged(
this );
3319void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3323 if ( !value.isValid() )
3324 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
3331 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3336 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3340 else if ( mPanel || mCheckboxPanel )
3343 if ( value.isValid() )
3349 opts.reserve( v.size() );
3350 for ( QString i : v )
3356 opts.reserve( v.size() );
3362 mPanel->setValue( opts );
3363 else if ( mCheckboxPanel )
3364 mCheckboxPanel->setValue( opts );
3368QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3371 return mComboBox->currentData();
3373 return mPanel->value();
3374 else if ( mCheckboxPanel )
3375 return mCheckboxPanel->value();
3380QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3382 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3385QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3392 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3397 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3409QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3418 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() : nullptr );
3423 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3425 emit widgetValueHasChanged(
this );
3432 mPlainComboBox =
new QComboBox();
3433 mPlainComboBox->setEditable(
true );
3434 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3435 if ( widgetContext().project() )
3439 mPlainComboBox->addItem( layout->name() );
3442 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [=](
const QString & ) {
3443 emit widgetValueHasChanged(
this );
3445 return mPlainComboBox;
3451void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3455 if ( !value.isValid() )
3456 mComboBox->setCurrentLayout(
nullptr );
3460 mComboBox->setCurrentLayout( l );
3462 mComboBox->setCurrentLayout(
nullptr );
3465 else if ( mPlainComboBox )
3468 mPlainComboBox->setCurrentText( v );
3472QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3477 return l ? l->
name() : QVariant();
3479 else if ( mPlainComboBox )
3480 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3488 if ( mPlainComboBox && context.
project() )
3492 mPlainComboBox->addItem( layout->name() );
3496QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3498 return tr(
"string representing the name of an existing print layout" );
3501QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3508 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3520 QVBoxLayout *vlayout =
new QVBoxLayout();
3521 vlayout->setContentsMargins( 0, 0, 0, 0 );
3523 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3525 mParentLayoutComboBox =
new QComboBox();
3526 QString initialParent;
3528 initialParent = itemParam->parentLayoutParameterName();
3530 if (
auto *lModel = widgetContext.
model() )
3533 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3534 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3538 mParentLayoutComboBox->addItem( definition->
description(), definition->
name() );
3539 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3541 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3547 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3550 mParentLayoutComboBox->addItem( initialParent, initialParent );
3551 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3554 vlayout->addWidget( mParentLayoutComboBox );
3555 setLayout( vlayout );
3559 auto param = std::make_unique<QgsProcessingParameterLayoutItem>( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3561 return param.release();
3570QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3581 mComboBox->setAllowEmptyItem(
true );
3582 if ( layoutParam->
itemType() >= 0 )
3585 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3587 emit widgetValueHasChanged(
this );
3594 mLineEdit =
new QLineEdit();
3595 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3596 connect( mLineEdit, &QLineEdit::textChanged,
this, [=](
const QString & ) {
3597 emit widgetValueHasChanged(
this );
3605void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3632void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3638 std::unique_ptr<QgsProcessingContext> tmpContext;
3639 if ( mProcessingContextGenerator )
3640 context = mProcessingContextGenerator->processingContext();
3644 tmpContext = std::make_unique<QgsProcessingContext>();
3645 context = tmpContext.get();
3649 setLayout( layout );
3652void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3655 mComboBox->setCurrentLayout( layout );
3658void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3662 if ( !value.isValid() )
3663 mComboBox->setItem(
nullptr );
3667 mComboBox->setItem( item );
3670 else if ( mLineEdit )
3673 mLineEdit->setText( v );
3677QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3682 return i ? i->
uuid() : QVariant();
3684 else if ( mLineEdit )
3685 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3691QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3693 return tr(
"string representing the UUID or ID of an existing print layout item" );
3696QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3703 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3708 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3715QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3722QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3724void QgsProcessingPointMapTool::deactivate()
3738 if ( e->button() == Qt::LeftButton )
3741 emit clicked( point );
3746void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3748 if ( e->key() == Qt::Key_Escape )
3761QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3764 QHBoxLayout *l =
new QHBoxLayout();
3765 l->setContentsMargins( 0, 0, 0, 0 );
3767 mLineEdit->setShowClearButton(
false );
3768 l->addWidget( mLineEdit, 1 );
3769 mButton =
new QToolButton();
3770 mButton->setText( QString( QChar( 0x2026 ) ) );
3771 l->addWidget( mButton );
3774 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3775 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::textChanged );
3776 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3777 mButton->setVisible(
false );
3780void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
3783 if ( mAllowSelectOnCanvas )
3785 mButton->setVisible(
true );
3788 mTool = std::make_unique<QgsProcessingPointMapTool>( mCanvas );
3789 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
3790 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
3794void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
3796 mLineEdit->setShowClearButton( allowNull );
3799void QgsProcessingPointPanel::setShowPointOnCanvas(
bool show )
3801 if ( mShowPointOnCanvas == show )
3804 mShowPointOnCanvas = show;
3805 if ( mShowPointOnCanvas )
3811 mMapPointRubberBand.reset();
3815void QgsProcessingPointPanel::setAllowSelectOnCanvas(
bool allow )
3817 mAllowSelectOnCanvas = allow;
3818 mButton->setVisible( mAllowSelectOnCanvas &&
static_cast<bool>( mTool ) );
3821QVariant QgsProcessingPointPanel::value()
const
3823 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
3826void QgsProcessingPointPanel::clear()
3834 QString newText = QStringLiteral(
"%1,%2" )
3835 .arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) );
3838 if ( mCrs.isValid() )
3840 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
3842 mLineEdit->setText( newText );
3846void QgsProcessingPointPanel::showEvent( QShowEvent * )
3851 if ( QWidget *parentWindow = window() )
3853 setAllowSelectOnCanvas( !parentWindow->isModal() );
3859void QgsProcessingPointPanel::selectOnCanvas()
3864 mPrevTool = mCanvas->mapTool();
3865 mCanvas->setMapTool( mTool.get() );
3867 emit toggleDialogVisibility(
false );
3870void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3872 setValue( point, mCanvas->mapSettings().destinationCrs() );
3875void QgsProcessingPointPanel::pointPicked()
3880 mCanvas->setMapTool( mPrevTool );
3882 emit toggleDialogVisibility(
true );
3885void QgsProcessingPointPanel::textChanged(
const QString &text )
3887 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3889 const QRegularExpressionMatch match = rx.match( text );
3890 if ( match.hasMatch() )
3893 const double x = match.captured( 1 ).toDouble( &xOk );
3895 const double y = match.captured( 2 ).toDouble( &yOk );
3902 if ( pointCrs.isValid() )
3920void QgsProcessingPointPanel::updateRubberBand()
3922 if ( !mShowPointOnCanvas || !mCanvas )
3925 if ( mPoint.isEmpty() )
3927 mMapPointRubberBand.reset();
3931 if ( !mMapPointRubberBand )
3934 mMapPointRubberBand->setZValue( 1000 );
3937 const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
3938 mMapPointRubberBand->setWidth( scaleFactor );
3939 mMapPointRubberBand->setIconSize( scaleFactor * 5 );
3941 mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
3942 mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
3956 QVBoxLayout *vlayout =
new QVBoxLayout();
3957 vlayout->setContentsMargins( 0, 0, 0, 0 );
3959 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3961 mDefaultLineEdit =
new QLineEdit();
3962 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3963 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
3967 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
3970 vlayout->addWidget( mDefaultLineEdit );
3971 setLayout( vlayout );
3976 auto param = std::make_unique<QgsProcessingParameterPoint>( name, description, mDefaultLineEdit->text() );
3978 return param.release();
3986QWidget *QgsProcessingPointWidgetWrapper::createWidget()
3994 mPanel =
new QgsProcessingPointPanel(
nullptr );
3995 if ( widgetContext().mapCanvas() )
3996 mPanel->setMapCanvas( widgetContext().mapCanvas() );
3999 mPanel->setAllowNull(
true );
4002 mPanel->setShowPointOnCanvas(
true );
4004 mPanel->setToolTip( parameterDefinition()->toolTip() );
4006 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [=] {
4007 emit widgetValueHasChanged(
this );
4011 setDialog( mDialog );
4017 mLineEdit =
new QLineEdit();
4018 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4019 connect( mLineEdit, &QLineEdit::textChanged,
this, [=](
const QString & ) {
4020 emit widgetValueHasChanged(
this );
4032 mPanel->setMapCanvas( context.
mapCanvas() );
4035void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
4040 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [=](
bool visible ) {
4042 mDialog->showMinimized();
4045 mDialog->showNormal();
4047 mDialog->activateWindow();
4054void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4058 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
4064 mPanel->setValue( p,
crs );
4067 else if ( mLineEdit )
4070 mLineEdit->setText( v );
4074QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
4078 return mPanel->value();
4080 else if ( mLineEdit )
4081 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
4086QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
4088 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
4091QString QgsProcessingPointWidgetWrapper::parameterType()
const
4098 return new QgsProcessingPointWidgetWrapper( parameter, type );
4103 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4115 QVBoxLayout *vlayout =
new QVBoxLayout();
4116 vlayout->setContentsMargins( 0, 0, 0, 0 );
4118 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4130 vlayout->addWidget( mGeometryWidget );
4131 setLayout( vlayout );
4137 auto param = std::make_unique<QgsProcessingParameterGeometry>( name, description, geometry.
isEmpty() ? QVariant() : geometry.asWkt() );
4139 return param.release();
4147QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
4156 mGeometryWidget->setToolTip( parameterDefinition()->toolTip() );
4158 emit widgetValueHasChanged(
this );
4160 return mGeometryWidget;
4166void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4168 if ( mGeometryWidget )
4177 mGeometryWidget->clearGeometry();
4182QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
4184 if ( mGeometryWidget )
4187 return geometry.
isEmpty() ? QVariant() : geometry.asWkt();
4195QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
4197 return tr(
"string in the Well-Known-Text format or a geometry value" );
4200QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
4207 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
4212 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4224 QVBoxLayout *vlayout =
new QVBoxLayout();
4225 vlayout->setContentsMargins( 0, 0, 0, 0 );
4227 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4230 mDefaultColorButton->setShowNull(
true );
4231 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
4237 mDefaultColorButton->setToNull();
4239 mDefaultColorButton->setColor(
c );
4240 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
4244 mDefaultColorButton->setToNull();
4245 mAllowOpacity->setChecked(
true );
4248 vlayout->addWidget( mDefaultColorButton );
4249 vlayout->addWidget( mAllowOpacity );
4250 setLayout( vlayout );
4255 auto param = std::make_unique<QgsProcessingParameterColor>( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
4257 return param.release();
4265QWidget *QgsProcessingColorWidgetWrapper::createWidget()
4275 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
4278 mColorButton->setShowNull(
true );
4281 mColorButton->setToolTip( parameterDefinition()->toolTip() );
4282 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
4289 emit widgetValueHasChanged(
this );
4292 return mColorButton;
4298void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4302 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() )
4303 || ( value.userType() == QMetaType::Type::QColor && !value.value<QColor>().isValid() ) )
4304 mColorButton->setToNull();
4308 if ( !
c.isValid() && mColorButton->showNull() )
4309 mColorButton->setToNull();
4311 mColorButton->setColor(
c );
4316QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
4319 return mColorButton->isNull() ? QVariant() : mColorButton->color();
4324QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
4326 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
4329QString QgsProcessingColorWidgetWrapper::parameterType()
const
4336 return new QgsProcessingColorWidgetWrapper( parameter, type );
4341 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4352 QVBoxLayout *vlayout =
new QVBoxLayout();
4353 vlayout->setContentsMargins( 0, 0, 0, 0 );
4355 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4357 mDefaultLineEdit =
new QLineEdit();
4360 vlayout->addWidget( mDefaultLineEdit );
4362 mSourceParamComboBox =
new QComboBox();
4363 mDestParamComboBox =
new QComboBox();
4364 QString initialSource;
4365 QString initialDest;
4370 initialSource = itemParam->sourceCrsParameterName();
4371 initialDest = itemParam->destinationCrsParameterName();
4376 mSourceParamComboBox->addItem( QString(), QString() );
4377 mDestParamComboBox->addItem( QString(), QString() );
4378 if (
auto *lModel = widgetContext.
model() )
4381 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4382 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4384 if ( definition && it->parameterName() == definition->
name() )
4388 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4389 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4390 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4392 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4394 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4396 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4401 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4404 mSourceParamComboBox->addItem( initialSource, initialSource );
4405 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4407 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4410 mDestParamComboBox->addItem( initialDest, initialDest );
4411 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4414 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4415 vlayout->addWidget( mSourceParamComboBox );
4416 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4417 vlayout->addWidget( mDestParamComboBox );
4421 mStaticSourceWidget->setCrs( sourceCrs );
4424 mStaticDestWidget->setCrs( destCrs );
4426 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4427 vlayout->addWidget( mStaticSourceWidget );
4428 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4429 vlayout->addWidget( mStaticDestWidget );
4431 setLayout( vlayout );
4436 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() );
4438 return param.release();
4446QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4457 mOperationWidget->setShowMakeDefault(
false );
4458 mOperationWidget->setShowFallbackOption(
false );
4459 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4460 mOperationWidget->setSourceCrs( mSourceCrs );
4461 mOperationWidget->setDestinationCrs( mDestCrs );
4462 mOperationWidget->setMapCanvas( mCanvas );
4467 mOperationWidget->setSelectedOperation( deets );
4471 emit widgetValueHasChanged(
this );
4474 return mOperationWidget;
4480 mLineEdit =
new QLineEdit();
4481 QHBoxLayout *layout =
new QHBoxLayout();
4482 layout->addWidget( mLineEdit, 1 );
4483 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
4484 emit widgetValueHasChanged(
this );
4487 QToolButton *button =
new QToolButton();
4488 button->setText( QString( QChar( 0x2026 ) ) );
4489 connect( button, &QToolButton::clicked,
this, [=] {
4490 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4493 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4494 emit widgetValueHasChanged(
this );
4497 layout->addWidget( button );
4499 QWidget *w =
new QWidget();
4500 layout->setContentsMargins( 0, 0, 0, 0 );
4501 w->setLayout( layout );
4508void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4544 if ( mOperationWidget )
4545 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4548void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4550 if ( mOperationWidget )
4552 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4555 deets.
proj = value.toString();
4556 mOperationWidget->setSelectedOperation( deets );
4561 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4563 mLineEdit->setText( value.toString() );
4568QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4570 if ( mOperationWidget )
4571 return mOperationWidget->selectedOperation().proj;
4572 else if ( mLineEdit )
4573 return mLineEdit->text();
4578QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4580 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4583void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4586 std::unique_ptr<QgsProcessingContext> tmpContext;
4587 if ( mProcessingContextGenerator )
4588 context = mProcessingContextGenerator->processingContext();
4592 tmpContext = std::make_unique<QgsProcessingContext>();
4593 context = tmpContext.get();
4597 if ( mOperationWidget )
4599 mOperationWidget->setSourceCrs( mSourceCrs );
4600 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4604void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4607 std::unique_ptr<QgsProcessingContext> tmpContext;
4608 if ( mProcessingContextGenerator )
4609 context = mProcessingContextGenerator->processingContext();
4613 tmpContext = std::make_unique<QgsProcessingContext>();
4614 context = tmpContext.get();
4618 if ( mOperationWidget )
4620 mOperationWidget->setDestinationCrs( mDestCrs );
4621 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4625QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
4632 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
4637 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4649 QHBoxLayout *hl =
new QHBoxLayout();
4650 hl->setContentsMargins( 0, 0, 0, 0 );
4652 mLineEdit =
new QLineEdit();
4653 mLineEdit->setEnabled(
false );
4654 hl->addWidget( mLineEdit, 1 );
4656 mToolButton =
new QToolButton();
4657 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4658 hl->addWidget( mToolButton );
4664 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4667 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4670void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4675void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4677 if ( value.isValid() )
4678 mValue = value.userType() == QMetaType::Type::QVariantList ? value.
toList() : QVariantList() << value;
4682 updateSummaryText();
4686void QgsProcessingFieldPanelWidget::showDialog()
4688 QVariantList availableOptions;
4689 availableOptions.reserve( mFields.size() );
4690 for (
const QgsField &field : std::as_const( mFields ) )
4692 availableOptions << field.name();
4698 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4699 widget->setPanelTitle( mParam->description() );
4701 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
4702 return v.toString();
4705 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
4706 setValue( widget->selectedOptions() );
4713 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4715 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
4716 return v.toString();
4720 setValue( dlg.selectedOptions() );
4725void QgsProcessingFieldPanelWidget::updateSummaryText()
4730 if ( mValue.empty() )
4732 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4737 values.reserve( mValue.size() );
4738 for (
const QVariant &val : std::as_const( mValue ) )
4740 values << val.toString();
4743 const QString concatenated = values.join( tr(
"," ) );
4744 if ( concatenated.length() < 100 )
4745 mLineEdit->setText( concatenated );
4747 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4759 QVBoxLayout *vlayout =
new QVBoxLayout();
4760 vlayout->setContentsMargins( 0, 0, 0, 0 );
4762 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4763 mParentLayerComboBox =
new QComboBox();
4765 QString initialParent;
4767 initialParent = fieldParam->parentLayerParameterName();
4769 if (
auto *lModel = widgetContext.
model() )
4772 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4773 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4777 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4778 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4780 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4785 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4786 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4788 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4795 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4796 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4798 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4805 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4808 mParentLayerComboBox->addItem( initialParent, initialParent );
4809 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4812 vlayout->addWidget( mParentLayerComboBox );
4814 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4815 mDataTypeComboBox =
new QComboBox();
4823 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast<int>( fieldParam->dataType() ) ) );
4825 vlayout->addWidget( mDataTypeComboBox );
4827 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4829 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4831 vlayout->addWidget( mAllowMultipleCheckBox );
4833 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4834 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4836 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4838 vlayout->addWidget( mDefaultToAllCheckBox );
4840 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [=] {
4841 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4844 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4846 mDefaultLineEdit =
new QLineEdit();
4847 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4851 mDefaultLineEdit->setText( fields.join(
';' ) );
4853 vlayout->addWidget( mDefaultLineEdit );
4855 setLayout( vlayout );
4862 QVariant defaultValue;
4863 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4865 defaultValue = mDefaultLineEdit->text();
4867 auto param = std::make_unique<QgsProcessingParameterField>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
4869 return param.release();
4877QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
4887 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
4888 mPanel->setToolTip( parameterDefinition()->toolTip() );
4889 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [=] {
4890 emit widgetValueHasChanged(
this );
4910 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4912 emit widgetValueHasChanged(
this );
4920 mLineEdit =
new QLineEdit();
4921 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
4922 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
4923 emit widgetValueHasChanged(
this );
4931void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4943 setParentLayerWrapperValue( wrapper );
4945 setParentLayerWrapperValue( wrapper );
4962 std::unique_ptr<QgsProcessingContext> tmpContext;
4963 if ( mProcessingContextGenerator )
4964 context = mProcessingContextGenerator->processingContext();
4968 tmpContext = std::make_unique<QgsProcessingContext>();
4969 context = tmpContext.get();
4974 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
4984 bool valueSet =
false;
4988 if ( layers.count() > 1 )
4990 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
4992 const QList<QgsMapLayer *> remainingLayers = layers.mid( 1 );
4998 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
4999 if ( !vlayer || !vlayer->
isValid() )
5005 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
5008 fields.
remove( fieldIdx );
5013 mComboBox->setFields( fields );
5015 mPanel->setFields( filterFields( fields ) );
5021 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
5023 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5027 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
5030 mParentLayer.reset( qobject_cast<QgsVectorLayer *>( ownedLayer.release() ) );
5031 layer = mParentLayer.get();
5039 mComboBox->setLayer( layer );
5041 mPanel->setFields( filterFields( layer->
fields() ) );
5051 const QgsFields fields = source->fields();
5053 mComboBox->setFields( fields );
5055 mPanel->setFields( filterFields( fields ) );
5064 mComboBox->setLayer(
nullptr );
5068 if ( value.isValid() && widgetContext().messageBar() )
5080 val.reserve( mPanel->fields().size() );
5081 for (
const QgsField &field : mPanel->fields() )
5082 val << field.name();
5083 setWidgetValue( val, *context );
5086 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5089void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5093 if ( !value.isValid() )
5094 mComboBox->setField( QString() );
5098 mComboBox->setField( v );
5104 if ( value.isValid() )
5107 opts.reserve( v.size() );
5108 for (
const QString &i : v )
5112 mPanel->setValue( opts );
5114 else if ( mLineEdit )
5120 mLineEdit->setText( v.join(
';' ) );
5129QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
5132 return mComboBox->currentField();
5134 return mPanel->value();
5135 else if ( mLineEdit )
5140 return mLineEdit->text().split(
';' );
5143 return mLineEdit->text();
5149QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
5151 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
5154const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
5156 if ( mComboBox && mComboBox->layer() )
5157 return mComboBox->layer();
5162QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
5175 if ( f.isNumeric() )
5180 if ( f.type() == QMetaType::Type::QString )
5185 if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
5190 if ( f.type() == QMetaType::Type::QByteArray )
5195 if ( f.type() == QMetaType::Type::Bool )
5204QString QgsProcessingFieldWidgetWrapper::parameterType()
const
5211 return new QgsProcessingFieldWidgetWrapper( parameter, type );
5216 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5227 QVBoxLayout *vlayout =
new QVBoxLayout();
5228 vlayout->setContentsMargins( 0, 0, 0, 0 );
5230 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5232 mDefaultComboBox =
new QComboBox();
5233 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
5236 for (
const QString &theme : mapThemes )
5240 mDefaultComboBox->setEditable(
true );
5244 if ( themeParam->defaultValueForGui().isValid() )
5247 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5250 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5252 vlayout->addWidget( mDefaultComboBox );
5254 setLayout( vlayout );
5259 QVariant defaultVal;
5260 if ( mDefaultComboBox->currentText().isEmpty() )
5261 defaultVal = QVariant();
5263 defaultVal = mDefaultComboBox->currentText();
5264 auto param = std::make_unique<QgsProcessingParameterMapTheme>( name, description, defaultVal );
5266 return param.release();
5275QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
5279 mComboBox =
new QComboBox();
5282 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
5285 for (
const QString &theme : mapThemes )
5297 mComboBox->setEditable(
true );
5301 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5302 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
5303 emit widgetValueHasChanged(
this );
5309void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5313 if ( !value.isValid() )
5314 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5317 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5319 const QString prev = mComboBox->currentText();
5320 mComboBox->setCurrentText( v );
5322 emit widgetValueHasChanged(
this );
5325 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5329QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5332 return mComboBox->currentData().toInt() == -1 ? QVariant() : !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5333 : mComboBox->currentData();
5338QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5340 return tr(
"map theme as a string value (e.g. 'base maps')" );
5343QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5350 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5355 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5367 QVBoxLayout *vlayout =
new QVBoxLayout();
5368 vlayout->setContentsMargins( 0, 0, 0, 0 );
5370 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5372 mTypeComboBox =
new QComboBox();
5377 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( datetimeParam->dataType() ) ) );
5379 mTypeComboBox->setCurrentIndex( 0 );
5380 vlayout->addWidget( mTypeComboBox );
5382 setLayout( vlayout );
5387 auto param = std::make_unique<QgsProcessingParameterDateTime>( name, description );
5390 return param.release();
5399QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5404 switch ( dateTimeParam->
dataType() )
5408 widget = mDateTimeEdit;
5431 widget->setToolTip( parameterDefinition()->toolTip() );
5433 if ( mDateTimeEdit )
5436 emit widgetValueHasChanged(
this );
5439 else if ( mDateEdit )
5442 emit widgetValueHasChanged(
this );
5445 else if ( mTimeEdit )
5448 emit widgetValueHasChanged(
this );
5457 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5460void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5462 if ( mDateTimeEdit )
5466 else if ( mDateEdit )
5470 else if ( mTimeEdit )
5476QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5478 if ( mDateTimeEdit )
5479 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5480 else if ( mDateEdit )
5481 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5482 else if ( mTimeEdit )
5483 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5488QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5491 if ( dateTimeParam )
5493 switch ( dateTimeParam->
dataType() )
5496 return tr(
"datetime value, or a ISO string representation of a datetime" );
5499 return tr(
"date value, or a ISO string representation of a date" );
5502 return tr(
"time value, or a ISO string representation of a time" );
5508QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5515 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5528 QVBoxLayout *vlayout =
new QVBoxLayout();
5529 vlayout->setContentsMargins( 0, 0, 0, 0 );
5531 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5532 mProviderComboBox =
new QComboBox();
5533 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
5534 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
5535 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
5537 vlayout->addWidget( mProviderComboBox );
5539 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5541 mDefaultEdit =
new QLineEdit();
5542 vlayout->addWidget( mDefaultEdit );
5543 setLayout( vlayout );
5545 if ( connectionParam )
5547 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5554 QVariant defaultVal;
5555 if ( mDefaultEdit->text().isEmpty() )
5556 defaultVal = QVariant();
5558 defaultVal = mDefaultEdit->text();
5559 auto param = std::make_unique<QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5561 return param.release();
5570QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5576 mProviderComboBox->setAllowEmptyConnection(
true );
5584 mProviderComboBox->setEditable(
true );
5588 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5589 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [=](
const QString & ) {
5590 if ( mBlockSignals )
5593 emit widgetValueHasChanged(
this );
5596 return mProviderComboBox;
5601 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5604void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5608 if ( !value.isValid() )
5609 mProviderComboBox->setCurrentIndex( -1 );
5612 if ( mProviderComboBox->isEditable() )
5614 const QString prev = mProviderComboBox->currentText();
5616 mProviderComboBox->setConnection( v );
5617 mProviderComboBox->setCurrentText( v );
5621 emit widgetValueHasChanged(
this );
5624 mProviderComboBox->setConnection( v );
5628QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5630 if ( mProviderComboBox )
5631 if ( mProviderComboBox->isEditable() )
5632 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5634 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5639QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5641 return tr(
"connection name as a string value" );
5644QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5651 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5664 QVBoxLayout *vlayout =
new QVBoxLayout();
5665 vlayout->setContentsMargins( 0, 0, 0, 0 );
5667 mConnectionParamComboBox =
new QComboBox();
5668 QString initialConnection;
5674 if (
auto *lModel = widgetContext.
model() )
5677 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5678 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5680 if ( definition && it->parameterName() == definition->
name() )
5686 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5687 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5689 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5694 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5697 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5698 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5701 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5702 vlayout->addWidget( mConnectionParamComboBox );
5704 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5706 mDefaultEdit =
new QLineEdit();
5707 vlayout->addWidget( mDefaultEdit );
5708 setLayout( vlayout );
5718 QVariant defaultVal;
5719 if ( mDefaultEdit->text().isEmpty() )
5720 defaultVal = QVariant();
5722 defaultVal = mDefaultEdit->text();
5723 auto param = std::make_unique<QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5725 return param.release();
5734QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5740 mSchemaComboBox->setAllowEmptySchema(
true );
5748 mSchemaComboBox->comboBox()->setEditable(
true );
5752 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5753 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [=](
const QString & ) {
5754 if ( mBlockSignals )
5757 emit widgetValueHasChanged( this );
5760 return mSchemaComboBox;
5765 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5772 std::unique_ptr<QgsProcessingContext> tmpContext;
5773 if ( mProcessingContextGenerator )
5774 context = mProcessingContextGenerator->processingContext();
5778 tmpContext = std::make_unique<QgsProcessingContext>();
5779 context = tmpContext.get();
5785 if ( mSchemaComboBox )
5786 mSchemaComboBox->setConnectionName( connection, qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId() );
5790 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5793void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5797 if ( !value.isValid() )
5798 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5801 if ( mSchemaComboBox->comboBox()->isEditable() )
5803 const QString prev = mSchemaComboBox->comboBox()->currentText();
5805 mSchemaComboBox->setSchema( v );
5806 mSchemaComboBox->comboBox()->setCurrentText( v );
5810 emit widgetValueHasChanged(
this );
5813 mSchemaComboBox->setSchema( v );
5817QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5819 if ( mSchemaComboBox )
5820 if ( mSchemaComboBox->comboBox()->isEditable() )
5821 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5823 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5828QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5830 return tr(
"database schema name as a string value" );
5833QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5840 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5843void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5855 setParentConnectionWrapperValue( wrapper );
5857 setParentConnectionWrapperValue( wrapper );
5880 QVBoxLayout *vlayout =
new QVBoxLayout();
5881 vlayout->setContentsMargins( 0, 0, 0, 0 );
5883 mConnectionParamComboBox =
new QComboBox();
5884 mSchemaParamComboBox =
new QComboBox();
5885 QString initialConnection;
5886 QString initialSchema;
5893 if (
auto *lModel = widgetContext.
model() )
5896 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5897 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5899 if ( definition && it->parameterName() == definition->
name() )
5904 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5905 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5907 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5912 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
5913 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5915 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5921 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5924 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5925 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5928 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
5931 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
5932 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5935 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5936 vlayout->addWidget( mConnectionParamComboBox );
5938 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
5939 vlayout->addWidget( mSchemaParamComboBox );
5941 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5943 mDefaultEdit =
new QLineEdit();
5944 vlayout->addWidget( mDefaultEdit );
5945 setLayout( vlayout );
5955 QVariant defaultVal;
5956 if ( mDefaultEdit->text().isEmpty() )
5957 defaultVal = QVariant();
5959 defaultVal = mDefaultEdit->text();
5960 auto param = std::make_unique<QgsProcessingParameterDatabaseTable>( name, description, mConnectionParamComboBox->currentData().toString(), mSchemaParamComboBox->currentData().toString(), defaultVal );
5962 return param.release();
5971QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
5977 mTableComboBox->setAllowEmptyTable(
true );
5980 mTableComboBox->comboBox()->setEditable(
true );
5982 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
5983 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [=](
const QString & ) {
5984 if ( mBlockSignals )
5987 emit widgetValueHasChanged( this );
5990 return mTableComboBox;
5995 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6002 std::unique_ptr<QgsProcessingContext> tmpContext;
6003 if ( mProcessingContextGenerator )
6004 context = mProcessingContextGenerator->processingContext();
6008 tmpContext = std::make_unique<QgsProcessingContext>();
6009 context = tmpContext.get();
6014 mProvider = qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId();
6015 if ( mTableComboBox && !mSchema.isEmpty() )
6017 mTableComboBox->setSchema( mSchema );
6018 mTableComboBox->setConnectionName( mConnection, mProvider );
6022 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6030 std::unique_ptr<QgsProcessingContext> tmpContext;
6031 if ( mProcessingContextGenerator )
6032 context = mProcessingContextGenerator->processingContext();
6036 tmpContext = std::make_unique<QgsProcessingContext>();
6037 context = tmpContext.get();
6043 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
6045 mTableComboBox->setSchema( mSchema );
6046 mTableComboBox->setConnectionName( mConnection, mProvider );
6050 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6054void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6058 if ( !value.isValid() )
6059 mTableComboBox->comboBox()->setCurrentIndex( -1 );
6062 if ( mTableComboBox->comboBox()->isEditable() )
6064 const QString prev = mTableComboBox->comboBox()->currentText();
6066 mTableComboBox->setTable( v );
6067 mTableComboBox->comboBox()->setCurrentText( v );
6071 emit widgetValueHasChanged(
this );
6074 mTableComboBox->setTable( v );
6078QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
6080 if ( mTableComboBox )
6081 if ( mTableComboBox->comboBox()->isEditable() )
6082 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
6084 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
6089QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
6091 return tr(
"database table name as a string value" );
6094QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
6101 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
6104void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6116 setParentConnectionWrapperValue( wrapper );
6118 setParentConnectionWrapperValue( wrapper );
6123 setParentSchemaWrapperValue( wrapper );
6125 setParentSchemaWrapperValue( wrapper );
6145 QVBoxLayout *vlayout =
new QVBoxLayout();
6146 vlayout->setContentsMargins( 0, 0, 0, 0 );
6148 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6151 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6154 if ( extentParam->defaultValueForGui().isValid() )
6158 mDefaultWidget->setCurrentExtent( rect,
crs );
6159 mDefaultWidget->setOutputExtentFromCurrent();
6163 mDefaultWidget->clear();
6167 vlayout->addWidget( mDefaultWidget );
6168 setLayout( vlayout );
6173 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();
6174 auto param = std::make_unique<QgsProcessingParameterExtent>( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
6176 return param.release();
6185QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
6195 if ( widgetContext().mapCanvas() )
6196 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
6199 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6201 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6204 emit widgetValueHasChanged(
this );
6208 setDialog( mDialog );
6210 return mExtentWidget;
6220 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6223void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6230 mDialog->showMinimized();
6233 mDialog->showNormal();
6235 mDialog->activateWindow();
6242void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6244 if ( mExtentWidget )
6246 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
6247 mExtentWidget->clear();
6252 mExtentWidget->setCurrentExtent( r,
crs );
6253 mExtentWidget->setOutputExtentFromUser( r,
crs );
6258QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6260 if ( mExtentWidget )
6262 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();
6264 return val.isEmpty() ? QVariant() : QVariant( val );
6270QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6272 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6275QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6282 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6287 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6298 QVBoxLayout *vlayout =
new QVBoxLayout();
6299 vlayout->setContentsMargins( 0, 0, 0, 0 );
6301 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6317 for (
int i : layerParam->dataTypes() )
6319 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6323 vlayout->addWidget( mLayerTypeComboBox );
6325 setLayout( vlayout );
6330 QList<int> dataTypes;
6331 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6332 dataTypes << v.toInt();
6334 auto param = std::make_unique<QgsProcessingParameterMapLayer>( name, description );
6335 param->setDataTypes( dataTypes );
6337 return param.release();
6345QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6347 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6355 mComboBox->setEditable(
true );
6359 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6361 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [=]() {
6362 if ( mBlockSignals )
6365 emit widgetValueHasChanged(
this );
6368 setWidgetContext( widgetContext() );
6377 mComboBox->setWidgetContext( context );
6382 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6388void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6391 mComboBox->setValue( value, context );
6394QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6396 return mComboBox ? mComboBox->value() : QVariant();
6399QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6401 return tr(
"path to a map layer" );
6418QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6425 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6430 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6439 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6443QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6445 return tr(
"path to a raster layer" );
6448QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6455 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6460 Q_UNUSED( context );
6461 Q_UNUSED( widgetContext );
6462 Q_UNUSED( definition );
6476 QVBoxLayout *vlayout =
new QVBoxLayout();
6477 vlayout->setContentsMargins( 0, 0, 0, 0 );
6479 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6489 for (
int i : vectorParam->dataTypes() )
6491 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6495 vlayout->addWidget( mGeometryTypeComboBox );
6497 setLayout( vlayout );
6502 QList<int> dataTypes;
6503 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6504 dataTypes << v.toInt();
6506 auto param = std::make_unique<QgsProcessingParameterVectorLayer>( name, description, dataTypes );
6508 return param.release();
6513 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6517QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6519 return tr(
"path to a vector layer" );
6522QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6529 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6534 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6545 QVBoxLayout *vlayout =
new QVBoxLayout();
6546 vlayout->setContentsMargins( 0, 0, 0, 0 );
6548 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6558 for (
int i : sourceParam->dataTypes() )
6560 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6568 vlayout->addWidget( mGeometryTypeComboBox );
6570 setLayout( vlayout );
6575 QList<int> dataTypes;
6576 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6577 dataTypes << v.toInt();
6579 auto param = std::make_unique<QgsProcessingParameterFeatureSource>( name, description, dataTypes );
6581 return param.release();
6585 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6589QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6591 return tr(
"path to a vector layer" );
6594QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6601 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6606 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6614 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6618QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6620 return tr(
"path to a mesh layer" );
6623QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6630 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6635 Q_UNUSED( context );
6636 Q_UNUSED( widgetContext );
6637 Q_UNUSED( definition );
6648QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6652 QHBoxLayout *hl =
new QHBoxLayout();
6653 hl->setContentsMargins( 0, 0, 0, 0 );
6655 mLineEdit =
new QLineEdit();
6656 mLineEdit->setEnabled(
false );
6657 hl->addWidget( mLineEdit, 1 );
6659 mToolButton =
new QToolButton();
6660 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6661 hl->addWidget( mToolButton );
6667 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6670 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6673void QgsProcessingRasterBandPanelWidget::setBands(
const QList<int> &bands )
6678void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6683void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6685 if ( value.isValid() )
6686 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
6690 updateSummaryText();
6694void QgsProcessingRasterBandPanelWidget::showDialog()
6696 QVariantList availableOptions;
6697 availableOptions.reserve( mBands.size() );
6698 for (
int band : std::as_const( mBands ) )
6700 availableOptions << band;
6706 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6707 widget->setPanelTitle( mParam->description() );
6709 widget->setValueFormatter( [
this](
const QVariant &v ) -> QString {
6710 int band = v.toInt();
6711 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6714 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
6715 setValue( widget->selectedOptions() );
6722 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6724 dlg.setValueFormatter( [
this](
const QVariant &v ) -> QString {
6725 int band = v.toInt();
6726 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6730 setValue( dlg.selectedOptions() );
6735void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6738 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6749 QVBoxLayout *vlayout =
new QVBoxLayout();
6750 vlayout->setContentsMargins( 0, 0, 0, 0 );
6752 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6754 mDefaultLineEdit =
new QLineEdit();
6755 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6760 for (
int b : bands )
6762 defVal << QString::number( b );
6765 mDefaultLineEdit->setText( defVal.join(
';' ) );
6767 vlayout->addWidget( mDefaultLineEdit );
6769 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6770 mParentLayerComboBox =
new QComboBox();
6772 QString initialParent;
6774 initialParent = bandParam->parentLayerParameterName();
6776 if (
auto *lModel = widgetContext.
model() )
6779 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6780 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6784 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
6785 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6787 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6793 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6796 mParentLayerComboBox->addItem( initialParent, initialParent );
6797 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6800 vlayout->addWidget( mParentLayerComboBox );
6802 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6804 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6806 vlayout->addWidget( mAllowMultipleCheckBox );
6807 setLayout( vlayout );
6812 auto param = std::make_unique<QgsProcessingParameterBand>( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6814 return param.release();
6822QWidget *QgsProcessingBandWidgetWrapper::createWidget()
6832 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
6833 mPanel->setToolTip( parameterDefinition()->toolTip() );
6834 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [=] {
6835 emit widgetValueHasChanged(
this );
6844 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6846 emit widgetValueHasChanged(
this );
6854 mLineEdit =
new QLineEdit();
6855 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6856 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
6857 emit widgetValueHasChanged(
this );
6865void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6877 setParentLayerWrapperValue( wrapper );
6879 setParentLayerWrapperValue( wrapper );
6896 std::unique_ptr<QgsProcessingContext> tmpContext;
6897 if ( mProcessingContextGenerator )
6898 context = mProcessingContextGenerator->processingContext();
6902 tmpContext = std::make_unique<QgsProcessingContext>();
6903 context = tmpContext.get();
6909 if ( layer && layer->
isValid() )
6913 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
6916 mParentLayer.reset( qobject_cast<QgsRasterLayer *>( ownedLayer.release() ) );
6917 layer = mParentLayer.get();
6925 mComboBox->setLayer( layer );
6929 if ( provider && layer->
isValid() )
6934 QHash<int, QString> bandNames;
6935 for (
int i = 1; i <= nBands; ++i )
6940 mPanel->setBands( bands );
6941 mPanel->setBandNames( bandNames );
6948 mComboBox->setLayer(
nullptr );
6950 mPanel->setBands( QList<int>() );
6952 if ( value.isValid() && widgetContext().messageBar() )
6959 if ( parameterDefinition()->defaultValueForGui().isValid() )
6960 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6963void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6967 if ( !value.isValid() )
6968 mComboBox->setBand( -1 );
6972 mComboBox->setBand( v );
6978 if ( value.isValid() )
6981 opts.reserve( v.size() );
6986 mPanel->setValue( value.isValid() ? opts : QVariant() );
6988 else if ( mLineEdit )
6995 opts.reserve( v.size() );
6997 opts << QString::number( i );
6998 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
7002 if ( value.isValid() )
7010QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
7013 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
7015 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7016 else if ( mLineEdit )
7021 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
7023 res.reserve( parts.count() );
7024 for (
const QString &s : parts )
7027 int band = s.toInt( &ok );
7031 return res.
isEmpty() ? QVariant() : res;
7035 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7042QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7044 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7047QString QgsProcessingBandWidgetWrapper::parameterType()
const
7054 return new QgsProcessingBandWidgetWrapper( parameter, type );
7059 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7070 setAcceptDrops(
true );
7073void QgsProcessingMultipleLayerLineEdit::dragEnterEvent( QDragEnterEvent *event )
7075 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7076 if ( !uris.isEmpty() )
7078 event->setDropAction( Qt::CopyAction );
7080 setHighlighted(
true );
7088void QgsProcessingMultipleLayerLineEdit::dragLeaveEvent( QDragLeaveEvent *event )
7090 QgsHighlightableLineEdit::dragLeaveEvent( event );
7092 setHighlighted(
false );
7095void QgsProcessingMultipleLayerLineEdit::dropEvent( QDropEvent *event )
7097 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7098 if ( !uris.isEmpty() )
7100 event->acceptProposedAction();
7101 QVariantList uriList;
7102 uriList.reserve( uris.size() );
7103 for (
const QString &uri : uris )
7104 uriList.append( QVariant( uri ) );
7105 emit layersDropped( uriList );
7108 setHighlighted(
false );
7119 QHBoxLayout *hl =
new QHBoxLayout();
7120 hl->setContentsMargins( 0, 0, 0, 0 );
7122 mLineEdit =
new QgsProcessingMultipleLayerLineEdit(
nullptr, param );
7123 mLineEdit->setEnabled(
true );
7124 mLineEdit->setReadOnly(
true );
7126 hl->addWidget( mLineEdit, 1 );
7127 connect( mLineEdit, &QgsProcessingMultipleLayerLineEdit::layersDropped,
this, &QgsProcessingMultipleLayerPanelWidget::setValue );
7129 mToolButton =
new QToolButton();
7130 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7131 hl->addWidget( mToolButton );
7137 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7140 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7143void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7145 if ( value.isValid() )
7146 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7150 updateSummaryText();
7154void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7160 if ( mValue.removeAll( layerId ) )
7162 updateSummaryText();
7169void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7175 switch ( mParam->layerType() )
7257void QgsProcessingMultipleLayerPanelWidget::showDialog()
7262 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
7263 widget->setPanelTitle( mParam->description() );
7264 widget->setProject( mProject );
7265 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
7266 setValue( widget->selectedOptions() );
7273 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7274 dlg.setProject( mProject );
7277 setValue( dlg.selectedOptions() );
7282void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7285 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7295 QVBoxLayout *vlayout =
new QVBoxLayout();
7296 vlayout->setContentsMargins( 0, 0, 0, 0 );
7298 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7299 mLayerTypeComboBox =
new QComboBox();
7313 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast<int>( layersParam->layerType() ) ) );
7315 vlayout->addWidget( mLayerTypeComboBox );
7316 setLayout( vlayout );
7321 auto param = std::make_unique<QgsProcessingParameterMultipleLayers>( name, description,
static_cast<Qgis::ProcessingSourceType>( mLayerTypeComboBox->currentData().toInt() ) );
7323 return param.release();
7331QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7335 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7336 mPanel->setToolTip( parameterDefinition()->toolTip() );
7337 mPanel->setProject( widgetContext().project() );
7339 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7340 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [=] {
7341 emit widgetValueHasChanged(
this );
7351 mPanel->setProject( context.
project() );
7353 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7357void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7362 if ( value.isValid() )
7365 opts.reserve( v.size() );
7367 opts << l->source();
7370 for (
const QVariant &v : value.toList() )
7372 if ( v.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
7374 const QgsProcessingModelChildParameterSource source = v.value<QgsProcessingModelChildParameterSource>();
7375 opts << QVariant::fromValue( source );
7380 mPanel->setValue( value.isValid() ? opts : QVariant() );
7384QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7387 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7392QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7394 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7397QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7404 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7409 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7418 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7422QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7424 return tr(
"path to a point cloud layer" );
7427QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7434 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7439 Q_UNUSED( context );
7440 Q_UNUSED( widgetContext );
7441 Q_UNUSED( definition );
7457QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7459 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7462QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7469 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7474 Q_UNUSED( context );
7475 Q_UNUSED( widgetContext );
7476 Q_UNUSED( definition );
7487 if ( mWidgetContext.project() )
7488 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7492QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7503 mComboBox->setEditable(
true );
7507 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7509 if ( mWidgetContext.project() )
7510 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7513 mComboBox->setAllowEmptyLayer(
true );
7516 if ( mBlockSignals )
7519 emit widgetValueHasChanged(
this );
7522 setWidgetContext( widgetContext() );
7526void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7532 mComboBox->setLayer(
nullptr );
7536 QVariant val = value;
7537 if ( val.userType() == qMetaTypeId<QgsProperty>() )
7549 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( val.value<QObject *>() );
7550 if ( !layer && val.userType() == QMetaType::Type::QString )
7557 mComboBox->setLayer( layer );
7562QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7564 return mComboBox && mComboBox->currentLayer() ? ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral(
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
7577 QHBoxLayout *hl =
new QHBoxLayout();
7578 hl->setContentsMargins( 0, 0, 0, 0 );
7580 mLineEdit =
new QLineEdit();
7581 mLineEdit->setEnabled(
false );
7582 hl->addWidget( mLineEdit, 1 );
7584 mToolButton =
new QToolButton();
7585 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7586 hl->addWidget( mToolButton );
7592 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7595 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7600 mAttributes = attributes;
7603void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7605 if ( value.isValid() )
7606 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7610 updateSummaryText();
7614void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7616 QVariantList availableOptions;
7617 availableOptions.reserve( mAttributes.count() );
7618 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7621 availableOptions << attr.name();
7627 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7628 widget->setPanelTitle( mParam->description() );
7630 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
7631 return v.toString();
7634 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [=]() {
7635 setValue( widget->selectedOptions() );
7642 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7644 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
7645 return v.toString();
7649 setValue( dlg.selectedOptions() );
7654void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7659 if ( mValue.empty() )
7661 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7666 values.reserve( mValue.size() );
7667 for (
const QVariant &val : std::as_const( mValue ) )
7669 values << val.toString();
7672 const QString concatenated = values.join( tr(
"," ) );
7673 if ( concatenated.length() < 100 )
7674 mLineEdit->setText( concatenated );
7676 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7688 QVBoxLayout *vlayout =
new QVBoxLayout();
7689 vlayout->setContentsMargins( 0, 0, 0, 0 );
7691 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7692 mParentLayerComboBox =
new QComboBox();
7694 QString initialParent;
7696 initialParent = attrParam->parentLayerParameterName();
7698 if (
auto *lModel = widgetContext.
model() )
7701 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7702 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7706 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
7707 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7709 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7715 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7718 mParentLayerComboBox->addItem( initialParent, initialParent );
7719 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7722 vlayout->addWidget( mParentLayerComboBox );
7724 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
7726 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
7728 vlayout->addWidget( mAllowMultipleCheckBox );
7730 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
7731 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7733 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
7735 vlayout->addWidget( mDefaultToAllCheckBox );
7737 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [=] {
7738 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7741 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7743 mDefaultLineEdit =
new QLineEdit();
7744 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
7748 mDefaultLineEdit->setText( attributes.join(
';' ) );
7750 vlayout->addWidget( mDefaultLineEdit );
7752 setLayout( vlayout );
7757 QVariant defaultValue;
7758 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
7760 defaultValue = mDefaultLineEdit->text();
7762 auto param = std::make_unique<QgsProcessingParameterPointCloudAttribute>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
7764 return param.release();
7772QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
7782 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
7783 mPanel->setToolTip( parameterDefinition()->toolTip() );
7784 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [=] {
7785 emit widgetValueHasChanged(
this );
7793 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7795 emit widgetValueHasChanged(
this );
7803 mLineEdit =
new QLineEdit();
7804 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
7805 connect( mLineEdit, &QLineEdit::textChanged,
this, [=] {
7806 emit widgetValueHasChanged(
this );
7814void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7826 setParentLayerWrapperValue( wrapper );
7828 setParentLayerWrapperValue( wrapper );
7845 std::unique_ptr<QgsProcessingContext> tmpContext;
7846 if ( mProcessingContextGenerator )
7847 context = mProcessingContextGenerator->processingContext();
7851 tmpContext = std::make_unique<QgsProcessingContext>();
7852 context = tmpContext.get();
7858 if ( layer && layer->
isValid() )
7862 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
7865 mParentLayer.reset( qobject_cast<QgsPointCloudLayer *>( ownedLayer.release() ) );
7866 layer = mParentLayer.get();
7874 mComboBox->setLayer( layer );
7877 mPanel->setAttributes( layer->
attributes() );
7884 mComboBox->setLayer(
nullptr );
7889 if ( value.isValid() && widgetContext().messageBar() )
7900 val.reserve( mPanel->attributes().attributes().size() );
7903 setWidgetValue( val, *context );
7906 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7909void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7913 if ( !value.isValid() )
7914 mComboBox->setAttribute( QString() );
7918 mComboBox->setAttribute( v );
7924 if ( value.isValid() )
7927 opts.reserve( v.size() );
7928 for (
const QString &i : v )
7932 mPanel->setValue( opts );
7934 else if ( mLineEdit )
7940 mLineEdit->setText( v.join(
';' ) );
7949QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
7952 return mComboBox->currentAttribute();
7954 return mPanel->value();
7955 else if ( mLineEdit )
7960 return mLineEdit->text().split(
';' );
7963 return mLineEdit->text();
7969QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
7971 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
7974QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
7981 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
7986 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7999QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8007 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8008 if ( mProcessingContextGenerator )
8009 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8010 if ( mParametersGenerator )
8011 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8012 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8014 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [=]() {
8015 if ( mBlockSignals )
8018 emit widgetValueHasChanged(
this );
8023 mOutputWidget->addOpenAfterRunningOption();
8025 return mOutputWidget;
8035void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8037 if ( mOutputWidget )
8038 mOutputWidget->setValue( value );
8041QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8043 if ( mOutputWidget )
8044 return mOutputWidget->value();
8049QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8052 if ( mOutputWidget )
8053 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
8062 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8066QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8073 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8076QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8078 return tr(
"path to layer destination" );
8086 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8090QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8097 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8100QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8102 return tr(
"path to layer destination" );
8110 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8114QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8121 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8124QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8126 return tr(
"path to layer destination" );
8134 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8138QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8145 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8148QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8150 return tr(
"path to layer destination" );
8158 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8162QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8169 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8173QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8175 return tr(
"path to file destination" );
8183 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8187QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8194 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8198QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8200 return tr(
"path to folder destination" );
8208 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8212QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8219 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8222QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8224 return tr(
"path to layer destination" );
@ Standard
Unit is a standard measurement unit.
ProcessingSourceType
Processing data source types.
@ File
Files (i.e. non map layer sources, such as text files)
@ Annotation
Annotation layers.
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ VectorTile
Vector tile layers.
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ VectorAnyGeometry
Any vector layer with geometry.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ PointCloud
Point cloud layers.
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
@ File
Parameter is a single file.
@ Folder
Parameter is a folder.
ExpressionType
Expression types.
@ RasterCalculator
Raster calculator expression.
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
ProcessingMode
Types of modes which Processing widgets can be created for.
@ Batch
Batch processing mode.
@ Standard
Standard (single-run) algorithm mode.
DistanceUnit
Units of distance.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ NauticalMiles
Nautical miles.
ProcessingFieldParameterDataType
Processing field parameter data types.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ Numeric
Accepts numeric fields.
@ DateTime
Accepts datetime fields.
@ SquareCentimeters
Square centimeters.
@ SquareInches
Square inches.
@ SquareNauticalMiles
Square nautical miles.
@ SquareMillimeters
Square millimeters.
@ SquareYards
Square yards.
@ SquareKilometers
Square kilometers.
@ SquareMeters
Square meters.
@ Unknown
Unknown areal unit.
@ SquareDegrees
Square degrees, for planar geographic CRS area measurements.
@ SquareMiles
Square miles.
@ Info
Information message.
@ AnnotationLayer
QgsAnnotationLayer.
TemporalUnit
Temporal units.
@ Milliseconds
Milliseconds.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
VolumeUnit
Units of volume.
@ CubicMeters
Cubic meters.
@ CubicDegrees
Cubic degrees, for planar geographic CRS volume measurements.
@ CubicDecimeter
Cubic decimeters.
@ Unknown
Unknown volume unit.
@ CubicCentimeter
Cubic Centimeters.
ProcessingModelChildParameterSource
Processing model child parameter sources.
@ ModelParameter
Parameter value is taken from a parent model parameter.
@ StaticValue
Parameter value is a static value.
@ Optional
Parameter is optional.
ProcessingDateTimeParameterDataType
Processing date time parameter data types.
@ DateTime
Datetime values.
ProcessingNumberParameterType
Processing numeric parameter data types.
@ Double
Double/float values.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
@ CapturePoint
Select and capture a point or a feature.
Selector widget for authentication configs.
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing.
QComboBox subclass which allows selecting multiple items.
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Qgis::DistanceUnit mapUnits
A combo box which displays the list of schemas for a specific database connection.
A combobox which displays the list of tables for a specific database connection.
A QDateEdit widget with the capability of setting/reading null dates.
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
A QDateTimeEdit with the capability of setting/reading null date/times.
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
void setNullRepresentation(const QString &null)
Sets the widget's null representation, which defaults to QgsApplication::nullRepresentation().
void valueChanged(const QDateTime &date)
Signal emitted whenever the value changes.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
A widget which includes a line edit for entering expressions together with a button to open the expre...
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
A combobox which displays the list of fields of a given layer.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
@ DateTime
Datetime fields.
@ Date
Date or datetime fields.
@ Binary
Binary fields, since QGIS 3.34.
@ Boolean
Boolean fields, since QGIS 3.34.
@ Numeric
All numeric fields.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
void remove(int fieldIdx)
Removes the field with the given index.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A geometry is the spatial representation of a feature.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
A QgsFilterLineEdit subclass with the ability to "highlight" the edges of the widget.
A combobox which displays available layouts from a QgsLayoutManager.
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
void setAllowEmptyLayout(bool allowEmpty)
Sets whether an optional empty layout ("not set") option is present in the combobox.
A combo box which displays items of a matching type from a layout.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
Base class for graphical items within a QgsLayout.
virtual QString uuid() const
Returns the item identification string.
@ FilterPrintLayouts
Includes print layouts.
QList< QgsPrintLayout * > printLayouts() const
Returns a list of all print layouts contained in the manager.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
A combobox which displays a dynamic list of layers from a QGIS project.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
Base class for all map layer types.
A mouse event which is the result of a user interaction with a QgsMapCanvas.
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Interface for master layout type objects, such as print layouts and reports.
virtual QString name() const =0
Returns the layout's name.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
bool clearWidgets()
Removes all items from the bar.
A collection of point cloud attributes.
A combobox which displays the list of attributes of a given point cloud layer.
void attributeChanged(const QString &name)
Emitted when the currently selected attribute changes.
Attribute for point cloud data pair of name and size in bytes.
Represents a map layer supporting display of point clouds.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes available from the layer.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
Base class for all parameter definitions which represent file or layer destinations,...
Encapsulates settings relating to a feature source input to a processing algorithm.
QgsProperty source
Source definition.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for area values.
Qgis::AreaUnit defaultUnit() const
Returns the default area unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A raster band parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
A boolean parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A color parameter for processing algorithms.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
static QString typeName()
Returns the type name for the parameter class.
A coordinate operation parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
QVariant sourceCrs() const
Returns the static source CRS, or an invalid value if this is not set.
QVariant destinationCrs() const
Returns the static destination CRS, or an invalid value if this is not set.
A coordinate reference system parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
A database table name parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
A datetime (or pure date or time) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
void setFlags(Qgis::ProcessingParameterFlags flags)
Sets the flags associated with the parameter.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
QString description() const
Returns the description for the parameter.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
virtual QString type() const =0
Unique parameter type name.
QString name() const
Returns the name of the parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
A double numeric parameter for duration values.
Qgis::TemporalUnit defaultUnit() const
Returns the default duration unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
static QString typeName()
Returns the type name for the parameter class.
An expression parameter for processing algorithms.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ExpressionType expressionType() const
Returns the parameter's expression type.
A rectangular map extent parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
An input feature source (such as vector layers) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A vector layer or feature source field parameter for processing algorithms.
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
static QString typeName()
Returns the type name for the parameter class.
A geometry parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A print layout item parameter, allowing users to select a particular item from a print layout.
static QString typeName()
Returns the type name for the parameter class.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
A print layout parameter, allowing users to select a print layout.
static QString typeName()
Returns the type name for the parameter class.
A map layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
static QString typeName()
Returns the type name for the parameter class.
A table (matrix) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
static QString typeName()
Returns the type name for the parameter class.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
double maximum() const
Returns the maximum value acceptable by the parameter.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer attribute parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A point parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A data provider connection parameter for processing algorithms, allowing users to select from availab...
static QString typeName()
Returns the type name for the parameter class.
QString providerId() const
Returns the ID of the provider associated with the connections.
A numeric range parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
A raster layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool multiLine() const
Returns true if the parameter allows multiline strings.
static QString typeName()
Returns the type name for the parameter class.
A vector layer (with or without geometry) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for volume values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::VolumeUnit defaultUnit() const
Returns the default volume unit for the parameter.
Contains settings which reflect the context in which a Processing parameter widget is shown.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsProject * project() const
Returns the project associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
QgsMapLayer * activeLayer() const
Returns the current active layer.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a list of map layers.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QStringList parameterAsStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of strings (e.g.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a point cloud layer.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Utility functions for use with processing classes.
@ Annotation
Annotation layer type, since QGIS 3.22.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
void layerRemoved(const QString &layerId)
Emitted after a layer was removed from the registry.
A store for object properties.
Qgis::PropertyType propertyType() const
Returns the property type.
A combo box which displays the list of connections registered for a given provider.
A combobox widget which displays the bands present in a raster layer.
void bandChanged(int band)
Emitted when the currently selected band changes.
static QString displayBandName(QgsRasterDataProvider *provider, int band)
Returns a user-friendly band name for the specified band.
Base class for raster data providers.
virtual int bandCount() const =0
Gets number of bands.
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
A rectangle specified with double values.
A QgsGeometry with associated coordinate reference system.
Responsible for drawing transient features (e.g.
@ ICON_X
A cross is used to highlight points (x)
Stores settings for use within QGIS.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Shows a snapping marker on map canvas for the current snapping match.
A spin box with a clear button that will set the value to the defined clear value.
A QTimeEdit widget with the capability of setting/reading null date/times.
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE Qgis::DistanceUnitType unitType(Qgis::DistanceUnit unit)
Returns the type for a distance unit.
static Q_INVOKABLE Qgis::AreaUnit distanceToAreaUnit(Qgis::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding area unit, e.g., meters to square meters.
static Q_INVOKABLE Qgis::VolumeUnit distanceToVolumeUnit(Qgis::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding volume unit, e.g., meters to cubic meters.
Represents a vector layer which manages a vector based dataset.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const QgsCoordinateReferenceSystem & crs