80#include <QButtonGroup>
85#include <QInputDialog>
90#include <QPlainTextEdit>
91#include <QRadioButton>
96#include "moc_qgsprocessingwidgetwrapperimpl.cpp"
98using namespace Qt::StringLiterals;
107QgsProcessingBooleanParameterDefinitionWidget::QgsProcessingBooleanParameterDefinitionWidget(
112 QVBoxLayout *vlayout =
new QVBoxLayout();
113 vlayout->setContentsMargins( 0, 0, 0, 0 );
115 mDefaultCheckBox =
new QCheckBox( tr(
"Checked" ) );
119 mDefaultCheckBox->setChecked(
false );
120 vlayout->addWidget( mDefaultCheckBox );
123 setLayout( vlayout );
128 auto param = std::make_unique<QgsProcessingParameterBoolean>( name, description, mDefaultCheckBox->isChecked() );
129 param->setFlags( flags );
130 return param.release();
138QWidget *QgsProcessingBooleanWidgetWrapper::createWidget()
144 QString description = parameterDefinition()->description();
146 description = QObject::tr(
"%1 [optional]" ).arg( description );
148 mCheckBox =
new QCheckBox( description );
149 mCheckBox->setToolTip( parameterDefinition()->toolTip() );
151 connect( mCheckBox, &QCheckBox::toggled,
this, [
this] { emit widgetValueHasChanged(
this ); } );
158 mComboBox =
new QComboBox();
159 mComboBox->addItem( tr(
"Yes" ),
true );
160 mComboBox->addItem( tr(
"No" ),
false );
161 mComboBox->setToolTip( parameterDefinition()->toolTip() );
163 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
171QLabel *QgsProcessingBooleanWidgetWrapper::createLabel()
180void QgsProcessingBooleanWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
187 mCheckBox->setChecked( v );
195 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
201QVariant QgsProcessingBooleanWidgetWrapper::widgetValue()
const
206 return mCheckBox->isChecked();
210 return mComboBox->currentData();
215QString QgsProcessingBooleanWidgetWrapper::parameterType()
const
222 return new QgsProcessingBooleanWidgetWrapper( parameter, type );
229 return new QgsProcessingBooleanParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
237QgsProcessingCrsParameterDefinitionWidget::QgsProcessingCrsParameterDefinitionWidget(
242 QVBoxLayout *vlayout =
new QVBoxLayout();
243 vlayout->setContentsMargins( 0, 0, 0, 0 );
245 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
250 mCrsSelector->setShowAccuracyWarnings(
true );
257 vlayout->addWidget( mCrsSelector );
258 setLayout( vlayout );
263 auto param = std::make_unique<QgsProcessingParameterCrs>( name, description, mCrsSelector->crs().authid() );
264 param->setFlags( flags );
265 return param.release();
272QWidget *QgsProcessingCrsWidgetWrapper::createWidget()
274 Q_ASSERT( mProjectionSelectionWidget ==
nullptr );
276 mProjectionSelectionWidget->setToolTip( parameterDefinition()->toolTip() );
290 return mProjectionSelectionWidget;
295 QWidget *w =
new QWidget();
296 w->setToolTip( parameterDefinition()->toolTip() );
298 QVBoxLayout *vl =
new QVBoxLayout();
299 vl->setContentsMargins( 0, 0, 0, 0 );
302 mUseProjectCrsCheckBox =
new QCheckBox( tr(
"Use project CRS" ) );
303 mUseProjectCrsCheckBox->setToolTip( tr(
"Always use the current project CRS when running the model" ) );
304 vl->addWidget( mUseProjectCrsCheckBox );
305 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled, mProjectionSelectionWidget, &QgsProjectionSelectionWidget::setDisabled );
306 connect( mUseProjectCrsCheckBox, &QCheckBox::toggled,
this, [
this] { emit widgetValueHasChanged(
this ); } );
308 vl->addWidget( mProjectionSelectionWidget );
316void QgsProcessingCrsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
318 if ( mUseProjectCrsCheckBox )
320 if ( value.toString().compare(
"ProjectCrs"_L1, Qt::CaseInsensitive ) == 0 )
322 mUseProjectCrsCheckBox->setChecked(
true );
327 mUseProjectCrsCheckBox->setChecked(
false );
332 if ( mProjectionSelectionWidget )
333 mProjectionSelectionWidget->setCrs( v );
336QVariant QgsProcessingCrsWidgetWrapper::widgetValue()
const
338 if ( mUseProjectCrsCheckBox && mUseProjectCrsCheckBox->isChecked() )
339 return u
"ProjectCrs"_s;
340 else if ( mProjectionSelectionWidget )
341 return mProjectionSelectionWidget->crs().isValid() ? mProjectionSelectionWidget->crs() : QVariant();
346QString QgsProcessingCrsWidgetWrapper::modelerExpressionFormatString()
const
348 return tr(
"string as EPSG code, WKT or PROJ format, or a string identifying a map layer" );
351QString QgsProcessingCrsWidgetWrapper::parameterType()
const
358 return new QgsProcessingCrsWidgetWrapper( parameter, type );
365 return new QgsProcessingCrsParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
374QgsProcessingStringParameterDefinitionWidget::QgsProcessingStringParameterDefinitionWidget(
379 QVBoxLayout *vlayout =
new QVBoxLayout();
380 vlayout->setContentsMargins( 0, 0, 0, 0 );
382 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
384 mDefaultLineEdit =
new QLineEdit();
387 vlayout->addWidget( mDefaultLineEdit );
391 mMultiLineCheckBox =
new QCheckBox( tr(
"Multiline input" ) );
393 mMultiLineCheckBox->setChecked( stringParam->multiLine() );
394 vlayout->addWidget( mMultiLineCheckBox );
398 setLayout( vlayout );
403 auto param = std::make_unique<QgsProcessingParameterString>( name, description, mDefaultLineEdit->text(), mMultiLineCheckBox->isChecked() );
404 param->setFlags( flags );
405 return param.release();
413QWidget *QgsProcessingStringWidgetWrapper::createWidget()
415 const QVariantMap metadata = parameterDefinition()->metadata();
416 const QVariant valueHintsVariant = metadata.value( u
"widget_wrapper"_s ).toMap().value( u
"value_hints"_s );
418 if ( valueHintsVariant.isValid() )
420 const QVariantList valueList = valueHintsVariant.toList();
421 mComboBox =
new QComboBox();
422 mComboBox->setToolTip( parameterDefinition()->toolTip() );
426 mComboBox->addItem( QString() );
428 for (
const QVariant &entry : valueList )
430 mComboBox->addItem( entry.toString(), entry.toString() );
432 mComboBox->setCurrentIndex( 0 );
434 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) { emit widgetValueHasChanged(
this ); } );
446 mPlainTextEdit =
new QPlainTextEdit();
447 mPlainTextEdit->setToolTip( parameterDefinition()->toolTip() );
449 connect( mPlainTextEdit, &QPlainTextEdit::textChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
450 return mPlainTextEdit;
454 mLineEdit =
new QLineEdit();
455 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
457 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
464 mLineEdit =
new QLineEdit();
465 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
467 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
476void QgsProcessingStringWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
480 mLineEdit->setText( v );
481 if ( mPlainTextEdit )
482 mPlainTextEdit->setPlainText( v );
486 if ( !value.isValid() )
487 index = mComboBox->findData( QVariant() );
489 index = mComboBox->findData( v );
492 mComboBox->setCurrentIndex( index );
494 mComboBox->setCurrentIndex( 0 );
498QVariant QgsProcessingStringWidgetWrapper::widgetValue()
const
501 return mLineEdit->text();
502 else if ( mPlainTextEdit )
503 return mPlainTextEdit->toPlainText();
504 else if ( mComboBox )
505 return mComboBox->currentData();
510QString QgsProcessingStringWidgetWrapper::parameterType()
const
517 return new QgsProcessingStringWidgetWrapper( parameter, type );
524 return new QgsProcessingStringParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
536QWidget *QgsProcessingAuthConfigWidgetWrapper::createWidget()
545 mAuthConfigSelect->setToolTip( parameterDefinition()->toolTip() );
548 return mAuthConfigSelect;
554void QgsProcessingAuthConfigWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
557 if ( mAuthConfigSelect )
558 mAuthConfigSelect->setConfigId( v );
561QVariant QgsProcessingAuthConfigWidgetWrapper::widgetValue()
const
563 if ( mAuthConfigSelect )
564 return mAuthConfigSelect->configId();
569QString QgsProcessingAuthConfigWidgetWrapper::parameterType()
const
576 return new QgsProcessingAuthConfigWidgetWrapper( parameter, type );
583QgsProcessingNumberParameterDefinitionWidget::QgsProcessingNumberParameterDefinitionWidget(
588 QVBoxLayout *vlayout =
new QVBoxLayout();
589 vlayout->setContentsMargins( 0, 0, 0, 0 );
591 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
593 mTypeComboBox =
new QComboBox();
596 vlayout->addWidget( mTypeComboBox );
598 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
599 mMinLineEdit =
new QLineEdit();
600 vlayout->addWidget( mMinLineEdit );
602 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
603 mMaxLineEdit =
new QLineEdit();
604 vlayout->addWidget( mMaxLineEdit );
606 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
607 mDefaultLineEdit =
new QLineEdit();
608 vlayout->addWidget( mDefaultLineEdit );
612 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( numberParam->dataType() ) ) );
614 if ( !
qgsDoubleNear( numberParam->maximum(), std::numeric_limits<double>::max() ) )
616 mMaxLineEdit->setText( QLocale().toString( numberParam->maximum() ) );
620 mMaxLineEdit->clear();
623 if ( !
qgsDoubleNear( numberParam->minimum(), std::numeric_limits<double>::lowest() ) )
625 mMinLineEdit->setText( QLocale().toString( numberParam->minimum() ) );
629 mMinLineEdit->clear();
632 mDefaultLineEdit->setText( numberParam->defaultValueForGui().toString() );
640 setLayout( vlayout );
649 auto param = std::make_unique<QgsProcessingParameterNumber>( name, description, dataType, ok ? val : QVariant() );
651 if ( !mMinLineEdit->text().trimmed().isEmpty() )
656 param->setMinimum( val );
660 if ( !mMaxLineEdit->text().trimmed().isEmpty() )
665 param->setMaximum( val );
669 param->setFlags( flags );
670 return param.release();
677QWidget *QgsProcessingNumericWidgetWrapper::createWidget()
680 const QVariantMap metadata = numberDef->
metadata();
681 const int decimals = metadata.value( u
"widget_wrapper"_s ).toMap().value( u
"decimals"_s, 6 ).toInt();
689 QAbstractSpinBox *spinBox =
nullptr;
694 mDoubleSpinBox->setExpressionsEnabled(
true );
695 mDoubleSpinBox->setDecimals( decimals );
700 double singleStep = calculateStep( numberDef->
minimum(), numberDef->
maximum() );
701 singleStep = std::max( singleStep, std::pow( 10, -decimals ) );
702 mDoubleSpinBox->setSingleStep( singleStep );
705 spinBox = mDoubleSpinBox;
710 mSpinBox->setExpressionsEnabled(
true );
714 spinBox->setToolTip( parameterDefinition()->toolTip() );
716 double max = 999999999;
721 double min = -999999999;
726 if ( mDoubleSpinBox )
728 mDoubleSpinBox->setMinimum( min );
729 mDoubleSpinBox->setMaximum( max );
733 mSpinBox->setMinimum(
static_cast<int>( min ) );
734 mSpinBox->setMaximum(
static_cast<int>( max ) );
739 mAllowingNull =
true;
740 if ( mDoubleSpinBox )
742 mDoubleSpinBox->setShowClearButton(
true );
743 const double min = mDoubleSpinBox->minimum() - mDoubleSpinBox->singleStep();
744 mDoubleSpinBox->setMinimum( min );
745 mDoubleSpinBox->setValue( min );
749 mSpinBox->setShowClearButton(
true );
750 const int min = mSpinBox->minimum() - 1;
751 mSpinBox->setMinimum( min );
752 mSpinBox->setValue( min );
754 spinBox->setSpecialValueText( tr(
"Not set" ) );
762 if ( mDoubleSpinBox )
766 mDoubleSpinBox->setClearValue( defaultVal );
772 mSpinBox->setClearValue( intVal );
778 if ( mDoubleSpinBox )
779 mDoubleSpinBox->setClearValue( numberDef->
minimum() );
781 mSpinBox->setClearValue(
static_cast<int>( numberDef->
minimum() ) );
786 if ( mDoubleSpinBox )
788 mDoubleSpinBox->setValue( 0 );
789 mDoubleSpinBox->setClearValue( 0 );
793 mSpinBox->setValue( 0 );
794 mSpinBox->setClearValue( 0 );
799 if ( mDoubleSpinBox )
800 connect( mDoubleSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
802 connect( mSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
810void QgsProcessingNumericWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
812 if ( mDoubleSpinBox )
814 if ( mAllowingNull && !value.isValid() )
815 mDoubleSpinBox->clear();
819 mDoubleSpinBox->setValue( v );
824 if ( mAllowingNull && !value.isValid() )
829 mSpinBox->setValue( v );
834QVariant QgsProcessingNumericWidgetWrapper::widgetValue()
const
836 if ( mDoubleSpinBox )
838 if ( mAllowingNull &&
qgsDoubleNear( mDoubleSpinBox->value(), mDoubleSpinBox->minimum() ) )
841 return mDoubleSpinBox->value();
845 if ( mAllowingNull && mSpinBox->value() == mSpinBox->minimum() )
848 return mSpinBox->value();
854double QgsProcessingNumericWidgetWrapper::calculateStep(
const double minimum,
const double maximum )
856 const double valueRange = maximum - minimum;
857 if ( valueRange <= 1.0 )
859 const double step = valueRange / 10.0;
861 return qgsRound( step, -std::floor( std::log( step ) ) );
869QString QgsProcessingNumericWidgetWrapper::parameterType()
const
876 return new QgsProcessingNumericWidgetWrapper( parameter, type );
883 return new QgsProcessingNumberParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
890QgsProcessingDistanceParameterDefinitionWidget::QgsProcessingDistanceParameterDefinitionWidget(
895 QVBoxLayout *vlayout =
new QVBoxLayout();
896 vlayout->setContentsMargins( 0, 0, 0, 0 );
898 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
900 mParentLayerComboBox =
new QComboBox();
902 QString initialParent;
904 initialParent = distParam->parentParameterName();
906 if (
auto *lModel = widgetContext.
model() )
909 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
910 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
914 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
915 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
917 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
922 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
923 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
925 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
930 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
931 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
933 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
938 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
939 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
941 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
947 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
950 mParentLayerComboBox->addItem( initialParent, initialParent );
951 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
954 vlayout->addWidget( mParentLayerComboBox );
957 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
958 mMinLineEdit =
new QLineEdit();
959 vlayout->addWidget( mMinLineEdit );
961 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
962 mMaxLineEdit =
new QLineEdit();
963 vlayout->addWidget( mMaxLineEdit );
965 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
966 mDefaultLineEdit =
new QLineEdit();
967 vlayout->addWidget( mDefaultLineEdit );
971 mMinLineEdit->setText( QLocale().toString( distParam->minimum() ) );
972 mMaxLineEdit->setText( QLocale().toString( distParam->maximum() ) );
973 mDefaultLineEdit->setText( distParam->defaultValueForGui().toString() );
979 setLayout( vlayout );
987 auto param = std::make_unique<QgsProcessingParameterDistance>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
992 param->setMinimum( val );
998 param->setMaximum( val );
1001 param->setFlags( flags );
1002 return param.release();
1006 : 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 );
1111 std::unique_ptr<QgsProcessingContext> tmpContext;
1112 if ( mProcessingContextGenerator )
1113 context = mProcessingContextGenerator->processingContext();
1117 tmpContext = std::make_unique<QgsProcessingContext>();
1118 context = tmpContext.get();
1125 units = crs.mapUnits();
1136 mUnitsCombo->hide();
1144 if ( mBaseUnit != units )
1146 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( units ) ) );
1149 mUnitsCombo->show();
1156QVariant QgsProcessingDistanceWidgetWrapper::widgetValue()
const
1158 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1159 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1174 return new QgsProcessingDistanceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1182QgsProcessingAreaParameterDefinitionWidget::QgsProcessingAreaParameterDefinitionWidget(
1187 QVBoxLayout *vlayout =
new QVBoxLayout();
1188 vlayout->setContentsMargins( 0, 0, 0, 0 );
1190 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1192 mParentLayerComboBox =
new QComboBox();
1194 QString initialParent;
1196 initialParent = areaParam->parentParameterName();
1198 if (
auto *lModel = widgetContext.
model() )
1201 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1202 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1206 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1207 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1209 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1214 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1215 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1217 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1222 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1223 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1225 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1230 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1231 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1233 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1239 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1242 mParentLayerComboBox->addItem( initialParent, initialParent );
1243 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1248 vlayout->addWidget( mParentLayerComboBox );
1250 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1251 mMinLineEdit =
new QLineEdit();
1252 vlayout->addWidget( mMinLineEdit );
1254 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1255 mMaxLineEdit =
new QLineEdit();
1256 vlayout->addWidget( mMaxLineEdit );
1258 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1259 mDefaultLineEdit =
new QLineEdit();
1260 vlayout->addWidget( mDefaultLineEdit );
1264 mMinLineEdit->setText( QLocale().toString( areaParam->minimum() ) );
1265 mMaxLineEdit->setText( QLocale().toString( areaParam->maximum() ) );
1266 mDefaultLineEdit->setText( areaParam->defaultValueForGui().toString() );
1273 setLayout( vlayout );
1281 auto param = std::make_unique<QgsProcessingParameterArea>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1286 param->setMinimum( val );
1292 param->setMaximum( val );
1295 param->setFlags( flags );
1296 return param.release();
1305 : 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 );
1413 std::unique_ptr<QgsProcessingContext> tmpContext;
1414 if ( mProcessingContextGenerator )
1415 context = mProcessingContextGenerator->processingContext();
1419 tmpContext = std::make_unique<QgsProcessingContext>();
1420 context = tmpContext.get();
1427 units = QgsUnitTypes::distanceToAreaUnit( crs.mapUnits() );
1433void QgsProcessingAreaWidgetWrapper::setUnits(
Qgis::AreaUnit units )
1438 mUnitsCombo->hide();
1443 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1444 mUnitsCombo->show();
1451QVariant QgsProcessingAreaWidgetWrapper::widgetValue()
const
1453 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1454 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1469 return new QgsProcessingAreaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1477QgsProcessingVolumeParameterDefinitionWidget::QgsProcessingVolumeParameterDefinitionWidget(
1482 QVBoxLayout *vlayout =
new QVBoxLayout();
1483 vlayout->setContentsMargins( 0, 0, 0, 0 );
1485 vlayout->addWidget(
new QLabel( tr(
"Linked input" ) ) );
1487 mParentLayerComboBox =
new QComboBox();
1489 QString initialParent;
1491 initialParent = volumeParam->parentParameterName();
1493 if (
auto *lModel = widgetContext.
model() )
1496 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
1497 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
1501 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1502 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1504 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1509 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1510 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1512 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1517 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1518 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1520 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1525 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
1526 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
1528 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1534 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
1537 mParentLayerComboBox->addItem( initialParent, initialParent );
1538 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
1541 vlayout->addWidget( mParentLayerComboBox );
1543 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1544 mMinLineEdit =
new QLineEdit();
1545 vlayout->addWidget( mMinLineEdit );
1547 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1548 mMaxLineEdit =
new QLineEdit();
1549 vlayout->addWidget( mMaxLineEdit );
1551 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1552 mDefaultLineEdit =
new QLineEdit();
1553 vlayout->addWidget( mDefaultLineEdit );
1557 mMinLineEdit->setText( QLocale().toString( volumeParam->minimum() ) );
1558 mMaxLineEdit->setText( QLocale().toString( volumeParam->maximum() ) );
1559 mDefaultLineEdit->setText( volumeParam->defaultValueForGui().toString() );
1567 setLayout( vlayout );
1575 auto param = std::make_unique<QgsProcessingParameterVolume>( name, description, ok ? val : QVariant(), mParentLayerComboBox->currentData().toString() );
1580 param->setMinimum( val );
1586 param->setMaximum( val );
1589 param->setFlags( flags );
1590 return param.release();
1599 : 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 );
1705 std::unique_ptr<QgsProcessingContext> tmpContext;
1706 if ( mProcessingContextGenerator )
1707 context = mProcessingContextGenerator->processingContext();
1711 tmpContext = std::make_unique<QgsProcessingContext>();
1712 context = tmpContext.get();
1719 units = QgsUnitTypes::distanceToVolumeUnit( crs.mapUnits() );
1730 mUnitsCombo->hide();
1735 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( QVariant::fromValue( units ) ) );
1736 mUnitsCombo->show();
1743QVariant QgsProcessingVolumeWidgetWrapper::widgetValue()
const
1745 const QVariant val = QgsProcessingNumericWidgetWrapper::widgetValue();
1746 if ( val.userType() == QMetaType::Type::Double && mUnitsCombo && mUnitsCombo->isVisible() )
1761 return new QgsProcessingVolumeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1769QgsProcessingDurationParameterDefinitionWidget::QgsProcessingDurationParameterDefinitionWidget(
1774 QVBoxLayout *vlayout =
new QVBoxLayout();
1775 vlayout->setContentsMargins( 0, 0, 0, 0 );
1777 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
1778 mMinLineEdit =
new QLineEdit();
1779 vlayout->addWidget( mMinLineEdit );
1781 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
1782 mMaxLineEdit =
new QLineEdit();
1783 vlayout->addWidget( mMaxLineEdit );
1785 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1786 mDefaultLineEdit =
new QLineEdit();
1787 vlayout->addWidget( mDefaultLineEdit );
1789 vlayout->addWidget(
new QLabel( tr(
"Default unit type" ) ) );
1791 mUnitsCombo =
new QComboBox();
1801 vlayout->addWidget( mUnitsCombo );
1807 mMinLineEdit->setText( QLocale().toString( durationParam->minimum() ) );
1808 mMaxLineEdit->setText( QLocale().toString( durationParam->maximum() ) );
1809 mDefaultLineEdit->setText( durationParam->defaultValueForGui().toString() );
1810 mUnitsCombo->setCurrentIndex( mUnitsCombo->findData(
static_cast<int>( durationParam->defaultUnit() ) ) );
1816 setLayout( vlayout );
1824 auto param = std::make_unique<QgsProcessingParameterDuration>( name, description, ok ? val : QVariant() );
1829 param->setMinimum( val );
1835 param->setMaximum( val );
1838 param->setDefaultUnit(
static_cast<Qgis::TemporalUnit>( mUnitsCombo->currentData().toInt() ) );
1840 param->setFlags( flags );
1841 return param.release();
1845 : 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 );
1944 return new QgsProcessingDurationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
1951QgsProcessingScaleParameterDefinitionWidget::QgsProcessingScaleParameterDefinitionWidget(
1956 QVBoxLayout *vlayout =
new QVBoxLayout();
1957 vlayout->setContentsMargins( 0, 0, 0, 0 );
1959 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
1961 mDefaultLineEdit =
new QLineEdit();
1965 mDefaultLineEdit->setText( scaleParam->defaultValueForGui().toString() );
1968 vlayout->addWidget( mDefaultLineEdit );
1971 setLayout( vlayout );
1977 double val = mDefaultLineEdit->text().toDouble( &ok );
1978 auto param = std::make_unique<QgsProcessingParameterScale>( name, description, ok ? val : QVariant() );
1979 param->setFlags( flags );
1980 return param.release();
1984 : QgsProcessingNumericWidgetWrapper( parameter, type, parent )
1987QString QgsProcessingScaleWidgetWrapper::parameterType()
const
1994 return new QgsProcessingScaleWidgetWrapper( parameter, type );
1997QWidget *QgsProcessingScaleWidgetWrapper::createWidget()
2009 mScaleWidget->setAllowNull(
true );
2011 mScaleWidget->setMapCanvas( widgetContext().mapCanvas() );
2012 mScaleWidget->setShowCurrentScaleButton(
true );
2014 mScaleWidget->setToolTip( parameterDefinition()->toolTip() );
2016 return mScaleWidget;
2025 mScaleWidget->setMapCanvas( context.
mapCanvas() );
2030QVariant QgsProcessingScaleWidgetWrapper::widgetValue()
const
2032 return mScaleWidget && !mScaleWidget->isNull() ? QVariant( mScaleWidget->scale() ) : QVariant();
2035void QgsProcessingScaleWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2039 if ( mScaleWidget->allowNull() && !value.isValid() )
2040 mScaleWidget->setNull();
2044 mScaleWidget->setScale( v );
2053 return new QgsProcessingScaleParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2061QgsProcessingRangeParameterDefinitionWidget::QgsProcessingRangeParameterDefinitionWidget(
2066 QVBoxLayout *vlayout =
new QVBoxLayout();
2067 vlayout->setContentsMargins( 0, 0, 0, 0 );
2069 vlayout->addWidget(
new QLabel( tr(
"Number type" ) ) );
2071 mTypeComboBox =
new QComboBox();
2074 vlayout->addWidget( mTypeComboBox );
2076 vlayout->addWidget(
new QLabel( tr(
"Minimum value" ) ) );
2077 mMinLineEdit =
new QLineEdit();
2078 vlayout->addWidget( mMinLineEdit );
2080 vlayout->addWidget(
new QLabel( tr(
"Maximum value" ) ) );
2081 mMaxLineEdit =
new QLineEdit();
2082 vlayout->addWidget( mMaxLineEdit );
2086 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( rangeParam->dataType() ) ) );
2088 mMinLineEdit->setText( QLocale().toString( range.at( 0 ) ) );
2089 mMaxLineEdit->setText( QLocale().toString( range.at( 1 ) ) );
2096 setLayout( vlayout );
2101 QString defaultValue;
2102 if ( mMinLineEdit->text().isEmpty() )
2104 defaultValue = u
"None"_s;
2112 defaultValue = u
"None"_s;
2116 if ( mMaxLineEdit->text().isEmpty() )
2118 defaultValue +=
",None"_L1;
2124 defaultValue += u
",%1"_s.arg( ok ? QString::number( val ) :
"None"_L1 );
2128 auto param = std::make_unique<QgsProcessingParameterRange>( name, description, dataType, defaultValue );
2129 param->setFlags( flags );
2130 return param.release();
2138QWidget *QgsProcessingRangeWidgetWrapper::createWidget()
2147 QHBoxLayout *layout =
new QHBoxLayout();
2152 mMinSpinBox->setExpressionsEnabled(
true );
2153 mMinSpinBox->setShowClearButton(
false );
2154 mMaxSpinBox->setExpressionsEnabled(
true );
2155 mMaxSpinBox->setShowClearButton(
false );
2157 QLabel *minLabel =
new QLabel( tr(
"Min" ) );
2158 layout->addWidget( minLabel );
2159 layout->addWidget( mMinSpinBox, 1 );
2161 QLabel *maxLabel =
new QLabel( tr(
"Max" ) );
2162 layout->addWidget( maxLabel );
2163 layout->addWidget( mMaxSpinBox, 1 );
2165 QWidget *w =
new QWidget();
2166 layout->setContentsMargins( 0, 0, 0, 0 );
2167 w->setLayout( layout );
2171 mMinSpinBox->setDecimals( 6 );
2172 mMaxSpinBox->setDecimals( 6 );
2176 mMinSpinBox->setDecimals( 0 );
2177 mMaxSpinBox->setDecimals( 0 );
2180 mMinSpinBox->setMinimum( -99999999.999999 );
2181 mMaxSpinBox->setMinimum( -99999999.999999 );
2182 mMinSpinBox->setMaximum( 99999999.999999 );
2183 mMaxSpinBox->setMaximum( 99999999.999999 );
2187 mAllowingNull =
true;
2189 const double min = mMinSpinBox->minimum() - 1;
2190 mMinSpinBox->setMinimum( min );
2191 mMaxSpinBox->setMinimum( min );
2192 mMinSpinBox->setValue( min );
2193 mMaxSpinBox->setValue( min );
2195 mMinSpinBox->setShowClearButton(
true );
2196 mMaxSpinBox->setShowClearButton(
true );
2197 mMinSpinBox->setSpecialValueText( tr(
"Not set" ) );
2198 mMaxSpinBox->setSpecialValueText( tr(
"Not set" ) );
2201 w->setToolTip( parameterDefinition()->toolTip() );
2203 connect( mMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this](
const double v ) {
2204 mBlockChangedSignal++;
2205 if ( !mAllowingNull && v > mMaxSpinBox->value() )
2206 mMaxSpinBox->setValue( v );
2207 mBlockChangedSignal--;
2209 if ( !mBlockChangedSignal )
2210 emit widgetValueHasChanged(
this );
2212 connect( mMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this](
const double v ) {
2213 mBlockChangedSignal++;
2214 if ( !mAllowingNull && v < mMinSpinBox->value() )
2215 mMinSpinBox->setValue( v );
2216 mBlockChangedSignal--;
2218 if ( !mBlockChangedSignal )
2219 emit widgetValueHasChanged(
this );
2228void QgsProcessingRangeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2231 if ( mAllowingNull && v.empty() )
2233 mMinSpinBox->clear();
2234 mMaxSpinBox->clear();
2241 if ( mAllowingNull )
2243 mBlockChangedSignal++;
2244 if ( std::isnan( v.at( 0 ) ) )
2245 mMinSpinBox->clear();
2247 mMinSpinBox->setValue( v.at( 0 ) );
2249 if ( v.count() >= 2 )
2251 if ( std::isnan( v.at( 1 ) ) )
2252 mMaxSpinBox->clear();
2254 mMaxSpinBox->setValue( v.at( 1 ) );
2256 mBlockChangedSignal--;
2260 mBlockChangedSignal++;
2261 mMinSpinBox->setValue( v.at( 0 ) );
2262 if ( v.count() >= 2 )
2263 mMaxSpinBox->setValue( v.at( 1 ) );
2264 mBlockChangedSignal--;
2268 if ( !mBlockChangedSignal )
2269 emit widgetValueHasChanged(
this );
2272QVariant QgsProcessingRangeWidgetWrapper::widgetValue()
const
2274 if ( mAllowingNull )
2277 if (
qgsDoubleNear( mMinSpinBox->value(), mMinSpinBox->minimum() ) )
2280 value = QString::number( mMinSpinBox->value() );
2282 if (
qgsDoubleNear( mMaxSpinBox->value(), mMaxSpinBox->minimum() ) )
2283 value +=
",None"_L1;
2285 value += u
",%1"_s.arg( mMaxSpinBox->value() );
2290 return u
"%1,%2"_s.arg( mMinSpinBox->value() ).arg( mMaxSpinBox->value() );
2293QString QgsProcessingRangeWidgetWrapper::modelerExpressionFormatString()
const
2295 return tr(
"string as two comma delimited floats, e.g. '1,10'" );
2298QString QgsProcessingRangeWidgetWrapper::parameterType()
const
2305 return new QgsProcessingRangeWidgetWrapper( parameter, type );
2312 return new QgsProcessingRangeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2320QgsProcessingMatrixParameterDefinitionWidget::QgsProcessingMatrixParameterDefinitionWidget(
2325 QVBoxLayout *vlayout =
new QVBoxLayout();
2326 vlayout->setContentsMargins( 0, 0, 0, 0 );
2328 mMatrixWidget =
new QgsProcessingMatrixModelerWidget();
2331 mMatrixWidget->setValue( matrixParam->headers(), matrixParam->defaultValueForGui() );
2332 mMatrixWidget->setFixedRows( matrixParam->hasFixedNumberRows() );
2334 vlayout->addWidget( mMatrixWidget );
2338 setLayout( vlayout );
2343 auto param = std::make_unique<QgsProcessingParameterMatrix>( name, description, 1, mMatrixWidget->fixedRows(), mMatrixWidget->headers(), mMatrixWidget->value() );
2344 param->setFlags( flags );
2345 return param.release();
2353QWidget *QgsProcessingMatrixWidgetWrapper::createWidget()
2355 mMatrixWidget =
new QgsProcessingMatrixParameterPanel(
nullptr,
dynamic_cast<const QgsProcessingParameterMatrix *
>( parameterDefinition() ) );
2356 mMatrixWidget->setToolTip( parameterDefinition()->toolTip() );
2358 connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed,
this, [
this] { emit widgetValueHasChanged(
this ); } );
2366 return mMatrixWidget;
2372void QgsProcessingMatrixWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2375 if ( mMatrixWidget )
2376 mMatrixWidget->setValue( v );
2379QVariant QgsProcessingMatrixWidgetWrapper::widgetValue()
const
2381 if ( mMatrixWidget )
2382 return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value();
2387QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString()
const
2389 return tr(
"comma delimited string of values, or an array of values" );
2392QString QgsProcessingMatrixWidgetWrapper::parameterType()
const
2399 return new QgsProcessingMatrixWidgetWrapper( parameter, type );
2406 return new QgsProcessingMatrixParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2415QgsProcessingFileParameterDefinitionWidget::QgsProcessingFileParameterDefinitionWidget(
2420 QVBoxLayout *vlayout =
new QVBoxLayout();
2421 vlayout->setContentsMargins( 0, 0, 0, 0 );
2423 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
2425 mTypeComboBox =
new QComboBox();
2429 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( fileParam->behavior() ) ) );
2431 mTypeComboBox->setCurrentIndex( 0 );
2432 vlayout->addWidget( mTypeComboBox );
2436 vlayout->addWidget(
new QLabel( tr(
"File filter" ) ) );
2438 mFilterComboBox =
new QComboBox();
2439 mFilterComboBox->setEditable(
true );
2441 mFilterComboBox->addItem( tr(
"All Files (*.*)" ) );
2442 mFilterComboBox->addItem( tr(
"CSV Files (*.csv)" ) );
2443 mFilterComboBox->addItem( tr(
"HTML Files (*.html *.htm)" ) );
2444 mFilterComboBox->addItem( tr(
"Text Files (*.txt)" ) );
2446 mFilterComboBox->setCurrentText( fileParam->fileFilter() );
2448 mFilterComboBox->setCurrentIndex( 0 );
2449 vlayout->addWidget( mFilterComboBox );
2453 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2456 mDefaultFileWidget->lineEdit()->setShowClearButton(
true );
2460 mDefaultFileWidget->setFilePath( fileParam->defaultValueForGui().toString() );
2464 vlayout->addWidget( mDefaultFileWidget );
2467 connect( mTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2475 setLayout( vlayout );
2480 auto param = std::make_unique<QgsProcessingParameterFile>( name, description );
2483 param->setFileFilter( mFilterComboBox->currentText() );
2484 if ( !mDefaultFileWidget->filePath().isEmpty() )
2485 param->setDefaultValue( mDefaultFileWidget->filePath() );
2486 param->setFlags( flags );
2487 return param.release();
2495QWidget *QgsProcessingFileWidgetWrapper::createWidget()
2508 mFileWidget->setToolTip( parameterDefinition()->toolTip() );
2509 mFileWidget->setDialogTitle( parameterDefinition()->description() );
2511 mFileWidget->setDefaultRoot(
QgsSettings().value( u
"/Processing/LastInputPath"_s, QDir::homePath() ).toString() );
2518 mFileWidget->setFilter( fileParam->
fileFilter() );
2519 else if ( !fileParam->
extension().isEmpty() )
2520 mFileWidget->setFilter( tr(
"%1 files" ).arg( fileParam->
extension().toUpper() ) + u
" (*."_s + fileParam->
extension().toLower() +
')' );
2529 QgsSettings().
setValue( u
"/Processing/LastInputPath"_s, QFileInfo( path ).canonicalPath() );
2530 emit widgetValueHasChanged(
this );
2538void QgsProcessingFileWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2542 mFileWidget->setFilePath( v );
2545QVariant QgsProcessingFileWidgetWrapper::widgetValue()
const
2548 return mFileWidget->filePath();
2553QString QgsProcessingFileWidgetWrapper::modelerExpressionFormatString()
const
2555 return tr(
"string representing a path to a file or folder" );
2558QString QgsProcessingFileWidgetWrapper::parameterType()
const
2565 return new QgsProcessingFileWidgetWrapper( parameter, type );
2572 return new QgsProcessingFileParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
2580QgsProcessingExpressionParameterDefinitionWidget::QgsProcessingExpressionParameterDefinitionWidget(
2585 QVBoxLayout *vlayout =
new QVBoxLayout();
2586 vlayout->setContentsMargins( 0, 0, 0, 0 );
2587 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
2590 mDefaultQgisLineEdit->registerExpressionContextGenerator(
this );
2592 mDefaultPointCloudLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2593 mDefaultRasterCalculatorLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2595 QStackedWidget *stackedWidget =
new QStackedWidget();
2596 stackedWidget->addWidget( mDefaultQgisLineEdit );
2597 stackedWidget->addWidget( mDefaultPointCloudLineEdit );
2598 stackedWidget->addWidget( mDefaultRasterCalculatorLineEdit );
2599 vlayout->addWidget( stackedWidget );
2608 mDefaultQgisLineEdit->setExpression( expr );
2609 mDefaultPointCloudLineEdit->setExpression( expr );
2612 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
2614 mParentLayerComboBox =
new QComboBox();
2615 vlayout->addWidget( mParentLayerComboBox );
2617 vlayout->addWidget(
new QLabel( tr(
"Expression type" ) ) );
2618 mExpressionTypeComboBox =
new QComboBox();
2623 connect( mExpressionTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this, stackedWidget, definition, widgetContext](
int ) {
2624 mParentLayerComboBox->clear();
2625 mParentLayerComboBox->addItem( tr(
"None" ), QVariant() );
2627 stackedWidget->setCurrentIndex( mExpressionTypeComboBox->currentIndex() > 0 ? mExpressionTypeComboBox->currentIndex() : 0 );
2629 QString initialParent;
2631 initialParent = expParam->parentLayerParameterName();
2635 if ( QgsProcessingModelAlgorithm *model = widgetContext.
model() )
2638 const QMap<QString, QgsProcessingModelParameter> components = model->parameterComponents();
2639 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
2646 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2647 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2649 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2654 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2655 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2657 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2664 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2665 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2667 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2678 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
2679 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
2681 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2689 if ( mParentLayerComboBox->count() == 1 && !initialParent.isEmpty() )
2692 mParentLayerComboBox->addItem( initialParent, initialParent );
2693 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
2697 mExpressionTypeComboBox->setCurrentIndex( -1 );
2699 mExpressionTypeComboBox->setCurrentIndex( mExpressionTypeComboBox->findData(
static_cast<int>( expParam->expressionType() ) ) );
2701 mExpressionTypeComboBox->setCurrentIndex( 0 );
2703 vlayout->addWidget( mExpressionTypeComboBox );
2708 setLayout( vlayout );
2715 switch ( expressionType )
2718 expression = mDefaultQgisLineEdit->expression();
2721 expression = mDefaultPointCloudLineEdit->expression();
2724 expression = mDefaultRasterCalculatorLineEdit->expression();
2727 auto param = std::make_unique<QgsProcessingParameterExpression>( name, description, expression, mParentLayerComboBox->currentData().toString(),
false, expressionType );
2728 param->setFlags( flags );
2729 return param.release();
2736QWidget *QgsProcessingExpressionWidgetWrapper::createWidget()
2751 mExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2752 mExpLineEdit->setExpressionDialogTitle( parameterDefinition()->description() );
2753 mExpLineEdit->registerExpressionContextGenerator(
this );
2755 return mExpLineEdit;
2761 mPointCloudExpLineEdit =
new QgsProcessingPointCloudExpressionLineEdit();
2762 mPointCloudExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2763 connect( mPointCloudExpLineEdit, &QgsProcessingPointCloudExpressionLineEdit::expressionChanged,
this, [
this](
const QString & ) { emit widgetValueHasChanged(
this ); } );
2764 return mPointCloudExpLineEdit;
2769 mRasterCalculatorExpLineEdit =
new QgsProcessingRasterCalculatorExpressionLineEdit();
2770 mRasterCalculatorExpLineEdit->setToolTip( parameterDefinition()->toolTip() );
2773 mRasterCalculatorExpLineEdit->setLayers( QVariantList() <<
"A" <<
"B" <<
"C" <<
"D" <<
"E" <<
"F" <<
"G" );
2775 connect( mRasterCalculatorExpLineEdit, &QgsProcessingRasterCalculatorExpressionLineEdit::expressionChanged,
this, [
this](
const QString & ) { emit widgetValueHasChanged(
this ); } );
2776 return mRasterCalculatorExpLineEdit;
2780 if ( expParam->
metadata().value( u
"inlineEditor"_s ).toBool() )
2783 mExpBuilderWidget->setToolTip( parameterDefinition()->toolTip() );
2784 mExpBuilderWidget->init( createExpressionContext() );
2786 Q_UNUSED( changed );
2787 emit widgetValueHasChanged(
this );
2789 return mExpBuilderWidget;
2794 mFieldExpWidget->setToolTip( parameterDefinition()->toolTip() );
2795 mFieldExpWidget->setExpressionDialogTitle( parameterDefinition()->description() );
2796 mFieldExpWidget->registerExpressionContextGenerator(
this );
2798 mFieldExpWidget->setAllowEmptyFieldName(
true );
2801 emit widgetValueHasChanged(
this );
2803 return mFieldExpWidget;
2811void QgsProcessingExpressionWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
2823 setParentLayerWrapperValue( wrapper );
2839 if ( mExpBuilderWidget )
2842 mExpBuilderWidget->setExpressionContext( createExpressionContext() );
2850 std::unique_ptr<QgsProcessingContext> tmpContext;
2851 if ( mProcessingContextGenerator )
2852 context = mProcessingContextGenerator->processingContext();
2856 tmpContext = std::make_unique<QgsProcessingContext>();
2857 context = tmpContext.get();
2870 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2880 if ( mFieldExpWidget )
2881 mFieldExpWidget->setLayer(
nullptr );
2882 else if ( mExpBuilderWidget )
2883 mExpBuilderWidget->setLayer(
nullptr );
2884 else if ( mExpLineEdit )
2885 mExpLineEdit->setLayer(
nullptr );
2891 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2894 mParentLayer = std::move( ownedLayer );
2902 if ( mFieldExpWidget )
2903 mFieldExpWidget->setLayer( layer );
2904 if ( mExpBuilderWidget )
2905 mExpBuilderWidget->setLayer( layer );
2906 else if ( mExpLineEdit )
2907 mExpLineEdit->setLayer( layer );
2916 if ( mPointCloudExpLineEdit )
2917 mPointCloudExpLineEdit->setLayer(
nullptr );
2923 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
2926 mParentLayer = std::move( ownedLayer );
2934 if ( mPointCloudExpLineEdit )
2935 mPointCloudExpLineEdit->setLayer( layer );
2942 if ( layers.isEmpty() )
2944 if ( mRasterCalculatorExpLineEdit )
2946 mRasterCalculatorExpLineEdit->setLayers( val.userType() == QMetaType::Type::QVariantList ? val.toList() : QVariantList() << val );
2951 if ( mRasterCalculatorExpLineEdit )
2953 QVariantList layersList;
2956 layersList << layer->
name();
2958 mRasterCalculatorExpLineEdit->setLayers( layersList );
2966void QgsProcessingExpressionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
2969 if ( mFieldExpWidget )
2970 mFieldExpWidget->setExpression( v );
2971 else if ( mExpBuilderWidget )
2972 mExpBuilderWidget->setExpressionText( v );
2973 else if ( mExpLineEdit )
2974 mExpLineEdit->setExpression( v );
2975 else if ( mPointCloudExpLineEdit )
2976 mPointCloudExpLineEdit->setExpression( v );
2977 else if ( mRasterCalculatorExpLineEdit )
2978 mRasterCalculatorExpLineEdit->setExpression( v );
2981QVariant QgsProcessingExpressionWidgetWrapper::widgetValue()
const
2983 if ( mFieldExpWidget )
2984 return mFieldExpWidget->expression();
2985 if ( mExpBuilderWidget )
2986 return mExpBuilderWidget->expressionText();
2987 else if ( mExpLineEdit )
2988 return mExpLineEdit->expression();
2989 else if ( mPointCloudExpLineEdit )
2990 return mPointCloudExpLineEdit->expression();
2991 else if ( mRasterCalculatorExpLineEdit )
2992 return mRasterCalculatorExpLineEdit->expression();
2997QString QgsProcessingExpressionWidgetWrapper::modelerExpressionFormatString()
const
2999 return tr(
"string representation of an expression" );
3002const QgsVectorLayer *QgsProcessingExpressionWidgetWrapper::linkedVectorLayer()
const
3004 if ( mFieldExpWidget && mFieldExpWidget->layer() )
3005 return mFieldExpWidget->layer();
3007 if ( mExpBuilderWidget && mExpBuilderWidget->layer() )
3008 return mExpBuilderWidget->layer();
3013QString QgsProcessingExpressionWidgetWrapper::parameterType()
const
3020 return new QgsProcessingExpressionWidgetWrapper( parameter, type );
3027 return new QgsProcessingExpressionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3039 QHBoxLayout *hl =
new QHBoxLayout();
3040 hl->setContentsMargins( 0, 0, 0, 0 );
3042 mLineEdit =
new QLineEdit();
3043 mLineEdit->setEnabled(
false );
3044 hl->addWidget( mLineEdit, 1 );
3046 mToolButton =
new QToolButton();
3047 mToolButton->setText( QString( QChar( 0x2026 ) ) );
3048 hl->addWidget( mToolButton );
3054 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3057 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingEnumPanelWidget::showDialog );
3060void QgsProcessingEnumPanelWidget::setValue(
const QVariant &value )
3062 if ( value.isValid() )
3064 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3066 if ( mParam->usesStaticStrings() && mValue.count() == 1 && mValue.at( 0 ).toString().isEmpty() )
3072 updateSummaryText();
3076void QgsProcessingEnumPanelWidget::showDialog()
3078 QVariantList availableOptions;
3081 availableOptions.reserve( mParam->options().size() );
3083 if ( mParam->usesStaticStrings() )
3085 for ( QString o : mParam->options() )
3087 availableOptions << o;
3092 for (
int i = 0; i < mParam->options().count(); ++i )
3093 availableOptions << i;
3097 const QStringList options = mParam ? mParam->options() : QStringList();
3101 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
3102 widget->setPanelTitle( mParam->description() );
3104 if ( mParam->usesStaticStrings() )
3106 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3107 const QString i = v.toString();
3108 return options.contains( i ) ? i : QString();
3113 widget->setValueFormatter( [options](
const QVariant &v ) -> QString {
3114 const int i = v.toInt();
3115 return options.size() > i ? options.at( i ) : QString();
3119 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() { setValue( widget->selectedOptions() ); } );
3125 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
3127 dlg.setValueFormatter( [options](
const QVariant &v ) -> QString {
3128 const int i = v.toInt();
3129 return options.size() > i ? options.at( i ) : QString();
3133 setValue( dlg.selectedOptions() );
3138void QgsProcessingEnumPanelWidget::updateSummaryText()
3143 if ( mValue.empty() )
3145 mLineEdit->setText( tr(
"%1 options selected" ).arg( 0 ) );
3150 values.reserve( mValue.size() );
3151 if ( mParam->usesStaticStrings() )
3153 for (
const QVariant &val : std::as_const( mValue ) )
3155 values << val.toString();
3160 const QStringList options = mParam->options();
3161 for (
const QVariant &val : std::as_const( mValue ) )
3163 const int i = val.toInt();
3164 values << ( options.size() > i ? options.at( i ) : QString() );
3168 const QString concatenated = values.join( tr(
"," ) );
3169 if ( concatenated.length() < 100 )
3170 mLineEdit->setText( concatenated );
3172 mLineEdit->setText( tr(
"%n option(s) selected",
nullptr, mValue.count() ) );
3180QgsProcessingEnumCheckboxPanelWidget::QgsProcessingEnumCheckboxPanelWidget( QWidget *parent,
const QgsProcessingParameterEnum *param,
int columns )
3183 , mButtonGroup( new QButtonGroup( this ) )
3184 , mColumns( columns )
3186 mButtonGroup->setExclusive( !mParam->allowMultiple() );
3188 QGridLayout *l =
new QGridLayout();
3189 l->setContentsMargins( 0, 0, 0, 0 );
3191 int rows =
static_cast<int>( std::ceil( mParam->options().count() /
static_cast<double>( mColumns ) ) );
3192 for (
int i = 0; i < mParam->options().count(); ++i )
3194 QAbstractButton *button =
nullptr;
3195 if ( mParam->allowMultiple() )
3196 button =
new QCheckBox( mParam->options().at( i ) );
3198 button =
new QRadioButton( mParam->options().at( i ) );
3200 connect( button, &QAbstractButton::toggled,
this, [
this] {
3201 if ( !mBlockChangedSignal )
3205 mButtons.insert( i, button );
3207 mButtonGroup->addButton( button, i );
3208 l->addWidget( button, i % rows, i / rows );
3210 l->addItem(
new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, mColumns );
3213 if ( mParam->allowMultiple() )
3215 setContextMenuPolicy( Qt::CustomContextMenu );
3216 connect(
this, &QWidget::customContextMenuRequested,
this, &QgsProcessingEnumCheckboxPanelWidget::showPopupMenu );
3220QVariant QgsProcessingEnumCheckboxPanelWidget::value()
const
3222 if ( mParam->allowMultiple() )
3225 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3227 if ( it.value()->isChecked() )
3228 value.append( mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key() );
3234 if ( mParam->usesStaticStrings() )
3235 return mButtonGroup->checkedId() >= 0 ? mParam->options().at( mButtonGroup->checkedId() ) : QVariant();
3237 return mButtonGroup->checkedId() >= 0 ? mButtonGroup->checkedId() : QVariant();
3241void QgsProcessingEnumCheckboxPanelWidget::setValue(
const QVariant &value )
3243 mBlockChangedSignal =
true;
3244 if ( mParam->allowMultiple() )
3246 QVariantList selected;
3247 if ( value.isValid() )
3248 selected = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
3249 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3251 QVariant v = mParam->usesStaticStrings() ? mParam->options().at( it.key().toInt() ) : it.key();
3252 it.value()->setChecked( selected.contains( v ) );
3258 if ( v.userType() == QMetaType::Type::QVariantList )
3259 v = v.toList().value( 0 );
3261 v = mParam->usesStaticStrings() ?
static_cast< int >( mParam->options().indexOf( v.toString() ) ) : v;
3262 if ( mButtons.contains( v ) )
3263 mButtons.value( v )->setChecked(
true );
3265 mBlockChangedSignal =
false;
3269void QgsProcessingEnumCheckboxPanelWidget::showPopupMenu()
3272 QAction *selectAllAction =
new QAction( tr(
"Select All" ), &popupMenu );
3273 connect( selectAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::selectAll );
3274 QAction *clearAllAction =
new QAction( tr(
"Clear Selection" ), &popupMenu );
3275 connect( clearAllAction, &QAction::triggered,
this, &QgsProcessingEnumCheckboxPanelWidget::deselectAll );
3276 popupMenu.addAction( selectAllAction );
3277 popupMenu.addAction( clearAllAction );
3278 popupMenu.exec( QCursor::pos() );
3281void QgsProcessingEnumCheckboxPanelWidget::selectAll()
3283 mBlockChangedSignal =
true;
3284 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3285 it.value()->setChecked(
true );
3286 mBlockChangedSignal =
false;
3290void QgsProcessingEnumCheckboxPanelWidget::deselectAll()
3292 mBlockChangedSignal =
true;
3293 for (
auto it = mButtons.constBegin(); it != mButtons.constEnd(); ++it )
3294 it.value()->setChecked(
false );
3295 mBlockChangedSignal =
false;
3304QgsProcessingEnumParameterDefinitionWidget::QgsProcessingEnumParameterDefinitionWidget(
3309 QVBoxLayout *vlayout =
new QVBoxLayout();
3310 vlayout->setContentsMargins( 0, 0, 0, 0 );
3312 mEnumWidget =
new QgsProcessingEnumModelerWidget();
3315 mEnumWidget->setAllowMultiple( enumParam->allowMultiple() );
3316 mEnumWidget->setOptions( enumParam->options() );
3317 mEnumWidget->setDefaultOptions( enumParam->defaultValueForGui() );
3319 vlayout->addWidget( mEnumWidget );
3323 setLayout( vlayout );
3328 auto param = std::make_unique<QgsProcessingParameterEnum>( name, description, mEnumWidget->options(), mEnumWidget->allowMultiple(), mEnumWidget->defaultOptions() );
3330 return param.release();
3338QWidget *QgsProcessingEnumWidgetWrapper::createWidget()
3349 if ( expParam->
metadata().value( u
"widget_wrapper"_s ).toMap().value( u
"useCheckBoxes"_s,
false ).toBool() )
3351 const int columns = expParam->
metadata().value( u
"widget_wrapper"_s ).toMap().value( u
"columns"_s, 2 ).toInt();
3352 mCheckboxPanel =
new QgsProcessingEnumCheckboxPanelWidget(
nullptr, expParam, columns );
3353 mCheckboxPanel->setToolTip( parameterDefinition()->toolTip() );
3354 connect( mCheckboxPanel, &QgsProcessingEnumCheckboxPanelWidget::changed,
this, [
this] { emit widgetValueHasChanged(
this ); } );
3355 return mCheckboxPanel;
3364 mPanel =
new QgsProcessingEnumPanelWidget(
nullptr, expParam );
3365 mPanel->setToolTip( parameterDefinition()->toolTip() );
3366 connect( mPanel, &QgsProcessingEnumPanelWidget::changed,
this, [
this] { 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 ) { emit widgetValueHasChanged(
this ); } );
3397void QgsProcessingEnumWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3401 if ( !value.isValid() )
3402 mComboBox->setCurrentIndex( mComboBox->findData( QVariant() ) );
3408 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3413 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
3417 else if ( mPanel || mCheckboxPanel )
3420 if ( value.isValid() )
3425 opts.reserve( v.size() );
3426 for ( QString i : v )
3432 opts.reserve( v.size() );
3438 mPanel->setValue( opts );
3439 else if ( mCheckboxPanel )
3440 mCheckboxPanel->setValue( opts );
3444QVariant QgsProcessingEnumWidgetWrapper::widgetValue()
const
3447 return mComboBox->currentData();
3449 return mPanel->value();
3450 else if ( mCheckboxPanel )
3451 return mCheckboxPanel->value();
3456QString QgsProcessingEnumWidgetWrapper::modelerExpressionFormatString()
const
3458 return tr(
"selected option index (starting from 0), array of indices, or comma separated string of options (e.g. '1,3')" );
3461QString QgsProcessingEnumWidgetWrapper::parameterType()
const
3468 return new QgsProcessingEnumWidgetWrapper( parameter, type );
3475 return new QgsProcessingEnumParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3486QWidget *QgsProcessingLayoutWidgetWrapper::createWidget()
3498 mComboBox =
new QgsLayoutComboBox(
nullptr, widgetContext().project() ? widgetContext().project()->layoutManager() :
nullptr );
3500 mComboBox->setAllowEmptyLayout(
true );
3503 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3510 mPlainComboBox =
new QComboBox();
3511 mPlainComboBox->setEditable(
true );
3512 mPlainComboBox->setToolTip( tr(
"Name of an existing print layout" ) );
3513 if ( widgetContext().project() )
3517 mPlainComboBox->addItem( layout->name() );
3520 connect( mPlainComboBox, &QComboBox::currentTextChanged,
this, [
this](
const QString & ) { emit widgetValueHasChanged(
this ); } );
3521 return mPlainComboBox;
3527void QgsProcessingLayoutWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3531 if ( !value.isValid() )
3532 mComboBox->setCurrentLayout(
nullptr );
3536 mComboBox->setCurrentLayout( l );
3538 mComboBox->setCurrentLayout(
nullptr );
3541 else if ( mPlainComboBox )
3544 mPlainComboBox->setCurrentText( v );
3548QVariant QgsProcessingLayoutWidgetWrapper::widgetValue()
const
3553 return l ? l->
name() : QVariant();
3555 else if ( mPlainComboBox )
3556 return mPlainComboBox->currentText().isEmpty() ? QVariant() : mPlainComboBox->currentText();
3564 if ( mPlainComboBox && context.
project() )
3568 mPlainComboBox->addItem( layout->name() );
3572QString QgsProcessingLayoutWidgetWrapper::modelerExpressionFormatString()
const
3574 return tr(
"string representing the name of an existing print layout" );
3577QString QgsProcessingLayoutWidgetWrapper::parameterType()
const
3584 return new QgsProcessingLayoutWidgetWrapper( parameter, type );
3593QgsProcessingLayoutItemParameterDefinitionWidget::QgsProcessingLayoutItemParameterDefinitionWidget(
3598 QVBoxLayout *vlayout =
new QVBoxLayout();
3599 vlayout->setContentsMargins( 0, 0, 0, 0 );
3601 vlayout->addWidget(
new QLabel( tr(
"Parent layout" ) ) );
3603 mParentLayoutComboBox =
new QComboBox();
3604 QString initialParent;
3606 initialParent = itemParam->parentLayoutParameterName();
3608 if (
auto *lModel = widgetContext.
model() )
3611 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
3612 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
3616 mParentLayoutComboBox->addItem( definition->
description(), definition->
name() );
3617 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
3619 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3625 if ( mParentLayoutComboBox->count() == 0 && !initialParent.isEmpty() )
3628 mParentLayoutComboBox->addItem( initialParent, initialParent );
3629 mParentLayoutComboBox->setCurrentIndex( mParentLayoutComboBox->count() - 1 );
3632 vlayout->addWidget( mParentLayoutComboBox );
3636 setLayout( vlayout );
3640 auto param = std::make_unique<QgsProcessingParameterLayoutItem>( name, description, QVariant(), mParentLayoutComboBox->currentData().toString() );
3642 return param.release();
3650QWidget *QgsProcessingLayoutItemWidgetWrapper::createWidget()
3664 mComboBox->setAllowEmptyItem(
true );
3665 if ( layoutParam->
itemType() >= 0 )
3668 mComboBox->setToolTip( parameterDefinition()->toolTip() );
3675 mLineEdit =
new QLineEdit();
3676 mLineEdit->setToolTip( tr(
"UUID or ID of an existing print layout item" ) );
3677 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString & ) { emit widgetValueHasChanged(
this ); } );
3684void QgsProcessingLayoutItemWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
3709void QgsProcessingLayoutItemWidgetWrapper::setLayoutParameterValue(
const QVariant &value )
3715 std::unique_ptr<QgsProcessingContext> tmpContext;
3716 if ( mProcessingContextGenerator )
3717 context = mProcessingContextGenerator->processingContext();
3721 tmpContext = std::make_unique<QgsProcessingContext>();
3722 context = tmpContext.get();
3726 setLayout( layout );
3729void QgsProcessingLayoutItemWidgetWrapper::setLayout(
QgsPrintLayout *layout )
3732 mComboBox->setCurrentLayout( layout );
3735void QgsProcessingLayoutItemWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
3739 if ( !value.isValid() )
3740 mComboBox->setItem(
nullptr );
3744 mComboBox->setItem( item );
3747 else if ( mLineEdit )
3750 mLineEdit->setText( v );
3754QVariant QgsProcessingLayoutItemWidgetWrapper::widgetValue()
const
3759 return i ? i->
uuid() : QVariant();
3761 else if ( mLineEdit )
3762 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
3768QString QgsProcessingLayoutItemWidgetWrapper::modelerExpressionFormatString()
const
3770 return tr(
"string representing the UUID or ID of an existing print layout item" );
3773QString QgsProcessingLayoutItemWidgetWrapper::parameterType()
const
3780 return new QgsProcessingLayoutItemWidgetWrapper( parameter, type );
3787 return new QgsProcessingLayoutItemParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
3794QgsProcessingPointMapTool::QgsProcessingPointMapTool(
QgsMapCanvas *canvas )
3798 mSnapIndicator = std::make_unique<QgsSnapIndicator>( canvas );
3801QgsProcessingPointMapTool::~QgsProcessingPointMapTool() =
default;
3803void QgsProcessingPointMapTool::deactivate()
3817 if ( e->button() == Qt::LeftButton )
3820 emit clicked( point );
3825void QgsProcessingPointMapTool::keyPressEvent( QKeyEvent *e )
3827 if ( e->key() == Qt::Key_Escape )
3840QgsProcessingPointPanel::QgsProcessingPointPanel( QWidget *parent )
3843 QHBoxLayout *l =
new QHBoxLayout();
3844 l->setContentsMargins( 0, 0, 0, 0 );
3846 mLineEdit->setShowClearButton(
false );
3847 l->addWidget( mLineEdit, 1 );
3848 mButton =
new QToolButton();
3849 mButton->setText( QString( QChar( 0x2026 ) ) );
3850 l->addWidget( mButton );
3853 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::changed );
3854 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsProcessingPointPanel::textChanged );
3855 connect( mButton, &QToolButton::clicked,
this, &QgsProcessingPointPanel::selectOnCanvas );
3856 mButton->setVisible(
false );
3859QgsProcessingPointPanel::~QgsProcessingPointPanel()
3861 if ( mCanvas && mPrevTool && mCanvas->mapTool() == mTool.get() )
3863 mCanvas->setMapTool( mPrevTool.get() );
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.arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) );
3924 if ( mCrs.isValid() )
3926 newText += u
" [%1]"_s.arg( mCrs.authid() );
3928 mLineEdit->setText( newText );
3932void QgsProcessingPointPanel::showEvent( QShowEvent * )
3937 if ( QWidget *parentWindow = window() )
3939 setAllowSelectOnCanvas( !parentWindow->isModal() );
3945void QgsProcessingPointPanel::selectOnCanvas()
3950 mPrevTool = mCanvas->mapTool();
3951 mCanvas->setMapTool( mTool.get() );
3953 emit toggleDialogVisibility(
false );
3956void QgsProcessingPointPanel::updatePoint(
const QgsPointXY &point )
3958 setValue( point, mCanvas->mapSettings().destinationCrs() );
3961void QgsProcessingPointPanel::pointPicked()
3966 mCanvas->setMapTool( mPrevTool );
3968 emit toggleDialogVisibility(
true );
3971void QgsProcessingPointPanel::textChanged(
const QString &text )
3973 const thread_local QRegularExpression rx( u
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$"_s );
3975 const QRegularExpressionMatch match = rx.match( text );
3976 if ( match.hasMatch() )
3979 const double x = match.captured( 1 ).toDouble( &xOk );
3981 const double y = match.captured( 2 ).toDouble( &yOk );
3988 if ( pointCrs.isValid() )
4006void QgsProcessingPointPanel::updateRubberBand()
4008 if ( !mShowPointOnCanvas || !mCanvas )
4011 if ( mPoint.isEmpty() )
4013 mMapPointRubberBand.reset();
4017 if ( !mMapPointRubberBand )
4020 mMapPointRubberBand->setZValue( 1000 );
4023 const double scaleFactor = mCanvas->fontMetrics().xHeight() * .4;
4024 mMapPointRubberBand->setWidth( scaleFactor );
4025 mMapPointRubberBand->setIconSize( scaleFactor * 5 );
4027 mMapPointRubberBand->setSecondaryStrokeColor( QColor( 255, 255, 255, 100 ) );
4028 mMapPointRubberBand->setColor( QColor( 200, 0, 200 ) );
4039QgsProcessingPointParameterDefinitionWidget::QgsProcessingPointParameterDefinitionWidget(
4044 QVBoxLayout *vlayout =
new QVBoxLayout();
4045 vlayout->setContentsMargins( 0, 0, 0, 0 );
4047 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4049 mDefaultLineEdit =
new QLineEdit();
4050 mDefaultLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4051 mDefaultLineEdit->setPlaceholderText( tr(
"Point as 'x,y'" ) );
4055 mDefaultLineEdit->setText( u
"%1,%2"_s.arg( QString::number( point.
x(),
'f' ), QString::number( point.
y(),
'f' ) ) );
4058 vlayout->addWidget( mDefaultLineEdit );
4062 setLayout( vlayout );
4067 auto param = std::make_unique<QgsProcessingParameterPoint>( name, description, mDefaultLineEdit->text() );
4069 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] { emit widgetValueHasChanged(
this ); } );
4102 setDialog( mDialog );
4108 mLineEdit =
new QLineEdit();
4109 mLineEdit->setToolTip( tr(
"Point as 'x,y'" ) );
4110 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString & ) { emit widgetValueHasChanged(
this ); } );
4121 mPanel->setMapCanvas( context.
mapCanvas() );
4124void QgsProcessingPointWidgetWrapper::setDialog( QWidget *dialog )
4129 connect( mPanel, &QgsProcessingPointPanel::toggleDialogVisibility, mDialog, [
this](
bool visible ) {
4131 mDialog->showMinimized();
4134 mDialog->showNormal();
4136 mDialog->activateWindow();
4143void QgsProcessingPointWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4147 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
4153 mPanel->setValue( p, crs );
4156 else if ( mLineEdit )
4159 mLineEdit->setText( v );
4163QVariant QgsProcessingPointWidgetWrapper::widgetValue()
const
4167 return mPanel->value();
4169 else if ( mLineEdit )
4170 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
4175QString QgsProcessingPointWidgetWrapper::modelerExpressionFormatString()
const
4177 return tr(
"string of the format 'x,y' or a geometry value (centroid is used)" );
4180QString QgsProcessingPointWidgetWrapper::parameterType()
const
4187 return new QgsProcessingPointWidgetWrapper( parameter, type );
4194 return new QgsProcessingPointParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4203QgsProcessingGeometryParameterDefinitionWidget::QgsProcessingGeometryParameterDefinitionWidget(
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();
4242QWidget *QgsProcessingGeometryWidgetWrapper::createWidget()
4251 mGeometryWidget->setToolTip( parameterDefinition()->toolTip() );
4253 return mGeometryWidget;
4259void QgsProcessingGeometryWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4261 if ( mGeometryWidget )
4270 mGeometryWidget->clearGeometry();
4275QVariant QgsProcessingGeometryWidgetWrapper::widgetValue()
const
4277 if ( mGeometryWidget )
4280 return geometry.
isEmpty() ? QVariant() : geometry.asWkt();
4288QString QgsProcessingGeometryWidgetWrapper::modelerExpressionFormatString()
const
4290 return tr(
"string in the Well-Known-Text format or a geometry value" );
4293QString QgsProcessingGeometryWidgetWrapper::parameterType()
const
4300 return new QgsProcessingGeometryWidgetWrapper( parameter, type );
4307 return new QgsProcessingGeometryParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4316QgsProcessingColorParameterDefinitionWidget::QgsProcessingColorParameterDefinitionWidget(
4321 QVBoxLayout *vlayout =
new QVBoxLayout();
4322 vlayout->setContentsMargins( 0, 0, 0, 0 );
4324 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4327 mDefaultColorButton->setShowNull(
true );
4328 mAllowOpacity =
new QCheckBox( tr(
"Allow opacity control" ) );
4334 mDefaultColorButton->setToNull();
4336 mDefaultColorButton->setColor(
c );
4337 mAllowOpacity->setChecked( colorParam->opacityEnabled() );
4341 mDefaultColorButton->setToNull();
4342 mAllowOpacity->setChecked(
true );
4348 vlayout->addWidget( mDefaultColorButton );
4349 vlayout->addWidget( mAllowOpacity );
4350 setLayout( vlayout );
4355 auto param = std::make_unique<QgsProcessingParameterColor>( name, description, mDefaultColorButton->color(), mAllowOpacity->isChecked() );
4357 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() );
4392 return mColorButton;
4398void QgsProcessingColorWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
4402 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) || ( value.userType() == QMetaType::Type::QColor && !value.value<QColor>().isValid() ) )
4403 mColorButton->setToNull();
4407 if ( !
c.isValid() && mColorButton->showNull() )
4408 mColorButton->setToNull();
4410 mColorButton->setColor(
c );
4415QVariant QgsProcessingColorWidgetWrapper::widgetValue()
const
4418 return mColorButton->isNull() ? QVariant() : mColorButton->color();
4423QString QgsProcessingColorWidgetWrapper::modelerExpressionFormatString()
const
4425 return tr(
"color style string, e.g. #ff0000 or 255,0,0" );
4428QString QgsProcessingColorWidgetWrapper::parameterType()
const
4435 return new QgsProcessingColorWidgetWrapper( parameter, type );
4442 return new QgsProcessingColorParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4450QgsProcessingCoordinateOperationParameterDefinitionWidget::QgsProcessingCoordinateOperationParameterDefinitionWidget(
4455 QVBoxLayout *vlayout =
new QVBoxLayout();
4456 vlayout->setContentsMargins( 0, 0, 0, 0 );
4458 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4460 mDefaultLineEdit =
new QLineEdit();
4463 vlayout->addWidget( mDefaultLineEdit );
4467 mSourceParamComboBox =
new QComboBox();
4468 mDestParamComboBox =
new QComboBox();
4469 QString initialSource;
4470 QString initialDest;
4475 initialSource = itemParam->sourceCrsParameterName();
4476 initialDest = itemParam->destinationCrsParameterName();
4481 mSourceParamComboBox->addItem( QString(), QString() );
4482 mDestParamComboBox->addItem( QString(), QString() );
4483 if (
auto *lModel = widgetContext.
model() )
4486 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4487 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4489 if ( definition && it->parameterName() == definition->
name() )
4493 mSourceParamComboBox->addItem( it->parameterName(), it->parameterName() );
4494 mDestParamComboBox->addItem( it->parameterName(), it->parameterName() );
4495 if ( !initialSource.isEmpty() && initialSource == it->parameterName() )
4497 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4499 if ( !initialDest.isEmpty() && initialDest == it->parameterName() )
4501 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4506 if ( mSourceParamComboBox->count() == 1 && !initialSource.isEmpty() )
4509 mSourceParamComboBox->addItem( initialSource, initialSource );
4510 mSourceParamComboBox->setCurrentIndex( mSourceParamComboBox->count() - 1 );
4512 if ( mDestParamComboBox->count() == 1 && !initialDest.isEmpty() )
4515 mDestParamComboBox->addItem( initialDest, initialDest );
4516 mDestParamComboBox->setCurrentIndex( mDestParamComboBox->count() - 1 );
4519 vlayout->addWidget(
new QLabel( tr(
"Source CRS parameter" ) ) );
4520 vlayout->addWidget( mSourceParamComboBox );
4521 vlayout->addWidget(
new QLabel( tr(
"Destination CRS parameter" ) ) );
4522 vlayout->addWidget( mDestParamComboBox );
4529 mStaticSourceWidget->setCrs( sourceCrs );
4532 mStaticDestWidget->setCrs( destCrs );
4534 vlayout->addWidget(
new QLabel( tr(
"Static source CRS" ) ) );
4535 vlayout->addWidget( mStaticSourceWidget );
4536 vlayout->addWidget(
new QLabel( tr(
"Static destination CRS" ) ) );
4537 vlayout->addWidget( mStaticDestWidget );
4542 setLayout( vlayout );
4547 auto param = std::make_unique<QgsProcessingParameterCoordinateOperation>(
4550 mDefaultLineEdit->text(),
4551 mSourceParamComboBox->currentText(),
4552 mDestParamComboBox->currentText(),
4553 mStaticSourceWidget->crs().isValid() ? QVariant::fromValue( mStaticSourceWidget->crs() ) : QVariant(),
4554 mStaticDestWidget->crs().isValid() ? QVariant::fromValue( mStaticDestWidget->crs() ) : QVariant()
4557 return param.release();
4564QWidget *QgsProcessingCoordinateOperationWidgetWrapper::createWidget()
4578 mOperationWidget->setShowMakeDefault(
false );
4579 mOperationWidget->setShowFallbackOption(
false );
4580 mOperationWidget->setToolTip( parameterDefinition()->toolTip() );
4581 mOperationWidget->setSourceCrs( mSourceCrs );
4582 mOperationWidget->setDestinationCrs( mDestCrs );
4583 mOperationWidget->setMapCanvas( mCanvas );
4588 mOperationWidget->setSelectedOperation( deets );
4593 return mOperationWidget;
4599 mLineEdit =
new QLineEdit();
4600 QHBoxLayout *layout =
new QHBoxLayout();
4601 layout->addWidget( mLineEdit, 1 );
4602 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
4604 QToolButton *button =
new QToolButton();
4605 button->setText( QString( QChar( 0x2026 ) ) );
4606 connect( button, &QToolButton::clicked,
this, [
this, button] {
4607 QgsDatumTransformDialog dlg( mSourceCrs, mDestCrs,
false,
false,
false, qMakePair( -1, -1 ), button, Qt::WindowFlags(), mLineEdit->text(), mCanvas );
4610 mLineEdit->setText( dlg.selectedDatumTransform().proj );
4611 emit widgetValueHasChanged(
this );
4614 layout->addWidget( button );
4616 QWidget *w =
new QWidget();
4617 layout->setContentsMargins( 0, 0, 0, 0 );
4618 w->setLayout( layout );
4625void 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 );
4752 return new QgsProcessingCoordinateOperationParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
4764 QHBoxLayout *hl =
new QHBoxLayout();
4765 hl->setContentsMargins( 0, 0, 0, 0 );
4767 mLineEdit =
new QLineEdit();
4768 mLineEdit->setEnabled(
false );
4769 hl->addWidget( mLineEdit, 1 );
4771 mToolButton =
new QToolButton();
4772 mToolButton->setText( QString( QChar( 0x2026 ) ) );
4773 hl->addWidget( mToolButton );
4779 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4782 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingFieldPanelWidget::showDialog );
4785void QgsProcessingFieldPanelWidget::setFields(
const QgsFields &fields )
4791 QVariantList availableFields;
4792 for (
const QgsField &field : std::as_const( mFields ) )
4794 availableFields << field.name();
4796 QList<QVariant>::iterator it = std::remove_if( mValue.begin(), mValue.end(), [&availableFields](
const QVariant &value ) { return !availableFields.contains( value ); } );
4797 mValue.erase( it, mValue.end() );
4799 updateSummaryText();
4803void QgsProcessingFieldPanelWidget::setValue(
const QVariant &value )
4805 if ( value.isValid() )
4806 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
4810 updateSummaryText();
4814void QgsProcessingFieldPanelWidget::showDialog()
4816 QVariantList availableOptions;
4817 availableOptions.reserve( mFields.size() );
4818 for (
const QgsField &field : std::as_const( mFields ) )
4820 availableOptions << field.name();
4826 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
4827 widget->setPanelTitle( mParam->description() );
4829 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
return v.toString(); } );
4831 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() { setValue( widget->selectedOptions() ); } );
4837 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
4839 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
return v.toString(); } );
4842 setValue( dlg.selectedOptions() );
4847void QgsProcessingFieldPanelWidget::updateSummaryText()
4852 if ( mValue.empty() )
4854 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, 0 ) );
4859 values.reserve( mValue.size() );
4860 for (
const QVariant &val : std::as_const( mValue ) )
4862 values << val.toString();
4865 const QString concatenated = values.join( tr(
"," ) );
4866 if ( concatenated.length() < 100 )
4867 mLineEdit->setText( concatenated );
4869 mLineEdit->setText( tr(
"%n field(s) selected",
nullptr, mValue.count() ) );
4878QgsProcessingFieldParameterDefinitionWidget::QgsProcessingFieldParameterDefinitionWidget(
4883 QVBoxLayout *vlayout =
new QVBoxLayout();
4884 vlayout->setContentsMargins( 0, 0, 0, 0 );
4886 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
4887 mParentLayerComboBox =
new QComboBox();
4889 QString initialParent;
4891 initialParent = fieldParam->parentLayerParameterName();
4893 if (
auto *lModel = widgetContext.
model() )
4896 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
4897 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
4901 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4902 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4904 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4909 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4910 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4912 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4919 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
4920 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
4922 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4929 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
4932 mParentLayerComboBox->addItem( initialParent, initialParent );
4933 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
4936 vlayout->addWidget( mParentLayerComboBox );
4939 vlayout->addWidget(
new QLabel( tr(
"Allowed data type" ) ) );
4940 mDataTypeComboBox =
new QComboBox();
4948 mDataTypeComboBox->setCurrentIndex( mDataTypeComboBox->findData(
static_cast<int>( fieldParam->dataType() ) ) );
4950 vlayout->addWidget( mDataTypeComboBox );
4953 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple fields" ) );
4955 mAllowMultipleCheckBox->setChecked( fieldParam->allowMultiple() );
4957 vlayout->addWidget( mAllowMultipleCheckBox );
4962 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all fields by default" ) );
4963 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
4965 mDefaultToAllCheckBox->setChecked( fieldParam->defaultToAllFields() );
4967 vlayout->addWidget( mDefaultToAllCheckBox );
4970 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [
this] { mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() ); } );
4972 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
4974 mDefaultLineEdit =
new QLineEdit();
4975 mDefaultLineEdit->setToolTip( tr(
"Default field name, or ; separated list of field names for multiple field parameters" ) );
4979 mDefaultLineEdit->setText( fields.join(
';' ) );
4981 vlayout->addWidget( mDefaultLineEdit );
4985 setLayout( vlayout );
4992 QVariant defaultValue;
4993 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
4995 defaultValue = mDefaultLineEdit->text();
4997 auto param = std::make_unique<
4998 QgsProcessingParameterField>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), dataType, mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
5000 return param.release();
5007QWidget *QgsProcessingFieldWidgetWrapper::createWidget()
5020 mPanel =
new QgsProcessingFieldPanelWidget(
nullptr, fieldParam );
5021 mPanel->setToolTip( parameterDefinition()->toolTip() );
5022 connect( mPanel, &QgsProcessingFieldPanelWidget::changed,
this, [
this] { emit widgetValueHasChanged(
this ); } );
5041 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5049 mLineEdit =
new QLineEdit();
5050 mLineEdit->setToolTip( QObject::tr(
"Name of field (separate field names with ; for multiple field parameters)" ) );
5051 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
5058void QgsProcessingFieldWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
5070 setParentLayerWrapperValue( wrapper );
5087 std::unique_ptr<QgsProcessingContext> tmpContext;
5088 if ( mProcessingContextGenerator )
5089 context = mProcessingContextGenerator->processingContext();
5093 tmpContext = std::make_unique<QgsProcessingContext>();
5094 context = tmpContext.get();
5099 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
5109 bool valueSet =
false;
5113 if ( layers.count() > 1 )
5115 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5117 const QList<QgsMapLayer *> remainingLayers = layers.mid( 1 );
5123 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
5124 if ( !vlayer || !vlayer->
isValid() )
5130 for (
int fieldIdx = fields.
count() - 1; fieldIdx >= 0; fieldIdx-- )
5133 fields.
remove( fieldIdx );
5138 mComboBox->setFields( fields );
5140 mPanel->setFields( filterFields( fields ) );
5146 if ( !valueSet && !layers.isEmpty() && layers.at( 0 )->isValid() )
5148 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
5152 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
5155 mParentLayer.reset( qobject_cast<QgsVectorLayer *>( ownedLayer.release() ) );
5156 layer = mParentLayer.get();
5164 mComboBox->setLayer( layer );
5166 mPanel->setFields( filterFields( layer->
fields() ) );
5176 const QgsFields fields = source->fields();
5178 mComboBox->setFields( fields );
5180 mPanel->setFields( filterFields( fields ) );
5189 mComboBox->setLayer(
nullptr );
5193 if ( value.isValid() && widgetContext().messageBar() )
5205 val.reserve( mPanel->fields().size() );
5206 for (
const QgsField &field : mPanel->fields() )
5207 val << field.name();
5208 setWidgetValue( val, *context );
5211 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5214void QgsProcessingFieldWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5218 if ( !value.isValid() )
5219 mComboBox->setField( QString() );
5223 mComboBox->setField( v );
5229 if ( value.isValid() )
5232 opts.reserve( v.size() );
5233 for (
const QString &i : v )
5237 mPanel->setValue( opts );
5239 else if ( mLineEdit )
5245 mLineEdit->setText( v.join(
';' ) );
5254QVariant QgsProcessingFieldWidgetWrapper::widgetValue()
const
5257 return mComboBox->currentField();
5259 return mPanel->value();
5260 else if ( mLineEdit )
5265 return mLineEdit->text().split(
';' );
5268 return mLineEdit->text();
5274QString QgsProcessingFieldWidgetWrapper::modelerExpressionFormatString()
const
5276 return tr(
"selected field names as an array of names, or semicolon separated string of options (e.g. 'fid;place_name')" );
5279const QgsVectorLayer *QgsProcessingFieldWidgetWrapper::linkedVectorLayer()
const
5281 if ( mComboBox && mComboBox->layer() )
5282 return mComboBox->layer();
5287QgsFields QgsProcessingFieldWidgetWrapper::filterFields(
const QgsFields &fields )
const
5300 if ( f.isNumeric() )
5305 if ( f.type() == QMetaType::Type::QString )
5310 if ( f.type() == QMetaType::Type::QDate || f.type() == QMetaType::Type::QTime || f.type() == QMetaType::Type::QDateTime )
5315 if ( f.type() == QMetaType::Type::QByteArray )
5320 if ( f.type() == QMetaType::Type::Bool )
5329QString QgsProcessingFieldWidgetWrapper::parameterType()
const
5336 return new QgsProcessingFieldWidgetWrapper( parameter, type );
5343 return new QgsProcessingFieldParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5351QgsProcessingMapThemeParameterDefinitionWidget::QgsProcessingMapThemeParameterDefinitionWidget(
5356 QVBoxLayout *vlayout =
new QVBoxLayout();
5357 vlayout->setContentsMargins( 0, 0, 0, 0 );
5359 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5361 mDefaultComboBox =
new QComboBox();
5362 mDefaultComboBox->addItem( QString(), QVariant( -1 ) );
5365 for (
const QString &theme : mapThemes )
5369 mDefaultComboBox->setEditable(
true );
5373 if ( themeParam->defaultValueForGui().isValid() )
5376 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5379 mDefaultComboBox->setCurrentIndex( mDefaultComboBox->findData( -1 ) );
5381 vlayout->addWidget( mDefaultComboBox );
5385 setLayout( vlayout );
5390 QVariant defaultVal;
5391 if ( mDefaultComboBox->currentText().isEmpty() )
5392 defaultVal = QVariant();
5394 defaultVal = mDefaultComboBox->currentText();
5395 auto param = std::make_unique<QgsProcessingParameterMapTheme>( name, description, defaultVal );
5397 return param.release();
5405QWidget *QgsProcessingMapThemeWidgetWrapper::createWidget()
5411 mComboBox =
new QComboBox();
5414 mComboBox->addItem( tr(
"[Not selected]" ), QVariant( -1 ) );
5417 for (
const QString &theme : mapThemes )
5429 mComboBox->setEditable(
true );
5433 mComboBox->setToolTip( parameterDefinition()->toolTip() );
5434 connect( mComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) { emit widgetValueHasChanged(
this ); } );
5439void QgsProcessingMapThemeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5443 if ( !value.isValid() )
5444 mComboBox->setCurrentIndex( mComboBox->findData( QVariant( -1 ) ) );
5447 if ( mComboBox->isEditable() && mComboBox->findData( v ) == -1 )
5449 const QString prev = mComboBox->currentText();
5450 mComboBox->setCurrentText( v );
5452 emit widgetValueHasChanged(
this );
5455 mComboBox->setCurrentIndex( mComboBox->findData( v ) );
5459QVariant QgsProcessingMapThemeWidgetWrapper::widgetValue()
const
5462 return mComboBox->currentData().toInt() == -1 ? QVariant()
5463 : !mComboBox->currentData().isValid() && mComboBox->isEditable() ? mComboBox->currentText().isEmpty() ? QVariant() : QVariant( mComboBox->currentText() )
5464 : mComboBox->currentData();
5469QString QgsProcessingMapThemeWidgetWrapper::modelerExpressionFormatString()
const
5471 return tr(
"map theme as a string value (e.g. 'base maps')" );
5474QString QgsProcessingMapThemeWidgetWrapper::parameterType()
const
5481 return new QgsProcessingMapThemeWidgetWrapper( parameter, type );
5488 return new QgsProcessingMapThemeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5497QgsProcessingDateTimeParameterDefinitionWidget::QgsProcessingDateTimeParameterDefinitionWidget(
5502 QVBoxLayout *vlayout =
new QVBoxLayout();
5503 vlayout->setContentsMargins( 0, 0, 0, 0 );
5505 vlayout->addWidget(
new QLabel( tr(
"Type" ) ) );
5507 mTypeComboBox =
new QComboBox();
5512 mTypeComboBox->setCurrentIndex( mTypeComboBox->findData(
static_cast<int>( datetimeParam->dataType() ) ) );
5514 mTypeComboBox->setCurrentIndex( 0 );
5515 vlayout->addWidget( mTypeComboBox );
5519 setLayout( vlayout );
5524 auto param = std::make_unique<QgsProcessingParameterDateTime>( name, description );
5527 return param.release();
5535QWidget *QgsProcessingDateTimeWidgetWrapper::createWidget()
5538 if ( !dateTimeParam )
5542 switch ( dateTimeParam->
dataType() )
5546 widget = mDateTimeEdit;
5571 widget->setToolTip( parameterDefinition()->toolTip() );
5573 if ( mDateTimeEdit )
5577 else if ( mDateEdit )
5581 else if ( mTimeEdit )
5593 return new QgsProcessingDateTimeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5596void QgsProcessingDateTimeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5598 if ( mDateTimeEdit )
5602 else if ( mDateEdit )
5606 else if ( mTimeEdit )
5612QVariant QgsProcessingDateTimeWidgetWrapper::widgetValue()
const
5614 if ( mDateTimeEdit )
5615 return !mDateTimeEdit->dateTime().isNull() && mDateTimeEdit->dateTime().isValid() ? QVariant( mDateTimeEdit->dateTime() ) : QVariant();
5616 else if ( mDateEdit )
5617 return !mDateEdit->date().isNull() && mDateEdit->date().isValid() ? QVariant( mDateEdit->date() ) : QVariant();
5618 else if ( mTimeEdit )
5619 return !mTimeEdit->time().isNull() && mTimeEdit->time().isValid() ? QVariant( mTimeEdit->time() ) : QVariant();
5624QString QgsProcessingDateTimeWidgetWrapper::modelerExpressionFormatString()
const
5627 if ( dateTimeParam )
5629 switch ( dateTimeParam->
dataType() )
5632 return tr(
"datetime value, or a ISO string representation of a datetime" );
5635 return tr(
"date value, or a ISO string representation of a date" );
5638 return tr(
"time value, or a ISO string representation of a time" );
5644QString QgsProcessingDateTimeWidgetWrapper::parameterType()
const
5651 return new QgsProcessingDateTimeWidgetWrapper( parameter, type );
5659QgsProcessingProviderConnectionParameterDefinitionWidget::QgsProcessingProviderConnectionParameterDefinitionWidget(
5666 QVBoxLayout *vlayout =
new QVBoxLayout();
5667 vlayout->setContentsMargins( 0, 0, 0, 0 );
5669 vlayout->addWidget(
new QLabel( tr(
"Provider" ) ) );
5670 mProviderComboBox =
new QComboBox();
5671 mProviderComboBox->addItem( QObject::tr(
"Postgres" ), u
"postgres"_s );
5672 mProviderComboBox->addItem( QObject::tr(
"GeoPackage" ), u
"ogr"_s );
5673 mProviderComboBox->addItem( QObject::tr(
"Spatialite" ), u
"spatialite"_s );
5675 vlayout->addWidget( mProviderComboBox );
5677 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5679 mDefaultEdit =
new QLineEdit();
5680 vlayout->addWidget( mDefaultEdit );
5681 setLayout( vlayout );
5683 if ( connectionParam )
5685 mProviderComboBox->setCurrentIndex( mProviderComboBox->findData( connectionParam->
providerId() ) );
5695 QVariant defaultVal;
5696 if ( mDefaultEdit->text().isEmpty() )
5697 defaultVal = QVariant();
5699 defaultVal = mDefaultEdit->text();
5700 auto param = std::make_unique<QgsProcessingParameterProviderConnection>( name, description, mProviderComboBox->currentData().toString(), defaultVal );
5702 return param.release();
5710QWidget *QgsProcessingProviderConnectionWidgetWrapper::createWidget()
5713 if ( !connectionParam )
5718 mProviderComboBox->setAllowEmptyConnection(
true );
5726 mProviderComboBox->setEditable(
true );
5730 mProviderComboBox->setToolTip( parameterDefinition()->toolTip() );
5731 connect( mProviderComboBox, &QgsProviderConnectionComboBox::currentTextChanged,
this, [
this](
const QString & ) {
5732 if ( mBlockSignals )
5735 emit widgetValueHasChanged(
this );
5738 return mProviderComboBox;
5745 return new QgsProcessingProviderConnectionParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5748void QgsProcessingProviderConnectionWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5752 if ( !value.isValid() )
5753 mProviderComboBox->setCurrentIndex( -1 );
5756 if ( mProviderComboBox->isEditable() )
5758 const QString prev = mProviderComboBox->currentText();
5760 mProviderComboBox->setConnection( v );
5761 mProviderComboBox->setCurrentText( v );
5765 emit widgetValueHasChanged(
this );
5768 mProviderComboBox->setConnection( v );
5772QVariant QgsProcessingProviderConnectionWidgetWrapper::widgetValue()
const
5774 if ( mProviderComboBox )
5775 if ( mProviderComboBox->isEditable() )
5776 return mProviderComboBox->currentText().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentText() );
5778 return mProviderComboBox->currentConnection().isEmpty() ? QVariant() : QVariant( mProviderComboBox->currentConnection() );
5783QString QgsProcessingProviderConnectionWidgetWrapper::modelerExpressionFormatString()
const
5785 return tr(
"connection name as a string value" );
5788QString QgsProcessingProviderConnectionWidgetWrapper::parameterType()
const
5795 return new QgsProcessingProviderConnectionWidgetWrapper( parameter, type );
5803QgsProcessingDatabaseSchemaParameterDefinitionWidget::QgsProcessingDatabaseSchemaParameterDefinitionWidget(
5810 QVBoxLayout *vlayout =
new QVBoxLayout();
5811 vlayout->setContentsMargins( 0, 0, 0, 0 );
5813 mConnectionParamComboBox =
new QComboBox();
5814 QString initialConnection;
5820 if (
auto *lModel = widgetContext.
model() )
5823 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
5824 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
5826 if ( definition && it->parameterName() == definition->
name() )
5832 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
5833 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
5835 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5840 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
5843 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
5844 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
5847 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
5848 vlayout->addWidget( mConnectionParamComboBox );
5852 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
5854 mDefaultEdit =
new QLineEdit();
5855 vlayout->addWidget( mDefaultEdit );
5856 setLayout( vlayout );
5867 QVariant defaultVal;
5868 if ( mDefaultEdit->text().isEmpty() )
5869 defaultVal = QVariant();
5871 defaultVal = mDefaultEdit->text();
5872 auto param = std::make_unique<QgsProcessingParameterDatabaseSchema>( name, description, mConnectionParamComboBox->currentData().toString(), defaultVal );
5874 return param.release();
5882QWidget *QgsProcessingDatabaseSchemaWidgetWrapper::createWidget()
5890 mSchemaComboBox->setAllowEmptySchema(
true );
5898 mSchemaComboBox->comboBox()->setEditable(
true );
5902 mSchemaComboBox->setToolTip( parameterDefinition()->toolTip() );
5903 connect( mSchemaComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
5904 if ( mBlockSignals )
5907 emit widgetValueHasChanged( this );
5910 return mSchemaComboBox;
5917 return new QgsProcessingDatabaseSchemaParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
5924 std::unique_ptr<QgsProcessingContext> tmpContext;
5925 if ( mProcessingContextGenerator )
5926 context = mProcessingContextGenerator->processingContext();
5930 tmpContext = std::make_unique<QgsProcessingContext>();
5931 context = tmpContext.get();
5937 if ( mSchemaComboBox )
5938 mSchemaComboBox->setConnectionName( connection, qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId() );
5942 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
5945void QgsProcessingDatabaseSchemaWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
5949 if ( !value.isValid() )
5950 mSchemaComboBox->comboBox()->setCurrentIndex( -1 );
5953 if ( mSchemaComboBox->comboBox()->isEditable() )
5955 const QString prev = mSchemaComboBox->comboBox()->currentText();
5957 mSchemaComboBox->setSchema( v );
5958 mSchemaComboBox->comboBox()->setCurrentText( v );
5962 emit widgetValueHasChanged(
this );
5965 mSchemaComboBox->setSchema( v );
5969QVariant QgsProcessingDatabaseSchemaWidgetWrapper::widgetValue()
const
5971 if ( mSchemaComboBox )
5972 if ( mSchemaComboBox->comboBox()->isEditable() )
5973 return mSchemaComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->comboBox()->currentText() );
5975 return mSchemaComboBox->currentSchema().isEmpty() ? QVariant() : QVariant( mSchemaComboBox->currentSchema() );
5980QString QgsProcessingDatabaseSchemaWidgetWrapper::modelerExpressionFormatString()
const
5982 return tr(
"database schema name as a string value" );
5985QString QgsProcessingDatabaseSchemaWidgetWrapper::parameterType()
const
5992 return new QgsProcessingDatabaseSchemaWidgetWrapper( parameter, type );
5995void QgsProcessingDatabaseSchemaWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6007 setParentConnectionWrapperValue( wrapper );
6025QgsProcessingDatabaseTableParameterDefinitionWidget::QgsProcessingDatabaseTableParameterDefinitionWidget(
6032 QVBoxLayout *vlayout =
new QVBoxLayout();
6033 vlayout->setContentsMargins( 0, 0, 0, 0 );
6035 mConnectionParamComboBox =
new QComboBox();
6036 mSchemaParamComboBox =
new QComboBox();
6037 QString initialConnection;
6038 QString initialSchema;
6045 if (
auto *lModel = widgetContext.
model() )
6048 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6049 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6051 if ( definition && it->parameterName() == definition->
name() )
6056 mConnectionParamComboBox->addItem( it->parameterName(), it->parameterName() );
6057 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6059 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6064 mSchemaParamComboBox->addItem( it->parameterName(), it->parameterName() );
6065 if ( !initialConnection.isEmpty() && initialConnection == it->parameterName() )
6067 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6073 if ( mConnectionParamComboBox->count() == 0 && !initialConnection.isEmpty() )
6076 mConnectionParamComboBox->addItem( initialConnection, initialConnection );
6077 mConnectionParamComboBox->setCurrentIndex( mConnectionParamComboBox->count() - 1 );
6080 if ( mSchemaParamComboBox->count() == 0 && !initialSchema.isEmpty() )
6083 mSchemaParamComboBox->addItem( initialSchema, initialSchema );
6084 mSchemaParamComboBox->setCurrentIndex( mSchemaParamComboBox->count() - 1 );
6087 vlayout->addWidget(
new QLabel( tr(
"Provider connection parameter" ) ) );
6088 vlayout->addWidget( mConnectionParamComboBox );
6090 vlayout->addWidget(
new QLabel( tr(
"Database schema parameter" ) ) );
6091 vlayout->addWidget( mSchemaParamComboBox );
6096 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6098 mDefaultEdit =
new QLineEdit();
6099 vlayout->addWidget( mDefaultEdit );
6100 setLayout( vlayout );
6111 QVariant defaultVal;
6112 if ( mDefaultEdit->text().isEmpty() )
6113 defaultVal = QVariant();
6115 defaultVal = mDefaultEdit->text();
6116 auto param = std::make_unique<QgsProcessingParameterDatabaseTable>( name, description, mConnectionParamComboBox->currentData().toString(), mSchemaParamComboBox->currentData().toString(), defaultVal );
6118 return param.release();
6126QWidget *QgsProcessingDatabaseTableWidgetWrapper::createWidget()
6134 mTableComboBox->setAllowEmptyTable(
true );
6137 mTableComboBox->comboBox()->setEditable(
true );
6139 mTableComboBox->setToolTip( parameterDefinition()->toolTip() );
6140 connect( mTableComboBox->comboBox(), &QComboBox::currentTextChanged,
this, [
this](
const QString & ) {
6141 if ( mBlockSignals )
6144 emit widgetValueHasChanged( this );
6147 return mTableComboBox;
6154 return new QgsProcessingDatabaseTableParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6161 std::unique_ptr<QgsProcessingContext> tmpContext;
6162 if ( mProcessingContextGenerator )
6163 context = mProcessingContextGenerator->processingContext();
6167 tmpContext = std::make_unique<QgsProcessingContext>();
6168 context = tmpContext.get();
6173 mProvider = qgis::down_cast<const QgsProcessingParameterProviderConnection *>( parentWrapper->
parameterDefinition() )->providerId();
6174 if ( mTableComboBox && !mSchema.isEmpty() )
6176 mTableComboBox->setSchema( mSchema );
6177 mTableComboBox->setConnectionName( mConnection, mProvider );
6181 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6189 std::unique_ptr<QgsProcessingContext> tmpContext;
6190 if ( mProcessingContextGenerator )
6191 context = mProcessingContextGenerator->processingContext();
6195 tmpContext = std::make_unique<QgsProcessingContext>();
6196 context = tmpContext.get();
6202 if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
6204 mTableComboBox->setSchema( mSchema );
6205 mTableComboBox->setConnectionName( mConnection, mProvider );
6207 const QgsProcessingParameterDatabaseTable *tableParam = static_cast<const QgsProcessingParameterDatabaseTable *>( parameterDefinition() );
6208 if ( tableParam->defaultValueForGui().isValid() )
6209 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
6213void QgsProcessingDatabaseTableWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6217 if ( !value.isValid() )
6218 mTableComboBox->comboBox()->setCurrentIndex( -1 );
6221 if ( mTableComboBox->comboBox()->isEditable() )
6223 const QString prev = mTableComboBox->comboBox()->currentText();
6225 mTableComboBox->setTable( v );
6226 mTableComboBox->comboBox()->setCurrentText( v );
6230 emit widgetValueHasChanged(
this );
6233 mTableComboBox->setTable( v );
6237QVariant QgsProcessingDatabaseTableWidgetWrapper::widgetValue()
const
6239 if ( mTableComboBox )
6240 if ( mTableComboBox->comboBox()->isEditable() )
6241 return mTableComboBox->comboBox()->currentText().isEmpty() ? QVariant() : QVariant( mTableComboBox->comboBox()->currentText() );
6243 return mTableComboBox->currentTable().isEmpty() ? QVariant() : QVariant( mTableComboBox->currentTable() );
6248QString QgsProcessingDatabaseTableWidgetWrapper::modelerExpressionFormatString()
const
6250 return tr(
"database table name as a string value" );
6253QString QgsProcessingDatabaseTableWidgetWrapper::parameterType()
const
6260 return new QgsProcessingDatabaseTableWidgetWrapper( parameter, type );
6263void QgsProcessingDatabaseTableWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
6275 setParentConnectionWrapperValue( wrapper );
6280 setParentSchemaWrapperValue( wrapper );
6297QgsProcessingExtentParameterDefinitionWidget::QgsProcessingExtentParameterDefinitionWidget(
6302 QVBoxLayout *vlayout =
new QVBoxLayout();
6303 vlayout->setContentsMargins( 0, 0, 0, 0 );
6305 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6308 mDefaultWidget->setNullValueAllowed(
true, tr(
"Not set" ) );
6311 if ( extentParam->defaultValueForGui().isValid() )
6315 mDefaultWidget->setCurrentExtent( rect, crs );
6316 mDefaultWidget->setOutputExtentFromCurrent();
6320 mDefaultWidget->clear();
6326 vlayout->addWidget( mDefaultWidget );
6327 setLayout( vlayout );
6332 const QString defaultVal = mDefaultWidget->isValid() ? u
"%1,%2,%3,%4%5"_s.arg(
6333 QString::number( mDefaultWidget->outputExtent().xMinimum(),
'f', 9 ),
6334 QString::number( mDefaultWidget->outputExtent().xMaximum(),
'f', 9 ),
6335 QString::number( mDefaultWidget->outputExtent().yMinimum(),
'f', 9 ),
6336 QString::number( mDefaultWidget->outputExtent().yMaximum(),
'f', 9 ),
6337 mDefaultWidget->outputCrs().isValid() ? u
" [%1]"_s.arg( mDefaultWidget->outputCrs().authid() ) : QString()
6340 auto param = std::make_unique<QgsProcessingParameterExtent>( name, description, !defaultVal.isEmpty() ? QVariant( defaultVal ) : QVariant() );
6342 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() );
6374 setDialog( mDialog );
6376 return mExtentWidget;
6386 mExtentWidget->setMapCanvas( context.
mapCanvas() );
6389void QgsProcessingExtentWidgetWrapper::setDialog( QWidget *dialog )
6396 mDialog->showMinimized();
6399 mDialog->showNormal();
6401 mDialog->activateWindow();
6408void QgsProcessingExtentWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6410 if ( mExtentWidget )
6412 if ( !value.isValid() || ( value.userType() == QMetaType::Type::QString && value.toString().isEmpty() ) )
6413 mExtentWidget->clear();
6418 mExtentWidget->setCurrentExtent( r, crs );
6419 mExtentWidget->setOutputExtentFromUser( r, crs );
6424QVariant QgsProcessingExtentWidgetWrapper::widgetValue()
const
6426 if ( mExtentWidget )
6428 const QString val = mExtentWidget->isValid() ? u
"%1,%2,%3,%4%5"_s.arg(
6429 QString::number( mExtentWidget->outputExtent().xMinimum(),
'f', 9 ),
6430 QString::number( mExtentWidget->outputExtent().xMaximum(),
'f', 9 ),
6431 QString::number( mExtentWidget->outputExtent().yMinimum(),
'f', 9 ),
6432 QString::number( mExtentWidget->outputExtent().yMaximum(),
'f', 9 ),
6433 mExtentWidget->outputCrs().isValid() ? u
" [%1]"_s.arg( mExtentWidget->outputCrs().authid() ) : QString()
6437 return val.isEmpty() ? QVariant() : QVariant( val );
6443QString QgsProcessingExtentWidgetWrapper::modelerExpressionFormatString()
const
6445 return tr(
"string of the format 'x min,x max,y min,y max' or a geometry value (bounding box is used)" );
6448QString QgsProcessingExtentWidgetWrapper::parameterType()
const
6455 return new QgsProcessingExtentWidgetWrapper( parameter, type );
6462 return new QgsProcessingExtentParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6470QgsProcessingMapLayerParameterDefinitionWidget::QgsProcessingMapLayerParameterDefinitionWidget(
6475 QVBoxLayout *vlayout =
new QVBoxLayout();
6476 vlayout->setContentsMargins( 0, 0, 0, 0 );
6478 vlayout->addWidget(
new QLabel( tr(
"Layer type" ) ) );
6494 for (
int i : layerParam->dataTypes() )
6496 mLayerTypeComboBox->setItemCheckState( mLayerTypeComboBox->findData( i ), Qt::Checked );
6500 vlayout->addWidget( mLayerTypeComboBox );
6504 setLayout( vlayout );
6509 QList<int> dataTypes;
6510 for (
const QVariant &v : mLayerTypeComboBox->checkedItemsData() )
6511 dataTypes << v.toInt();
6513 auto param = std::make_unique<QgsProcessingParameterMapLayer>( name, description );
6514 param->setDataTypes( dataTypes );
6516 return param.release();
6523QWidget *QgsProcessingMapLayerWidgetWrapper::createWidget()
6525 mComboBox =
new QgsProcessingMapLayerComboBox( parameterDefinition(), type() );
6533 mComboBox->setEditable(
true );
6537 mComboBox->setToolTip( parameterDefinition()->toolTip() );
6539 connect( mComboBox, &QgsProcessingMapLayerComboBox::valueChanged,
this, [
this]() {
6540 if ( mBlockSignals )
6543 emit widgetValueHasChanged(
this );
6546 setWidgetContext( widgetContext() );
6555 mComboBox->setWidgetContext( context );
6560 if ( !parameterDefinition()->defaultValueForGui().isValid() )
6566void QgsProcessingMapLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
6569 mComboBox->setValue( value, context );
6572QVariant QgsProcessingMapLayerWidgetWrapper::widgetValue()
const
6574 return mComboBox ? mComboBox->value() : QVariant();
6577QString QgsProcessingMapLayerWidgetWrapper::modelerExpressionFormatString()
const
6579 return tr(
"path to a map layer" );
6596QString QgsProcessingMapLayerWidgetWrapper::parameterType()
const
6603 return new QgsProcessingMapLayerWidgetWrapper( parameter, type );
6610 return new QgsProcessingMapLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6619 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6622QString QgsProcessingRasterLayerWidgetWrapper::modelerExpressionFormatString()
const
6624 return tr(
"path to a raster layer" );
6627QString QgsProcessingRasterLayerWidgetWrapper::parameterType()
const
6634 return new QgsProcessingRasterLayerWidgetWrapper( parameter, type );
6641 Q_UNUSED( context );
6642 Q_UNUSED( widgetContext );
6643 Q_UNUSED( definition );
6654QgsProcessingVectorLayerParameterDefinitionWidget::QgsProcessingVectorLayerParameterDefinitionWidget(
6659 QVBoxLayout *vlayout =
new QVBoxLayout();
6660 vlayout->setContentsMargins( 0, 0, 0, 0 );
6662 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6672 for (
int i : vectorParam->dataTypes() )
6674 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6678 vlayout->addWidget( mGeometryTypeComboBox );
6682 setLayout( vlayout );
6687 QList<int> dataTypes;
6688 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6689 dataTypes << v.toInt();
6691 auto param = std::make_unique<QgsProcessingParameterVectorLayer>( name, description, dataTypes );
6693 return param.release();
6698 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6701QString QgsProcessingVectorLayerWidgetWrapper::modelerExpressionFormatString()
const
6703 return tr(
"path to a vector layer" );
6706QString QgsProcessingVectorLayerWidgetWrapper::parameterType()
const
6713 return new QgsProcessingVectorLayerWidgetWrapper( parameter, type );
6720 return new QgsProcessingVectorLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6728QgsProcessingFeatureSourceParameterDefinitionWidget::QgsProcessingFeatureSourceParameterDefinitionWidget(
6733 QVBoxLayout *vlayout =
new QVBoxLayout();
6734 vlayout->setContentsMargins( 0, 0, 0, 0 );
6736 vlayout->addWidget(
new QLabel( tr(
"Geometry type" ) ) );
6746 for (
int i : sourceParam->dataTypes() )
6748 mGeometryTypeComboBox->setItemCheckState( mGeometryTypeComboBox->findData( i ), Qt::Checked );
6756 vlayout->addWidget( mGeometryTypeComboBox );
6759 setLayout( vlayout );
6764 QList<int> dataTypes;
6765 for (
const QVariant &v : mGeometryTypeComboBox->checkedItemsData() )
6766 dataTypes << v.toInt();
6768 auto param = std::make_unique<QgsProcessingParameterFeatureSource>( name, description, dataTypes );
6770 return param.release();
6774 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6777QString QgsProcessingFeatureSourceWidgetWrapper::modelerExpressionFormatString()
const
6779 return tr(
"path to a vector layer" );
6782QString QgsProcessingFeatureSourceWidgetWrapper::parameterType()
const
6789 return new QgsProcessingFeatureSourceWidgetWrapper( parameter, type );
6796 return new QgsProcessingFeatureSourceParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
6804 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
6807QString QgsProcessingMeshLayerWidgetWrapper::modelerExpressionFormatString()
const
6809 return tr(
"path to a mesh layer" );
6812QString QgsProcessingMeshLayerWidgetWrapper::parameterType()
const
6819 return new QgsProcessingMeshLayerWidgetWrapper( parameter, type );
6826 Q_UNUSED( context );
6827 Q_UNUSED( widgetContext );
6828 Q_UNUSED( definition );
6839QgsProcessingRasterBandPanelWidget::QgsProcessingRasterBandPanelWidget( QWidget *parent,
const QgsProcessingParameterBand *param )
6843 QHBoxLayout *hl =
new QHBoxLayout();
6844 hl->setContentsMargins( 0, 0, 0, 0 );
6846 mLineEdit =
new QLineEdit();
6847 mLineEdit->setEnabled(
false );
6848 hl->addWidget( mLineEdit, 1 );
6850 mToolButton =
new QToolButton();
6851 mToolButton->setText( QString( QChar( 0x2026 ) ) );
6852 hl->addWidget( mToolButton );
6858 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, 0 ) );
6861 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingRasterBandPanelWidget::showDialog );
6864void QgsProcessingRasterBandPanelWidget::setBands(
const QList<int> &bands )
6869void QgsProcessingRasterBandPanelWidget::setBandNames(
const QHash<int, QString> &names )
6874void QgsProcessingRasterBandPanelWidget::setValue(
const QVariant &value )
6876 if ( value.isValid() )
6877 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
6881 updateSummaryText();
6885void QgsProcessingRasterBandPanelWidget::showDialog()
6887 QVariantList availableOptions;
6888 availableOptions.reserve( mBands.size() );
6889 for (
int band : std::as_const( mBands ) )
6891 availableOptions << band;
6897 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
6898 widget->setPanelTitle( mParam->description() );
6900 widget->setValueFormatter( [
this](
const QVariant &v ) -> QString {
6901 int band = v.toInt();
6902 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6905 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() { setValue( widget->selectedOptions() ); } );
6911 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
6913 dlg.setValueFormatter( [
this](
const QVariant &v ) -> QString {
6914 int band = v.toInt();
6915 return mBandNames.contains( band ) ? mBandNames.value( band ) : v.toString();
6919 setValue( dlg.selectedOptions() );
6924void QgsProcessingRasterBandPanelWidget::updateSummaryText()
6927 mLineEdit->setText( tr(
"%n band(s) selected",
nullptr, mValue.count() ) );
6935QgsProcessingBandParameterDefinitionWidget::QgsProcessingBandParameterDefinitionWidget(
6940 QVBoxLayout *vlayout =
new QVBoxLayout();
6941 vlayout->setContentsMargins( 0, 0, 0, 0 );
6943 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
6945 mDefaultLineEdit =
new QLineEdit();
6946 mDefaultLineEdit->setToolTip( tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
6951 for (
int b : bands )
6953 defVal << QString::number( b );
6956 mDefaultLineEdit->setText( defVal.join(
';' ) );
6958 vlayout->addWidget( mDefaultLineEdit );
6961 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
6962 mParentLayerComboBox =
new QComboBox();
6964 QString initialParent;
6966 initialParent = bandParam->parentLayerParameterName();
6968 if (
auto *lModel = widgetContext.
model() )
6971 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
6972 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
6976 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
6977 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
6979 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6985 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
6988 mParentLayerComboBox->addItem( initialParent, initialParent );
6989 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
6993 vlayout->addWidget( mParentLayerComboBox );
6995 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Allow multiple" ) );
6997 mAllowMultipleCheckBox->setChecked( bandParam->allowMultiple() );
7000 vlayout->addWidget( mAllowMultipleCheckBox );
7001 setLayout( vlayout );
7007 = std::make_unique<QgsProcessingParameterBand>( name, description, mDefaultLineEdit->text().split(
';' ), mParentLayerComboBox->currentData().toString(),
false, mAllowMultipleCheckBox->isChecked() );
7009 return param.release();
7016QWidget *QgsProcessingBandWidgetWrapper::createWidget()
7029 mPanel =
new QgsProcessingRasterBandPanelWidget(
nullptr, bandParam );
7030 mPanel->setToolTip( parameterDefinition()->toolTip() );
7031 connect( mPanel, &QgsProcessingRasterBandPanelWidget::changed,
this, [
this] { emit widgetValueHasChanged(
this ); } );
7039 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7047 mLineEdit =
new QLineEdit();
7048 mLineEdit->setToolTip( QObject::tr(
"Band number (separate bands with ; for multiple band parameters)" ) );
7049 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
7056void QgsProcessingBandWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
7068 setParentLayerWrapperValue( wrapper );
7085 std::unique_ptr<QgsProcessingContext> tmpContext;
7086 if ( mProcessingContextGenerator )
7087 context = mProcessingContextGenerator->processingContext();
7091 tmpContext = std::make_unique<QgsProcessingContext>();
7092 context = tmpContext.get();
7098 if ( layer && layer->
isValid() )
7102 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
7105 mParentLayer.reset( qobject_cast<QgsRasterLayer *>( ownedLayer.release() ) );
7106 layer = mParentLayer.get();
7114 mComboBox->setLayer( layer );
7118 if ( provider && layer->
isValid() )
7123 QHash<int, QString> bandNames;
7124 for (
int i = 1; i <= nBands; ++i )
7129 mPanel->setBands( bands );
7130 mPanel->setBandNames( bandNames );
7137 mComboBox->setLayer(
nullptr );
7139 mPanel->setBands( QList<int>() );
7141 if ( value.isValid() && widgetContext().messageBar() )
7148 if ( parameterDefinition()->defaultValueForGui().isValid() )
7149 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
7152void QgsProcessingBandWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7156 if ( !value.isValid() )
7157 mComboBox->setBand( -1 );
7161 mComboBox->setBand( v );
7167 if ( value.isValid() )
7170 opts.reserve( v.size() );
7175 mPanel->setValue( value.isValid() ? opts : QVariant() );
7177 else if ( mLineEdit )
7184 opts.reserve( v.size() );
7186 opts << QString::number( i );
7187 mLineEdit->setText( value.isValid() && !opts.empty() ? opts.join(
';' ) : QString() );
7191 if ( value.isValid() )
7199QVariant QgsProcessingBandWidgetWrapper::widgetValue()
const
7202 return mComboBox->currentBand() == -1 ? QVariant() : mComboBox->currentBand();
7204 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7205 else if ( mLineEdit )
7210 const QStringList parts = mLineEdit->text().split(
';', Qt::SkipEmptyParts );
7212 res.reserve( parts.count() );
7213 for (
const QString &s : parts )
7216 int band = s.toInt( &ok );
7220 return res.
isEmpty() ? QVariant() : res;
7224 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
7231QString QgsProcessingBandWidgetWrapper::modelerExpressionFormatString()
const
7233 return tr(
"selected band numbers as an array of numbers, or semicolon separated string of options (e.g. '1;3')" );
7236QString QgsProcessingBandWidgetWrapper::parameterType()
const
7243 return new QgsProcessingBandWidgetWrapper( parameter, type );
7250 return new QgsProcessingBandParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7261 setAcceptDrops(
true );
7264void QgsProcessingMultipleLayerLineEdit::dragEnterEvent( QDragEnterEvent *event )
7266 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7267 if ( !uris.isEmpty() )
7269 event->setDropAction( Qt::CopyAction );
7271 setHighlighted(
true );
7279void QgsProcessingMultipleLayerLineEdit::dragLeaveEvent( QDragLeaveEvent *event )
7281 QgsHighlightableLineEdit::dragLeaveEvent( event );
7283 setHighlighted(
false );
7286void QgsProcessingMultipleLayerLineEdit::dropEvent( QDropEvent *event )
7288 const QStringList uris = QgsProcessingMultipleInputPanelWidget::compatibleUrisFromMimeData( mParam, event->mimeData(), {} );
7289 if ( !uris.isEmpty() )
7291 event->setDropAction( Qt::CopyAction );
7293 QVariantList uriList;
7294 uriList.reserve( uris.size() );
7295 for (
const QString &uri : uris )
7296 uriList.append( QVariant( uri ) );
7297 emit layersDropped( uriList );
7300 setHighlighted(
false );
7311 QHBoxLayout *hl =
new QHBoxLayout();
7312 hl->setContentsMargins( 0, 0, 0, 0 );
7314 mLineEdit =
new QgsProcessingMultipleLayerLineEdit(
nullptr, param );
7315 mLineEdit->setEnabled(
true );
7316 mLineEdit->setReadOnly(
true );
7318 hl->addWidget( mLineEdit, 1 );
7319 connect( mLineEdit, &QgsProcessingMultipleLayerLineEdit::layersDropped,
this, &QgsProcessingMultipleLayerPanelWidget::setValue );
7321 mToolButton =
new QToolButton();
7322 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7323 hl->addWidget( mToolButton );
7329 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, 0 ) );
7332 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingMultipleLayerPanelWidget::showDialog );
7335void QgsProcessingMultipleLayerPanelWidget::setValue(
const QVariant &value )
7337 if ( value.isValid() )
7338 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7342 updateSummaryText();
7346void QgsProcessingMultipleLayerPanelWidget::setProject(
QgsProject *project )
7352 if ( mValue.removeAll( layerId ) )
7354 updateSummaryText();
7361void QgsProcessingMultipleLayerPanelWidget::setModel( QgsProcessingModelAlgorithm *model,
const QString &modelChildAlgorithmID )
7367 switch ( mParam->layerType() )
7375 mModelSources = model->availableSourcesForChild(
7376 modelChildAlgorithmID,
7385 mModelSources = model->availableSourcesForChild(
7386 modelChildAlgorithmID,
7395 mModelSources = model->availableSourcesForChild(
7396 modelChildAlgorithmID,
7405 mModelSources = model->availableSourcesForChild(
7406 modelChildAlgorithmID,
7415 mModelSources = model->availableSourcesForChild(
7416 modelChildAlgorithmID,
7425 mModelSources = model->availableSourcesForChild(
7426 modelChildAlgorithmID,
7435 mModelSources = model->availableSourcesForChild(
7436 modelChildAlgorithmID,
7445 mModelSources = model->availableSourcesForChild(
7446 modelChildAlgorithmID,
7460 mModelSources = model->availableSourcesForChild(
7461 modelChildAlgorithmID,
7474 mModelSources = model->availableSourcesForChild(
7475 modelChildAlgorithmID,
7489 mModelSources = model->availableSourcesForChild(
7490 modelChildAlgorithmID,
7504 mModelSources = model->availableSourcesForChild(
7505 modelChildAlgorithmID,
7519 mModelSources = model->availableSourcesForChild(
7520 modelChildAlgorithmID,
7541void QgsProcessingMultipleLayerPanelWidget::showDialog()
7546 QgsProcessingMultipleInputPanelWidget *widget =
new QgsProcessingMultipleInputPanelWidget( mParam, mValue, mModelSources, mModel,
nullptr );
7547 widget->setPanelTitle( mParam->description() );
7548 widget->setProject( mProject );
7549 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() { setValue( widget->selectedOptions() ); } );
7555 QgsProcessingMultipleInputDialog dlg( mParam, mValue, mModelSources, mModel,
this, Qt::WindowFlags() );
7556 dlg.setProject( mProject );
7559 setValue( dlg.selectedOptions() );
7564void QgsProcessingMultipleLayerPanelWidget::updateSummaryText()
7567 mLineEdit->setText( tr(
"%n input(s) selected",
nullptr, mValue.count() ) );
7574QgsProcessingMultipleLayerParameterDefinitionWidget::QgsProcessingMultipleLayerParameterDefinitionWidget(
7579 QVBoxLayout *vlayout =
new QVBoxLayout();
7580 vlayout->setContentsMargins( 0, 0, 0, 0 );
7582 vlayout->addWidget(
new QLabel( tr(
"Allowed layer type" ) ) );
7583 mLayerTypeComboBox =
new QComboBox();
7597 mLayerTypeComboBox->setCurrentIndex( mLayerTypeComboBox->findData(
static_cast<int>( layersParam->layerType() ) ) );
7599 vlayout->addWidget( mLayerTypeComboBox );
7602 setLayout( vlayout );
7607 auto param = std::make_unique<QgsProcessingParameterMultipleLayers>( name, description,
static_cast<Qgis::ProcessingSourceType>( mLayerTypeComboBox->currentData().toInt() ) );
7609 return param.release();
7616QWidget *QgsProcessingMultipleLayerWidgetWrapper::createWidget()
7620 mPanel =
new QgsProcessingMultipleLayerPanelWidget(
nullptr, layerParam );
7621 mPanel->setToolTip( parameterDefinition()->toolTip() );
7622 mPanel->setProject( widgetContext().project() );
7624 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7625 connect( mPanel, &QgsProcessingMultipleLayerPanelWidget::changed,
this, [
this] { emit widgetValueHasChanged(
this ); } );
7634 mPanel->setProject( context.
project() );
7636 mPanel->setModel( widgetContext().model(), widgetContext().modelChildAlgorithmId() );
7640void QgsProcessingMultipleLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7645 if ( value.isValid() )
7648 opts.reserve( v.size() );
7650 opts << l->source();
7653 for (
const QVariant &v : value.toList() )
7655 if ( v.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
7657 const QgsProcessingModelChildParameterSource source = v.value<QgsProcessingModelChildParameterSource>();
7658 opts << QVariant::fromValue( source );
7663 mPanel->setValue( value.isValid() ? opts : QVariant() );
7667QVariant QgsProcessingMultipleLayerWidgetWrapper::widgetValue()
const
7670 return !mPanel->value().toList().isEmpty() ? mPanel->value() : QVariant();
7675QString QgsProcessingMultipleLayerWidgetWrapper::modelerExpressionFormatString()
const
7677 return tr(
"an array of layer paths, or semicolon separated string of layer paths" );
7680QString QgsProcessingMultipleLayerWidgetWrapper::parameterType()
const
7687 return new QgsProcessingMultipleLayerWidgetWrapper( parameter, type );
7694 return new QgsProcessingMultipleLayerParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
7703 : QgsProcessingMapLayerWidgetWrapper( parameter, type, parent )
7706QString QgsProcessingPointCloudLayerWidgetWrapper::modelerExpressionFormatString()
const
7708 return tr(
"path to a point cloud layer" );
7711QString QgsProcessingPointCloudLayerWidgetWrapper::parameterType()
const
7718 return new QgsProcessingPointCloudLayerWidgetWrapper( parameter, type );
7725 Q_UNUSED( context );
7726 Q_UNUSED( widgetContext );
7727 Q_UNUSED( definition );
7742QString QgsProcessingAnnotationLayerWidgetWrapper::modelerExpressionFormatString()
const
7744 return tr(
"name of an annotation layer, or \"main\" for the main annotation layer" );
7747QString QgsProcessingAnnotationLayerWidgetWrapper::parameterType()
const
7754 return new QgsProcessingAnnotationLayerWidgetWrapper( parameter, type );
7761 Q_UNUSED( context );
7762 Q_UNUSED( widgetContext );
7763 Q_UNUSED( definition );
7774 if ( mWidgetContext.project() )
7775 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7779QWidget *QgsProcessingAnnotationLayerWidgetWrapper::createWidget()
7790 mComboBox->setEditable(
true );
7794 mComboBox->setToolTip( parameterDefinition()->toolTip() );
7796 if ( mWidgetContext.project() )
7797 mComboBox->setAdditionalLayers( { mWidgetContext.project()->mainAnnotationLayer() } );
7800 mComboBox->setAllowEmptyLayer(
true );
7803 if ( mBlockSignals )
7806 emit widgetValueHasChanged(
this );
7809 setWidgetContext( widgetContext() );
7813void QgsProcessingAnnotationLayerWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
7819 mComboBox->setLayer(
nullptr );
7823 QVariant val = value;
7824 if ( val.userType() == qMetaTypeId<QgsProperty>() )
7836 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( val.value<QObject *>() );
7837 if ( !layer && val.userType() == QMetaType::Type::QString )
7844 mComboBox->setLayer( layer );
7849QVariant QgsProcessingAnnotationLayerWidgetWrapper::widgetValue()
const
7851 return mComboBox && mComboBox->currentLayer()
7852 ? ( mWidgetContext.project() ? ( mComboBox->currentLayer() == mWidgetContext.project()->mainAnnotationLayer() ? u
"main"_s : mComboBox->currentLayer()->id() )
7853 : mComboBox->currentLayer()->id() )
7866 QHBoxLayout *hl =
new QHBoxLayout();
7867 hl->setContentsMargins( 0, 0, 0, 0 );
7869 mLineEdit =
new QLineEdit();
7870 mLineEdit->setEnabled(
false );
7871 hl->addWidget( mLineEdit, 1 );
7873 mToolButton =
new QToolButton();
7874 mToolButton->setText( QString( QChar( 0x2026 ) ) );
7875 hl->addWidget( mToolButton );
7881 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7884 connect( mToolButton, &QToolButton::clicked,
this, &QgsProcessingPointCloudAttributePanelWidget::showDialog );
7889 mAttributes = attributes;
7892void QgsProcessingPointCloudAttributePanelWidget::setValue(
const QVariant &value )
7894 if ( value.isValid() )
7895 mValue = value.userType() == QMetaType::Type::QVariantList ? value.toList() : QVariantList() << value;
7899 updateSummaryText();
7903void QgsProcessingPointCloudAttributePanelWidget::showDialog()
7905 QVariantList availableOptions;
7906 availableOptions.reserve( mAttributes.count() );
7907 const QVector<QgsPointCloudAttribute> attributes = mAttributes.attributes();
7910 availableOptions << attr.name();
7916 QgsProcessingMultipleSelectionPanelWidget *widget =
new QgsProcessingMultipleSelectionPanelWidget( availableOptions, mValue );
7917 widget->setPanelTitle( mParam->description() );
7919 widget->setValueFormatter( [](
const QVariant &v ) -> QString {
return v.toString(); } );
7921 connect( widget, &QgsProcessingMultipleSelectionPanelWidget::selectionChanged,
this, [
this, widget]() { setValue( widget->selectedOptions() ); } );
7927 QgsProcessingMultipleSelectionDialog dlg( availableOptions, mValue,
this, Qt::WindowFlags() );
7929 dlg.setValueFormatter( [](
const QVariant &v ) -> QString {
return v.toString(); } );
7932 setValue( dlg.selectedOptions() );
7937void QgsProcessingPointCloudAttributePanelWidget::updateSummaryText()
7942 if ( mValue.empty() )
7944 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, 0 ) );
7949 values.reserve( mValue.size() );
7950 for (
const QVariant &val : std::as_const( mValue ) )
7952 values << val.toString();
7955 const QString concatenated = values.join( tr(
"," ) );
7956 if ( concatenated.length() < 100 )
7957 mLineEdit->setText( concatenated );
7959 mLineEdit->setText( tr(
"%n attribute(s) selected",
nullptr, mValue.count() ) );
7968QgsProcessingPointCloudAttributeParameterDefinitionWidget::QgsProcessingPointCloudAttributeParameterDefinitionWidget(
7973 QVBoxLayout *vlayout =
new QVBoxLayout();
7974 vlayout->setContentsMargins( 0, 0, 0, 0 );
7976 vlayout->addWidget(
new QLabel( tr(
"Parent layer" ) ) );
7977 mParentLayerComboBox =
new QComboBox();
7979 QString initialParent;
7981 initialParent = attrParam->parentLayerParameterName();
7983 if (
auto *lModel = widgetContext.
model() )
7986 const QMap<QString, QgsProcessingModelParameter> components = lModel->parameterComponents();
7987 for (
auto it = components.constBegin(); it != components.constEnd(); ++it )
7991 mParentLayerComboBox->addItem( definition->
description(), definition->
name() );
7992 if ( !initialParent.isEmpty() && initialParent == definition->
name() )
7994 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
8000 if ( mParentLayerComboBox->count() == 0 && !initialParent.isEmpty() )
8003 mParentLayerComboBox->addItem( initialParent, initialParent );
8004 mParentLayerComboBox->setCurrentIndex( mParentLayerComboBox->count() - 1 );
8007 vlayout->addWidget( mParentLayerComboBox );
8011 mAllowMultipleCheckBox =
new QCheckBox( tr(
"Accept multiple attributes" ) );
8013 mAllowMultipleCheckBox->setChecked( attrParam->allowMultiple() );
8015 vlayout->addWidget( mAllowMultipleCheckBox );
8018 mDefaultToAllCheckBox =
new QCheckBox( tr(
"Select all attributes by default" ) );
8019 mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() );
8021 mDefaultToAllCheckBox->setChecked( attrParam->defaultToAllAttributes() );
8025 vlayout->addWidget( mDefaultToAllCheckBox );
8027 connect( mAllowMultipleCheckBox, &QCheckBox::stateChanged,
this, [
this] { mDefaultToAllCheckBox->setEnabled( mAllowMultipleCheckBox->isChecked() ); } );
8029 vlayout->addWidget(
new QLabel( tr(
"Default value" ) ) );
8031 mDefaultLineEdit =
new QLineEdit();
8032 mDefaultLineEdit->setToolTip( tr(
"Default attribute name, or ; separated list of attribute names for multiple attribute parameters" ) );
8036 mDefaultLineEdit->setText( attributes.join(
';' ) );
8038 vlayout->addWidget( mDefaultLineEdit );
8042 setLayout( vlayout );
8047 QVariant defaultValue;
8048 if ( !mDefaultLineEdit->text().trimmed().isEmpty() )
8050 defaultValue = mDefaultLineEdit->text();
8052 auto param = std::make_unique<
8053 QgsProcessingParameterPointCloudAttribute>( name, description, defaultValue, mParentLayerComboBox->currentData().toString(), mAllowMultipleCheckBox->isChecked(),
false, mDefaultToAllCheckBox->isChecked() );
8055 return param.release();
8062QWidget *QgsProcessingPointCloudAttributeWidgetWrapper::createWidget()
8075 mPanel =
new QgsProcessingPointCloudAttributePanelWidget(
nullptr, attrParam );
8076 mPanel->setToolTip( parameterDefinition()->toolTip() );
8077 connect( mPanel, &QgsProcessingPointCloudAttributePanelWidget::changed,
this, [
this] { emit widgetValueHasChanged(
this ); } );
8084 mComboBox->setToolTip( parameterDefinition()->toolTip() );
8092 mLineEdit =
new QLineEdit();
8093 mLineEdit->setToolTip( QObject::tr(
"Name of attribute (separate attribute names with ; for multiple attribute parameters)" ) );
8094 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
8101void QgsProcessingPointCloudAttributeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
8113 setParentLayerWrapperValue( wrapper );
8130 std::unique_ptr<QgsProcessingContext> tmpContext;
8131 if ( mProcessingContextGenerator )
8132 context = mProcessingContextGenerator->processingContext();
8136 tmpContext = std::make_unique<QgsProcessingContext>();
8137 context = tmpContext.get();
8143 if ( layer && layer->
isValid() )
8147 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
8150 mParentLayer.reset( qobject_cast<QgsPointCloudLayer *>( ownedLayer.release() ) );
8151 layer = mParentLayer.get();
8159 mComboBox->setLayer( layer );
8162 mPanel->setAttributes( layer->
attributes() );
8169 mComboBox->setLayer(
nullptr );
8174 if ( value.isValid() && widgetContext().messageBar() )
8185 val.reserve( mPanel->attributes().attributes().size() );
8188 setWidgetValue( val, *context );
8191 setWidgetValue( parameterDefinition()->defaultValueForGui(), *context );
8194void QgsProcessingPointCloudAttributeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
8198 if ( !value.isValid() )
8199 mComboBox->setAttribute( QString() );
8203 mComboBox->setAttribute( v );
8209 if ( value.isValid() )
8212 opts.reserve( v.size() );
8213 for (
const QString &i : v )
8217 mPanel->setValue( opts );
8219 else if ( mLineEdit )
8225 mLineEdit->setText( v.join(
';' ) );
8234QVariant QgsProcessingPointCloudAttributeWidgetWrapper::widgetValue()
const
8237 return mComboBox->currentAttribute();
8239 return mPanel->value();
8240 else if ( mLineEdit )
8245 return mLineEdit->text().split(
';' );
8248 return mLineEdit->text();
8254QString QgsProcessingPointCloudAttributeWidgetWrapper::modelerExpressionFormatString()
const
8256 return tr(
"selected attribute names as an array of names, or semicolon separated string of options (e.g. 'X;Intensity')" );
8259QString QgsProcessingPointCloudAttributeWidgetWrapper::parameterType()
const
8266 return new QgsProcessingPointCloudAttributeWidgetWrapper( parameter, type );
8273 return new QgsProcessingPointCloudAttributeParameterDefinitionWidget( context, widgetContext, definition,
algorithm );
8285QWidget *QgsProcessingOutputWidgetWrapper::createWidget()
8293 mOutputWidget =
new QgsProcessingLayerOutputDestinationWidget( destParam,
false );
8294 if ( mProcessingContextGenerator )
8295 mOutputWidget->setContext( mProcessingContextGenerator->processingContext() );
8296 if ( mParametersGenerator )
8297 mOutputWidget->registerProcessingParametersGenerator( mParametersGenerator );
8298 mOutputWidget->setToolTip( parameterDefinition()->toolTip() );
8300 connect( mOutputWidget, &QgsProcessingLayerOutputDestinationWidget::destinationChanged,
this, [
this]() {
8301 if ( mBlockSignals )
8304 emit widgetValueHasChanged(
this );
8309 mOutputWidget->addOpenAfterRunningOption();
8311 return mOutputWidget;
8321void QgsProcessingOutputWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8323 if ( mOutputWidget )
8324 mOutputWidget->setValue( value );
8327QVariant QgsProcessingOutputWidgetWrapper::widgetValue()
const
8329 if ( mOutputWidget )
8330 return mOutputWidget->value();
8335QVariantMap QgsProcessingOutputWidgetWrapper::customProperties()
const
8338 if ( mOutputWidget )
8339 res.insert( u
"OPEN_AFTER_RUNNING"_s, mOutputWidget->openAfterRunning() );
8348 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8351QString QgsProcessingFeatureSinkWidgetWrapper::parameterType()
const
8358 return new QgsProcessingFeatureSinkWidgetWrapper( parameter, type );
8361QString QgsProcessingFeatureSinkWidgetWrapper::modelerExpressionFormatString()
const
8363 return tr(
"path to layer destination" );
8371 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8374QString QgsProcessingVectorDestinationWidgetWrapper::parameterType()
const
8381 return new QgsProcessingVectorDestinationWidgetWrapper( parameter, type );
8384QString QgsProcessingVectorDestinationWidgetWrapper::modelerExpressionFormatString()
const
8386 return tr(
"path to layer destination" );
8394 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8397QString QgsProcessingRasterDestinationWidgetWrapper::parameterType()
const
8404 return new QgsProcessingRasterDestinationWidgetWrapper( parameter, type );
8407QString QgsProcessingRasterDestinationWidgetWrapper::modelerExpressionFormatString()
const
8409 return tr(
"path to layer destination" );
8417 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8420QString QgsProcessingPointCloudDestinationWidgetWrapper::parameterType()
const
8427 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8430QString QgsProcessingPointCloudDestinationWidgetWrapper::modelerExpressionFormatString()
const
8432 return tr(
"path to layer destination" );
8440 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8443QString QgsProcessingFileDestinationWidgetWrapper::parameterType()
const
8450 return new QgsProcessingFileDestinationWidgetWrapper( parameter, type );
8454QString QgsProcessingFileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8456 return tr(
"path to file destination" );
8464 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8467QString QgsProcessingFolderDestinationWidgetWrapper::parameterType()
const
8474 return new QgsProcessingFolderDestinationWidgetWrapper( parameter, type );
8478QString QgsProcessingFolderDestinationWidgetWrapper::modelerExpressionFormatString()
const
8480 return tr(
"path to folder destination" );
8488 : QgsProcessingOutputWidgetWrapper( parameter, type, parent )
8491QString QgsProcessingVectorTileDestinationWidgetWrapper::parameterType()
const
8498 return new QgsProcessingPointCloudDestinationWidgetWrapper( parameter, type );
8501QString QgsProcessingVectorTileDestinationWidgetWrapper::modelerExpressionFormatString()
const
8503 return tr(
"path to layer destination" );
8511QgsHeatmapPixelSizeWidget::QgsHeatmapPixelSizeWidget( QWidget *parent )
8516 mCellXSpinBox->setShowClearButton(
false );
8517 mCellYSpinBox->setShowClearButton(
false );
8518 mRowsSpinBox->setShowClearButton(
false );
8519 mColumnsSpinBox->setShowClearButton(
false );
8521 connect( mCellYSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), mCellXSpinBox, &QgsDoubleSpinBox::setValue );
8522 connect( mCellXSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsHeatmapPixelSizeWidget::pixelSizeChanged );
8523 connect( mRowsSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, &QgsHeatmapPixelSizeWidget::rowsChanged );
8524 connect( mColumnsSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
this, &QgsHeatmapPixelSizeWidget::columnsChanged );
8531 mLayerBounds = mLayer->
extent();
8535 recalculateBounds();
8543void QgsHeatmapPixelSizeWidget::setRadius(
double radius )
8546 recalculateBounds();
8549void QgsHeatmapPixelSizeWidget::setRadiusField(
const QString &radiusField )
8551 mRadiusField = radiusField;
8552 recalculateBounds();
8555void QgsHeatmapPixelSizeWidget::recalculateBounds()
8557 mRasterBounds = mLayerBounds;
8561 double maxRadius = mRadius;
8562 if ( !mRadiusField.isEmpty() )
8564 const int idx = mLayer->fields().lookupField( mRadiusField );
8566 maxRadius = mLayer->maximumValue( idx ).toDouble();
8569 mRasterBounds.setXMinimum( mRasterBounds.xMinimum() - maxRadius );
8570 mRasterBounds.setYMinimum( mRasterBounds.yMinimum() - maxRadius );
8571 mRasterBounds.setXMaximum( mRasterBounds.xMaximum() + maxRadius );
8572 mRasterBounds.setYMaximum( mRasterBounds.yMaximum() + maxRadius );
8577void QgsHeatmapPixelSizeWidget::pixelSizeChanged()
8579 const double prevValue = value();
8580 const double cellSize = mCellXSpinBox->value();
8581 if ( cellSize <= 0 || mRasterBounds.isNull() )
8583 emit valueChanged();
8589 const int rows = std::max(
static_cast<int>( std::round( mRasterBounds.height() / cellSize ) ) + 1, 1 );
8590 const int cols = std::max(
static_cast<int>( std::round( mRasterBounds.width() / cellSize ) ) + 1, 1 );
8597 emit valueChanged();
8601void QgsHeatmapPixelSizeWidget::rowsChanged()
8603 const int rows = mRowsSpinBox->value();
8604 if ( rows <= 0 || mRasterBounds.isNull() )
8607 const double cellSize = mRasterBounds.height() / rows;
8608 if ( cellSize == 0 )
8611 const int cols = std::max(
static_cast<int>( std::round( mRasterBounds.width() / cellSize ) ) + 1, 1 );
8617 emit valueChanged();
8620void QgsHeatmapPixelSizeWidget::columnsChanged()
8622 const int cols = mColumnsSpinBox->value();
8623 if ( cols < 2 || mRasterBounds.isNull() )
8626 const double cellSize = mRasterBounds.width() / ( cols - 1 );
8627 if ( cellSize == 0 )
8630 const int rows = std::max(
static_cast<int>( std::round( mRasterBounds.height() / cellSize ) ), 1 );
8636 emit valueChanged();
8639double QgsHeatmapPixelSizeWidget::value()
const
8641 return mCellXSpinBox->value();
8644void QgsHeatmapPixelSizeWidget::setValue(
double value )
8646 mCellXSpinBox->setValue( value );
8647 mCellYSpinBox->setValue( value );
8658QString QgsProcessingHeatmapPixelSizeWidgetWrapper::parameterType()
const
8665 return new QgsProcessingHeatmapPixelSizeWidgetWrapper( parameter, type );
8675QWidget *QgsProcessingHeatmapPixelSizeWidgetWrapper::createWidget()
8681 mWidget =
new QgsHeatmapPixelSizeWidget();
8682 connect( mWidget, &QgsHeatmapPixelSizeWidget::valueChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
8690 mFallbackSpinBox->setShowClearButton(
false );
8691 mFallbackSpinBox->setMinimum( 0.0 );
8692 mFallbackSpinBox->setMaximum( 99999999999.0 );
8693 mFallbackSpinBox->setDecimals( 6 );
8694 mFallbackSpinBox->setToolTip( tr(
"Resolution of each pixel in output raster, in layer units" ) );
8695 connect( mFallbackSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] { emit widgetValueHasChanged(
this ); } );
8696 return mFallbackSpinBox;
8702void QgsProcessingHeatmapPixelSizeWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
8711 if ( !param || !mWidget )
8718 setParentLayerWrapperValue( wrapper );
8747 std::unique_ptr<QgsProcessingContext> tmpContext;
8748 if ( mProcessingContextGenerator )
8749 context = mProcessingContextGenerator->processingContext();
8753 tmpContext = std::make_unique<QgsProcessingContext>();
8754 context = tmpContext.get();
8758 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
8768 mWidget->setLayer(
nullptr );
8774 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
8777 mParentLayer = std::move( ownedLayer );
8785 mWidget->setLayer( layer );
8788void QgsProcessingHeatmapPixelSizeWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext & )
8791 mWidget->setValue( value.toDouble() );
8792 else if ( mFallbackSpinBox )
8793 mFallbackSpinBox->setValue( value.toDouble() );
8796QVariant QgsProcessingHeatmapPixelSizeWidgetWrapper::widgetValue()
const
8799 return mWidget->value();
8800 else if ( mFallbackSpinBox )
8801 return mFallbackSpinBox->value();
8805const QgsVectorLayer *QgsProcessingHeatmapPixelSizeWidgetWrapper::linkedVectorLayer()
const
8807 if ( mWidget && mWidget->layer() )
8808 return mWidget->layer();
8829QgsReliefColorsWidget::QgsReliefColorsWidget( QWidget *parent )
8834 connect( mButtonAdd, &QToolButton::clicked,
this, &QgsReliefColorsWidget::addClicked );
8835 connect( mButtonRemove, &QToolButton::clicked,
this, &QgsReliefColorsWidget::removeClicked );
8836 connect( mButtonUp, &QToolButton::clicked,
this, &QgsReliefColorsWidget::upClicked );
8837 connect( mButtonDown, &QToolButton::clicked,
this, &QgsReliefColorsWidget::downClicked );
8838 connect( mButtonLoad, &QToolButton::clicked,
this, &QgsReliefColorsWidget::loadClicked );
8839 connect( mButtonSave, &QToolButton::clicked,
this, &QgsReliefColorsWidget::saveClicked );
8840 connect( mButtonAuto, &QToolButton::clicked,
this, &QgsReliefColorsWidget::autoCalculate );
8841 connect( mReliefColorsWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsReliefColorsWidget::itemDoubleClicked );
8851 return mLayer.data();
8854void QgsReliefColorsWidget::addClicked()
8856 auto item =
new QTreeWidgetItem();
8857 item->setText( 0, u
"0.00"_s );
8858 item->setText( 1, u
"0.00"_s );
8859 item->setBackground( 2, QBrush( QColor( 127, 127, 127 ) ) );
8860 mReliefColorsWidget->addTopLevelItem( item );
8861 emit valueChanged();
8864void QgsReliefColorsWidget::removeClicked()
8866 const QList<QTreeWidgetItem *> selectedItems = mReliefColorsWidget->selectedItems();
8867 for ( QTreeWidgetItem *item : std::as_const( selectedItems ) )
8871 emit valueChanged();
8874void QgsReliefColorsWidget::downClicked()
8876 const QList<QTreeWidgetItem *> selectedItems = mReliefColorsWidget->selectedItems();
8877 for ( QTreeWidgetItem *item : std::as_const( selectedItems ) )
8879 const int currentIndex = mReliefColorsWidget->indexOfTopLevelItem( item );
8880 if ( currentIndex >= 0 && currentIndex < mReliefColorsWidget->topLevelItemCount() - 1 )
8882 mReliefColorsWidget->takeTopLevelItem( currentIndex );
8883 mReliefColorsWidget->insertTopLevelItem( currentIndex + 1, item );
8884 mReliefColorsWidget->setCurrentItem( item );
8887 emit valueChanged();
8890void QgsReliefColorsWidget::upClicked()
8892 const QList<QTreeWidgetItem *> selectedItems = mReliefColorsWidget->selectedItems();
8893 for ( QTreeWidgetItem *item : std::as_const( selectedItems ) )
8895 const int currentIndex = mReliefColorsWidget->indexOfTopLevelItem( item );
8896 if ( currentIndex > 0 )
8898 mReliefColorsWidget->takeTopLevelItem( currentIndex );
8899 mReliefColorsWidget->insertTopLevelItem( currentIndex - 1, item );
8900 mReliefColorsWidget->setCurrentItem( item );
8903 emit valueChanged();
8906void QgsReliefColorsWidget::loadClicked()
8908 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Import Colors from XML" ), QDir::homePath(), tr(
"XML files (*.xml *.XML)" ) );
8909 if ( fileName.isEmpty() )
8912 QFile file( fileName );
8913 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
8917 if ( !doc.setContent( &file ) )
8919 QMessageBox::critical(
this, tr(
"Import Colors from XML" ), tr(
"The XML file could not be loaded" ) );
8923 mReliefColorsWidget->clear();
8924 const QDomNodeList reliefColorList = doc.elementsByTagName( u
"ReliefColor"_s );
8925 for (
int i = 0; i < reliefColorList.length(); ++i )
8927 const QDomElement elem = reliefColorList.at( i ).toElement();
8928 auto item =
new QTreeWidgetItem();
8929 item->setText( 0, elem.attribute( u
"MinElevation"_s ) );
8930 item->setText( 1, elem.attribute( u
"MaxElevation"_s ) );
8931 item->setBackground( 2, QBrush( QColor( elem.attribute( u
"red"_s ).toInt(), elem.attribute( u
"green"_s ).toInt(), elem.attribute( u
"blue"_s ).toInt() ) ) );
8932 mReliefColorsWidget->addTopLevelItem( item );
8934 emit valueChanged();
8937void QgsReliefColorsWidget::saveClicked()
8939 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Export Colors as XML" ), QDir::homePath(), tr(
"XML files (*.xml *.XML)" ) );
8940 if ( fileName.isEmpty() )
8946 QDomElement colorsElem = doc.createElement( u
"ReliefColors"_s );
8947 doc.appendChild( colorsElem );
8949 const QList<QgsRasterReliefColor> currentColors = colors();
8952 QDomElement elem = doc.createElement( u
"ReliefColor"_s );
8955 elem.setAttribute( u
"red"_s, QString::number(
c.color.red() ) );
8956 elem.setAttribute( u
"green"_s, QString::number(
c.color.green() ) );
8957 elem.setAttribute( u
"blue"_s, QString::number(
c.color.blue() ) );
8958 colorsElem.appendChild( elem );
8961 QFile file( fileName );
8962 if ( file.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
8964 QTextStream out( &file );
8965 out << doc.toString( 2 );
8969void QgsReliefColorsWidget::autoCalculate()
8971 if ( !mLayer || !mLayer->isValid() )
8975 setColors( autoColors );
8976 emit valueChanged();
8979void QgsReliefColorsWidget::itemDoubleClicked( QTreeWidgetItem *item,
int column )
8987 const double d = QInputDialog::getDouble(
this, tr(
"Enter lower elevation class bound" ), tr(
"Elevation" ), item->text( 0 ).toDouble(), -2147483647, 2147483647, 2, &ok );
8990 item->setText( 0, QString::number( d ) );
8991 emit valueChanged();
8994 else if ( column == 1 )
8996 const double d = QInputDialog::getDouble(
this, tr(
"Enter upper elevation class bound" ), tr(
"Elevation" ), item->text( 1 ).toDouble(), -2147483647, 2147483647, 2, &ok );
8999 item->setText( 1, QString::number( d ) );
9000 emit valueChanged();
9003 else if ( column == 2 )
9005 const QColor
c = QColorDialog::getColor( item->background( 2 ).color(),
this, tr(
"Select color for relief class" ) );
9008 item->setBackground( 2, QBrush(
c ) );
9009 emit valueChanged();
9014QList<QgsRasterReliefColor> QgsReliefColorsWidget::colors()
const
9016 QList<QgsRasterReliefColor> colors;
9017 for (
int i = 0; i < mReliefColorsWidget->topLevelItemCount(); ++i )
9019 if ( QTreeWidgetItem *item = mReliefColorsWidget->topLevelItem( i ) )
9021 colors.append(
QgsRasterReliefColor( item->background( 2 ).color(), item->text( 0 ).toDouble(), item->text( 1 ).toDouble() ) );
9027void QgsReliefColorsWidget::setColors(
const QList<QgsRasterReliefColor> &colors )
9029 mReliefColorsWidget->clear();
9032 auto item =
new QTreeWidgetItem();
9035 item->setBackground( 2, QBrush(
c.color ) );
9036 mReliefColorsWidget->addTopLevelItem( item );
9038 emit valueChanged();
9049QString QgsProcessingReliefColorsWidgetWrapper::parameterType()
const
9056 return new QgsProcessingReliefColorsWidgetWrapper( parameter, type );
9066QWidget *QgsProcessingReliefColorsWidgetWrapper::createWidget()
9072 mWidget =
new QgsReliefColorsWidget();
9073 connect( mWidget, &QgsReliefColorsWidget::valueChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
9080 mFallbackLineEdit =
new QLineEdit();
9081 mFallbackLineEdit->setPlaceholderText( tr(
"Relief colors definition" ) );
9082 connect( mFallbackLineEdit, &QLineEdit::textChanged,
this, [
this] { emit widgetValueHasChanged(
this ); } );
9083 return mFallbackLineEdit;
9089void QgsProcessingReliefColorsWidgetWrapper::postInitialize(
const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
9098 if ( !param || !mWidget )
9105 setParentLayerWrapperValue( wrapper );
9124 std::unique_ptr<QgsProcessingContext> tmpContext;
9125 if ( mProcessingContextGenerator )
9126 context = mProcessingContextGenerator->processingContext();
9130 tmpContext = std::make_unique<QgsProcessingContext>();
9131 context = tmpContext.get();
9136 if ( layer && layer->
isValid() )
9140 std::unique_ptr<QgsMapLayer> ownedLayer( context->
takeResultLayer( layer->
id() ) );
9143 mParentLayer.reset( qobject_cast<QgsRasterLayer *>( ownedLayer.release() ) );
9144 layer = mParentLayer.get();
9152 mWidget->setLayer( layer );
9157 mWidget->setLayer(
nullptr );
9161void QgsProcessingReliefColorsWidgetWrapper::setWidgetValue(
const QVariant &value,
QgsProcessingContext &context )
9165 if ( mWidget && param )
9167 mWidget->setColors( param->valueAsReliefColors( value, context ) );
9169 else if ( mFallbackLineEdit )
9170 mFallbackLineEdit->setText( value.toString() );
9173QVariant QgsProcessingReliefColorsWidgetWrapper::widgetValue()
const
9177 else if ( mFallbackLineEdit )
9178 return mFallbackLineEdit->text();
9182QString QgsProcessingReliefColorsWidgetWrapper::modelerExpressionFormatString()
const
9184 return tr(
"string of the format 'min,max,red,green,blue' for each relief color, joined by a ; delimiter" );
@ 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.
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
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 parameter for the heatmap algorithm pixel size parameter.
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 parameter for raster relief colors.
static QVariant colorsAsVariant(const QList< QgsRasterReliefColor > &colors)
Returns a list of raster relief colors encoded as a variant value.
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.
static QList< QgsRasterReliefColor > calculateOptimizedReliefClasses(QgsRasterDataProvider *provider, int band)
Calculates optimized relief class breaks according with the method of Buenzli (2011) using an iterati...
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
Defines elevation range and color for raster relief coloring.
A rectangle specified with double values.
A QgsGeometry with associated coordinate reference system.
@ 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.
QgsRectangle extent() const final
Returns the extent of the layer.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
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).
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
constexpr QObjectUniquePtr< Tp > make_qobject_unique(Args &&...args)
Create an object owned by a QObjectUniquePtr.