77#include <QPlainTextEdit>
78#include <QRadioButton>
79#include <QButtonGroup>
93 QVBoxLayout *vlayout =
new QVBoxLayout();
94 vlayout->setContentsMargins( 0, 0, 0, 0 );
96 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
100 mDefaultCheckBox->setChecked(
false );
101 vlayout->addWidget( mDefaultCheckBox );
102 setLayout( vlayout );
105QgsProcessingParameterDefinition *QgsProcessingBooleanParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
107 auto param = std::make_unique< QgsProcessingParameterBoolean >( name, description, mDefaultCheckBox->isChecked() );
108 param->setFlags( flags );
109 return param.release();
119QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
125 QString description = parameterDefinition()->description();
127 description = QObject::tr(
"%1 [optional]" ).arg( description );
129 mCheckBox =
new QCheckBox( description );
130 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
132 connect( mCheckBox, &QCheckBox::toggled,
this, [ = ]
134 emit widgetValueHasChanged(
this );
142 mComboBox =
new QComboBox();
143 mComboBox->addItem( tr(
"Yes" ),
true );
144 mComboBox->addItem( tr(
"No" ),
false );
145 mComboBox->setToolTip( parameterDefinition()->toolTip() );
147 connect( mComboBox, qOverload< int>( &QComboBox::currentIndexChanged ),
this, [ = ]
149 emit widgetValueHasChanged(
this );
158QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
167void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
174 mCheckBox->setChecked( v );
182 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
188QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
193 return mCheckBox->isChecked();
197 return mComboBox->currentData();
202QStringList QgsProcessingBooleanWidgetWrapper::compatibleParameterTypes()
const
224QStringList QgsProcessingBooleanWidgetWrapper::compatibleOutputTypes()
const
235QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
242 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
247 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
258 QVBoxLayout *vlayout =
new QVBoxLayout();
259 vlayout->setContentsMargins( 0, 0, 0, 0 );
261 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
266 mCrsSelector->setShowAccuracyWarnings(
true );
273 vlayout->addWidget( mCrsSelector );
274 setLayout( vlayout );
277QgsProcessingParameterDefinition *QgsProcessingCrsParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
279 auto param = std::make_unique< QgsProcessingParameterCrs >( name, description, mCrsSelector->crs().authid() );
280 param->setFlags( flags );
281 return param.release();
290QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
292 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
294 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
303 emit widgetValueHasChanged(
this );
311 return mProjectionSelectionWidget;
316 QWidget *w =
new QWidget();
317 w->setToolTip( parameterDefinition()->toolTip() );
319 QVBoxLayout *vl =
new QVBoxLayout();
320 vl->setContentsMargins( 0, 0, 0, 0 );
323 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
324 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
325 vl->addWidget( mUseProjectCrsCheckBox );
326 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
327 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [ = ]
329 emit widgetValueHasChanged(
this );
332 vl->addWidget( mProjectionSelectionWidget );
340void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
342 if ( mUseProjectCrsCheckBox )
344 if ( value.toString().compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
346 mUseProjectCrsCheckBox->setChecked(
true );
351 mUseProjectCrsCheckBox->setChecked(
false );
356 if ( mProjectionSelectionWidget )
357 mProjectionSelectionWidget->setCrs( v );
360QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
362 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
363 return QStringLiteral(
"ProjectCrs" );
364 else if ( mProjectionSelectionWidget )
365 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
370QStringList QgsProcessingCrsWidgetWrapper::compatibleParameterTypes()
const
384QStringList QgsProcessingCrsWidgetWrapper::compatibleOutputTypes()
const
392QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
394 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
397QString QgsProcessingCrsWidgetWrapper::parameterType()
const
404 return new QgsProcessingCrsWidgetWrapper( parameter, type );
409 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
422 QVBoxLayout *vlayout =
new QVBoxLayout();
423 vlayout->setContentsMargins( 0, 0, 0, 0 );
425 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
427 mDefaultLineEdit =
new QLineEdit();
430 vlayout->addWidget( mDefaultLineEdit );
432 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
434 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
435 vlayout->addWidget( mMultiLineCheckBox );
437 setLayout( vlayout );
440QgsProcessingParameterDefinition *QgsProcessingStringParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
442 auto param = std::make_unique< QgsProcessingParameterString >( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
443 param->setFlags( flags );
444 return param.release();
455QWidget *QgsProcessingStringWidgetWrapper::createWidget()
457 const QVariantMap metadata = parameterDefinition()->metadata();
458 const QVariant valueHintsVariant = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"value_hints" ) );
460 if ( valueHintsVariant.isValid() )
462 const QVariantList valueList = valueHintsVariant.toList();
463 mComboBox =
new QComboBox();
464 mComboBox->setToolTip( parameterDefinition()->toolTip() );
468 mComboBox->addItem( QString() );
470 for (
const QVariant &entry : valueList )
472 mComboBox->addItem( entry.toString(), entry.toString() );
474 mComboBox->setCurrentIndex( 0 );
476 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
478 emit widgetValueHasChanged(
this );
491 mPlainTextEdit =
new QPlainTextEdit();
492 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
494 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [ = ]
496 emit widgetValueHasChanged(
this );
498 return mPlainTextEdit;
502 mLineEdit =
new QLineEdit();
503 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
505 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
507 emit widgetValueHasChanged(
this );
515 mLineEdit =
new QLineEdit();
516 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
518 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
520 emit widgetValueHasChanged(
this );
530void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
534 mLineEdit->setText( v );
535 if ( mPlainTextEdit )
536 mPlainTextEdit->setPlainText( v );
540 if ( !value.isValid() )
541 index = mComboBox->findData( QVariant() );
543 index = mComboBox->findData( v );
546 mComboBox->setCurrentIndex( index );
548 mComboBox->setCurrentIndex( 0 );
552QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
555 return mLineEdit->text();
556 else if ( mPlainTextEdit )
557 return mPlainTextEdit->toPlainText();
558 else if ( mComboBox )
559 return mComboBox->currentData();
564QStringList QgsProcessingStringWidgetWrapper::compatibleParameterTypes()
const
580QStringList QgsProcessingStringWidgetWrapper::compatibleOutputTypes()
const
588QString QgsProcessingStringWidgetWrapper::parameterType()
const
595 return new QgsProcessingStringWidgetWrapper( parameter, type );
600 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
615QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
624 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
628 emit widgetValueHasChanged(
this );
630 return mAuthConfigSelect;
636void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
639 if ( mAuthConfigSelect )
640 mAuthConfigSelect->setConfigId( v );
643QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
645 if ( mAuthConfigSelect )
646 return mAuthConfigSelect->configId();
651QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleParameterTypes()
const
659QStringList QgsProcessingAuthConfigWidgetWrapper::compatibleOutputTypes()
const
664QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
671 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
681 QVBoxLayout *vlayout =
new QVBoxLayout();
682 vlayout->setContentsMargins( 0, 0, 0, 0 );
684 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
686 mTypeComboBox =
new QComboBox();
689 vlayout->addWidget( mTypeComboBox );
691 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
692 mMinLineEdit =
new QLineEdit();
693 vlayout->addWidget( mMinLineEdit );
695 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
696 mMaxLineEdit =
new QLineEdit();
697 vlayout->addWidget( mMaxLineEdit );
699 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
700 mDefaultLineEdit =
new QLineEdit();
701 vlayout->addWidget( mDefaultLineEdit );
705 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( numberParam->dataType() ) );
707 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
709 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
713 mMaxLineEdit->clear();
716 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
718 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
722 mMinLineEdit->clear();
725 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
728 setLayout( vlayout );
731QgsProcessingParameterDefinition *QgsProcessingNumberParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
737 auto param = std::make_unique< QgsProcessingParameterNumber >( name, description, dataType, ok ? val : QVariant() );
739 if ( !mMinLineEdit->text().trimmed().isEmpty() )
744 param->setMinimum( val );
748 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
753 param->setMaximum( val );
757 param->setFlags( flags );
758 return param.release();
767QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
770 const QVariantMap metadata = numberDef->
metadata();
771 const int decimals = metadata.value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"decimals" ), 6 ).toInt();
779 QAbstractSpinBox *spinBox =
nullptr;
784 mDoubleSpinBox->setExpressionsEnabled(
true );
785 mDoubleSpinBox->setDecimals( decimals );
791 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
792 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
793 mDoubleSpinBox->setSingleStep( singleStep );
796 spinBox = mDoubleSpinBox;
801 mSpinBox->setExpressionsEnabled(
true );
805 spinBox->setToolTip( parameterDefinition()->toolTip() );
807 double max = 999999999;
812 double min = -999999999;
817 if ( mDoubleSpinBox )
819 mDoubleSpinBox->setMinimum( min );
820 mDoubleSpinBox->setMaximum( max );
824 mSpinBox->setMinimum(
static_cast< int >( min ) );
825 mSpinBox->setMaximum(
static_cast< int >( max ) );
830 mAllowingNull =
true;
831 if ( mDoubleSpinBox )
833 mDoubleSpinBox->setShowClearButton(
true );
834 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
835 mDoubleSpinBox->setMinimum( min );
836 mDoubleSpinBox->setValue( min );
840 mSpinBox->setShowClearButton(
true );
841 const int min = mSpinBox->minimum() - 1;
842 mSpinBox->setMinimum( min );
843 mSpinBox->setValue( min );
845 spinBox->setSpecialValueText( tr(
"Not set" ) );
853 if ( mDoubleSpinBox )
857 mDoubleSpinBox->setClearValue( defaultVal );
863 mSpinBox->setClearValue( intVal );
869 if ( mDoubleSpinBox )
870 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
872 mSpinBox->setClearValue(
static_cast< int >( numberDef->
minimum() ) );
877 if ( mDoubleSpinBox )
879 mDoubleSpinBox->setValue( 0 );
880 mDoubleSpinBox->setClearValue( 0 );
884 mSpinBox->setValue( 0 );
885 mSpinBox->setClearValue( 0 );
890 if ( mDoubleSpinBox )
891 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
893 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [ = ] { emit widgetValueHasChanged(
this ); } );
901void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
903 if ( mDoubleSpinBox )
905 if ( mAllowingNull && !value.isValid() )
906 mDoubleSpinBox->clear();
910 mDoubleSpinBox->setValue( v );
915 if ( mAllowingNull && !value.isValid() )
920 mSpinBox->setValue( v );
925QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
927 if ( mDoubleSpinBox )
929 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
932 return mDoubleSpinBox->value();
936 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
939 return mSpinBox->value();
945QStringList QgsProcessingNumericWidgetWrapper::compatibleParameterTypes()
const
955QStringList QgsProcessingNumericWidgetWrapper::compatibleOutputTypes()
const
961double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
963 const double valueRange = maximum - minimum;
964 if ( valueRange <= 1.0 )
966 const double step = valueRange / 10.0;
968 return qgsRound( step, -std::floor( std::log( step ) ) );
976QString QgsProcessingNumericWidgetWrapper::parameterType()
const
983 return new QgsProcessingNumericWidgetWrapper( parameter, type );
988 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
998 QVBoxLayout *vlayout =
new QVBoxLayout();
999 vlayout->setContentsMargins( 0, 0, 0, 0 );
1001 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1003 mParentLayerComboBox =
new QComboBox();
1005 QString initialParent;
1007 initialParent = distParam->parentParameterName();
1009 if (
auto *lModel = widgetContext.
model() )
1012 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1013 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1017 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1018 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1020 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1025 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1026 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1028 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1033 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1034 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1036 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1041 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
1042 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1044 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1050 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1053 mParentLayerComboBox->addItem( initialParent, initialParent );
1054 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1057 vlayout->addWidget( mParentLayerComboBox );
1059 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1060 mMinLineEdit =
new QLineEdit();
1061 vlayout->addWidget( mMinLineEdit );
1063 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1064 mMaxLineEdit =
new QLineEdit();
1065 vlayout->addWidget( mMaxLineEdit );
1067 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1068 mDefaultLineEdit =
new QLineEdit();
1069 vlayout->addWidget( mDefaultLineEdit );
1073 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
1074 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
1075 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
1078 setLayout( vlayout );
1081QgsProcessingParameterDefinition *QgsProcessingDistanceParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1086 auto param = std::make_unique< QgsProcessingParameterDistance >( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1091 param->setMinimum( val );
1097 param->setMaximum( val );
1100 param->setFlags( flags );
1101 return param.release();
1105 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1110QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
1117 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
1120QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1124 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1129 mLabel =
new QLabel();
1130 mUnitsCombo =
new QComboBox();
1132 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::DistanceUnit::Meters ),
static_cast< int >( Qgis::DistanceUnit::Meters ) );
1133 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::DistanceUnit::Kilometers ),
static_cast< int >( Qgis::DistanceUnit::Kilometers ) );
1134 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::DistanceUnit::Feet ),
static_cast< int >( Qgis::DistanceUnit::Feet ) );
1135 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::DistanceUnit::Yards ),
static_cast< int >( Qgis::DistanceUnit::Yards ) );
1136 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::DistanceUnit::Miles ),
static_cast< int >( Qgis::DistanceUnit::Miles ) );
1137 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::DistanceUnit::NauticalMiles ),
static_cast< int >( Qgis::DistanceUnit::NauticalMiles ) );
1138 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::DistanceUnit::Centimeters ),
static_cast< int >( Qgis::DistanceUnit::Centimeters ) );
1139 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::DistanceUnit::Millimeters ),
static_cast< int >( Qgis::DistanceUnit::Millimeters ) );
1142 const int labelMargin =
static_cast< int >( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1143 QHBoxLayout *layout =
new QHBoxLayout();
1144 layout->addWidget( spin, 1 );
1145 layout->insertSpacing( 1, labelMargin / 2 );
1146 layout->insertWidget( 2, mLabel );
1147 layout->insertWidget( 3, mUnitsCombo );
1152 mWarningLabel =
new QWidget();
1153 QHBoxLayout *warningLayout =
new QHBoxLayout();
1154 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1155 QLabel *warning =
new QLabel();
1157 const int size =
static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1158 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1159 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1160 warningLayout->insertSpacing( 0, labelMargin / 2 );
1161 warningLayout->insertWidget( 1, warning );
1162 mWarningLabel->setLayout( warningLayout );
1163 layout->insertWidget( 4, mWarningLabel );
1165 QWidget *w =
new QWidget();
1166 layout->setContentsMargins( 0, 0, 0, 0 );
1167 w->setLayout( layout );
1182void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1184 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1191 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1193 setUnitParameterValue( wrapper->parameterValue() );
1196 setUnitParameterValue( wrapper->parameterValue() );
1210void QgsProcessingDistanceWidgetWrapper::setUnitParameterValue(
const QVariant &value )
1216 std::unique_ptr< QgsProcessingContext > tmpContext;
1217 if ( mProcessingContextGenerator )
1218 context = mProcessingContextGenerator->processingContext();
1222 tmpContext = std::make_unique< QgsProcessingContext >();
1223 context = tmpContext.get();
1240 mUnitsCombo->hide();
1245 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( units ) ) );
1246 mUnitsCombo->show();
1249 mWarningLabel->setVisible( units == Qgis::DistanceUnit::Degrees );
1253QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1255 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1256 if ( val.type() == QVariant::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1269 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1280 QVBoxLayout *vlayout =
new QVBoxLayout();
1281 vlayout->setContentsMargins( 0, 0, 0, 0 );
1283 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1284 mMinLineEdit =
new QLineEdit();
1285 vlayout->addWidget( mMinLineEdit );
1287 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1288 mMaxLineEdit =
new QLineEdit();
1289 vlayout->addWidget( mMaxLineEdit );
1291 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1292 mDefaultLineEdit =
new QLineEdit();
1293 vlayout->addWidget( mDefaultLineEdit );
1295 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1297 mUnitsCombo =
new QComboBox();
1298 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Milliseconds ),
static_cast< int >( Qgis::TemporalUnit::Milliseconds ) );
1299 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Seconds ),
static_cast< int >( Qgis::TemporalUnit::Seconds ) );
1300 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Minutes ),
static_cast< int >( Qgis::TemporalUnit::Minutes ) );
1301 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Hours ),
static_cast< int >( Qgis::TemporalUnit::Hours ) );
1302 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Days ),
static_cast< int >( Qgis::TemporalUnit::Days ) );
1303 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Weeks ),
static_cast< int >( Qgis::TemporalUnit::Weeks ) );
1304 mUnitsCombo->addItem( tr(
"years (365.25 days)" ),
static_cast< int >( Qgis::TemporalUnit::Years ) );
1305 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Decades ),
static_cast< int >( Qgis::TemporalUnit::Decades ) );
1306 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Centuries ),
static_cast< int >( Qgis::TemporalUnit::Centuries ) );
1307 vlayout->addWidget( mUnitsCombo );
1311 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1312 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1313 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1314 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast <int >( durationParam->defaultUnit() ) ) );
1317 setLayout( vlayout );
1320QgsProcessingParameterDefinition *QgsProcessingDurationParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1325 auto param = std::make_unique< QgsProcessingParameterDuration >( name, description, ok ? val : QVariant() );
1330 param->setMinimum( val );
1336 param->setMaximum( val );
1339 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit >( mUnitsCombo->currentData().toInt() ) );
1341 param->setFlags( flags );
1342 return param.release();
1346 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1351QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1358 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1361QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1365 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1370 mUnitsCombo =
new QComboBox();
1372 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Milliseconds ),
static_cast< int >( Qgis::TemporalUnit::Milliseconds ) );
1373 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Seconds ),
static_cast< int >( Qgis::TemporalUnit::Seconds ) );
1374 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Minutes ),
static_cast< int >( Qgis::TemporalUnit::Minutes ) );
1375 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Hours ),
static_cast< int >( Qgis::TemporalUnit::Hours ) );
1376 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Days ),
static_cast< int >( Qgis::TemporalUnit::Days ) );
1377 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Weeks ),
static_cast< int >( Qgis::TemporalUnit::Weeks ) );
1378 mUnitsCombo->addItem( tr(
"years (365.25 days)" ),
static_cast< int >( Qgis::TemporalUnit::Years ) );
1379 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Decades ),
static_cast< int >( Qgis::TemporalUnit::Decades ) );
1380 mUnitsCombo->addItem(
QgsUnitTypes::toString( Qgis::TemporalUnit::Centuries ),
static_cast< int >( Qgis::TemporalUnit::Centuries ) );
1382 QHBoxLayout *layout =
new QHBoxLayout();
1383 layout->addWidget( spin, 1 );
1384 layout->insertWidget( 1, mUnitsCombo );
1386 QWidget *w =
new QWidget();
1387 layout->setContentsMargins( 0, 0, 0, 0 );
1388 w->setLayout( layout );
1390 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast< int >( durationDef->
defaultUnit() ) ) );
1391 mUnitsCombo->show();
1404QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
1416QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
1418 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1419 if ( val.type() == QVariant::Double && mUnitsCombo )
1430void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1436 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
1440 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
1446 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1456 QVBoxLayout *vlayout =
new QVBoxLayout();
1457 vlayout->setContentsMargins( 0, 0, 0, 0 );
1459 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1461 mDefaultLineEdit =
new QLineEdit();
1465 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1468 vlayout->addWidget( mDefaultLineEdit );
1470 setLayout( vlayout );
1473QgsProcessingParameterDefinition *QgsProcessingScaleParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1476 double val = mDefaultLineEdit->text().toDouble( &ok );
1477 auto param = std::make_unique< QgsProcessingParameterScale >( name, description, ok ? val : QVariant() );
1478 param->setFlags( flags );
1479 return param.release();
1483 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1488QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1495 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1498QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
1510 mScaleWidget->setAllowNull(
true );
1512 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
1513 mScaleWidget->setShowCurrentScaleButton(
true );
1515 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
1518 emit widgetValueHasChanged(
this );
1520 return mScaleWidget;
1529 mScaleWidget->setMapCanvas( context.
mapCanvas() );
1534QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
1536 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
1539void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1543 if ( mScaleWidget->allowNull() && !value.isValid() )
1544 mScaleWidget->setNull();
1548 mScaleWidget->setScale( v );
1555 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1566 QVBoxLayout *vlayout =
new QVBoxLayout();
1567 vlayout->setContentsMargins( 0, 0, 0, 0 );
1569 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
1571 mTypeComboBox =
new QComboBox();
1574 vlayout->addWidget( mTypeComboBox );
1576 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1577 mMinLineEdit =
new QLineEdit();
1578 vlayout->addWidget( mMinLineEdit );
1580 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1581 mMaxLineEdit =
new QLineEdit();
1582 vlayout->addWidget( mMaxLineEdit );
1586 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( rangeParam->dataType() ) );
1588 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
1589 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
1592 setLayout( vlayout );
1595QgsProcessingParameterDefinition *QgsProcessingRangeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1597 QString defaultValue;
1598 if ( mMinLineEdit->text().isEmpty() )
1600 defaultValue = QStringLiteral(
"None" );
1608 defaultValue = QStringLiteral(
"None" );
1612 if ( mMaxLineEdit->text().isEmpty() )
1614 defaultValue += QLatin1String(
",None" );
1620 defaultValue += QStringLiteral(
",%1" ).arg( ok ? QString::number( val ) : QLatin1String(
"None" ) );
1624 auto param = std::make_unique< QgsProcessingParameterRange >( name, description, dataType, defaultValue );
1625 param->setFlags( flags );
1626 return param.release();
1636QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
1645 QHBoxLayout *layout =
new QHBoxLayout();
1650 mMinSpinBox->setExpressionsEnabled(
true );
1651 mMinSpinBox->setShowClearButton(
false );
1652 mMaxSpinBox->setExpressionsEnabled(
true );
1653 mMaxSpinBox->setShowClearButton(
false );
1655 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
1656 layout->addWidget( minLabel );
1657 layout->addWidget( mMinSpinBox, 1 );
1659 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
1660 layout->addWidget( maxLabel );
1661 layout->addWidget( mMaxSpinBox, 1 );
1663 QWidget *w =
new QWidget();
1664 layout->setContentsMargins( 0, 0, 0, 0 );
1665 w->setLayout( layout );
1669 mMinSpinBox->setDecimals( 6 );
1670 mMaxSpinBox->setDecimals( 6 );
1674 mMinSpinBox->setDecimals( 0 );
1675 mMaxSpinBox->setDecimals( 0 );
1678 mMinSpinBox->setMinimum( -99999999.999999 );
1679 mMaxSpinBox->setMinimum( -99999999.999999 );
1680 mMinSpinBox->setMaximum( 99999999.999999 );
1681 mMaxSpinBox->setMaximum( 99999999.999999 );
1685 mAllowingNull =
true;
1687 const double min = mMinSpinBox->minimum() - 1;
1688 mMinSpinBox->setMinimum( min );
1689 mMaxSpinBox->setMinimum( min );
1690 mMinSpinBox->setValue( min );
1691 mMaxSpinBox->setValue( min );
1693 mMinSpinBox->setShowClearButton(
true );
1694 mMaxSpinBox->setShowClearButton(
true );
1695 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
1696 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
1699 w->setToolTip( parameterDefinition()->toolTip() );
1701 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1703 mBlockChangedSignal++;
1704 if ( !mAllowingNull && v > mMaxSpinBox->value() )
1705 mMaxSpinBox->setValue( v );
1706 mBlockChangedSignal--;
1708 if ( !mBlockChangedSignal )
1709 emit widgetValueHasChanged(
this );
1711 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
const double v )
1713 mBlockChangedSignal++;
1714 if ( !mAllowingNull && v < mMinSpinBox->value() )
1715 mMinSpinBox->setValue( v );
1716 mBlockChangedSignal--;
1718 if ( !mBlockChangedSignal )
1719 emit widgetValueHasChanged(
this );
1728void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1731 if ( mAllowingNull && v.empty() )
1733 mMinSpinBox->clear();
1734 mMaxSpinBox->clear();
1741 if ( mAllowingNull )
1743 mBlockChangedSignal++;
1744 if ( std::isnan( v.at( 0 ) ) )
1745 mMinSpinBox->clear();
1747 mMinSpinBox->setValue( v.at( 0 ) );
1749 if ( v.count() >= 2 )
1751 if ( std::isnan( v.at( 1 ) ) )
1752 mMaxSpinBox->clear();
1754 mMaxSpinBox->setValue( v.at( 1 ) );
1756 mBlockChangedSignal--;
1760 mBlockChangedSignal++;
1761 mMinSpinBox->setValue( v.at( 0 ) );
1762 if ( v.count() >= 2 )
1763 mMaxSpinBox->setValue( v.at( 1 ) );
1764 mBlockChangedSignal--;
1768 if ( !mBlockChangedSignal )
1769 emit widgetValueHasChanged(
this );
1772QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
1774 if ( mAllowingNull )
1777 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
1778 value = QStringLiteral(
"None" );
1780 value = QString::number( mMinSpinBox->value() );
1782 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
1783 value += QLatin1String(
",None" );
1785 value += QStringLiteral(
",%1" ).arg( mMaxSpinBox->value() );
1790 return QStringLiteral(
"%1,%2" ).arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
1793QStringList QgsProcessingRangeWidgetWrapper::compatibleParameterTypes()
const
1795 return QStringList()
1800QStringList QgsProcessingRangeWidgetWrapper::compatibleOutputTypes()
const
1805QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
1807 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
1810QString QgsProcessingRangeWidgetWrapper::parameterType()
const
1817 return new QgsProcessingRangeWidgetWrapper( parameter, type );
1822 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1833 QVBoxLayout *vlayout =
new QVBoxLayout();
1834 vlayout->setContentsMargins( 0, 0, 0, 0 );
1836 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
1839 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
1840 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
1842 vlayout->addWidget( mMatrixWidget );
1843 setLayout( vlayout );
1846QgsProcessingParameterDefinition *QgsProcessingMatrixParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1848 auto param = std::make_unique< QgsProcessingParameterMatrix >( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
1849 param->setFlags( flags );
1850 return param.release();
1860QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
1862 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast< const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
1863 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
1865 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [ = ]
1867 emit widgetValueHasChanged(
this );
1876 return mMatrixWidget;
1882void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1885 if ( mMatrixWidget )
1886 mMatrixWidget->setValue( v );
1889QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
1891 if ( mMatrixWidget )
1892 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
1897QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes()
const
1899 return QStringList()
1903QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes()
const
1905 return QStringList();
1908QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
1910 return tr(
"comma delimited string of values, or an array of values" );
1913QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
1920 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
1925 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1937 QVBoxLayout *vlayout =
new QVBoxLayout();
1938 vlayout->setContentsMargins( 0, 0, 0, 0 );
1940 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
1942 mTypeComboBox =
new QComboBox();
1946 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( fileParam->behavior() ) );
1948 mTypeComboBox->setCurrentIndex( 0 );
1949 vlayout->addWidget( mTypeComboBox );
1951 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
1953 mFilterComboBox =
new QComboBox();
1954 mFilterComboBox->setEditable(
true );
1956 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
1957 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
1958 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
1959 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
1961 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
1963 mFilterComboBox->setCurrentIndex( 0 );
1964 vlayout->addWidget( mFilterComboBox );
1966 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1969 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
1973 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
1977 vlayout->addWidget( mDefaultFileWidget );
1979 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ]
1988 setLayout( vlayout );
1991QgsProcessingParameterDefinition *QgsProcessingFileParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
1993 auto param = std::make_unique< QgsProcessingParameterFile >( name, description );
1996 param->setFileFilter( mFilterComboBox->currentText() );
1997 if ( !mDefaultFileWidget->filePath().isEmpty() )
1998 param->setDefaultValue( mDefaultFileWidget->filePath() );
1999 param->setFlags( flags );
2000 return param.release();
2010QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2020 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2021 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2023 mFileWidget->setDefaultRoot(
QgsSettings().value( QStringLiteral(
"/Processing/LastInputPath" ), QDir::homePath() ).toString() );
2030 mFileWidget->setFilter( fileParam->
fileFilter() );
2031 else if ( !fileParam->
extension().isEmpty() )
2032 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + QStringLiteral(
" (*." ) + fileParam->
extension().toLower() +
')' );
2042 QgsSettings().
setValue( QStringLiteral(
"/Processing/LastInputPath" ), QFileInfo( path ).canonicalPath() );
2043 emit widgetValueHasChanged(
this );
2051void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2055 mFileWidget->setFilePath( v );
2058QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2061 return mFileWidget->filePath();
2066QStringList QgsProcessingFileWidgetWrapper::compatibleParameterTypes()
const
2068 return QStringList()
2073QStringList QgsProcessingFileWidgetWrapper::compatibleOutputTypes()
const
2083QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2085 return tr(
"string representing a path to a file or folder" );
2088QString QgsProcessingFileWidgetWrapper::parameterType()
const
2095 return new QgsProcessingFileWidgetWrapper( parameter, type );
2100 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2112 QVBoxLayout *vlayout =
new QVBoxLayout();
2113 vlayout->setContentsMargins( 0, 0, 0, 0 );
2114 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2117 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2119 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2121 QStackedWidget *stackedWidget =
new QStackedWidget();
2122 stackedWidget->addWidget( mDefaultQgisLineEdit );
2123 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2124 vlayout->addWidget( stackedWidget );
2129 mDefaultQgisLineEdit->setExpression( expr );
2130 mDefaultPointCloudLineEdit->setExpression( expr );
2133 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2135 mParentLayerComboBox =
new QComboBox();
2136 vlayout->addWidget( mParentLayerComboBox );
2138 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2139 mExpressionTypeComboBox =
new QComboBox();
2143 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2145 mParentLayerComboBox->clear();
2146 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2148 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2150 QString initialParent;
2152 initialParent = expParam->parentLayerParameterName();
2156 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2159 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2160 for ( auto it = components.constBegin(); it != components.constEnd(); ++it )
2162 if ( exprType == Qgis::ExpressionType::Qgis )
2164 if ( const QgsProcessingParameterFeatureSource *definition = dynamic_cast< const QgsProcessingParameterFeatureSource * >( model->parameterDefinition( it.value().parameterName() ) ) )
2166 mParentLayerComboBox-> addItem( definition->description(), definition->name() );
2167 if ( !initialParent.isEmpty() && initialParent == definition->name() )
2169 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2172 else if ( const QgsProcessingParameterVectorLayer *definition = dynamic_cast< const QgsProcessingParameterVectorLayer * >( model->parameterDefinition( it.value().parameterName() ) ) )
2174 mParentLayerComboBox-> addItem( definition->description(), definition->name() );
2175 if ( !initialParent.isEmpty() && initialParent == definition->name() )
2177 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2183 if ( const QgsProcessingParameterPointCloudLayer *definition = dynamic_cast< const QgsProcessingParameterPointCloudLayer * >( model->parameterDefinition( it.value().parameterName() ) ) )
2185 mParentLayerComboBox-> addItem( definition->description(), definition->name() );
2186 if ( !initialParent.isEmpty() && initialParent == definition->name() )
2188 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2195 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2198 mParentLayerComboBox->addItem( initialParent, initialParent );
2199 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2204 mExpressionTypeComboBox->setCurrentIndex( -1 );
2206 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast< int >( expParam->expressionType() ) ) );
2208 mExpressionTypeComboBox->setCurrentIndex( 0 );
2210 vlayout->addWidget( mExpressionTypeComboBox );
2212 setLayout( vlayout );
2215QgsProcessingParameterDefinition *QgsProcessingExpressionParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
2218 QString expression = expressionType ==
Qgis::ExpressionType::Qgis ? mDefaultQgisLineEdit->expression() : mDefaultPointCloudLineEdit->expression();
2219 auto param = std::make_unique< QgsProcessingParameterExpression >( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2220 param->setFlags( flags );
2221 return param.release();
2230QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2242 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2243 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2244 mExpLineEdit->registerExpressionContextGenerator(
this );
2247 emit widgetValueHasChanged(
this );
2249 return mExpLineEdit;
2255 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2256 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2257 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [ = ](
const QString & )
2259 emit widgetValueHasChanged(
this );
2261 return mPointCloudExpLineEdit;
2265 if ( expParam->
metadata().value( QStringLiteral(
"inlineEditor" ) ).toBool() )
2268 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2269 mExpBuilderWidget->init( createExpressionContext() );
2272 Q_UNUSED( changed );
2273 emit widgetValueHasChanged(
this );
2275 return mExpBuilderWidget;
2280 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2281 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2282 mFieldExpWidget->registerExpressionContextGenerator(
this );
2284 mFieldExpWidget->setAllowEmptyFieldName(
true );
2288 emit widgetValueHasChanged(
this );
2290 return mFieldExpWidget;
2298void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2308 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterExpression *
>( parameterDefinition() )->parentLayerParameterName() )
2310 setParentLayerWrapperValue( wrapper );
2313 setParentLayerWrapperValue( wrapper );
2329 if ( mExpBuilderWidget )
2332 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2340 std::unique_ptr< QgsProcessingContext > tmpContext;
2341 if ( mProcessingContextGenerator )
2342 context = mProcessingContextGenerator->processingContext();
2346 tmpContext = std::make_unique< QgsProcessingContext >();
2347 context = tmpContext.get();
2357 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2367 if ( mFieldExpWidget )
2368 mFieldExpWidget->setLayer(
nullptr );
2369 else if ( mExpBuilderWidget )
2370 mExpBuilderWidget->setLayer(
nullptr );
2371 else if ( mExpLineEdit )
2372 mExpLineEdit->setLayer(
nullptr );
2378 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
2379 if ( ownedLayer && ownedLayer->type() == Qgis::LayerType::Vector )
2381 mParentLayer.reset( ownedLayer.release() );
2389 if ( mFieldExpWidget )
2390 mFieldExpWidget->setLayer( layer );
2391 if ( mExpBuilderWidget )
2392 mExpBuilderWidget->setLayer( layer );
2393 else if ( mExpLineEdit )
2394 mExpLineEdit->setLayer( layer );
2403 if ( mPointCloudExpLineEdit )
2404 mPointCloudExpLineEdit->setLayer(
nullptr );
2410 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
2411 if ( ownedLayer && ownedLayer->type() == Qgis::LayerType::PointCloud )
2413 mParentLayer.reset( ownedLayer.release() );
2421 if ( mPointCloudExpLineEdit )
2422 mPointCloudExpLineEdit->setLayer( layer );
2429void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2432 if ( mFieldExpWidget )
2433 mFieldExpWidget->setExpression( v );
2434 else if ( mExpBuilderWidget )
2435 mExpBuilderWidget->setExpressionText( v );
2436 else if ( mExpLineEdit )
2437 mExpLineEdit->setExpression( v );
2438 else if ( mPointCloudExpLineEdit )
2439 mPointCloudExpLineEdit->setExpression( v );
2442QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2444 if ( mFieldExpWidget )
2445 return mFieldExpWidget->expression();
2446 if ( mExpBuilderWidget )
2447 return mExpBuilderWidget->expressionText();
2448 else if ( mExpLineEdit )
2449 return mExpLineEdit->expression();
2450 else if ( mPointCloudExpLineEdit )
2451 return mPointCloudExpLineEdit->expression();
2456QStringList QgsProcessingExpressionWidgetWrapper::compatibleParameterTypes()
const
2458 return QStringList()
2467QStringList QgsProcessingExpressionWidgetWrapper::compatibleOutputTypes()
const
2469 return QStringList()
2474QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2476 return tr(
"string representation of an expression" );
2479const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
2481 if ( mFieldExpWidget && mFieldExpWidget->layer() )
2482 return mFieldExpWidget->layer();
2484 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
2485 return mExpBuilderWidget->layer();
2490QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
2497 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
2502 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2515 QHBoxLayout *hl =
new QHBoxLayout();
2516 hl->setContentsMargins( 0, 0, 0, 0 );
2518 mLineEdit =
new QLineEdit();
2519 mLineEdit->setEnabled(
false );
2520 hl->addWidget( mLineEdit, 1 );
2522 mToolButton =
new QToolButton();
2523 mToolButton->setText( QString( QChar( 0x2026 ) ) );
2524 hl->addWidget( mToolButton );
2530 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2533 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
2536void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
2538 if ( value.isValid() )
2540 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
2542 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
2548 updateSummaryText();
2552void QgsProcessingEnumPanelWidget::showDialog()
2554 QVariantList availableOptions;
2557 availableOptions.reserve( mParam->options().size() );
2559 if ( mParam->usesStaticStrings() )
2561 for ( QString o : mParam->options() )
2563 availableOptions << o;
2568 for (
int i = 0; i < mParam->options().count(); ++i )
2569 availableOptions << i;
2573 const QStringList options = mParam ? mParam->options() : QStringList();
2577 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
2578 widget->setPanelTitle( mParam->description() );
2580 if ( mParam->usesStaticStrings() )
2582 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
2584 const QString i = v.toString();
2585 return options.contains( i ) ? i : QString();
2590 widget->setValueFormatter( [options](
const QVariant & v ) -> QString
2592 const int i = v.toInt();
2593 return options.size() > i ? options.at( i ) : QString();
2597 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
2599 setValue( widget->selectedOptions() );
2606 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
2608 dlg.setValueFormatter( [options](
const QVariant & v ) -> QString
2610 const int i = v.toInt();
2611 return options.size() > i ? options.at( i ) : QString();
2615 setValue( dlg.selectedOptions() );
2620void QgsProcessingEnumPanelWidget::updateSummaryText()
2625 if ( mValue.empty() )
2627 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
2632 values.reserve( mValue.size() );
2633 if ( mParam->usesStaticStrings() )
2635 for (
const QVariant &val : std::as_const( mValue ) )
2637 values << val.toString();
2642 const QStringList options = mParam->options();
2643 for (
const QVariant &val : std::as_const( mValue ) )
2645 const int i = val.toInt();
2646 values << ( options.size() > i ? options.at( i ) : QString() );
2650 const QString concatenated = values.join( tr(
"," ) );
2651 if ( concatenated.length() < 100 )
2652 mLineEdit->setText( concatenated );
2654 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
2662QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
2665 , mButtonGroup( new QButtonGroup( this ) )
2666 , mColumns( columns )
2668 mButtonGroup->setExclusive( !mParam->allowMultiple() );
2670 QGridLayout *l =
new QGridLayout();
2671 l->setContentsMargins( 0, 0, 0, 0 );
2673 int rows =
static_cast< int >( std::ceil( mParam->options().count() /
static_cast< double >( mColumns ) ) );
2674 for (
int i = 0; i < mParam->options().count(); ++i )
2676 QAbstractButton *button =
nullptr;
2677 if ( mParam->allowMultiple() )
2678 button =
new QCheckBox( mParam->options().at( i ) );
2680 button =
new QRadioButton( mParam->options().at( i ) );
2682 connect( button, &QAbstractButton::toggled,
this, [ = ]
2684 if ( !mBlockChangedSignal )
2688 mButtons.insert( i, button );
2690 mButtonGroup->addButton( button, i );
2691 l->addWidget( button, i % rows, i / rows );
2693 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
2696 if ( mParam->allowMultiple() )
2698 setContextMenuPolicy( Qt::CustomContextMenu );
2699 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
2703QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
2705 if ( mParam->allowMultiple() )
2708 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2710 if ( it.value()->isChecked() )
2711 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
2717 if ( mParam->usesStaticStrings() )
2718 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
2720 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
2724void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
2726 mBlockChangedSignal =
true;
2727 if ( mParam->allowMultiple() )
2729 QVariantList selected;
2730 if ( value.isValid() )
2731 selected = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
2732 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2734 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
2735 it.value()->setChecked( selected.contains( v ) );
2741 if ( v.type() == QVariant::List )
2742 v = v.toList().value( 0 );
2744 v = mParam->usesStaticStrings() ? mParam->options().indexOf( v.toString() ) : v;
2745 if ( mButtons.contains( v ) )
2746 mButtons.value( v )->setChecked(
true );
2748 mBlockChangedSignal =
false;
2752void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
2755 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
2756 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
2757 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
2758 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
2759 popupMenu.addAction( selectAllAction );
2760 popupMenu.addAction( clearAllAction );
2761 popupMenu.exec( QCursor::pos() );
2764void QgsProcessingEnumCheckboxPanelWidget::selectAll()
2766 mBlockChangedSignal =
true;
2767 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2768 it.value()->setChecked(
true );
2769 mBlockChangedSignal =
false;
2773void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
2775 mBlockChangedSignal =
true;
2776 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
2777 it.value()->setChecked(
false );
2778 mBlockChangedSignal =
false;
2790 QVBoxLayout *vlayout =
new QVBoxLayout();
2791 vlayout->setContentsMargins( 0, 0, 0, 0 );
2793 mEnumWidget =
new QgsProcessingEnumModelerWidget();
2796 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
2797 mEnumWidget->setOptions( enumParam->options() );
2798 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
2800 vlayout->addWidget( mEnumWidget );
2801 setLayout( vlayout );
2804QgsProcessingParameterDefinition *QgsProcessingEnumParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
2806 auto param = std::make_unique< QgsProcessingParameterEnum >( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
2808 return param.release();
2818QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
2826 if ( expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"useCheckBoxes" ),
false ).toBool() )
2828 const int columns = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"columns" ), 2 ).toInt();
2829 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
2830 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
2831 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [ = ]
2833 emit widgetValueHasChanged(
this );
2835 return mCheckboxPanel;
2844 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
2845 mPanel->setToolTip( parameterDefinition()->toolTip() );
2846 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [ = ]
2848 emit widgetValueHasChanged(
this );
2854 mComboBox =
new QComboBox();
2857 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
2858 const QStringList options = expParam->
options();
2859 const QVariantList iconList = expParam->
metadata().value( QStringLiteral(
"widget_wrapper" ) ).toMap().value( QStringLiteral(
"icons" ) ).toList();
2860 for (
int i = 0; i < options.count(); ++i )
2862 const QIcon icon = iconList.value( i ).value< QIcon >();
2865 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
2867 mComboBox->addItem( icon, options.at( i ), i );
2870 mComboBox->setToolTip( parameterDefinition()->toolTip() );
2871 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
2873 emit widgetValueHasChanged(
this );
2882void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2886 if ( !value.isValid() )
2887 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
2894 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
2899 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
2903 else if ( mPanel || mCheckboxPanel )
2906 if ( value.isValid() )
2912 opts.reserve( v.size() );
2913 for ( QString i : v )
2919 opts.reserve( v.size() );
2925 mPanel->setValue( opts );
2926 else if ( mCheckboxPanel )
2927 mCheckboxPanel->setValue( opts );
2931QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
2934 return mComboBox->currentData();
2936 return mPanel->value();
2937 else if ( mCheckboxPanel )
2938 return mCheckboxPanel->value();
2943QStringList QgsProcessingEnumWidgetWrapper::compatibleParameterTypes()
const
2945 return QStringList()
2951QStringList QgsProcessingEnumWidgetWrapper::compatibleOutputTypes()
const
2953 return QStringList()
2958QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
2960 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
2963QString QgsProcessingEnumWidgetWrapper::parameterType()
const
2970 return new QgsProcessingEnumWidgetWrapper( parameter, type );
2975 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2988QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
2997 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() :
nullptr );
2999 mComboBox->setAllowEmptyLayout(
true );
3002 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3005 emit widgetValueHasChanged(
this );
3012 mPlainComboBox =
new QComboBox();
3013 mPlainComboBox->setEditable(
true );
3014 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3015 if ( widgetContext().project() )
3019 mPlainComboBox->addItem( layout->name() );
3022 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
3024 emit widgetValueHasChanged(
this );
3026 return mPlainComboBox;
3032void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3036 if ( !value.isValid() )
3037 mComboBox->setCurrentLayout(
nullptr );
3041 mComboBox->setCurrentLayout( l );
3043 mComboBox->setCurrentLayout(
nullptr );
3046 else if ( mPlainComboBox )
3049 mPlainComboBox->setCurrentText( v );
3053QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3058 return l ? l->
name() : QVariant();
3060 else if ( mPlainComboBox )
3061 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3069 if ( mPlainComboBox && context.
project() )
3073 mPlainComboBox->addItem( layout->name() );
3077QStringList QgsProcessingLayoutWidgetWrapper::compatibleParameterTypes()
const
3079 return QStringList()
3084QStringList QgsProcessingLayoutWidgetWrapper::compatibleOutputTypes()
const
3086 return QStringList()
3090QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3092 return tr(
"string representing the name of an existing print layout" );
3095QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3102 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3116 QVBoxLayout *vlayout =
new QVBoxLayout();
3117 vlayout->setContentsMargins( 0, 0, 0, 0 );
3119 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3121 mParentLayoutComboBox =
new QComboBox();
3122 QString initialParent;
3124 initialParent = itemParam->parentLayoutParameterName();
3126 if (
auto *lModel = widgetContext.
model() )
3129 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3130 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3134 mParentLayoutComboBox-> addItem( definition->
description(), definition->
name() );
3135 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3137 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3143 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3146 mParentLayoutComboBox->addItem( initialParent, initialParent );
3147 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3150 vlayout->addWidget( mParentLayoutComboBox );
3151 setLayout( vlayout );
3153QgsProcessingParameterDefinition *QgsProcessingLayoutItemParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3155 auto param = std::make_unique< QgsProcessingParameterLayoutItem >( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3157 return param.release();
3167QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3178 mComboBox->setAllowEmptyItem(
true );
3179 if ( layoutParam->
itemType() >= 0 )
3182 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3185 emit widgetValueHasChanged(
this );
3192 mLineEdit =
new QLineEdit();
3193 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3194 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3196 emit widgetValueHasChanged(
this );
3204void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3214 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterLayoutItem *
>( parameterDefinition() )->parentLayoutParameterName() )
3216 setLayoutParameterValue( wrapper->parameterValue() );
3219 setLayoutParameterValue( wrapper->parameterValue() );
3232void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3238 std::unique_ptr< QgsProcessingContext > tmpContext;
3239 if ( mProcessingContextGenerator )
3240 context = mProcessingContextGenerator->processingContext();
3244 tmpContext = std::make_unique< QgsProcessingContext >();
3245 context = tmpContext.get();
3249 setLayout( layout );
3252void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3255 mComboBox->setCurrentLayout( layout );
3258void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3262 if ( !value.isValid() )
3263 mComboBox->setItem(
nullptr );
3267 mComboBox->setItem( item );
3270 else if ( mLineEdit )
3273 mLineEdit->setText( v );
3277QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3282 return i ? i->
uuid() : QVariant();
3284 else if ( mLineEdit )
3285 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3290QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleParameterTypes()
const
3292 return QStringList()
3297QStringList QgsProcessingLayoutItemWidgetWrapper::compatibleOutputTypes()
const
3299 return QStringList()
3303QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3305 return tr(
"string representing the UUID or ID of an existing print layout item" );
3308QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3315 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3320 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3327QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3334QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3336void QgsProcessingPointMapTool::deactivate()
3350 if ( e->button() == Qt::LeftButton )
3353 emit clicked( point );
3358void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3360 if ( e->key() == Qt::Key_Escape )
3375QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3378 QHBoxLayout *l =
new QHBoxLayout();
3379 l->setContentsMargins( 0, 0, 0, 0 );
3381 mLineEdit->setShowClearButton(
false );
3382 l->addWidget( mLineEdit, 1 );
3383 mButton =
new QToolButton();
3384 mButton->setText( QString( QChar( 0x2026 ) ) );
3385 l->addWidget( mButton );
3388 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3389 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3390 mButton->setVisible(
false );
3393void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
3396 mButton->setVisible(
true );
3399 mTool = std::make_unique< QgsProcessingPointMapTool >( mCanvas );
3400 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
3401 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
3404void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
3406 mLineEdit->setShowClearButton( allowNull );
3409QVariant QgsProcessingPointPanel::value()
const
3411 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
3414void QgsProcessingPointPanel::clear()
3421 QString newText = QStringLiteral(
"%1,%2" )
3422 .arg( QString::number( point.
x(),
'f' ),
3423 QString::number( point.
y(),
'f' ) );
3426 if ( mCrs.isValid() )
3428 newText += QStringLiteral(
" [%1]" ).arg( mCrs.authid() );
3430 mLineEdit->setText( newText );
3433void QgsProcessingPointPanel::selectOnCanvas()
3438 mPrevTool = mCanvas->mapTool();
3439 mCanvas->setMapTool( mTool.get() );
3441 emit toggleDialogVisibility(
false );
3444void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3446 setValue( point, mCanvas->mapSettings().destinationCrs() );
3449void QgsProcessingPointPanel::pointPicked()
3454 mCanvas->setMapTool( mPrevTool );
3456 emit toggleDialogVisibility(
true );
3468 QVBoxLayout *vlayout =
new QVBoxLayout();
3469 vlayout->setContentsMargins( 0, 0, 0, 0 );
3471 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3473 mDefaultLineEdit =
new QLineEdit();
3474 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3475 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
3479 mDefaultLineEdit->setText( QStringLiteral(
"%1,%2" ).arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
3482 vlayout->addWidget( mDefaultLineEdit );
3483 setLayout( vlayout );
3486QgsProcessingParameterDefinition *QgsProcessingPointParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3488 auto param = std::make_unique< QgsProcessingParameterPoint >( name, description, mDefaultLineEdit->text() );
3490 return param.release();
3499QWidget *QgsProcessingPointWidgetWrapper::createWidget()
3507 mPanel =
new QgsProcessingPointPanel(
nullptr );
3508 if ( widgetContext().mapCanvas() )
3509 mPanel->setMapCanvas( widgetContext().mapCanvas() );
3512 mPanel->setAllowNull(
true );
3514 mPanel->setToolTip( parameterDefinition()->toolTip() );
3516 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [ = ]
3518 emit widgetValueHasChanged(
this );
3522 setDialog( mDialog );
3528 mLineEdit =
new QLineEdit();
3529 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
3530 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & )
3532 emit widgetValueHasChanged(
this );
3544 mPanel->setMapCanvas( context.
mapCanvas() );
3547void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
3552 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [ = ](
bool visible )
3555 mDialog->showMinimized();
3558 mDialog->showNormal();
3560 mDialog->activateWindow();
3567void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3571 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
3577 mPanel->setValue( p,
crs );
3580 else if ( mLineEdit )
3583 mLineEdit->setText( v );
3587QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
3591 return mPanel->value();
3593 else if ( mLineEdit )
3594 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3599QStringList QgsProcessingPointWidgetWrapper::compatibleParameterTypes()
const
3601 return QStringList()
3606QStringList QgsProcessingPointWidgetWrapper::compatibleOutputTypes()
const
3608 return QStringList()
3612QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
3614 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
3617QString QgsProcessingPointWidgetWrapper::parameterType()
const
3624 return new QgsProcessingPointWidgetWrapper( parameter, type );
3629 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3641 QVBoxLayout *vlayout =
new QVBoxLayout();
3642 vlayout->setContentsMargins( 0, 0, 0, 0 );
3644 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3646 mDefaultLineEdit =
new QLineEdit();
3647 mDefaultLineEdit->setToolTip( tr(
"Geometry as WKT" ) );
3648 mDefaultLineEdit->setPlaceholderText( tr(
"Geometry as WKT" ) );
3653 mDefaultLineEdit->setText( g.
asWkt() );
3656 vlayout->addWidget( mDefaultLineEdit );
3657 setLayout( vlayout );
3660QgsProcessingParameterDefinition *QgsProcessingGeometryParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3662 auto param = std::make_unique< QgsProcessingParameterGeometry >( name, description, mDefaultLineEdit->text() );
3664 return param.release();
3673QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
3681 mLineEdit =
new QLineEdit();
3682 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
3683 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
3685 emit widgetValueHasChanged(
this );
3693void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3699 mLineEdit->setText( g.
asWkt() );
3705QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
3708 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3713QStringList QgsProcessingGeometryWidgetWrapper::compatibleParameterTypes()
const
3715 return QStringList()
3722QStringList QgsProcessingGeometryWidgetWrapper::compatibleOutputTypes()
const
3724 return QStringList()
3728QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
3730 return tr(
"string in the Well-Known-Text format or a geometry value" );
3733QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
3740 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
3745 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3757 QVBoxLayout *vlayout =
new QVBoxLayout();
3758 vlayout->setContentsMargins( 0, 0, 0, 0 );
3760 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3763 mDefaultColorButton->setShowNull(
true );
3764 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
3770 mDefaultColorButton->setToNull();
3772 mDefaultColorButton->setColor(
c );
3773 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
3777 mDefaultColorButton->setToNull();
3778 mAllowOpacity->setChecked(
true );
3781 vlayout->addWidget( mDefaultColorButton );
3782 vlayout->addWidget( mAllowOpacity );
3783 setLayout( vlayout );
3786QgsProcessingParameterDefinition *QgsProcessingColorParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3788 auto param = std::make_unique< QgsProcessingParameterColor >( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
3790 return param.release();
3799QWidget *QgsProcessingColorWidgetWrapper::createWidget()
3809 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
3812 mColorButton->setShowNull(
true );
3815 mColorButton->setToolTip( parameterDefinition()->toolTip() );
3816 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
3824 emit widgetValueHasChanged(
this );
3827 return mColorButton;
3833void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3837 if ( !value.isValid() ||
3838 ( value.type() == QVariant::String && value.toString().isEmpty() )
3839 || ( value.type() == QVariant::Color && !value.value< QColor >().isValid() ) )
3840 mColorButton->setToNull();
3844 if ( !
c.isValid() && mColorButton->showNull() )
3845 mColorButton->setToNull();
3847 mColorButton->setColor(
c );
3852QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
3855 return mColorButton->isNull() ? QVariant() : mColorButton->color();
3860QStringList QgsProcessingColorWidgetWrapper::compatibleParameterTypes()
const
3862 return QStringList()
3867QStringList QgsProcessingColorWidgetWrapper::compatibleOutputTypes()
const
3869 return QStringList()
3873QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
3875 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
3878QString QgsProcessingColorWidgetWrapper::parameterType()
const
3885 return new QgsProcessingColorWidgetWrapper( parameter, type );
3890 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3901 QVBoxLayout *vlayout =
new QVBoxLayout();
3902 vlayout->setContentsMargins( 0, 0, 0, 0 );
3904 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
3906 mDefaultLineEdit =
new QLineEdit();
3909 vlayout->addWidget( mDefaultLineEdit );
3911 mSourceParamComboBox =
new QComboBox();
3912 mDestParamComboBox =
new QComboBox();
3913 QString initialSource;
3914 QString initialDest;
3919 initialSource = itemParam->sourceCrsParameterName();
3920 initialDest = itemParam->destinationCrsParameterName();
3925 mSourceParamComboBox->addItem( QString(), QString() );
3926 mDestParamComboBox->addItem( QString(), QString() );
3927 if (
auto *lModel = widgetContext.
model() )
3930 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3931 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3933 if ( definition && it->parameterName() == definition->
name() )
3937 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
3938 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
3939 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
3941 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
3943 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
3945 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
3950 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
3953 mSourceParamComboBox->addItem( initialSource, initialSource );
3954 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
3956 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
3959 mDestParamComboBox->addItem( initialDest, initialDest );
3960 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
3963 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
3964 vlayout->addWidget( mSourceParamComboBox );
3965 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
3966 vlayout->addWidget( mDestParamComboBox );
3970 mStaticSourceWidget->setCrs( sourceCrs );
3973 mStaticDestWidget->setCrs( destCrs );
3975 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
3976 vlayout->addWidget( mStaticSourceWidget );
3977 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
3978 vlayout->addWidget( mStaticDestWidget );
3980 setLayout( vlayout );
3983QgsProcessingParameterDefinition *QgsProcessingCoordinateOperationParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
3985 auto param = std::make_unique< QgsProcessingParameterCoordinateOperation >( name, description, mDefaultLineEdit->text(),
3986 mSourceParamComboBox->currentText(),
3987 mDestParamComboBox->currentText(),
3988 mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
3989 mStaticDestWidget->crs().isValid() ? QVariant::fromValue( mStaticDestWidget->crs() ) : QVariant() );
3991 return param.release();
4000QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4011 mOperationWidget->setShowMakeDefault(
false );
4012 mOperationWidget->setShowFallbackOption(
false );
4013 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4014 mOperationWidget->setSourceCrs( mSourceCrs );
4015 mOperationWidget->setDestinationCrs( mDestCrs );
4016 mOperationWidget->setMapCanvas( mCanvas );
4021 mOperationWidget->setSelectedOperation( deets );
4026 emit widgetValueHasChanged(
this );
4029 return mOperationWidget;
4035 mLineEdit =
new QLineEdit();
4036 QHBoxLayout *layout =
new QHBoxLayout();
4037 layout->addWidget( mLineEdit, 1 );
4038 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4040 emit widgetValueHasChanged(
this );
4043 QToolButton *button =
new QToolButton();
4044 button->setText( QString( QChar( 0x2026 ) ) );
4045 connect( button, &QToolButton::clicked,
this, [ = ]
4047 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4050 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4051 emit widgetValueHasChanged(
this );
4054 layout->addWidget( button );
4056 QWidget *w =
new QWidget();
4057 layout->setContentsMargins( 0, 0, 0, 0 );
4058 w->setLayout( layout );
4066void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4078 setSourceCrsParameterValue( wrapper->parameterValue() );
4081 setSourceCrsParameterValue( wrapper->parameterValue() );
4086 setDestinationCrsParameterValue( wrapper->parameterValue() );
4089 setDestinationCrsParameterValue( wrapper->parameterValue() );
4104 if ( mOperationWidget )
4105 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4108void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4110 if ( mOperationWidget )
4112 if ( !value.isValid() ||
4113 ( value.type() == QVariant::String ) )
4116 deets.
proj = value.toString();
4117 mOperationWidget->setSelectedOperation( deets );
4122 if ( !value.isValid() ||
4123 ( value.type() == QVariant::String ) )
4125 mLineEdit->setText( value.toString() );
4130QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4132 if ( mOperationWidget )
4133 return mOperationWidget->selectedOperation().proj;
4134 else if ( mLineEdit )
4135 return mLineEdit->text();
4140QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleParameterTypes()
const
4142 return QStringList()
4147QStringList QgsProcessingCoordinateOperationWidgetWrapper::compatibleOutputTypes()
const
4149 return QStringList()
4153QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4155 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4158void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4161 std::unique_ptr< QgsProcessingContext > tmpContext;
4162 if ( mProcessingContextGenerator )
4163 context = mProcessingContextGenerator->processingContext();
4167 tmpContext = std::make_unique< QgsProcessingContext >();
4168 context = tmpContext.get();
4172 if ( mOperationWidget )
4174 mOperationWidget->setSourceCrs( mSourceCrs );
4175 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4179void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4182 std::unique_ptr< QgsProcessingContext > tmpContext;
4183 if ( mProcessingContextGenerator )
4184 context = mProcessingContextGenerator->processingContext();
4188 tmpContext = std::make_unique< QgsProcessingContext >();
4189 context = tmpContext.get();
4193 if ( mOperationWidget )
4195 mOperationWidget->setDestinationCrs( mDestCrs );
4196 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4200QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
4207 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
4212 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4225 QHBoxLayout *hl =
new QHBoxLayout();
4226 hl->setContentsMargins( 0, 0, 0, 0 );
4228 mLineEdit =
new QLineEdit();
4229 mLineEdit->setEnabled(
false );
4230 hl->addWidget( mLineEdit, 1 );
4232 mToolButton =
new QToolButton();
4233 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4234 hl->addWidget( mToolButton );
4240 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4243 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4246void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4251void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4253 if ( value.isValid() )
4254 mValue = value.type() == QVariant::List ? value.
toList() : QVariantList() << value;
4258 updateSummaryText();
4262void QgsProcessingFieldPanelWidget::showDialog()
4264 QVariantList availableOptions;
4265 availableOptions.reserve( mFields.size() );
4274 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4275 widget->setPanelTitle( mParam->description() );
4277 widget->setValueFormatter( [](
const QVariant & v ) -> QString
4279 return v.toString();
4282 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
4284 setValue( widget->selectedOptions() );
4291 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4293 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
4295 return v.toString();
4299 setValue( dlg.selectedOptions() );
4304void QgsProcessingFieldPanelWidget::updateSummaryText()
4309 if ( mValue.empty() )
4311 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4316 values.reserve( mValue.size() );
4317 for (
const QVariant &val : std::as_const( mValue ) )
4319 values << val.toString();
4322 const QString concatenated = values.join( tr(
"," ) );
4323 if ( concatenated.length() < 100 )
4324 mLineEdit->setText( concatenated );
4326 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4338 QVBoxLayout *vlayout =
new QVBoxLayout();
4339 vlayout->setContentsMargins( 0, 0, 0, 0 );
4341 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4342 mParentLayerComboBox =
new QComboBox();
4344 QString initialParent;
4346 initialParent = fieldParam->parentLayerParameterName();
4348 if (
auto *lModel = widgetContext.
model() )
4351 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4352 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4356 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4357 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4359 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4364 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4365 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4367 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4374 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
4375 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4377 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4384 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4387 mParentLayerComboBox->addItem( initialParent, initialParent );
4388 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4391 vlayout->addWidget( mParentLayerComboBox );
4393 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4394 mDataTypeComboBox =
new QComboBox();
4400 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData( fieldParam->dataType() ) );
4402 vlayout->addWidget( mDataTypeComboBox );
4404 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4406 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4408 vlayout->addWidget( mAllowMultipleCheckBox );
4410 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4411 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4413 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4415 vlayout->addWidget( mDefaultToAllCheckBox );
4417 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
4419 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4422 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4424 mDefaultLineEdit =
new QLineEdit();
4425 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4429 mDefaultLineEdit->setText( fields.join(
';' ) );
4431 vlayout->addWidget( mDefaultLineEdit );
4433 setLayout( vlayout );
4436QgsProcessingParameterDefinition *QgsProcessingFieldParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4440 QVariant defaultValue;
4441 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4443 defaultValue = mDefaultLineEdit->text();
4445 auto param = std::make_unique< QgsProcessingParameterField >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
4447 return param.release();
4456QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
4466 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
4467 mPanel->setToolTip( parameterDefinition()->toolTip() );
4468 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [ = ]
4470 emit widgetValueHasChanged(
this );
4486 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4489 emit widgetValueHasChanged(
this );
4497 mLineEdit =
new QLineEdit();
4498 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
4499 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
4501 emit widgetValueHasChanged(
this );
4510void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4520 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterField *
>( parameterDefinition() )->parentLayerParameterName() )
4522 setParentLayerWrapperValue( wrapper );
4525 setParentLayerWrapperValue( wrapper );
4542 std::unique_ptr< QgsProcessingContext > tmpContext;
4543 if ( mProcessingContextGenerator )
4544 context = mProcessingContextGenerator->processingContext();
4548 tmpContext = std::make_unique< QgsProcessingContext >();
4549 context = tmpContext.get();
4554 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
4564 bool valueSet =
false;
4568 if ( layers.count() > 1 )
4570 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
4572 const QList< QgsMapLayer * > remainingLayers = layers.mid( 1 );
4578 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer );
4579 if ( !vlayer || !vlayer->
isValid() )
4585 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
4588 fields.
remove( fieldIdx );
4593 mComboBox->setFields( fields );
4595 mPanel->setFields( filterFields( fields ) );
4601 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
4603 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
4607 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
4608 if ( ownedLayer && ownedLayer->type() == Qgis::LayerType::Vector )
4610 mParentLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
4611 layer = mParentLayer.get();
4619 mComboBox->setLayer( layer );
4621 mPanel->setFields( filterFields( layer->
fields() ) );
4631 const QgsFields fields = source->fields();
4633 mComboBox->setFields( fields );
4635 mPanel->setFields( filterFields( fields ) );
4644 mComboBox->setLayer(
nullptr );
4648 if ( value.isValid() && widgetContext().messageBar() )
4651 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent field could not be populated" ),
4652 Qgis::MessageLevel::Info );
4661 val.reserve( mPanel->fields().size() );
4664 setWidgetValue( val, *context );
4667 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
4670void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4674 if ( !value.isValid() )
4675 mComboBox->setField( QString() );
4679 mComboBox->setField( v );
4685 if ( value.isValid() )
4688 opts.reserve( v.size() );
4689 for (
const QString &i : v )
4693 mPanel->setValue( opts );
4695 else if ( mLineEdit )
4701 mLineEdit->setText( v.join(
';' ) );
4710QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
4713 return mComboBox->currentField();
4715 return mPanel->value();
4716 else if ( mLineEdit )
4721 return mLineEdit->text().split(
';' );
4724 return mLineEdit->text();
4730QStringList QgsProcessingFieldWidgetWrapper::compatibleParameterTypes()
const
4732 return QStringList()
4737QStringList QgsProcessingFieldWidgetWrapper::compatibleOutputTypes()
const
4739 return QStringList()
4743QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
4745 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
4748const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
4750 if ( mComboBox && mComboBox->layer() )
4751 return mComboBox->layer();
4756QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
4769 if ( f.isNumeric() )
4774 if ( f.type() == QVariant::String )
4779 if ( f.type() == QVariant::Date || f.type() == QVariant::Time || f.type() == QVariant::DateTime )
4788QString QgsProcessingFieldWidgetWrapper::parameterType()
const
4795 return new QgsProcessingFieldWidgetWrapper( parameter, type );
4800 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4811 QVBoxLayout *vlayout =
new QVBoxLayout();
4812 vlayout->setContentsMargins( 0, 0, 0, 0 );
4814 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4816 mDefaultComboBox =
new QComboBox();
4817 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
4820 for (
const QString &theme : mapThemes )
4824 mDefaultComboBox->setEditable(
true );
4828 if ( themeParam->defaultValueForGui().isValid() )
4831 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
4834 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
4836 vlayout->addWidget( mDefaultComboBox );
4838 setLayout( vlayout );
4841QgsProcessingParameterDefinition *QgsProcessingMapThemeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4843 QVariant defaultVal;
4844 if ( mDefaultComboBox->currentText().isEmpty() )
4845 defaultVal = QVariant();
4847 defaultVal = mDefaultComboBox->currentText();
4848 auto param = std::make_unique< QgsProcessingParameterMapTheme>( name, description, defaultVal );
4850 return param.release();
4860QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
4864 mComboBox =
new QComboBox();
4867 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
4870 for (
const QString &theme : mapThemes )
4882 mComboBox->setEditable(
true );
4886 mComboBox->setToolTip( parameterDefinition()->toolTip() );
4887 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
4889 emit widgetValueHasChanged(
this );
4895void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4899 if ( !value.isValid() )
4900 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
4903 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
4905 const QString prev = mComboBox->currentText();
4906 mComboBox->setCurrentText( v );
4908 emit widgetValueHasChanged(
this );
4911 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
4915QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
4918 return mComboBox->currentData().toInt() == -1 ? QVariant() :
4919 !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
4920 : mComboBox->currentData();
4925QStringList QgsProcessingMapThemeWidgetWrapper::compatibleParameterTypes()
const
4927 return QStringList()
4932QStringList QgsProcessingMapThemeWidgetWrapper::compatibleOutputTypes()
const
4934 return QStringList()
4938QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
4940 return tr(
"map theme as a string value (e.g. 'base maps')" );
4943QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
4950 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
4955 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4968 QVBoxLayout *vlayout =
new QVBoxLayout();
4969 vlayout->setContentsMargins( 0, 0, 0, 0 );
4971 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
4973 mTypeComboBox =
new QComboBox();
4978 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( datetimeParam->dataType() ) );
4980 mTypeComboBox->setCurrentIndex( 0 );
4981 vlayout->addWidget( mTypeComboBox );
4983 setLayout( vlayout );
4986QgsProcessingParameterDefinition *QgsProcessingDateTimeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
4988 auto param = std::make_unique< QgsProcessingParameterDateTime >( name, description );
4991 return param.release();
5001QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5006 switch ( dateTimeParam->
dataType() )
5010 widget = mDateTimeEdit;
5033 widget->setToolTip( parameterDefinition()->toolTip() );
5035 if ( mDateTimeEdit )
5039 emit widgetValueHasChanged(
this );
5042 else if ( mDateEdit )
5046 emit widgetValueHasChanged(
this );
5049 else if ( mTimeEdit )
5053 emit widgetValueHasChanged(
this );
5062 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5065void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5067 if ( mDateTimeEdit )
5071 else if ( mDateEdit )
5075 else if ( mTimeEdit )
5081QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5083 if ( mDateTimeEdit )
5084 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5085 else if ( mDateEdit )
5086 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5087 else if ( mTimeEdit )
5088 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5093QStringList QgsProcessingDateTimeWidgetWrapper::compatibleParameterTypes()
const
5095 return QStringList()
5100QStringList QgsProcessingDateTimeWidgetWrapper::compatibleOutputTypes()
const
5102 return QStringList()
5106QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5109 if ( dateTimeParam )
5111 switch ( dateTimeParam->
dataType() )
5114 return tr(
"datetime value, or a ISO string representation of a datetime" );
5117 return tr(
"date value, or a ISO string representation of a date" );
5120 return tr(
"time value, or a ISO string representation of a time" );
5126QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5133 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5147 QVBoxLayout *vlayout =
new QVBoxLayout();
5148 vlayout->setContentsMargins( 0, 0, 0, 0 );
5150 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5151 mProviderComboBox =
new QComboBox();
5152 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), QStringLiteral(
"postgres" ) );
5153 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), QStringLiteral(
"ogr" ) );
5154 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), QStringLiteral(
"spatialite" ) );
5156 vlayout->addWidget( mProviderComboBox );
5158 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5160 mDefaultEdit =
new QLineEdit();
5161 vlayout->addWidget( mDefaultEdit );
5162 setLayout( vlayout );
5164 if ( connectionParam )
5166 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5171QgsProcessingParameterDefinition *QgsProcessingProviderConnectionParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5173 QVariant defaultVal;
5174 if ( mDefaultEdit->text().isEmpty() )
5175 defaultVal = QVariant();
5177 defaultVal = mDefaultEdit->text();
5178 auto param = std::make_unique< QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5180 return param.release();
5190QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5196 mProviderComboBox->setAllowEmptyConnection(
true );
5204 mProviderComboBox->setEditable(
true );
5208 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5209 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [ = ](
const QString & )
5211 if ( mBlockSignals )
5214 emit widgetValueHasChanged(
this );
5217 return mProviderComboBox;
5222 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5225void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5229 if ( !value.isValid() )
5230 mProviderComboBox->setCurrentIndex( -1 );
5233 if ( mProviderComboBox->isEditable() )
5235 const QString prev = mProviderComboBox->currentText();
5237 mProviderComboBox->setConnection( v );
5238 mProviderComboBox->setCurrentText( v );
5242 emit widgetValueHasChanged(
this );
5245 mProviderComboBox->setConnection( v );
5249QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5251 if ( mProviderComboBox )
5252 if ( mProviderComboBox->isEditable() )
5253 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5255 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5260QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleParameterTypes()
const
5262 return QStringList()
5268QStringList QgsProcessingProviderConnectionWidgetWrapper::compatibleOutputTypes()
const
5270 return QStringList()
5274QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5276 return tr(
"connection name as a string value" );
5279QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5286 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5301 QVBoxLayout *vlayout =
new QVBoxLayout();
5302 vlayout->setContentsMargins( 0, 0, 0, 0 );
5304 mConnectionParamComboBox =
new QComboBox();
5305 QString initialConnection;
5311 if (
auto *lModel = widgetContext.
model() )
5314 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5315 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5317 if ( definition && it->parameterName() == definition->
name() )
5323 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5324 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5326 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5331 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5334 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5335 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5338 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5339 vlayout->addWidget( mConnectionParamComboBox );
5341 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5343 mDefaultEdit =
new QLineEdit();
5344 vlayout->addWidget( mDefaultEdit );
5345 setLayout( vlayout );
5353QgsProcessingParameterDefinition *QgsProcessingDatabaseSchemaParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5355 QVariant defaultVal;
5356 if ( mDefaultEdit->text().isEmpty() )
5357 defaultVal = QVariant();
5359 defaultVal = mDefaultEdit->text();
5360 auto param = std::make_unique< QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5362 return param.release();
5372QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5378 mSchemaComboBox->setAllowEmptySchema(
true );
5386 mSchemaComboBox->comboBox()->setEditable(
true );
5390 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5391 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
5393 if ( mBlockSignals )
5396 emit widgetValueHasChanged( this );
5399 return mSchemaComboBox;
5404 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5411 std::unique_ptr< QgsProcessingContext > tmpContext;
5412 if ( mProcessingContextGenerator )
5413 context = mProcessingContextGenerator->processingContext();
5417 tmpContext = std::make_unique< QgsProcessingContext >();
5418 context = tmpContext.get();
5424 if ( mSchemaComboBox )
5425 mSchemaComboBox->setConnectionName( connection, qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId() );
5429 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5432void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5436 if ( !value.isValid() )
5437 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5440 if ( mSchemaComboBox->comboBox()->isEditable() )
5442 const QString prev = mSchemaComboBox->comboBox()->currentText();
5444 mSchemaComboBox->setSchema( v );
5445 mSchemaComboBox->comboBox()->setCurrentText( v );
5449 emit widgetValueHasChanged(
this );
5452 mSchemaComboBox->setSchema( v );
5456QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5458 if ( mSchemaComboBox )
5459 if ( mSchemaComboBox->comboBox()->isEditable() )
5460 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5462 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5467QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleParameterTypes()
const
5469 return QStringList()
5475QStringList QgsProcessingDatabaseSchemaWidgetWrapper::compatibleOutputTypes()
const
5477 return QStringList()
5481QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5483 return tr(
"database schema name as a string value" );
5486QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5493 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5496void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5508 setParentConnectionWrapperValue( wrapper );
5511 setParentConnectionWrapperValue( wrapper );
5535 QVBoxLayout *vlayout =
new QVBoxLayout();
5536 vlayout->setContentsMargins( 0, 0, 0, 0 );
5538 mConnectionParamComboBox =
new QComboBox();
5539 mSchemaParamComboBox =
new QComboBox();
5540 QString initialConnection;
5541 QString initialSchema;
5548 if (
auto *lModel = widgetContext.
model() )
5551 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5552 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5554 if ( definition && it->parameterName() == definition->
name() )
5559 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5560 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5562 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5567 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
5568 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5570 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5576 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5579 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5580 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5583 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
5586 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
5587 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
5590 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5591 vlayout->addWidget( mConnectionParamComboBox );
5593 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
5594 vlayout->addWidget( mSchemaParamComboBox );
5596 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5598 mDefaultEdit =
new QLineEdit();
5599 vlayout->addWidget( mDefaultEdit );
5600 setLayout( vlayout );
5608QgsProcessingParameterDefinition *QgsProcessingDatabaseTableParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5610 QVariant defaultVal;
5611 if ( mDefaultEdit->text().isEmpty() )
5612 defaultVal = QVariant();
5614 defaultVal = mDefaultEdit->text();
5615 auto param = std::make_unique< QgsProcessingParameterDatabaseTable>( name, description,
5616 mConnectionParamComboBox->currentData().toString(),
5617 mSchemaParamComboBox->currentData().toString(),
5620 return param.release();
5630QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
5636 mTableComboBox->setAllowEmptyTable(
true );
5639 mTableComboBox->comboBox()->setEditable(
true );
5641 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
5642 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [ = ](
const QString & )
5644 if ( mBlockSignals )
5647 emit widgetValueHasChanged( this );
5650 return mTableComboBox;
5655 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5662 std::unique_ptr< QgsProcessingContext > tmpContext;
5663 if ( mProcessingContextGenerator )
5664 context = mProcessingContextGenerator->processingContext();
5668 tmpContext = std::make_unique< QgsProcessingContext >();
5669 context = tmpContext.get();
5674 mProvider = qgis::down_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->
parameterDefinition() )->providerId();
5675 if ( mTableComboBox && !mSchema.isEmpty() )
5677 mTableComboBox->setSchema( mSchema );
5678 mTableComboBox->setConnectionName( mConnection, mProvider );
5682 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5690 std::unique_ptr< QgsProcessingContext > tmpContext;
5691 if ( mProcessingContextGenerator )
5692 context = mProcessingContextGenerator->processingContext();
5696 tmpContext = std::make_unique< QgsProcessingContext >();
5697 context = tmpContext.get();
5703 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
5705 mTableComboBox->setSchema( mSchema );
5706 mTableComboBox->setConnectionName( mConnection, mProvider );
5710 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5715void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5719 if ( !value.isValid() )
5720 mTableComboBox->comboBox()->setCurrentIndex( -1 );
5723 if ( mTableComboBox->comboBox()->isEditable() )
5725 const QString prev = mTableComboBox->comboBox()->currentText();
5727 mTableComboBox->setTable( v );
5728 mTableComboBox->comboBox()->setCurrentText( v );
5732 emit widgetValueHasChanged(
this );
5735 mTableComboBox->setTable( v );
5739QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
5741 if ( mTableComboBox )
5742 if ( mTableComboBox->comboBox()->isEditable() )
5743 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
5745 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
5750QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleParameterTypes()
const
5752 return QStringList()
5758QStringList QgsProcessingDatabaseTableWidgetWrapper::compatibleOutputTypes()
const
5760 return QStringList()
5764QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
5766 return tr(
"database table name as a string value" );
5769QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
5776 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
5779void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5791 setParentConnectionWrapperValue( wrapper );
5794 setParentConnectionWrapperValue( wrapper );
5799 setParentSchemaWrapperValue( wrapper );
5802 setParentSchemaWrapperValue( wrapper );
5822 QVBoxLayout *vlayout =
new QVBoxLayout();
5823 vlayout->setContentsMargins( 0, 0, 0, 0 );
5825 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5828 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
5831 if ( extentParam->defaultValueForGui().isValid() )
5835 mDefaultWidget->setCurrentExtent( rect,
crs );
5836 mDefaultWidget->setOutputExtentFromCurrent();
5840 mDefaultWidget->clear();
5844 vlayout->addWidget( mDefaultWidget );
5845 setLayout( vlayout );
5848QgsProcessingParameterDefinition *QgsProcessingExtentParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
5850 const QString defaultVal = mDefaultWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
5851 QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ),
5852 QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ),
5853 QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ),
5854 QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ),
5855 mDefaultWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mDefaultWidget->outputCrs().authid() ) : QString()
5857 auto param = std::make_unique< QgsProcessingParameterExtent >( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
5859 return param.release();
5870QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
5880 if ( widgetContext().mapCanvas() )
5881 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
5884 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
5886 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
5890 emit widgetValueHasChanged(
this );
5894 setDialog( mDialog );
5896 return mExtentWidget;
5906 mExtentWidget->setMapCanvas( context.
mapCanvas() );
5909void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
5917 mDialog->showMinimized();
5920 mDialog->showNormal();
5922 mDialog->activateWindow();
5929void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5931 if ( mExtentWidget )
5933 if ( !value.isValid() || ( value.type() == QVariant::String && value.toString().isEmpty() ) )
5934 mExtentWidget->clear();
5939 mExtentWidget->setCurrentExtent( r,
crs );
5940 mExtentWidget->setOutputExtentFromUser( r,
crs );
5945QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
5947 if ( mExtentWidget )
5949 const QString val = mExtentWidget->isValid() ? QStringLiteral(
"%1,%2,%3,%4%5" ).arg(
5950 QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ),
5951 QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ),
5952 QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ),
5953 QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ),
5954 mExtentWidget->outputCrs().isValid() ? QStringLiteral(
" [%1]" ).arg( mExtentWidget->outputCrs().authid() ) : QString()
5957 return val.isEmpty() ? QVariant() : QVariant( val );
5963QStringList QgsProcessingExtentWidgetWrapper::compatibleParameterTypes()
const
5965 return QStringList()
5977QStringList QgsProcessingExtentWidgetWrapper::compatibleOutputTypes()
const
5979 return QStringList()
5986QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
5988 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
5991QString QgsProcessingExtentWidgetWrapper::parameterType()
const
5998 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6003 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6015 QVBoxLayout *vlayout =
new QVBoxLayout();
6016 vlayout->setContentsMargins( 0, 0, 0, 0 );
6018 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6033 for (
int i : layerParam->dataTypes() )
6035 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6039 vlayout->addWidget( mLayerTypeComboBox );
6041 setLayout( vlayout );
6044QgsProcessingParameterDefinition *QgsProcessingMapLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6046 QList< int > dataTypes;
6047 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6048 dataTypes << v.toInt();
6050 auto param = std::make_unique< QgsProcessingParameterMapLayer >( name, description );
6051 param->setDataTypes( dataTypes );
6053 return param.release();
6062QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6064 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6072 mComboBox->setEditable(
true );
6076 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6078 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [ = ]()
6080 if ( mBlockSignals )
6083 emit widgetValueHasChanged(
this );
6086 setWidgetContext( widgetContext() );
6095 mComboBox->setWidgetContext( context );
6100 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6106void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6109 mComboBox->setValue( value, context );
6112QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6114 return mComboBox ? mComboBox->value() : QVariant();
6117QStringList QgsProcessingMapLayerWidgetWrapper::compatibleParameterTypes()
const
6119 return QStringList()
6130QStringList QgsProcessingMapLayerWidgetWrapper::compatibleOutputTypes()
const
6132 return QStringList()
6140QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6142 return tr(
"path to a map layer" );
6147 return QgsProcessingModelChildParameterSource::ModelParameter;
6150QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6157 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6162 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6171 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6176QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleParameterTypes()
const
6178 return QStringList()
6185QStringList QgsProcessingRasterLayerWidgetWrapper::compatibleOutputTypes()
const
6187 return QStringList()
6195QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6197 return tr(
"path to a raster layer" );
6200QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6207 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6212 Q_UNUSED( context );
6213 Q_UNUSED( widgetContext );
6214 Q_UNUSED( definition );
6228 QVBoxLayout *vlayout =
new QVBoxLayout();
6229 vlayout->setContentsMargins( 0, 0, 0, 0 );
6231 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6241 for (
int i : vectorParam->dataTypes() )
6243 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6247 vlayout->addWidget( mGeometryTypeComboBox );
6249 setLayout( vlayout );
6252QgsProcessingParameterDefinition *QgsProcessingVectorLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6254 QList< int > dataTypes;
6255 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6256 dataTypes << v.toInt();
6258 auto param = std::make_unique< QgsProcessingParameterVectorLayer >( name, description, dataTypes );
6260 return param.release();
6265 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6270QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleParameterTypes()
const
6272 return QStringList()
6279QStringList QgsProcessingVectorLayerWidgetWrapper::compatibleOutputTypes()
const
6281 return QStringList()
6289QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6291 return tr(
"path to a vector layer" );
6297 return param->dataTypes();
6299 return QList< int >();
6302QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6309 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6314 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6326 QVBoxLayout *vlayout =
new QVBoxLayout();
6327 vlayout->setContentsMargins( 0, 0, 0, 0 );
6329 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6339 for (
int i : sourceParam->dataTypes() )
6341 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6349 vlayout->addWidget( mGeometryTypeComboBox );
6351 setLayout( vlayout );
6354QgsProcessingParameterDefinition *QgsProcessingFeatureSourceParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6356 QList< int > dataTypes;
6357 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6358 dataTypes << v.toInt();
6360 auto param = std::make_unique< QgsProcessingParameterFeatureSource >( name, description, dataTypes );
6362 return param.release();
6366 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6371QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleParameterTypes()
const
6373 return QStringList()
6381QStringList QgsProcessingFeatureSourceWidgetWrapper::compatibleOutputTypes()
const
6383 return QStringList()
6391QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6393 return tr(
"path to a vector layer" );
6399 return param->dataTypes();
6401 return QList< int >();
6404QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6411 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6416 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6424 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6429QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleParameterTypes()
const
6431 return QStringList()
6438QStringList QgsProcessingMeshLayerWidgetWrapper::compatibleOutputTypes()
const
6440 return QStringList()
6448QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6450 return tr(
"path to a mesh layer" );
6453QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6460 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6465 Q_UNUSED( context );
6466 Q_UNUSED( widgetContext );
6467 Q_UNUSED( definition );
6479QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6483 QHBoxLayout *hl =
new QHBoxLayout();
6484 hl->setContentsMargins( 0, 0, 0, 0 );
6486 mLineEdit =
new QLineEdit();
6487 mLineEdit->setEnabled(
false );
6488 hl->addWidget( mLineEdit, 1 );
6490 mToolButton =
new QToolButton();
6491 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6492 hl->addWidget( mToolButton );
6498 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6501 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6504void QgsProcessingRasterBandPanelWidget::setBands(
const QList< int > &bands )
6509void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6514void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6516 if ( value.isValid() )
6517 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
6521 updateSummaryText();
6525void QgsProcessingRasterBandPanelWidget::showDialog()
6527 QVariantList availableOptions;
6528 availableOptions.reserve( mBands.size() );
6529 for (
int band : std::as_const( mBands ) )
6531 availableOptions << band;
6537 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6538 widget->setPanelTitle( mParam->description() );
6540 widget->setValueFormatter( [
this](
const QVariant & v ) -> QString
6542 int band = v.toInt();
6543 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6546 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
6548 setValue( widget->selectedOptions() );
6555 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6557 dlg.setValueFormatter( [
this](
const QVariant & v ) -> QString
6559 int band = v.toInt();
6560 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6564 setValue( dlg.selectedOptions() );
6569void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6572 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6584 QVBoxLayout *vlayout =
new QVBoxLayout();
6585 vlayout->setContentsMargins( 0, 0, 0, 0 );
6587 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6589 mDefaultLineEdit =
new QLineEdit();
6590 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6595 for (
int b : bands )
6597 defVal << QString::number( b );
6600 mDefaultLineEdit->setText( defVal.join(
';' ) );
6602 vlayout->addWidget( mDefaultLineEdit );
6604 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6605 mParentLayerComboBox =
new QComboBox();
6607 QString initialParent;
6609 initialParent = bandParam->parentLayerParameterName();
6611 if (
auto *lModel = widgetContext.
model() )
6614 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6615 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6619 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
6620 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6622 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6628 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6631 mParentLayerComboBox->addItem( initialParent, initialParent );
6632 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6635 vlayout->addWidget( mParentLayerComboBox );
6637 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6639 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6641 vlayout->addWidget( mAllowMultipleCheckBox );
6642 setLayout( vlayout );
6645QgsProcessingParameterDefinition *QgsProcessingBandParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
6647 auto param = std::make_unique< QgsProcessingParameterBand >( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6649 return param.release();
6658QWidget *QgsProcessingBandWidgetWrapper::createWidget()
6668 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
6669 mPanel->setToolTip( parameterDefinition()->toolTip() );
6670 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [ = ]
6672 emit widgetValueHasChanged(
this );
6681 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6684 emit widgetValueHasChanged(
this );
6692 mLineEdit =
new QLineEdit();
6693 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6694 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
6696 emit widgetValueHasChanged(
this );
6705void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6715 if ( wrapper->parameterDefinition()->name() ==
static_cast< const QgsProcessingParameterBand *
>( parameterDefinition() )->parentLayerParameterName() )
6717 setParentLayerWrapperValue( wrapper );
6720 setParentLayerWrapperValue( wrapper );
6737 std::unique_ptr< QgsProcessingContext > tmpContext;
6738 if ( mProcessingContextGenerator )
6739 context = mProcessingContextGenerator->processingContext();
6743 tmpContext = std::make_unique< QgsProcessingContext >();
6744 context = tmpContext.get();
6750 if ( layer && layer->
isValid() )
6754 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
6755 if ( ownedLayer && ownedLayer->type() == Qgis::LayerType::Raster )
6757 mParentLayer.reset( qobject_cast< QgsRasterLayer * >( ownedLayer.release() ) );
6758 layer = mParentLayer.get();
6766 mComboBox->setLayer( layer );
6770 if ( provider && layer->
isValid() )
6775 QHash< int, QString > bandNames;
6776 for (
int i = 1; i <= nBands; ++i )
6781 mPanel->setBands( bands );
6782 mPanel->setBandNames( bandNames );
6789 mComboBox->setLayer(
nullptr );
6791 mPanel->setBands( QList< int >() );
6793 if ( value.isValid() && widgetContext().messageBar() )
6796 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent bands could not be populated" ),
6797 Qgis::MessageLevel::Info );
6801 if ( parameterDefinition()->defaultValueForGui().isValid() )
6802 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6805void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6809 if ( !value.isValid() )
6810 mComboBox->setBand( -1 );
6814 mComboBox->setBand( v );
6820 if ( value.isValid() )
6823 opts.reserve( v.size() );
6828 mPanel->setValue( value.isValid() ? opts : QVariant() );
6830 else if ( mLineEdit )
6837 opts.reserve( v.size() );
6839 opts << QString::number( i );
6840 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
6844 if ( value.isValid() )
6852QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
6855 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
6857 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
6858 else if ( mLineEdit )
6863#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
6864 const QStringList parts = mLineEdit->text().split(
';', QString::SkipEmptyParts );
6866 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
6869 res.reserve( parts.count() );
6870 for (
const QString &s : parts )
6873 int band = s.toInt( &ok );
6877 return res.
isEmpty() ? QVariant() : res;
6881 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
6888QStringList QgsProcessingBandWidgetWrapper::compatibleParameterTypes()
const
6890 return QStringList()
6895QStringList QgsProcessingBandWidgetWrapper::compatibleOutputTypes()
const
6897 return QStringList()
6901QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
6903 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
6906QString QgsProcessingBandWidgetWrapper::parameterType()
const
6913 return new QgsProcessingBandWidgetWrapper( parameter, type );
6918 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6931 QHBoxLayout *hl =
new QHBoxLayout();
6932 hl->setContentsMargins( 0, 0, 0, 0 );
6934 mLineEdit =
new QLineEdit();
6935 mLineEdit->setEnabled(
false );
6936 hl->addWidget( mLineEdit, 1 );
6938 mToolButton =
new QToolButton();
6939 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6940 hl->addWidget( mToolButton );
6946 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
6949 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
6952void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
6954 if ( value.isValid() )
6955 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
6959 updateSummaryText();
6963void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
6970 if ( mValue.removeAll( layerId ) )
6972 updateSummaryText();
6979void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
6985 switch ( mParam->layerType() )
7143void QgsProcessingMultipleLayerPanelWidget::showDialog()
7148 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel );
7149 widget->setPanelTitle( mParam->description() );
7150 widget->setProject( mProject );
7151 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
7153 setValue( widget->selectedOptions() );
7160 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7161 dlg.setProject( mProject );
7164 setValue( dlg.selectedOptions() );
7169void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7172 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7182 QVBoxLayout *vlayout =
new QVBoxLayout();
7183 vlayout->setContentsMargins( 0, 0, 0, 0 );
7185 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7186 mLayerTypeComboBox =
new QComboBox();
7200 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData( layersParam->layerType() ) );
7202 vlayout->addWidget( mLayerTypeComboBox );
7203 setLayout( vlayout );
7206QgsProcessingParameterDefinition *QgsProcessingMultipleLayerParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
7208 auto param = std::make_unique< QgsProcessingParameterMultipleLayers >( name, description,
static_cast< QgsProcessing::SourceType >( mLayerTypeComboBox->currentData().toInt() ) );
7210 return param.release();
7219QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7223 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7224 mPanel->setToolTip( parameterDefinition()->toolTip() );
7225 mPanel->setProject( widgetContext().project() );
7227 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7228 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [ = ]
7230 emit widgetValueHasChanged(
this );
7240 mPanel->setProject( context.
project() );
7242 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7246void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7251 if ( value.isValid() )
7254 opts.reserve( v.size() );
7256 opts << l->source();
7259 for (
const QVariant &v : value.toList() )
7261 if ( v.userType() == QMetaType::type(
"QgsProcessingModelChildParameterSource" ) )
7263 const QgsProcessingModelChildParameterSource source = v.value< QgsProcessingModelChildParameterSource >();
7264 opts << QVariant::fromValue( source );
7269 mPanel->setValue( value.isValid() ? opts : QVariant() );
7273QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7276 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7281QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleParameterTypes()
const
7283 return QStringList()
7294QStringList QgsProcessingMultipleLayerWidgetWrapper::compatibleOutputTypes()
const
7296 return QStringList()
7305QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7307 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7310QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7317 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7322 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7331 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7336QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleParameterTypes()
const
7338 return QStringList()
7345QStringList QgsProcessingPointCloudLayerWidgetWrapper::compatibleOutputTypes()
const
7347 return QStringList()
7355QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7357 return tr(
"path to a point cloud layer" );
7360QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7367 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7372 Q_UNUSED( context );
7373 Q_UNUSED( widgetContext );
7374 Q_UNUSED( definition );
7391QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleParameterTypes()
const
7393 return QStringList()
7400QStringList QgsProcessingAnnotationLayerWidgetWrapper::compatibleOutputTypes()
const
7402 return QStringList()
7407QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7409 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7412QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7419 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7424 Q_UNUSED( context );
7425 Q_UNUSED( widgetContext );
7426 Q_UNUSED( definition );
7437 if ( mWidgetContext.project() )
7438 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7442QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7453 mComboBox->setEditable(
true );
7457 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7459 if ( mWidgetContext.project() )
7460 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7463 mComboBox->setAllowEmptyLayer(
true );
7467 if ( mBlockSignals )
7470 emit widgetValueHasChanged(
this );
7473 setWidgetContext( widgetContext() );
7477void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7483 mComboBox->setLayer(
nullptr );
7487 QVariant val = value;
7488 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
7500 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( val.value< QObject * >() );
7501 if ( !layer && val.type() == QVariant::String )
7508 mComboBox->setLayer( layer );
7513QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7515 return mComboBox && mComboBox->currentLayer() ?
7516 ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? QStringLiteral(
"main" ) : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
7529 QHBoxLayout *hl =
new QHBoxLayout();
7530 hl->setContentsMargins( 0, 0, 0, 0 );
7532 mLineEdit =
new QLineEdit();
7533 mLineEdit->setEnabled(
false );
7534 hl->addWidget( mLineEdit, 1 );
7536 mToolButton =
new QToolButton();
7537 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7538 hl->addWidget( mToolButton );
7544 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7547 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7552 mAttributes = attributes;
7555void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7557 if ( value.isValid() )
7558 mValue = value.type() == QVariant::List ? value.toList() : QVariantList() << value;
7562 updateSummaryText();
7566void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7568 QVariantList availableOptions;
7569 availableOptions.reserve( mAttributes.count() );
7570 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7573 availableOptions << attr.name();
7579 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7580 widget->setPanelTitle( mParam->description() );
7582 widget->setValueFormatter( [](
const QVariant & v ) -> QString
7584 return v.toString();
7587 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [ = ]()
7589 setValue( widget->selectedOptions() );
7596 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7598 dlg.setValueFormatter( [](
const QVariant & v ) -> QString
7600 return v.toString();
7604 setValue( dlg.selectedOptions() );
7609void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7614 if ( mValue.empty() )
7616 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7621 values.reserve( mValue.size() );
7622 for (
const QVariant &val : std::as_const( mValue ) )
7624 values << val.toString();
7627 const QString concatenated = values.join( tr(
"," ) );
7628 if ( concatenated.length() < 100 )
7629 mLineEdit->setText( concatenated );
7631 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7643 QVBoxLayout *vlayout =
new QVBoxLayout();
7644 vlayout->setContentsMargins( 0, 0, 0, 0 );
7646 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7647 mParentLayerComboBox =
new QComboBox();
7649 QString initialParent;
7651 initialParent = attrParam->parentLayerParameterName();
7653 if (
auto *lModel = widgetContext.
model() )
7656 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7657 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7661 mParentLayerComboBox-> addItem( definition->
description(), definition->
name() );
7662 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7664 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7670 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7673 mParentLayerComboBox->addItem( initialParent, initialParent );
7674 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7677 vlayout->addWidget( mParentLayerComboBox );
7679 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
7681 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
7683 vlayout->addWidget( mAllowMultipleCheckBox );
7685 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
7686 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7688 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
7690 vlayout->addWidget( mDefaultToAllCheckBox );
7692 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [ = ]
7694 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7697 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7699 mDefaultLineEdit =
new QLineEdit();
7700 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
7704 mDefaultLineEdit->setText( attributes.join(
';' ) );
7706 vlayout->addWidget( mDefaultLineEdit );
7708 setLayout( vlayout );
7711QgsProcessingParameterDefinition *QgsProcessingPointCloudAttributeParameterDefinitionWidget::createParameter(
const QString &name,
const QString &description, QgsProcessingParameterDefinition::Flags flags )
const
7713 QVariant defaultValue;
7714 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
7716 defaultValue = mDefaultLineEdit->text();
7718 auto param = std::make_unique< QgsProcessingParameterPointCloudAttribute >( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
7720 return param.release();
7728QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
7738 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
7739 mPanel->setToolTip( parameterDefinition()->toolTip() );
7740 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [ = ]
7742 emit widgetValueHasChanged(
this );
7750 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7753 emit widgetValueHasChanged(
this );
7761 mLineEdit =
new QLineEdit();
7762 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
7763 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ]
7765 emit widgetValueHasChanged(
this );
7774void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7786 setParentLayerWrapperValue( wrapper );
7789 setParentLayerWrapperValue( wrapper );
7806 std::unique_ptr< QgsProcessingContext > tmpContext;
7807 if ( mProcessingContextGenerator )
7808 context = mProcessingContextGenerator->processingContext();
7812 tmpContext = std::make_unique< QgsProcessingContext >();
7813 context = tmpContext.get();
7819 if ( layer && layer->
isValid() )
7823 std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
7824 if ( ownedLayer && ownedLayer->type() == Qgis::LayerType::PointCloud )
7826 mParentLayer.reset( qobject_cast< QgsPointCloudLayer * >( ownedLayer.release() ) );
7827 layer = mParentLayer.get();
7835 mComboBox->setLayer( layer );
7838 mPanel->setAttributes( layer->
attributes() );
7845 mComboBox->setLayer(
nullptr );
7850 if ( value.isValid() && widgetContext().messageBar() )
7853 widgetContext().
messageBar()->
pushMessage( QString(), QObject::tr(
"Could not load selected layer/table. Dependent attributes could not be populated" ),
7854 Qgis::MessageLevel::Info );
7862 val.reserve( mPanel->attributes().attributes().size() );
7865 setWidgetValue( val, *context );
7868 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7871void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7875 if ( !value.isValid() )
7876 mComboBox->setAttribute( QString() );
7880 mComboBox->setAttribute( v );
7886 if ( value.isValid() )
7889 opts.reserve( v.size() );
7890 for (
const QString &i : v )
7894 mPanel->setValue( opts );
7896 else if ( mLineEdit )
7902 mLineEdit->setText( v.join(
';' ) );
7911QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
7914 return mComboBox->currentAttribute();
7916 return mPanel->value();
7917 else if ( mLineEdit )
7922 return mLineEdit->text().split(
';' );
7925 return mLineEdit->text();
7931QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleParameterTypes()
const
7933 return QStringList()
7938QStringList QgsProcessingPointCloudAttributeWidgetWrapper::compatibleOutputTypes()
const
7940 return QStringList()
7944QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
7946 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
7949QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
7956 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
7961 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7975QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
7983 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
7984 if ( mProcessingContextGenerator )
7985 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
7986 if ( mParametersGenerator )
7987 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
7988 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
7990 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [ = ]()
7992 if ( mBlockSignals )
7995 emit widgetValueHasChanged(
this );
8004 mOutputWidget->addOpenAfterRunningOption();
8006 return mOutputWidget;
8016void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8018 if ( mOutputWidget )
8019 mOutputWidget->setValue( value );
8022QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8024 if ( mOutputWidget )
8025 return mOutputWidget->value();
8030QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8033 if ( mOutputWidget )
8034 res.insert( QStringLiteral(
"OPEN_AFTER_RUNNING" ), mOutputWidget->openAfterRunning() );
8038QStringList QgsProcessingOutputWidgetWrapper::compatibleParameterTypes()
const
8040 return QStringList()
8049QStringList QgsProcessingOutputWidgetWrapper::compatibleOutputTypes()
const
8051 return QStringList()
8062 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8067QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8074 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8077QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8079 return tr(
"path to layer destination" );
8087 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8092QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8099 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8102QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8104 return tr(
"path to layer destination" );
8112 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8117QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8124 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8127QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8129 return tr(
"path to layer destination" );
8137 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8142QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8149 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8152QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8154 return tr(
"path to layer destination" );
8162 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8167QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8174 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8177QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8179 return tr(
"path to file destination" );
8187 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8192QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8199 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8202QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8204 return tr(
"path to folder destination" );
8212 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8216QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8223 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8226QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8228 return tr(
"path to layer destination" );
@ Standard
Unit is a standard measurement unit.
ExpressionType
Expression types.
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
DistanceUnit
Units of distance.
@ Inches
Inches (since QGIS 3.32)
TemporalUnit
Temporal units.
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.
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.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Q_GADGET Qgis::DistanceUnit mapUnits
The QgsDatabaseSchemaComboBox class is a combo box which displays the list of schemas for a specific ...
The QgsDatabaseTableComboBox class is a combo box which displays the list of tables for a specific da...
The QgsDateEdit class is a QDateEdit widget with the capability of setting/reading null dates.
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
The QgsDateTimeEdit class is 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.
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
@ DateTime
Datetime fieldss.
@ Date
Date or datetime fields.
@ Numeric
All numeric fields.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
void remove(int fieldIdx)
Removes the field with the given index.
int count() const
Returns number of items.
bool isEmpty() const
Checks whether the container is empty.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
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.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
The QgsLayoutComboBox class is a combo box which displays available layouts from a QgsLayoutManager.
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
The QgsLayoutItemComboBox class is 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.
The QgsMapLayerComboBox class is a combo box which displays the list of layers.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
@ AnnotationLayer
QgsAnnotationLayer.
Base class for all map layer types.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
A QgsMapMouseEvent is the result of a user interaction with the mouse on 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.
Collection of point cloud attributes.
The QgsPointCloudAttributeComboBox is a combo box which displays the list of attributes of a given po...
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.
A class to represent a 2D point.
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.
WidgetType
Types of dialogs which Processing widgets can be created for.
@ Standard
Standard algorithm dialog.
@ Batch
Batch processing dialog.
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 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.
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, for selection between available coordinat...
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, allowing users to select from existing dat...
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.
@ DateTime
Datetime values.
static QString typeName()
Returns the type name for the parameter class.
Type dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
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.
@ FlagOptional
Parameter is optional.
virtual QString type() const =0
Unique parameter type name.
Flags flags() const
Returns any flags associated with the parameter.
QString name() const
Returns the name of the parameter.
void setFlags(Flags flags)
Sets the 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.
void setDataType(DataType type)
Sets 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.
DataType
Field data types.
@ DateTime
Accepts datetime fields.
@ Numeric
Accepts numeric fields.
@ String
Accepts string fields.
DataType dataType() const
Returns 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.
Behavior
Parameter behavior.
@ Folder
Parameter is a folder.
@ File
Parameter is a single file.
Behavior behavior() const
Returns the parameter behavior (e.g.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
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
Double/float values.
double maximum() const
Returns the maximum value acceptable by the parameter.
Type 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.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A raster layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool multiLine() const
Returns true if the parameter allows multiline strings.
static QString typeName()
Returns the type name for the parameter class.
A vector layer (with or without geometry) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
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.
@ 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.
SourceType
Data source types enum.
@ TypePlugin
Plugin layers.
@ TypeVectorLine
Vector line layers.
@ TypeMapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ TypeVectorPolygon
Vector polygon layers.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
@ TypeAnnotation
Annotation layers.
@ TypePointCloud
Point cloud layers.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ TypeRaster
Raster layers.
@ TypeVectorTile
Vector tile layers.
@ TypeVectorPoint
Vector point layers.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
@ 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.
@ StaticProperty
Static property (QgsStaticProperty)
Type propertyType() const
Returns the property type.
The QgsProviderConnectionComboBox class is a combo box which displays the list of connections registe...
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.
This class is a composition of two QSettings instances:
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Class that shows snapping marker on map canvas for the current snapping match.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
The QgsTimeEdit class is 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 data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const QgsCoordinateReferenceSystem & crs