76#include <QButtonGroup>
84#include <QPlainTextEdit>
85#include <QRadioButton>
90#include "moc_qgsprocessingwidgetwrapperimpl.cpp"
92using namespace Qt::StringLiterals;
104 QVBoxLayout *vlayout =
new QVBoxLayout();
105 vlayout->setContentsMargins( 0, 0, 0, 0 );
107 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
111 mDefaultCheckBox->setChecked(
false );
112 vlayout->addWidget( mDefaultCheckBox );
115 setLayout( vlayout );
120 auto param = std::make_unique<QgsProcessingParameterBoolean>( name, description, mDefaultCheckBox->isChecked() );
121 param->setFlags( flags );
122 return param.release();
131QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
137 QString description = parameterDefinition()->description();
139 description = QObject::tr(
"%1 [optional]" ).arg( description );
141 mCheckBox =
new QCheckBox( description );
142 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
144 connect( mCheckBox, &QCheckBox::toggled,
this, [
this] {
145 emit widgetValueHasChanged(
this );
153 mComboBox =
new QComboBox();
154 mComboBox->addItem( tr(
"Yes" ),
true );
155 mComboBox->addItem( tr(
"No" ),
false );
156 mComboBox->setToolTip( parameterDefinition()->toolTip() );
158 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
159 emit widgetValueHasChanged(
this );
168QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
177void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
184 mCheckBox->setChecked( v );
192 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
198QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
203 return mCheckBox->isChecked();
207 return mComboBox->currentData();
212QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
219 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
224 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
235 QVBoxLayout *vlayout =
new QVBoxLayout();
236 vlayout->setContentsMargins( 0, 0, 0, 0 );
238 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
243 mCrsSelector->setShowAccuracyWarnings(
true );
250 vlayout->addWidget( mCrsSelector );
251 setLayout( vlayout );
256 auto param = std::make_unique<QgsProcessingParameterCrs>( name, description, mCrsSelector->crs().authid() );
257 param->setFlags( flags );
258 return param.release();
266QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
268 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
270 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
278 emit widgetValueHasChanged(
this );
286 return mProjectionSelectionWidget;
291 QWidget *w =
new QWidget();
292 w->setToolTip( parameterDefinition()->toolTip() );
294 QVBoxLayout *vl =
new QVBoxLayout();
295 vl->setContentsMargins( 0, 0, 0, 0 );
298 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
299 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
300 vl->addWidget( mUseProjectCrsCheckBox );
301 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
302 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [
this] {
303 emit widgetValueHasChanged(
this );
306 vl->addWidget( mProjectionSelectionWidget );
314void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
316 if ( mUseProjectCrsCheckBox )
318 if ( value.toString().compare(
"ProjectCrs"_L1, Qt::CaseInsensitive ) == 0 )
320 mUseProjectCrsCheckBox->setChecked(
true );
325 mUseProjectCrsCheckBox->setChecked(
false );
330 if ( mProjectionSelectionWidget )
331 mProjectionSelectionWidget->setCrs( v );
334QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
336 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
337 return u
"ProjectCrs"_s;
338 else if ( mProjectionSelectionWidget )
339 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
344QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
346 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
349QString QgsProcessingCrsWidgetWrapper::parameterType()
const
356 return new QgsProcessingCrsWidgetWrapper( parameter, type );
361 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
373 QVBoxLayout *vlayout =
new QVBoxLayout();
374 vlayout->setContentsMargins( 0, 0, 0, 0 );
376 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
378 mDefaultLineEdit =
new QLineEdit();
381 vlayout->addWidget( mDefaultLineEdit );
385 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
387 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
388 vlayout->addWidget( mMultiLineCheckBox );
392 setLayout( vlayout );
397 auto param = std::make_unique<QgsProcessingParameterString>( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
398 param->setFlags( flags );
399 return param.release();
408QWidget *QgsProcessingStringWidgetWrapper::createWidget()
410 const QVariantMap metadata = parameterDefinition()->metadata();
411 const QVariant valueHintsVariant = metadata.value( u
"widget_wrapper"_s ).toMap().value( u
"value_hints"_s );
413 if ( valueHintsVariant.isValid() )
415 const QVariantList valueList = valueHintsVariant.toList();
416 mComboBox =
new QComboBox();
417 mComboBox->setToolTip( parameterDefinition()->toolTip() );
421 mComboBox->addItem( QString() );
423 for (
const QVariant &entry : valueList )
425 mComboBox->addItem( entry.toString(), entry.toString() );
427 mComboBox->setCurrentIndex( 0 );
429 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
430 emit widgetValueHasChanged(
this );
443 mPlainTextEdit =
new QPlainTextEdit();
444 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
446 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [
this] {
447 emit widgetValueHasChanged(
this );
449 return mPlainTextEdit;
453 mLineEdit =
new QLineEdit();
454 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
456 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
457 emit widgetValueHasChanged(
this );
465 mLineEdit =
new QLineEdit();
466 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
468 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
469 emit widgetValueHasChanged(
this );
479void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
483 mLineEdit->setText( v );
484 if ( mPlainTextEdit )
485 mPlainTextEdit->setPlainText( v );
489 if ( !value.isValid() )
490 index = mComboBox->findData( QVariant() );
492 index = mComboBox->findData( v );
495 mComboBox->setCurrentIndex( index );
497 mComboBox->setCurrentIndex( 0 );
501QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
504 return mLineEdit->text();
505 else if ( mPlainTextEdit )
506 return mPlainTextEdit->toPlainText();
507 else if ( mComboBox )
508 return mComboBox->currentData();
513QString QgsProcessingStringWidgetWrapper::parameterType()
const
520 return new QgsProcessingStringWidgetWrapper( parameter, type );
525 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
538QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
547 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
550 emit widgetValueHasChanged(
this );
552 return mAuthConfigSelect;
558void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
561 if ( mAuthConfigSelect )
562 mAuthConfigSelect->setConfigId( v );
565QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
567 if ( mAuthConfigSelect )
568 return mAuthConfigSelect->configId();
573QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
580 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
590 QVBoxLayout *vlayout =
new QVBoxLayout();
591 vlayout->setContentsMargins( 0, 0, 0, 0 );
593 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
595 mTypeComboBox =
new QComboBox();
598 vlayout->addWidget( mTypeComboBox );
600 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
601 mMinLineEdit =
new QLineEdit();
602 vlayout->addWidget( mMinLineEdit );
604 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
605 mMaxLineEdit =
new QLineEdit();
606 vlayout->addWidget( mMaxLineEdit );
608 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
609 mDefaultLineEdit =
new QLineEdit();
610 vlayout->addWidget( mDefaultLineEdit );
614 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( numberParam->dataType() ) ) );
616 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
618 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
622 mMaxLineEdit->clear();
625 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
627 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
631 mMinLineEdit->clear();
634 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
642 setLayout( vlayout );
651 auto param = std::make_unique<QgsProcessingParameterNumber>( name, description, dataType, ok ? val : QVariant() );
653 if ( !mMinLineEdit->text().trimmed().isEmpty() )
658 param->setMinimum( val );
662 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
667 param->setMaximum( val );
671 param->setFlags( flags );
672 return param.release();
680QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
683 const QVariantMap metadata = numberDef->
metadata();
684 const int decimals = metadata.value( u
"widget_wrapper"_s ).toMap().value( u
"decimals"_s, 6 ).toInt();
692 QAbstractSpinBox *spinBox =
nullptr;
697 mDoubleSpinBox->setExpressionsEnabled(
true );
698 mDoubleSpinBox->setDecimals( decimals );
703 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
704 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
705 mDoubleSpinBox->setSingleStep( singleStep );
708 spinBox = mDoubleSpinBox;
713 mSpinBox->setExpressionsEnabled(
true );
717 spinBox->setToolTip( parameterDefinition()->toolTip() );
719 double max = 999999999;
724 double min = -999999999;
729 if ( mDoubleSpinBox )
731 mDoubleSpinBox->setMinimum( min );
732 mDoubleSpinBox->setMaximum( max );
736 mSpinBox->setMinimum(
static_cast<int>( min ) );
737 mSpinBox->setMaximum(
static_cast<int>( max ) );
742 mAllowingNull =
true;
743 if ( mDoubleSpinBox )
745 mDoubleSpinBox->setShowClearButton(
true );
746 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
747 mDoubleSpinBox->setMinimum( min );
748 mDoubleSpinBox->setValue( min );
752 mSpinBox->setShowClearButton(
true );
753 const int min = mSpinBox->minimum() - 1;
754 mSpinBox->setMinimum( min );
755 mSpinBox->setValue( min );
757 spinBox->setSpecialValueText( tr(
"Not set" ) );
765 if ( mDoubleSpinBox )
769 mDoubleSpinBox->setClearValue( defaultVal );
775 mSpinBox->setClearValue( intVal );
781 if ( mDoubleSpinBox )
782 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
784 mSpinBox->setClearValue(
static_cast<int>( numberDef->
minimum() ) );
789 if ( mDoubleSpinBox )
791 mDoubleSpinBox->setValue( 0 );
792 mDoubleSpinBox->setClearValue( 0 );
796 mSpinBox->setValue( 0 );
797 mSpinBox->setClearValue( 0 );
802 if ( mDoubleSpinBox )
803 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
805 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
813void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
815 if ( mDoubleSpinBox )
817 if ( mAllowingNull && !value.isValid() )
818 mDoubleSpinBox->clear();
822 mDoubleSpinBox->setValue( v );
827 if ( mAllowingNull && !value.isValid() )
832 mSpinBox->setValue( v );
837QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
839 if ( mDoubleSpinBox )
841 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
844 return mDoubleSpinBox->value();
848 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
851 return mSpinBox->value();
857double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
859 const double valueRange = maximum - minimum;
860 if ( valueRange <= 1.0 )
862 const double step = valueRange / 10.0;
864 return qgsRound( step, -std::floor( std::log( step ) ) );
872QString QgsProcessingNumericWidgetWrapper::parameterType()
const
879 return new QgsProcessingNumericWidgetWrapper( parameter, type );
884 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
894 QVBoxLayout *vlayout =
new QVBoxLayout();
895 vlayout->setContentsMargins( 0, 0, 0, 0 );
897 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
899 mParentLayerComboBox =
new QComboBox();
901 QString initialParent;
903 initialParent = distParam->parentParameterName();
905 if (
auto *lModel = widgetContext.
model() )
908 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
909 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
913 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
914 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
916 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
921 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
922 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
924 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
929 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
930 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
932 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
937 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
938 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
940 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
946 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
949 mParentLayerComboBox->addItem( initialParent, initialParent );
950 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
953 vlayout->addWidget( mParentLayerComboBox );
956 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
957 mMinLineEdit =
new QLineEdit();
958 vlayout->addWidget( mMinLineEdit );
960 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
961 mMaxLineEdit =
new QLineEdit();
962 vlayout->addWidget( mMaxLineEdit );
964 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
965 mDefaultLineEdit =
new QLineEdit();
966 vlayout->addWidget( mDefaultLineEdit );
970 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
971 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
972 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
978 setLayout( vlayout );
986 auto param = std::make_unique<QgsProcessingParameterDistance>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
991 param->setMinimum( val );
997 param->setMaximum( val );
1000 param->setFlags( flags );
1001 return param.release();
1005 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1009QString QgsProcessingDistanceWidgetWrapper::parameterType()
const
1016 return new QgsProcessingDistanceWidgetWrapper( parameter, type );
1019QWidget *QgsProcessingDistanceWidgetWrapper::createWidget()
1023 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1028 mLabel =
new QLabel();
1029 mUnitsCombo =
new QComboBox();
1041 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1042 QHBoxLayout *layout =
new QHBoxLayout();
1043 layout->addWidget( spin, 1 );
1044 layout->insertSpacing( 1, labelMargin / 2 );
1045 layout->insertWidget( 2, mLabel );
1046 layout->insertWidget( 3, mUnitsCombo );
1051 mWarningLabel =
new QWidget();
1052 QHBoxLayout *warningLayout =
new QHBoxLayout();
1053 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1054 QLabel *warning =
new QLabel();
1056 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1057 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1058 warning->setToolTip( tr(
"Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1059 warningLayout->insertSpacing( 0, labelMargin / 2 );
1060 warningLayout->insertWidget( 1, warning );
1061 mWarningLabel->setLayout( warningLayout );
1062 layout->insertWidget( 4, mWarningLabel );
1064 QWidget *w =
new QWidget();
1065 layout->setContentsMargins( 0, 0, 0, 0 );
1066 w->setLayout( layout );
1080void QgsProcessingDistanceWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1082 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1089 if ( wrapper->parameterDefinition()->name() ==
static_cast<const QgsProcessingParameterDistance *
>( parameterDefinition() )->parentParameterName() )
1091 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1093 setUnitParameterValue( wrapper->parameterValue(), wrapper );
1113 std::unique_ptr<QgsProcessingContext> tmpContext;
1114 if ( mProcessingContextGenerator )
1115 context = mProcessingContextGenerator->processingContext();
1119 tmpContext = std::make_unique<QgsProcessingContext>();
1120 context = tmpContext.get();
1128 units = crs.mapUnits();
1139 mUnitsCombo->hide();
1147 if ( mBaseUnit != units )
1149 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( units ) ) );
1152 mUnitsCombo->show();
1159QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1161 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1162 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1175 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1186 QVBoxLayout *vlayout =
new QVBoxLayout();
1187 vlayout->setContentsMargins( 0, 0, 0, 0 );
1189 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1191 mParentLayerComboBox =
new QComboBox();
1193 QString initialParent;
1195 initialParent = areaParam->parentParameterName();
1197 if (
auto *lModel = widgetContext.
model() )
1200 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1201 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1205 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1206 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1208 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1213 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1214 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1216 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1221 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1222 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1224 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1229 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1230 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1232 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1238 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1241 mParentLayerComboBox->addItem( initialParent, initialParent );
1242 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1247 vlayout->addWidget( mParentLayerComboBox );
1249 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1250 mMinLineEdit =
new QLineEdit();
1251 vlayout->addWidget( mMinLineEdit );
1253 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1254 mMaxLineEdit =
new QLineEdit();
1255 vlayout->addWidget( mMaxLineEdit );
1257 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1258 mDefaultLineEdit =
new QLineEdit();
1259 vlayout->addWidget( mDefaultLineEdit );
1263 mMinLineEdit->setText( QLocale().toString( areaParam->minimum() ) );
1264 mMaxLineEdit->setText( QLocale().toString( areaParam->maximum() ) );
1265 mDefaultLineEdit->setText( areaParam->defaultValueForGui().toString() );
1272 setLayout( vlayout );
1280 auto param = std::make_unique<QgsProcessingParameterArea>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1285 param->setMinimum( val );
1291 param->setMaximum( val );
1294 param->setFlags( flags );
1295 return param.release();
1304 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1308QString QgsProcessingAreaWidgetWrapper::parameterType()
const
1315 return new QgsProcessingAreaWidgetWrapper( parameter, type );
1318QWidget *QgsProcessingAreaWidgetWrapper::createWidget()
1322 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1327 mLabel =
new QLabel();
1328 mUnitsCombo =
new QComboBox();
1343 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1344 QHBoxLayout *layout =
new QHBoxLayout();
1345 layout->addWidget( spin, 1 );
1346 layout->insertSpacing( 1, labelMargin / 2 );
1347 layout->insertWidget( 2, mLabel );
1348 layout->insertWidget( 3, mUnitsCombo );
1353 mWarningLabel =
new QWidget();
1354 QHBoxLayout *warningLayout =
new QHBoxLayout();
1355 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1356 QLabel *warning =
new QLabel();
1358 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1359 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1360 warning->setToolTip( tr(
"Area is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1361 warningLayout->insertSpacing( 0, labelMargin / 2 );
1362 warningLayout->insertWidget( 1, warning );
1363 mWarningLabel->setLayout( warningLayout );
1364 layout->insertWidget( 4, mWarningLabel );
1366 QWidget *w =
new QWidget();
1367 layout->setContentsMargins( 0, 0, 0, 0 );
1368 w->setLayout( layout );
1382void QgsProcessingAreaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1384 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1415 std::unique_ptr<QgsProcessingContext> tmpContext;
1416 if ( mProcessingContextGenerator )
1417 context = mProcessingContextGenerator->processingContext();
1421 tmpContext = std::make_unique<QgsProcessingContext>();
1422 context = tmpContext.get();
1430 units = QgsUnitTypes::distanceToAreaUnit( crs.mapUnits() );
1436void QgsProcessingAreaWidgetWrapper::setUnits(
Qgis::AreaUnit units )
1441 mUnitsCombo->hide();
1446 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1447 mUnitsCombo->show();
1454QVariant QgsProcessingAreaWidgetWrapper::widgetValue()
const
1456 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1457 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1470 return new QgsProcessingAreaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1481 QVBoxLayout *vlayout =
new QVBoxLayout();
1482 vlayout->setContentsMargins( 0, 0, 0, 0 );
1484 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1486 mParentLayerComboBox =
new QComboBox();
1488 QString initialParent;
1490 initialParent = volumeParam->parentParameterName();
1492 if (
auto *lModel = widgetContext.
model() )
1495 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1496 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1500 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1501 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1503 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1508 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1509 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1511 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1516 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1517 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1519 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1524 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1525 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1527 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1533 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1536 mParentLayerComboBox->addItem( initialParent, initialParent );
1537 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1540 vlayout->addWidget( mParentLayerComboBox );
1542 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1543 mMinLineEdit =
new QLineEdit();
1544 vlayout->addWidget( mMinLineEdit );
1546 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1547 mMaxLineEdit =
new QLineEdit();
1548 vlayout->addWidget( mMaxLineEdit );
1550 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1551 mDefaultLineEdit =
new QLineEdit();
1552 vlayout->addWidget( mDefaultLineEdit );
1556 mMinLineEdit->setText( QLocale().toString( volumeParam->minimum() ) );
1557 mMaxLineEdit->setText( QLocale().toString( volumeParam->maximum() ) );
1558 mDefaultLineEdit->setText( volumeParam->defaultValueForGui().toString() );
1566 setLayout( vlayout );
1574 auto param = std::make_unique<QgsProcessingParameterVolume>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1579 param->setMinimum( val );
1585 param->setMaximum( val );
1588 param->setFlags( flags );
1589 return param.release();
1598 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1602QString QgsProcessingVolumeWidgetWrapper::parameterType()
const
1609 return new QgsProcessingVolumeWidgetWrapper( parameter, type );
1612QWidget *QgsProcessingVolumeWidgetWrapper::createWidget()
1616 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1621 mLabel =
new QLabel();
1622 mUnitsCombo =
new QComboBox();
1635 const int labelMargin =
static_cast<int>( std::round( mUnitsCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
1636 QHBoxLayout *layout =
new QHBoxLayout();
1637 layout->addWidget( spin, 1 );
1638 layout->insertSpacing( 1, labelMargin / 2 );
1639 layout->insertWidget( 2, mLabel );
1640 layout->insertWidget( 3, mUnitsCombo );
1645 mWarningLabel =
new QWidget();
1646 QHBoxLayout *warningLayout =
new QHBoxLayout();
1647 warningLayout->setContentsMargins( 0, 0, 0, 0 );
1648 QLabel *warning =
new QLabel();
1650 const int size =
static_cast<int>( std::max( 24.0, spin->minimumSize().height() * 0.5 ) );
1651 warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
1652 warning->setToolTip( tr(
"Volume is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) );
1653 warningLayout->insertSpacing( 0, labelMargin / 2 );
1654 warningLayout->insertWidget( 1, warning );
1655 mWarningLabel->setLayout( warningLayout );
1656 layout->insertWidget( 4, mWarningLabel );
1658 QWidget *w =
new QWidget();
1659 layout->setContentsMargins( 0, 0, 0, 0 );
1660 w->setLayout( layout );
1674void QgsProcessingVolumeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
1676 QgsProcessingNumericWidgetWrapper::postInitialize( wrappers );
1707 std::unique_ptr<QgsProcessingContext> tmpContext;
1708 if ( mProcessingContextGenerator )
1709 context = mProcessingContextGenerator->processingContext();
1713 tmpContext = std::make_unique<QgsProcessingContext>();
1714 context = tmpContext.get();
1722 units = QgsUnitTypes::distanceToVolumeUnit( crs.mapUnits() );
1733 mUnitsCombo->hide();
1738 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1739 mUnitsCombo->show();
1746QVariant QgsProcessingVolumeWidgetWrapper::widgetValue()
const
1748 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1749 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1762 return new QgsProcessingVolumeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1773 QVBoxLayout *vlayout =
new QVBoxLayout();
1774 vlayout->setContentsMargins( 0, 0, 0, 0 );
1776 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1777 mMinLineEdit =
new QLineEdit();
1778 vlayout->addWidget( mMinLineEdit );
1780 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1781 mMaxLineEdit =
new QLineEdit();
1782 vlayout->addWidget( mMaxLineEdit );
1784 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1785 mDefaultLineEdit =
new QLineEdit();
1786 vlayout->addWidget( mDefaultLineEdit );
1788 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1790 mUnitsCombo =
new QComboBox();
1800 vlayout->addWidget( mUnitsCombo );
1806 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1807 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1808 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1809 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationParam->defaultUnit() ) ) );
1815 setLayout( vlayout );
1823 auto param = std::make_unique<QgsProcessingParameterDuration>( name, description, ok ? val : QVariant() );
1828 param->setMinimum( val );
1834 param->setMaximum( val );
1837 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit>( mUnitsCombo->currentData().toInt() ) );
1839 param->setFlags( flags );
1840 return param.release();
1844 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1848QString QgsProcessingDurationWidgetWrapper::parameterType()
const
1855 return new QgsProcessingDurationWidgetWrapper( parameter, type );
1858QWidget *QgsProcessingDurationWidgetWrapper::createWidget()
1862 QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget();
1867 mUnitsCombo =
new QComboBox();
1879 QHBoxLayout *layout =
new QHBoxLayout();
1880 layout->addWidget( spin, 1 );
1881 layout->insertWidget( 1, mUnitsCombo );
1883 QWidget *w =
new QWidget();
1884 layout->setContentsMargins( 0, 0, 0, 0 );
1885 w->setLayout( layout );
1887 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationDef->
defaultUnit() ) ) );
1888 mUnitsCombo->show();
1900QLabel *QgsProcessingDurationWidgetWrapper::createLabel()
1912QVariant QgsProcessingDurationWidgetWrapper::widgetValue()
const
1914 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1915 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo )
1926void QgsProcessingDurationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
1932 QgsProcessingNumericWidgetWrapper::setWidgetValue( val, context );
1936 QgsProcessingNumericWidgetWrapper::setWidgetValue( value, context );
1942 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1952 QVBoxLayout *vlayout =
new QVBoxLayout();
1953 vlayout->setContentsMargins( 0, 0, 0, 0 );
1955 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1957 mDefaultLineEdit =
new QLineEdit();
1961 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1964 vlayout->addWidget( mDefaultLineEdit );
1967 setLayout( vlayout );
1973 double val = mDefaultLineEdit->text().toDouble( &ok );
1974 auto param = std::make_unique<QgsProcessingParameterScale>( name, description, ok ? val : QVariant() );
1975 param->setFlags( flags );
1976 return param.release();
1980 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1984QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1991 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1994QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
2006 mScaleWidget->setAllowNull(
true );
2008 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
2009 mScaleWidget->setShowCurrentScaleButton(
true );
2011 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
2013 emit widgetValueHasChanged(
this );
2015 return mScaleWidget;
2024 mScaleWidget->setMapCanvas( context.
mapCanvas() );
2029QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
2031 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
2034void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2038 if ( mScaleWidget->allowNull() && !value.isValid() )
2039 mScaleWidget->setNull();
2043 mScaleWidget->setScale( v );
2050 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2061 QVBoxLayout *vlayout =
new QVBoxLayout();
2062 vlayout->setContentsMargins( 0, 0, 0, 0 );
2064 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
2066 mTypeComboBox =
new QComboBox();
2069 vlayout->addWidget( mTypeComboBox );
2071 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
2072 mMinLineEdit =
new QLineEdit();
2073 vlayout->addWidget( mMinLineEdit );
2075 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
2076 mMaxLineEdit =
new QLineEdit();
2077 vlayout->addWidget( mMaxLineEdit );
2081 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( rangeParam->dataType() ) ) );
2083 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
2084 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
2091 setLayout( vlayout );
2096 QString defaultValue;
2097 if ( mMinLineEdit->text().isEmpty() )
2099 defaultValue = u
"None"_s;
2107 defaultValue = u
"None"_s;
2111 if ( mMaxLineEdit->text().isEmpty() )
2113 defaultValue +=
",None"_L1;
2119 defaultValue += u
",%1"_s.arg( ok ? QString::number( val ) :
"None"_L1 );
2123 auto param = std::make_unique<QgsProcessingParameterRange>( name, description, dataType, defaultValue );
2124 param->setFlags( flags );
2125 return param.release();
2134QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
2143 QHBoxLayout *layout =
new QHBoxLayout();
2148 mMinSpinBox->setExpressionsEnabled(
true );
2149 mMinSpinBox->setShowClearButton(
false );
2150 mMaxSpinBox->setExpressionsEnabled(
true );
2151 mMaxSpinBox->setShowClearButton(
false );
2153 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
2154 layout->addWidget( minLabel );
2155 layout->addWidget( mMinSpinBox, 1 );
2157 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
2158 layout->addWidget( maxLabel );
2159 layout->addWidget( mMaxSpinBox, 1 );
2161 QWidget *w =
new QWidget();
2162 layout->setContentsMargins( 0, 0, 0, 0 );
2163 w->setLayout( layout );
2167 mMinSpinBox->setDecimals( 6 );
2168 mMaxSpinBox->setDecimals( 6 );
2172 mMinSpinBox->setDecimals( 0 );
2173 mMaxSpinBox->setDecimals( 0 );
2176 mMinSpinBox->setMinimum( -99999999.999999 );
2177 mMaxSpinBox->setMinimum( -99999999.999999 );
2178 mMinSpinBox->setMaximum( 99999999.999999 );
2179 mMaxSpinBox->setMaximum( 99999999.999999 );
2183 mAllowingNull =
true;
2185 const double min = mMinSpinBox->minimum() - 1;
2186 mMinSpinBox->setMinimum( min );
2187 mMaxSpinBox->setMinimum( min );
2188 mMinSpinBox->setValue( min );
2189 mMaxSpinBox->setValue( min );
2191 mMinSpinBox->setShowClearButton(
true );
2192 mMaxSpinBox->setShowClearButton(
true );
2193 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
2194 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
2197 w->setToolTip( parameterDefinition()->toolTip() );
2199 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this](
const double v ) {
2200 mBlockChangedSignal++;
2201 if ( !mAllowingNull && v > mMaxSpinBox->value() )
2202 mMaxSpinBox->setValue( v );
2203 mBlockChangedSignal--;
2205 if ( !mBlockChangedSignal )
2206 emit widgetValueHasChanged(
this );
2208 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this](
const double v ) {
2209 mBlockChangedSignal++;
2210 if ( !mAllowingNull && v < mMinSpinBox->value() )
2211 mMinSpinBox->setValue( v );
2212 mBlockChangedSignal--;
2214 if ( !mBlockChangedSignal )
2215 emit widgetValueHasChanged(
this );
2224void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2227 if ( mAllowingNull && v.empty() )
2229 mMinSpinBox->clear();
2230 mMaxSpinBox->clear();
2237 if ( mAllowingNull )
2239 mBlockChangedSignal++;
2240 if ( std::isnan( v.at( 0 ) ) )
2241 mMinSpinBox->clear();
2243 mMinSpinBox->setValue( v.at( 0 ) );
2245 if ( v.count() >= 2 )
2247 if ( std::isnan( v.at( 1 ) ) )
2248 mMaxSpinBox->clear();
2250 mMaxSpinBox->setValue( v.at( 1 ) );
2252 mBlockChangedSignal--;
2256 mBlockChangedSignal++;
2257 mMinSpinBox->setValue( v.at( 0 ) );
2258 if ( v.count() >= 2 )
2259 mMaxSpinBox->setValue( v.at( 1 ) );
2260 mBlockChangedSignal--;
2264 if ( !mBlockChangedSignal )
2265 emit widgetValueHasChanged(
this );
2268QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
2270 if ( mAllowingNull )
2273 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
2276 value = QString::number( mMinSpinBox->value() );
2278 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
2279 value +=
",None"_L1;
2281 value += u
",%1"_s.arg( mMaxSpinBox->value() );
2286 return u
"%1,%2"_s.arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
2289QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
2291 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
2294QString QgsProcessingRangeWidgetWrapper::parameterType()
const
2301 return new QgsProcessingRangeWidgetWrapper( parameter, type );
2306 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2317 QVBoxLayout *vlayout =
new QVBoxLayout();
2318 vlayout->setContentsMargins( 0, 0, 0, 0 );
2320 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
2323 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
2324 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
2326 vlayout->addWidget( mMatrixWidget );
2330 setLayout( vlayout );
2335 auto param = std::make_unique<QgsProcessingParameterMatrix>( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
2336 param->setFlags( flags );
2337 return param.release();
2346QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
2348 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast<const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
2349 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
2351 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [
this] {
2352 emit widgetValueHasChanged(
this );
2361 return mMatrixWidget;
2367void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2370 if ( mMatrixWidget )
2371 mMatrixWidget->setValue( v );
2374QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
2376 if ( mMatrixWidget )
2377 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
2382QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
2384 return tr(
"comma delimited string of values, or an array of values" );
2387QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
2394 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
2399 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2411 QVBoxLayout *vlayout =
new QVBoxLayout();
2412 vlayout->setContentsMargins( 0, 0, 0, 0 );
2414 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
2416 mTypeComboBox =
new QComboBox();
2420 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( fileParam->behavior() ) ) );
2422 mTypeComboBox->setCurrentIndex( 0 );
2423 vlayout->addWidget( mTypeComboBox );
2427 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
2429 mFilterComboBox =
new QComboBox();
2430 mFilterComboBox->setEditable(
true );
2432 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
2433 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
2434 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
2435 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
2437 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
2439 mFilterComboBox->setCurrentIndex( 0 );
2440 vlayout->addWidget( mFilterComboBox );
2444 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2447 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
2451 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
2455 vlayout->addWidget( mDefaultFileWidget );
2458 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2466 setLayout( vlayout );
2471 auto param = std::make_unique<QgsProcessingParameterFile>( name, description );
2474 param->setFileFilter( mFilterComboBox->currentText() );
2475 if ( !mDefaultFileWidget->filePath().isEmpty() )
2476 param->setDefaultValue( mDefaultFileWidget->filePath() );
2477 param->setFlags( flags );
2478 return param.release();
2487QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2500 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2501 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2503 mFileWidget->setDefaultRoot(
QgsSettings().value( u
"/Processing/LastInputPath"_s, QDir::homePath() ).toString() );
2510 mFileWidget->setFilter( fileParam->
fileFilter() );
2511 else if ( !fileParam->
extension().isEmpty() )
2512 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + u
" (*."_s + fileParam->
extension().toLower() +
')' );
2521 QgsSettings().
setValue( u
"/Processing/LastInputPath"_s, QFileInfo( path ).canonicalPath() );
2522 emit widgetValueHasChanged(
this );
2530void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2534 mFileWidget->setFilePath( v );
2537QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2540 return mFileWidget->filePath();
2545QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2547 return tr(
"string representing a path to a file or folder" );
2550QString QgsProcessingFileWidgetWrapper::parameterType()
const
2557 return new QgsProcessingFileWidgetWrapper( parameter, type );
2562 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2573 QVBoxLayout *vlayout =
new QVBoxLayout();
2574 vlayout->setContentsMargins( 0, 0, 0, 0 );
2575 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2578 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2580 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2581 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2583 QStackedWidget *stackedWidget =
new QStackedWidget();
2584 stackedWidget->addWidget( mDefaultQgisLineEdit );
2585 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2586 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2587 vlayout->addWidget( stackedWidget );
2596 mDefaultQgisLineEdit->setExpression( expr );
2597 mDefaultPointCloudLineEdit->setExpression( expr );
2600 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2602 mParentLayerComboBox =
new QComboBox();
2603 vlayout->addWidget( mParentLayerComboBox );
2605 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2606 mExpressionTypeComboBox =
new QComboBox();
2611 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this, stackedWidget, definition, widgetContext](
int ) {
2612 mParentLayerComboBox->clear();
2613 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2615 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2617 QString initialParent;
2619 initialParent = expParam->parentLayerParameterName();
2623 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2626 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2627 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2634 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2635 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2637 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2642 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2643 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2645 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2652 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2653 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2655 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2666 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2667 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2669 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2677 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2680 mParentLayerComboBox->addItem( initialParent, initialParent );
2681 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2685 mExpressionTypeComboBox->setCurrentIndex( -1 );
2687 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast<int>( expParam->expressionType() ) ) );
2689 mExpressionTypeComboBox->setCurrentIndex( 0 );
2691 vlayout->addWidget( mExpressionTypeComboBox );
2696 setLayout( vlayout );
2703 switch ( expressionType )
2706 expression = mDefaultQgisLineEdit->expression();
2709 expression = mDefaultPointCloudLineEdit->expression();
2712 expression = mDefaultRasterCalculatorLineEdit->expression();
2715 auto param = std::make_unique<QgsProcessingParameterExpression>( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2716 param->setFlags( flags );
2717 return param.release();
2725QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2740 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2741 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2742 mExpLineEdit->registerExpressionContextGenerator(
this );
2744 emit widgetValueHasChanged(
this );
2746 return mExpLineEdit;
2752 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2753 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2754 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [
this](
const QString & ) {
2755 emit widgetValueHasChanged(
this );
2757 return mPointCloudExpLineEdit;
2762 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2763 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2766 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2768 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [
this](
const QString & ) {
2769 emit widgetValueHasChanged(
this );
2771 return mRasterCalculatorExpLineEdit;
2775 if ( expParam->
metadata().value( u
"inlineEditor"_s ).toBool() )
2778 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2779 mExpBuilderWidget->init( createExpressionContext() );
2781 Q_UNUSED( changed );
2782 emit widgetValueHasChanged(
this );
2784 return mExpBuilderWidget;
2789 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2790 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2791 mFieldExpWidget->registerExpressionContextGenerator(
this );
2793 mFieldExpWidget->setAllowEmptyFieldName(
true );
2796 emit widgetValueHasChanged(
this );
2798 return mFieldExpWidget;
2806void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2818 setParentLayerWrapperValue( wrapper );
2820 setParentLayerWrapperValue( wrapper );
2836 if ( mExpBuilderWidget )
2839 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2847 std::unique_ptr<QgsProcessingContext> tmpContext;
2848 if ( mProcessingContextGenerator )
2849 context = mProcessingContextGenerator->processingContext();
2853 tmpContext = std::make_unique<QgsProcessingContext>();
2854 context = tmpContext.get();
2867 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2877 if ( mFieldExpWidget )
2878 mFieldExpWidget->setLayer(
nullptr );
2879 else if ( mExpBuilderWidget )
2880 mExpBuilderWidget->setLayer(
nullptr );
2881 else if ( mExpLineEdit )
2882 mExpLineEdit->setLayer(
nullptr );
2888 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2891 mParentLayer = std::move( ownedLayer );
2899 if ( mFieldExpWidget )
2900 mFieldExpWidget->setLayer( layer );
2901 if ( mExpBuilderWidget )
2902 mExpBuilderWidget->setLayer( layer );
2903 else if ( mExpLineEdit )
2904 mExpLineEdit->setLayer( layer );
2913 if ( mPointCloudExpLineEdit )
2914 mPointCloudExpLineEdit->setLayer(
nullptr );
2920 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2923 mParentLayer = std::move( ownedLayer );
2931 if ( mPointCloudExpLineEdit )
2932 mPointCloudExpLineEdit->setLayer( layer );
2939 if ( layers.isEmpty() )
2941 if ( mRasterCalculatorExpLineEdit )
2943 mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
2948 if ( mRasterCalculatorExpLineEdit )
2950 QVariantList layersList;
2953 layersList << layer->
name();
2955 mRasterCalculatorExpLineEdit->setLayers( layersList );
2963void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2966 if ( mFieldExpWidget )
2967 mFieldExpWidget->setExpression( v );
2968 else if ( mExpBuilderWidget )
2969 mExpBuilderWidget->setExpressionText( v );
2970 else if ( mExpLineEdit )
2971 mExpLineEdit->setExpression( v );
2972 else if ( mPointCloudExpLineEdit )
2973 mPointCloudExpLineEdit->setExpression( v );
2974 else if ( mRasterCalculatorExpLineEdit )
2975 mRasterCalculatorExpLineEdit->setExpression( v );
2978QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2980 if ( mFieldExpWidget )
2981 return mFieldExpWidget->expression();
2982 if ( mExpBuilderWidget )
2983 return mExpBuilderWidget->expressionText();
2984 else if ( mExpLineEdit )
2985 return mExpLineEdit->expression();
2986 else if ( mPointCloudExpLineEdit )
2987 return mPointCloudExpLineEdit->expression();
2988 else if ( mRasterCalculatorExpLineEdit )
2989 return mRasterCalculatorExpLineEdit->expression();
2994QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2996 return tr(
"string representation of an expression" );
2999const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
3001 if ( mFieldExpWidget && mFieldExpWidget->layer() )
3002 return mFieldExpWidget->layer();
3004 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
3005 return mExpBuilderWidget->layer();
3010QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
3017 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
3022 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3034 QHBoxLayout *hl =
new QHBoxLayout();
3035 hl->setContentsMargins( 0, 0, 0, 0 );
3037 mLineEdit =
new QLineEdit();
3038 mLineEdit->setEnabled(
false );
3039 hl->addWidget( mLineEdit, 1 );
3041 mToolButton =
new QToolButton();
3042 mToolButton->setText( QString( QChar( 0x2026 ) ) );
3043 hl->addWidget( mToolButton );
3049 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3052 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
3055void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
3057 if ( value.isValid() )
3059 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3061 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
3067 updateSummaryText();
3071void QgsProcessingEnumPanelWidget::showDialog()
3073 QVariantList availableOptions;
3076 availableOptions.reserve( mParam->options().size() );
3078 if ( mParam->usesStaticStrings() )
3080 for ( QString o : mParam->options() )
3082 availableOptions << o;
3087 for (
int i = 0; i < mParam->options().count(); ++i )
3088 availableOptions << i;
3092 const QStringList options = mParam ? mParam->options() : QStringList();
3096 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3097 widget->setPanelTitle( mParam->description() );
3099 if ( mParam->usesStaticStrings() )
3101 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3102 const QString i = v.toString();
3103 return options.contains( i ) ? i : QString();
3108 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3109 const int i = v.toInt();
3110 return options.size() > i ? options.at( i ) : QString();
3114 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
3115 setValue( widget->selectedOptions() );
3122 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3124 dlg.setValueFormatter( [options](
const QVariant &v ) -> QString {
3125 const int i = v.toInt();
3126 return options.size() > i ? options.at( i ) : QString();
3130 setValue( dlg.selectedOptions() );
3135void QgsProcessingEnumPanelWidget::updateSummaryText()
3140 if ( mValue.empty() )
3142 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3147 values.reserve( mValue.size() );
3148 if ( mParam->usesStaticStrings() )
3150 for (
const QVariant &val : std::as_const( mValue ) )
3152 values << val.toString();
3157 const QStringList options = mParam->options();
3158 for (
const QVariant &val : std::as_const( mValue ) )
3160 const int i = val.toInt();
3161 values << ( options.size() > i ? options.at( i ) : QString() );
3165 const QString concatenated = values.join( tr(
"," ) );
3166 if ( concatenated.length() < 100 )
3167 mLineEdit->setText( concatenated );
3169 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
3177QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
3180 , mButtonGroup( new QButtonGroup( this ) )
3181 , mColumns( columns )
3183 mButtonGroup->setExclusive( !mParam->allowMultiple() );
3185 QGridLayout *l =
new QGridLayout();
3186 l->setContentsMargins( 0, 0, 0, 0 );
3188 int rows =
static_cast<int>( std::ceil( mParam->options().count() /
static_cast<double>( mColumns ) ) );
3189 for (
int i = 0; i < mParam->options().count(); ++i )
3191 QAbstractButton *button =
nullptr;
3192 if ( mParam->allowMultiple() )
3193 button =
new QCheckBox( mParam->options().at( i ) );
3195 button =
new QRadioButton( mParam->options().at( i ) );
3197 connect( button, &QAbstractButton::toggled,
this, [
this] {
3198 if ( !mBlockChangedSignal )
3202 mButtons.insert( i, button );
3204 mButtonGroup->addButton( button, i );
3205 l->addWidget( button, i % rows, i / rows );
3207 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
3210 if ( mParam->allowMultiple() )
3212 setContextMenuPolicy( Qt::CustomContextMenu );
3213 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
3217QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
3219 if ( mParam->allowMultiple() )
3222 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3224 if ( it.value()->isChecked() )
3225 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
3231 if ( mParam->usesStaticStrings() )
3232 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
3234 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
3238void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
3240 mBlockChangedSignal =
true;
3241 if ( mParam->allowMultiple() )
3243 QVariantList selected;
3244 if ( value.isValid() )
3245 selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3246 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3248 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
3249 it.value()->setChecked( selected.contains( v ) );
3255 if ( v.userType() == QMetaType::Type::QVariantList )
3256 v = v.toList().value( 0 );
3258 v = mParam->usesStaticStrings() ?
static_cast< int >( mParam->options().indexOf( v.toString() ) ) : v;
3259 if ( mButtons.contains( v ) )
3260 mButtons.value( v )->setChecked(
true );
3262 mBlockChangedSignal =
false;
3266void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
3269 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
3270 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
3271 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
3272 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
3273 popupMenu.addAction( selectAllAction );
3274 popupMenu.addAction( clearAllAction );
3275 popupMenu.exec( QCursor::pos() );
3278void QgsProcessingEnumCheckboxPanelWidget::selectAll()
3280 mBlockChangedSignal =
true;
3281 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3282 it.value()->setChecked(
true );
3283 mBlockChangedSignal =
false;
3287void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
3289 mBlockChangedSignal =
true;
3290 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3291 it.value()->setChecked(
false );
3292 mBlockChangedSignal =
false;
3304 QVBoxLayout *vlayout =
new QVBoxLayout();
3305 vlayout->setContentsMargins( 0, 0, 0, 0 );
3307 mEnumWidget =
new QgsProcessingEnumModelerWidget();
3310 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
3311 mEnumWidget->setOptions( enumParam->options() );
3312 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
3314 vlayout->addWidget( mEnumWidget );
3318 setLayout( vlayout );
3323 auto param = std::make_unique<QgsProcessingParameterEnum>( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
3325 return param.release();
3334QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
3345 if ( expParam->
metadata().value( u
"widget_wrapper"_s ).toMap().value( u
"useCheckBoxes"_s,
false ).toBool() )
3347 const int columns = expParam->
metadata().value( u
"widget_wrapper"_s ).toMap().value( u
"columns"_s, 2 ).toInt();
3348 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
3349 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
3350 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [
this] {
3351 emit widgetValueHasChanged(
this );
3353 return mCheckboxPanel;
3362 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
3363 mPanel->setToolTip( parameterDefinition()->toolTip() );
3364 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [
this] {
3365 emit widgetValueHasChanged(
this );
3371 mComboBox =
new QComboBox();
3374 mComboBox->addItem( tr(
"[Not selected]" ), QVariant() );
3375 const QStringList options = expParam->
options();
3376 const QVariantList iconList = expParam->
metadata().value( u
"widget_wrapper"_s ).toMap().value( u
"icons"_s ).toList();
3377 for (
int i = 0; i < options.count(); ++i )
3379 const QIcon icon = iconList.value( i ).value<QIcon>();
3382 mComboBox->addItem( icon, options.at( i ), options.at( i ) );
3384 mComboBox->addItem( icon, options.at( i ), i );
3387 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3388 mComboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
3389 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
3390 emit widgetValueHasChanged(
this );
3399void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3403 if ( !value.isValid() )
3404 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
3410 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3415 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3419 else if ( mPanel || mCheckboxPanel )
3422 if ( value.isValid() )
3427 opts.reserve( v.size() );
3428 for ( QString i : v )
3434 opts.reserve( v.size() );
3440 mPanel->setValue( opts );
3441 else if ( mCheckboxPanel )
3442 mCheckboxPanel->setValue( opts );
3446QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3449 return mComboBox->currentData();
3451 return mPanel->value();
3452 else if ( mCheckboxPanel )
3453 return mCheckboxPanel->value();
3458QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3460 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3463QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3470 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3475 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3487QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3499 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() :
nullptr );
3501 mComboBox->setAllowEmptyLayout(
true );
3504 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3506 emit widgetValueHasChanged(
this );
3513 mPlainComboBox =
new QComboBox();
3514 mPlainComboBox->setEditable(
true );
3515 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3516 if ( widgetContext().project() )
3520 mPlainComboBox->addItem( layout->name() );
3523 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
3524 emit widgetValueHasChanged(
this );
3526 return mPlainComboBox;
3532void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3536 if ( !value.isValid() )
3537 mComboBox->setCurrentLayout(
nullptr );
3541 mComboBox->setCurrentLayout( l );
3543 mComboBox->setCurrentLayout(
nullptr );
3546 else if ( mPlainComboBox )
3549 mPlainComboBox->setCurrentText( v );
3553QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3558 return l ? l->
name() : QVariant();
3560 else if ( mPlainComboBox )
3561 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3569 if ( mPlainComboBox && context.
project() )
3573 mPlainComboBox->addItem( layout->name() );
3577QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3579 return tr(
"string representing the name of an existing print layout" );
3582QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3589 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3601 QVBoxLayout *vlayout =
new QVBoxLayout();
3602 vlayout->setContentsMargins( 0, 0, 0, 0 );
3604 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3606 mParentLayoutComboBox =
new QComboBox();
3607 QString initialParent;
3609 initialParent = itemParam->parentLayoutParameterName();
3611 if (
auto *lModel = widgetContext.
model() )
3614 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3615 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3619 mParentLayoutComboBox->addItem( definition->
description(), definition->
name() );
3620 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3622 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3628 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3631 mParentLayoutComboBox->addItem( initialParent, initialParent );
3632 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3635 vlayout->addWidget( mParentLayoutComboBox );
3639 setLayout( vlayout );
3643 auto param = std::make_unique<QgsProcessingParameterLayoutItem>( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3645 return param.release();
3654QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3668 mComboBox->setAllowEmptyItem(
true );
3669 if ( layoutParam->
itemType() >= 0 )
3672 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3674 emit widgetValueHasChanged(
this );
3681 mLineEdit =
new QLineEdit();
3682 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3683 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString & ) {
3684 emit widgetValueHasChanged(
this );
3692void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3719void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3725 std::unique_ptr<QgsProcessingContext> tmpContext;
3726 if ( mProcessingContextGenerator )
3727 context = mProcessingContextGenerator->processingContext();
3731 tmpContext = std::make_unique<QgsProcessingContext>();
3732 context = tmpContext.get();
3736 setLayout( layout );
3739void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3742 mComboBox->setCurrentLayout( layout );
3745void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3749 if ( !value.isValid() )
3750 mComboBox->setItem(
nullptr );
3754 mComboBox->setItem( item );
3757 else if ( mLineEdit )
3760 mLineEdit->setText( v );
3764QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3769 return i ? i->
uuid() : QVariant();
3771 else if ( mLineEdit )
3772 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3778QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3780 return tr(
"string representing the UUID or ID of an existing print layout item" );
3783QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3790 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3795 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3802QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3806 mSnapIndicator = std::make_unique<QgsSnapIndicator>( canvas );
3809QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3811void QgsProcessingPointMapTool::deactivate()
3825 if ( e->button() == Qt::LeftButton )
3828 emit clicked( point );
3833void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3835 if ( e->key() == Qt::Key_Escape )
3848QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3851 QHBoxLayout *l =
new QHBoxLayout();
3852 l->setContentsMargins( 0, 0, 0, 0 );
3854 mLineEdit->setShowClearButton(
false );
3855 l->addWidget( mLineEdit, 1 );
3856 mButton =
new QToolButton();
3857 mButton->setText( QString( QChar( 0x2026 ) ) );
3858 l->addWidget( mButton );
3861 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3862 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::textChanged );
3863 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3864 mButton->setVisible(
false );
3867void QgsProcessingPointPanel::setMapCanvas(
QgsMapCanvas *canvas )
3870 if ( mAllowSelectOnCanvas )
3872 mButton->setVisible(
true );
3875 mTool = std::make_unique<QgsProcessingPointMapTool>( mCanvas );
3876 connect( mTool.get(), &QgsProcessingPointMapTool::clicked,
this, &QgsProcessingPointPanel::updatePoint );
3877 connect( mTool.get(), &QgsProcessingPointMapTool::complete,
this, &QgsProcessingPointPanel::pointPicked );
3881void QgsProcessingPointPanel::setAllowNull(
bool allowNull )
3883 mLineEdit->setShowClearButton( allowNull );
3886void QgsProcessingPointPanel::setShowPointOnCanvas(
bool show )
3888 if ( mShowPointOnCanvas == show )
3891 mShowPointOnCanvas = show;
3892 if ( mShowPointOnCanvas )
3898 mMapPointRubberBand.reset();
3902void QgsProcessingPointPanel::setAllowSelectOnCanvas(
bool allow )
3904 mAllowSelectOnCanvas = allow;
3905 mButton->setVisible( mAllowSelectOnCanvas &&
static_cast<bool>( mTool ) );
3908QVariant QgsProcessingPointPanel::value()
const
3910 return mLineEdit->showClearButton() && mLineEdit->text().trimmed().isEmpty() ? QVariant() : QVariant( mLineEdit->text() );
3913void QgsProcessingPointPanel::clear()
3921 QString newText = u
"%1,%2"_s
3922 .arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) );
3925 if ( mCrs.isValid() )
3927 newText += u
" [%1]"_s.arg( mCrs.authid() );
3929 mLineEdit->setText( newText );
3933void QgsProcessingPointPanel::showEvent( QShowEvent * )
3938 if ( QWidget *parentWindow = window() )
3940 setAllowSelectOnCanvas( !parentWindow->isModal() );
3946void QgsProcessingPointPanel::selectOnCanvas()
3951 mPrevTool = mCanvas->mapTool();
3952 mCanvas->setMapTool( mTool.get() );
3954 emit toggleDialogVisibility(
false );
3957void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3959 setValue( point, mCanvas->mapSettings().destinationCrs() );
3962void QgsProcessingPointPanel::pointPicked()
3967 mCanvas->setMapTool( mPrevTool );
3969 emit toggleDialogVisibility(
true );
3972void QgsProcessingPointPanel::textChanged(
const QString &text )
3974 const thread_local QRegularExpression rx( u
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$"_s );
3976 const QRegularExpressionMatch match = rx.match( text );
3977 if ( match.hasMatch() )
3980 const double x = match.captured( 1 ).toDouble( &xOk );
3982 const double y = match.captured( 2 ).toDouble( &yOk );
3989 if ( pointCrs.isValid() )
4007void QgsProcessingPointPanel::updateRubberBand()
4009 if ( !mShowPointOnCanvas || !mCanvas )
4012 if ( mPoint.isEmpty() )
4014 mMapPointRubberBand.reset();
4018 if ( !mMapPointRubberBand )
4021 mMapPointRubberBand->setZValue( 1000 );
4024 const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
4025 mMapPointRubberBand->setWidth( scaleFactor );
4026 mMapPointRubberBand->setIconSize( scaleFactor * 5 );
4028 mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
4029 mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
4043 QVBoxLayout *vlayout =
new QVBoxLayout();
4044 vlayout->setContentsMargins( 0, 0, 0, 0 );
4046 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4048 mDefaultLineEdit =
new QLineEdit();
4049 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4050 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
4054 mDefaultLineEdit->setText( u
"%1,%2"_s.arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
4057 vlayout->addWidget( mDefaultLineEdit );
4061 setLayout( vlayout );
4066 auto param = std::make_unique<QgsProcessingParameterPoint>( name, description, mDefaultLineEdit->text() );
4068 return param.release();
4076QWidget *QgsProcessingPointWidgetWrapper::createWidget()
4087 mPanel =
new QgsProcessingPointPanel(
nullptr );
4088 if ( widgetContext().mapCanvas() )
4089 mPanel->setMapCanvas( widgetContext().mapCanvas() );
4092 mPanel->setAllowNull(
true );
4095 mPanel->setShowPointOnCanvas(
true );
4097 mPanel->setToolTip( parameterDefinition()->toolTip() );
4099 connect( mPanel, &QgsProcessingPointPanel::changed,
this, [
this] {
4100 emit widgetValueHasChanged(
this );
4104 setDialog( mDialog );
4110 mLineEdit =
new QLineEdit();
4111 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4112 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString & ) {
4113 emit widgetValueHasChanged(
this );
4125 mPanel->setMapCanvas( context.
mapCanvas() );
4128void QgsProcessingPointWidgetWrapper::setDialog( QDialog *dialog )
4133 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [
this](
bool visible ) {
4135 mDialog->showMinimized();
4138 mDialog->showNormal();
4140 mDialog->activateWindow();
4147void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4151 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
4157 mPanel->setValue( p, crs );
4160 else if ( mLineEdit )
4163 mLineEdit->setText( v );
4167QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
4171 return mPanel->value();
4173 else if ( mLineEdit )
4174 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
4179QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
4181 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
4184QString QgsProcessingPointWidgetWrapper::parameterType()
const
4191 return new QgsProcessingPointWidgetWrapper( parameter, type );
4196 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4208 QVBoxLayout *vlayout =
new QVBoxLayout();
4209 vlayout->setContentsMargins( 0, 0, 0, 0 );
4211 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4223 vlayout->addWidget( mGeometryWidget );
4227 setLayout( vlayout );
4233 auto param = std::make_unique<QgsProcessingParameterGeometry>( name, description, geometry.
isEmpty() ? QVariant() : geometry.
asWkt() );
4235 return param.release();
4243QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
4252 mGeometryWidget->setToolTip( parameterDefinition()->toolTip() );
4254 emit widgetValueHasChanged(
this );
4256 return mGeometryWidget;
4262void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4264 if ( mGeometryWidget )
4273 mGeometryWidget->clearGeometry();
4278QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
4280 if ( mGeometryWidget )
4283 return geometry.
isEmpty() ? QVariant() : geometry.asWkt();
4291QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
4293 return tr(
"string in the Well-Known-Text format or a geometry value" );
4296QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
4303 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
4308 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4320 QVBoxLayout *vlayout =
new QVBoxLayout();
4321 vlayout->setContentsMargins( 0, 0, 0, 0 );
4323 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4326 mDefaultColorButton->setShowNull(
true );
4327 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
4333 mDefaultColorButton->setToNull();
4335 mDefaultColorButton->setColor(
c );
4336 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
4340 mDefaultColorButton->setToNull();
4341 mAllowOpacity->setChecked(
true );
4347 vlayout->addWidget( mDefaultColorButton );
4348 vlayout->addWidget( mAllowOpacity );
4349 setLayout( vlayout );
4354 auto param = std::make_unique<QgsProcessingParameterColor>( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
4356 return param.release();
4364QWidget *QgsProcessingColorWidgetWrapper::createWidget()
4377 mColorButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
4380 mColorButton->setShowNull(
true );
4383 mColorButton->setToolTip( parameterDefinition()->toolTip() );
4384 mColorButton->setColorDialogTitle( parameterDefinition()->description() );
4391 emit widgetValueHasChanged(
this );
4394 return mColorButton;
4400void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4404 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() )
4405 || ( value.userType() == QMetaType::Type::QColor && !value.value<QColor>().isValid() ) )
4406 mColorButton->setToNull();
4410 if ( !
c.isValid() && mColorButton->showNull() )
4411 mColorButton->setToNull();
4413 mColorButton->setColor(
c );
4418QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
4421 return mColorButton->isNull() ? QVariant() : mColorButton->color();
4426QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
4428 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
4431QString QgsProcessingColorWidgetWrapper::parameterType()
const
4438 return new QgsProcessingColorWidgetWrapper( parameter, type );
4443 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4454 QVBoxLayout *vlayout =
new QVBoxLayout();
4455 vlayout->setContentsMargins( 0, 0, 0, 0 );
4457 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4459 mDefaultLineEdit =
new QLineEdit();
4462 vlayout->addWidget( mDefaultLineEdit );
4466 mSourceParamComboBox =
new QComboBox();
4467 mDestParamComboBox =
new QComboBox();
4468 QString initialSource;
4469 QString initialDest;
4474 initialSource = itemParam->sourceCrsParameterName();
4475 initialDest = itemParam->destinationCrsParameterName();
4480 mSourceParamComboBox->addItem( QString(), QString() );
4481 mDestParamComboBox->addItem( QString(), QString() );
4482 if (
auto *lModel = widgetContext.
model() )
4485 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4486 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4488 if ( definition && it->parameterName() == definition->
name() )
4492 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4493 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4494 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4496 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4498 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4500 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4505 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4508 mSourceParamComboBox->addItem( initialSource, initialSource );
4509 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4511 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4514 mDestParamComboBox->addItem( initialDest, initialDest );
4515 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4518 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4519 vlayout->addWidget( mSourceParamComboBox );
4520 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4521 vlayout->addWidget( mDestParamComboBox );
4528 mStaticSourceWidget->setCrs( sourceCrs );
4531 mStaticDestWidget->setCrs( destCrs );
4533 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4534 vlayout->addWidget( mStaticSourceWidget );
4535 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4536 vlayout->addWidget( mStaticDestWidget );
4541 setLayout( vlayout );
4546 auto param = std::make_unique<QgsProcessingParameterCoordinateOperation>( name, description, mDefaultLineEdit->text(), mSourceParamComboBox->currentText(), mDestParamComboBox->currentText(), mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(), mStaticDestWidget->crs().isValid() ? QVariant::fromValue( mStaticDestWidget->crs() ) : QVariant() );
4548 return param.release();
4556QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4570 mOperationWidget->setShowMakeDefault(
false );
4571 mOperationWidget->setShowFallbackOption(
false );
4572 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4573 mOperationWidget->setSourceCrs( mSourceCrs );
4574 mOperationWidget->setDestinationCrs( mDestCrs );
4575 mOperationWidget->setMapCanvas( mCanvas );
4580 mOperationWidget->setSelectedOperation( deets );
4584 emit widgetValueHasChanged(
this );
4587 return mOperationWidget;
4593 mLineEdit =
new QLineEdit();
4594 QHBoxLayout *layout =
new QHBoxLayout();
4595 layout->addWidget( mLineEdit, 1 );
4596 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
4597 emit widgetValueHasChanged(
this );
4600 QToolButton *button =
new QToolButton();
4601 button->setText( QString( QChar( 0x2026 ) ) );
4602 connect( button, &QToolButton::clicked,
this, [
this, button] {
4603 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4606 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4607 emit widgetValueHasChanged(
this );
4610 layout->addWidget( button );
4612 QWidget *w =
new QWidget();
4613 layout->setContentsMargins( 0, 0, 0, 0 );
4614 w->setLayout( layout );
4621void QgsProcessingCoordinateOperationWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
4657 if ( mOperationWidget )
4658 mOperationWidget->setMapCanvas( context.
mapCanvas() );
4661void QgsProcessingCoordinateOperationWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
4663 if ( mOperationWidget )
4665 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4668 deets.
proj = value.toString();
4669 mOperationWidget->setSelectedOperation( deets );
4674 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString ) )
4676 mLineEdit->setText( value.toString() );
4681QVariant QgsProcessingCoordinateOperationWidgetWrapper::widgetValue()
const
4683 if ( mOperationWidget )
4684 return mOperationWidget->selectedOperation().proj;
4685 else if ( mLineEdit )
4686 return mLineEdit->text();
4691QString QgsProcessingCoordinateOperationWidgetWrapper::modelerExpressionFormatString()
const
4693 return tr(
"Proj coordinate operation string, e.g. '+proj=pipeline +step +inv...'" );
4696void QgsProcessingCoordinateOperationWidgetWrapper::setSourceCrsParameterValue(
const QVariant &value )
4699 std::unique_ptr<QgsProcessingContext> tmpContext;
4700 if ( mProcessingContextGenerator )
4701 context = mProcessingContextGenerator->processingContext();
4705 tmpContext = std::make_unique<QgsProcessingContext>();
4706 context = tmpContext.get();
4710 if ( mOperationWidget )
4712 mOperationWidget->setSourceCrs( mSourceCrs );
4713 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4717void QgsProcessingCoordinateOperationWidgetWrapper::setDestinationCrsParameterValue(
const QVariant &value )
4720 std::unique_ptr<QgsProcessingContext> tmpContext;
4721 if ( mProcessingContextGenerator )
4722 context = mProcessingContextGenerator->processingContext();
4726 tmpContext = std::make_unique<QgsProcessingContext>();
4727 context = tmpContext.get();
4731 if ( mOperationWidget )
4733 mOperationWidget->setDestinationCrs( mDestCrs );
4734 mOperationWidget->setSelectedOperationUsingContext( context->
transformContext() );
4738QString QgsProcessingCoordinateOperationWidgetWrapper::parameterType()
const
4745 return new QgsProcessingCoordinateOperationWidgetWrapper( parameter, type );
4750 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4762 QHBoxLayout *hl =
new QHBoxLayout();
4763 hl->setContentsMargins( 0, 0, 0, 0 );
4765 mLineEdit =
new QLineEdit();
4766 mLineEdit->setEnabled(
false );
4767 hl->addWidget( mLineEdit, 1 );
4769 mToolButton =
new QToolButton();
4770 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4771 hl->addWidget( mToolButton );
4777 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4780 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4783void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4789 QVariantList availableFields;
4790 for (
const QgsField &field : std::as_const( mFields ) )
4792 availableFields << field.name();
4794 QList<QVariant>::iterator it = std::remove_if( mValue.begin(), mValue.end(), [&availableFields](
const QVariant &value ) { return !availableFields.contains( value ); } );
4795 mValue.erase( it, mValue.end() );
4797 updateSummaryText();
4801void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4803 if ( value.isValid() )
4804 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
4808 updateSummaryText();
4812void QgsProcessingFieldPanelWidget::showDialog()
4814 QVariantList availableOptions;
4815 availableOptions.reserve( mFields.size() );
4816 for (
const QgsField &field : std::as_const( mFields ) )
4818 availableOptions << field.name();
4824 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4825 widget->setPanelTitle( mParam->description() );
4827 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
4828 return v.toString();
4831 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
4832 setValue( widget->selectedOptions() );
4839 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4841 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
4842 return v.toString();
4846 setValue( dlg.selectedOptions() );
4851void QgsProcessingFieldPanelWidget::updateSummaryText()
4856 if ( mValue.empty() )
4858 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4863 values.reserve( mValue.size() );
4864 for (
const QVariant &val : std::as_const( mValue ) )
4866 values << val.toString();
4869 const QString concatenated = values.join( tr(
"," ) );
4870 if ( concatenated.length() < 100 )
4871 mLineEdit->setText( concatenated );
4873 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4885 QVBoxLayout *vlayout =
new QVBoxLayout();
4886 vlayout->setContentsMargins( 0, 0, 0, 0 );
4888 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4889 mParentLayerComboBox =
new QComboBox();
4891 QString initialParent;
4893 initialParent = fieldParam->parentLayerParameterName();
4895 if (
auto *lModel = widgetContext.
model() )
4898 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4899 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4903 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4904 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4906 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4911 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4912 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4914 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4921 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4922 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4924 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4931 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4934 mParentLayerComboBox->addItem( initialParent, initialParent );
4935 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4938 vlayout->addWidget( mParentLayerComboBox );
4941 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4942 mDataTypeComboBox =
new QComboBox();
4950 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast<int>( fieldParam->dataType() ) ) );
4952 vlayout->addWidget( mDataTypeComboBox );
4955 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4957 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4959 vlayout->addWidget( mAllowMultipleCheckBox );
4964 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4965 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4967 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4969 vlayout->addWidget( mDefaultToAllCheckBox );
4972 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [
this] {
4973 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4976 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4978 mDefaultLineEdit =
new QLineEdit();
4979 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4983 mDefaultLineEdit->setText( fields.join(
';' ) );
4985 vlayout->addWidget( mDefaultLineEdit );
4989 setLayout( vlayout );
4996 QVariant defaultValue;
4997 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4999 defaultValue = mDefaultLineEdit->text();
5001 auto param = std::make_unique<QgsProcessingParameterField>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
5003 return param.release();
5011QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
5024 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
5025 mPanel->setToolTip( parameterDefinition()->toolTip() );
5026 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [
this] {
5027 emit widgetValueHasChanged(
this );
5047 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5049 emit widgetValueHasChanged(
this );
5057 mLineEdit =
new QLineEdit();
5058 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
5059 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
5060 emit widgetValueHasChanged(
this );
5068void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5080 setParentLayerWrapperValue( wrapper );
5082 setParentLayerWrapperValue( wrapper );
5099 std::unique_ptr<QgsProcessingContext> tmpContext;
5100 if ( mProcessingContextGenerator )
5101 context = mProcessingContextGenerator->processingContext();
5105 tmpContext = std::make_unique<QgsProcessingContext>();
5106 context = tmpContext.get();
5111 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
5121 bool valueSet =
false;
5125 if ( layers.count() > 1 )
5127 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5129 const QList<QgsMapLayer *> remainingLayers = layers.mid( 1 );
5135 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
5136 if ( !vlayer || !vlayer->
isValid() )
5142 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
5145 fields.
remove( fieldIdx );
5150 mComboBox->setFields( fields );
5152 mPanel->setFields( filterFields( fields ) );
5158 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
5160 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5164 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
5167 mParentLayer.reset( qobject_cast<QgsVectorLayer *>( ownedLayer.release() ) );
5168 layer = mParentLayer.get();
5176 mComboBox->setLayer( layer );
5178 mPanel->setFields( filterFields( layer->
fields() ) );
5188 const QgsFields fields = source->fields();
5190 mComboBox->setFields( fields );
5192 mPanel->setFields( filterFields( fields ) );
5201 mComboBox->setLayer(
nullptr );
5205 if ( value.isValid() && widgetContext().messageBar() )
5217 val.reserve( mPanel->fields().size() );
5218 for (
const QgsField &field : mPanel->fields() )
5219 val << field.name();
5220 setWidgetValue( val, *context );
5223 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5226void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5230 if ( !value.isValid() )
5231 mComboBox->setField( QString() );
5235 mComboBox->setField( v );
5241 if ( value.isValid() )
5244 opts.reserve( v.size() );
5245 for (
const QString &i : v )
5249 mPanel->setValue( opts );
5251 else if ( mLineEdit )
5257 mLineEdit->setText( v.join(
';' ) );
5266QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
5269 return mComboBox->currentField();
5271 return mPanel->value();
5272 else if ( mLineEdit )
5277 return mLineEdit->text().split(
';' );
5280 return mLineEdit->text();
5286QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
5288 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
5291const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
5293 if ( mComboBox && mComboBox->layer() )
5294 return mComboBox->layer();
5299QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
5312 if ( f.isNumeric() )
5317 if ( f.type() == QMetaType::Type::QString )
5322 if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
5327 if ( f.type() == QMetaType::Type::QByteArray )
5332 if ( f.type() == QMetaType::Type::Bool )
5341QString QgsProcessingFieldWidgetWrapper::parameterType()
const
5348 return new QgsProcessingFieldWidgetWrapper( parameter, type );
5353 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5364 QVBoxLayout *vlayout =
new QVBoxLayout();
5365 vlayout->setContentsMargins( 0, 0, 0, 0 );
5367 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5369 mDefaultComboBox =
new QComboBox();
5370 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
5373 for (
const QString &theme : mapThemes )
5377 mDefaultComboBox->setEditable(
true );
5381 if ( themeParam->defaultValueForGui().isValid() )
5384 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5387 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5389 vlayout->addWidget( mDefaultComboBox );
5393 setLayout( vlayout );
5398 QVariant defaultVal;
5399 if ( mDefaultComboBox->currentText().isEmpty() )
5400 defaultVal = QVariant();
5402 defaultVal = mDefaultComboBox->currentText();
5403 auto param = std::make_unique<QgsProcessingParameterMapTheme>( name, description, defaultVal );
5405 return param.release();
5414QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
5420 mComboBox =
new QComboBox();
5423 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
5426 for (
const QString &theme : mapThemes )
5438 mComboBox->setEditable(
true );
5442 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5443 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
5444 emit widgetValueHasChanged(
this );
5450void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5454 if ( !value.isValid() )
5455 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5458 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5460 const QString prev = mComboBox->currentText();
5461 mComboBox->setCurrentText( v );
5463 emit widgetValueHasChanged(
this );
5466 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5470QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5473 return mComboBox->currentData().toInt() == -1 ? QVariant() : !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5474 : mComboBox->currentData();
5479QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5481 return tr(
"map theme as a string value (e.g. 'base maps')" );
5484QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5491 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5496 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5508 QVBoxLayout *vlayout =
new QVBoxLayout();
5509 vlayout->setContentsMargins( 0, 0, 0, 0 );
5511 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5513 mTypeComboBox =
new QComboBox();
5518 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( datetimeParam->dataType() ) ) );
5520 mTypeComboBox->setCurrentIndex( 0 );
5521 vlayout->addWidget( mTypeComboBox );
5525 setLayout( vlayout );
5530 auto param = std::make_unique<QgsProcessingParameterDateTime>( name, description );
5533 return param.release();
5542QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5545 if ( !dateTimeParam )
5549 switch ( dateTimeParam->
dataType() )
5553 widget = mDateTimeEdit;
5578 widget->setToolTip( parameterDefinition()->toolTip() );
5580 if ( mDateTimeEdit )
5583 emit widgetValueHasChanged(
this );
5586 else if ( mDateEdit )
5589 emit widgetValueHasChanged(
this );
5592 else if ( mTimeEdit )
5595 emit widgetValueHasChanged(
this );
5604 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5607void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5609 if ( mDateTimeEdit )
5613 else if ( mDateEdit )
5617 else if ( mTimeEdit )
5623QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5625 if ( mDateTimeEdit )
5626 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5627 else if ( mDateEdit )
5628 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5629 else if ( mTimeEdit )
5630 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5635QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5638 if ( dateTimeParam )
5640 switch ( dateTimeParam->
dataType() )
5643 return tr(
"datetime value, or a ISO string representation of a datetime" );
5646 return tr(
"date value, or a ISO string representation of a date" );
5649 return tr(
"time value, or a ISO string representation of a time" );
5655QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5662 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5675 QVBoxLayout *vlayout =
new QVBoxLayout();
5676 vlayout->setContentsMargins( 0, 0, 0, 0 );
5678 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5679 mProviderComboBox =
new QComboBox();
5680 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), u
"postgres"_s );
5681 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), u
"ogr"_s );
5682 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), u
"spatialite"_s );
5684 vlayout->addWidget( mProviderComboBox );
5686 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5688 mDefaultEdit =
new QLineEdit();
5689 vlayout->addWidget( mDefaultEdit );
5690 setLayout( vlayout );
5692 if ( connectionParam )
5694 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5704 QVariant defaultVal;
5705 if ( mDefaultEdit->text().isEmpty() )
5706 defaultVal = QVariant();
5708 defaultVal = mDefaultEdit->text();
5709 auto param = std::make_unique<QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5711 return param.release();
5720QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5723 if ( !connectionParam )
5728 mProviderComboBox->setAllowEmptyConnection(
true );
5736 mProviderComboBox->setEditable(
true );
5740 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5741 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [
this](
const QString & ) {
5742 if ( mBlockSignals )
5745 emit widgetValueHasChanged(
this );
5748 return mProviderComboBox;
5753 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5756void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5760 if ( !value.isValid() )
5761 mProviderComboBox->setCurrentIndex( -1 );
5764 if ( mProviderComboBox->isEditable() )
5766 const QString prev = mProviderComboBox->currentText();
5768 mProviderComboBox->setConnection( v );
5769 mProviderComboBox->setCurrentText( v );
5773 emit widgetValueHasChanged(
this );
5776 mProviderComboBox->setConnection( v );
5780QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5782 if ( mProviderComboBox )
5783 if ( mProviderComboBox->isEditable() )
5784 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5786 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5791QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5793 return tr(
"connection name as a string value" );
5796QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5803 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5816 QVBoxLayout *vlayout =
new QVBoxLayout();
5817 vlayout->setContentsMargins( 0, 0, 0, 0 );
5819 mConnectionParamComboBox =
new QComboBox();
5820 QString initialConnection;
5826 if (
auto *lModel = widgetContext.
model() )
5829 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5830 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5832 if ( definition && it->parameterName() == definition->
name() )
5838 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5839 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5841 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5846 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5849 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5850 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5853 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5854 vlayout->addWidget( mConnectionParamComboBox );
5858 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5860 mDefaultEdit =
new QLineEdit();
5861 vlayout->addWidget( mDefaultEdit );
5862 setLayout( vlayout );
5873 QVariant defaultVal;
5874 if ( mDefaultEdit->text().isEmpty() )
5875 defaultVal = QVariant();
5877 defaultVal = mDefaultEdit->text();
5878 auto param = std::make_unique<QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5880 return param.release();
5889QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5897 mSchemaComboBox->setAllowEmptySchema(
true );
5905 mSchemaComboBox->comboBox()->setEditable(
true );
5909 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5910 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
5911 if ( mBlockSignals )
5914 emit widgetValueHasChanged( this );
5917 return mSchemaComboBox;
5922 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5929 std::unique_ptr<QgsProcessingContext> tmpContext;
5930 if ( mProcessingContextGenerator )
5931 context = mProcessingContextGenerator->processingContext();
5935 tmpContext = std::make_unique<QgsProcessingContext>();
5936 context = tmpContext.get();
5942 if ( mSchemaComboBox )
5943 mSchemaComboBox->setConnectionName( connection, qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId() );
5947 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5950void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5954 if ( !value.isValid() )
5955 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5958 if ( mSchemaComboBox->comboBox()->isEditable() )
5960 const QString prev = mSchemaComboBox->comboBox()->currentText();
5962 mSchemaComboBox->setSchema( v );
5963 mSchemaComboBox->comboBox()->setCurrentText( v );
5967 emit widgetValueHasChanged(
this );
5970 mSchemaComboBox->setSchema( v );
5974QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5976 if ( mSchemaComboBox )
5977 if ( mSchemaComboBox->comboBox()->isEditable() )
5978 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5980 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5985QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5987 return tr(
"database schema name as a string value" );
5990QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5997 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
6000void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6012 setParentConnectionWrapperValue( wrapper );
6014 setParentConnectionWrapperValue( wrapper );
6037 QVBoxLayout *vlayout =
new QVBoxLayout();
6038 vlayout->setContentsMargins( 0, 0, 0, 0 );
6040 mConnectionParamComboBox =
new QComboBox();
6041 mSchemaParamComboBox =
new QComboBox();
6042 QString initialConnection;
6043 QString initialSchema;
6050 if (
auto *lModel = widgetContext.
model() )
6053 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6054 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6056 if ( definition && it->parameterName() == definition->
name() )
6061 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
6062 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6064 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6069 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
6070 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6072 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6078 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
6081 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
6082 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6085 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
6088 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
6089 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6092 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
6093 vlayout->addWidget( mConnectionParamComboBox );
6095 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
6096 vlayout->addWidget( mSchemaParamComboBox );
6101 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6103 mDefaultEdit =
new QLineEdit();
6104 vlayout->addWidget( mDefaultEdit );
6105 setLayout( vlayout );
6116 QVariant defaultVal;
6117 if ( mDefaultEdit->text().isEmpty() )
6118 defaultVal = QVariant();
6120 defaultVal = mDefaultEdit->text();
6121 auto param = std::make_unique<QgsProcessingParameterDatabaseTable>( name, description, mConnectionParamComboBox->currentData().toString(), mSchemaParamComboBox->currentData().toString(), defaultVal );
6123 return param.release();
6132QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
6140 mTableComboBox->setAllowEmptyTable(
true );
6143 mTableComboBox->comboBox()->setEditable(
true );
6145 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
6146 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
6147 if ( mBlockSignals )
6150 emit widgetValueHasChanged( this );
6153 return mTableComboBox;
6158 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6165 std::unique_ptr<QgsProcessingContext> tmpContext;
6166 if ( mProcessingContextGenerator )
6167 context = mProcessingContextGenerator->processingContext();
6171 tmpContext = std::make_unique<QgsProcessingContext>();
6172 context = tmpContext.get();
6177 mProvider = qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId();
6178 if ( mTableComboBox && !mSchema.isEmpty() )
6180 mTableComboBox->setSchema( mSchema );
6181 mTableComboBox->setConnectionName( mConnection, mProvider );
6185 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6193 std::unique_ptr<QgsProcessingContext> tmpContext;
6194 if ( mProcessingContextGenerator )
6195 context = mProcessingContextGenerator->processingContext();
6199 tmpContext = std::make_unique<QgsProcessingContext>();
6200 context = tmpContext.get();
6206 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
6208 mTableComboBox->setSchema( mSchema );
6209 mTableComboBox->setConnectionName( mConnection, mProvider );
6211 const QgsProcessingParameterDatabaseTable *tableParam = static_cast<const QgsProcessingParameterDatabaseTable *>( parameterDefinition() );
6212 if ( tableParam->defaultValueForGui().isValid() )
6213 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6217void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6221 if ( !value.isValid() )
6222 mTableComboBox->comboBox()->setCurrentIndex( -1 );
6225 if ( mTableComboBox->comboBox()->isEditable() )
6227 const QString prev = mTableComboBox->comboBox()->currentText();
6229 mTableComboBox->setTable( v );
6230 mTableComboBox->comboBox()->setCurrentText( v );
6234 emit widgetValueHasChanged(
this );
6237 mTableComboBox->setTable( v );
6241QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
6243 if ( mTableComboBox )
6244 if ( mTableComboBox->comboBox()->isEditable() )
6245 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
6247 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
6252QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
6254 return tr(
"database table name as a string value" );
6257QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
6264 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
6267void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6279 setParentConnectionWrapperValue( wrapper );
6281 setParentConnectionWrapperValue( wrapper );
6286 setParentSchemaWrapperValue( wrapper );
6288 setParentSchemaWrapperValue( wrapper );
6308 QVBoxLayout *vlayout =
new QVBoxLayout();
6309 vlayout->setContentsMargins( 0, 0, 0, 0 );
6311 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6314 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6317 if ( extentParam->defaultValueForGui().isValid() )
6321 mDefaultWidget->setCurrentExtent( rect, crs );
6322 mDefaultWidget->setOutputExtentFromCurrent();
6326 mDefaultWidget->clear();
6332 vlayout->addWidget( mDefaultWidget );
6333 setLayout( vlayout );
6338 const QString defaultVal = mDefaultWidget->isValid() ? u
"%1,%2,%3,%4%5"_s.arg( QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ), QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ), QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ), QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ), mDefaultWidget->outputCrs().isValid() ? u
" [%1]"_s.arg( mDefaultWidget->outputCrs().authid() ) : QString() ) : QString();
6339 auto param = std::make_unique<QgsProcessingParameterExtent>( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
6341 return param.release();
6350QWidget *QgsProcessingExtentWidgetWrapper::createWidget()
6363 if ( widgetContext().mapCanvas() )
6364 mExtentWidget->setMapCanvas( widgetContext().mapCanvas() );
6367 mExtentWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6369 mExtentWidget->setToolTip( parameterDefinition()->toolTip() );
6372 emit widgetValueHasChanged(
this );
6376 setDialog( mDialog );
6378 return mExtentWidget;
6388 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6391void QgsProcessingExtentWidgetWrapper::setDialog( QDialog *dialog )
6398 mDialog->showMinimized();
6401 mDialog->showNormal();
6403 mDialog->activateWindow();
6410void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6412 if ( mExtentWidget )
6414 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
6415 mExtentWidget->clear();
6420 mExtentWidget->setCurrentExtent( r, crs );
6421 mExtentWidget->setOutputExtentFromUser( r, crs );
6426QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6428 if ( mExtentWidget )
6430 const QString val = mExtentWidget->isValid() ? u
"%1,%2,%3,%4%5"_s.arg( QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ), QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ), QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ), QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ), mExtentWidget->outputCrs().isValid() ? u
" [%1]"_s.arg( mExtentWidget->outputCrs().authid() ) : QString() ) : QString();
6432 return val.isEmpty() ? QVariant() : QVariant( val );
6438QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6440 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6443QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6450 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6455 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6466 QVBoxLayout *vlayout =
new QVBoxLayout();
6467 vlayout->setContentsMargins( 0, 0, 0, 0 );
6469 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6485 for (
int i : layerParam->dataTypes() )
6487 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6491 vlayout->addWidget( mLayerTypeComboBox );
6495 setLayout( vlayout );
6500 QList<int> dataTypes;
6501 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6502 dataTypes << v.toInt();
6504 auto param = std::make_unique<QgsProcessingParameterMapLayer>( name, description );
6505 param->setDataTypes( dataTypes );
6507 return param.release();
6515QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6517 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6525 mComboBox->setEditable(
true );
6529 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6531 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [
this]() {
6532 if ( mBlockSignals )
6535 emit widgetValueHasChanged(
this );
6538 setWidgetContext( widgetContext() );
6547 mComboBox->setWidgetContext( context );
6552 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6558void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6561 mComboBox->setValue( value, context );
6564QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6566 return mComboBox ? mComboBox->value() : QVariant();
6569QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6571 return tr(
"path to a map layer" );
6588QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6595 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6600 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6609 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6613QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6615 return tr(
"path to a raster layer" );
6618QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6625 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6630 Q_UNUSED( context );
6631 Q_UNUSED( widgetContext );
6632 Q_UNUSED( definition );
6646 QVBoxLayout *vlayout =
new QVBoxLayout();
6647 vlayout->setContentsMargins( 0, 0, 0, 0 );
6649 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6659 for (
int i : vectorParam->dataTypes() )
6661 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6665 vlayout->addWidget( mGeometryTypeComboBox );
6669 setLayout( vlayout );
6674 QList<int> dataTypes;
6675 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6676 dataTypes << v.toInt();
6678 auto param = std::make_unique<QgsProcessingParameterVectorLayer>( name, description, dataTypes );
6680 return param.release();
6685 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6689QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6691 return tr(
"path to a vector layer" );
6694QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6701 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6706 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6717 QVBoxLayout *vlayout =
new QVBoxLayout();
6718 vlayout->setContentsMargins( 0, 0, 0, 0 );
6720 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6730 for (
int i : sourceParam->dataTypes() )
6732 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6740 vlayout->addWidget( mGeometryTypeComboBox );
6743 setLayout( vlayout );
6748 QList<int> dataTypes;
6749 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6750 dataTypes << v.toInt();
6752 auto param = std::make_unique<QgsProcessingParameterFeatureSource>( name, description, dataTypes );
6754 return param.release();
6758 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6762QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6764 return tr(
"path to a vector layer" );
6767QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6774 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6779 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6787 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6791QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6793 return tr(
"path to a mesh layer" );
6796QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6803 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6808 Q_UNUSED( context );
6809 Q_UNUSED( widgetContext );
6810 Q_UNUSED( definition );
6821QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6825 QHBoxLayout *hl =
new QHBoxLayout();
6826 hl->setContentsMargins( 0, 0, 0, 0 );
6828 mLineEdit =
new QLineEdit();
6829 mLineEdit->setEnabled(
false );
6830 hl->addWidget( mLineEdit, 1 );
6832 mToolButton =
new QToolButton();
6833 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6834 hl->addWidget( mToolButton );
6840 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6843 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6846void QgsProcessingRasterBandPanelWidget::setBands(
const QList<int> &bands )
6851void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6856void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6858 if ( value.isValid() )
6859 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
6863 updateSummaryText();
6867void QgsProcessingRasterBandPanelWidget::showDialog()
6869 QVariantList availableOptions;
6870 availableOptions.reserve( mBands.size() );
6871 for (
int band : std::as_const( mBands ) )
6873 availableOptions << band;
6879 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6880 widget->setPanelTitle( mParam->description() );
6882 widget->setValueFormatter( [
this](
const QVariant &v ) -> QString {
6883 int band = v.toInt();
6884 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6887 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
6888 setValue( widget->selectedOptions() );
6895 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6897 dlg.setValueFormatter( [
this](
const QVariant &v ) -> QString {
6898 int band = v.toInt();
6899 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6903 setValue( dlg.selectedOptions() );
6908void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6911 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6922 QVBoxLayout *vlayout =
new QVBoxLayout();
6923 vlayout->setContentsMargins( 0, 0, 0, 0 );
6925 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6927 mDefaultLineEdit =
new QLineEdit();
6928 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6933 for (
int b : bands )
6935 defVal << QString::number( b );
6938 mDefaultLineEdit->setText( defVal.join(
';' ) );
6940 vlayout->addWidget( mDefaultLineEdit );
6943 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6944 mParentLayerComboBox =
new QComboBox();
6946 QString initialParent;
6948 initialParent = bandParam->parentLayerParameterName();
6950 if (
auto *lModel = widgetContext.
model() )
6953 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6954 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6958 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
6959 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6961 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6967 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6970 mParentLayerComboBox->addItem( initialParent, initialParent );
6971 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6975 vlayout->addWidget( mParentLayerComboBox );
6977 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6979 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
6982 vlayout->addWidget( mAllowMultipleCheckBox );
6983 setLayout( vlayout );
6988 auto param = std::make_unique<QgsProcessingParameterBand>( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
6990 return param.release();
6998QWidget *QgsProcessingBandWidgetWrapper::createWidget()
7011 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
7012 mPanel->setToolTip( parameterDefinition()->toolTip() );
7013 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [
this] {
7014 emit widgetValueHasChanged(
this );
7023 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7025 emit widgetValueHasChanged(
this );
7033 mLineEdit =
new QLineEdit();
7034 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
7035 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
7036 emit widgetValueHasChanged(
this );
7044void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7056 setParentLayerWrapperValue( wrapper );
7058 setParentLayerWrapperValue( wrapper );
7075 std::unique_ptr<QgsProcessingContext> tmpContext;
7076 if ( mProcessingContextGenerator )
7077 context = mProcessingContextGenerator->processingContext();
7081 tmpContext = std::make_unique<QgsProcessingContext>();
7082 context = tmpContext.get();
7088 if ( layer && layer->
isValid() )
7092 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
7095 mParentLayer.reset( qobject_cast<QgsRasterLayer *>( ownedLayer.release() ) );
7096 layer = mParentLayer.get();
7104 mComboBox->setLayer( layer );
7108 if ( provider && layer->
isValid() )
7113 QHash<int, QString> bandNames;
7114 for (
int i = 1; i <= nBands; ++i )
7119 mPanel->setBands( bands );
7120 mPanel->setBandNames( bandNames );
7127 mComboBox->setLayer(
nullptr );
7129 mPanel->setBands( QList<int>() );
7131 if ( value.isValid() && widgetContext().messageBar() )
7138 if ( parameterDefinition()->defaultValueForGui().isValid() )
7139 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7142void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7146 if ( !value.isValid() )
7147 mComboBox->setBand( -1 );
7151 mComboBox->setBand( v );
7157 if ( value.isValid() )
7160 opts.reserve( v.size() );
7165 mPanel->setValue( value.isValid() ? opts : QVariant() );
7167 else if ( mLineEdit )
7174 opts.reserve( v.size() );
7176 opts << QString::number( i );
7177 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
7181 if ( value.isValid() )
7189QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
7192 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
7194 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7195 else if ( mLineEdit )
7200 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
7202 res.reserve( parts.count() );
7203 for (
const QString &s : parts )
7206 int band = s.toInt( &ok );
7210 return res.
isEmpty() ? QVariant() : res;
7214 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7221QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7223 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7226QString QgsProcessingBandWidgetWrapper::parameterType()
const
7233 return new QgsProcessingBandWidgetWrapper( parameter, type );
7238 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7249 setAcceptDrops(
true );
7252void QgsProcessingMultipleLayerLineEdit::dragEnterEvent( QDragEnterEvent *event )
7254 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7255 if ( !uris.isEmpty() )
7257 event->setDropAction( Qt::CopyAction );
7259 setHighlighted(
true );
7267void QgsProcessingMultipleLayerLineEdit::dragLeaveEvent( QDragLeaveEvent *event )
7269 QgsHighlightableLineEdit::dragLeaveEvent( event );
7271 setHighlighted(
false );
7274void QgsProcessingMultipleLayerLineEdit::dropEvent( QDropEvent *event )
7276 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7277 if ( !uris.isEmpty() )
7279 event->setDropAction( Qt::CopyAction );
7281 QVariantList uriList;
7282 uriList.reserve( uris.size() );
7283 for (
const QString &uri : uris )
7284 uriList.append( QVariant( uri ) );
7285 emit layersDropped( uriList );
7288 setHighlighted(
false );
7299 QHBoxLayout *hl =
new QHBoxLayout();
7300 hl->setContentsMargins( 0, 0, 0, 0 );
7302 mLineEdit =
new QgsProcessingMultipleLayerLineEdit(
nullptr, param );
7303 mLineEdit->setEnabled(
true );
7304 mLineEdit->setReadOnly(
true );
7306 hl->addWidget( mLineEdit, 1 );
7307 connect( mLineEdit, &QgsProcessingMultipleLayerLineEdit::layersDropped,
this, &QgsProcessingMultipleLayerPanelWidget::setValue );
7309 mToolButton =
new QToolButton();
7310 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7311 hl->addWidget( mToolButton );
7317 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7320 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7323void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7325 if ( value.isValid() )
7326 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7330 updateSummaryText();
7334void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7340 if ( mValue.removeAll( layerId ) )
7342 updateSummaryText();
7349void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7355 switch ( mParam->layerType() )
7443void QgsProcessingMultipleLayerPanelWidget::showDialog()
7448 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel,
nullptr );
7449 widget->setPanelTitle( mParam->description() );
7450 widget->setProject( mProject );
7451 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
7452 setValue( widget->selectedOptions() );
7459 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7460 dlg.setProject( mProject );
7463 setValue( dlg.selectedOptions() );
7468void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7471 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7481 QVBoxLayout *vlayout =
new QVBoxLayout();
7482 vlayout->setContentsMargins( 0, 0, 0, 0 );
7484 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7485 mLayerTypeComboBox =
new QComboBox();
7499 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast<int>( layersParam->layerType() ) ) );
7501 vlayout->addWidget( mLayerTypeComboBox );
7504 setLayout( vlayout );
7509 auto param = std::make_unique<QgsProcessingParameterMultipleLayers>( name, description,
static_cast<Qgis::ProcessingSourceType>( mLayerTypeComboBox->currentData().toInt() ) );
7511 return param.release();
7519QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7523 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7524 mPanel->setToolTip( parameterDefinition()->toolTip() );
7525 mPanel->setProject( widgetContext().project() );
7527 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7528 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [
this] {
7529 emit widgetValueHasChanged(
this );
7539 mPanel->setProject( context.
project() );
7541 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7545void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7550 if ( value.isValid() )
7553 opts.reserve( v.size() );
7555 opts << l->source();
7558 for (
const QVariant &v : value.toList() )
7560 if ( v.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
7562 const QgsProcessingModelChildParameterSource source = v.value<QgsProcessingModelChildParameterSource>();
7563 opts << QVariant::fromValue( source );
7568 mPanel->setValue( value.isValid() ? opts : QVariant() );
7572QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7575 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7580QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7582 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7585QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7592 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7597 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7606 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7610QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7612 return tr(
"path to a point cloud layer" );
7615QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7622 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7627 Q_UNUSED( context );
7628 Q_UNUSED( widgetContext );
7629 Q_UNUSED( definition );
7645QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7647 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7650QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7657 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7662 Q_UNUSED( context );
7663 Q_UNUSED( widgetContext );
7664 Q_UNUSED( definition );
7675 if ( mWidgetContext.project() )
7676 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7680QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7691 mComboBox->setEditable(
true );
7695 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7697 if ( mWidgetContext.project() )
7698 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7701 mComboBox->setAllowEmptyLayer(
true );
7704 if ( mBlockSignals )
7707 emit widgetValueHasChanged(
this );
7710 setWidgetContext( widgetContext() );
7714void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7720 mComboBox->setLayer(
nullptr );
7724 QVariant val = value;
7725 if ( val.userType() == qMetaTypeId<QgsProperty>() )
7737 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( val.value<QObject *>() );
7738 if ( !layer && val.userType() == QMetaType::Type::QString )
7745 mComboBox->setLayer( layer );
7750QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7752 return mComboBox && mComboBox->currentLayer() ? ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? u
"main"_s : mComboBox->currentLayer()->id() ) : mComboBox->currentLayer()->id() )
7765 QHBoxLayout *hl =
new QHBoxLayout();
7766 hl->setContentsMargins( 0, 0, 0, 0 );
7768 mLineEdit =
new QLineEdit();
7769 mLineEdit->setEnabled(
false );
7770 hl->addWidget( mLineEdit, 1 );
7772 mToolButton =
new QToolButton();
7773 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7774 hl->addWidget( mToolButton );
7780 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7783 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7788 mAttributes = attributes;
7791void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7793 if ( value.isValid() )
7794 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7798 updateSummaryText();
7802void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7804 QVariantList availableOptions;
7805 availableOptions.reserve( mAttributes.count() );
7806 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7809 availableOptions << attr.name();
7815 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7816 widget->setPanelTitle( mParam->description() );
7818 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
7819 return v.toString();
7822 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() {
7823 setValue( widget->selectedOptions() );
7830 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7832 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
7833 return v.toString();
7837 setValue( dlg.selectedOptions() );
7842void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7847 if ( mValue.empty() )
7849 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7854 values.reserve( mValue.size() );
7855 for (
const QVariant &val : std::as_const( mValue ) )
7857 values << val.toString();
7860 const QString concatenated = values.join( tr(
"," ) );
7861 if ( concatenated.length() < 100 )
7862 mLineEdit->setText( concatenated );
7864 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7876 QVBoxLayout *vlayout =
new QVBoxLayout();
7877 vlayout->setContentsMargins( 0, 0, 0, 0 );
7879 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7880 mParentLayerComboBox =
new QComboBox();
7882 QString initialParent;
7884 initialParent = attrParam->parentLayerParameterName();
7886 if (
auto *lModel = widgetContext.
model() )
7889 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7890 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7894 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
7895 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7897 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7903 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
7906 mParentLayerComboBox->addItem( initialParent, initialParent );
7907 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
7910 vlayout->addWidget( mParentLayerComboBox );
7914 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
7916 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
7918 vlayout->addWidget( mAllowMultipleCheckBox );
7921 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
7922 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7924 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
7928 vlayout->addWidget( mDefaultToAllCheckBox );
7930 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [
this] {
7931 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
7934 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
7936 mDefaultLineEdit =
new QLineEdit();
7937 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
7941 mDefaultLineEdit->setText( attributes.join(
';' ) );
7943 vlayout->addWidget( mDefaultLineEdit );
7947 setLayout( vlayout );
7952 QVariant defaultValue;
7953 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
7955 defaultValue = mDefaultLineEdit->text();
7957 auto param = std::make_unique<QgsProcessingParameterPointCloudAttribute>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
7959 return param.release();
7967QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
7980 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
7981 mPanel->setToolTip( parameterDefinition()->toolTip() );
7982 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [
this] {
7983 emit widgetValueHasChanged(
this );
7991 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7993 emit widgetValueHasChanged(
this );
8001 mLineEdit =
new QLineEdit();
8002 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
8003 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] {
8004 emit widgetValueHasChanged(
this );
8012void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
8024 setParentLayerWrapperValue( wrapper );
8026 setParentLayerWrapperValue( wrapper );
8043 std::unique_ptr<QgsProcessingContext> tmpContext;
8044 if ( mProcessingContextGenerator )
8045 context = mProcessingContextGenerator->processingContext();
8049 tmpContext = std::make_unique<QgsProcessingContext>();
8050 context = tmpContext.get();
8056 if ( layer && layer->
isValid() )
8060 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
8063 mParentLayer.reset( qobject_cast<QgsPointCloudLayer *>( ownedLayer.release() ) );
8064 layer = mParentLayer.get();
8072 mComboBox->setLayer( layer );
8075 mPanel->setAttributes( layer->
attributes() );
8082 mComboBox->setLayer(
nullptr );
8087 if ( value.isValid() && widgetContext().messageBar() )
8098 val.reserve( mPanel->attributes().attributes().size() );
8101 setWidgetValue( val, *context );
8104 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
8107void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8111 if ( !value.isValid() )
8112 mComboBox->setAttribute( QString() );
8116 mComboBox->setAttribute( v );
8122 if ( value.isValid() )
8125 opts.reserve( v.size() );
8126 for (
const QString &i : v )
8130 mPanel->setValue( opts );
8132 else if ( mLineEdit )
8138 mLineEdit->setText( v.join(
';' ) );
8147QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
8150 return mComboBox->currentAttribute();
8152 return mPanel->value();
8153 else if ( mLineEdit )
8158 return mLineEdit->text().split(
';' );
8161 return mLineEdit->text();
8167QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
8169 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
8172QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
8179 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
8184 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8197QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8205 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8206 if ( mProcessingContextGenerator )
8207 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8208 if ( mParametersGenerator )
8209 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8210 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8212 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [
this]() {
8213 if ( mBlockSignals )
8216 emit widgetValueHasChanged(
this );
8221 mOutputWidget->addOpenAfterRunningOption();
8223 return mOutputWidget;
8233void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8235 if ( mOutputWidget )
8236 mOutputWidget->setValue( value );
8239QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8241 if ( mOutputWidget )
8242 return mOutputWidget->value();
8247QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8250 if ( mOutputWidget )
8251 res.insert( u
"OPEN_AFTER_RUNNING"_s, mOutputWidget->openAfterRunning() );
8260 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8264QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8271 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8274QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8276 return tr(
"path to layer destination" );
8284 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8288QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8295 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8298QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8300 return tr(
"path to layer destination" );
8308 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8312QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8319 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8322QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8324 return tr(
"path to layer destination" );
8332 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8336QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8343 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8346QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8348 return tr(
"path to layer destination" );
8356 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8360QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8367 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8371QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8373 return tr(
"path to file destination" );
8381 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8385QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8392 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8396QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8398 return tr(
"path to folder destination" );
8406 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8410QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8417 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8420QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8422 return tr(
"path to layer destination" );
@ Standard
Unit is a standard measurement unit.
ProcessingSourceType
Processing data source types.
@ File
Files (i.e. non map layer sources, such as text files).
@ TiledScene
Tiled scene layers.
@ Annotation
Annotation layers.
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ VectorTile
Vector tile layers.
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer).
@ VectorAnyGeometry
Any vector layer with geometry.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ PointCloud
Point cloud layers.
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
@ File
Parameter is a single file.
@ Folder
Parameter is a folder.
ExpressionType
Expression types.
@ RasterCalculator
Raster calculator expression.
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
ProcessingMode
Types of modes which Processing widgets can be created for.
@ Batch
Batch processing mode.
@ Standard
Standard (single-run) algorithm mode.
DistanceUnit
Units of distance.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ NauticalMiles
Nautical miles.
ProcessingFieldParameterDataType
Processing field parameter data types.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ Numeric
Accepts numeric fields.
@ DateTime
Accepts datetime fields.
@ SquareCentimeters
Square centimeters.
@ SquareInches
Square inches.
@ SquareNauticalMiles
Square nautical miles.
@ SquareMillimeters
Square millimeters.
@ SquareYards
Square yards.
@ SquareKilometers
Square kilometers.
@ SquareMeters
Square meters.
@ Unknown
Unknown areal unit.
@ SquareDegrees
Square degrees, for planar geographic CRS area measurements.
@ SquareMiles
Square miles.
@ Info
Information message.
@ AnnotationLayer
QgsAnnotationLayer.
TemporalUnit
Temporal units.
@ Milliseconds
Milliseconds.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
VolumeUnit
Units of volume.
@ CubicMeters
Cubic meters.
@ CubicDegrees
Cubic degrees, for planar geographic CRS volume measurements.
@ CubicDecimeter
Cubic decimeters.
@ Unknown
Unknown volume unit.
@ CubicCentimeter
Cubic Centimeters.
ProcessingModelChildParameterSource
Processing model child parameter sources.
@ ModelParameter
Parameter value is taken from a parent model parameter.
@ StaticValue
Parameter value is a static value.
@ Optional
Parameter is optional.
ProcessingDateTimeParameterDataType
Processing date time parameter data types.
@ DateTime
Datetime values.
ProcessingNumberParameterType
Processing numeric parameter data types.
@ Double
Double/float values.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
@ CapturePoint
Select and capture a point or a feature.
Selector widget for authentication configs.
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing.
QComboBox subclass which allows selecting multiple items.
void checkedItemsChanged(const QStringList &items)
Emitted whenever the checked items list changed.
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
A combo box which displays the list of schemas for a specific database connection.
A combobox which displays the list of tables for a specific database connection.
A QDateEdit widget with the capability of setting/reading null dates.
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
A QDateTimeEdit with the capability of setting/reading null date/times.
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
void setNullRepresentation(const QString &null)
Sets the widget's null representation, which defaults to QgsApplication::nullRepresentation().
void valueChanged(const QDateTime &date)
Signal emitted whenever the value changes.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
A widget which includes a line edit for entering expressions together with a button to open the expre...
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
A combobox which displays the list of fields of a given layer.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
@ DateTime
Datetime fields.
@ Date
Date or datetime fields.
@ Binary
Binary fields, since QGIS 3.34.
@ Boolean
Boolean fields, since QGIS 3.34.
@ Numeric
All numeric fields.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
void remove(int fieldIdx)
Removes the field with the given index.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A geometry is the spatial representation of a feature.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Q_INVOKABLE QString asWkt(int precision=17) const
Exports the geometry to WKT.
A QgsFilterLineEdit subclass with the ability to "highlight" the edges of the widget.
A combobox which displays available layouts from a QgsLayoutManager.
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
A combo box which displays items of a matching type from a layout.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
Base class for graphical items within a QgsLayout.
virtual QString uuid() const
Returns the item identification string.
@ FilterPrintLayouts
Includes print layouts.
QList< QgsPrintLayout * > printLayouts() const
Returns a list of all print layouts contained in the manager.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
A combobox which displays a dynamic list of layers from a QGIS project.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
Base class for all map layer types.
A mouse event which is the result of a user interaction with a QgsMapCanvas.
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Interface for master layout type objects, such as print layouts and reports.
virtual QString name() const =0
Returns the layout's name.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
bool clearWidgets()
Removes all items from the bar.
A collection of point cloud attributes.
A combobox which displays the list of attributes of a given point cloud layer.
void attributeChanged(const QString &name)
Emitted when the currently selected attribute changes.
Attribute for point cloud data pair of name and size in bytes.
Represents a map layer supporting display of point clouds.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes available from the layer.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
Base class for all parameter definitions which represent file or layer destinations,...
Encapsulates settings relating to a feature source input to a processing algorithm.
QgsProperty source
Source definition.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for area values.
Qgis::AreaUnit defaultUnit() const
Returns the default area unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A raster band parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
A boolean parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A color parameter for processing algorithms.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
static QString typeName()
Returns the type name for the parameter class.
A coordinate operation parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
QVariant sourceCrs() const
Returns the static source CRS, or an invalid value if this is not set.
QVariant destinationCrs() const
Returns the static destination CRS, or an invalid value if this is not set.
A coordinate reference system parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
A database table name parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
A datetime (or pure date or time) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
Base class for the definition of processing parameters.
void setFlags(Qgis::ProcessingParameterFlags flags)
Sets the flags associated with the parameter.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
QString description() const
Returns the description for the parameter.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
virtual QString type() const =0
Unique parameter type name.
QString name() const
Returns the name of the parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
A double numeric parameter for distance values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
A double numeric parameter for duration values.
Qgis::TemporalUnit defaultUnit() const
Returns the default duration unit for the parameter.
static QString typeName()
Returns the type name for the parameter class.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
static QString typeName()
Returns the type name for the parameter class.
An expression parameter for processing algorithms.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ExpressionType expressionType() const
Returns the parameter's expression type.
A rectangular map extent parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
An input feature source (such as vector layers) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A vector layer or feature source field parameter for processing algorithms.
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
static QString typeName()
Returns the type name for the parameter class.
A geometry parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A print layout item parameter, allowing users to select a particular item from a print layout.
static QString typeName()
Returns the type name for the parameter class.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
A print layout parameter, allowing users to select a print layout.
static QString typeName()
Returns the type name for the parameter class.
A map layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
static QString typeName()
Returns the type name for the parameter class.
A table (matrix) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
static QString typeName()
Returns the type name for the parameter class.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
double maximum() const
Returns the maximum value acceptable by the parameter.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer attribute parameter for Processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A point parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A data provider connection parameter for processing algorithms, allowing users to select from availab...
static QString typeName()
Returns the type name for the parameter class.
QString providerId() const
Returns the ID of the provider associated with the connections.
A numeric range parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
A raster layer parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for map scale values.
static QString typeName()
Returns the type name for the parameter class.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A vector layer (with or without geometry) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A double numeric parameter for volume values.
static QString typeName()
Returns the type name for the parameter class.
Qgis::VolumeUnit defaultUnit() const
Returns the default volume unit for the parameter.
Contains settings which reflect the context in which a Processing parameter widget is shown.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsProject * project() const
Returns the project associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
QgsMapLayer * activeLayer() const
Returns the current active layer.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a list of map layers.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QStringList parameterAsStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of strings (e.g.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a point cloud layer.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Utility functions for use with processing classes.
@ Annotation
Annotation layer type, since QGIS 3.22.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
void layerRemoved(const QString &layerId)
Emitted after a layer was removed from the registry.
A store for object properties.
Qgis::PropertyType propertyType() const
Returns the property type.
A combo box which displays the list of connections registered for a given provider.
A combobox widget which displays the bands present in a raster layer.
void bandChanged(int band)
Emitted when the currently selected band changes.
static QString displayBandName(QgsRasterDataProvider *provider, int band)
Returns a user-friendly band name for the specified band.
Base class for raster data providers.
virtual int bandCount() const =0
Gets number of bands.
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
A rectangle specified with double values.
A QgsGeometry with associated coordinate reference system.
Responsible for drawing transient features (e.g.
@ ICON_X
A cross is used to highlight points (x).
Stores settings for use within QGIS.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
A spin box with a clear button that will set the value to the defined clear value.
A QTimeEdit widget with the capability of setting/reading null date/times.
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE Qgis::DistanceUnitType unitType(Qgis::DistanceUnit unit)
Returns the type for a distance unit.
Represents a vector layer which manages a vector based dataset.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).