43#include <QRegularExpression>
51 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
53 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
54 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
62 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
64 flags =
static_cast< Qgis::ProcessingFeatureSourceDefinitionFlags
>( map.value( QStringLiteral(
"flags" ), 0 ).toInt() );
77 mRemappingDefinition = definition;
84 map.insert( QStringLiteral(
"create_options" ),
createOptions );
86 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
93 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
94 if ( map.contains( QStringLiteral(
"remapping" ) ) )
101 mUseRemapping =
false;
109 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
114 return !( *
this == other );
119 const QVariant val = parameters.value( name );
120 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
139 QVariant val = value;
140 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
143 if ( !val.isValid() )
152 return destParam->generateTemporaryDestination( &context );
155 return val.toString();
171 const QVariant val = value;
172 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
175 if ( val.isValid() && !val.toString().isEmpty() )
179 return val.toString();
199 QVariant val = value;
200 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
204 const double res = val.toDouble( &ok );
210 return val.toDouble();
226 QVariant val = value;
227 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
231 double dbl = val.toDouble( &ok );
236 dbl = val.toDouble( &ok );
243 const double round = std::round( dbl );
244 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
249 return static_cast< int >( std::round( dbl ) );
258 return QList< int >();
266 return QList< int >();
268 QList< int > resultList;
269 const QVariant val = value;
272 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
274 else if ( val.type() == QVariant::List )
276 const QVariantList list = val.toList();
277 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
278 resultList << it->toInt();
282 const QStringList parts = val.toString().split(
';' );
283 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
284 resultList << it->toInt();
288 if ( resultList.isEmpty() )
293 if ( definition->
defaultValue().type() == QVariant::List )
295 const QVariantList list = definition->
defaultValue().toList();
296 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
297 resultList << it->toInt();
301 const QStringList parts = definition->
defaultValue().toString().split(
';' );
302 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
303 resultList << it->toInt();
324 QVariant val = value;
325 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
328 QDateTime d = val.toDateTime();
329 if ( !d.isValid() && val.type() == QVariant::String )
331 d = QDateTime::fromString( val.toString() );
338 d = val.toDateTime();
340 if ( !d.isValid() && val.type() == QVariant::String )
342 d = QDateTime::fromString( val.toString() );
361 QVariant val = value;
362 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
365 QDate d = val.toDate();
366 if ( !d.isValid() && val.type() == QVariant::String )
368 d = QDate::fromString( val.toString() );
377 if ( !d.isValid() && val.type() == QVariant::String )
379 d = QDate::fromString( val.toString() );
398 QVariant val = value;
399 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
404 if ( val.type() == QVariant::DateTime )
405 d = val.toDateTime().time();
409 if ( !d.isValid() && val.type() == QVariant::String )
411 d = QTime::fromString( val.toString() );
420 if ( !d.isValid() && val.type() == QVariant::String )
422 d = QTime::fromString( val.toString() );
443 if ( enumDef && val >= enumDef->
options().size() )
463 QVariantList resultList;
464 const QVariant val = value;
465 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
467 else if ( val.type() == QVariant::List )
469 const auto constToList = val.toList();
470 for (
const QVariant &var : constToList )
473 else if ( val.type() == QVariant::String )
475 const auto constSplit = val.toString().split(
',' );
476 for (
const QString &var : constSplit )
482 if ( resultList.isEmpty() )
483 return QList< int >();
485 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
489 if ( definition->
defaultValue().type() == QVariant::List )
491 const auto constToList = definition->
defaultValue().toList();
492 for (
const QVariant &var : constToList )
495 else if ( definition->
defaultValue().type() == QVariant::String )
497 const auto constSplit = definition->
defaultValue().toString().split(
',' );
498 for (
const QString &var : constSplit )
507 const auto constResultList = resultList;
508 for (
const QVariant &var : constResultList )
510 const int resInt = var.toInt();
511 if ( !enumDef || resInt < enumDef->options().size() )
534 if ( enumText.isEmpty() || !enumDef->
options().contains( enumText ) )
543 return QStringList();
551 return QStringList();
553 const QVariant val = value;
555 QStringList enumValues;
557 std::function< void(
const QVariant &var ) > processVariant;
558 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
560 if ( var.type() == QVariant::List )
562 const auto constToList = var.toList();
563 for (
const QVariant &listVar : constToList )
565 processVariant( listVar );
568 else if ( var.type() == QVariant::StringList )
570 const auto constToStringList = var.toStringList();
571 for (
const QString &s : constToStringList )
576 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
580 const QStringList parts = var.toString().split(
',' );
581 for (
const QString &s : parts )
588 processVariant( val );
594 const QStringList options = enumDef->
options();
595 const QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
597 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
630 const QVariant val = value;
631 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
633 else if ( val.isValid() )
646 const QVariant val = value;
647 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
649 else if ( val.isValid() )
657 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
658 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
663 val = parameters.value( definition->
name() );
666 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
669QgsFeatureSink *
QgsProcessingParameters::parameterAsSink(
const QgsProcessingParameterDefinition *definition,
const QVariant &value,
const QgsFields &fields,
Qgis::WkbType geometryType,
const QgsCoordinateReferenceSystem &
crs,
QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
671 QVariantMap options = createOptions;
672 QVariant val = value;
677 bool useRemapDefinition =
false;
678 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
689 useRemapDefinition =
true;
695 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
699 else if ( !val.isValid() || val.toString().isEmpty() )
715 dest = val.toString();
720 dest = destParam->generateTemporaryDestination( &context );
723 if ( dest.isEmpty() )
726 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition : nullptr ) );
727 destinationIdentifier = dest;
729 if ( destinationProject )
731 if ( destName.isEmpty() && definition )
737 outputName = definition->
name();
741 return sink.release();
765 QVariant val = parameters.value( definition->
name() );
767 bool selectedFeaturesOnly =
false;
768 long long featureLimit = -1;
769 QString filterExpression;
770 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
779 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
786 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
792 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
797 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
801 else if ( !val.isValid() || val.toString().isEmpty() )
807 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
813 layerRef = val.toString();
818 if ( layerRef.isEmpty() )
830 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit, filterExpression );
833 compatibleFormats, preferredFormat, context, feedback, featureLimit, filterExpression );
843 QString *destLayer = layerName;
858 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint, flags );
866 QVariant val = value;
867 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
872 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
877 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
889 if ( !val.isValid() || val.toString().isEmpty() )
895 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
900 QString layerRef = val.toString();
901 if ( layerRef.isEmpty() )
904 if ( layerRef.isEmpty() )
935 val = parameters.value( definition->
name() );
942 QVariant val = value;
946 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
956 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
960 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
967 dest = val.toString();
972 dest = destParam->generateTemporaryDestination( &context );
975 if ( destinationProject )
978 if ( destName.isEmpty() && definition )
983 outputName = definition->
name();
1006 val = parameters.value( definition->
name() );
1013 QVariant val = value;
1015 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1023 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
1027 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1034 dest = val.toString();
1039 dest = destParam->generateTemporaryDestination( &context );
1059 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1084 QVariant val = value;
1086 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1090 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1096 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1115 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1121 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1134 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1137 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1140 rectText = val.toString();
1142 if ( rectText.isEmpty() && !layer )
1145 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1146 const QRegularExpressionMatch match = rx.match( rectText );
1147 if ( match.hasMatch() )
1149 bool xMinOk =
false;
1150 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1151 bool xMaxOk =
false;
1152 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1153 bool yMinOk =
false;
1154 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1155 bool yMaxOk =
false;
1156 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1157 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1208 QVariant val = parameters.value( definition->
name() );
1210 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1216 g = g.densifyByCount( 20 );
1230 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1236 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1249 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1252 rectText = val.toString();
1254 if ( !rectText.isEmpty() )
1256 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1257 const QRegularExpressionMatch match = rx.match( rectText );
1258 if ( match.hasMatch() )
1260 bool xMinOk =
false;
1261 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1262 bool xMaxOk =
false;
1263 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1264 bool yMinOk =
false;
1265 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1266 bool yMaxOk =
false;
1267 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1268 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1294 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1323 const QVariant val = parameters.value( definition->
name() );
1329 QVariant val = value;
1330 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1339 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1345 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1357 QString valueAsString;
1358 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1361 valueAsString = val.toString();
1363 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1365 const QRegularExpressionMatch match = rx.match( valueAsString );
1366 if ( match.hasMatch() )
1373 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1379 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1392 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1393 return layer->crs();
1395 return layer->crs();
1397 if (
auto *lProject = context.
project() )
1398 return lProject->crs();
1416 const QVariant val = value;
1417 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1421 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1427 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1446 if ( pointText.isEmpty() )
1449 if ( pointText.isEmpty() )
1452 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1455 const QRegularExpressionMatch match = rx.match( valueAsString );
1456 if ( match.hasMatch() )
1459 const double x = match.captured( 1 ).toDouble( &xOk );
1461 const double y = match.captured( 2 ).toDouble( &yOk );
1489 const QVariant val = parameters.value( definition->
name() );
1495 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1504 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1507 const QRegularExpressionMatch match = rx.match( valueAsString );
1508 if ( match.hasMatch() )
1515 if (
auto *lProject = context.
project() )
1516 return lProject->crs();
1534 const QVariant val = value;
1535 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1540 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1545 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1550 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1568 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1574 g = g.densifyByCount( 20 );
1588 if ( val.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1607 if ( valueAsString.isEmpty() )
1610 if ( valueAsString.isEmpty() )
1613 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1615 const QRegularExpressionMatch match = rx.match( valueAsString );
1616 if ( match.hasMatch() )
1643 const QVariant val = parameters.value( definition->
name() );
1649 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1658 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1667 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1677 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1680 const QRegularExpressionMatch match = rx.match( valueAsString );
1681 if ( match.hasMatch() )
1688 if (
auto *lProject = context.
project() )
1689 return lProject->crs();
1700 if ( fileText.isEmpty() )
1711 if ( fileText.isEmpty() )
1719 return QVariantList();
1727 return QVariantList();
1729 QString resultString;
1730 const QVariant val = value;
1731 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1733 else if ( val.type() == QVariant::List )
1734 return val.toList();
1736 resultString = val.toString();
1738 if ( resultString.isEmpty() )
1741 if ( definition->
defaultValue().type() == QVariant::List )
1747 QVariantList result;
1748 const auto constSplit = resultString.split(
',' );
1751 for (
const QString &s : constSplit )
1753 number = s.toDouble( &ok );
1754 result << ( ok ? QVariant( number ) : s );
1763 return QList<QgsMapLayer *>();
1771 return QList<QgsMapLayer *>();
1773 const QVariant val = value;
1774 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1776 return QList<QgsMapLayer *>() << layer;
1779 QList<QgsMapLayer *> layers;
1781 std::function< void(
const QVariant &var ) > processVariant;
1782 processVariant = [ &layers, &context, &definition, flags, &processVariant](
const QVariant & var )
1784 if ( var.type() == QVariant::List )
1786 const auto constToList = var.toList();
1787 for (
const QVariant &listVar : constToList )
1789 processVariant( listVar );
1792 else if ( var.type() == QVariant::StringList )
1794 const auto constToStringList = var.toStringList();
1795 for (
const QString &s : constToStringList )
1797 processVariant( s );
1800 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1802 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1806 const QVariant sink = fromVar.
sink;
1807 if ( sink.userType() == QMetaType::type(
"QgsProperty" ) )
1812 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1824 processVariant( val );
1826 if ( layers.isEmpty() )
1829 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1833 else if ( definition->
defaultValue().type() == QVariant::List )
1835 const auto constToList = definition->
defaultValue().toList();
1836 for (
const QVariant &var : constToList )
1838 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1844 processVariant( var );
1858 return QStringList();
1860 const QVariant val = value;
1864 std::function< void(
const QVariant &var ) > processVariant;
1865 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1867 if ( var.type() == QVariant::List )
1869 const auto constToList = var.toList();
1870 for (
const QVariant &listVar : constToList )
1872 processVariant( listVar );
1875 else if ( var.type() == QVariant::StringList )
1877 const auto constToStringList = var.toStringList();
1878 for (
const QString &s : constToStringList )
1880 processVariant( s );
1883 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1887 files << var.toString();
1891 processVariant( val );
1893 if ( files.isEmpty() )
1904 return QStringList();
1912 return QList<double>();
1920 return QList<double>();
1922 QStringList resultStringList;
1923 const QVariant val = value;
1925 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1927 else if ( val.type() == QVariant::List )
1929 const auto constToList = val.toList();
1930 for (
const QVariant &var : constToList )
1931 resultStringList << var.toString();
1934 resultStringList << val.toString();
1936 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1938 resultStringList.clear();
1940 if ( definition->
defaultValue().type() == QVariant::List )
1942 const auto constToList = definition->
defaultValue().toList();
1943 for (
const QVariant &var : constToList )
1944 resultStringList << var.toString();
1947 resultStringList << definition->
defaultValue().toString();
1950 if ( resultStringList.size() == 1 )
1952 resultStringList = resultStringList.at( 0 ).split(
',' );
1955 if ( resultStringList.size() < 2 )
1956 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1958 QList< double > result;
1960 double n = resultStringList.at( 0 ).toDouble( &ok );
1964 result << std::numeric_limits<double>::quiet_NaN() ;
1966 n = resultStringList.at( 1 ).toDouble( &ok );
1970 result << std::numeric_limits<double>::quiet_NaN() ;
1978 return QStringList();
1991 return QStringList();
1999 return QStringList();
2001 QStringList resultStringList;
2002 const QVariant val = value;
2003 if ( val.isValid() )
2005 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2007 else if ( val.type() == QVariant::List )
2009 const auto constToList = val.toList();
2010 for (
const QVariant &var : constToList )
2011 resultStringList << var.toString();
2013 else if ( val.type() == QVariant::StringList )
2015 resultStringList = val.toStringList();
2018 resultStringList.append( val.toString().split(
';' ) );
2021 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2023 resultStringList.clear();
2027 if ( definition->
defaultValue().type() == QVariant::List )
2029 const auto constToList = definition->
defaultValue().toList();
2030 for (
const QVariant &var : constToList )
2031 resultStringList << var.toString();
2033 else if ( definition->
defaultValue().type() == QVariant::StringList )
2035 resultStringList = definition->
defaultValue().toStringList();
2038 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2042 return resultStringList;
2056 if ( layoutName.isEmpty() )
2108 QVariant val = value;
2109 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2113 if ( val.type() == QVariant::Color )
2115 QColor
c = val.
value< QColor >();
2117 if ( !colorParam->opacityEnabled() )
2125 if ( definition->
defaultValue().type() == QVariant::Color )
2131 if ( colorText.isEmpty() )
2134 bool containsAlpha =
false;
2137 if (
c.isValid() && !colorParam->opacityEnabled() )
2209 const QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2210 const QString name = map.value( QStringLiteral(
"name" ) ).toString();
2211 std::unique_ptr< QgsProcessingParameterDefinition > def;
2288 def.reset( paramType->
create( name ) );
2294 def->fromVariantMap( map );
2295 return def.release();
2300 QString desc = name;
2301 desc.replace(
'_',
' ' );
2307 bool isOptional =
false;
2311 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2316 if ( type == QLatin1String(
"boolean" ) )
2318 else if ( type == QLatin1String(
"crs" ) )
2320 else if ( type == QLatin1String(
"layer" ) )
2322 else if ( type == QLatin1String(
"extent" ) )
2324 else if ( type == QLatin1String(
"point" ) )
2326 else if ( type == QLatin1String(
"geometry" ) )
2328 else if ( type == QLatin1String(
"file" ) )
2330 else if ( type == QLatin1String(
"folder" ) )
2332 else if ( type == QLatin1String(
"matrix" ) )
2334 else if ( type == QLatin1String(
"multiple" ) )
2336 else if ( type == QLatin1String(
"number" ) )
2338 else if ( type == QLatin1String(
"distance" ) )
2340 else if ( type == QLatin1String(
"duration" ) )
2342 else if ( type == QLatin1String(
"scale" ) )
2344 else if ( type == QLatin1String(
"range" ) )
2346 else if ( type == QLatin1String(
"raster" ) )
2348 else if ( type == QLatin1String(
"enum" ) )
2350 else if ( type == QLatin1String(
"string" ) )
2352 else if ( type == QLatin1String(
"authcfg" ) )
2354 else if ( type == QLatin1String(
"expression" ) )
2356 else if ( type == QLatin1String(
"field" ) )
2358 else if ( type == QLatin1String(
"vector" ) )
2360 else if ( type == QLatin1String(
"source" ) )
2362 else if ( type == QLatin1String(
"sink" ) )
2364 else if ( type == QLatin1String(
"vectordestination" ) )
2366 else if ( type == QLatin1String(
"rasterdestination" ) )
2368 else if ( type == QLatin1String(
"pointclouddestination" ) )
2370 else if ( type == QLatin1String(
"filedestination" ) )
2372 else if ( type == QLatin1String(
"folderdestination" ) )
2374 else if ( type == QLatin1String(
"band" ) )
2376 else if ( type == QLatin1String(
"mesh" ) )
2378 else if ( type == QLatin1String(
"layout" ) )
2380 else if ( type == QLatin1String(
"layoutitem" ) )
2382 else if ( type == QLatin1String(
"color" ) )
2384 else if ( type == QLatin1String(
"coordinateoperation" ) )
2386 else if ( type == QLatin1String(
"maptheme" ) )
2388 else if ( type == QLatin1String(
"datetime" ) )
2390 else if ( type == QLatin1String(
"providerconnection" ) )
2392 else if ( type == QLatin1String(
"databaseschema" ) )
2394 else if ( type == QLatin1String(
"databasetable" ) )
2396 else if ( type == QLatin1String(
"pointcloud" ) )
2398 else if ( type == QLatin1String(
"annotation" ) )
2400 else if ( type == QLatin1String(
"attribute" ) )
2402 else if ( type == QLatin1String(
"vectortiledestination" ) )
2408bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2410 const thread_local QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2411 QRegularExpressionMatch m = re.match( code );
2412 if ( !m.hasMatch() )
2415 name = m.captured( 1 );
2416 QString tokens = m.captured( 2 );
2417 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2420 tokens.remove( 0, 8 );
2427 tokens = tokens.trimmed();
2429 const thread_local QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2430 m = re2.match( tokens );
2431 if ( !m.hasMatch() )
2433 type = tokens.toLower().trimmed();
2438 type = m.captured( 1 ).toLower().trimmed();
2439 definition = m.captured( 2 );
2450 , mDescription( description )
2452 , mDefault( defaultValue )
2453 , mFlags( optional ?
Qgis::ProcessingParameterFlag::Optional :
Qgis::ProcessingParameterFlag() )
2459 if ( defaultSettingsValue.isValid() )
2461 return defaultSettingsValue;
2469 if ( defaultSettingsValue.isValid() )
2471 return defaultSettingsValue;
2481 QVariant settingValue = s.
value( QStringLiteral(
"/Processing/DefaultGuiParam/%1/%2" ).arg(
mAlgorithm->
id() ).arg(
mName ) );
2482 if ( settingValue.isValid() )
2484 return settingValue;
2492 if ( !input.isValid() && !
mDefault.isValid() )
2495 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2496 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2504 if ( !value.isValid() )
2505 return QStringLiteral(
"None" );
2507 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2508 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2520 if ( !value.isValid() )
2524 if ( value.type() == QVariant::Type::Map )
2526 const QVariantMap sourceMap = value.toMap();
2527 QVariantMap resultMap;
2528 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2534 else if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2536 const QVariantList sourceList = value.toList();
2537 QVariantList resultList;
2538 resultList.reserve( sourceList.size() );
2539 for (
const QVariant &v : sourceList )
2547 switch ( value.userType() )
2550 case QMetaType::Bool:
2551 case QMetaType::Char:
2552 case QMetaType::Int:
2553 case QMetaType::Double:
2554 case QMetaType::Float:
2555 case QMetaType::LongLong:
2556 case QMetaType::ULongLong:
2557 case QMetaType::UInt:
2558 case QMetaType::ULong:
2559 case QMetaType::UShort:
2566 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2576 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"field" ), prop.
field() }} );
2578 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"expression" ), prop.
expressionString() }} );
2583 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2593 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2601 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2610 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2622 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2637 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2643 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2650 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2657 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2662 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2664 const QColor fromVar = value.value< QColor >();
2665 if ( !fromVar.isValid() )
2668 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2670 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2672 const QDateTime fromVar = value.toDateTime();
2673 if ( !fromVar.isValid() )
2676 return fromVar.toString( Qt::ISODate );
2678 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2680 const QDate fromVar = value.toDate();
2681 if ( !fromVar.isValid() )
2684 return fromVar.toString( Qt::ISODate );
2686 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2688 const QTime fromVar = value.toTime();
2689 if ( !fromVar.isValid() )
2692 return fromVar.toString( Qt::ISODate );
2699 p.insert(
name(), value );
2707 if ( value.userType() == QMetaType::QString )
2712 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2725 if ( !value.isValid() )
2728 switch ( value.userType() )
2731 case QMetaType::Bool:
2732 case QMetaType::Char:
2733 case QMetaType::Int:
2734 case QMetaType::Double:
2735 case QMetaType::Float:
2736 case QMetaType::LongLong:
2737 case QMetaType::ULongLong:
2738 case QMetaType::UInt:
2739 case QMetaType::ULong:
2740 case QMetaType::UShort:
2741 return value.toString();
2747 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2757 return QStringLiteral(
"field:%1" ).arg( prop.
field() );
2764 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2774 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2782 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2790 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2802 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2817 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2823 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2830 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2835 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2840 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2842 const QColor fromVar = value.value< QColor >();
2843 if ( !fromVar.isValid() )
2846 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2848 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2850 const QDateTime fromVar = value.toDateTime();
2851 if ( !fromVar.isValid() )
2854 return fromVar.toString( Qt::ISODate );
2856 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2858 const QDate fromVar = value.toDate();
2859 if ( !fromVar.isValid() )
2862 return fromVar.toString( Qt::ISODate );
2864 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2866 const QTime fromVar = value.toTime();
2867 if ( !fromVar.isValid() )
2870 return fromVar.toString( Qt::ISODate );
2877 p.insert(
name(), value );
2885 if ( value.userType() == QMetaType::QString )
2886 return value.toString();
2889 QgsDebugError( QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ) );
2891 return value.toString();
2897 if ( !value.isValid( ) )
2898 return QStringList();
2900 if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2902 const QVariantList sourceList = value.toList();
2903 QStringList resultList;
2904 resultList.reserve( sourceList.size() );
2905 for (
const QVariant &v : sourceList )
2914 return QStringList();
2926 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2928 code += QLatin1String(
"optional " );
2929 code +=
type() +
' ';
2931 return code.trimmed();
2939 switch ( outputType )
2943 QString code = t->className() + QStringLiteral(
"('%1', %2" )
2946 code += QLatin1String(
", optional=True" );
2962 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2963 map.insert( QStringLiteral(
"name" ),
mName );
2964 map.insert( QStringLiteral(
"description" ),
mDescription );
2965 map.insert( QStringLiteral(
"help" ),
mHelp );
2966 map.insert( QStringLiteral(
"default" ),
mDefault );
2967 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2968 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2969 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2975 mName = map.value( QStringLiteral(
"name" ) ).toString();
2976 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2977 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2978 mDefault = map.value( QStringLiteral(
"default" ) );
2979 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2980 mFlags =
static_cast< Qgis::ProcessingParameterFlags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2981 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2997 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
2998 if ( !
help().isEmpty() )
3000 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
3002 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
3017 if ( !val.isValid() )
3018 return QStringLiteral(
"None" );
3020 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3022 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
3027 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3029 code += QLatin1String(
"optional " );
3030 code +=
type() +
' ';
3031 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
3032 return code.trimmed();
3054 if ( !input.isValid() )
3062 if ( input.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3066 else if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3070 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3075 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3081 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3084 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3092 if ( !value.isValid() )
3093 return QStringLiteral(
"None" );
3095 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3098 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
3103 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3104 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3107 p.insert(
name(), value );
3146 if ( !input.isValid() )
3154 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3159 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3164 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3182 if ( !val.isValid() )
3183 return QStringLiteral(
"None" );
3185 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3189 p.insert(
name(), val );
3209 for (
const QString &raster : rasters )
3211 if ( !vectors.contains( raster ) )
3215 for (
const QString &mesh : meshFilters )
3217 if ( !vectors.contains( mesh ) )
3221 for (
const QString &pointCloud : pointCloudFilters )
3223 if ( !vectors.contains( pointCloud ) )
3224 vectors << pointCloud;
3226 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3227 std::sort( vectors.begin(), vectors.end() );
3229 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3239 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3241 code += QLatin1String(
"optional " );
3242 code += QLatin1String(
"layer " );
3249 code += QLatin1String(
"hasgeometry " );
3253 code += QLatin1String(
"point " );
3257 code += QLatin1String(
"line " );
3261 code += QLatin1String(
"polygon " );
3265 code += QLatin1String(
"raster " );
3269 code += QLatin1String(
"mesh " );
3273 code += QLatin1String(
"plugin " );
3277 code += QLatin1String(
"pointcloud " );
3281 code += QLatin1String(
"annotation " );
3290 return code.trimmed();
3296 QString def = definition;
3299 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3302 def = def.mid( 12 );
3305 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3311 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3317 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3323 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3329 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3335 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3341 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3344 def = def.mid( 11 );
3347 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3350 def = def.mid( 11 );
3361 switch ( outputType )
3365 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3368 code += QLatin1String(
", optional=True" );
3375 QStringList options;
3379 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3383 code += QLatin1Char(
')' );
3400 map.insert( QStringLiteral(
"data_types" ), types );
3408 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3409 for (
const QVariant &val : values )
3430 if ( !input.isValid() )
3438 if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3442 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3447 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3452 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3457 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3461 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3468 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3471 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3480 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3481 const QRegularExpressionMatch match = rx.match( input.toString() );
3482 if ( match.hasMatch() )
3484 bool xMinOk =
false;
3485 ( void )match.captured( 1 ).toDouble( &xMinOk );
3486 bool xMaxOk =
false;
3487 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3488 bool yMinOk =
false;
3489 ( void )match.captured( 3 ).toDouble( &yMinOk );
3490 bool yMaxOk =
false;
3491 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3492 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3502 if ( !value.isValid() )
3503 return QStringLiteral(
"None" );
3505 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3506 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3508 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3516 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3524 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3529 const QString wkt = g.
asWkt();
3530 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3535 p.insert(
name(), value );
3572 if ( !input.isValid() )
3580 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3585 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3589 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3593 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3598 if ( input.type() == QVariant::String )
3600 if ( input.toString().isEmpty() )
3604 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3606 const QRegularExpressionMatch match = rx.match( input.toString() );
3607 if ( match.hasMatch() )
3610 ( void )match.captured( 1 ).toDouble( &xOk );
3612 ( void )match.captured( 2 ).toDouble( &yOk );
3621 if ( !value.isValid() )
3622 return QStringLiteral(
"None" );
3624 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3625 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3627 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3633 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3640 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3645 const QString wkt = g.
asWkt();
3646 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3659 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3661 mGeomTypes( geometryTypes ),
3662 mAllowMultipart( allowMultipart )
3675 if ( !input.isValid() )
3683 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3690 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3692 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3693 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3696 if ( input.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3702 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3707 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3712 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3717 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3722 if ( input.type() == QVariant::String )
3724 if ( input.toString().isEmpty() )
3729 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3731 const QRegularExpressionMatch match = rx.match( input.toString() );
3732 if ( match.hasMatch() )
3737 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
3757 if ( !value.isValid() )
3758 return QStringLiteral(
"None" );
3760 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3763 if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3770 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3777 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3784 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3791 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3798 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3810 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3812 code += QLatin1String(
"optional " );
3813 code +=
type() +
' ';
3815 for (
const int type : mGeomTypes )
3820 code += QLatin1String(
"point " );
3824 code += QLatin1String(
"line " );
3828 code += QLatin1String(
"polygon " );
3832 code += QLatin1String(
"unknown " );
3838 return code.trimmed();
3843 switch ( outputType )
3847 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3850 code += QLatin1String(
", optional=True" );
3852 if ( !mGeomTypes.empty() )
3859 return QStringLiteral(
"PointGeometry" );
3862 return QStringLiteral(
"LineGeometry" );
3865 return QStringLiteral(
"PolygonGeometry" );
3868 return QStringLiteral(
"UnknownGeometry" );
3871 return QStringLiteral(
"NullGeometry" );
3876 QStringList options;
3877 options.reserve( mGeomTypes.size() );
3878 for (
const int type : mGeomTypes )
3880 options << QStringLiteral(
" QgsWkbTypes.%1" ).arg( geomTypeToString(
static_cast<Qgis::GeometryType>(
type ) ) );
3882 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3885 if ( ! mAllowMultipart )
3887 code += QLatin1String(
", allowMultipart=False" );
3902 for (
const int type : mGeomTypes )
3906 map.insert( QStringLiteral(
"geometrytypes" ), types );
3907 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3915 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3916 for (
const QVariant &val : values )
3918 mGeomTypes << val.toInt();
3920 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
3931 , mBehavior( behavior )
3932 , mExtension( fileFilter.isEmpty() ? extension : QString() )
3933 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3946 if ( !input.isValid() )
3954 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3959 const QString
string = input.toString().trimmed();
3961 if ( input.type() != QVariant::String ||
string.isEmpty() )
3964 switch ( mBehavior )
3968 if ( !mExtension.isEmpty() )
3970 return string.endsWith( mExtension, Qt::CaseInsensitive );
3972 else if ( !mFileFilter.isEmpty() )
3990 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3992 code += QLatin1String(
"optional " );
3995 return code.trimmed();
4000 switch ( outputType )
4005 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
4008 code += QLatin1String(
", optional=True" );
4009 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
Qgis::ProcessingFileParameterBehavior::File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
4010 if ( !mExtension.isEmpty() )
4011 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
4012 if ( !mFileFilter.isEmpty() )
4013 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
4024 switch ( mBehavior )
4028 if ( !mFileFilter.isEmpty() )
4029 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
4030 else if ( !mExtension.isEmpty() )
4031 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
4033 return QObject::tr(
"All files (*.*)" );
4045 mFileFilter.clear();
4055 mFileFilter = filter;
4062 map.insert( QStringLiteral(
"behavior" ),
static_cast< int >( mBehavior ) );
4063 map.insert( QStringLiteral(
"extension" ), mExtension );
4064 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
4072 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
4073 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
4084 , mHeaders( headers )
4085 , mNumberRows( numberRows )
4086 , mFixedNumberRows( fixedNumberRows )
4099 if ( !input.isValid() )
4107 if ( input.type() == QVariant::String )
4109 if ( input.toString().isEmpty() )
4113 else if ( input.type() == QVariant::List )
4115 if ( input.toList().isEmpty() )
4119 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
4129 if ( !value.isValid() )
4130 return QStringLiteral(
"None" );
4132 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4133 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4136 p.insert(
name(), value );
4144 switch ( outputType )
4148 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4151 code += QLatin1String(
", optional=True" );
4152 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4153 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4156 headers.reserve( mHeaders.size() );
4157 for (
const QString &h : mHeaders )
4159 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4191 return mFixedNumberRows;
4196 mFixedNumberRows = fixedNumberRows;
4202 map.insert( QStringLiteral(
"headers" ), mHeaders );
4203 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4204 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4211 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4212 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4213 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4224 , mLayerType( layerType )
4237 if ( !input.isValid() )
4247 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4253 if ( input.type() == QVariant::String )
4255 if ( input.toString().isEmpty() )
4258 if ( mMinimumNumberInputs > 1 )
4269 else if ( input.type() == QVariant::List )
4271 if ( input.toList().count() < mMinimumNumberInputs )
4274 if ( mMinimumNumberInputs > input.toList().count() )
4282 const auto constToList = input.toList();
4283 for (
const QVariant &v : constToList )
4285 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4294 else if ( input.type() == QVariant::StringList )
4296 if ( input.toStringList().count() < mMinimumNumberInputs )
4299 if ( mMinimumNumberInputs > input.toStringList().count() )
4307 const auto constToStringList = input.toStringList();
4308 for (
const QString &v : constToStringList )
4321 if ( !value.isValid() )
4322 return QStringLiteral(
"None" );
4324 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4325 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4330 if ( value.type() == QVariant::StringList )
4332 const QStringList list = value.toStringList();
4333 parts.reserve( list.count() );
4334 for (
const QString &v : list )
4337 else if ( value.type() == QVariant::List )
4339 const QVariantList list = value.toList();
4340 parts.reserve( list.count() );
4341 for (
const QVariant &v : list )
4344 if ( !parts.isEmpty() )
4345 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4350 p.insert(
name(), value );
4352 if ( !list.isEmpty() )
4355 parts.reserve( list.count() );
4360 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4379 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4381 code += QLatin1String(
"optional " );
4382 switch ( mLayerType )
4385 code += QLatin1String(
"multiple raster" );
4389 code += QLatin1String(
"multiple file" );
4393 code += QLatin1String(
"multiple vector" );
4397 if (
mDefault.type() == QVariant::List )
4400 const auto constToList =
mDefault.toList();
4401 for (
const QVariant &var : constToList )
4403 parts << var.toString();
4405 code += parts.join(
',' );
4407 else if (
mDefault.type() == QVariant::StringList )
4409 code +=
mDefault.toStringList().join(
',' );
4415 return code.trimmed();
4420 switch ( outputType )
4424 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4427 code += QLatin1String(
", optional=True" );
4431 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4442 switch ( mLayerType )
4445 return QObject::tr(
"All files (*.*)" );
4484 return mMinimumNumberInputs;
4496 map.insert( QStringLiteral(
"layer_type" ),
static_cast< int >( mLayerType ) );
4497 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4505 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4511 QString
type = definition;
4513 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4514 const QRegularExpressionMatch m = re.match( definition );
4517 type = m.captured( 1 ).toLower().trimmed();
4518 defaultVal = m.captured( 2 );
4521 if (
type == QLatin1String(
"vector" ) )
4523 else if (
type == QLatin1String(
"raster" ) )
4525 else if (
type == QLatin1String(
"file" ) )
4538 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4549 QVariant input = value;
4550 if ( !input.isValid() )
4558 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4564 const double res = input.toDouble( &ok );
4568 return !( res < mMin || res > mMax );
4573 if ( !value.isValid() )
4574 return QStringLiteral(
"None" );
4576 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4577 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4579 return value.toString();
4586 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4587 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4588 if ( mMax < std::numeric_limits<double>::max() )
4589 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4592 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4593 if ( !extra.isEmpty() )
4594 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4600 switch ( outputType )
4604 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4607 code += QLatin1String(
", optional=True" );
4609 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4611 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4612 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4613 if ( mMax != std::numeric_limits<double>::max() )
4614 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4656 map.insert( QStringLiteral(
"min" ), mMin );
4657 map.insert( QStringLiteral(
"max" ), mMax );
4658 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4665 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4666 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4674 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4692 if ( !input.isValid() )
4700 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4705 if ( input.type() == QVariant::String )
4707 const QStringList list = input.toString().split(
',' );
4708 if ( list.count() != 2 )
4711 list.at( 0 ).toDouble( &ok );
4713 list.at( 1 ).toDouble( &ok2 );
4718 else if ( input.type() == QVariant::List )
4720 if ( input.toList().count() != 2 )
4724 input.toList().at( 0 ).toDouble( &ok );
4726 input.toList().at( 1 ).toDouble( &ok2 );
4737 if ( !value.isValid() )
4738 return QStringLiteral(
"None" );
4740 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4741 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4744 p.insert(
name(), value );
4747 QStringList stringParts;
4748 const auto constParts = parts;
4749 for (
const double v : constParts )
4751 stringParts << QString::number( v );
4753 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4758 switch ( outputType )
4762 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4765 code += QLatin1String(
", optional=True" );
4767 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4790 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4804 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4821 if ( !input.isValid() )
4829 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4834 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4837 if ( input.type() != QVariant::String || input.toString().isEmpty() )
4855 if ( !val.isValid() )
4856 return QStringLiteral(
"None" );
4858 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
4862 p.insert(
name(), val );
4890 , mOptions( options )
4891 , mAllowMultiple( allowMultiple )
4892 , mUsesStaticStrings( usesStaticStrings )
4904 QVariant input = value;
4905 if ( !input.isValid() )
4913 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4918 if ( mUsesStaticStrings )
4920 if ( input.type() == QVariant::List )
4922 if ( !mAllowMultiple )
4925 const QVariantList values = input.toList();
4929 for (
const QVariant &val : values )
4931 if ( !mOptions.contains( val.toString() ) )
4937 else if ( input.type() == QVariant::StringList )
4939 if ( !mAllowMultiple )
4942 const QStringList values = input.toStringList();
4947 if ( values.count() > 1 && !mAllowMultiple )
4950 for (
const QString &val : values )
4952 if ( !mOptions.contains( val ) )
4957 else if ( input.type() == QVariant::String )
4959 const QStringList parts = input.toString().split(
',' );
4960 if ( parts.count() > 1 && !mAllowMultiple )
4963 const auto constParts = parts;
4964 for (
const QString &part : constParts )
4966 if ( !mOptions.contains( part ) )
4974 if ( input.type() == QVariant::List )
4976 if ( !mAllowMultiple )
4979 const QVariantList values = input.toList();
4983 for (
const QVariant &val : values )
4986 const int res = val.toInt( &ok );
4989 else if ( res < 0 || res >= mOptions.count() )
4995 else if ( input.type() == QVariant::String )
4997 const QStringList parts = input.toString().split(
',' );
4998 if ( parts.count() > 1 && !mAllowMultiple )
5001 const auto constParts = parts;
5002 for (
const QString &part : constParts )
5005 const int res = part.toInt( &ok );
5008 else if ( res < 0 || res >= mOptions.count() )
5013 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
5016 const int res = input.toInt( &ok );
5019 else if ( res >= 0 && res < mOptions.count() )
5029 if ( !value.isValid() )
5030 return QStringLiteral(
"None" );
5032 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5033 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5035 if ( mUsesStaticStrings )
5037 if ( value.type() == QVariant::List || value.type() == QVariant::StringList )
5040 const QStringList constList = value.toStringList();
5041 for (
const QString &val : constList )
5045 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5047 else if ( value.type() == QVariant::String )
5050 const QStringList constList = value.toString().split(
',' );
5051 if ( constList.count() > 1 )
5053 for (
const QString &val : constList )
5057 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5065 if ( value.type() == QVariant::List )
5068 const auto constToList = value.toList();
5069 for (
const QVariant &val : constToList )
5071 parts << QString::number( static_cast< int >( val.toDouble() ) );
5073 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5075 else if ( value.type() == QVariant::String )
5077 const QStringList parts = value.toString().split(
',' );
5078 if ( parts.count() > 1 )
5080 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5084 return QString::number(
static_cast< int >( value.toDouble() ) );
5090 if ( !value.isValid() )
5093 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5096 if ( mUsesStaticStrings )
5102 if ( value.type() == QVariant::List )
5105 const QVariantList toList = value.toList();
5106 parts.reserve( toList.size() );
5107 for (
const QVariant &val : toList )
5109 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5111 return parts.join(
',' );
5113 else if ( value.type() == QVariant::String )
5115 const QStringList parts = value.toString().split(
',' );
5116 QStringList comments;
5117 if ( parts.count() > 1 )
5119 for (
const QString &part : parts )
5122 const int val = part.toInt( &ok );
5124 comments << mOptions.value( val );
5126 return comments.join(
',' );
5130 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5136 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5138 code += QLatin1String(
"optional " );
5139 code += QLatin1String(
"enum " );
5141 if ( mAllowMultiple )
5142 code += QLatin1String(
"multiple " );
5144 if ( mUsesStaticStrings )
5145 code += QLatin1String(
"static " );
5147 code += mOptions.join(
';' ) +
' ';
5150 return code.trimmed();
5155 switch ( outputType )
5159 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5162 code += QLatin1String(
", optional=True" );
5165 options.reserve( mOptions.size() );
5166 for (
const QString &o : mOptions )
5168 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5170 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5172 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5195 return mAllowMultiple;
5205 return mUsesStaticStrings;
5216 map.insert( QStringLiteral(
"options" ), mOptions );
5217 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5218 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5225 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5226 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5227 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5234 QString def = definition;
5236 bool multiple =
false;
5237 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5243 bool staticStrings =
false;
5244 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5246 staticStrings =
true;
5250 const thread_local QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5251 const QRegularExpressionMatch m = re.match( def );
5252 QString values = def;
5255 values = m.captured( 1 ).trimmed();
5256 defaultVal = m.captured( 2 );
5264 , mMultiLine( multiLine )
5277 return QStringLiteral(
"None" );
5279 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5280 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5282 const QString s = value.toString();
5288 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5290 code += QLatin1String(
"optional " );
5291 code += QLatin1String(
"string " );
5294 code += QLatin1String(
"long " );
5297 return code.trimmed();
5302 switch ( outputType )
5306 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5309 code += QLatin1String(
", optional=True" );
5310 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5333 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5340 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5346 QString def = definition;
5348 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5354 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5356 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5360 if ( def == QLatin1String(
"None" ) )
5383 if ( !value.isValid() )
5384 return QStringLiteral(
"None" );
5386 const QString s = value.toString();
5392 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5394 code += QLatin1String(
"optional " );
5395 code += QLatin1String(
"authcfg " );
5398 return code.trimmed();
5403 QString def = definition;
5405 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5407 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5411 if ( def == QLatin1String(
"None" ) )
5424 , mParentLayerParameterName( parentLayerParameterName )
5425 , mExpressionType( type )
5437 if ( !value.isValid() )
5438 return QStringLiteral(
"None" );
5440 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5441 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5443 const QString s = value.toString();
5449 QStringList depends;
5450 if ( !mParentLayerParameterName.isEmpty() )
5451 depends << mParentLayerParameterName;
5457 switch ( outputType )
5461 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5464 code += QLatin1String(
", optional=True" );
5466 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5472 switch ( mExpressionType )
5475 code += QLatin1String(
", type=Qgis.ExpressionType.PointCloud)" );
5478 code += QLatin1String(
", type=Qgis.ExpressionType.RasterCalculator)" );
5481 code += QLatin1Char(
')' );
5492 return mParentLayerParameterName;
5502 return mExpressionType;
5513 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5514 map.insert( QStringLiteral(
"expression_type" ),
static_cast< int >( mExpressionType ) );
5521 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5522 mExpressionType =
static_cast< Qgis::ExpressionType >( map.value( QStringLiteral(
"expression_type" ) ).toInt() );
5547 if ( !var.isValid() )
5555 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5568 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5571 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5589 if ( !val.isValid() )
5590 return QStringLiteral(
"None" );
5592 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5596 p.insert(
name(), val );
5614 switch ( outputType )
5618 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5621 code += QLatin1String(
", optional=True" );
5625 QStringList options;
5628 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5662 map.insert( QStringLiteral(
"data_types" ), types );
5670 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5671 for (
const QVariant &val : values )
5684 const QVariant &defaultValue,
bool optional )
5699 if ( !var.isValid() )
5707 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5720 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5723 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5741 if ( !val.isValid() )
5742 return QStringLiteral(
"None" );
5744 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5748 p.insert(
name(), val );
5776 , mParentLayerParameterName( parentLayerParameterName )
5778 , mAllowMultiple( allowMultiple )
5779 , mDefaultToAllFields( defaultToAllFields )
5793 if ( !input.isValid() )
5801 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
5806 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5808 if ( !mAllowMultiple )
5814 else if ( input.type() == QVariant::String )
5816 if ( input.toString().isEmpty() )
5819 const QStringList parts = input.toString().split(
';' );
5820 if ( parts.count() > 1 && !mAllowMultiple )
5825 if ( input.toString().isEmpty() )
5833 if ( !value.isValid() )
5834 return QStringLiteral(
"None" );
5836 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5837 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5839 if ( value.type() == QVariant::List )
5842 const auto constToList = value.toList();
5843 for (
const QVariant &val : constToList )
5847 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5849 else if ( value.type() == QVariant::StringList )
5852 const auto constToStringList = value.toStringList();
5853 for (
const QString &s : constToStringList )
5857 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5865 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5867 code += QLatin1String(
"optional " );
5868 code += QLatin1String(
"field " );
5870 switch ( mDataType )
5873 code += QLatin1String(
"numeric " );
5877 code += QLatin1String(
"string " );
5881 code += QLatin1String(
"datetime " );
5885 code += QLatin1String(
"binary " );
5889 code += QLatin1String(
"boolean " );
5896 if ( mAllowMultiple )
5897 code += QLatin1String(
"multiple " );
5899 if ( mDefaultToAllFields )
5900 code += QLatin1String(
"default_to_all_fields " );
5902 code += mParentLayerParameterName +
' ';
5905 return code.trimmed();
5910 switch ( outputType )
5914 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
5917 code += QLatin1String(
", optional=True" );
5920 switch ( mDataType )
5923 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
5927 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
5931 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
5935 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
5939 dataType = QStringLiteral(
"QgsProcessingParameterField.Binary" );
5943 dataType = QStringLiteral(
"QgsProcessingParameterField.Boolean" );
5946 code += QStringLiteral(
", type=%1" ).arg(
dataType );
5948 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5949 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5953 if ( mDefaultToAllFields )
5954 code += QLatin1String(
", defaultToAllFields=True" );
5966 QStringList depends;
5967 if ( !mParentLayerParameterName.isEmpty() )
5968 depends << mParentLayerParameterName;
5974 return mParentLayerParameterName;
5994 return mAllowMultiple;
6004 return mDefaultToAllFields;
6009 mDefaultToAllFields = enabled;
6015 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6016 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6017 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6018 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
6025 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6027 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6028 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
6038 QString def = definition;
6040 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
6045 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
6050 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
6055 else if ( def.startsWith( QLatin1String(
"binary " ), Qt::CaseInsensitive ) )
6060 else if ( def.startsWith( QLatin1String(
"boolean " ), Qt::CaseInsensitive ) )
6066 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6069 def = def.mid( 8 ).trimmed();
6072 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
6075 def = def.mid( 21 ).trimmed();
6078 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6079 const QRegularExpressionMatch m = re.match( def );
6082 parent = m.captured( 1 ).trimmed();
6083 def = m.captured( 2 );
6108 QVariant var = input;
6109 if ( !var.isValid() )
6117 if ( var.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6122 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6129 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6141 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6146 if ( var.type() != QVariant::String || var.toString().isEmpty() )
6164 if ( !value.isValid() )
6165 return QStringLiteral(
"None" );
6167 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6170 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6173 QString geometryCheckString;
6177 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
6181 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
6185 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6192 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6194 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6195 if ( !
flags.empty() )
6196 flagString =
flags.join( QLatin1String(
" | " ) );
6203 layerString = layer->source();
6210 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6211 geometryCheckString,
6223 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4%6, geometryCheck=%5)" )
6227 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6228 geometryCheckString,
6237 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6242 QString layerString = value.toString();
6246 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6263 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6265 code += QLatin1String(
"optional " );
6266 code += QLatin1String(
"source " );
6273 code += QLatin1String(
"point " );
6277 code += QLatin1String(
"line " );
6281 code += QLatin1String(
"polygon " );
6290 return code.trimmed();
6295 switch ( outputType )
6299 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6302 code += QLatin1String(
", optional=True" );
6306 QStringList options;
6310 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6327 : mDataTypes( types )
6340 map.insert( QStringLiteral(
"data_types" ), types );
6348 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6349 for (
const QVariant &val : values )
6359 QString def = definition;
6362 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6368 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6374 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6389 , mSupportsAppend( supportsAppend )
6400 QVariant var = input;
6401 if ( !var.isValid() )
6409 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6415 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6428 if ( var.type() != QVariant::String )
6431 if ( var.toString().isEmpty() )
6439 if ( !value.isValid() )
6440 return QStringLiteral(
"None" );
6442 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6443 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6445 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6454 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6463 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6465 code += QLatin1String(
"optional " );
6466 code += QLatin1String(
"sink " );
6468 switch ( mDataType )
6471 code += QLatin1String(
"point " );
6475 code += QLatin1String(
"line " );
6479 code += QLatin1String(
"polygon " );
6483 code += QLatin1String(
"table " );
6491 return code.trimmed();
6503 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6507 return p->defaultVectorFileExtension(
hasGeometry() );
6517 return QStringLiteral(
"dbf" );
6524 switch ( outputType )
6528 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6531 code += QLatin1String(
", optional=True" );
6535 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6536 if ( mSupportsAppend )
6537 code += QLatin1String(
", supportsAppend=True" );
6550 QStringList filters;
6551 for (
const QString &ext : exts )
6553 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6555 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6564 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6566 return lOriginalProvider->supportedOutputTableExtensions();
6571 return p->supportedOutputVectorLayerExtensions();
6573 return p->supportedOutputTableExtensions();
6588 switch ( mDataType )
6618 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6619 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6627 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6634 return QStringLiteral(
"memory:%1" ).arg(
description() );
6642 QString def = definition;
6643 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6648 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6653 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6658 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6669 return mSupportsAppend;
6689 QVariant var = input;
6690 if ( !var.isValid() )
6698 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6704 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6717 if ( var.type() != QVariant::String )
6720 if ( var.toString().isEmpty() )
6728 if ( !value.isValid() )
6729 return QStringLiteral(
"None" );
6731 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6732 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6734 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6743 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6759 return lOriginalProvider->defaultRasterFileExtension();
6763 return p->defaultRasterFileExtension();
6774 QStringList filters;
6775 for (
const QString &ext : exts )
6777 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6779 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6786 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6790 return p->supportedOutputRasterLayerExtensions();
6806 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6818 QVariant var = input;
6819 if ( !var.isValid() )
6827 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6833 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6846 if ( var.type() != QVariant::String )
6849 if ( var.toString().isEmpty() )
6859 if ( !value.isValid() )
6860 return QStringLiteral(
"None" );
6862 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6863 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6865 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6874 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6883 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6895 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6896 return QStringLiteral(
"file" );
6899 const thread_local QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6900 const QRegularExpressionMatch match = rx.match( mFileFilter );
6901 if ( !match.hasMatch() )
6902 return QStringLiteral(
"file" );
6904 return match.captured( 1 );
6909 switch ( outputType )
6913 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
6916 code += QLatin1String(
", optional=True" );
6920 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6932 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
6948 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
6955 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
6976 QVariant var = input;
6977 if ( !var.isValid() )
6985 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6998 if ( var.type() != QVariant::String )
7001 if ( var.toString().isEmpty() )
7024 , mCreateByDefault( createByDefault )
7032 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
7033 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
7040 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
7041 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
7047 switch ( outputType )
7054 QString code = t->className() + QStringLiteral(
"('%1', %2" )
7057 code += QLatin1String(
", optional=True" );
7059 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7074 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
7081 const thread_local QRegularExpression rx( QStringLiteral(
"[.]" ) );
7082 QString sanitizedName =
name();
7083 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
7098 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
7107 return mCreateByDefault;
7129 QVariant var = input;
7130 if ( !var.isValid() )
7138 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7144 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
7157 if ( var.type() != QVariant::String )
7160 if ( var.toString().isEmpty() )
7168 if ( !value.isValid() )
7169 return QStringLiteral(
"None" );
7171 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7172 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7174 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7183 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
7192 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7194 code += QLatin1String(
"optional " );
7195 code += QLatin1String(
"vectorDestination " );
7197 switch ( mDataType )
7200 code += QLatin1String(
"point " );
7204 code += QLatin1String(
"line " );
7208 code += QLatin1String(
"polygon " );
7216 return code.trimmed();
7228 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7232 return p->defaultVectorFileExtension(
hasGeometry() );
7242 return QStringLiteral(
"dbf" );
7249 switch ( outputType )
7253 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7256 code += QLatin1String(
", optional=True" );
7260 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7273 QStringList filters;
7274 for (
const QString &ext : exts )
7276 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7278 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7286 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7288 return lOriginalProvider->supportedOutputTableExtensions();
7293 return p->supportedOutputVectorLayerExtensions();
7295 return p->supportedOutputTableExtensions();
7310 switch ( mDataType )
7340 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
7354 QString def = definition;
7355 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7360 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7365 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7376 , mParentLayerParameterName( parentLayerParameterName )
7377 , mAllowMultiple( allowMultiple )
7389 QVariant input = value;
7390 if ( !input.isValid() )
7398 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7403 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
7405 if ( !mAllowMultiple )
7414 const double res = input.toInt( &ok );
7424 return mAllowMultiple;
7434 if ( !value.isValid() )
7435 return QStringLiteral(
"None" );
7437 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7438 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7440 if ( value.type() == QVariant::List )
7443 const QVariantList values = value.toList();
7444 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7446 parts << QString::number( static_cast< int >( it->toDouble() ) );
7448 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7450 else if ( value.type() == QVariant::StringList )
7453 const QStringList values = value.toStringList();
7454 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7456 parts << QString::number( static_cast< int >( it->toDouble() ) );
7458 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7461 return value.toString();
7466 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7468 code += QLatin1String(
"optional " );
7469 code += QLatin1String(
"band " );
7471 if ( mAllowMultiple )
7472 code += QLatin1String(
"multiple " );
7474 code += mParentLayerParameterName +
' ';
7477 return code.trimmed();
7482 QStringList depends;
7483 if ( !mParentLayerParameterName.isEmpty() )
7484 depends << mParentLayerParameterName;
7490 switch ( outputType )
7494 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7497 code += QLatin1String(
", optional=True" );
7499 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7500 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7512 return mParentLayerParameterName;
7523 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7524 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7531 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7532 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7539 QString def = definition;
7542 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7545 def = def.mid( 8 ).trimmed();
7548 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7549 const QRegularExpressionMatch m = re.match( def );
7552 parent = m.captured( 1 ).trimmed();
7553 def = m.captured( 2 );
7570 , mParentParameterName( parentParameterName )
7587 QStringList depends;
7588 if ( !mParentParameterName.isEmpty() )
7589 depends << mParentParameterName;
7595 switch ( outputType )
7599 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7602 code += QLatin1String(
", optional=True" );
7604 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7606 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7607 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7608 if (
maximum() != std::numeric_limits<double>::max() )
7609 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7620 return mParentParameterName;
7631 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7632 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7639 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7666 switch ( outputType )
7670 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7673 code += QLatin1String(
", optional=True" );
7675 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7676 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7677 if (
maximum() != std::numeric_limits<double>::max() )
7678 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7690 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7724 switch ( outputType )
7728 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7731 code += QLatin1String(
", optional=True" );
7743 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7763 return QStringLiteral(
"None" );
7765 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7766 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7768 const QString s = value.toString();
7774 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7776 code += QLatin1String(
"optional " );
7777 code += QLatin1String(
"layout " );
7780 return code.trimmed();
7785 switch ( outputType )
7789 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
7792 code += QLatin1String(
", optional=True" );
7803 QString def = definition;
7805 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7807 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7811 if ( def == QLatin1String(
"None" ) )
7824 , mParentLayoutParameterName( parentLayoutParameterName )
7825 , mItemType( itemType )
7838 return QStringLiteral(
"None" );
7840 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7841 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7843 const QString s = value.toString();
7849 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7851 code += QLatin1String(
"optional " );
7852 code += QLatin1String(
"layoutitem " );
7853 if ( mItemType >= 0 )
7854 code += QString::number( mItemType ) +
' ';
7856 code += mParentLayoutParameterName +
' ';
7859 return code.trimmed();
7864 switch ( outputType )
7868 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
7871 code += QLatin1String(
", optional=True" );
7873 if ( mItemType >= 0 )
7874 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
7876 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
7889 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
7890 map.insert( QStringLiteral(
"item_type" ), mItemType );
7897 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
7898 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
7904 QStringList depends;
7905 if ( !mParentLayoutParameterName.isEmpty() )
7906 depends << mParentLayoutParameterName;
7913 QString def = definition;
7915 const thread_local QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
7916 const QRegularExpressionMatch m = re.match( def );
7919 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
7920 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
7921 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
7934 return mParentLayoutParameterName;
7939 mParentLayoutParameterName =
name;
7958 , mAllowOpacity( opacityEnabled )
7971 return QStringLiteral(
"None" );
7973 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7974 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7976 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
7977 return QStringLiteral(
"QColor()" );
7979 if ( value.canConvert< QColor >() )
7981 const QColor
c = value.value< QColor >();
7982 if ( !mAllowOpacity ||
c.alpha() == 255 )
7983 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
7985 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
7988 const QString s = value.toString();
7994 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7996 code += QLatin1String(
"optional " );
7997 code += QLatin1String(
"color " );
7999 if ( mAllowOpacity )
8000 code += QLatin1String(
"withopacity " );
8003 return code.trimmed();
8008 switch ( outputType )
8012 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
8015 code += QLatin1String(
", optional=True" );
8017 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
8029 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
8032 if ( !input.isValid() )
8035 if ( input.type() == QVariant::Color )
8039 else if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8044 if ( input.type() != QVariant::String || input.toString().isEmpty() )
8047 bool containsAlpha =
false;
8054 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
8061 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
8067 return mAllowOpacity;
8072 mAllowOpacity = enabled;
8077 QString def = definition;
8079 bool allowOpacity =
false;
8080 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
8082 allowOpacity =
true;
8083 def = def.mid( 12 );
8086 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8088 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8092 if ( def == QLatin1String(
"None" ) || def.isEmpty() )
8103 , mSourceParameterName( sourceCrsParameterName )
8104 , mDestParameterName( destinationCrsParameterName )
8105 , mSourceCrs( staticSourceCrs )
8106 , mDestCrs( staticDestinationCrs )
8119 return QStringLiteral(
"None" );
8121 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
8124 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
8129 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8130 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8133 p.insert(
name(), value );
8138 const QString s = value.toString();
8144 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8146 code += QLatin1String(
"optional " );
8147 code += QLatin1String(
"coordinateoperation " );
8150 return code.trimmed();
8155 switch ( outputType )
8160 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
8163 code += QLatin1String(
", optional=True" );
8164 if ( !mSourceParameterName.isEmpty() )
8165 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
8166 if ( !mDestParameterName.isEmpty() )
8167 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
8169 if ( mSourceCrs.isValid() )
8171 if ( mDestCrs.isValid() )
8172 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
8184 if ( !mSourceParameterName.isEmpty() )
8185 res << mSourceParameterName;
8186 if ( !mDestParameterName.isEmpty() )
8187 res << mDestParameterName;
8194 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
8195 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
8196 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
8197 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
8204 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
8205 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
8206 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
8207 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
8213 QString def = definition;
8215 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8217 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8221 if ( def == QLatin1String(
"None" ) )
8246 if ( !input.isValid() && !
mDefault.isValid() )
8249 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8250 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8258 if ( !value.isValid() )
8259 return QStringLiteral(
"None" );
8261 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8262 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8269 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8271 code += QLatin1String(
"optional " );
8272 code += QLatin1String(
"maptheme " );
8275 return code.trimmed();
8280 switch ( outputType )
8284 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8287 code += QLatin1String(
", optional=True" );
8312 QString def = definition;
8313 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8315 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8337 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8339 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8350 QVariant input = value;
8351 if ( !input.isValid() )
8359 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8364 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
8370 if ( input.type() == QVariant::String )
8372 const QString s = input.toString();
8376 input = QDateTime::fromString( s, Qt::ISODate );
8379 if ( !input.toDateTime().isValid() )
8380 input = QTime::fromString( s );
8382 input = input.toDateTime().time();
8388 const QDateTime res = input.toDateTime();
8389 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8393 const QTime res = input.toTime();
8394 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8400 if ( !value.isValid() )
8401 return QStringLiteral(
"None" );
8403 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8404 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8406 if ( value.type() == QVariant::DateTime )
8408 const QDateTime dt = value.toDateTime();
8409 if ( !dt.isValid() )
8410 return QStringLiteral(
"QDateTime()" );
8412 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8413 .arg( dt.date().month() )
8414 .arg( dt.date().day() )
8415 .arg( dt.time().hour() )
8416 .arg( dt.time().minute() )
8417 .arg( dt.time().second() );
8419 else if ( value.type() == QVariant::Date )
8421 const QDate dt = value.toDate();
8422 if ( !dt.isValid() )
8423 return QStringLiteral(
"QDate()" );
8425 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8429 else if ( value.type() == QVariant::Time )
8431 const QTime dt = value.toTime();
8432 if ( !dt.isValid() )
8433 return QStringLiteral(
"QTime()" );
8435 return QStringLiteral(
"QTime(%4, %5, %6)" )
8438 .arg( dt.second() );
8440 return value.toString();
8447 if ( mMin.isValid() )
8448 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8449 if ( mMax.isValid() )
8450 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8454 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8455 if ( !extra.isEmpty() )
8456 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8462 switch ( outputType )
8466 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8469 code += QLatin1String(
", optional=True" );
8473 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8476 if ( mMin.isValid() )
8478 if ( mMax.isValid() )
8520 map.insert( QStringLiteral(
"min" ), mMin );
8521 map.insert( QStringLiteral(
"max" ), mMax );
8522 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
8529 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8530 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8538 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8549 , mProviderId( provider )
8562 if ( !input.isValid() && !
mDefault.isValid() )
8565 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8566 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8574 if ( !value.isValid() )
8575 return QStringLiteral(
"None" );
8577 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8578 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8585 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8587 code += QLatin1String(
"optional " );
8588 code += QLatin1String(
"providerconnection " );
8589 code += mProviderId +
' ';
8592 return code.trimmed();
8597 switch ( outputType )
8601 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8604 code += QLatin1String(
", optional=True" );
8618 map.insert( QStringLiteral(
"provider" ), mProviderId );
8625 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8631 QString def = definition;
8633 if ( def.contains(
' ' ) )
8635 provider = def.left( def.indexOf(
' ' ) );
8636 def = def.mid( def.indexOf(
' ' ) + 1 );
8644 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8646 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8664 , mParentConnectionParameterName( parentLayerParameterName )
8677 if ( !input.isValid() && !
mDefault.isValid() )
8680 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8681 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8689 if ( !value.isValid() )
8690 return QStringLiteral(
"None" );
8692 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8693 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8700 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8702 code += QLatin1String(
"optional " );
8703 code += QLatin1String(
"databaseschema " );
8705 code += mParentConnectionParameterName +
' ';
8708 return code.trimmed();
8713 switch ( outputType )
8717 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8720 code += QLatin1String(
", optional=True" );
8722 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8736 QStringList depends;
8737 if ( !mParentConnectionParameterName.isEmpty() )
8738 depends << mParentConnectionParameterName;
8744 return mParentConnectionParameterName;
8749 mParentConnectionParameterName =
name;
8755 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8762 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8769 QString def = definition;
8771 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
8772 const QRegularExpressionMatch m = re.match( def );
8775 parent = m.captured( 1 ).trimmed();
8776 def = m.captured( 2 );
8792 const QString &connectionParameterName,
8793 const QString &schemaParameterName,
8794 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
8796 , mParentConnectionParameterName( connectionParameterName )
8797 , mParentSchemaParameterName( schemaParameterName )
8798 , mAllowNewTableNames( allowNewTableNames )
8811 if ( !input.isValid() && !
mDefault.isValid() )
8814 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8815 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8823 if ( !value.isValid() )
8824 return QStringLiteral(
"None" );
8826 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8827 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8834 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8836 code += QLatin1String(
"optional " );
8837 code += QLatin1String(
"databasetable " );
8839 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
8840 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
8843 return code.trimmed();
8848 switch ( outputType )
8852 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
8855 code += QLatin1String(
", optional=True" );
8857 if ( mAllowNewTableNames )
8858 code += QLatin1String(
", allowNewTableNames=True" );
8860 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8861 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
8875 QStringList depends;
8876 if ( !mParentConnectionParameterName.isEmpty() )
8877 depends << mParentConnectionParameterName;
8878 if ( !mParentSchemaParameterName.isEmpty() )
8879 depends << mParentSchemaParameterName;
8885 return mParentConnectionParameterName;
8890 mParentConnectionParameterName =
name;
8895 return mParentSchemaParameterName;
8900 mParentSchemaParameterName =
name;
8906 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8907 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
8908 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
8915 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8916 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
8917 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
8925 QString def = definition;
8927 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
8928 const QRegularExpressionMatch m = re.match( def );
8931 connection = m.captured( 1 ).trimmed();
8932 if ( connection == QLatin1String(
"none" ) )
8934 schema = m.captured( 2 ).trimmed();
8935 if ( schema == QLatin1String(
"none" ) )
8937 def = m.captured( 3 );
8945 return mAllowNewTableNames;
8958 const QVariant &defaultValue,
bool optional )
8972 if ( !var.isValid() )
8980 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8993 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
8996 if ( var.type() != QVariant::String || var.toString().isEmpty() )
9014 if ( !val.isValid() )
9015 return QStringLiteral(
"None" );
9017 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
9021 p.insert(
name(), val );
9052 const QVariant &defaultValue,
bool optional )
9065 if ( !var.isValid() )
9073 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9086 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
9089 if ( var.type() != QVariant::String || var.toString().isEmpty() )
9107 if ( !val.isValid() )
9108 return QStringLiteral(
"None" );
9110 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
9114 p.insert(
name(), val );
9147 QVariant var = input;
9148 if ( !var.isValid() )
9156 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9162 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9175 if ( var.type() != QVariant::String )
9178 if ( var.toString().isEmpty() )
9186 if ( !value.isValid() )
9187 return QStringLiteral(
"None" );
9189 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9190 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9192 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9201 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9217 return lOriginalProvider->defaultPointCloudFileExtension();
9221 return p->defaultPointCloudFileExtension();
9232 QStringList filters;
9233 for (
const QString &ext : exts )
9235 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9237 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9244 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9248 return p->supportedOutputPointCloudLayerExtensions();
9253 return QStringList() << ext;
9268 , mParentLayerParameterName( parentLayerParameterName )
9269 , mAllowMultiple( allowMultiple )
9270 , mDefaultToAllAttributes( defaultToAllAttributes )
9290 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
9295 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
9297 if ( !mAllowMultiple )
9303 else if ( input.type() == QVariant::String )
9305 if ( input.toString().isEmpty() )
9308 const QStringList parts = input.toString().split(
';' );
9309 if ( parts.count() > 1 && !mAllowMultiple )
9314 if ( input.toString().isEmpty() )
9322 if ( !value.isValid() )
9323 return QStringLiteral(
"None" );
9325 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9326 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9328 if ( value.type() == QVariant::List )
9331 const auto constToList = value.toList();
9332 for (
const QVariant &val : constToList )
9336 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9338 else if ( value.type() == QVariant::StringList )
9341 const auto constToStringList = value.toStringList();
9342 for (
const QString &s : constToStringList )
9346 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9354 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9356 code += QLatin1String(
"optional " );
9357 code += QLatin1String(
"attribute " );
9359 if ( mAllowMultiple )
9360 code += QLatin1String(
"multiple " );
9362 if ( mDefaultToAllAttributes )
9363 code += QLatin1String(
"default_to_all_attributes " );
9365 code += mParentLayerParameterName +
' ';
9368 return code.trimmed();
9373 switch ( outputType )
9377 QString code = QStringLiteral(
"QgsProcessingParameterPointCloudAttribute('%1', %2" )
9380 code += QLatin1String(
", optional=True" );
9382 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
9383 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
9387 if ( mDefaultToAllAttributes )
9388 code += QLatin1String(
", defaultToAllAttributes=True" );
9400 QStringList depends;
9401 if ( !mParentLayerParameterName.isEmpty() )
9402 depends << mParentLayerParameterName;
9408 return mParentLayerParameterName;
9418 return mAllowMultiple;
9428 return mDefaultToAllAttributes;
9433 mDefaultToAllAttributes = enabled;
9439 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
9440 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
9441 map.insert( QStringLiteral(
"default_to_all_attributes" ), mDefaultToAllAttributes );
9448 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
9449 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
9450 mDefaultToAllAttributes = map.value( QStringLiteral(
"default_to_all_attributes" ) ).toBool();
9459 QString def = definition;
9461 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
9464 def = def.mid( 8 ).trimmed();
9467 if ( def.startsWith( QLatin1String(
"default_to_all_attributes" ), Qt::CaseInsensitive ) )
9470 def = def.mid( 25 ).trimmed();
9473 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9474 const QRegularExpressionMatch m = re.match( def );
9477 parent = m.captured( 1 ).trimmed();
9478 def = m.captured( 2 );
9505 QVariant var = input;
9506 if ( !var.isValid() )
9514 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9520 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9533 if ( var.type() != QVariant::String )
9536 if ( var.toString().isEmpty() )
9544 if ( !value.isValid() )
9545 return QStringLiteral(
"None" );
9547 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9548 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9550 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9559 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9579 QStringList filters;
9580 for (
const QString &ext : exts )
9582 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9584 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9590 return QStringList() << ext;
The Qgis class provides global constants for use throughout the application.
ProcessingSourceType
Processing data source types.
@ File
Files (i.e. non map layer sources, such as text files)
@ Annotation
Annotation layers.
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ VectorTile
Vector tile layers.
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ VectorAnyGeometry
Any vector layer with geometry.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ PointCloud
Point cloud layers.
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
@ File
Parameter is a single file.
@ Folder
Parameter is a folder.
ExpressionType
Expression types.
@ RasterCalculator
Raster calculator expression (since QGIS 3.34)
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
DistanceUnit
Units of distance.
@ Unknown
Unknown distance unit.
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.
@ Invalid
Invalid (not set) property.
@ Field
Field based property.
@ Expression
Expression based property.
TemporalUnit
Temporal units.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
@ NoCheck
No invalid geometry checking.
@ AbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ SkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
@ CreateIndividualOutputPerInputFeature
If set, every feature processed from this source will be placed into its own individually created out...
@ OverrideDefaultGeometryCheck
If set, the default geometry check method (as dictated by QgsProcessingContext) will be overridden fo...
WkbType
The WKB type describes the number of dimensions a geometry has.
@ Preferred
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
@ Optional
Parameter is optional.
ProcessingDateTimeParameterDataType
Processing date time parameter data types.
@ DateTime
Datetime values.
ProcessingNumberParameterType
Processing numeric parameter data types.
@ Double
Double/float values.
Represents a map layer containing a set of georeferenced annotations, e.g.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString toWkt(Qgis::CrsWktVariant variant=Qgis::CrsWktVariant::Wkt1Gdal, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Custom exception class for Coordinate Reference System related exceptions.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool isValid() const
Checks if this expression is valid.
An interface for objects which accept features via addFeature(s) methods.
Container of fields for a vector layer.
static bool fileMatchesFilter(const QString &fileName, const QString &filter)
Returns true if the given fileName matches a file filter string.
A geometry is the spatial representation of a feature.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
Base class for graphical items within a QgsLayout.
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found.
QgsLayoutItem * itemById(const QString &id) const
Returns a layout item given its id.
QgsLayoutItem * itemByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout item with matching uuid unique identifier, or nullptr if a matching item could not...
Base class for all map layer types.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsCoordinateReferenceSystem crs
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Interface for master layout type objects, such as print layouts and reports.
virtual QgsMasterLayoutInterface::Type layoutType() const =0
Returns the master layout type.
@ PrintLayout
Individual print layout (QgsPrintLayout)
Represents a mesh layer supporting display of data on structured or unstructured meshes.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Represents a map layer supporting display of point clouds.
A class to represent a 2D point.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
QString id() const
Returns the unique ID for the algorithm, which is a combination of the algorithm provider's ID and th...
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
Details for layers to load into projects.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
void addLayerToLoadOnCompletion(const QString &layer, const QgsProcessingContext::LayerDetails &details)
Adds a layer to load (by ID or datasource) into the canvas upon completion of the algorithm or model.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Base class for all parameter definitions which represent file or layer destinations,...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter.
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
bool createByDefault() const
Returns true if the destination should be created by default.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
virtual bool isSupportedOutputValue(const QVariant &value, QgsProcessingContext &context, QString &error) const
Tests whether a value is a supported value for this parameter.
virtual QString generateTemporaryDestination(const QgsProcessingContext *context=nullptr) const
Generates a temporary destination value for this parameter.
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingDestinationParameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Custom exception class for processing related exceptions.
Encapsulates settings relating to a feature source input to a processing algorithm.
bool loadVariant(const QVariantMap &map)
Loads this source definition from a QVariantMap, wrapped in a QVariant.
bool selectedFeaturesOnly
true if only selected features in the source should be used by algorithms.
QgsProperty source
Source definition.
Qgis::InvalidGeometryCheck geometryCheck
Geometry check method to apply to this source.
Qgis::ProcessingFeatureSourceDefinitionFlags flags
Flags which dictate source behavior.
long long featureLimit
If set to a value > 0, places a limit on the maximum number of features which will be read from the s...
QVariant toVariant() const
Saves this source definition to a QVariantMap, wrapped in a QVariant.
QString filterExpression
Optional expression filter to use for filtering features which will be read from the source.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
Base class for providing feedback from a processing algorithm.
Base class for the definition of processing outputs.
A file output for processing algorithms.
A folder output for processing algorithms.
A HTML file output for processing algorithms.
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
bool operator!=(const QgsProcessingOutputLayerDefinition &other) const
QgsProject * destinationProject
Destination project.
bool operator==(const QgsProcessingOutputLayerDefinition &other) const
QgsProperty sink
Sink/layer definition.
bool useRemapping() const
Returns true if the output uses a remapping definition.
QgsRemappingSinkDefinition remappingDefinition() const
Returns the output remapping definition, if useRemapping() is true.
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
QString destinationName
Name to use for sink if it's to be loaded into a destination project.
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
void setRemappingDefinition(const QgsRemappingSinkDefinition &definition)
Sets the remapping definition to use when adding features to the output layer.
A pointcloud layer output for processing algorithms.
A raster layer output for processing algorithms.
A vector layer output for processing algorithms.
A vector tile layer output for processing algorithms.
An annotation layer parameter for processing algorithms.
QgsProcessingParameterAnnotationLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAnnotationLayer.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterAnnotationLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
static QString typeName()
Returns the type name for the parameter class.
A string parameter for authentication configuration ID values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterAuthConfig(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAuthConfig.
static QString typeName()
Returns the type name for the parameter class.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterAuthConfig * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
A raster band parameter for Processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple band selections are permitted.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
QgsProcessingParameterBand(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false, bool allowMultiple=false)
Constructor for QgsProcessingParameterBand.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterBand * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
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.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterBoolean * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterBoolean(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterBoolean.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
A color parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterColor * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
void setOpacityEnabled(bool enabled)
Sets whether the parameter allows opacity control.
QgsProcessingParameterColor(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool opacityEnabled=true, bool optional=false)
Constructor for QgsProcessingParameterColor.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterCoordinateOperation * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterCoordinateOperation(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &sourceCrsParameterName=QString(), const QString &destinationCrsParameterName=QString(), const QVariant &staticSourceCrs=QVariant(), const QVariant &staticDestinationCrs=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCoordinateOperation.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A coordinate reference system parameter for processing algorithms.
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterCrs * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterDatabaseSchema(const QString &name, const QString &description, const QString &connectionParameterName=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterDatabaseSchema.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterDatabaseSchema * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A database table name parameter for processing algorithms, allowing users to select from existing dat...
QgsProcessingParameterDatabaseTable(const QString &name, const QString &description, const QString &connectionParameterName=QString(), const QString &schemaParameterName=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool allowNewTableNames=false)
Constructor for QgsProcessingParameterDatabaseTable.
void setParentSchemaParameterName(const QString &name)
Sets the name of the parent schema parameter.
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.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterDatabaseTable * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
void setAllowNewTableNames(bool allowed)
Sets whether the parameter allows users to enter names for a new (non-existing) tables.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
A datetime (or pure date or time) parameter for processing algorithms.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setMaximum(const QDateTime &maximum)
Sets the maximum value acceptable by the parameter.
static QgsProcessingParameterDateTime * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QDateTime minimum() const
Returns the minimum value acceptable by the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
void setDataType(Qgis::ProcessingDateTimeParameterDataType type)
Sets the acceptable data type for the parameter.
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
void setMinimum(const QDateTime &minimum)
Sets the minimum value acceptable by the parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QDateTime maximum() const
Returns the maximum value acceptable by the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDateTime(const QString &name, const QString &description=QString(), Qgis::ProcessingDateTimeParameterDataType type=Qgis::ProcessingDateTimeParameterDataType::DateTime, const QVariant &defaultValue=QVariant(), bool optional=false, const QDateTime &minValue=QDateTime(), const QDateTime &maxValue=QDateTime())
Constructor for QgsProcessingParameterDateTime.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Base class for the definition of processing parameters.
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
QString mHelp
Parameter help.
virtual QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QVariant defaultValue() const
Returns the default value for the parameter.
QVariant guiDefaultValueOverride() const
Returns the default value to use in the GUI for the parameter.
QString valueAsStringPrivate(const QVariant &value, QgsProcessingContext &context, bool &ok, ValueAsStringFlags flags) const
Internal method for evaluating values as string.
QString help() const
Returns the help for the parameter.
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Processing script.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
Qgis::ProcessingParameterFlags mFlags
Parameter flags.
virtual QStringList valueAsStringList(const QVariant &value, QgsProcessingContext &context, bool &ok) const
Returns a string list version of the parameter input value (if possible).
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
@ AllowMapLayerValues
Enable map layer value handling.
QString mName
Parameter name.
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &help=QString())
Constructor for QgsProcessingParameterDefinition.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
virtual QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const
Returns a string version of the parameter input value (if possible).
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
QString mDescription
Parameter description.
virtual QString type() const =0
Unique parameter type name.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
QString name() const
Returns the name of the parameter.
QVariant mDefault
Default value for parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
QVariant mGuiDefault
Default value for parameter in GUI.
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
QVariant defaultGuiValueFromSetting() const
Default gui value for an algorithm parameter from settings.
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
virtual QString valueAsPythonComment(const QVariant &value, QgsProcessingContext &context) const
Returns a Python comment explaining a parameter value, or an empty string if no comment is required.
QVariant valueAsJsonObjectPrivate(const QVariant &value, QgsProcessingContext &context, ValueAsStringFlags flags) const
Internal method for evaluating values as JSON objects.
A double numeric parameter for distance values.
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
QString type() const override
Unique parameter type name.
QgsProcessingParameterDistance(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentParameterName=QString(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDistance.
A double numeric parameter for duration values.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDuration * clone() const override
Creates a clone of the parameter definition.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
QgsProcessingParameterDuration(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDuration.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
void setUsesStaticStrings(bool usesStaticStrings)
Sets whether the parameter uses static (non-translated) string values for its enumeration choice list...
static QgsProcessingParameterEnum * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
QgsProcessingParameterEnum(const QString &name, const QString &description=QString(), const QStringList &options=QStringList(), bool allowMultiple=false, const QVariant &defaultValue=QVariant(), bool optional=false, bool usesStaticStrings=false)
Constructor for QgsProcessingParameterEnum.
void setOptions(const QStringList &options)
Sets the list of acceptable options for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
QString valueAsPythonComment(const QVariant &value, QgsProcessingContext &context) const override
Returns a Python comment explaining a parameter value, or an empty string if no comment is required.
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
An expression parameter for processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterExpression * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false, Qgis::ExpressionType type=Qgis::ExpressionType::Qgis)
Constructor for QgsProcessingParameterExpression.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
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.
void setExpressionType(Qgis::ExpressionType type)
Sets the parameter's expression type.
A rectangular map extent parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterExtent(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterExtent.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterExtent * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
A feature sink output for processing algorithms.
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), Qgis::ProcessingSourceType type=Qgis::ProcessingSourceType::VectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true, bool supportsAppend=false)
Constructor for QgsProcessingParameterFeatureSink.
QString generateTemporaryDestination(const QgsProcessingContext *context=nullptr) const override
Generates a temporary destination value for this parameter.
static QgsProcessingParameterFeatureSink * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool hasGeometry() const
Returns true if sink is likely to include geometries.
QString type() const override
Unique parameter type name.
void setDataType(Qgis::ProcessingSourceType type)
Sets the layer type for the sinks associated with the parameter.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
void setSupportsAppend(bool supportsAppend)
Sets whether the sink supports appending features to an existing table.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
bool supportsAppend() const
Returns true if the sink supports appending features to an existing table.
Qgis::ProcessingSourceType dataType() const
Returns the layer type for sinks associated with the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
An input feature source (such as vector layers) parameter for processing algorithms.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterFeatureSource(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSource.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterFeatureSource * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
A vector layer or feature source field parameter for processing algorithms.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
QgsProcessingParameterField(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), Qgis::ProcessingFieldParameterDataType type=Qgis::ProcessingFieldParameterDataType::Any, bool allowMultiple=false, bool optional=false, bool defaultToAllFields=false)
Constructor for QgsProcessingParameterField.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
void setDefaultToAllFields(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterField * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
static QgsProcessingParameterFileDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterFileDestination(const QString &name, const QString &description=QString(), const QString &fileFilter=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFileDestination.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
void setExtension(const QString &extension)
Sets a file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Qgis::ProcessingFileParameterBehavior behavior=Qgis::ProcessingFileParameterBehavior::File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &fileFilter=QString())
Constructor for QgsProcessingParameterFile.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
static QgsProcessingParameterFile * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition, Qgis::ProcessingFileParameterBehavior behavior=Qgis::ProcessingFileParameterBehavior::File)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
static QgsProcessingParameterFolderDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterFolderDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFolderDestination.
A geometry parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString type() const override
Unique parameter type name.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterGeometry(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &geometryTypes=QList< int >(), bool allowMultipart=true)
Constructor for QgsProcessingParameterGeometry.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterGeometry * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
A print layout item parameter, allowing users to select a particular item from a print layout.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterLayoutItem * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterLayoutItem(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayoutParameterName=QString(), int itemType=-1, bool optional=false)
Constructor for QgsProcessingParameterLayoutItem.
void setParentLayoutParameterName(const QString &name)
Sets the name of the parent layout parameter.
QString parentLayoutParameterName() const
Returns the name of the parent layout parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
void setItemType(int type)
Sets the acceptable item type, or -1 if any item type is allowed.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A print layout parameter, allowing users to select a print layout.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterLayout * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterLayout(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterLayout.
static QString typeName()
Returns the type name for the parameter class.
Can be inherited by parameters which require limits to their acceptable data types.
void setDataTypes(const QList< int > &types)
Sets the geometry types for sources acceptable by the parameter.
QgsProcessingParameterLimitedDataTypes(const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data types.
QList< int > mDataTypes
List of acceptable data types for the parameter.
QList< int > dataTypes() const
Returns the geometry types for sources acceptable by the parameter.
A map layer parameter for processing algorithms.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterMapLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString type() const override
Unique parameter type name.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterMapLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterMapLayer.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
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 ...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterMapTheme * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterMapTheme(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMapTheme.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A table (matrix) parameter for processing algorithms.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QStringList headers() const
Returns a list of column headers (if set).
void setHeaders(const QStringList &headers)
Sets the list of column headers.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
void setHasFixedNumberRows(bool hasFixedNumberRows)
Sets whether the table has a fixed number of rows.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
void setNumberRows(int rows)
Sets the fixed number of rows in the table.
int numberRows() const
Returns the fixed number of rows in the table.
static QgsProcessingParameterMatrix * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterMatrix(const QString &name, const QString &description=QString(), int numberRows=3, bool hasFixedNumberRows=false, const QStringList &headers=QStringList(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMatrix.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
A mesh layer parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterMeshLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Qgis::ProcessingSourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
void setLayerType(Qgis::ProcessingSourceType type)
Sets the layer type for layers acceptable by the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), Qgis::ProcessingSourceType layerType=Qgis::ProcessingSourceType::VectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterMultipleLayers * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString type() const override
Unique parameter type name.
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
static QgsProcessingParameterNumber * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
void setMaximum(double maximum)
Sets the maximum value acceptable by the parameter.
double maximum() const
Returns the maximum value acceptable by the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Qgis::ProcessingNumberParameterType type=Qgis::ProcessingNumberParameterType::Integer, const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterNumber.
void setDataType(Qgis::ProcessingNumberParameterType type)
Sets the acceptable data type for the parameter.
A point cloud layer attribute parameter for Processing algorithms.
QgsProcessingParameterPointCloudAttribute(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool allowMultiple=false, bool optional=false, bool defaultToAllAttributes=false)
Constructor for QgsProcessingParameterField.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setDefaultToAllAttributes(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QgsProcessingParameterPointCloudAttribute * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
A point cloud layer destination parameter, for specifying the destination path for a point cloud laye...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterPointCloudDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
virtual QStringList supportedOutputPointCloudLayerExtensions() const
Returns a list of the point cloud format file extensions supported for this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterPointCloudDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterPointCloudDestination.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
A point cloud layer parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
static QgsProcessingParameterPointCloudLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterPointCloudLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPointCloudLayer.
A point parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterPoint * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterPoint(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPoint.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
A data provider connection parameter for processing algorithms, allowing users to select from availab...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterProviderConnection(const QString &name, const QString &description, const QString &provider, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterProviderConnection, for the specified provider type.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterProviderConnection * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A numeric range parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), Qgis::ProcessingNumberParameterType type=Qgis::ProcessingNumberParameterType::Integer, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRange.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setDataType(Qgis::ProcessingNumberParameterType dataType)
Sets the acceptable data type for the range.
static QgsProcessingParameterRange * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterRasterDestination.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter.
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
A raster layer parameter for processing algorithms.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterRasterLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterLayer.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
A double numeric parameter for map scale values.
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterScale * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterScale * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterScale(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterScale.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setMultiLine(bool multiLine)
Sets whether the parameter allows multiline strings.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterString * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool multiLine() const
Returns true if the parameter allows multiline strings.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Makes metadata of processing parameters available.
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
QgsProcessingParameterVectorDestination(const QString &name, const QString &description=QString(), Qgis::ProcessingSourceType type=Qgis::ProcessingSourceType::VectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorDestination.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString type() const override
Unique parameter type name.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Qgis::ProcessingSourceType dataType() const
Returns the layer type for this created vector layer.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
void setDataType(Qgis::ProcessingSourceType type)
Sets the layer type for the created vector layer.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterVectorDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A vector layer (with or without geometry) parameter for processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterVectorLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessingParameterVectorLayer(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorLayer.
static QString typeName()
Returns the type name for the parameter class.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
A vector tile layer destination parameter, for specifying the destination path for a vector tile laye...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterVectorTileDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorTileDestination.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
virtual QStringList supportedOutputVectorTileLayerExtensions() const
Returns a list of the point cloud format file extensions supported for this parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterVectorTileDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
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 QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
static QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, Qgis::WkbType geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList())
Evaluates the parameter with matching definition to a feature sink.
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 QgsProcessingParameterDefinition * parameterFromVariantMap(const QVariantMap &map)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map.
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 QgsCoordinateReferenceSystem parameterAsGeometryCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with a geometry parameter value.
static QgsAnnotationLayer * parameterAsAnnotationLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to an annotation layer.
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 QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
static bool parameterAsBoolean(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
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 QString parameterAsCompatibleSourceLayerPathAndLayerName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr, QString *layerName=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path and layer name of...
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
static QString parameterAsCompatibleSourceLayerPath(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path of compatible for...
static QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
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 QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a map layer.
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 QgsGeometry parameterAsExtentGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry cove...
static QStringList parameterAsFileList(const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultip...
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
static Q_DECL_DEPRECATED QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
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 QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
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.
Abstract base class for processing providers.
virtual bool isSupportedOutputValue(const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error) const
Returns true if the specified outputValue is of a supported file format for the given destination par...
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
static QString defaultVectorExtension()
Returns the default vector extension to use, in the absence of all other constraints (e....
static QString generateTempFilename(const QString &basename, const QgsProcessingContext *context=nullptr)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri()
LayerHint
Layer type hints.
@ Annotation
Annotation layer type, since QGIS 3.22.
@ Vector
Vector layer type.
@ VectorTile
Vector tile layer type, since QGIS 3.32.
@ Mesh
Mesh layer type, since QGIS 3.6.
@ Raster
Raster layer type.
@ UnknownType
Unknown layer type.
@ PointCloud
Point cloud layer type, since QGIS 3.22.
static QString layerToStringIdentifier(const QgsMapLayer *layer)
Returns a string representation of the source for a layer.
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
static QString variantToPythonLiteral(const QVariant &value)
Converts a variant to a Python literal.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QString convertToCompatibleFormatAndLayerName(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, QString &layerName, long long featureLimit=-1, const QString &filterExpression=QString())
Converts a source vector layer to a file path and layer name of a vector layer of compatible format.
static QString convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long long featureLimit=-1, const QString &filterExpression=QString())
Converts a source vector layer to a file path of a vector layer of compatible format.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, Qgis::WkbType geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
static QString defaultVectorTileExtension()
Returns the default vector tile extension to use, in the absence of all other constraints (e....
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.
static QString defaultPointCloudExtension()
Returns the default point cloud extension to use, in the absence of all other constraints (e....
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file.
PythonOutputType
Available Python output types.
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
static QString sourceTypeToString(Qgis::ProcessingSourceType type)
Converts a source type to a string representation.
@ 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,...
QgsAnnotationLayer * mainAnnotationLayer()
Returns the main annotation layer associated with the project.
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
A store for object properties.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QString expressionString() const
Returns the expression used for the property value.
Qgis::PropertyType propertyType() const
Returns the property type.
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
QString field() const
Returns the current field name the property references.
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
QVariant staticValue() const
Returns the current static value for the property.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString fileVectorFilters() const
Returns a file filter string for supported vector files.
QString fileRasterFilters() const
Returns a file filter string for supported raster files.
QString fileMeshFilters() const
Returns a file filter string for supported mesh files.
QString filePointCloudFilters() const
Returns a file filter string for supported point clouds.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
Represents a raster layer.
A rectangle specified with double values.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
bool isNull() const
Test if the rectangle is null (holding no spatial information).
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
A QgsGeometry with associated coordinate reference system.
static QgsReferencedGeometry fromReferencedPointXY(const QgsReferencedPointXY &point)
Construct a new QgsReferencedGeometry from referenced point.
static QgsReferencedGeometry fromReferencedRect(const QgsReferencedRectangle &rectangle)
Construct a new QgsReferencedGeometry from referenced rectangle.
A QgsPointXY with associated coordinate reference system.
A QgsRectangle with associated coordinate reference system.
Defines the parameters used to remap features when creating a QgsRemappingProxyFeatureSink.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
static QColor parseColorWithAlpha(const QString &colorStr, bool &containsAlpha, bool strictEval=false)
Attempts to parse a string as a color using a variety of common formats, including hex codes,...
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
Represents a vector layer which manages a vector based data sets.
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.
#define QgsDebugError(str)
QString parameterAsCompatibleSourceLayerPathInternal(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName)
QString createAllMapLayerFileFilter()
const QgsCoordinateReferenceSystem & crs