41#include <QRegularExpression>
49 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
50 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
51 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
59 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
60 flags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ), 0 ).toInt() );
73 mRemappingDefinition = definition;
80 map.insert( QStringLiteral(
"create_options" ),
createOptions );
82 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
89 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
90 if ( map.contains( QStringLiteral(
"remapping" ) ) )
97 mUseRemapping =
false;
105 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
110 return !( *
this == other );
115 const QVariant val = parameters.value( name );
116 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
135 QVariant val = value;
136 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
139 if ( !val.isValid() )
148 return destParam->generateTemporaryDestination();
151 return val.toString();
167 const QVariant val = value;
168 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
171 if ( val.isValid() && !val.toString().isEmpty() )
175 return val.toString();
195 QVariant val = value;
196 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
200 const double res = val.toDouble( &ok );
206 return val.toDouble();
222 QVariant val = value;
223 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
227 double dbl = val.toDouble( &ok );
232 dbl = val.toDouble( &ok );
239 const double round = std::round( dbl );
240 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
245 return static_cast< int >( std::round( dbl ) );
254 return QList< int >();
262 return QList< int >();
264 QList< int > resultList;
265 const QVariant val = value;
268 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
270 else if ( val.type() == QVariant::List )
272 const QVariantList list = val.toList();
273 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
274 resultList << it->toInt();
278 const QStringList parts = val.toString().split(
';' );
279 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
280 resultList << it->toInt();
284 if ( resultList.isEmpty() )
289 if ( definition->
defaultValue().type() == QVariant::List )
291 const QVariantList list = definition->
defaultValue().toList();
292 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
293 resultList << it->toInt();
297 const QStringList parts = definition->
defaultValue().toString().split(
';' );
298 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
299 resultList << it->toInt();
320 QVariant val = value;
321 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
324 QDateTime d = val.toDateTime();
325 if ( !d.isValid() && val.type() == QVariant::String )
327 d = QDateTime::fromString( val.toString() );
334 d = val.toDateTime();
336 if ( !d.isValid() && val.type() == QVariant::String )
338 d = QDateTime::fromString( val.toString() );
357 QVariant val = value;
358 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
361 QDate d = val.toDate();
362 if ( !d.isValid() && val.type() == QVariant::String )
364 d = QDate::fromString( val.toString() );
373 if ( !d.isValid() && val.type() == QVariant::String )
375 d = QDate::fromString( val.toString() );
394 QVariant val = value;
395 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
400 if ( val.type() == QVariant::DateTime )
401 d = val.toDateTime().time();
405 if ( !d.isValid() && val.type() == QVariant::String )
407 d = QTime::fromString( val.toString() );
416 if ( !d.isValid() && val.type() == QVariant::String )
418 d = QTime::fromString( val.toString() );
439 if ( enumDef && val >= enumDef->
options().size() )
459 QVariantList resultList;
460 const QVariant val = value;
461 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
463 else if ( val.type() == QVariant::List )
465 const auto constToList = val.toList();
466 for (
const QVariant &var : constToList )
469 else if ( val.type() == QVariant::String )
471 const auto constSplit = val.toString().split(
',' );
472 for (
const QString &var : constSplit )
478 if ( resultList.isEmpty() )
479 return QList< int >();
481 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
485 if ( definition->
defaultValue().type() == QVariant::List )
487 const auto constToList = definition->
defaultValue().toList();
488 for (
const QVariant &var : constToList )
491 else if ( definition->
defaultValue().type() == QVariant::String )
493 const auto constSplit = definition->
defaultValue().toString().split(
',' );
494 for (
const QString &var : constSplit )
503 const auto constResultList = resultList;
504 for (
const QVariant &var : constResultList )
506 const int resInt = var.toInt();
507 if ( !enumDef || resInt < enumDef->options().size() )
530 if ( enumText.isEmpty() || !enumDef->
options().contains( enumText ) )
539 return QStringList();
547 return QStringList();
549 const QVariant val = value;
551 QStringList enumValues;
553 std::function< void(
const QVariant &var ) > processVariant;
554 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
556 if ( var.type() == QVariant::List )
558 const auto constToList = var.toList();
559 for (
const QVariant &listVar : constToList )
561 processVariant( listVar );
564 else if ( var.type() == QVariant::StringList )
566 const auto constToStringList = var.toStringList();
567 for (
const QString &s : constToStringList )
572 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
576 const QStringList parts = var.toString().split(
',' );
577 for (
const QString &s : parts )
584 processVariant( val );
590 const QStringList options = enumDef->
options();
591 const QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
593 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
625 const QVariant val = value;
626 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
628 else if ( val.isValid() )
641 const QVariant val = value;
642 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
644 else if ( val.isValid() )
652 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
653 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
658 val = parameters.value( definition->
name() );
661 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
664QgsFeatureSink *
QgsProcessingParameters::parameterAsSink(
const QgsProcessingParameterDefinition *definition,
const QVariant &value,
const QgsFields &fields,
QgsWkbTypes::Type geometryType,
const QgsCoordinateReferenceSystem &
crs,
QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
666 QVariantMap options = createOptions;
667 QVariant val = value;
672 bool useRemapDefinition =
false;
673 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
684 useRemapDefinition =
true;
690 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
694 else if ( !val.isValid() || val.toString().isEmpty() )
710 dest = val.toString();
715 dest = destParam->generateTemporaryDestination();
718 if ( dest.isEmpty() )
721 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition : nullptr ) );
722 destinationIdentifier = dest;
724 if ( destinationProject )
726 if ( destName.isEmpty() && definition )
732 outputName = definition->
name();
736 return sink.release();
760 QVariant val = parameters.value( definition->
name() );
762 bool selectedFeaturesOnly =
false;
763 long long featureLimit = -1;
764 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
772 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
779 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
785 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
790 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
794 else if ( !val.isValid() || val.toString().isEmpty() )
800 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
806 layerRef = val.toString();
811 if ( layerRef.isEmpty() )
823 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit );
826 compatibleFormats, preferredFormat, context, feedback, featureLimit );
836 QString *destLayer = layerName;
851 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint );
859 QVariant val = value;
860 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
865 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
870 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
882 if ( !val.isValid() || val.toString().isEmpty() )
888 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
893 QString layerRef = val.toString();
894 if ( layerRef.isEmpty() )
897 if ( layerRef.isEmpty() )
928 val = parameters.value( definition->
name() );
935 QVariant val = value;
939 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
949 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
953 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
960 dest = val.toString();
965 dest = destParam->generateTemporaryDestination();
968 if ( destinationProject )
971 if ( destName.isEmpty() && definition )
976 outputName = definition->
name();
997 val = parameters.value( definition->
name() );
1004 QVariant val = value;
1006 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1014 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
1018 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1025 dest = val.toString();
1030 dest = destParam->generateTemporaryDestination();
1050 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1075 QVariant val = value;
1077 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1081 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1087 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1106 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1112 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1125 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1128 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1131 rectText = val.toString();
1133 if ( rectText.isEmpty() && !layer )
1136 const QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1137 const QRegularExpressionMatch match = rx.match( rectText );
1138 if ( match.hasMatch() )
1140 bool xMinOk =
false;
1141 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1142 bool xMaxOk =
false;
1143 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1144 bool yMinOk =
false;
1145 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1146 bool yMaxOk =
false;
1147 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1148 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1199 QVariant val = parameters.value( definition->
name() );
1201 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1207 g = g.densifyByCount( 20 );
1221 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1227 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1240 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1243 rectText = val.toString();
1245 if ( !rectText.isEmpty() )
1247 const QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1248 const QRegularExpressionMatch match = rx.match( rectText );
1249 if ( match.hasMatch() )
1251 bool xMinOk =
false;
1252 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1253 bool xMaxOk =
false;
1254 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1255 bool yMinOk =
false;
1256 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1257 bool yMaxOk =
false;
1258 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1259 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1285 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1314 const QVariant val = parameters.value( definition->
name() );
1320 QVariant val = value;
1321 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1330 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1336 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1348 QString valueAsString;
1349 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1352 valueAsString = val.toString();
1354 const QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1356 const QRegularExpressionMatch match = rx.match( valueAsString );
1357 if ( match.hasMatch() )
1364 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1370 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1383 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1384 return layer->crs();
1386 return layer->crs();
1388 if (
auto *lProject = context.
project() )
1389 return lProject->crs();
1407 const QVariant val = value;
1408 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1412 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1418 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1437 if ( pointText.isEmpty() )
1440 if ( pointText.isEmpty() )
1443 const QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1446 const QRegularExpressionMatch match = rx.match( valueAsString );
1447 if ( match.hasMatch() )
1450 const double x = match.captured( 1 ).toDouble( &xOk );
1452 const double y = match.captured( 2 ).toDouble( &yOk );
1480 const QVariant val = parameters.value( definition->
name() );
1486 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1495 const QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1498 const QRegularExpressionMatch match = rx.match( valueAsString );
1499 if ( match.hasMatch() )
1506 if (
auto *lProject = context.
project() )
1507 return lProject->crs();
1525 const QVariant val = value;
1526 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1531 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1536 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1541 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1559 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1565 g = g.densifyByCount( 20 );
1579 if ( val.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1598 if ( valueAsString.isEmpty() )
1601 if ( valueAsString.isEmpty() )
1604 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1606 const QRegularExpressionMatch match = rx.match( valueAsString );
1607 if ( match.hasMatch() )
1634 const QVariant val = parameters.value( definition->
name() );
1640 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1649 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1658 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1668 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1671 const QRegularExpressionMatch match = rx.match( valueAsString );
1672 if ( match.hasMatch() )
1679 if (
auto *lProject = context.
project() )
1680 return lProject->crs();
1691 if ( fileText.isEmpty() )
1702 if ( fileText.isEmpty() )
1710 return QVariantList();
1718 return QVariantList();
1720 QString resultString;
1721 const QVariant val = value;
1722 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1724 else if ( val.type() == QVariant::List )
1725 return val.toList();
1727 resultString = val.toString();
1729 if ( resultString.isEmpty() )
1732 if ( definition->
defaultValue().type() == QVariant::List )
1738 QVariantList result;
1739 const auto constSplit = resultString.split(
',' );
1742 for (
const QString &s : constSplit )
1744 number = s.toDouble( &ok );
1745 result << ( ok ? QVariant( number ) : s );
1754 return QList<QgsMapLayer *>();
1762 return QList<QgsMapLayer *>();
1764 const QVariant val = value;
1765 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1767 return QList<QgsMapLayer *>() << layer;
1770 QList<QgsMapLayer *> layers;
1772 std::function< void(
const QVariant &var ) > processVariant;
1773 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1775 if ( var.type() == QVariant::List )
1777 const auto constToList = var.toList();
1778 for (
const QVariant &listVar : constToList )
1780 processVariant( listVar );
1783 else if ( var.type() == QVariant::StringList )
1785 const auto constToStringList = var.toStringList();
1786 for (
const QString &s : constToStringList )
1788 processVariant( s );
1791 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1793 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1797 const QVariant sink = fromVar.
sink;
1798 if ( sink.userType() == QMetaType::type(
"QgsProperty" ) )
1803 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1815 processVariant( val );
1817 if ( layers.isEmpty() )
1820 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1824 else if ( definition->
defaultValue().type() == QVariant::List )
1826 const auto constToList = definition->
defaultValue().toList();
1827 for (
const QVariant &var : constToList )
1829 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1835 processVariant( var );
1849 return QStringList();
1851 const QVariant val = value;
1855 std::function< void(
const QVariant &var ) > processVariant;
1856 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1858 if ( var.type() == QVariant::List )
1860 const auto constToList = var.toList();
1861 for (
const QVariant &listVar : constToList )
1863 processVariant( listVar );
1866 else if ( var.type() == QVariant::StringList )
1868 const auto constToStringList = var.toStringList();
1869 for (
const QString &s : constToStringList )
1871 processVariant( s );
1874 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1878 files << var.toString();
1882 processVariant( val );
1884 if ( files.isEmpty() )
1895 return QStringList();
1903 return QList<double>();
1911 return QList<double>();
1913 QStringList resultStringList;
1914 const QVariant val = value;
1916 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1918 else if ( val.type() == QVariant::List )
1920 const auto constToList = val.toList();
1921 for (
const QVariant &var : constToList )
1922 resultStringList << var.toString();
1925 resultStringList << val.toString();
1927 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1929 resultStringList.clear();
1931 if ( definition->
defaultValue().type() == QVariant::List )
1933 const auto constToList = definition->
defaultValue().toList();
1934 for (
const QVariant &var : constToList )
1935 resultStringList << var.toString();
1938 resultStringList << definition->
defaultValue().toString();
1941 if ( resultStringList.size() == 1 )
1943 resultStringList = resultStringList.at( 0 ).split(
',' );
1946 if ( resultStringList.size() < 2 )
1947 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1949 QList< double > result;
1951 double n = resultStringList.at( 0 ).toDouble( &ok );
1955 result << std::numeric_limits<double>::quiet_NaN() ;
1957 n = resultStringList.at( 1 ).toDouble( &ok );
1961 result << std::numeric_limits<double>::quiet_NaN() ;
1969 return QStringList();
1971 const QStringList resultStringList;
1978 return QStringList();
1980 QStringList resultStringList;
1981 const QVariant val = value;
1982 if ( val.isValid() )
1984 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1986 else if ( val.type() == QVariant::List )
1988 const auto constToList = val.toList();
1989 for (
const QVariant &var : constToList )
1990 resultStringList << var.toString();
1992 else if ( val.type() == QVariant::StringList )
1994 resultStringList = val.toStringList();
1997 resultStringList.append( val.toString().split(
';' ) );
2000 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2002 resultStringList.clear();
2006 if ( definition->
defaultValue().type() == QVariant::List )
2008 const auto constToList = definition->
defaultValue().toList();
2009 for (
const QVariant &var : constToList )
2010 resultStringList << var.toString();
2012 else if ( definition->
defaultValue().type() == QVariant::StringList )
2014 resultStringList = definition->
defaultValue().toStringList();
2017 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2021 return resultStringList;
2035 if ( layoutName.isEmpty() )
2087 QVariant val = value;
2088 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2092 if ( val.type() == QVariant::Color )
2094 QColor
c = val.
value< QColor >();
2096 if ( !colorParam->opacityEnabled() )
2104 if ( definition->
defaultValue().type() == QVariant::Color )
2110 if ( colorText.isEmpty() )
2113 bool containsAlpha =
false;
2116 if (
c.isValid() && !colorParam->opacityEnabled() )
2188 const QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2189 const QString name = map.value( QStringLiteral(
"name" ) ).toString();
2190 std::unique_ptr< QgsProcessingParameterDefinition > def;
2263 def.reset( paramType->
create( name ) );
2269 def->fromVariantMap( map );
2270 return def.release();
2275 QString desc = name;
2276 desc.replace(
'_',
' ' );
2282 bool isOptional =
false;
2286 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2291 if ( type == QLatin1String(
"boolean" ) )
2293 else if ( type == QLatin1String(
"crs" ) )
2295 else if ( type == QLatin1String(
"layer" ) )
2297 else if ( type == QLatin1String(
"extent" ) )
2299 else if ( type == QLatin1String(
"point" ) )
2301 else if ( type == QLatin1String(
"geometry" ) )
2303 else if ( type == QLatin1String(
"file" ) )
2305 else if ( type == QLatin1String(
"folder" ) )
2307 else if ( type == QLatin1String(
"matrix" ) )
2309 else if ( type == QLatin1String(
"multiple" ) )
2311 else if ( type == QLatin1String(
"number" ) )
2313 else if ( type == QLatin1String(
"distance" ) )
2315 else if ( type == QLatin1String(
"duration" ) )
2317 else if ( type == QLatin1String(
"scale" ) )
2319 else if ( type == QLatin1String(
"range" ) )
2321 else if ( type == QLatin1String(
"raster" ) )
2323 else if ( type == QLatin1String(
"enum" ) )
2325 else if ( type == QLatin1String(
"string" ) )
2327 else if ( type == QLatin1String(
"authcfg" ) )
2329 else if ( type == QLatin1String(
"expression" ) )
2331 else if ( type == QLatin1String(
"field" ) )
2333 else if ( type == QLatin1String(
"vector" ) )
2335 else if ( type == QLatin1String(
"source" ) )
2337 else if ( type == QLatin1String(
"sink" ) )
2339 else if ( type == QLatin1String(
"vectordestination" ) )
2341 else if ( type == QLatin1String(
"rasterdestination" ) )
2343 else if ( type == QLatin1String(
"pointclouddestination" ) )
2345 else if ( type == QLatin1String(
"filedestination" ) )
2347 else if ( type == QLatin1String(
"folderdestination" ) )
2349 else if ( type == QLatin1String(
"band" ) )
2351 else if ( type == QLatin1String(
"mesh" ) )
2353 else if ( type == QLatin1String(
"layout" ) )
2355 else if ( type == QLatin1String(
"layoutitem" ) )
2357 else if ( type == QLatin1String(
"color" ) )
2359 else if ( type == QLatin1String(
"coordinateoperation" ) )
2361 else if ( type == QLatin1String(
"maptheme" ) )
2363 else if ( type == QLatin1String(
"datetime" ) )
2365 else if ( type == QLatin1String(
"providerconnection" ) )
2367 else if ( type == QLatin1String(
"databaseschema" ) )
2369 else if ( type == QLatin1String(
"databasetable" ) )
2371 else if ( type == QLatin1String(
"pointcloud" ) )
2373 else if ( type == QLatin1String(
"annotation" ) )
2379bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2381 const QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2382 QRegularExpressionMatch m = re.match( code );
2383 if ( !m.hasMatch() )
2386 name = m.captured( 1 );
2387 QString tokens = m.captured( 2 );
2388 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2391 tokens.remove( 0, 8 );
2398 tokens = tokens.trimmed();
2400 const QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2401 m = re2.match( tokens );
2402 if ( !m.hasMatch() )
2404 type = tokens.toLower().trimmed();
2409 type = m.captured( 1 ).toLower().trimmed();
2410 definition = m.captured( 2 );
2421 , mDescription( description )
2423 , mDefault( defaultValue )
2424 , mFlags( optional ? FlagOptional : 0 )
2429 if ( !input.isValid() && !
mDefault.isValid() )
2432 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2433 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2441 if ( !value.isValid() )
2442 return QStringLiteral(
"None" );
2444 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2445 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2457 if ( !value.isValid() )
2461 if ( value.type() == QVariant::Type::Map )
2463 const QVariantMap sourceMap = value.toMap();
2464 QVariantMap resultMap;
2465 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2471 else if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2473 const QVariantList sourceList = value.toList();
2474 QVariantList resultList;
2475 resultList.reserve( sourceList.size() );
2476 for (
const QVariant &v : sourceList )
2484 switch ( value.userType() )
2487 case QMetaType::Bool:
2488 case QMetaType::Char:
2489 case QMetaType::Int:
2490 case QMetaType::Double:
2491 case QMetaType::Float:
2492 case QMetaType::LongLong:
2493 case QMetaType::ULongLong:
2494 case QMetaType::UInt:
2495 case QMetaType::ULong:
2496 case QMetaType::UShort:
2504 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2517 QgsDebugMsg( QStringLiteral(
"could not convert expression/field based property to JSON object" ) );
2523 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2533 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2541 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2550 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2562 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2577 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2583 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2590 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2597 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2602 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2604 const QColor fromVar = value.value< QColor >();
2605 if ( !fromVar.isValid() )
2608 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2610 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2612 const QDateTime fromVar = value.toDateTime();
2613 if ( !fromVar.isValid() )
2616 return fromVar.toString( Qt::ISODate );
2618 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2620 const QDate fromVar = value.toDate();
2621 if ( !fromVar.isValid() )
2624 return fromVar.toString( Qt::ISODate );
2626 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2628 const QTime fromVar = value.toTime();
2629 if ( !fromVar.isValid() )
2632 return fromVar.toString( Qt::ISODate );
2639 p.insert(
name(), value );
2643 if ( !source.isEmpty() )
2650 if ( value.userType() == QMetaType::QString )
2655 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2668 if ( !value.isValid() )
2671 switch ( value.userType() )
2674 case QMetaType::Bool:
2675 case QMetaType::Char:
2676 case QMetaType::Int:
2677 case QMetaType::Double:
2678 case QMetaType::Float:
2679 case QMetaType::LongLong:
2680 case QMetaType::ULongLong:
2681 case QMetaType::UInt:
2682 case QMetaType::ULong:
2683 case QMetaType::UShort:
2684 return value.toString();
2690 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2703 QgsDebugMsg( QStringLiteral(
"could not convert expression/field based property to string" ) );
2709 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2719 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2727 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2735 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2747 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2762 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2768 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2775 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2780 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2785 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2787 const QColor fromVar = value.value< QColor >();
2788 if ( !fromVar.isValid() )
2791 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2793 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2795 const QDateTime fromVar = value.toDateTime();
2796 if ( !fromVar.isValid() )
2799 return fromVar.toString( Qt::ISODate );
2801 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2803 const QDate fromVar = value.toDate();
2804 if ( !fromVar.isValid() )
2807 return fromVar.toString( Qt::ISODate );
2809 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2811 const QTime fromVar = value.toTime();
2812 if ( !fromVar.isValid() )
2815 return fromVar.toString( Qt::ISODate );
2822 p.insert(
name(), value );
2826 if ( !source.isEmpty() )
2833 if ( value.userType() == QMetaType::QString )
2834 return value.toString();
2837 QgsDebugMsg( QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ) );
2839 return value.toString();
2845 if ( !value.isValid( ) )
2846 return QStringList();
2848 if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2850 const QVariantList sourceList = value.toList();
2851 QStringList resultList;
2852 resultList.reserve( sourceList.size() );
2853 for (
const QVariant &v : sourceList )
2862 return QStringList();
2874 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2876 code += QLatin1String(
"optional " );
2877 code +=
type() +
' ';
2879 return code.trimmed();
2887 switch ( outputType )
2891 QString code = t->className() + QStringLiteral(
"('%1', %2" )
2894 code += QLatin1String(
", optional=True" );
2910 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2911 map.insert( QStringLiteral(
"name" ),
mName );
2912 map.insert( QStringLiteral(
"description" ),
mDescription );
2913 map.insert( QStringLiteral(
"help" ),
mHelp );
2914 map.insert( QStringLiteral(
"default" ),
mDefault );
2915 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2916 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2917 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2923 mName = map.value( QStringLiteral(
"name" ) ).toString();
2924 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2925 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2926 mDefault = map.value( QStringLiteral(
"default" ) );
2927 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2928 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2929 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2945 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
2946 if ( !
help().isEmpty() )
2948 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
2950 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
2965 if ( !val.isValid() )
2966 return QStringLiteral(
"None" );
2968 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2970 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
2975 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2977 code += QLatin1String(
"optional " );
2978 code +=
type() +
' ';
2979 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
2980 return code.trimmed();
3002 if ( !input.isValid() )
3010 if ( input.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3014 else if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3018 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3023 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3029 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3032 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3040 if ( !value.isValid() )
3041 return QStringLiteral(
"None" );
3043 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3046 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
3051 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3052 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3055 p.insert(
name(), value );
3094 if ( !input.isValid() )
3102 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3107 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3112 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3130 if ( !val.isValid() )
3131 return QStringLiteral(
"None" );
3133 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3137 p.insert(
name(), val );
3157 for (
const QString &raster : rasters )
3159 if ( !vectors.contains( raster ) )
3163 for (
const QString &mesh : meshFilters )
3165 if ( !vectors.contains( mesh ) )
3169 for (
const QString &pointCloud : pointCloudFilters )
3171 if ( !vectors.contains( pointCloud ) )
3172 vectors << pointCloud;
3174 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3175 std::sort( vectors.begin(), vectors.end() );
3177 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3187 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3189 code += QLatin1String(
"optional " );
3190 code += QLatin1String(
"layer " );
3197 code += QLatin1String(
"hasgeometry " );
3201 code += QLatin1String(
"point " );
3205 code += QLatin1String(
"line " );
3209 code += QLatin1String(
"polygon " );
3213 code += QLatin1String(
"raster " );
3217 code += QLatin1String(
"mesh " );
3221 code += QLatin1String(
"plugin " );
3225 code += QLatin1String(
"pointcloud " );
3229 code += QLatin1String(
"annotation " );
3235 return code.trimmed();
3241 QString def = definition;
3244 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3247 def = def.mid( 12 );
3250 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3256 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3262 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3268 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3274 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3280 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3286 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3289 def = def.mid( 11 );
3292 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3295 def = def.mid( 11 );
3306 switch ( outputType )
3310 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3313 code += QLatin1String(
", optional=True" );
3320 QStringList options;
3324 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3328 code += QLatin1Char(
')' );
3345 map.insert( QStringLiteral(
"data_types" ), types );
3353 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3354 for (
const QVariant &val : values )
3375 if ( !input.isValid() )
3383 if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3387 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3392 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3397 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3402 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3406 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3413 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3416 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3425 const QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3426 const QRegularExpressionMatch match = rx.match( input.toString() );
3427 if ( match.hasMatch() )
3429 bool xMinOk =
false;
3430 ( void )match.captured( 1 ).toDouble( &xMinOk );
3431 bool xMaxOk =
false;
3432 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3433 bool yMinOk =
false;
3434 ( void )match.captured( 3 ).toDouble( &yMinOk );
3435 bool yMaxOk =
false;
3436 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3437 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3447 if ( !value.isValid() )
3448 return QStringLiteral(
"None" );
3450 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3451 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3453 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3461 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3469 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3474 const QString wkt = g.
asWkt();
3475 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3480 p.insert(
name(), value );
3517 if ( !input.isValid() )
3525 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3530 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3534 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3538 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3543 if ( input.type() == QVariant::String )
3545 if ( input.toString().isEmpty() )
3549 const QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3551 const QRegularExpressionMatch match = rx.match( input.toString() );
3552 if ( match.hasMatch() )
3555 ( void )match.captured( 1 ).toDouble( &xOk );
3557 ( void )match.captured( 2 ).toDouble( &yOk );
3566 if ( !value.isValid() )
3567 return QStringLiteral(
"None" );
3569 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3570 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3572 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3578 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3585 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3590 const QString wkt = g.
asWkt();
3591 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3604 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3606 mGeomTypes( geometryTypes ),
3607 mAllowMultipart( allowMultipart )
3620 if ( !input.isValid() )
3628 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3635 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3637 return ( anyTypeAllowed || mGeomTypes.contains( input.value<
QgsGeometry>().
type() ) ) &&
3638 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3641 if ( input.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3647 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3652 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3657 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3662 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3667 if ( input.type() == QVariant::String )
3669 if ( input.toString().isEmpty() )
3674 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3676 const QRegularExpressionMatch match = rx.match( input.toString() );
3677 if ( match.hasMatch() )
3682 return ( anyTypeAllowed || mGeomTypes.contains( g.
type() ) ) && ( mAllowMultipart || !g.
isMultipart() );
3702 if ( !value.isValid() )
3703 return QStringLiteral(
"None" );
3705 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3708 if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3715 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3722 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3729 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3736 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3743 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3755 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3757 code += QLatin1String(
"optional " );
3758 code +=
type() +
' ';
3760 for (
const int type : mGeomTypes )
3765 code += QLatin1String(
"point " );
3769 code += QLatin1String(
"line " );
3773 code += QLatin1String(
"polygon " );
3777 code += QLatin1String(
"unknown " );
3783 return code.trimmed();
3788 switch ( outputType )
3792 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3795 code += QLatin1String(
", optional=True" );
3797 if ( !mGeomTypes.empty() )
3804 return QStringLiteral(
"PointGeometry" );
3807 return QStringLiteral(
"LineGeometry" );
3810 return QStringLiteral(
"PolygonGeometry" );
3813 return QStringLiteral(
"UnknownGeometry" );
3816 return QStringLiteral(
"NullGeometry" );
3821 QStringList options;
3822 options.reserve( mGeomTypes.size() );
3823 for (
const int type : mGeomTypes )
3827 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3830 if ( ! mAllowMultipart )
3832 code += QLatin1String(
", allowMultipart=False" );
3847 for (
const int type : mGeomTypes )
3851 map.insert( QStringLiteral(
"geometrytypes" ), types );
3852 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3860 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3861 for (
const QVariant &val : values )
3863 mGeomTypes << val.toInt();
3865 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
3876 , mBehavior( behavior )
3877 , mExtension( fileFilter.isEmpty() ? extension : QString() )
3878 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3891 if ( !input.isValid() )
3899 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3904 const QString
string = input.toString().trimmed();
3906 if ( input.type() != QVariant::String ||
string.isEmpty() )
3909 switch ( mBehavior )
3913 if ( !mExtension.isEmpty() )
3915 return string.endsWith( mExtension, Qt::CaseInsensitive );
3917 else if ( !mFileFilter.isEmpty() )
3935 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3937 code += QLatin1String(
"optional " );
3938 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
3940 return code.trimmed();
3945 switch ( outputType )
3950 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
3953 code += QLatin1String(
", optional=True" );
3954 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
3955 if ( !mExtension.isEmpty() )
3956 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
3957 if ( !mFileFilter.isEmpty() )
3958 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
3969 switch ( mBehavior )
3973 if ( !mFileFilter.isEmpty() )
3974 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
3975 else if ( !mExtension.isEmpty() )
3976 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
3978 return QObject::tr(
"All files (*.*)" );
3990 mFileFilter.clear();
4000 mFileFilter = filter;
4007 map.insert( QStringLiteral(
"behavior" ), mBehavior );
4008 map.insert( QStringLiteral(
"extension" ), mExtension );
4009 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
4016 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
4017 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
4018 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
4029 , mHeaders( headers )
4030 , mNumberRows( numberRows )
4031 , mFixedNumberRows( fixedNumberRows )
4044 if ( !input.isValid() )
4052 if ( input.type() == QVariant::String )
4054 if ( input.toString().isEmpty() )
4058 else if ( input.type() == QVariant::List )
4060 if ( input.toList().isEmpty() )
4064 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
4074 if ( !value.isValid() )
4075 return QStringLiteral(
"None" );
4077 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4078 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4081 p.insert(
name(), value );
4089 switch ( outputType )
4093 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4096 code += QLatin1String(
", optional=True" );
4097 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4098 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4101 headers.reserve( mHeaders.size() );
4102 for (
const QString &h : mHeaders )
4104 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4136 return mFixedNumberRows;
4141 mFixedNumberRows = fixedNumberRows;
4147 map.insert( QStringLiteral(
"headers" ), mHeaders );
4148 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4149 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4156 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4157 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4158 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4169 , mLayerType( layerType )
4182 if ( !input.isValid() )
4192 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4198 if ( input.type() == QVariant::String )
4200 if ( input.toString().isEmpty() )
4203 if ( mMinimumNumberInputs > 1 )
4214 else if ( input.type() == QVariant::List )
4216 if ( input.toList().count() < mMinimumNumberInputs )
4219 if ( mMinimumNumberInputs > input.toList().count() )
4227 const auto constToList = input.toList();
4228 for (
const QVariant &v : constToList )
4230 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4239 else if ( input.type() == QVariant::StringList )
4241 if ( input.toStringList().count() < mMinimumNumberInputs )
4244 if ( mMinimumNumberInputs > input.toStringList().count() )
4252 const auto constToStringList = input.toStringList();
4253 for (
const QString &v : constToStringList )
4266 if ( !value.isValid() )
4267 return QStringLiteral(
"None" );
4269 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4270 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4275 if ( value.type() == QVariant::StringList )
4277 const QStringList list = value.toStringList();
4278 parts.reserve( list.count() );
4279 for (
const QString &v : list )
4282 else if ( value.type() == QVariant::List )
4284 const QVariantList list = value.toList();
4285 parts.reserve( list.count() );
4286 for (
const QVariant &v : list )
4289 if ( !parts.isEmpty() )
4290 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4295 p.insert(
name(), value );
4297 if ( !list.isEmpty() )
4300 parts.reserve( list.count() );
4305 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4324 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4326 code += QLatin1String(
"optional " );
4327 switch ( mLayerType )
4330 code += QLatin1String(
"multiple raster" );
4334 code += QLatin1String(
"multiple file" );
4338 code += QLatin1String(
"multiple vector" );
4342 if (
mDefault.type() == QVariant::List )
4345 const auto constToList =
mDefault.toList();
4346 for (
const QVariant &var : constToList )
4348 parts << var.toString();
4350 code += parts.join(
',' );
4352 else if (
mDefault.type() == QVariant::StringList )
4354 code +=
mDefault.toStringList().join(
',' );
4360 return code.trimmed();
4365 switch ( outputType )
4369 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4372 code += QLatin1String(
", optional=True" );
4376 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4387 const QStringList exts;
4388 switch ( mLayerType )
4391 return QObject::tr(
"All files (*.*)" );
4429 return mMinimumNumberInputs;
4441 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
4442 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4450 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4456 QString
type = definition;
4458 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4459 const QRegularExpressionMatch m = re.match( definition );
4462 type = m.captured( 1 ).toLower().trimmed();
4463 defaultVal = m.captured( 2 );
4466 if (
type == QLatin1String(
"vector" ) )
4468 else if (
type == QLatin1String(
"raster" ) )
4470 else if (
type == QLatin1String(
"file" ) )
4483 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4494 QVariant input = value;
4495 if ( !input.isValid() )
4503 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4509 const double res = input.toDouble( &ok );
4513 return !( res < mMin || res > mMax );
4518 if ( !value.isValid() )
4519 return QStringLiteral(
"None" );
4521 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4522 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4524 return value.toString();
4531 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4532 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4533 if ( mMax < std::numeric_limits<double>::max() )
4534 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4536 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
4537 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4538 if ( !extra.isEmpty() )
4539 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4545 switch ( outputType )
4549 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4552 code += QLatin1String(
", optional=True" );
4554 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4556 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4557 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4558 if ( mMax != std::numeric_limits<double>::max() )
4559 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4601 map.insert( QStringLiteral(
"min" ), mMin );
4602 map.insert( QStringLiteral(
"max" ), mMax );
4603 map.insert( QStringLiteral(
"data_type" ), mDataType );
4610 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4611 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4612 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4619 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4637 if ( !input.isValid() )
4645 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4650 if ( input.type() == QVariant::String )
4652 const QStringList list = input.toString().split(
',' );
4653 if ( list.count() != 2 )
4656 list.at( 0 ).toDouble( &ok );
4658 list.at( 1 ).toDouble( &ok2 );
4663 else if ( input.type() == QVariant::List )
4665 if ( input.toList().count() != 2 )
4669 input.toList().at( 0 ).toDouble( &ok );
4671 input.toList().at( 1 ).toDouble( &ok2 );
4682 if ( !value.isValid() )
4683 return QStringLiteral(
"None" );
4685 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4686 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4689 p.insert(
name(), value );
4692 QStringList stringParts;
4693 const auto constParts = parts;
4694 for (
const double v : constParts )
4696 stringParts << QString::number( v );
4698 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4703 switch ( outputType )
4707 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4710 code += QLatin1String(
", optional=True" );
4712 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4735 map.insert( QStringLiteral(
"data_type" ), mDataType );
4749 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4766 if ( !input.isValid() )
4774 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4779 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4782 if ( input.type() != QVariant::String || input.toString().isEmpty() )
4800 if ( !val.isValid() )
4801 return QStringLiteral(
"None" );
4803 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
4807 p.insert(
name(), val );
4835 , mOptions( options )
4836 , mAllowMultiple( allowMultiple )
4837 , mUsesStaticStrings( usesStaticStrings )
4849 QVariant input = value;
4850 if ( !input.isValid() )
4858 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4863 if ( mUsesStaticStrings )
4865 if ( input.type() == QVariant::List )
4867 if ( !mAllowMultiple )
4870 const QVariantList values = input.toList();
4874 for (
const QVariant &val : values )
4876 if ( !mOptions.contains( val.toString() ) )
4882 else if ( input.type() == QVariant::StringList )
4884 if ( !mAllowMultiple )
4887 const QStringList values = input.toStringList();
4892 if ( values.count() > 1 && !mAllowMultiple )
4895 for (
const QString &val : values )
4897 if ( !mOptions.contains( val ) )
4902 else if ( input.type() == QVariant::String )
4904 const QStringList parts = input.toString().split(
',' );
4905 if ( parts.count() > 1 && !mAllowMultiple )
4908 const auto constParts = parts;
4909 for (
const QString &part : constParts )
4911 if ( !mOptions.contains( part ) )
4919 if ( input.type() == QVariant::List )
4921 if ( !mAllowMultiple )
4924 const QVariantList values = input.toList();
4928 for (
const QVariant &val : values )
4931 const int res = val.toInt( &ok );
4934 else if ( res < 0 || res >= mOptions.count() )
4940 else if ( input.type() == QVariant::String )
4942 const QStringList parts = input.toString().split(
',' );
4943 if ( parts.count() > 1 && !mAllowMultiple )
4946 const auto constParts = parts;
4947 for (
const QString &part : constParts )
4950 const int res = part.toInt( &ok );
4953 else if ( res < 0 || res >= mOptions.count() )
4958 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
4961 const int res = input.toInt( &ok );
4964 else if ( res >= 0 && res < mOptions.count() )
4974 if ( !value.isValid() )
4975 return QStringLiteral(
"None" );
4977 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4978 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4980 if ( mUsesStaticStrings )
4982 if ( value.type() == QVariant::List || value.type() == QVariant::StringList )
4985 const QStringList constList = value.toStringList();
4986 for (
const QString &val : constList )
4990 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4992 else if ( value.type() == QVariant::String )
4995 const QStringList constList = value.toString().split(
',' );
4996 if ( constList.count() > 1 )
4998 for (
const QString &val : constList )
5002 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5010 if ( value.type() == QVariant::List )
5013 const auto constToList = value.toList();
5014 for (
const QVariant &val : constToList )
5016 parts << QString::number( static_cast< int >( val.toDouble() ) );
5018 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5020 else if ( value.type() == QVariant::String )
5022 const QStringList parts = value.toString().split(
',' );
5023 if ( parts.count() > 1 )
5025 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5029 return QString::number(
static_cast< int >( value.toDouble() ) );
5035 if ( !value.isValid() )
5038 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5041 if ( mUsesStaticStrings )
5047 if ( value.type() == QVariant::List )
5050 const QVariantList toList = value.toList();
5051 parts.reserve( toList.size() );
5052 for (
const QVariant &val : toList )
5054 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5056 return parts.join(
',' );
5058 else if ( value.type() == QVariant::String )
5060 const QStringList parts = value.toString().split(
',' );
5061 QStringList comments;
5062 if ( parts.count() > 1 )
5064 for (
const QString &part : parts )
5067 const int val = part.toInt( &ok );
5069 comments << mOptions.value( val );
5071 return comments.join(
',' );
5075 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5081 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5083 code += QLatin1String(
"optional " );
5084 code += QLatin1String(
"enum " );
5086 if ( mAllowMultiple )
5087 code += QLatin1String(
"multiple " );
5089 if ( mUsesStaticStrings )
5090 code += QLatin1String(
"static " );
5092 code += mOptions.join(
';' ) +
' ';
5095 return code.trimmed();
5100 switch ( outputType )
5104 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5107 code += QLatin1String(
", optional=True" );
5110 options.reserve( mOptions.size() );
5111 for (
const QString &o : mOptions )
5113 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5115 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5117 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5140 return mAllowMultiple;
5150 return mUsesStaticStrings;
5161 map.insert( QStringLiteral(
"options" ), mOptions );
5162 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5163 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5170 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5171 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5172 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5179 QString def = definition;
5181 bool multiple =
false;
5182 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5188 bool staticStrings =
false;
5189 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5191 staticStrings =
true;
5195 const QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5196 const QRegularExpressionMatch m = re.match( def );
5197 QString values = def;
5200 values = m.captured( 1 ).trimmed();
5201 defaultVal = m.captured( 2 );
5209 , mMultiLine( multiLine )
5222 return QStringLiteral(
"None" );
5224 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5225 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5227 const QString s = value.toString();
5233 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5235 code += QLatin1String(
"optional " );
5236 code += QLatin1String(
"string " );
5239 code += QLatin1String(
"long " );
5242 return code.trimmed();
5247 switch ( outputType )
5251 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5254 code += QLatin1String(
", optional=True" );
5255 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5278 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5285 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5291 QString def = definition;
5293 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5299 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5301 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5305 if ( def == QLatin1String(
"None" ) )
5328 if ( !value.isValid() )
5329 return QStringLiteral(
"None" );
5331 const QString s = value.toString();
5337 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5339 code += QLatin1String(
"optional " );
5340 code += QLatin1String(
"authcfg " );
5343 return code.trimmed();
5348 QString def = definition;
5350 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5352 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5356 if ( def == QLatin1String(
"None" ) )
5369 , mParentLayerParameterName( parentLayerParameterName )
5381 if ( !value.isValid() )
5382 return QStringLiteral(
"None" );
5384 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5385 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5387 const QString s = value.toString();
5393 QStringList depends;
5394 if ( !mParentLayerParameterName.isEmpty() )
5395 depends << mParentLayerParameterName;
5401 switch ( outputType )
5405 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5408 code += QLatin1String(
", optional=True" );
5410 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5422 return mParentLayerParameterName;
5433 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5440 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5464 if ( !var.isValid() )
5472 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5485 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5488 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5506 if ( !val.isValid() )
5507 return QStringLiteral(
"None" );
5509 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5513 p.insert(
name(), val );
5531 switch ( outputType )
5535 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5538 code += QLatin1String(
", optional=True" );
5542 QStringList options;
5545 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5579 map.insert( QStringLiteral(
"data_types" ), types );
5587 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5588 for (
const QVariant &val : values )
5601 const QVariant &defaultValue,
bool optional )
5616 if ( !var.isValid() )
5624 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5637 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5640 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5658 if ( !val.isValid() )
5659 return QStringLiteral(
"None" );
5661 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5665 p.insert(
name(), val );
5693 , mParentLayerParameterName( parentLayerParameterName )
5695 , mAllowMultiple( allowMultiple )
5696 , mDefaultToAllFields( defaultToAllFields )
5710 if ( !input.isValid() )
5718 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
5723 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5725 if ( !mAllowMultiple )
5731 else if ( input.type() == QVariant::String )
5733 if ( input.toString().isEmpty() )
5736 const QStringList parts = input.toString().split(
';' );
5737 if ( parts.count() > 1 && !mAllowMultiple )
5742 if ( input.toString().isEmpty() )
5750 if ( !value.isValid() )
5751 return QStringLiteral(
"None" );
5753 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5754 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5756 if ( value.type() == QVariant::List )
5759 const auto constToList = value.toList();
5760 for (
const QVariant &val : constToList )
5764 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5766 else if ( value.type() == QVariant::StringList )
5769 const auto constToStringList = value.toStringList();
5770 for (
const QString &s : constToStringList )
5774 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5782 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5784 code += QLatin1String(
"optional " );
5785 code += QLatin1String(
"field " );
5787 switch ( mDataType )
5790 code += QLatin1String(
"numeric " );
5794 code += QLatin1String(
"string " );
5798 code += QLatin1String(
"datetime " );
5805 if ( mAllowMultiple )
5806 code += QLatin1String(
"multiple " );
5808 if ( mDefaultToAllFields )
5809 code += QLatin1String(
"default_to_all_fields " );
5811 code += mParentLayerParameterName +
' ';
5814 return code.trimmed();
5819 switch ( outputType )
5823 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
5826 code += QLatin1String(
", optional=True" );
5829 switch ( mDataType )
5832 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
5836 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
5840 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
5844 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
5847 code += QStringLiteral(
", type=%1" ).arg(
dataType );
5849 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5850 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5854 if ( mDefaultToAllFields )
5855 code += QLatin1String(
", defaultToAllFields=True" );
5867 QStringList depends;
5868 if ( !mParentLayerParameterName.isEmpty() )
5869 depends << mParentLayerParameterName;
5875 return mParentLayerParameterName;
5895 return mAllowMultiple;
5905 return mDefaultToAllFields;
5910 mDefaultToAllFields = enabled;
5916 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5917 map.insert( QStringLiteral(
"data_type" ), mDataType );
5918 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5919 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
5926 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5927 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
5928 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5929 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
5939 QString def = definition;
5941 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
5946 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
5951 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
5957 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5960 def = def.mid( 8 ).trimmed();
5963 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
5966 def = def.mid( 21 ).trimmed();
5969 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5970 const QRegularExpressionMatch m = re.match( def );
5973 parent = m.captured( 1 ).trimmed();
5974 def = m.captured( 2 );
5999 QVariant var = input;
6000 if ( !var.isValid() )
6008 if ( var.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6013 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6020 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6032 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6037 if ( var.type() != QVariant::String || var.toString().isEmpty() )
6055 if ( !value.isValid() )
6056 return QStringLiteral(
"None" );
6058 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6061 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6064 QString geometryCheckString;
6068 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
6072 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
6076 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6083 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6085 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6086 if ( !
flags.empty() )
6087 flagString =
flags.join( QLatin1String(
" | " ) );
6094 layerString = layer->source();
6101 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6102 geometryCheckString );
6113 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" )
6117 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6118 geometryCheckString );
6126 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6131 QString layerString = value.toString();
6135 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6152 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6154 code += QLatin1String(
"optional " );
6155 code += QLatin1String(
"source " );
6162 code += QLatin1String(
"point " );
6166 code += QLatin1String(
"line " );
6170 code += QLatin1String(
"polygon " );
6177 return code.trimmed();
6182 switch ( outputType )
6186 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6189 code += QLatin1String(
", optional=True" );
6193 QStringList options;
6197 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6214 : mDataTypes( types )
6227 map.insert( QStringLiteral(
"data_types" ), types );
6235 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6236 for (
const QVariant &val : values )
6246 QString def = definition;
6249 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6255 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6261 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6276 , mSupportsAppend( supportsAppend )
6287 QVariant var = input;
6288 if ( !var.isValid() )
6296 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6302 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6315 if ( var.type() != QVariant::String )
6318 if ( var.toString().isEmpty() )
6326 if ( !value.isValid() )
6327 return QStringLiteral(
"None" );
6329 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6330 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6332 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6341 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6350 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6352 code += QLatin1String(
"optional " );
6353 code += QLatin1String(
"sink " );
6355 switch ( mDataType )
6358 code += QLatin1String(
"point " );
6362 code += QLatin1String(
"line " );
6366 code += QLatin1String(
"polygon " );
6370 code += QLatin1String(
"table " );
6378 return code.trimmed();
6390 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6394 return p->defaultVectorFileExtension(
hasGeometry() );
6404 return QStringLiteral(
"dbf" );
6411 switch ( outputType )
6415 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6418 code += QLatin1String(
", optional=True" );
6422 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6423 if ( mSupportsAppend )
6424 code += QLatin1String(
", supportsAppend=True" );
6437 QStringList filters;
6438 for (
const QString &ext : exts )
6440 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6442 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6451 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6453 return lOriginalProvider->supportedOutputTableExtensions();
6458 return p->supportedOutputVectorLayerExtensions();
6460 return p->supportedOutputTableExtensions();
6475 switch ( mDataType )
6504 map.insert( QStringLiteral(
"data_type" ), mDataType );
6505 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6513 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6520 return QStringLiteral(
"memory:%1" ).arg(
description() );
6528 QString def = definition;
6529 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6534 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6539 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6544 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6555 return mSupportsAppend;
6575 QVariant var = input;
6576 if ( !var.isValid() )
6584 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6590 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6603 if ( var.type() != QVariant::String )
6606 if ( var.toString().isEmpty() )
6614 if ( !value.isValid() )
6615 return QStringLiteral(
"None" );
6617 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6618 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6620 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6629 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6645 return lOriginalProvider->defaultRasterFileExtension();
6649 return p->defaultRasterFileExtension();
6660 QStringList filters;
6661 for (
const QString &ext : exts )
6663 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6665 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6672 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6676 return p->supportedOutputRasterLayerExtensions();
6692 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6704 QVariant var = input;
6705 if ( !var.isValid() )
6713 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6719 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6732 if ( var.type() != QVariant::String )
6735 if ( var.toString().isEmpty() )
6745 if ( !value.isValid() )
6746 return QStringLiteral(
"None" );
6748 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6749 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6751 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6760 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6769 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6781 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6782 return QStringLiteral(
"file" );
6785 const QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6786 const QRegularExpressionMatch match = rx.match( mFileFilter );
6787 if ( !match.hasMatch() )
6788 return QStringLiteral(
"file" );
6790 return match.captured( 1 );
6795 switch ( outputType )
6799 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
6802 code += QLatin1String(
", optional=True" );
6806 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6818 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
6834 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
6841 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
6862 QVariant var = input;
6863 if ( !var.isValid() )
6871 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6884 if ( var.type() != QVariant::String )
6887 if ( var.toString().isEmpty() )
6910 , mCreateByDefault( createByDefault )
6918 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
6919 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
6926 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
6927 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
6933 switch ( outputType )
6940 QString code = t->className() + QStringLiteral(
"('%1', %2" )
6943 code += QLatin1String(
", optional=True" );
6945 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6960 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
6967 const QRegularExpression rx( QStringLiteral(
"[.]" ) );
6968 QString sanitizedName =
name();
6969 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
6984 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
6993 return mCreateByDefault;
7015 QVariant var = input;
7016 if ( !var.isValid() )
7024 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7030 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
7043 if ( var.type() != QVariant::String )
7046 if ( var.toString().isEmpty() )
7054 if ( !value.isValid() )
7055 return QStringLiteral(
"None" );
7057 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7058 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7060 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7069 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
7078 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7080 code += QLatin1String(
"optional " );
7081 code += QLatin1String(
"vectorDestination " );
7083 switch ( mDataType )
7086 code += QLatin1String(
"point " );
7090 code += QLatin1String(
"line " );
7094 code += QLatin1String(
"polygon " );
7102 return code.trimmed();
7114 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7118 return p->defaultVectorFileExtension(
hasGeometry() );
7128 return QStringLiteral(
"dbf" );
7135 switch ( outputType )
7139 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7142 code += QLatin1String(
", optional=True" );
7146 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7159 QStringList filters;
7160 for (
const QString &ext : exts )
7162 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7164 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7172 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7174 return lOriginalProvider->supportedOutputTableExtensions();
7179 return p->supportedOutputVectorLayerExtensions();
7181 return p->supportedOutputTableExtensions();
7196 switch ( mDataType )
7225 map.insert( QStringLiteral(
"data_type" ), mDataType );
7239 QString def = definition;
7240 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7245 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7250 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7261 , mParentLayerParameterName( parentLayerParameterName )
7262 , mAllowMultiple( allowMultiple )
7274 QVariant input = value;
7275 if ( !input.isValid() )
7283 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7288 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
7290 if ( !mAllowMultiple )
7299 const double res = input.toInt( &ok );
7309 return mAllowMultiple;
7319 if ( !value.isValid() )
7320 return QStringLiteral(
"None" );
7322 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7323 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7325 if ( value.type() == QVariant::List )
7328 const QVariantList values = value.toList();
7329 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7331 parts << QString::number( static_cast< int >( it->toDouble() ) );
7333 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7335 else if ( value.type() == QVariant::StringList )
7338 const QStringList values = value.toStringList();
7339 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7341 parts << QString::number( static_cast< int >( it->toDouble() ) );
7343 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7346 return value.toString();
7351 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7353 code += QLatin1String(
"optional " );
7354 code += QLatin1String(
"band " );
7356 if ( mAllowMultiple )
7357 code += QLatin1String(
"multiple " );
7359 code += mParentLayerParameterName +
' ';
7362 return code.trimmed();
7367 QStringList depends;
7368 if ( !mParentLayerParameterName.isEmpty() )
7369 depends << mParentLayerParameterName;
7375 switch ( outputType )
7379 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7382 code += QLatin1String(
", optional=True" );
7384 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7385 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7397 return mParentLayerParameterName;
7408 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7409 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7416 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7417 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7424 QString def = definition;
7427 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7430 def = def.mid( 8 ).trimmed();
7433 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7434 const QRegularExpressionMatch m = re.match( def );
7437 parent = m.captured( 1 ).trimmed();
7438 def = m.captured( 2 );
7455 , mParentParameterName( parentParameterName )
7472 QStringList depends;
7473 if ( !mParentParameterName.isEmpty() )
7474 depends << mParentParameterName;
7480 switch ( outputType )
7484 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7487 code += QLatin1String(
", optional=True" );
7489 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7491 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7492 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7493 if (
maximum() != std::numeric_limits<double>::max() )
7494 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7505 return mParentParameterName;
7516 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7517 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7524 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7551 switch ( outputType )
7555 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7558 code += QLatin1String(
", optional=True" );
7560 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7561 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7562 if (
maximum() != std::numeric_limits<double>::max() )
7563 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7575 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7609 switch ( outputType )
7613 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7616 code += QLatin1String(
", optional=True" );
7628 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7648 return QStringLiteral(
"None" );
7650 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7651 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7653 const QString s = value.toString();
7659 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7661 code += QLatin1String(
"optional " );
7662 code += QLatin1String(
"layout " );
7665 return code.trimmed();
7670 switch ( outputType )
7674 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
7677 code += QLatin1String(
", optional=True" );
7688 QString def = definition;
7690 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7692 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7696 if ( def == QLatin1String(
"None" ) )
7709 , mParentLayoutParameterName( parentLayoutParameterName )
7710 , mItemType( itemType )
7723 return QStringLiteral(
"None" );
7725 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7726 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7728 const QString s = value.toString();
7734 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7736 code += QLatin1String(
"optional " );
7737 code += QLatin1String(
"layoutitem " );
7738 if ( mItemType >= 0 )
7739 code += QString::number( mItemType ) +
' ';
7741 code += mParentLayoutParameterName +
' ';
7744 return code.trimmed();
7749 switch ( outputType )
7753 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
7756 code += QLatin1String(
", optional=True" );
7758 if ( mItemType >= 0 )
7759 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
7761 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
7774 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
7775 map.insert( QStringLiteral(
"item_type" ), mItemType );
7782 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
7783 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
7789 QStringList depends;
7790 if ( !mParentLayoutParameterName.isEmpty() )
7791 depends << mParentLayoutParameterName;
7798 QString def = definition;
7800 const QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
7801 const QRegularExpressionMatch m = re.match( def );
7804 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
7805 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
7806 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
7819 return mParentLayoutParameterName;
7824 mParentLayoutParameterName =
name;
7843 , mAllowOpacity( opacityEnabled )
7856 return QStringLiteral(
"None" );
7858 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7859 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7861 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
7862 return QStringLiteral(
"QColor()" );
7864 if ( value.canConvert< QColor >() )
7866 const QColor
c = value.value< QColor >();
7867 if ( !mAllowOpacity ||
c.alpha() == 255 )
7868 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
7870 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
7873 const QString s = value.toString();
7879 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7881 code += QLatin1String(
"optional " );
7882 code += QLatin1String(
"color " );
7884 if ( mAllowOpacity )
7885 code += QLatin1String(
"withopacity " );
7888 return code.trimmed();
7893 switch ( outputType )
7897 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
7900 code += QLatin1String(
", optional=True" );
7902 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7914 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
7917 if ( !input.isValid() )
7920 if ( input.type() == QVariant::Color )
7924 else if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7929 if ( input.type() != QVariant::String || input.toString().isEmpty() )
7932 bool containsAlpha =
false;
7939 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
7946 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
7952 return mAllowOpacity;
7957 mAllowOpacity = enabled;
7962 QString def = definition;
7964 bool allowOpacity =
false;
7965 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
7967 allowOpacity =
true;
7968 def = def.mid( 12 );
7971 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7973 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7977 if ( def == QLatin1String(
"None" ) || def.isEmpty() )
7988 , mSourceParameterName( sourceCrsParameterName )
7989 , mDestParameterName( destinationCrsParameterName )
7990 , mSourceCrs( staticSourceCrs )
7991 , mDestCrs( staticDestinationCrs )
8004 return QStringLiteral(
"None" );
8006 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
8009 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
8014 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8015 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8018 p.insert(
name(), value );
8023 const QString s = value.toString();
8029 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8031 code += QLatin1String(
"optional " );
8032 code += QLatin1String(
"coordinateoperation " );
8035 return code.trimmed();
8040 switch ( outputType )
8045 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
8048 code += QLatin1String(
", optional=True" );
8049 if ( !mSourceParameterName.isEmpty() )
8050 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
8051 if ( !mDestParameterName.isEmpty() )
8052 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
8054 if ( mSourceCrs.isValid() )
8056 if ( mDestCrs.isValid() )
8057 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
8069 if ( !mSourceParameterName.isEmpty() )
8070 res << mSourceParameterName;
8071 if ( !mDestParameterName.isEmpty() )
8072 res << mDestParameterName;
8079 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
8080 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
8081 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
8082 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
8089 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
8090 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
8091 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
8092 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
8098 QString def = definition;
8100 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8102 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8106 if ( def == QLatin1String(
"None" ) )
8131 if ( !input.isValid() && !
mDefault.isValid() )
8134 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8135 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8143 if ( !value.isValid() )
8144 return QStringLiteral(
"None" );
8146 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8147 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8154 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8156 code += QLatin1String(
"optional " );
8157 code += QLatin1String(
"maptheme " );
8160 return code.trimmed();
8165 switch ( outputType )
8169 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8172 code += QLatin1String(
", optional=True" );
8197 QString def = definition;
8198 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8200 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8222 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8224 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8235 QVariant input = value;
8236 if ( !input.isValid() )
8244 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8249 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
8252 if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType ==
Time )
8255 if ( input.type() == QVariant::String )
8257 const QString s = input.toString();
8261 input = QDateTime::fromString( s, Qt::ISODate );
8262 if ( mDataType ==
Time )
8264 if ( !input.toDateTime().isValid() )
8265 input = QTime::fromString( s );
8267 input = input.toDateTime().time();
8271 if ( mDataType !=
Time )
8273 const QDateTime res = input.toDateTime();
8274 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8278 const QTime res = input.toTime();
8279 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8285 if ( !value.isValid() )
8286 return QStringLiteral(
"None" );
8288 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8289 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8291 if ( value.type() == QVariant::DateTime )
8293 const QDateTime dt = value.toDateTime();
8294 if ( !dt.isValid() )
8295 return QStringLiteral(
"QDateTime()" );
8297 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8298 .arg( dt.date().month() )
8299 .arg( dt.date().day() )
8300 .arg( dt.time().hour() )
8301 .arg( dt.time().minute() )
8302 .arg( dt.time().second() );
8304 else if ( value.type() == QVariant::Date )
8306 const QDate dt = value.toDate();
8307 if ( !dt.isValid() )
8308 return QStringLiteral(
"QDate()" );
8310 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8314 else if ( value.type() == QVariant::Time )
8316 const QTime dt = value.toTime();
8317 if ( !dt.isValid() )
8318 return QStringLiteral(
"QTime()" );
8320 return QStringLiteral(
"QTime(%4, %5, %6)" )
8323 .arg( dt.second() );
8325 return value.toString();
8332 if ( mMin.isValid() )
8333 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8334 if ( mMax.isValid() )
8335 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8337 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
DateTime ?
mDefault.toDateTime().toString( Qt::ISODate ) :
8338 ( mDataType ==
Date ?
mDefault.toDate().toString( Qt::ISODate ) :
mDefault.toTime( ).toString() ) );
8339 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8340 if ( !extra.isEmpty() )
8341 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8347 switch ( outputType )
8351 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8354 code += QLatin1String(
", optional=True" );
8356 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
DateTime ? QStringLiteral(
"QgsProcessingParameterDateTime.DateTime" )
8357 : mDataType ==
Date ? QStringLiteral(
"QgsProcessingParameterDateTime.Date" )
8358 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8361 if ( mMin.isValid() )
8363 if ( mMax.isValid() )
8405 map.insert( QStringLiteral(
"min" ), mMin );
8406 map.insert( QStringLiteral(
"max" ), mMax );
8407 map.insert( QStringLiteral(
"data_type" ), mDataType );
8414 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8415 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8416 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
8423 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8434 , mProviderId( provider )
8447 if ( !input.isValid() && !
mDefault.isValid() )
8450 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8451 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8459 if ( !value.isValid() )
8460 return QStringLiteral(
"None" );
8462 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8463 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8470 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8472 code += QLatin1String(
"optional " );
8473 code += QLatin1String(
"providerconnection " );
8474 code += mProviderId +
' ';
8477 return code.trimmed();
8482 switch ( outputType )
8486 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8489 code += QLatin1String(
", optional=True" );
8503 map.insert( QStringLiteral(
"provider" ), mProviderId );
8510 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8516 QString def = definition;
8518 if ( def.contains(
' ' ) )
8520 provider = def.left( def.indexOf(
' ' ) );
8521 def = def.mid( def.indexOf(
' ' ) + 1 );
8529 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8531 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8549 , mParentConnectionParameterName( parentLayerParameterName )
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(
"databaseschema " );
8590 code += mParentConnectionParameterName +
' ';
8593 return code.trimmed();
8598 switch ( outputType )
8602 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8605 code += QLatin1String(
", optional=True" );
8607 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8621 QStringList depends;
8622 if ( !mParentConnectionParameterName.isEmpty() )
8623 depends << mParentConnectionParameterName;
8629 return mParentConnectionParameterName;
8634 mParentConnectionParameterName =
name;
8640 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8647 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8654 QString def = definition;
8656 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
8657 const QRegularExpressionMatch m = re.match( def );
8660 parent = m.captured( 1 ).trimmed();
8661 def = m.captured( 2 );
8677 const QString &connectionParameterName,
8678 const QString &schemaParameterName,
8679 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
8681 , mParentConnectionParameterName( connectionParameterName )
8682 , mParentSchemaParameterName( schemaParameterName )
8683 , mAllowNewTableNames( allowNewTableNames )
8696 if ( !input.isValid() && !
mDefault.isValid() )
8699 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8700 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8708 if ( !value.isValid() )
8709 return QStringLiteral(
"None" );
8711 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8712 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8719 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8721 code += QLatin1String(
"optional " );
8722 code += QLatin1String(
"databasetable " );
8724 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
8725 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
8728 return code.trimmed();
8733 switch ( outputType )
8737 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
8740 code += QLatin1String(
", optional=True" );
8742 if ( mAllowNewTableNames )
8743 code += QLatin1String(
", allowNewTableNames=True" );
8745 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8746 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
8760 QStringList depends;
8761 if ( !mParentConnectionParameterName.isEmpty() )
8762 depends << mParentConnectionParameterName;
8763 if ( !mParentSchemaParameterName.isEmpty() )
8764 depends << mParentSchemaParameterName;
8770 return mParentConnectionParameterName;
8775 mParentConnectionParameterName =
name;
8780 return mParentSchemaParameterName;
8785 mParentSchemaParameterName =
name;
8791 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8792 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
8793 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
8800 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8801 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
8802 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
8810 QString def = definition;
8812 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
8813 const QRegularExpressionMatch m = re.match( def );
8816 connection = m.captured( 1 ).trimmed();
8817 if ( connection == QLatin1String(
"none" ) )
8819 schema = m.captured( 2 ).trimmed();
8820 if ( schema == QLatin1String(
"none" ) )
8822 def = m.captured( 3 );
8830 return mAllowNewTableNames;
8843 const QVariant &defaultValue,
bool optional )
8857 if ( !var.isValid() )
8865 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8878 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
8881 if ( var.type() != QVariant::String || var.toString().isEmpty() )
8899 if ( !val.isValid() )
8900 return QStringLiteral(
"None" );
8902 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
8906 p.insert(
name(), val );
8937 const QVariant &defaultValue,
bool optional )
8950 if ( !var.isValid() )
8958 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8971 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
8974 if ( var.type() != QVariant::String || var.toString().isEmpty() )
8992 if ( !val.isValid() )
8993 return QStringLiteral(
"None" );
8995 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
8999 p.insert(
name(), val );
9032 QVariant var = input;
9033 if ( !var.isValid() )
9041 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9047 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9060 if ( var.type() != QVariant::String )
9063 if ( var.toString().isEmpty() )
9071 if ( !value.isValid() )
9072 return QStringLiteral(
"None" );
9074 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9075 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9077 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9086 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9102 return lOriginalProvider->defaultPointCloudFileExtension();
9106 return p->defaultPointCloudFileExtension();
9117 QStringList filters;
9118 for (
const QString &ext : exts )
9120 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9122 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9129 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9133 return p->supportedOutputPointCloudLayerExtensions();
9138 return QStringList() << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
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.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
QString toWkt(WktVariant variant=WKT1_GDAL, 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.
InvalidGeometryCheck
Handling of features with invalid geometries.
@ GeometryNoCheck
No invalid geometry checking.
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
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.
QgsWkbTypes::GeometryType type
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.
QString source() const
Returns the source for 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.
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,...
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.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
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.
Flags flags
Flags which dictate source behavior.
bool selectedFeaturesOnly
true if only selected features in the source should be used by algorithms.
QgsFeatureRequest::InvalidGeometryCheck geometryCheck
Geometry check method to apply to this source.
QgsProperty source
Source definition.
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...
@ FlagCreateIndividualOutputPerInputFeature
If set, every feature processed from this source will be placed into its own individually created out...
@ FlagOverrideDefaultGeometryCheck
If set, the default geometry check method (as dictated by QgsProcessingContext) will be overridden fo...
QVariant toVariant() const
Saves this source definition to a QVariantMap, wrapped in a QVariant.
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.
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::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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
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 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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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...
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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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::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.
@ DateTime
Datetime values.
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.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable 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.
QgsProcessingParameterDateTime(const QString &name, const QString &description=QString(), Type type=DateTime, const QVariant &defaultValue=QVariant(), bool optional=false, const QDateTime &minValue=QDateTime(), const QDateTime &maxValue=QDateTime())
Constructor for QgsProcessingParameterDateTime.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Type dataType() const
Returns the acceptable data type for the parameter.
void setDataType(Type type)
Sets the acceptable data type for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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.
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...
virtual QStringList valueAsStringList(const QVariant &value, QgsProcessingContext &context, bool &ok) const
Returns a string list version of the parameter input value (if possible).
Flags mFlags
Parameter flags.
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.
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString mName
Parameter name.
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.
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...
@ FlagOptional
Parameter is optional.
QString mDescription
Parameter description.
virtual QString type() const =0
Unique parameter type name.
Flags flags() const
Returns any flags associated with the parameter.
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.
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.
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.
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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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::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...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
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.
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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
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.
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.
QString generateTemporaryDestination() 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.
QgsProcessing::SourceType dataType() const
Returns the layer type for 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.
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true, bool supportsAppend=false)
Constructor for QgsProcessingParameterFeatureSink.
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.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the sinks associated with the parameter.
bool supportsAppend() const
Returns true if the sink supports appending features to an existing table.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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.
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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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 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 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.
QgsProcessingParameterField(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), DataType type=Any, bool allowMultiple=false, bool optional=false, bool defaultToAllFields=false)
Constructor for QgsProcessingParameterField.
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 setDataType(DataType type)
Sets the acceptable data type for the field.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
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.
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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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 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 setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
DataType
Field data types.
@ DateTime
Accepts datetime fields.
@ Numeric
Accepts numeric fields.
@ String
Accepts string fields.
DataType dataType() const
Returns the acceptable data type for the field.
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::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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
static QgsProcessingParameterFile * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior=File)
Creates a new parameter using the definition from a script code.
Behavior
Parameter behavior.
@ Folder
Parameter is a folder.
@ File
Parameter is a single file.
Behavior behavior() const
Returns the parameter behavior (e.g.
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.
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Behavior behavior=File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &fileFilter=QString())
Constructor for QgsProcessingParameterFile.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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 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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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.
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 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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString type() const override
Unique parameter type name.
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::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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
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.
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), QgsProcessing::SourceType layerType=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
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.
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...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
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.
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
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
Double/float values.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
double maximum() const
Returns the maximum value acceptable by the parameter.
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Type type=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(Type type)
Sets the acceptable data type for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Type dataType() const
Returns the acceptable data type 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.
static QString typeName()
Returns the type name for the parameter class.
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::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.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
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::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setDataType(QgsProcessingParameterNumber::Type dataType)
Sets the acceptable data type for the range.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), QgsProcessingParameterNumber::Type type=QgsProcessingParameterNumber::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...
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::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 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::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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 ...
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...
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the created vector layer.
QgsProcessingParameterVectorDestination(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorDestination.
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.
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...
A vector layer (with or without geometry) parameter for processing algorithms.
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...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
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 QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
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 QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint=QgsProcessingUtils::LayerHint::UnknownType)
Evaluates the parameter with matching definition to a map layer.
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 QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, QgsWkbTypes::Type 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 bool parameterAsBoolean(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
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 QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a point cloud layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static 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 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 convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long long featureLimit=-1)
Converts a source vector layer to a file path of a vector layer of compatible format.
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 normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type 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 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.
@ 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 generateTempFilename(const QString &basename)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
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)
Converts a source vector layer to a file path and layer name of a vector layer of compatible format.
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 QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType)
Interprets a string as a map layer within the supplied context.
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
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.
SourceType
Data source types enum.
@ TypePlugin
Plugin layers.
@ TypeVectorLine
Vector line layers.
@ TypeMapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ TypeVectorPolygon
Vector polygon layers.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
@ TypeAnnotation
Annotation layers.
@ TypePointCloud
Point cloud layers.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ TypeRaster
Raster layers.
@ TypeVectorPoint
Vector point layers.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
static QString sourceTypeToString(SourceType type)
Converts a source type to a string representation.
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.
@ ExpressionBasedProperty
Expression based property (QgsExpressionBasedProperty)
@ StaticProperty
Static property (QgsStaticProperty)
@ FieldBasedProperty
Field based property (QgsFieldBasedProperty)
@ InvalidProperty
Invalid (not set) property.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
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.
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.
Type propertyType() const
Returns the property type.
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 (all coordinates zero or after call to setMinimal()).
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.
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,...
DistanceUnit
Units of distance.
@ DistanceUnknownUnit
Unknown distance unit.
TemporalUnit
Temporal units.
static bool isNull(const QVariant &variant)
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.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Type
The WKB type describes the number of dimensions a geometry has.
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.
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