76#include <QButtonGroup>
84#include <QPlainTextEdit>
85#include <QRadioButton>
90#include "moc_qgsprocessingwidgetwrapperimpl.cpp"
92using namespace Qt::StringLiterals;
104 QVBoxLayout *vlayout =
new QVBoxLayout();
105 vlayout->setContentsMargins( 0, 0, 0, 0 );
107 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
111 mDefaultCheckBox->setChecked(
false );
112 vlayout->addWidget( mDefaultCheckBox );
113 setLayout( vlayout );
118 auto param = std::make_unique<QgsProcessingParameterBoolean>( name, description, mDefaultCheckBox->isChecked() );
119 param->setFlags( flags );
120 return param.release();
129QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
135 QString description = parameterDefinition()->description();
137 description = QObject::tr(
"%1 [optional]" ).arg( description );
139 mCheckBox =
new QCheckBox( description );
140 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
142 connect( mCheckBox, &QCheckBox::toggled,
this, [
this] {
143 emit widgetValueHasChanged(
this );
151 mComboBox =
new QComboBox();
152 mComboBox->addItem( tr(
"Yes" ),
true );
153 mComboBox->addItem( tr(
"No" ),
false );
154 mComboBox->setToolTip( parameterDefinition()->toolTip() );
156 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
157 emit widgetValueHasChanged(
this );
166QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
175void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
182 mCheckBox->setChecked( v );
190 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
196QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
201 return mCheckBox->isChecked();
205 return mComboBox->currentData();
210QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
217 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
222 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
233 QVBoxLayout *vlayout =
new QVBoxLayout();
234 vlayout->setContentsMargins( 0, 0, 0, 0 );
236 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
241 mCrsSelector->setShowAccuracyWarnings(
true );
248 vlayout->addWidget( mCrsSelector );
249 setLayout( vlayout );
254 auto param = std::make_unique<QgsProcessingParameterCrs>( name, description, mCrsSelector->crs().authid() );
255 param->setFlags( flags );
256 return param.release();
264QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
266 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
268 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
276 emit widgetValueHasChanged(
this );
284 return mProjectionSelectionWidget;
289 QWidget *w =
new QWidget();
290 w->setToolTip( parameterDefinition()->toolTip() );
292 QVBoxLayout *vl =
new QVBoxLayout();
293 vl->setContentsMargins( 0, 0, 0, 0 );
296 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
297 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
298 vl->addWidget( mUseProjectCrsCheckBox );
299 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
300 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [
this] {
301 emit widgetValueHasChanged(
this );
304 vl->addWidget( mProjectionSelectionWidget );
312void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
314 if ( mUseProjectCrsCheckBox )
316 if ( value.toString().compare(
"ProjectCrs"_L1, Qt::CaseInsensitive ) == 0 )
318 mUseProjectCrsCheckBox->setChecked(
true );
323 mUseProjectCrsCheckBox->setChecked(
false );
328 if ( mProjectionSelectionWidget )
329 mProjectionSelectionWidget->setCrs( v );
332QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
334 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
335 return u
"ProjectCrs"_s;
336 else if ( mProjectionSelectionWidget )
337 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
342QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
344 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
347QString QgsProcessingCrsWidgetWrapper::parameterType()
const
354 return new QgsProcessingCrsWidgetWrapper( parameter, type );
359 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
371 QVBoxLayout *vlayout =
new QVBoxLayout();
372 vlayout->setContentsMargins( 0, 0, 0, 0 );
374 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
376 mDefaultLineEdit =
new QLineEdit();
379 vlayout->addWidget( mDefaultLineEdit );
381 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
383 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
384 vlayout->addWidget( mMultiLineCheckBox );
386 setLayout( vlayout );
391 auto param = std::make_unique<QgsProcessingParameterString>( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
392 param->setFlags( flags );
393 return param.release();
402QWidget *QgsProcessingStringWidgetWrapper::createWidget()
404 const QVariantMap metadata = parameterDefinition()->metadata();
405 const QVariant valueHintsVariant = metadata.value( u
"widget_wrapper"_s ).toMap().value( u
"value_hints"_s );
407 if ( valueHintsVariant.isValid() )
409 const QVariantList valueList = valueHintsVariant.toList();
410 mComboBox =
new QComboBox();
411 mComboBox->setToolTip( parameterDefinition()->toolTip() );
415 mComboBox->addItem( QString() );
417 for (
const QVariant &entry : valueList )
419 mComboBox->addItem( entry.toString(), entry.toString() );
421 mComboBox->setCurrentIndex( 0 );
423 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
424 emit widgetValueHasChanged(
this );
437 mPlainTextEdit =
new QPlainTextEdit();
438 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
440 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [
this] {
441 emit widgetValueHasChanged(
this );
443 return mPlainTextEdit;
447 mLineEdit =
new QLineEdit();
448 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
450 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
451 emit widgetValueHasChanged(
this );
459 mLineEdit =
new QLineEdit();
460 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
462 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
463 emit widgetValueHasChanged(
this );
473void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
477 mLineEdit->setText( v );
478 if ( mPlainTextEdit )
479 mPlainTextEdit->setPlainText( v );
483 if ( !value.isValid() )
484 index = mComboBox->findData( QVariant() );
486 index = mComboBox->findData( v );
489 mComboBox->setCurrentIndex( index );
491 mComboBox->setCurrentIndex( 0 );
495QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
498 return mLineEdit->text();
499 else if ( mPlainTextEdit )
500 return mPlainTextEdit->toPlainText();
501 else if ( mComboBox )
502 return mComboBox->currentData();
507QString QgsProcessingStringWidgetWrapper::parameterType()
const
514 return new QgsProcessingStringWidgetWrapper( parameter, type );
519 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
532QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
541 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
544 emit widgetValueHasChanged(
this );
546 return mAuthConfigSelect;
552void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
555 if ( mAuthConfigSelect )
556 mAuthConfigSelect->setConfigId( v );
559QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
561 if ( mAuthConfigSelect )
562 return mAuthConfigSelect->configId();
567QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
574 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
584 QVBoxLayout *vlayout =
new QVBoxLayout();
585 vlayout->setContentsMargins( 0, 0, 0, 0 );
587 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
589 mTypeComboBox =
new QComboBox();
592 vlayout->addWidget( mTypeComboBox );
594 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
595 mMinLineEdit =
new QLineEdit();
596 vlayout->addWidget( mMinLineEdit );
598 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
599 mMaxLineEdit =
new QLineEdit();
600 vlayout->addWidget( mMaxLineEdit );
602 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
603 mDefaultLineEdit =
new QLineEdit();
604 vlayout->addWidget( mDefaultLineEdit );
608 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( numberParam->dataType() ) ) );
610 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
612 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
616 mMaxLineEdit->clear();
619 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
621 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
625 mMinLineEdit->clear();
628 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
631 setLayout( vlayout );
640 auto param = std::make_unique<QgsProcessingParameterNumber>( name, description, dataType, ok ? val : QVariant() );
642 if ( !mMinLineEdit->text().trimmed().isEmpty() )
647 param->setMinimum( val );
651 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
656 param->setMaximum( val );
660 param->setFlags( flags );
661 return param.release();
669QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
672 const QVariantMap metadata = numberDef->
metadata();
673 const int decimals = metadata.value( u
"widget_wrapper"_s ).toMap().value( u
"decimals"_s, 6 ).toInt();
681 QAbstractSpinBox *spinBox =
nullptr;
686 mDoubleSpinBox->setExpressionsEnabled(
true );
687 mDoubleSpinBox->setDecimals( decimals );
692 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
693 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
694 mDoubleSpinBox->setSingleStep( singleStep );
697 spinBox = mDoubleSpinBox;
702 mSpinBox->setExpressionsEnabled(
true );
706 spinBox->setToolTip( parameterDefinition()->toolTip() );
708 double max = 999999999;
713 double min = -999999999;
718 if ( mDoubleSpinBox )
720 mDoubleSpinBox->setMinimum( min );
721 mDoubleSpinBox->setMaximum( max );
725 mSpinBox->setMinimum(
static_cast<int>( min ) );
726 mSpinBox->setMaximum(
static_cast<int>( max ) );
731 mAllowingNull =
true;
732 if ( mDoubleSpinBox )
734 mDoubleSpinBox->setShowClearButton(
true );
735 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
736 mDoubleSpinBox->setMinimum( min );
737 mDoubleSpinBox->setValue( min );
741 mSpinBox->setShowClearButton(
true );
742 const int min = mSpinBox->minimum() - 1;
743 mSpinBox->setMinimum( min );
744 mSpinBox->setValue( min );
746 spinBox->setSpecialValueText( tr(
"Not set" ) );
754 if ( mDoubleSpinBox )
758 mDoubleSpinBox->setClearValue( defaultVal );
764 mSpinBox->setClearValue( intVal );
770 if ( mDoubleSpinBox )
771 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
773 mSpinBox->setClearValue(
static_cast<int>( numberDef->
minimum() ) );
778 if ( mDoubleSpinBox )
780 mDoubleSpinBox->setValue( 0 );
781 mDoubleSpinBox->setClearValue( 0 );
785 mSpinBox->setValue( 0 );
786 mSpinBox->setClearValue( 0 );
791 if ( mDoubleSpinBox )
792 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
794 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
802void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
804 if ( mDoubleSpinBox )
806 if ( mAllowingNull && !value.isValid() )
807 mDoubleSpinBox->clear();
811 mDoubleSpinBox->setValue( v );
816 if ( mAllowingNull && !value.isValid() )
821 mSpinBox->setValue( v );
826QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
828 if ( mDoubleSpinBox )
830 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
833 return mDoubleSpinBox->value();
837 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
840 return mSpinBox->value();
846double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
848 const double valueRange = maximum - minimum;
849 if ( valueRange <= 1.0 )
851 const double step = valueRange / 10.0;
853 return qgsRound( step, -std::floor( std::log( step ) ) );
861QString QgsProcessingNumericWidgetWrapper::parameterType()
const
868 return new QgsProcessingNumericWidgetWrapper( parameter, type );
873 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
883 QVBoxLayout *vlayout =
new QVBoxLayout();
884 vlayout->setContentsMargins( 0, 0, 0, 0 );
886 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
888 mParentLayerComboBox =
new QComboBox();
890 QString initialParent;
892 initialParent = distParam->parentParameterName();
894 if (
auto *lModel = widgetContext.
model() )
897 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
898 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
902 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
903 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
905 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
910 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
911 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
913 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
918 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
919 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
921 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
926 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
927 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
929 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
935 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
938 mParentLayerComboBox->addItem( initialParent, initialParent );
939 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
942 vlayout->addWidget( mParentLayerComboBox );
944 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
945 mMinLineEdit =
new QLineEdit();
946 vlayout->addWidget( mMinLineEdit );
948 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
949 mMaxLineEdit =
new QLineEdit();
950 vlayout->addWidget( mMaxLineEdit );
952 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
953 mDefaultLineEdit =
new QLineEdit();
954 vlayout->addWidget( mDefaultLineEdit );
958 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
959 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
960 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
963 setLayout( vlayout );
971 auto param = std::make_unique<QgsProcessingParameterDistance>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
976 param->setMinimum( val );
982 param->setMaximum( val );
985 param->setFlags( flags );
986 return param.release();
990 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
994QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
1001 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
1004QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1008 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1013 mLabel =
new QLabel();
1014 mUnitsCombo =
new QComboBox();
1026 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1027 QHBoxLayout *layout =
new QHBoxLayout();
1028 layout->addWidget( spin, 1 );
1029 layout->insertSpacing( 1, labelMargin / 2 );
1030 layout->insertWidget( 2, mLabel );
1031 layout->insertWidget( 3, mUnitsCombo );
1036 mWarningLabel =
new QWidget();
1037 QHBoxLayout *warningLayout =
new QHBoxLayout();
1038 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1039 QLabel *warning =
new QLabel();
1041 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1042 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1043 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1044 warningLayout->insertSpacing( 0, labelMargin / 2 );
1045 warningLayout->insertWidget( 1, warning );
1046 mWarningLabel->setLayout( warningLayout );
1047 layout->insertWidget( 4, mWarningLabel );
1049 QWidget *w =
new QWidget();
1050 layout->setContentsMargins( 0, 0, 0, 0 );
1051 w->setLayout( layout );
1065void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1067 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1074 if ( wrapper->parameterDefinition()->name() ==
static_cast<const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1076 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1078 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1098 std::unique_ptr<QgsProcessingContext> tmpContext;
1099 if ( mProcessingContextGenerator )
1100 context = mProcessingContextGenerator->processingContext();
1104 tmpContext = std::make_unique<QgsProcessingContext>();
1105 context = tmpContext.get();
1113 units = crs.mapUnits();
1124 mUnitsCombo->hide();
1132 if ( mBaseUnit != units )
1134 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( units ) ) );
1137 mUnitsCombo->show();
1144QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1146 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1147 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1160 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1171 QVBoxLayout *vlayout =
new QVBoxLayout();
1172 vlayout->setContentsMargins( 0, 0, 0, 0 );
1174 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1176 mParentLayerComboBox =
new QComboBox();
1178 QString initialParent;
1180 initialParent = areaParam->parentParameterName();
1182 if (
auto *lModel = widgetContext.
model() )
1185 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1186 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1190 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1191 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1193 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1198 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1199 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1201 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1206 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1207 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1209 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1214 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1215 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1217 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1223 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1226 mParentLayerComboBox->addItem( initialParent, initialParent );
1227 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1230 vlayout->addWidget( mParentLayerComboBox );
1232 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1233 mMinLineEdit =
new QLineEdit();
1234 vlayout->addWidget( mMinLineEdit );
1236 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1237 mMaxLineEdit =
new QLineEdit();
1238 vlayout->addWidget( mMaxLineEdit );
1240 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1241 mDefaultLineEdit =
new QLineEdit();
1242 vlayout->addWidget( mDefaultLineEdit );
1246 mMinLineEdit->setText( QLocale().toString( areaParam->minimum() ) );
1247 mMaxLineEdit->setText( QLocale().toString( areaParam->maximum() ) );
1248 mDefaultLineEdit->setText( areaParam->defaultValueForGui().toString() );
1251 setLayout( vlayout );
1259 auto param = std::make_unique<QgsProcessingParameterArea>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1264 param->setMinimum( val );
1270 param->setMaximum( val );
1273 param->setFlags( flags );
1274 return param.release();
1283 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1287QString QgsProcessingAreaWidgetWrapper::parameterType()
const
1294 return new QgsProcessingAreaWidgetWrapper( parameter, type );
1297QWidget *QgsProcessingAreaWidgetWrapper::createWidget()
1301 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1306 mLabel =
new QLabel();
1307 mUnitsCombo =
new QComboBox();
1322 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1323 QHBoxLayout *layout =
new QHBoxLayout();
1324 layout->addWidget( spin, 1 );
1325 layout->insertSpacing( 1, labelMargin / 2 );
1326 layout->insertWidget( 2, mLabel );
1327 layout->insertWidget( 3, mUnitsCombo );
1332 mWarningLabel =
new QWidget();
1333 QHBoxLayout *warningLayout =
new QHBoxLayout();
1334 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1335 QLabel *warning =
new QLabel();
1337 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1338 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1339 warning->setToolTip( tr(
"Area is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1340 warningLayout->insertSpacing( 0, labelMargin / 2 );
1341 warningLayout->insertWidget( 1, warning );
1342 mWarningLabel->setLayout( warningLayout );
1343 layout->insertWidget( 4, mWarningLabel );
1345 QWidget *w =
new QWidget();
1346 layout->setContentsMargins( 0, 0, 0, 0 );
1347 w->setLayout( layout );
1361void QgsProcessingAreaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1363 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1394 std::unique_ptr<QgsProcessingContext> tmpContext;
1395 if ( mProcessingContextGenerator )
1396 context = mProcessingContextGenerator->processingContext();
1400 tmpContext = std::make_unique<QgsProcessingContext>();
1401 context = tmpContext.get();
1409 units = QgsUnitTypes::distanceToAreaUnit( crs.mapUnits() );
1415void QgsProcessingAreaWidgetWrapper::setUnits(
Qgis::AreaUnit units )
1420 mUnitsCombo->hide();
1425 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1426 mUnitsCombo->show();
1433QVariant QgsProcessingAreaWidgetWrapper::widgetValue()
const
1435 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1436 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1449 return new QgsProcessingAreaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1460 QVBoxLayout *vlayout =
new QVBoxLayout();
1461 vlayout->setContentsMargins( 0, 0, 0, 0 );
1463 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1465 mParentLayerComboBox =
new QComboBox();
1467 QString initialParent;
1469 initialParent = volumeParam->parentParameterName();
1471 if (
auto *lModel = widgetContext.
model() )
1474 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1475 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1479 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1480 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1482 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1487 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1488 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1490 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1495 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1496 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1498 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1503 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1504 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1506 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1512 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1515 mParentLayerComboBox->addItem( initialParent, initialParent );
1516 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1519 vlayout->addWidget( mParentLayerComboBox );
1521 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1522 mMinLineEdit =
new QLineEdit();
1523 vlayout->addWidget( mMinLineEdit );
1525 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1526 mMaxLineEdit =
new QLineEdit();
1527 vlayout->addWidget( mMaxLineEdit );
1529 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1530 mDefaultLineEdit =
new QLineEdit();
1531 vlayout->addWidget( mDefaultLineEdit );
1535 mMinLineEdit->setText( QLocale().toString( volumeParam->minimum() ) );
1536 mMaxLineEdit->setText( QLocale().toString( volumeParam->maximum() ) );
1537 mDefaultLineEdit->setText( volumeParam->defaultValueForGui().toString() );
1540 setLayout( vlayout );
1548 auto param = std::make_unique<QgsProcessingParameterVolume>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1553 param->setMinimum( val );
1559 param->setMaximum( val );
1562 param->setFlags( flags );
1563 return param.release();
1572 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1576QString QgsProcessingVolumeWidgetWrapper::parameterType()
const
1583 return new QgsProcessingVolumeWidgetWrapper( parameter, type );
1586QWidget *QgsProcessingVolumeWidgetWrapper::createWidget()
1590 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1595 mLabel =
new QLabel();
1596 mUnitsCombo =
new QComboBox();
1609 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1610 QHBoxLayout *layout =
new QHBoxLayout();
1611 layout->addWidget( spin, 1 );
1612 layout->insertSpacing( 1, labelMargin / 2 );
1613 layout->insertWidget( 2, mLabel );
1614 layout->insertWidget( 3, mUnitsCombo );
1619 mWarningLabel =
new QWidget();
1620 QHBoxLayout *warningLayout =
new QHBoxLayout();
1621 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1622 QLabel *warning =
new QLabel();
1624 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1625 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1626 warning->setToolTip( tr(
"Volume is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1627 warningLayout->insertSpacing( 0, labelMargin / 2 );
1628 warningLayout->insertWidget( 1, warning );
1629 mWarningLabel->setLayout( warningLayout );
1630 layout->insertWidget( 4, mWarningLabel );
1632 QWidget *w =
new QWidget();
1633 layout->setContentsMargins( 0, 0, 0, 0 );
1634 w->setLayout( layout );
1648void QgsProcessingVolumeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1650 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1681 std::unique_ptr<QgsProcessingContext> tmpContext;
1682 if ( mProcessingContextGenerator )
1683 context = mProcessingContextGenerator->processingContext();
1687 tmpContext = std::make_unique<QgsProcessingContext>();
1688 context = tmpContext.get();
1696 units = QgsUnitTypes::distanceToVolumeUnit( crs.mapUnits() );
1707 mUnitsCombo->hide();
1712 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1713 mUnitsCombo->show();
1720QVariant QgsProcessingVolumeWidgetWrapper::widgetValue()
const
1722 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1723 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1736 return new QgsProcessingVolumeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1747 QVBoxLayout *vlayout =
new QVBoxLayout();
1748 vlayout->setContentsMargins( 0, 0, 0, 0 );
1750 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1751 mMinLineEdit =
new QLineEdit();
1752 vlayout->addWidget( mMinLineEdit );
1754 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1755 mMaxLineEdit =
new QLineEdit();
1756 vlayout->addWidget( mMaxLineEdit );
1758 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1759 mDefaultLineEdit =
new QLineEdit();
1760 vlayout->addWidget( mDefaultLineEdit );
1762 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1764 mUnitsCombo =
new QComboBox();
1774 vlayout->addWidget( mUnitsCombo );
1778 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1779 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1780 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1781 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationParam->defaultUnit() ) ) );
1784 setLayout( vlayout );
1792 auto param = std::make_unique<QgsProcessingParameterDuration>( name, description, ok ? val : QVariant() );
1797 param->setMinimum( val );
1803 param->setMaximum( val );
1806 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit>( mUnitsCombo->currentData().toInt() ) );
1808 param->setFlags( flags );
1809 return param.release();
1813 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1817QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1824 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1827QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1831 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1836 mUnitsCombo =
new QComboBox();
1848 QHBoxLayout *layout =
new QHBoxLayout();
1849 layout->addWidget( spin, 1 );
1850 layout->insertWidget( 1, mUnitsCombo );
1852 QWidget *w =
new QWidget();
1853 layout->setContentsMargins( 0, 0, 0, 0 );
1854 w->setLayout( layout );
1856 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationDef->
defaultUnit() ) ) );
1857 mUnitsCombo->show();
1869QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
1881QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
1883 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1884 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo )
1895void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1901 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
1905 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
1911 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1921 QVBoxLayout *vlayout =
new QVBoxLayout();
1922 vlayout->setContentsMargins( 0, 0, 0, 0 );
1924 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1926 mDefaultLineEdit =
new QLineEdit();
1930 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1933 vlayout->addWidget( mDefaultLineEdit );
1935 setLayout( vlayout );
1941 double val = mDefaultLineEdit->text().toDouble( &ok );
1942 auto param = std::make_unique<QgsProcessingParameterScale>( name, description, ok ? val : QVariant() );
1943 param->setFlags( flags );
1944 return param.release();
1948 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1952QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1959 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1962QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
1974 mScaleWidget->setAllowNull(
true );
1976 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
1977 mScaleWidget->setShowCurrentScaleButton(
true );
1979 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
1981 emit widgetValueHasChanged(
this );
1983 return mScaleWidget;
1992 mScaleWidget->setMapCanvas( context.
mapCanvas() );
1997QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
1999 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
2002void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2006 if ( mScaleWidget->allowNull() && !value.isValid() )
2007 mScaleWidget->setNull();
2011 mScaleWidget->setScale( v );
2018 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2029 QVBoxLayout *vlayout =
new QVBoxLayout();
2030 vlayout->setContentsMargins( 0, 0, 0, 0 );
2032 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
2034 mTypeComboBox =
new QComboBox();
2037 vlayout->addWidget( mTypeComboBox );
2039 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
2040 mMinLineEdit =
new QLineEdit();
2041 vlayout->addWidget( mMinLineEdit );
2043 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
2044 mMaxLineEdit =
new QLineEdit();
2045 vlayout->addWidget( mMaxLineEdit );
2049 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( rangeParam->dataType() ) ) );
2051 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
2052 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
2055 setLayout( vlayout );
2060 QString defaultValue;
2061 if ( mMinLineEdit->text().isEmpty() )
2063 defaultValue = u
"None"_s;
2071 defaultValue = u
"None"_s;
2075 if ( mMaxLineEdit->text().isEmpty() )
2077 defaultValue +=
",None"_L1;
2083 defaultValue += u
",%1"_s.arg( ok ? QString::number( val ) :
"None"_L1 );
2087 auto param = std::make_unique<QgsProcessingParameterRange>( name, description, dataType, defaultValue );
2088 param->setFlags( flags );
2089 return param.release();
2098QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
2107 QHBoxLayout *layout =
new QHBoxLayout();
2112 mMinSpinBox->setExpressionsEnabled(
true );
2113 mMinSpinBox->setShowClearButton(
false );
2114 mMaxSpinBox->setExpressionsEnabled(
true );
2115 mMaxSpinBox->setShowClearButton(
false );
2117 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
2118 layout->addWidget( minLabel );
2119 layout->addWidget( mMinSpinBox, 1 );
2121 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
2122 layout->addWidget( maxLabel );
2123 layout->addWidget( mMaxSpinBox, 1 );
2125 QWidget *w =
new QWidget();
2126 layout->setContentsMargins( 0, 0, 0, 0 );
2127 w->setLayout( layout );
2131 mMinSpinBox->setDecimals( 6 );
2132 mMaxSpinBox->setDecimals( 6 );
2136 mMinSpinBox->setDecimals( 0 );
2137 mMaxSpinBox->setDecimals( 0 );
2140 mMinSpinBox->setMinimum( -99999999.999999 );
2141 mMaxSpinBox->setMinimum( -99999999.999999 );
2142 mMinSpinBox->setMaximum( 99999999.999999 );
2143 mMaxSpinBox->setMaximum( 99999999.999999 );
2147 mAllowingNull =
true;
2149 const double min = mMinSpinBox->minimum() - 1;
2150 mMinSpinBox->setMinimum( min );
2151 mMaxSpinBox->setMinimum( min );
2152 mMinSpinBox->setValue( min );
2153 mMaxSpinBox->setValue( min );
2155 mMinSpinBox->setShowClearButton(
true );
2156 mMaxSpinBox->setShowClearButton(
true );
2157 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
2158 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
2161 w->setToolTip( parameterDefinition()->toolTip() );
2163 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this](
const double v ) {
2164 mBlockChangedSignal++;
2165 if ( !mAllowingNull && v > mMaxSpinBox->value() )
2166 mMaxSpinBox->setValue( v );
2167 mBlockChangedSignal--;
2169 if ( !mBlockChangedSignal )
2170 emit widgetValueHasChanged(
this );
2172 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this](
const double v ) {
2173 mBlockChangedSignal++;
2174 if ( !mAllowingNull && v < mMinSpinBox->value() )
2175 mMinSpinBox->setValue( v );
2176 mBlockChangedSignal--;
2178 if ( !mBlockChangedSignal )
2179 emit widgetValueHasChanged(
this );
2188void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2191 if ( mAllowingNull && v.empty() )
2193 mMinSpinBox->clear();
2194 mMaxSpinBox->clear();
2201 if ( mAllowingNull )
2203 mBlockChangedSignal++;
2204 if ( std::isnan( v.at( 0 ) ) )
2205 mMinSpinBox->clear();
2207 mMinSpinBox->setValue( v.at( 0 ) );
2209 if ( v.count() >= 2 )
2211 if ( std::isnan( v.at( 1 ) ) )
2212 mMaxSpinBox->clear();
2214 mMaxSpinBox->setValue( v.at( 1 ) );
2216 mBlockChangedSignal--;
2220 mBlockChangedSignal++;
2221 mMinSpinBox->setValue( v.at( 0 ) );
2222 if ( v.count() >= 2 )
2223 mMaxSpinBox->setValue( v.at( 1 ) );
2224 mBlockChangedSignal--;
2228 if ( !mBlockChangedSignal )
2229 emit widgetValueHasChanged(
this );
2232QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
2234 if ( mAllowingNull )
2237 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
2240 value = QString::number( mMinSpinBox->value() );
2242 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
2243 value +=
",None"_L1;
2245 value += u
",%1"_s.arg( mMaxSpinBox->value() );
2250 return u
"%1,%2"_s.arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
2253QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
2255 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
2258QString QgsProcessingRangeWidgetWrapper::parameterType()
const
2265 return new QgsProcessingRangeWidgetWrapper( parameter, type );
2270 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2281 QVBoxLayout *vlayout =
new QVBoxLayout();
2282 vlayout->setContentsMargins( 0, 0, 0, 0 );
2284 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
2287 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
2288 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
2290 vlayout->addWidget( mMatrixWidget );
2291 setLayout( vlayout );
2296 auto param = std::make_unique<QgsProcessingParameterMatrix>( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
2297 param->setFlags( flags );
2298 return param.release();
2307QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
2309 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast<const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
2310 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
2312 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [
this] {
2313 emit widgetValueHasChanged(
this );
2322 return mMatrixWidget;
2328void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2331 if ( mMatrixWidget )
2332 mMatrixWidget->setValue( v );
2335QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
2337 if ( mMatrixWidget )
2338 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
2343QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
2345 return tr(
"comma delimited string of values, or an array of values" );
2348QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
2355 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
2360 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2372 QVBoxLayout *vlayout =
new QVBoxLayout();
2373 vlayout->setContentsMargins( 0, 0, 0, 0 );
2375 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
2377 mTypeComboBox =
new QComboBox();
2381 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( fileParam->behavior() ) ) );
2383 mTypeComboBox->setCurrentIndex( 0 );
2384 vlayout->addWidget( mTypeComboBox );
2386 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
2388 mFilterComboBox =
new QComboBox();
2389 mFilterComboBox->setEditable(
true );
2391 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
2392 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
2393 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
2394 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
2396 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
2398 mFilterComboBox->setCurrentIndex( 0 );
2399 vlayout->addWidget( mFilterComboBox );
2401 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2404 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
2408 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
2412 vlayout->addWidget( mDefaultFileWidget );
2414 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2422 setLayout( vlayout );
2427 auto param = std::make_unique<QgsProcessingParameterFile>( name, description );
2430 param->setFileFilter( mFilterComboBox->currentText() );
2431 if ( !mDefaultFileWidget->filePath().isEmpty() )
2432 param->setDefaultValue( mDefaultFileWidget->filePath() );
2433 param->setFlags( flags );
2434 return param.release();
2443QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2456 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2457 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2459 mFileWidget->setDefaultRoot(
QgsSettings().value( u
"/Processing/LastInputPath"_s, QDir::homePath() ).toString() );
2466 mFileWidget->setFilter( fileParam->
fileFilter() );
2467 else if ( !fileParam->
extension().isEmpty() )
2468 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + u
" (*."_s + fileParam->
extension().toLower() +
')' );
2477 QgsSettings().
setValue( u
"/Processing/LastInputPath"_s, QFileInfo( path ).canonicalPath() );
2478 emit widgetValueHasChanged(
this );
2486void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2490 mFileWidget->setFilePath( v );
2493QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2496 return mFileWidget->filePath();
2501QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2503 return tr(
"string representing a path to a file or folder" );
2506QString QgsProcessingFileWidgetWrapper::parameterType()
const
2513 return new QgsProcessingFileWidgetWrapper( parameter, type );
2518 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2529 QVBoxLayout *vlayout =
new QVBoxLayout();
2530 vlayout->setContentsMargins( 0, 0, 0, 0 );
2531 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2534 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2536 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2537 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2539 QStackedWidget *stackedWidget =
new QStackedWidget();
2540 stackedWidget->addWidget( mDefaultQgisLineEdit );
2541 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2542 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2543 vlayout->addWidget( stackedWidget );
2548 mDefaultQgisLineEdit->setExpression( expr );
2549 mDefaultPointCloudLineEdit->setExpression( expr );
2552 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2554 mParentLayerComboBox =
new QComboBox();
2555 vlayout->addWidget( mParentLayerComboBox );
2557 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2558 mExpressionTypeComboBox =
new QComboBox();
2563 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this, stackedWidget, definition, widgetContext](
int ) {
2564 mParentLayerComboBox->clear();
2565 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2567 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2569 QString initialParent;
2571 initialParent = expParam->parentLayerParameterName();
2575 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2578 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2579 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2586 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2587 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2589 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2594 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2595 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2597 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2604 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2605 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2607 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2618 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2619 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2621 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2629 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2632 mParentLayerComboBox->addItem( initialParent, initialParent );
2633 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2637 mExpressionTypeComboBox->setCurrentIndex( -1 );
2639 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast<int>( expParam->expressionType() ) ) );
2641 mExpressionTypeComboBox->setCurrentIndex( 0 );
2643 vlayout->addWidget( mExpressionTypeComboBox );
2645 setLayout( vlayout );
2652 switch ( expressionType )
2655 expression = mDefaultQgisLineEdit->expression();
2658 expression = mDefaultPointCloudLineEdit->expression();
2661 expression = mDefaultRasterCalculatorLineEdit->expression();
2664 auto param = std::make_unique<QgsProcessingParameterExpression>( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2665 param->setFlags( flags );
2666 return param.release();
2674QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2689 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2690 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2691 mExpLineEdit->registerExpressionContextGenerator(
this );
2693 emit widgetValueHasChanged(
this );
2695 return mExpLineEdit;
2701 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2702 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2703 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [
this](
const QString & ) {
2704 emit widgetValueHasChanged(
this );
2706 return mPointCloudExpLineEdit;
2711 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2712 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2715 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2717 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [
this](
const QString & ) {
2718 emit widgetValueHasChanged(
this );
2720 return mRasterCalculatorExpLineEdit;
2724 if ( expParam->
metadata().value( u
"inlineEditor"_s ).toBool() )
2727 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2728 mExpBuilderWidget->init( createExpressionContext() );
2730 Q_UNUSED( changed );
2731 emit widgetValueHasChanged(
this );
2733 return mExpBuilderWidget;
2738 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2739 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2740 mFieldExpWidget->registerExpressionContextGenerator(
this );
2742 mFieldExpWidget->setAllowEmptyFieldName(
true );
2745 emit widgetValueHasChanged(
this );
2747 return mFieldExpWidget;
2755void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2767 setParentLayerWrapperValue( wrapper );
2769 setParentLayerWrapperValue( wrapper );
2785 if ( mExpBuilderWidget )
2788 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2796 std::unique_ptr<QgsProcessingContext> tmpContext;
2797 if ( mProcessingContextGenerator )
2798 context = mProcessingContextGenerator->processingContext();
2802 tmpContext = std::make_unique<QgsProcessingContext>();
2803 context = tmpContext.get();
2816 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2826 if ( mFieldExpWidget )
2827 mFieldExpWidget->setLayer(
nullptr );
2828 else if ( mExpBuilderWidget )
2829 mExpBuilderWidget->setLayer(
nullptr );
2830 else if ( mExpLineEdit )
2831 mExpLineEdit->setLayer(
nullptr );
2837 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2840 mParentLayer = std::move( ownedLayer );
2848 if ( mFieldExpWidget )
2849 mFieldExpWidget->setLayer( layer );
2850 if ( mExpBuilderWidget )
2851 mExpBuilderWidget->setLayer( layer );
2852 else if ( mExpLineEdit )
2853 mExpLineEdit->setLayer( layer );
2862 if ( mPointCloudExpLineEdit )
2863 mPointCloudExpLineEdit->setLayer(
nullptr );
2869 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2872 mParentLayer = std::move( ownedLayer );
2880 if ( mPointCloudExpLineEdit )
2881 mPointCloudExpLineEdit->setLayer( layer );
2888 if ( layers.isEmpty() )
2890 if ( mRasterCalculatorExpLineEdit )
2892 mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
2897 if ( mRasterCalculatorExpLineEdit )
2899 QVariantList layersList;
2902 layersList << layer->
name();
2904 mRasterCalculatorExpLineEdit->setLayers( layersList );
2912void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2915 if ( mFieldExpWidget )
2916 mFieldExpWidget->setExpression( v );
2917 else if ( mExpBuilderWidget )
2918 mExpBuilderWidget->setExpressionText( v );
2919 else if ( mExpLineEdit )
2920 mExpLineEdit->setExpression( v );
2921 else if ( mPointCloudExpLineEdit )
2922 mPointCloudExpLineEdit->setExpression( v );
2923 else if ( mRasterCalculatorExpLineEdit )
2924 mRasterCalculatorExpLineEdit->setExpression( v );
2927QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2929 if ( mFieldExpWidget )
2930 return mFieldExpWidget->expression();
2931 if ( mExpBuilderWidget )
2932 return mExpBuilderWidget->expressionText();
2933 else if ( mExpLineEdit )
2934 return mExpLineEdit->expression();
2935 else if ( mPointCloudExpLineEdit )
2936 return mPointCloudExpLineEdit->expression();
2937 else if ( mRasterCalculatorExpLineEdit )
2938 return mRasterCalculatorExpLineEdit->expression();
2943QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2945 return tr(
"string representation of an expression" );
2948const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
2950 if ( mFieldExpWidget && mFieldExpWidget->layer() )
2951 return mFieldExpWidget->layer();
2953 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
2954 return mExpBuilderWidget->layer();
2959QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
2966 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
2971 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2983 QHBoxLayout *hl =
new QHBoxLayout();
2984 hl->setContentsMargins( 0, 0, 0, 0 );
2986 mLineEdit =
new QLineEdit();
2987 mLineEdit->setEnabled(
false );
2988 hl->addWidget( mLineEdit, 1 );
2990 mToolButton =
new QToolButton();
2991 mToolButton->setText( QString( QChar( 0x2026 ) ) );
2992 hl->addWidget( mToolButton );
2998 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3001 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
3004void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
3006 if ( value.isValid() )
3008 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3010 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
3016 updateSummaryText();
3020void QgsProcessingEnumPanelWidget::showDialog()
3022 QVariantList availableOptions;
3025 availableOptions.reserve( mParam->options().size() );
3027 if ( mParam->usesStaticStrings() )
3029 for ( QString o : mParam->options() )
3031 availableOptions << o;
3036 for (
int i = 0; i < mParam->options().count(); ++i )
3037 availableOptions << i;
3041 const QStringList options = mParam ? mParam->options() : QStringList();
3045 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3046 widget->setPanelTitle( mParam->description() );
3048 if ( mParam->usesStaticStrings() )
3050 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3051 const QString i = v.toString();
3052 return options.contains( i ) ? i : QString();
3057 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3058 const int i = v.toInt();
3059 return options.size() > i ? options.at( i ) : QString();
3063 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
3064 setValue( widget->selectedOptions() );
3071 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3073 dlg.setValueFormatter( [options](
const QVariant &v ) -> QString {
3074 const int i = v.toInt();
3075 return options.size() > i ? options.at( i ) : QString();
3079 setValue( dlg.selectedOptions() );
3084void QgsProcessingEnumPanelWidget::updateSummaryText()
3089 if ( mValue.empty() )
3091 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3096 values.reserve( mValue.size() );
3097 if ( mParam->usesStaticStrings() )
3099 for (
const QVariant &val : std::as_const( mValue ) )
3101 values << val.toString();
3106 const QStringList options = mParam->options();
3107 for (
const QVariant &val : std::as_const( mValue ) )
3109 const int i = val.toInt();
3110 values << ( options.size() > i ? options.at( i ) : QString() );
3114 const QString concatenated = values.join( tr(
"," ) );
3115 if ( concatenated.length() < 100 )
3116 mLineEdit->setText( concatenated );
3118 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
3126QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
3129 , mButtonGroup( new QButtonGroup( this ) )
3130 , mColumns( columns )
3132 mButtonGroup->setExclusive( !mParam->allowMultiple() );
3134 QGridLayout *l =
new QGridLayout();
3135 l->setContentsMargins( 0, 0, 0, 0 );
3137 int rows =
static_cast<int>( std::ceil( mParam->options().count() /
static_cast<double>( mColumns ) ) );
3138 for (
int i = 0; i < mParam->options().count(); ++i )
3140 QAbstractButton *button =
nullptr;
3141 if ( mParam->allowMultiple() )
3142 button =
new QCheckBox( mParam->options().at( i ) );
3144 button =
new QRadioButton( mParam->options().at( i ) );
3146 connect( button, &QAbstractButton::toggled,
this, [
this] {
3147 if ( !mBlockChangedSignal )
3151 mButtons.insert( i, button );
3153 mButtonGroup->addButton( button, i );
3154 l->addWidget( button, i % rows, i / rows );
3156 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
3159 if ( mParam->allowMultiple() )
3161 setContextMenuPolicy( Qt::CustomContextMenu );
3162 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
3166QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
3168 if ( mParam->allowMultiple() )
3171 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3173 if ( it.value()->isChecked() )
3174 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
3180 if ( mParam->usesStaticStrings() )
3181 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
3183 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
3187void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
3189 mBlockChangedSignal =
true;
3190 if ( mParam->allowMultiple() )
3192 QVariantList selected;
3193 if ( value.isValid() )
3194 selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3195 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3197 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
3198 it.value()->setChecked( selected.contains( v ) );
3204 if ( v.userType() == QMetaType::Type::QVariantList )
3205 v = v.toList().value( 0 );
3207 v = mParam->usesStaticStrings() ?
static_cast< int >( mParam->options().indexOf( v.toString() ) ) : v;
3208 if ( mButtons.contains( v ) )
3209 mButtons.value( v )->setChecked(
true );
3211 mBlockChangedSignal =
false;
3215void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
3218 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
3219 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
3220 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
3221 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
3222 popupMenu.addAction( selectAllAction );
3223 popupMenu.addAction( clearAllAction );
3224 popupMenu.exec( QCursor::pos() );
3227void QgsProcessingEnumCheckboxPanelWidget::selectAll()
3229 mBlockChangedSignal =
true;
3230 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3231 it.value()->setChecked(
true );
3232 mBlockChangedSignal =
false;
3236void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
3238 mBlockChangedSignal =
true;
3239 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3240 it.value()->setChecked(
false );
3241 mBlockChangedSignal =
false;
3253 QVBoxLayout *vlayout =
new QVBoxLayout();
3254 vlayout->setContentsMargins( 0, 0, 0, 0 );
3256 mEnumWidget =
new QgsProcessingEnumModelerWidget();
3259 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
3260 mEnumWidget->setOptions( enumParam->options() );
3261 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
3263 vlayout->addWidget( mEnumWidget );
3264 setLayout( vlayout );
3269 auto param = std::make_unique<QgsProcessingParameterEnum>( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
3271 return param.release();
3280QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
3291 if ( expParam->
metadata().value( u
"widget_wrapper"_s ).toMap().value( u
"useCheckBoxes"_s,
false ).toBool() )
3293 const int columns = expParam->
metadata().value( u
"widget_wrapper"_s ).toMap().value( u
"columns"_s, 2 ).toInt();
3294 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
3295 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
3296 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [
this] {
3297 emit widgetValueHasChanged(
this );
3299 return mCheckboxPanel;
3308 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
3309 mPanel->setToolTip( parameterDefinition()->toolTip() );
3310 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [
this] {
3311 emit widgetValueHasChanged(
this );
3317 mComboBox =
new QComboBox();
3320 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
3321 const QStringList options = expParam->
options();
3322 const QVariantList iconList = expParam->
metadata().value( u
"widget_wrapper"_s ).toMap().value( u
"icons"_s ).toList();
3323 for (
int i = 0; i < options.count(); ++i )
3325 const QIcon icon = iconList.value( i ).value<QIcon>();
3328 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
3330 mComboBox->addItem( icon, options.at( i ), i );
3333 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3334 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
3335 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
3336 emit widgetValueHasChanged(
this );
3345void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3349 if ( !value.isValid() )
3350 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
3356 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3361 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3365 else if ( mPanel || mCheckboxPanel )
3368 if ( value.isValid() )
3373 opts.reserve( v.size() );
3374 for ( QString i : v )
3380 opts.reserve( v.size() );
3386 mPanel->setValue( opts );
3387 else if ( mCheckboxPanel )
3388 mCheckboxPanel->setValue( opts );
3392QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3395 return mComboBox->currentData();
3397 return mPanel->value();
3398 else if ( mCheckboxPanel )
3399 return mCheckboxPanel->value();
3404QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3406 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3409QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3416 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3421 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3433QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3445 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() :
nullptr );
3447 mComboBox->setAllowEmptyLayout(
true );
3450 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3452 emit widgetValueHasChanged(
this );
3459 mPlainComboBox =
new QComboBox();
3460 mPlainComboBox->setEditable(
true );
3461 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3462 if ( widgetContext().project() )
3466 mPlainComboBox->addItem( layout->name() );
3469 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
3470 emit widgetValueHasChanged(
this );
3472 return mPlainComboBox;
3478void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3482 if ( !value.isValid() )
3483 mComboBox->setCurrentLayout(
nullptr );
3487 mComboBox->setCurrentLayout( l );
3489 mComboBox->setCurrentLayout(
nullptr );
3492 else if ( mPlainComboBox )
3495 mPlainComboBox->setCurrentText( v );
3499QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3504 return l ? l->
name() : QVariant();
3506 else if ( mPlainComboBox )
3507 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3515 if ( mPlainComboBox && context.
project() )
3519 mPlainComboBox->addItem( layout->name() );
3523QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3525 return tr(
"string representing the name of an existing print layout" );
3528QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3535 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3547 QVBoxLayout *vlayout =
new QVBoxLayout();
3548 vlayout->setContentsMargins( 0, 0, 0, 0 );
3550 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3552 mParentLayoutComboBox =
new QComboBox();
3553 QString initialParent;
3555 initialParent = itemParam->parentLayoutParameterName();
3557 if (
auto *lModel = widgetContext.
model() )
3560 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3561 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3565 mParentLayoutComboBox->addItem( definition->
description(), definition->
name() );
3566 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3568 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3574 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3577 mParentLayoutComboBox->addItem( initialParent, initialParent );
3578 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3581 vlayout->addWidget( mParentLayoutComboBox );
3582 setLayout( vlayout );
3586 auto param = std::make_unique<QgsProcessingParameterLayoutItem>( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3588 return param.release();
3597QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3611 mComboBox->setAllowEmptyItem(
true );
3612 if ( layoutParam->
itemType() >= 0 )
3615 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3617 emit widgetValueHasChanged(
this );
3624 mLineEdit =
new QLineEdit();
3625 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3626 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString & ) {
3627 emit widgetValueHasChanged(
this );
3635void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3662void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3668 std::unique_ptr<QgsProcessingContext> tmpContext;
3669 if ( mProcessingContextGenerator )
3670 context = mProcessingContextGenerator->processingContext();
3674 tmpContext = std::make_unique<QgsProcessingContext>();
3675 context = tmpContext.get();
3679 setLayout( layout );
3682void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3685 mComboBox->setCurrentLayout( layout );
3688void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3692 if ( !value.isValid() )
3693 mComboBox->setItem(
nullptr );
3697 mComboBox->setItem( item );
3700 else if ( mLineEdit )
3703 mLineEdit->setText( v );
3707QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3712 return i ? i->
uuid() : QVariant();
3714 else if ( mLineEdit )
3715 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3721QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3723 return tr(
"string representing the UUID or ID of an existing print layout item" );
3726QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3733 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3738 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3745QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3749 mSnapIndicator = std::make_unique<QgsSnapIndicator>( canvas );
3752QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3754void QgsProcessingPointMapTool::deactivate()
3768 if ( e->button() == Qt::LeftButton )
3771 emit clicked( point );
3776void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3778 if ( e->key() == Qt::Key_Escape )
3791QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3794 QHBoxLayout *l =
new QHBoxLayout();
3795 l->setContentsMargins( 0, 0, 0, 0 );
3797 mLineEdit->setShowClearButton(
false );
3798 l->addWidget( mLineEdit, 1 );
3799 mButton =
new QToolButton();
3800 mButton->setText( QString( QChar( 0x2026 ) ) );
3801 l->addWidget( mButton );
3804 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3805 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::textChanged );
3806 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3807 mButton->setVisible(
false );
3810void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
3813 if ( mAllowSelectOnCanvas )
3815 mButton->setVisible(
true );
3818 mTool = std::make_unique<QgsProcessingPointMapTool>( mCanvas );
3819 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
3820 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
3824void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
3826 mLineEdit->setShowClearButton( allowNull );
3829void QgsProcessingPointPanel::setShowPointOnCanvas(
bool show )
3831 if ( mShowPointOnCanvas == show )
3834 mShowPointOnCanvas = show;
3835 if ( mShowPointOnCanvas )
3841 mMapPointRubberBand.reset();
3845void QgsProcessingPointPanel::setAllowSelectOnCanvas(
bool allow )
3847 mAllowSelectOnCanvas = allow;
3848 mButton->setVisible( mAllowSelectOnCanvas &&
static_cast<bool>( mTool ) );
3851QVariant QgsProcessingPointPanel::value()
const
3853 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
3856void QgsProcessingPointPanel::clear()
3864 QString newText = u
"%1,%2"_s
3865 .arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) );
3868 if ( mCrs.isValid() )
3870 newText += u
" [%1]"_s.arg( mCrs.authid() );
3872 mLineEdit->setText( newText );
3876void QgsProcessingPointPanel::showEvent( QShowEvent * )
3881 if ( QWidget *parentWindow = window() )
3883 setAllowSelectOnCanvas( !parentWindow->isModal() );
3889void QgsProcessingPointPanel::selectOnCanvas()
3894 mPrevTool = mCanvas->mapTool();
3895 mCanvas->setMapTool( mTool.get() );
3897 emit toggleDialogVisibility(
false );
3900void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3902 setValue( point, mCanvas->mapSettings().destinationCrs() );
3905void QgsProcessingPointPanel::pointPicked()
3910 mCanvas->setMapTool( mPrevTool );
3912 emit toggleDialogVisibility(
true );
3915void QgsProcessingPointPanel::textChanged(
const QString &text )
3917 const thread_local QRegularExpression rx( u
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$"_s );
3919 const QRegularExpressionMatch match = rx.match( text );
3920 if ( match.hasMatch() )
3923 const double x = match.captured( 1 ).toDouble( &xOk );
3925 const double y = match.captured( 2 ).toDouble( &yOk );
3932 if ( pointCrs.isValid() )
3950void QgsProcessingPointPanel::updateRubberBand()
3952 if ( !mShowPointOnCanvas || !mCanvas )
3955 if ( mPoint.isEmpty() )
3957 mMapPointRubberBand.reset();
3961 if ( !mMapPointRubberBand )
3964 mMapPointRubberBand->setZValue( 1000 );
3967 const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
3968 mMapPointRubberBand->setWidth( scaleFactor );
3969 mMapPointRubberBand->setIconSize( scaleFactor * 5 );
3971 mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
3972 mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
3986 QVBoxLayout *vlayout =
new QVBoxLayout();
3987 vlayout->setContentsMargins( 0, 0, 0, 0 );
3989 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3991 mDefaultLineEdit =
new QLineEdit();
3992 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3993 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
3997 mDefaultLineEdit->setText( u
"%1,%2"_s.arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
4000 vlayout->addWidget( mDefaultLineEdit );
4001 setLayout( vlayout );
4006 auto param = std::make_unique<QgsProcessingParameterPoint>( name, description, mDefaultLineEdit->text() );
4008 return param.release();
4016QWidget *QgsProcessingPointWidgetWrapper::createWidget()
4027 mPanel =
new QgsProcessingPointPanel(
nullptr );
4028 if ( widgetContext().mapCanvas() )
4029 mPanel->setMapCanvas( widgetContext().mapCanvas() );
4032 mPanel->setAllowNull(
true );
4035 mPanel->setShowPointOnCanvas(
true );
4037 mPanel->setToolTip( parameterDefinition()->toolTip() );
4039 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [
this] {
4040 emit widgetValueHasChanged(
this );
4044 setDialog( mDialog );
4050 mLineEdit =
new QLineEdit();
4051 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4052 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString & ) {
4053 emit widgetValueHasChanged(
this );
4065 mPanel->setMapCanvas( context.
mapCanvas() );
4068void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
4073 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [
this](
bool visible ) {
4075 mDialog->showMinimized();
4078 mDialog->showNormal();
4080 mDialog->activateWindow();
4087void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4091 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
4097 mPanel->setValue( p, crs );
4100 else if ( mLineEdit )
4103 mLineEdit->setText( v );
4107QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
4111 return mPanel->value();
4113 else if ( mLineEdit )
4114 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
4119QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
4121 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
4124QString QgsProcessingPointWidgetWrapper::parameterType()
const
4131 return new QgsProcessingPointWidgetWrapper( parameter, type );
4136 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4148 QVBoxLayout *vlayout =
new QVBoxLayout();
4149 vlayout->setContentsMargins( 0, 0, 0, 0 );
4151 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4163 vlayout->addWidget( mGeometryWidget );
4164 setLayout( vlayout );
4170 auto param = std::make_unique<QgsProcessingParameterGeometry>( name, description, geometry.
isEmpty() ? QVariant() : geometry.
asWkt() );
4172 return param.release();
4180QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
4189 mGeometryWidget->setToolTip( parameterDefinition()->toolTip() );
4191 emit widgetValueHasChanged(
this );
4193 return mGeometryWidget;
4199void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4201 if ( mGeometryWidget )
4210 mGeometryWidget->clearGeometry();
4215QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
4217 if ( mGeometryWidget )
4220 return geometry.
isEmpty() ? QVariant() : geometry.asWkt();
4228QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
4230 return tr(
"string in the Well-Known-Text format or a geometry value" );
4233QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
4240 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
4245 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4257 QVBoxLayout *vlayout =
new QVBoxLayout();
4258 vlayout->setContentsMargins( 0, 0, 0, 0 );
4260 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4263 mDefaultColorButton->setShowNull(
true );
4264 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
4270 mDefaultColorButton->setToNull();
4272 mDefaultColorButton->setColor(
c );
4273 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
4277 mDefaultColorButton->setToNull();
4278 mAllowOpacity->setChecked(
true );
4281 vlayout->addWidget( mDefaultColorButton );
4282 vlayout->addWidget( mAllowOpacity );
4283 setLayout( vlayout );
4288 auto param = std::make_unique<QgsProcessingParameterColor>( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
4290 return param.release();
4298QWidget *QgsProcessingColorWidgetWrapper::createWidget()
4311 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
4314 mColorButton->setShowNull(
true );
4317 mColorButton->setToolTip( parameterDefinition()->toolTip() );
4318 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
4325 emit widgetValueHasChanged(
this );
4328 return mColorButton;
4334void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4338 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() )
4339 || ( value.userType() == QMetaType::Type::QColor && !value.value<QColor>().isValid() ) )
4340 mColorButton->setToNull();
4344 if ( !
c.isValid() && mColorButton->showNull() )
4345 mColorButton->setToNull();
4347 mColorButton->setColor(
c );
4352QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
4355 return mColorButton->isNull() ? QVariant() : mColorButton->color();
4360QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
4362 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
4365QString QgsProcessingColorWidgetWrapper::parameterType()
const
4372 return new QgsProcessingColorWidgetWrapper( parameter, type );
4377 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4388 QVBoxLayout *vlayout =
new QVBoxLayout();
4389 vlayout->setContentsMargins( 0, 0, 0, 0 );
4391 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4393 mDefaultLineEdit =
new QLineEdit();
4396 vlayout->addWidget( mDefaultLineEdit );
4398 mSourceParamComboBox =
new QComboBox();
4399 mDestParamComboBox =
new QComboBox();
4400 QString initialSource;
4401 QString initialDest;
4406 initialSource = itemParam->sourceCrsParameterName();
4407 initialDest = itemParam->destinationCrsParameterName();
4412 mSourceParamComboBox->addItem( QString(), QString() );
4413 mDestParamComboBox->addItem( QString(), QString() );
4414 if (
auto *lModel = widgetContext.
model() )
4417 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4418 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4420 if ( definition && it->parameterName() == definition->
name() )
4424 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4425 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4426 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4428 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4430 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4432 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4437 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4440 mSourceParamComboBox->addItem( initialSource, initialSource );
4441 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4443 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4446 mDestParamComboBox->addItem( initialDest, initialDest );
4447 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4450 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4451 vlayout->addWidget( mSourceParamComboBox );
4452 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4453 vlayout->addWidget( mDestParamComboBox );
4457 mStaticSourceWidget->setCrs( sourceCrs );
4460 mStaticDestWidget->setCrs( destCrs );
4462 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4463 vlayout->addWidget( mStaticSourceWidget );
4464 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4465 vlayout->addWidget( mStaticDestWidget );
4467 setLayout( vlayout );
4472 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() );
4474 return param.release();
4482QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4496 mOperationWidget->setShowMakeDefault(
false );
4497 mOperationWidget->setShowFallbackOption(
false );
4498 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4499 mOperationWidget->setSourceCrs( mSourceCrs );
4500 mOperationWidget->setDestinationCrs( mDestCrs );
4501 mOperationWidget->setMapCanvas( mCanvas );
4506 mOperationWidget->setSelectedOperation( deets );
4510 emit widgetValueHasChanged(
this );
4513 return mOperationWidget;
4519 mLineEdit =
new QLineEdit();
4520 QHBoxLayout *layout =
new QHBoxLayout();
4521 layout->addWidget( mLineEdit, 1 );
4522 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
4523 emit widgetValueHasChanged(
this );
4526 QToolButton *button =
new QToolButton();
4527 button->setText( QString( QChar( 0x2026 ) ) );
4528 connect( button, &QToolButton::clicked,
this, [
this, button] {
4529 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4532 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4533 emit widgetValueHasChanged(
this );
4536 layout->addWidget( button );
4538 QWidget *w =
new QWidget();
4539 layout->setContentsMargins( 0, 0, 0, 0 );
4540 w->setLayout( layout );
4547void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4583 if ( mOperationWidget )
4584 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4587void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4589 if ( mOperationWidget )
4591 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4594 deets.
proj = value.toString();
4595 mOperationWidget->setSelectedOperation( deets );
4600 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4602 mLineEdit->setText( value.toString() );
4607QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4609 if ( mOperationWidget )
4610 return mOperationWidget->selectedOperation().proj;
4611 else if ( mLineEdit )
4612 return mLineEdit->text();
4617QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4619 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4622void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4625 std::unique_ptr<QgsProcessingContext> tmpContext;
4626 if ( mProcessingContextGenerator )
4627 context = mProcessingContextGenerator->processingContext();
4631 tmpContext = std::make_unique<QgsProcessingContext>();
4632 context = tmpContext.get();
4636 if ( mOperationWidget )
4638 mOperationWidget->setSourceCrs( mSourceCrs );
4639 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4643void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4646 std::unique_ptr<QgsProcessingContext> tmpContext;
4647 if ( mProcessingContextGenerator )
4648 context = mProcessingContextGenerator->processingContext();
4652 tmpContext = std::make_unique<QgsProcessingContext>();
4653 context = tmpContext.get();
4657 if ( mOperationWidget )
4659 mOperationWidget->setDestinationCrs( mDestCrs );
4660 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4664QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
4671 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
4676 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4688 QHBoxLayout *hl =
new QHBoxLayout();
4689 hl->setContentsMargins( 0, 0, 0, 0 );
4691 mLineEdit =
new QLineEdit();
4692 mLineEdit->setEnabled(
false );
4693 hl->addWidget( mLineEdit, 1 );
4695 mToolButton =
new QToolButton();
4696 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4697 hl->addWidget( mToolButton );
4703 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4706 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4709void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4715 QVariantList availableFields;
4716 for (
const QgsField &field : std::as_const( mFields ) )
4718 availableFields << field.name();
4720 QList<QVariant>::iterator it = std::remove_if( mValue.begin(), mValue.end(), [&availableFields](
const QVariant &value ) { return !availableFields.contains( value ); } );
4721 mValue.erase( it, mValue.end() );
4723 updateSummaryText();
4727void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4729 if ( value.isValid() )
4730 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
4734 updateSummaryText();
4738void QgsProcessingFieldPanelWidget::showDialog()
4740 QVariantList availableOptions;
4741 availableOptions.reserve( mFields.size() );
4742 for (
const QgsField &field : std::as_const( mFields ) )
4744 availableOptions << field.name();
4750 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4751 widget->setPanelTitle( mParam->description() );
4753 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
4754 return v.toString();
4757 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
4758 setValue( widget->selectedOptions() );
4765 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4767 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
4768 return v.toString();
4772 setValue( dlg.selectedOptions() );
4777void QgsProcessingFieldPanelWidget::updateSummaryText()
4782 if ( mValue.empty() )
4784 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4789 values.reserve( mValue.size() );
4790 for (
const QVariant &val : std::as_const( mValue ) )
4792 values << val.toString();
4795 const QString concatenated = values.join( tr(
"," ) );
4796 if ( concatenated.length() < 100 )
4797 mLineEdit->setText( concatenated );
4799 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4811 QVBoxLayout *vlayout =
new QVBoxLayout();
4812 vlayout->setContentsMargins( 0, 0, 0, 0 );
4814 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4815 mParentLayerComboBox =
new QComboBox();
4817 QString initialParent;
4819 initialParent = fieldParam->parentLayerParameterName();
4821 if (
auto *lModel = widgetContext.
model() )
4824 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4825 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4829 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4830 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4832 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4837 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4838 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4840 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4847 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4848 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4850 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4857 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4860 mParentLayerComboBox->addItem( initialParent, initialParent );
4861 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4864 vlayout->addWidget( mParentLayerComboBox );
4866 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4867 mDataTypeComboBox =
new QComboBox();
4875 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast<int>( fieldParam->dataType() ) ) );
4877 vlayout->addWidget( mDataTypeComboBox );
4879 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4881 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4883 vlayout->addWidget( mAllowMultipleCheckBox );
4885 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4886 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4888 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4890 vlayout->addWidget( mDefaultToAllCheckBox );
4892 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [
this] {
4893 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4896 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4898 mDefaultLineEdit =
new QLineEdit();
4899 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4903 mDefaultLineEdit->setText( fields.join(
';' ) );
4905 vlayout->addWidget( mDefaultLineEdit );
4907 setLayout( vlayout );
4914 QVariant defaultValue;
4915 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4917 defaultValue = mDefaultLineEdit->text();
4919 auto param = std::make_unique<QgsProcessingParameterField>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
4921 return param.release();
4929QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
4942 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
4943 mPanel->setToolTip( parameterDefinition()->toolTip() );
4944 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [
this] {
4945 emit widgetValueHasChanged(
this );
4965 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4967 emit widgetValueHasChanged(
this );
4975 mLineEdit =
new QLineEdit();
4976 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
4977 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
4978 emit widgetValueHasChanged(
this );
4986void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4998 setParentLayerWrapperValue( wrapper );
5000 setParentLayerWrapperValue( wrapper );
5017 std::unique_ptr<QgsProcessingContext> tmpContext;
5018 if ( mProcessingContextGenerator )
5019 context = mProcessingContextGenerator->processingContext();
5023 tmpContext = std::make_unique<QgsProcessingContext>();
5024 context = tmpContext.get();
5029 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
5039 bool valueSet =
false;
5043 if ( layers.count() > 1 )
5045 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5047 const QList<QgsMapLayer *> remainingLayers = layers.mid( 1 );
5053 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
5054 if ( !vlayer || !vlayer->
isValid() )
5060 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
5063 fields.
remove( fieldIdx );
5068 mComboBox->setFields( fields );
5070 mPanel->setFields( filterFields( fields ) );
5076 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
5078 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5082 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
5085 mParentLayer.reset( qobject_cast<QgsVectorLayer *>( ownedLayer.release() ) );
5086 layer = mParentLayer.get();
5094 mComboBox->setLayer( layer );
5096 mPanel->setFields( filterFields( layer->
fields() ) );
5106 const QgsFields fields = source->fields();
5108 mComboBox->setFields( fields );
5110 mPanel->setFields( filterFields( fields ) );
5119 mComboBox->setLayer(
nullptr );
5123 if ( value.isValid() && widgetContext().messageBar() )
5135 val.reserve( mPanel->fields().size() );
5136 for (
const QgsField &field : mPanel->fields() )
5137 val << field.name();
5138 setWidgetValue( val, *context );
5141 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5144void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5148 if ( !value.isValid() )
5149 mComboBox->setField( QString() );
5153 mComboBox->setField( v );
5159 if ( value.isValid() )
5162 opts.reserve( v.size() );
5163 for (
const QString &i : v )
5167 mPanel->setValue( opts );
5169 else if ( mLineEdit )
5175 mLineEdit->setText( v.join(
';' ) );
5184QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
5187 return mComboBox->currentField();
5189 return mPanel->value();
5190 else if ( mLineEdit )
5195 return mLineEdit->text().split(
';' );
5198 return mLineEdit->text();
5204QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
5206 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
5209const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
5211 if ( mComboBox && mComboBox->layer() )
5212 return mComboBox->layer();
5217QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
5230 if ( f.isNumeric() )
5235 if ( f.type() == QMetaType::Type::QString )
5240 if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
5245 if ( f.type() == QMetaType::Type::QByteArray )
5250 if ( f.type() == QMetaType::Type::Bool )
5259QString QgsProcessingFieldWidgetWrapper::parameterType()
const
5266 return new QgsProcessingFieldWidgetWrapper( parameter, type );
5271 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5282 QVBoxLayout *vlayout =
new QVBoxLayout();
5283 vlayout->setContentsMargins( 0, 0, 0, 0 );
5285 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5287 mDefaultComboBox =
new QComboBox();
5288 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
5291 for (
const QString &theme : mapThemes )
5295 mDefaultComboBox->setEditable(
true );
5299 if ( themeParam->defaultValueForGui().isValid() )
5302 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5305 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5307 vlayout->addWidget( mDefaultComboBox );
5309 setLayout( vlayout );
5314 QVariant defaultVal;
5315 if ( mDefaultComboBox->currentText().isEmpty() )
5316 defaultVal = QVariant();
5318 defaultVal = mDefaultComboBox->currentText();
5319 auto param = std::make_unique<QgsProcessingParameterMapTheme>( name, description, defaultVal );
5321 return param.release();
5330QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
5336 mComboBox =
new QComboBox();
5339 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
5342 for (
const QString &theme : mapThemes )
5354 mComboBox->setEditable(
true );
5358 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5359 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
5360 emit widgetValueHasChanged(
this );
5366void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5370 if ( !value.isValid() )
5371 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5374 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5376 const QString prev = mComboBox->currentText();
5377 mComboBox->setCurrentText( v );
5379 emit widgetValueHasChanged(
this );
5382 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5386QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5389 return mComboBox->currentData().toInt() == -1 ? QVariant() : !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5390 : mComboBox->currentData();
5395QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5397 return tr(
"map theme as a string value (e.g. 'base maps')" );
5400QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5407 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5412 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5424 QVBoxLayout *vlayout =
new QVBoxLayout();
5425 vlayout->setContentsMargins( 0, 0, 0, 0 );
5427 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5429 mTypeComboBox =
new QComboBox();
5434 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( datetimeParam->dataType() ) ) );
5436 mTypeComboBox->setCurrentIndex( 0 );
5437 vlayout->addWidget( mTypeComboBox );
5439 setLayout( vlayout );
5444 auto param = std::make_unique<QgsProcessingParameterDateTime>( name, description );
5447 return param.release();
5456QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5459 if ( !dateTimeParam )
5463 switch ( dateTimeParam->
dataType() )
5467 widget = mDateTimeEdit;
5492 widget->setToolTip( parameterDefinition()->toolTip() );
5494 if ( mDateTimeEdit )
5497 emit widgetValueHasChanged(
this );
5500 else if ( mDateEdit )
5503 emit widgetValueHasChanged(
this );
5506 else if ( mTimeEdit )
5509 emit widgetValueHasChanged(
this );
5518 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5521void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5523 if ( mDateTimeEdit )
5527 else if ( mDateEdit )
5531 else if ( mTimeEdit )
5537QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5539 if ( mDateTimeEdit )
5540 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5541 else if ( mDateEdit )
5542 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5543 else if ( mTimeEdit )
5544 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5549QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5552 if ( dateTimeParam )
5554 switch ( dateTimeParam->
dataType() )
5557 return tr(
"datetime value, or a ISO string representation of a datetime" );
5560 return tr(
"date value, or a ISO string representation of a date" );
5563 return tr(
"time value, or a ISO string representation of a time" );
5569QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5576 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5589 QVBoxLayout *vlayout =
new QVBoxLayout();
5590 vlayout->setContentsMargins( 0, 0, 0, 0 );
5592 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5593 mProviderComboBox =
new QComboBox();
5594 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), u
"postgres"_s );
5595 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), u
"ogr"_s );
5596 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), u
"spatialite"_s );
5598 vlayout->addWidget( mProviderComboBox );
5600 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5602 mDefaultEdit =
new QLineEdit();
5603 vlayout->addWidget( mDefaultEdit );
5604 setLayout( vlayout );
5606 if ( connectionParam )
5608 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5615 QVariant defaultVal;
5616 if ( mDefaultEdit->text().isEmpty() )
5617 defaultVal = QVariant();
5619 defaultVal = mDefaultEdit->text();
5620 auto param = std::make_unique<QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5622 return param.release();
5631QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5634 if ( !connectionParam )
5639 mProviderComboBox->setAllowEmptyConnection(
true );
5647 mProviderComboBox->setEditable(
true );
5651 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5652 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [
this](
const QString & ) {
5653 if ( mBlockSignals )
5656 emit widgetValueHasChanged(
this );
5659 return mProviderComboBox;
5664 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5667void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5671 if ( !value.isValid() )
5672 mProviderComboBox->setCurrentIndex( -1 );
5675 if ( mProviderComboBox->isEditable() )
5677 const QString prev = mProviderComboBox->currentText();
5679 mProviderComboBox->setConnection( v );
5680 mProviderComboBox->setCurrentText( v );
5684 emit widgetValueHasChanged(
this );
5687 mProviderComboBox->setConnection( v );
5691QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5693 if ( mProviderComboBox )
5694 if ( mProviderComboBox->isEditable() )
5695 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5697 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5702QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5704 return tr(
"connection name as a string value" );
5707QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5714 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5727 QVBoxLayout *vlayout =
new QVBoxLayout();
5728 vlayout->setContentsMargins( 0, 0, 0, 0 );
5730 mConnectionParamComboBox =
new QComboBox();
5731 QString initialConnection;
5737 if (
auto *lModel = widgetContext.
model() )
5740 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5741 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5743 if ( definition && it->parameterName() == definition->
name() )
5749 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5750 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5752 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5757 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5760 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5761 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5764 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5765 vlayout->addWidget( mConnectionParamComboBox );
5767 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5769 mDefaultEdit =
new QLineEdit();
5770 vlayout->addWidget( mDefaultEdit );
5771 setLayout( vlayout );
5781 QVariant defaultVal;
5782 if ( mDefaultEdit->text().isEmpty() )
5783 defaultVal = QVariant();
5785 defaultVal = mDefaultEdit->text();
5786 auto param = std::make_unique<QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5788 return param.release();
5797QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5805 mSchemaComboBox->setAllowEmptySchema(
true );
5813 mSchemaComboBox->comboBox()->setEditable(
true );
5817 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5818 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
5819 if ( mBlockSignals )
5822 emit widgetValueHasChanged( this );
5825 return mSchemaComboBox;
5830 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5837 std::unique_ptr<QgsProcessingContext> tmpContext;
5838 if ( mProcessingContextGenerator )
5839 context = mProcessingContextGenerator->processingContext();
5843 tmpContext = std::make_unique<QgsProcessingContext>();
5844 context = tmpContext.get();
5850 if ( mSchemaComboBox )
5851 mSchemaComboBox->setConnectionName( connection, qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId() );
5855 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5858void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5862 if ( !value.isValid() )
5863 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5866 if ( mSchemaComboBox->comboBox()->isEditable() )
5868 const QString prev = mSchemaComboBox->comboBox()->currentText();
5870 mSchemaComboBox->setSchema( v );
5871 mSchemaComboBox->comboBox()->setCurrentText( v );
5875 emit widgetValueHasChanged(
this );
5878 mSchemaComboBox->setSchema( v );
5882QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5884 if ( mSchemaComboBox )
5885 if ( mSchemaComboBox->comboBox()->isEditable() )
5886 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5888 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5893QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5895 return tr(
"database schema name as a string value" );
5898QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5905 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5908void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5920 setParentConnectionWrapperValue( wrapper );
5922 setParentConnectionWrapperValue( wrapper );
5945 QVBoxLayout *vlayout =
new QVBoxLayout();
5946 vlayout->setContentsMargins( 0, 0, 0, 0 );
5948 mConnectionParamComboBox =
new QComboBox();
5949 mSchemaParamComboBox =
new QComboBox();
5950 QString initialConnection;
5951 QString initialSchema;
5958 if (
auto *lModel = widgetContext.
model() )
5961 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5962 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5964 if ( definition && it->parameterName() == definition->
name() )
5969 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5970 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5972 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5977 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
5978 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5980 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5986 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5989 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5990 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5993 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
5996 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
5997 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6000 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
6001 vlayout->addWidget( mConnectionParamComboBox );
6003 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
6004 vlayout->addWidget( mSchemaParamComboBox );
6006 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6008 mDefaultEdit =
new QLineEdit();
6009 vlayout->addWidget( mDefaultEdit );
6010 setLayout( vlayout );
6020 QVariant defaultVal;
6021 if ( mDefaultEdit->text().isEmpty() )
6022 defaultVal = QVariant();
6024 defaultVal = mDefaultEdit->text();
6025 auto param = std::make_unique<QgsProcessingParameterDatabaseTable>( name, description, mConnectionParamComboBox->currentData().toString(), mSchemaParamComboBox->currentData().toString(), defaultVal );
6027 return param.release();
6036QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
6044 mTableComboBox->setAllowEmptyTable(
true );
6047 mTableComboBox->comboBox()->setEditable(
true );
6049 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
6050 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
6051 if ( mBlockSignals )
6054 emit widgetValueHasChanged( this );
6057 return mTableComboBox;
6062 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6069 std::unique_ptr<QgsProcessingContext> tmpContext;
6070 if ( mProcessingContextGenerator )
6071 context = mProcessingContextGenerator->processingContext();
6075 tmpContext = std::make_unique<QgsProcessingContext>();
6076 context = tmpContext.get();
6081 mProvider = qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId();
6082 if ( mTableComboBox && !mSchema.isEmpty() )
6084 mTableComboBox->setSchema( mSchema );
6085 mTableComboBox->setConnectionName( mConnection, mProvider );
6089 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6097 std::unique_ptr<QgsProcessingContext> tmpContext;
6098 if ( mProcessingContextGenerator )
6099 context = mProcessingContextGenerator->processingContext();
6103 tmpContext = std::make_unique<QgsProcessingContext>();
6104 context = tmpContext.get();
6110 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
6112 mTableComboBox->setSchema( mSchema );
6113 mTableComboBox->setConnectionName( mConnection, mProvider );
6115 const QgsProcessingParameterDatabaseTable *tableParam = static_cast<const QgsProcessingParameterDatabaseTable *>( parameterDefinition() );
6116 if ( tableParam->defaultValueForGui().isValid() )
6117 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6121void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6125 if ( !value.isValid() )
6126 mTableComboBox->comboBox()->setCurrentIndex( -1 );
6129 if ( mTableComboBox->comboBox()->isEditable() )
6131 const QString prev = mTableComboBox->comboBox()->currentText();
6133 mTableComboBox->setTable( v );
6134 mTableComboBox->comboBox()->setCurrentText( v );
6138 emit widgetValueHasChanged(
this );
6141 mTableComboBox->setTable( v );
6145QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
6147 if ( mTableComboBox )
6148 if ( mTableComboBox->comboBox()->isEditable() )
6149 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
6151 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
6156QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
6158 return tr(
"database table name as a string value" );
6161QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
6168 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
6171void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6183 setParentConnectionWrapperValue( wrapper );
6185 setParentConnectionWrapperValue( wrapper );
6190 setParentSchemaWrapperValue( wrapper );
6192 setParentSchemaWrapperValue( wrapper );
6212 QVBoxLayout *vlayout =
new QVBoxLayout();
6213 vlayout->setContentsMargins( 0, 0, 0, 0 );
6215 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6218 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6221 if ( extentParam->defaultValueForGui().isValid() )
6225 mDefaultWidget->setCurrentExtent( rect, crs );
6226 mDefaultWidget->setOutputExtentFromCurrent();
6230 mDefaultWidget->clear();
6234 vlayout->addWidget( mDefaultWidget );
6235 setLayout( vlayout );
6240 const QString defaultVal = mDefaultWidget->isValid() ? u
"%1,%2,%3,%4%5"_s.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() ? u
" [%1]"_s.arg( mDefaultWidget->outputCrs().authid() ) : QString() ) : QString();
6241 auto param = std::make_unique<QgsProcessingParameterExtent>( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
6243 return param.release();
6252QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
6265 if ( widgetContext().mapCanvas() )
6266 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
6269 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6271 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6274 emit widgetValueHasChanged(
this );
6278 setDialog( mDialog );
6280 return mExtentWidget;
6290 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6293void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6300 mDialog->showMinimized();
6303 mDialog->showNormal();
6305 mDialog->activateWindow();
6312void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6314 if ( mExtentWidget )
6316 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
6317 mExtentWidget->clear();
6322 mExtentWidget->setCurrentExtent( r, crs );
6323 mExtentWidget->setOutputExtentFromUser( r, crs );
6328QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6330 if ( mExtentWidget )
6332 const QString val = mExtentWidget->isValid() ? u
"%1,%2,%3,%4%5"_s.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() ? u
" [%1]"_s.arg( mExtentWidget->outputCrs().authid() ) : QString() ) : QString();
6334 return val.isEmpty() ? QVariant() : QVariant( val );
6340QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6342 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6345QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6352 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6357 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6368 QVBoxLayout *vlayout =
new QVBoxLayout();
6369 vlayout->setContentsMargins( 0, 0, 0, 0 );
6371 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6387 for (
int i : layerParam->dataTypes() )
6389 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6393 vlayout->addWidget( mLayerTypeComboBox );
6395 setLayout( vlayout );
6400 QList<int> dataTypes;
6401 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6402 dataTypes << v.toInt();
6404 auto param = std::make_unique<QgsProcessingParameterMapLayer>( name, description );
6405 param->setDataTypes( dataTypes );
6407 return param.release();
6415QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6417 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6425 mComboBox->setEditable(
true );
6429 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6431 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [
this]() {
6432 if ( mBlockSignals )
6435 emit widgetValueHasChanged(
this );
6438 setWidgetContext( widgetContext() );
6447 mComboBox->setWidgetContext( context );
6452 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6458void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6461 mComboBox->setValue( value, context );
6464QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6466 return mComboBox ? mComboBox->value() : QVariant();
6469QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6471 return tr(
"path to a map layer" );
6488QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6495 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6500 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6509 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6513QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6515 return tr(
"path to a raster layer" );
6518QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6525 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6530 Q_UNUSED( context );
6531 Q_UNUSED( widgetContext );
6532 Q_UNUSED( definition );
6546 QVBoxLayout *vlayout =
new QVBoxLayout();
6547 vlayout->setContentsMargins( 0, 0, 0, 0 );
6549 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6559 for (
int i : vectorParam->dataTypes() )
6561 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6565 vlayout->addWidget( mGeometryTypeComboBox );
6567 setLayout( vlayout );
6572 QList<int> dataTypes;
6573 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6574 dataTypes << v.toInt();
6576 auto param = std::make_unique<QgsProcessingParameterVectorLayer>( name, description, dataTypes );
6578 return param.release();
6583 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6587QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6589 return tr(
"path to a vector layer" );
6592QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6599 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6604 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6615 QVBoxLayout *vlayout =
new QVBoxLayout();
6616 vlayout->setContentsMargins( 0, 0, 0, 0 );
6618 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6628 for (
int i : sourceParam->dataTypes() )
6630 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6638 vlayout->addWidget( mGeometryTypeComboBox );
6640 setLayout( vlayout );
6645 QList<int> dataTypes;
6646 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6647 dataTypes << v.toInt();
6649 auto param = std::make_unique<QgsProcessingParameterFeatureSource>( name, description, dataTypes );
6651 return param.release();
6655 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6659QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6661 return tr(
"path to a vector layer" );
6664QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6671 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6676 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6684 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6688QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6690 return tr(
"path to a mesh layer" );
6693QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6700 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6705 Q_UNUSED( context );
6706 Q_UNUSED( widgetContext );
6707 Q_UNUSED( definition );
6718QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6722 QHBoxLayout *hl =
new QHBoxLayout();
6723 hl->setContentsMargins( 0, 0, 0, 0 );
6725 mLineEdit =
new QLineEdit();
6726 mLineEdit->setEnabled(
false );
6727 hl->addWidget( mLineEdit, 1 );
6729 mToolButton =
new QToolButton();
6730 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6731 hl->addWidget( mToolButton );
6737 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6740 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6743void QgsProcessingRasterBandPanelWidget::setBands(
const QList<int> &bands )
6748void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6753void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6755 if ( value.isValid() )
6756 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
6760 updateSummaryText();
6764void QgsProcessingRasterBandPanelWidget::showDialog()
6766 QVariantList availableOptions;
6767 availableOptions.reserve( mBands.size() );
6768 for (
int band : std::as_const( mBands ) )
6770 availableOptions << band;
6776 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6777 widget->setPanelTitle( mParam->description() );
6779 widget->setValueFormatter( [
this](
const QVariant &v ) -> QString {
6780 int band = v.toInt();
6781 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6784 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
6785 setValue( widget->selectedOptions() );
6792 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6794 dlg.setValueFormatter( [
this](
const QVariant &v ) -> QString {
6795 int band = v.toInt();
6796 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6800 setValue( dlg.selectedOptions() );
6805void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6808 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6819 QVBoxLayout *vlayout =
new QVBoxLayout();
6820 vlayout->setContentsMargins( 0, 0, 0, 0 );
6822 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6824 mDefaultLineEdit =
new QLineEdit();
6825 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6830 for (
int b : bands )
6832 defVal << QString::number( b );
6835 mDefaultLineEdit->setText( defVal.join(
';' ) );
6837 vlayout->addWidget( mDefaultLineEdit );
6839 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6840 mParentLayerComboBox =
new QComboBox();
6842 QString initialParent;
6844 initialParent = bandParam->parentLayerParameterName();
6846 if (
auto *lModel = widgetContext.
model() )
6849 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6850 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6854 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
6855 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6857 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6863 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6866 mParentLayerComboBox->addItem( initialParent, initialParent );
6867 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6870 vlayout->addWidget( mParentLayerComboBox );
6872 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6874 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6876 vlayout->addWidget( mAllowMultipleCheckBox );
6877 setLayout( vlayout );
6882 auto param = std::make_unique<QgsProcessingParameterBand>( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6884 return param.release();
6892QWidget *QgsProcessingBandWidgetWrapper::createWidget()
6905 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
6906 mPanel->setToolTip( parameterDefinition()->toolTip() );
6907 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [
this] {
6908 emit widgetValueHasChanged(
this );
6917 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6919 emit widgetValueHasChanged(
this );
6927 mLineEdit =
new QLineEdit();
6928 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6929 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
6930 emit widgetValueHasChanged(
this );
6938void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6950 setParentLayerWrapperValue( wrapper );
6952 setParentLayerWrapperValue( wrapper );
6969 std::unique_ptr<QgsProcessingContext> tmpContext;
6970 if ( mProcessingContextGenerator )
6971 context = mProcessingContextGenerator->processingContext();
6975 tmpContext = std::make_unique<QgsProcessingContext>();
6976 context = tmpContext.get();
6982 if ( layer && layer->
isValid() )
6986 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
6989 mParentLayer.reset( qobject_cast<QgsRasterLayer *>( ownedLayer.release() ) );
6990 layer = mParentLayer.get();
6998 mComboBox->setLayer( layer );
7002 if ( provider && layer->
isValid() )
7007 QHash<int, QString> bandNames;
7008 for (
int i = 1; i <= nBands; ++i )
7013 mPanel->setBands( bands );
7014 mPanel->setBandNames( bandNames );
7021 mComboBox->setLayer(
nullptr );
7023 mPanel->setBands( QList<int>() );
7025 if ( value.isValid() && widgetContext().messageBar() )
7032 if ( parameterDefinition()->defaultValueForGui().isValid() )
7033 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7036void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7040 if ( !value.isValid() )
7041 mComboBox->setBand( -1 );
7045 mComboBox->setBand( v );
7051 if ( value.isValid() )
7054 opts.reserve( v.size() );
7059 mPanel->setValue( value.isValid() ? opts : QVariant() );
7061 else if ( mLineEdit )
7068 opts.reserve( v.size() );
7070 opts << QString::number( i );
7071 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
7075 if ( value.isValid() )
7083QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
7086 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
7088 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7089 else if ( mLineEdit )
7094 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
7096 res.reserve( parts.count() );
7097 for (
const QString &s : parts )
7100 int band = s.toInt( &ok );
7104 return res.
isEmpty() ? QVariant() : res;
7108 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7115QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7117 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7120QString QgsProcessingBandWidgetWrapper::parameterType()
const
7127 return new QgsProcessingBandWidgetWrapper( parameter, type );
7132 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7143 setAcceptDrops(
true );
7146void QgsProcessingMultipleLayerLineEdit::dragEnterEvent( QDragEnterEvent *event )
7148 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7149 if ( !uris.isEmpty() )
7151 event->setDropAction( Qt::CopyAction );
7153 setHighlighted(
true );
7161void QgsProcessingMultipleLayerLineEdit::dragLeaveEvent( QDragLeaveEvent *event )
7163 QgsHighlightableLineEdit::dragLeaveEvent( event );
7165 setHighlighted(
false );
7168void QgsProcessingMultipleLayerLineEdit::dropEvent( QDropEvent *event )
7170 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7171 if ( !uris.isEmpty() )
7173 event->setDropAction( Qt::CopyAction );
7175 QVariantList uriList;
7176 uriList.reserve( uris.size() );
7177 for (
const QString &uri : uris )
7178 uriList.append( QVariant( uri ) );
7179 emit layersDropped( uriList );
7182 setHighlighted(
false );
7193 QHBoxLayout *hl =
new QHBoxLayout();
7194 hl->setContentsMargins( 0, 0, 0, 0 );
7196 mLineEdit =
new QgsProcessingMultipleLayerLineEdit(
nullptr, param );
7197 mLineEdit->setEnabled(
true );
7198 mLineEdit->setReadOnly(
true );
7200 hl->addWidget( mLineEdit, 1 );
7201 connect( mLineEdit, &QgsProcessingMultipleLayerLineEdit::layersDropped,
this, &QgsProcessingMultipleLayerPanelWidget::setValue );
7203 mToolButton =
new QToolButton();
7204 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7205 hl->addWidget( mToolButton );
7211 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7214 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7217void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7219 if ( value.isValid() )
7220 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7224 updateSummaryText();
7228void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7234 if ( mValue.removeAll( layerId ) )
7236 updateSummaryText();
7243void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7249 switch ( mParam->layerType() )
7337void QgsProcessingMultipleLayerPanelWidget::showDialog()
7342 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel,
nullptr );
7343 widget->setPanelTitle( mParam->description() );
7344 widget->setProject( mProject );
7345 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
7346 setValue( widget->selectedOptions() );
7353 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7354 dlg.setProject( mProject );
7357 setValue( dlg.selectedOptions() );
7362void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7365 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7375 QVBoxLayout *vlayout =
new QVBoxLayout();
7376 vlayout->setContentsMargins( 0, 0, 0, 0 );
7378 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7379 mLayerTypeComboBox =
new QComboBox();
7393 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast<int>( layersParam->layerType() ) ) );
7395 vlayout->addWidget( mLayerTypeComboBox );
7396 setLayout( vlayout );
7401 auto param = std::make_unique<QgsProcessingParameterMultipleLayers>( name, description,
static_cast<Qgis::ProcessingSourceType>( mLayerTypeComboBox->currentData().toInt() ) );
7403 return param.release();
7411QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7415 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7416 mPanel->setToolTip( parameterDefinition()->toolTip() );
7417 mPanel->setProject( widgetContext().project() );
7419 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7420 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [
this] {
7421 emit widgetValueHasChanged(
this );
7431 mPanel->setProject( context.
project() );
7433 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7437void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7442 if ( value.isValid() )
7445 opts.reserve( v.size() );
7447 opts << l->source();
7450 for (
const QVariant &v : value.toList() )
7452 if ( v.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
7454 const QgsProcessingModelChildParameterSource source = v.value<QgsProcessingModelChildParameterSource>();
7455 opts << QVariant::fromValue( source );
7460 mPanel->setValue( value.isValid() ? opts : QVariant() );
7464QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7467 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7472QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7474 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7477QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7484 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7489 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7498 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7502QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7504 return tr(
"path to a point cloud layer" );
7507QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7514 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7519 Q_UNUSED( context );
7520 Q_UNUSED( widgetContext );
7521 Q_UNUSED( definition );
7537QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7539 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7542QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7549 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7554 Q_UNUSED( context );
7555 Q_UNUSED( widgetContext );
7556 Q_UNUSED( definition );
7567 if ( mWidgetContext.project() )
7568 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7572QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7583 mComboBox->setEditable(
true );
7587 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7589 if ( mWidgetContext.project() )
7590 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7593 mComboBox->setAllowEmptyLayer(
true );
7596 if ( mBlockSignals )
7599 emit widgetValueHasChanged(
this );
7602 setWidgetContext( widgetContext() );
7606void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7612 mComboBox->setLayer(
nullptr );
7616 QVariant val = value;
7617 if ( val.userType() == qMetaTypeId<QgsProperty>() )
7629 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( val.value<QObject *>() );
7630 if ( !layer && val.userType() == QMetaType::Type::QString )
7637 mComboBox->setLayer( layer );
7642QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7644 return mComboBox && mComboBox->currentLayer() ? ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? u
"main"_s : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
7657 QHBoxLayout *hl =
new QHBoxLayout();
7658 hl->setContentsMargins( 0, 0, 0, 0 );
7660 mLineEdit =
new QLineEdit();
7661 mLineEdit->setEnabled(
false );
7662 hl->addWidget( mLineEdit, 1 );
7664 mToolButton =
new QToolButton();
7665 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7666 hl->addWidget( mToolButton );
7672 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7675 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7680 mAttributes = attributes;
7683void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7685 if ( value.isValid() )
7686 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7690 updateSummaryText();
7694void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7696 QVariantList availableOptions;
7697 availableOptions.reserve( mAttributes.count() );
7698 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7701 availableOptions << attr.name();
7707 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7708 widget->setPanelTitle( mParam->description() );
7710 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
7711 return v.toString();
7714 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
7715 setValue( widget->selectedOptions() );
7722 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7724 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
7725 return v.toString();
7729 setValue( dlg.selectedOptions() );
7734void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7739 if ( mValue.empty() )
7741 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7746 values.reserve( mValue.size() );
7747 for (
const QVariant &val : std::as_const( mValue ) )
7749 values << val.toString();
7752 const QString concatenated = values.join( tr(
"," ) );
7753 if ( concatenated.length() < 100 )
7754 mLineEdit->setText( concatenated );
7756 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7768 QVBoxLayout *vlayout =
new QVBoxLayout();
7769 vlayout->setContentsMargins( 0, 0, 0, 0 );
7771 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7772 mParentLayerComboBox =
new QComboBox();
7774 QString initialParent;
7776 initialParent = attrParam->parentLayerParameterName();
7778 if (
auto *lModel = widgetContext.
model() )
7781 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7782 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7786 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
7787 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7789 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7795 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7798 mParentLayerComboBox->addItem( initialParent, initialParent );
7799 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7802 vlayout->addWidget( mParentLayerComboBox );
7804 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
7806 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
7808 vlayout->addWidget( mAllowMultipleCheckBox );
7810 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
7811 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7813 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
7815 vlayout->addWidget( mDefaultToAllCheckBox );
7817 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [
this] {
7818 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7821 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7823 mDefaultLineEdit =
new QLineEdit();
7824 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
7828 mDefaultLineEdit->setText( attributes.join(
';' ) );
7830 vlayout->addWidget( mDefaultLineEdit );
7832 setLayout( vlayout );
7837 QVariant defaultValue;
7838 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
7840 defaultValue = mDefaultLineEdit->text();
7842 auto param = std::make_unique<QgsProcessingParameterPointCloudAttribute>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
7844 return param.release();
7852QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
7865 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
7866 mPanel->setToolTip( parameterDefinition()->toolTip() );
7867 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [
this] {
7868 emit widgetValueHasChanged(
this );
7876 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7878 emit widgetValueHasChanged(
this );
7886 mLineEdit =
new QLineEdit();
7887 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
7888 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
7889 emit widgetValueHasChanged(
this );
7897void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7909 setParentLayerWrapperValue( wrapper );
7911 setParentLayerWrapperValue( wrapper );
7928 std::unique_ptr<QgsProcessingContext> tmpContext;
7929 if ( mProcessingContextGenerator )
7930 context = mProcessingContextGenerator->processingContext();
7934 tmpContext = std::make_unique<QgsProcessingContext>();
7935 context = tmpContext.get();
7941 if ( layer && layer->
isValid() )
7945 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
7948 mParentLayer.reset( qobject_cast<QgsPointCloudLayer *>( ownedLayer.release() ) );
7949 layer = mParentLayer.get();
7957 mComboBox->setLayer( layer );
7960 mPanel->setAttributes( layer->
attributes() );
7967 mComboBox->setLayer(
nullptr );
7972 if ( value.isValid() && widgetContext().messageBar() )
7983 val.reserve( mPanel->attributes().attributes().size() );
7986 setWidgetValue( val, *context );
7989 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7992void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7996 if ( !value.isValid() )
7997 mComboBox->setAttribute( QString() );
8001 mComboBox->setAttribute( v );
8007 if ( value.isValid() )
8010 opts.reserve( v.size() );
8011 for (
const QString &i : v )
8015 mPanel->setValue( opts );
8017 else if ( mLineEdit )
8023 mLineEdit->setText( v.join(
';' ) );
8032QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
8035 return mComboBox->currentAttribute();
8037 return mPanel->value();
8038 else if ( mLineEdit )
8043 return mLineEdit->text().split(
';' );
8046 return mLineEdit->text();
8052QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
8054 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
8057QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
8064 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
8069 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8082QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8090 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8091 if ( mProcessingContextGenerator )
8092 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8093 if ( mParametersGenerator )
8094 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8095 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8097 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [
this]() {
8098 if ( mBlockSignals )
8101 emit widgetValueHasChanged(
this );
8106 mOutputWidget->addOpenAfterRunningOption();
8108 return mOutputWidget;
8118void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8120 if ( mOutputWidget )
8121 mOutputWidget->setValue( value );
8124QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8126 if ( mOutputWidget )
8127 return mOutputWidget->value();
8132QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8135 if ( mOutputWidget )
8136 res.insert( u
"OPEN_AFTER_RUNNING"_s, mOutputWidget->openAfterRunning() );
8145 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8149QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8156 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8159QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8161 return tr(
"path to layer destination" );
8169 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8173QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8180 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8183QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8185 return tr(
"path to layer destination" );
8193 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8197QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8204 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8207QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8209 return tr(
"path to layer destination" );
8217 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8221QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8228 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8231QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8233 return tr(
"path to layer destination" );
8241 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8245QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8252 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8256QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8258 return tr(
"path to file destination" );
8266 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8270QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8277 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8281QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8283 return tr(
"path to folder destination" );
8291 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8295QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8302 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8305QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8307 return tr(
"path to layer destination" );
@ Standard
Unit is a standard measurement unit.
ProcessingSourceType
Processing data source types.
@ File
Files (i.e. non map layer sources, such as text files).
@ TiledScene
Tiled scene layers.
@ Annotation
Annotation layers.
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ VectorTile
Vector tile layers.
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer).
@ VectorAnyGeometry
Any vector layer with geometry.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ PointCloud
Point cloud layers.
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
@ File
Parameter is a single file.
@ Folder
Parameter is a folder.
ExpressionType
Expression types.
@ RasterCalculator
Raster calculator expression.
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
ProcessingMode
Types of modes which Processing widgets can be created for.
@ Batch
Batch processing mode.
@ Standard
Standard (single-run) algorithm mode.
DistanceUnit
Units of distance.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ NauticalMiles
Nautical miles.
ProcessingFieldParameterDataType
Processing field parameter data types.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ Numeric
Accepts numeric fields.
@ DateTime
Accepts datetime fields.
@ SquareCentimeters
Square centimeters.
@ SquareInches
Square inches.
@ SquareNauticalMiles
Square nautical miles.
@ SquareMillimeters
Square millimeters.
@ SquareYards
Square yards.
@ SquareKilometers
Square kilometers.
@ SquareMeters
Square meters.
@ Unknown
Unknown areal unit.
@ SquareDegrees
Square degrees, for planar geographic CRS area measurements.
@ SquareMiles
Square miles.
@ Info
Information message.
@ AnnotationLayer
QgsAnnotationLayer.
TemporalUnit
Temporal units.
@ Milliseconds
Milliseconds.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
VolumeUnit
Units of volume.
@ CubicMeters
Cubic meters.
@ CubicDegrees
Cubic degrees, for planar geographic CRS volume measurements.
@ CubicDecimeter
Cubic decimeters.
@ Unknown
Unknown volume unit.
@ CubicCentimeter
Cubic Centimeters.
ProcessingModelChildParameterSource
Processing model child parameter sources.
@ ModelParameter
Parameter value is taken from a parent model parameter.
@ StaticValue
Parameter value is a static value.
@ Optional
Parameter is optional.
ProcessingDateTimeParameterDataType
Processing date time parameter data types.
@ DateTime
Datetime values.
ProcessingNumberParameterType
Processing numeric parameter data types.
@ Double
Double/float values.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
@ CapturePoint
Select and capture a point or a feature.
Selector widget for authentication configs.
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing.
QComboBox subclass which allows selecting multiple items.
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
A combo box which displays the list of schemas for a specific database connection.
A combobox which displays the list of tables for a specific database connection.
A QDateEdit widget with the capability of setting/reading null dates.
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
A QDateTimeEdit with the capability of setting/reading null date/times.
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
void setNullRepresentation(const QString &null)
Sets the widget's null representation, which defaults to QgsApplication::nullRepresentation().
void valueChanged(const QDateTime &date)
Signal emitted whenever the value changes.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
A widget which includes a line edit for entering expressions together with a button to open the expre...
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
A combobox which displays the list of fields of a given layer.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
@ DateTime
Datetime fields.
@ Date
Date or datetime fields.
@ Binary
Binary fields, since QGIS 3.34.
@ Boolean
Boolean fields, since QGIS 3.34.
@ Numeric
All numeric fields.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
void remove(int fieldIdx)
Removes the field with the given index.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A geometry is the spatial representation of a feature.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Q_INVOKABLE QString asWkt(int precision=17) const
Exports the geometry to WKT.
A QgsFilterLineEdit subclass with the ability to "highlight" the edges of the widget.
A combobox which displays available layouts from a QgsLayoutManager.
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
A combo box which displays items of a matching type from a layout.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
Base class for graphical items within a QgsLayout.
virtual QString uuid() const
Returns the item identification string.
@ FilterPrintLayouts
Includes print layouts.
QList< QgsPrintLayout * > printLayouts() const
Returns a list of all print layouts contained in the manager.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
A combobox which displays a dynamic list of layers from a QGIS project.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
Base class for all map layer types.
A mouse event which is the result of a user interaction with a QgsMapCanvas.
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Interface for master layout type objects, such as print layouts and reports.
virtual QString name() const =0
Returns the layout's name.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
bool clearWidgets()
Removes all items from the bar.
A collection of point cloud attributes.
A combobox which displays the list of attributes of a given point cloud layer.
void attributeChanged(const QString &name)
Emitted when the currently selected attribute changes.
Attribute for point cloud data pair of name and size in bytes.
Represents a map layer supporting display of point clouds.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes available from the layer.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
Base class for all parameter definitions which represent file or layer destinations,...
Encapsulates settings relating to a feature source input to a processing algorithm.
QgsProperty source
Source definition.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for area values.
Qgis::AreaUnit defaultUnit() const
Returns the default area unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A raster band parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
A boolean parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A color parameter for processing algorithms.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
static QString typeName()
Returns the type name for the parameter class.
A coordinate operation parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
QVariant sourceCrs() const
Returns the static source CRS, or an invalid value if this is not set.
QVariant destinationCrs() const
Returns the static destination CRS, or an invalid value if this is not set.
A coordinate reference system parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
A database table name parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
A datetime (or pure date or time) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
void setFlags(Qgis::ProcessingParameterFlags flags)
Sets the flags associated with the parameter.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
QString description() const
Returns the description for the parameter.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
virtual QString type() const =0
Unique parameter type name.
QString name() const
Returns the name of the parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
A double numeric parameter for duration values.
Qgis::TemporalUnit defaultUnit() const
Returns the default duration unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
static QString typeName()
Returns the type name for the parameter class.
An expression parameter for processing algorithms.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ExpressionType expressionType() const
Returns the parameter's expression type.
A rectangular map extent parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
An input feature source (such as vector layers) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A vector layer or feature source field parameter for processing algorithms.
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
static QString typeName()
Returns the type name for the parameter class.
A geometry parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A print layout item parameter, allowing users to select a particular item from a print layout.
static QString typeName()
Returns the type name for the parameter class.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
A print layout parameter, allowing users to select a print layout.
static QString typeName()
Returns the type name for the parameter class.
A map layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
static QString typeName()
Returns the type name for the parameter class.
A table (matrix) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
static QString typeName()
Returns the type name for the parameter class.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
double maximum() const
Returns the maximum value acceptable by the parameter.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer attribute parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A point parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A data provider connection parameter for processing algorithms, allowing users to select from availab...
static QString typeName()
Returns the type name for the parameter class.
QString providerId() const
Returns the ID of the provider associated with the connections.
A numeric range parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
A raster layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A vector layer (with or without geometry) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for volume values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::VolumeUnit defaultUnit() const
Returns the default volume unit for the parameter.
Contains settings which reflect the context in which a Processing parameter widget is shown.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsProject * project() const
Returns the project associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
QgsMapLayer * activeLayer() const
Returns the current active layer.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a list of map layers.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QStringList parameterAsStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of strings (e.g.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a point cloud layer.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Utility functions for use with processing classes.
@ Annotation
Annotation layer type, since QGIS 3.22.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
void layerRemoved(const QString &layerId)
Emitted after a layer was removed from the registry.
A store for object properties.
Qgis::PropertyType propertyType() const
Returns the property type.
A combo box which displays the list of connections registered for a given provider.
A combobox widget which displays the bands present in a raster layer.
void bandChanged(int band)
Emitted when the currently selected band changes.
static QString displayBandName(QgsRasterDataProvider *provider, int band)
Returns a user-friendly band name for the specified band.
Base class for raster data providers.
virtual int bandCount() const =0
Gets number of bands.
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
A rectangle specified with double values.
A QgsGeometry with associated coordinate reference system.
Responsible for drawing transient features (e.g.
@ ICON_X
A cross is used to highlight points (x).
Stores settings for use within QGIS.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
A spin box with a clear button that will set the value to the defined clear value.
A QTimeEdit widget with the capability of setting/reading null date/times.
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE Qgis::DistanceUnitType unitType(Qgis::DistanceUnit unit)
Returns the type for a distance unit.
Represents a vector layer which manages a vector based dataset.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).