25 #include "qgssettings.h"
40 #include <QRegularExpression>
48 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
49 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
50 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
58 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
59 flags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ), 0 ).toInt() );
72 mRemappingDefinition = definition;
79 map.insert( QStringLiteral(
"create_options" ),
createOptions );
81 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
88 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
89 if ( map.contains( QStringLiteral(
"remapping" ) ) )
96 mUseRemapping =
false;
104 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
109 return !( *
this == other );
114 QVariant val = parameters.value( name );
134 QVariant val = value;
138 if ( !val.isValid() )
147 return destParam->generateTemporaryDestination();
150 return val.toString();
166 QVariant val = value;
170 if ( val.isValid() && !val.toString().isEmpty() )
174 return val.toString();
194 QVariant val = value;
199 double res = val.toDouble( &ok );
205 return val.toDouble();
221 QVariant val = value;
226 double dbl = val.toDouble( &ok );
231 dbl = val.toDouble( &ok );
238 double round = std::round( dbl );
239 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
244 return static_cast< int >( std::round( dbl ) );
253 return QList< int >();
261 return QList< int >();
263 QList< int > resultList;
264 QVariant val = value;
269 else if ( val.type() == QVariant::List )
271 QVariantList list = val.toList();
272 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
273 resultList << it->toInt();
277 QStringList parts = val.toString().split(
';' );
278 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
279 resultList << it->toInt();
283 if ( resultList.isEmpty() )
288 if ( definition->
defaultValue().type() == QVariant::List )
290 QVariantList list = definition->
defaultValue().toList();
291 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
292 resultList << it->toInt();
296 QStringList parts = definition->
defaultValue().toString().split(
';' );
297 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
298 resultList << it->toInt();
319 QVariant val = value;
323 QDateTime d = val.toDateTime();
324 if ( !d.isValid() && val.type() == QVariant::String )
326 d = QDateTime::fromString( val.toString() );
333 d = val.toDateTime();
335 if ( !d.isValid() && val.type() == QVariant::String )
337 d = QDateTime::fromString( val.toString() );
356 QVariant val = value;
360 QDate d = val.toDate();
361 if ( !d.isValid() && val.type() == QVariant::String )
363 d = QDate::fromString( val.toString() );
372 if ( !d.isValid() && val.type() == QVariant::String )
374 d = QDate::fromString( val.toString() );
393 QVariant val = value;
399 if ( val.type() == QVariant::DateTime )
400 d = val.toDateTime().time();
404 if ( !d.isValid() && val.type() == QVariant::String )
406 d = QTime::fromString( val.toString() );
415 if ( !d.isValid() && val.type() == QVariant::String )
417 d = QTime::fromString( val.toString() );
438 if ( enumDef && val >= enumDef->
options().size() )
458 QVariantList resultList;
459 QVariant val = value;
462 else if ( val.type() == QVariant::List )
464 const auto constToList = val.toList();
465 for (
const QVariant &var : constToList )
468 else if ( val.type() == QVariant::String )
470 const auto constSplit = val.toString().split(
',' );
471 for (
const QString &var : constSplit )
477 if ( resultList.isEmpty() )
478 return QList< int >();
480 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
484 if ( definition->
defaultValue().type() == QVariant::List )
486 const auto constToList = definition->
defaultValue().toList();
487 for (
const QVariant &var : constToList )
490 else if ( definition->
defaultValue().type() == QVariant::String )
492 const auto constSplit = definition->
defaultValue().toString().split(
',' );
493 for (
const QString &var : constSplit )
502 const auto constResultList = resultList;
503 for (
const QVariant &var : constResultList )
505 int resInt = var.toInt();
506 if ( !enumDef || resInt < enumDef->options().size() )
529 if ( enumText.isEmpty() || !enumDef->
options().contains( enumText ) )
538 return QStringList();
546 return QStringList();
548 QVariant val = value;
550 QStringList enumValues;
552 std::function< void(
const QVariant &var ) > processVariant;
553 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
555 if ( var.type() == QVariant::List )
557 const auto constToList = var.toList();
558 for (
const QVariant &listVar : constToList )
560 processVariant( listVar );
563 else if ( var.type() == QVariant::StringList )
565 const auto constToStringList = var.toStringList();
566 for (
const QString &s : constToStringList )
575 const QStringList parts = var.toString().split(
',' );
576 for (
const QString &s : parts )
583 processVariant( val );
589 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
590 QSet<QString> subtraction = enumValues.toSet().subtract( enumDef->
options().toSet() );
592 const QStringList options = enumDef->
options();
593 QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
596 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
628 QVariant val = value;
631 else if ( val.isValid() )
644 QVariant val = value;
647 else if ( val.isValid() )
655 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
656 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
661 val = parameters.value( definition->
name() );
664 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
667 QgsFeatureSink *
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 )
669 QVariantMap options = createOptions;
670 QVariant val = value;
675 bool useRemapDefinition =
false;
687 useRemapDefinition =
true;
697 else if ( !val.isValid() || val.toString().isEmpty() )
713 dest = val.toString();
718 dest = destParam->generateTemporaryDestination();
721 if ( dest.isEmpty() )
724 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition :
nullptr ) );
725 destinationIdentifier = dest;
727 if ( destinationProject )
729 if ( destName.isEmpty() && definition )
735 outputName = definition->
name();
739 return sink.release();
763 QVariant val = parameters.value( definition->
name() );
765 bool selectedFeaturesOnly =
false;
766 long long featureLimit = -1;
788 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
797 else if ( !val.isValid() || val.toString().isEmpty() )
803 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
809 layerRef = val.toString();
814 if ( layerRef.isEmpty() )
826 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit );
829 compatibleFormats, preferredFormat, context, feedback, featureLimit );
839 QString *destLayer = layerName;
854 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint );
862 QVariant val = value;
868 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
885 if ( !val.isValid() || val.toString().isEmpty() )
891 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
896 QString layerRef = val.toString();
897 if ( layerRef.isEmpty() )
900 if ( layerRef.isEmpty() )
931 val = parameters.value( definition->
name() );
938 QVariant val = value;
956 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
963 dest = val.toString();
968 dest = destParam->generateTemporaryDestination();
971 if ( destinationProject )
974 if ( destName.isEmpty() && definition )
979 outputName = definition->
name();
998 val = parameters.value( definition->
name() );
1005 QVariant val = value;
1015 if ( definition && val.canConvert<
QgsProperty>() )
1019 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1026 dest = val.toString();
1031 dest = destParam->generateTemporaryDestination();
1051 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1076 QVariant val = value;
1125 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1131 rectText = val.toString();
1133 if ( rectText.isEmpty() && !layer )
1136 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1137 QRegularExpressionMatch match = rx.match( rectText );
1138 if ( match.hasMatch() )
1140 bool xMinOk =
false;
1141 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1142 bool xMaxOk =
false;
1143 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1144 bool yMinOk =
false;
1145 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1146 bool yMaxOk =
false;
1147 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1148 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1197 QVariant val = parameters.value( definition->
name() );
1205 g = g.densifyByCount( 20 );
1241 rectText = val.toString();
1243 if ( !rectText.isEmpty() )
1245 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1246 QRegularExpressionMatch match = rx.match( rectText );
1247 if ( match.hasMatch() )
1249 bool xMinOk =
false;
1250 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1251 bool xMaxOk =
false;
1252 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1253 bool yMinOk =
false;
1254 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1255 bool yMaxOk =
false;
1256 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1257 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1283 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1312 QVariant val = parameters.value( definition->
name() );
1318 QVariant val = value;
1346 QString valueAsString;
1350 valueAsString = val.toString();
1352 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1354 QRegularExpressionMatch match = rx.match( valueAsString );
1355 if ( match.hasMatch() )
1381 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1382 return layer->crs();
1384 return layer->crs();
1386 if (
auto *lProject = context.
project() )
1387 return lProject->crs();
1405 QVariant val = value;
1435 if ( pointText.isEmpty() )
1438 if ( pointText.isEmpty() )
1441 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1444 QRegularExpressionMatch match = rx.match( valueAsString );
1445 if ( match.hasMatch() )
1448 double x = match.captured( 1 ).toDouble( &xOk );
1450 double y = match.captured( 2 ).toDouble( &yOk );
1478 QVariant val = parameters.value( definition->
name() );
1493 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1496 QRegularExpressionMatch match = rx.match( valueAsString );
1497 if ( match.hasMatch() )
1504 if (
auto *lProject = context.
project() )
1505 return lProject->crs();
1523 QVariant val = value;
1563 g = g.densifyByCount( 20 );
1596 if ( valueAsString.isEmpty() )
1599 if ( valueAsString.isEmpty() )
1602 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1604 QRegularExpressionMatch match = rx.match( valueAsString );
1605 if ( match.hasMatch() )
1632 QVariant val = parameters.value( definition->
name() );
1666 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1669 QRegularExpressionMatch match = rx.match( valueAsString );
1670 if ( match.hasMatch() )
1677 if (
auto *lProject = context.
project() )
1678 return lProject->crs();
1689 if ( fileText.isEmpty() )
1700 if ( fileText.isEmpty() )
1708 return QVariantList();
1716 return QVariantList();
1718 QString resultString;
1719 QVariant val = value;
1722 else if ( val.type() == QVariant::List )
1723 return val.toList();
1725 resultString = val.toString();
1727 if ( resultString.isEmpty() )
1730 if ( definition->
defaultValue().type() == QVariant::List )
1736 QVariantList result;
1737 const auto constSplit = resultString.split(
',' );
1738 for (
const QString &s : constSplit )
1747 return QList<QgsMapLayer *>();
1755 return QList<QgsMapLayer *>();
1757 QVariant val = value;
1758 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1760 return QList<QgsMapLayer *>() << layer;
1763 QList<QgsMapLayer *> layers;
1765 std::function< void(
const QVariant &var ) > processVariant;
1766 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1768 if ( var.type() == QVariant::List )
1770 const auto constToList = var.toList();
1771 for (
const QVariant &listVar : constToList )
1773 processVariant( listVar );
1776 else if ( var.type() == QVariant::StringList )
1778 const auto constToStringList = var.toStringList();
1779 for (
const QString &s : constToStringList )
1781 processVariant( s );
1790 QVariant sink = fromVar.
sink;
1796 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1808 processVariant( val );
1810 if ( layers.isEmpty() )
1813 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1817 else if ( definition->
defaultValue().type() == QVariant::List )
1819 const auto constToList = definition->
defaultValue().toList();
1820 for (
const QVariant &var : constToList )
1822 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1828 processVariant( var );
1842 return QStringList();
1844 QVariant val = value;
1848 std::function< void(
const QVariant &var ) > processVariant;
1849 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1851 if ( var.type() == QVariant::List )
1853 const auto constToList = var.toList();
1854 for (
const QVariant &listVar : constToList )
1856 processVariant( listVar );
1859 else if ( var.type() == QVariant::StringList )
1861 const auto constToStringList = var.toStringList();
1862 for (
const QString &s : constToStringList )
1864 processVariant( s );
1871 files << var.toString();
1875 processVariant( val );
1877 if ( files.isEmpty() )
1888 return QStringList();
1896 return QList<double>();
1904 return QList<double>();
1906 QStringList resultStringList;
1907 QVariant val = value;
1911 else if ( val.type() == QVariant::List )
1913 const auto constToList = val.toList();
1914 for (
const QVariant &var : constToList )
1915 resultStringList << var.toString();
1918 resultStringList << val.toString();
1920 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1922 resultStringList.clear();
1924 if ( definition->
defaultValue().type() == QVariant::List )
1926 const auto constToList = definition->
defaultValue().toList();
1927 for (
const QVariant &var : constToList )
1928 resultStringList << var.toString();
1931 resultStringList << definition->
defaultValue().toString();
1934 if ( resultStringList.size() == 1 )
1936 resultStringList = resultStringList.at( 0 ).split(
',' );
1939 if ( resultStringList.size() < 2 )
1940 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1942 QList< double > result;
1944 double n = resultStringList.at( 0 ).toDouble( &ok );
1948 result << std::numeric_limits<double>::quiet_NaN() ;
1950 n = resultStringList.at( 1 ).toDouble( &ok );
1954 result << std::numeric_limits<double>::quiet_NaN() ;
1962 return QStringList();
1964 QStringList resultStringList;
1971 return QStringList();
1973 QStringList resultStringList;
1974 QVariant val = value;
1975 if ( val.isValid() )
1979 else if ( val.type() == QVariant::List )
1981 const auto constToList = val.toList();
1982 for (
const QVariant &var : constToList )
1983 resultStringList << var.toString();
1985 else if ( val.type() == QVariant::StringList )
1987 resultStringList = val.toStringList();
1990 resultStringList.append( val.toString().split(
';' ) );
1993 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1995 resultStringList.clear();
1999 if ( definition->
defaultValue().type() == QVariant::List )
2001 const auto constToList = definition->
defaultValue().toList();
2002 for (
const QVariant &var : constToList )
2003 resultStringList << var.toString();
2005 else if ( definition->
defaultValue().type() == QVariant::StringList )
2007 resultStringList = definition->
defaultValue().toStringList();
2010 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2014 return resultStringList;
2028 if ( layoutName.isEmpty() )
2080 QVariant val = value;
2085 if ( val.type() == QVariant::Color )
2087 QColor
c = val.value< QColor >();
2089 if ( !colorParam->opacityEnabled() )
2097 if ( definition->
defaultValue().type() == QVariant::Color )
2103 if ( colorText.isEmpty() )
2106 bool containsAlpha =
false;
2109 if (
c.isValid() && !colorParam->opacityEnabled() )
2161 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2162 QString name = map.value( QStringLiteral(
"name" ) ).toString();
2163 std::unique_ptr< QgsProcessingParameterDefinition > def;
2230 def.reset( paramType->
create( name ) );
2236 def->fromVariantMap( map );
2237 return def.release();
2242 QString desc = name;
2243 desc.replace(
'_',
' ' );
2249 bool isOptional =
false;
2253 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2258 if ( type == QLatin1String(
"boolean" ) )
2260 else if ( type == QLatin1String(
"crs" ) )
2262 else if ( type == QLatin1String(
"layer" ) )
2264 else if ( type == QLatin1String(
"extent" ) )
2266 else if ( type == QLatin1String(
"point" ) )
2268 else if ( type == QLatin1String(
"geometry" ) )
2270 else if ( type == QLatin1String(
"file" ) )
2272 else if ( type == QLatin1String(
"folder" ) )
2274 else if ( type == QLatin1String(
"matrix" ) )
2276 else if ( type == QLatin1String(
"multiple" ) )
2278 else if ( type == QLatin1String(
"number" ) )
2280 else if ( type == QLatin1String(
"distance" ) )
2282 else if ( type == QLatin1String(
"scale" ) )
2284 else if ( type == QLatin1String(
"range" ) )
2286 else if ( type == QLatin1String(
"raster" ) )
2288 else if ( type == QLatin1String(
"enum" ) )
2290 else if ( type == QLatin1String(
"string" ) )
2292 else if ( type == QLatin1String(
"authcfg" ) )
2294 else if ( type == QLatin1String(
"expression" ) )
2296 else if ( type == QLatin1String(
"field" ) )
2298 else if ( type == QLatin1String(
"vector" ) )
2300 else if ( type == QLatin1String(
"source" ) )
2302 else if ( type == QLatin1String(
"sink" ) )
2304 else if ( type == QLatin1String(
"vectordestination" ) )
2306 else if ( type == QLatin1String(
"rasterdestination" ) )
2308 else if ( type == QLatin1String(
"filedestination" ) )
2310 else if ( type == QLatin1String(
"folderdestination" ) )
2312 else if ( type == QLatin1String(
"band" ) )
2314 else if ( type == QLatin1String(
"mesh" ) )
2316 else if ( type == QLatin1String(
"layout" ) )
2318 else if ( type == QLatin1String(
"layoutitem" ) )
2320 else if ( type == QLatin1String(
"color" ) )
2322 else if ( type == QLatin1String(
"coordinateoperation" ) )
2324 else if ( type == QLatin1String(
"maptheme" ) )
2326 else if ( type == QLatin1String(
"datetime" ) )
2328 else if ( type == QLatin1String(
"providerconnection" ) )
2330 else if ( type == QLatin1String(
"databaseschema" ) )
2332 else if ( type == QLatin1String(
"databasetable" ) )
2338 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2340 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2341 QRegularExpressionMatch m = re.match( code );
2342 if ( !m.hasMatch() )
2345 name = m.captured( 1 );
2346 QString tokens = m.captured( 2 );
2347 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2350 tokens.remove( 0, 8 );
2357 tokens = tokens.trimmed();
2359 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2360 m = re2.match( tokens );
2361 if ( !m.hasMatch() )
2363 type = tokens.toLower().trimmed();
2368 type = m.captured( 1 ).toLower().trimmed();
2369 definition = m.captured( 2 );
2380 , mDescription( description )
2382 , mDefault( defaultValue )
2383 , mFlags( optional ? FlagOptional : 0 )
2388 if ( !input.isValid() && !
mDefault.isValid() )
2391 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2392 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2400 if ( !value.isValid() )
2401 return QStringLiteral(
"None" );
2404 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2416 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2418 code += QLatin1String(
"optional " );
2419 code +=
type() +
' ';
2421 return code.trimmed();
2429 switch ( outputType )
2433 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
2435 code += QLatin1String(
", optional=True" );
2451 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2452 map.insert( QStringLiteral(
"name" ),
mName );
2453 map.insert( QStringLiteral(
"description" ),
mDescription );
2454 map.insert( QStringLiteral(
"help" ),
mHelp );
2455 map.insert( QStringLiteral(
"default" ),
mDefault );
2456 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2457 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2458 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2464 mName = map.value( QStringLiteral(
"name" ) ).toString();
2465 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2466 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2467 mDefault = map.value( QStringLiteral(
"default" ) );
2468 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2469 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2470 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2486 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
2487 if ( !
help().isEmpty() )
2489 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
2491 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
2506 if ( !val.isValid() )
2507 return QStringLiteral(
"None" );
2511 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
2516 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2518 code += QLatin1String(
"optional " );
2519 code +=
type() +
' ';
2520 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
2521 return code.trimmed();
2542 if ( !input.isValid() )
2564 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2567 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2575 if ( !value.isValid() )
2576 return QStringLiteral(
"None" );
2581 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
2587 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2590 p.insert(
name(), value );
2617 if ( !input.isValid() )
2625 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2630 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2648 if ( !val.isValid() )
2649 return QStringLiteral(
"None" );
2655 p.insert(
name(), val );
2665 for (
const QString &raster : rasters )
2667 if ( !vectors.contains( raster ) )
2671 for (
const QString &mesh : meshFilters )
2673 if ( !vectors.contains( mesh ) )
2676 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
2677 std::sort( vectors.begin(), vectors.end() );
2679 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
2689 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2691 code += QLatin1String(
"optional " );
2692 code += QLatin1String(
"layer " );
2699 code += QLatin1String(
"hasgeometry " );
2703 code += QLatin1String(
"point " );
2707 code += QLatin1String(
"line " );
2711 code += QLatin1String(
"polygon " );
2715 code += QLatin1String(
"raster " );
2719 code += QLatin1String(
"mesh " );
2725 return code.trimmed();
2731 QString def = definition;
2734 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
2737 def = def.mid( 12 );
2740 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
2746 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
2752 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
2758 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
2764 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
2778 switch ( outputType )
2782 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', '%2'" ).arg(
name(),
description() );
2784 code += QLatin1String(
", optional=True" );
2791 QStringList options;
2795 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
2799 code += QLatin1Char(
')' );
2816 map.insert( QStringLiteral(
"data_types" ), types );
2824 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
2825 for (
const QVariant &val : values )
2845 if ( !input.isValid() )
2878 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2881 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2890 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
2891 QRegularExpressionMatch match = rx.match( input.toString() );
2892 if ( match.hasMatch() )
2894 bool xMinOk =
false;
2895 ( void )match.captured( 1 ).toDouble( &xMinOk );
2896 bool xMaxOk =
false;
2897 ( void )match.captured( 2 ).toDouble( &xMaxOk );
2898 bool yMinOk =
false;
2899 ( void )match.captured( 3 ).toDouble( &yMinOk );
2900 bool yMaxOk =
false;
2901 ( void )match.captured( 4 ).toDouble( &yMaxOk );
2902 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
2912 if ( !value.isValid() )
2913 return QStringLiteral(
"None" );
2916 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2939 const QString wkt = g.
asWkt();
2940 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
2945 p.insert(
name(), value );
2971 if ( !input.isValid() )
2992 if ( input.type() == QVariant::String )
2994 if ( input.toString().isEmpty() )
2998 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3000 QRegularExpressionMatch match = rx.match( input.toString() );
3001 if ( match.hasMatch() )
3004 ( void )match.captured( 1 ).toDouble( &xOk );
3006 ( void )match.captured( 2 ).toDouble( &yOk );
3015 if ( !value.isValid() )
3016 return QStringLiteral(
"None" );
3019 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3039 const QString wkt = g.
asWkt();
3040 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3053 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3055 mGeomTypes( geometryTypes ),
3056 mAllowMultipart( allowMultipart )
3068 if ( !input.isValid() )
3080 return ( anyTypeAllowed || mGeomTypes.contains( input.value<
QgsGeometry>().
type() ) ) &&
3081 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3110 if ( input.type() == QVariant::String )
3112 if ( input.toString().isEmpty() )
3117 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3119 QRegularExpressionMatch match = rx.match( input.toString() );
3120 if ( match.hasMatch() )
3125 return ( anyTypeAllowed || mGeomTypes.contains( g.
type() ) ) && ( mAllowMultipart || !g.
isMultipart() );
3145 if ( !value.isValid() )
3146 return QStringLiteral(
"None" );
3198 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3200 code += QLatin1String(
"optional " );
3201 code +=
type() +
' ';
3203 for (
int type : mGeomTypes )
3208 code += QLatin1String(
"point " );
3212 code += QLatin1String(
"line " );
3216 code += QLatin1String(
"polygon " );
3220 code += QLatin1String(
"unknown " );
3226 return code.trimmed();
3231 switch ( outputType )
3235 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', '%2'" ).arg(
name(),
description() );
3237 code += QLatin1String(
", optional=True" );
3239 if ( !mGeomTypes.empty() )
3246 return QStringLiteral(
"PointGeometry" );
3249 return QStringLiteral(
"LineGeometry" );
3252 return QStringLiteral(
"PolygonGeometry" );
3255 return QStringLiteral(
"UnknownGeometry" );
3258 return QStringLiteral(
"NullGeometry" );
3263 QStringList options;
3264 options.reserve( mGeomTypes.size() );
3265 for (
int type : mGeomTypes )
3269 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3272 if ( ! mAllowMultipart )
3274 code += QLatin1String(
", allowMultipart=False" );
3289 for (
int type : mGeomTypes )
3293 map.insert( QStringLiteral(
"geometrytypes" ), types );
3294 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3302 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3303 for (
const QVariant &val : values )
3305 mGeomTypes << val.toInt();
3307 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
3318 , mBehavior( behavior )
3319 , mExtension( fileFilter.isEmpty() ? extension : QString() )
3320 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3332 if ( !input.isValid() )
3340 QString
string = input.toString().trimmed();
3342 if ( input.type() != QVariant::String ||
string.isEmpty() )
3345 switch ( mBehavior )
3349 if ( !mExtension.isEmpty() )
3351 return string.endsWith( mExtension, Qt::CaseInsensitive );
3353 else if ( !mFileFilter.isEmpty() )
3356 return test == string;
3372 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3374 code += QLatin1String(
"optional " );
3375 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
3377 return code.trimmed();
3382 switch ( outputType )
3387 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', '%2'" ).arg(
name(),
description() );
3389 code += QLatin1String(
", optional=True" );
3390 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
3391 if ( !mExtension.isEmpty() )
3392 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
3393 if ( !mFileFilter.isEmpty() )
3394 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
3405 switch ( mBehavior )
3409 if ( !mFileFilter.isEmpty() )
3410 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
3411 else if ( !mExtension.isEmpty() )
3412 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
3414 return QObject::tr(
"All files (*.*)" );
3426 mFileFilter.clear();
3436 mFileFilter = filter;
3443 map.insert( QStringLiteral(
"behavior" ), mBehavior );
3444 map.insert( QStringLiteral(
"extension" ), mExtension );
3445 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
3452 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
3453 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
3454 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
3465 , mHeaders( headers )
3466 , mNumberRows( numberRows )
3467 , mFixedNumberRows( fixedNumberRows )
3479 if ( !input.isValid() )
3482 if ( input.type() == QVariant::String )
3484 if ( input.toString().isEmpty() )
3488 else if ( input.type() == QVariant::List )
3490 if ( input.toList().isEmpty() )
3494 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
3504 if ( !value.isValid() )
3505 return QStringLiteral(
"None" );
3508 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3511 p.insert(
name(), value );
3515 const auto constList = list;
3516 for (
const QVariant &v : constList )
3518 if ( v.type() == QVariant::List )
3521 const auto constToList = v.toList();
3522 for (
const QVariant &v2 : constToList )
3524 if ( v2.isNull() || !v2.isValid() )
3525 parts2 << QStringLiteral(
"None" );
3526 else if ( v2.toString().isEmpty() )
3527 parts2 << QStringLiteral(
"''" );
3529 parts2 << v2.toString();
3531 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
3535 if ( v.isNull() || !v.isValid() )
3536 parts << QStringLiteral(
"None" );
3537 else if ( v.toString().isEmpty() )
3538 parts << QStringLiteral(
"''" );
3540 parts << v.toString();
3544 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3549 switch ( outputType )
3553 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', '%2'" ).arg(
name(),
description() );
3555 code += QLatin1String(
", optional=True" );
3556 code += QStringLiteral(
", numberRows=" ).arg( mNumberRows );
3557 code += QStringLiteral(
", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3560 headers.reserve( mHeaders.size() );
3561 for (
const QString &h : mHeaders )
3563 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
3595 return mFixedNumberRows;
3600 mFixedNumberRows = fixedNumberRows;
3606 map.insert( QStringLiteral(
"headers" ), mHeaders );
3607 map.insert( QStringLiteral(
"rows" ), mNumberRows );
3608 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
3615 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
3616 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
3617 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
3628 , mLayerType( layerType )
3640 if ( !input.isValid() )
3645 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3651 if ( input.type() == QVariant::String )
3653 if ( input.toString().isEmpty() )
3656 if ( mMinimumNumberInputs > 1 )
3667 else if ( input.type() == QVariant::List )
3669 if ( input.toList().count() < mMinimumNumberInputs )
3672 if ( mMinimumNumberInputs > input.toList().count() )
3680 const auto constToList = input.toList();
3681 for (
const QVariant &v : constToList )
3683 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
3692 else if ( input.type() == QVariant::StringList )
3694 if ( input.toStringList().count() < mMinimumNumberInputs )
3697 if ( mMinimumNumberInputs > input.toStringList().count() )
3705 const auto constToStringList = input.toStringList();
3706 for (
const QString &v : constToStringList )
3719 if ( !value.isValid() )
3720 return QStringLiteral(
"None" );
3723 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3728 if ( value.type() == QVariant::StringList )
3730 const QStringList list = value.toStringList();
3731 parts.reserve( list.count() );
3732 for (
const QString &v : list )
3735 else if ( value.type() == QVariant::List )
3737 const QVariantList list = value.toList();
3738 parts.reserve( list.count() );
3739 for (
const QVariant &v : list )
3742 if ( !parts.isEmpty() )
3743 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3748 p.insert(
name(), value );
3750 if ( !list.isEmpty() )
3753 parts.reserve( list.count() );
3758 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3767 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3769 code += QLatin1String(
"optional " );
3770 switch ( mLayerType )
3773 code += QLatin1String(
"multiple raster" );
3777 code += QLatin1String(
"multiple file" );
3781 code += QLatin1String(
"multiple vector" );
3785 if (
mDefault.type() == QVariant::List )
3788 const auto constToList =
mDefault.toList();
3789 for (
const QVariant &var : constToList )
3791 parts << var.toString();
3793 code += parts.join(
',' );
3795 else if (
mDefault.type() == QVariant::StringList )
3797 code +=
mDefault.toStringList().join(
',' );
3803 return code.trimmed();
3808 switch ( outputType )
3812 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg(
name(),
description() );
3814 code += QLatin1String(
", optional=True" );
3818 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
3830 switch ( mLayerType )
3833 return QObject::tr(
"All files (*.*)" );
3866 return mMinimumNumberInputs;
3878 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
3879 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
3887 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
3893 QString
type = definition;
3895 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
3896 QRegularExpressionMatch m = re.match( definition );
3899 type = m.captured( 1 ).toLower().trimmed();
3900 defaultVal = m.captured( 2 );
3903 if (
type == QLatin1String(
"vector" ) )
3905 else if (
type == QLatin1String(
"raster" ) )
3907 else if (
type == QLatin1String(
"file" ) )
3920 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
3931 QVariant input = value;
3932 if ( !input.isValid() )
3946 double res = input.toDouble( &ok );
3950 return !( res < mMin || res > mMax );
3955 if ( !value.isValid() )
3956 return QStringLiteral(
"None" );
3959 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3961 return value.toString();
3968 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
3969 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
3970 if ( mMax < std::numeric_limits<double>::max() )
3971 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
3973 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
3974 QString extra = parts.join( QLatin1String(
"<br />" ) );
3975 if ( !extra.isEmpty() )
3976 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
3982 switch ( outputType )
3986 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', '%2'" ).arg(
name(),
description() );
3988 code += QLatin1String(
", optional=True" );
3990 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
3992 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
3993 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
3994 if ( mMax != std::numeric_limits<double>::max() )
3995 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4037 map.insert( QStringLiteral(
"min" ), mMin );
4038 map.insert( QStringLiteral(
"max" ), mMax );
4039 map.insert( QStringLiteral(
"data_type" ), mDataType );
4046 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4047 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4048 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4055 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4072 if ( !input.isValid() )
4080 if ( input.type() == QVariant::String )
4082 QStringList list = input.toString().split(
',' );
4083 if ( list.count() != 2 )
4086 list.at( 0 ).toDouble( &ok );
4088 list.at( 1 ).toDouble( &ok2 );
4093 else if ( input.type() == QVariant::List )
4095 if ( input.toList().count() != 2 )
4099 input.toList().at( 0 ).toDouble( &ok );
4101 input.toList().at( 1 ).toDouble( &ok2 );
4112 if ( !value.isValid() )
4113 return QStringLiteral(
"None" );
4116 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4119 p.insert(
name(), value );
4122 QStringList stringParts;
4123 const auto constParts = parts;
4124 for (
double v : constParts )
4126 stringParts << QString::number( v );
4128 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4133 switch ( outputType )
4137 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', '%2'" ).arg(
name(),
description() );
4139 code += QLatin1String(
", optional=True" );
4141 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4164 map.insert( QStringLiteral(
"data_type" ), mDataType );
4178 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4194 if ( !input.isValid() )
4202 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4205 if ( input.type() != QVariant::String || input.toString().isEmpty() )
4223 if ( !val.isValid() )
4224 return QStringLiteral(
"None" );
4230 p.insert(
name(), val );
4248 , mOptions( options )
4249 , mAllowMultiple( allowMultiple )
4250 , mUsesStaticStrings( usesStaticStrings )
4262 QVariant input = value;
4263 if ( !input.isValid() )
4276 if ( mUsesStaticStrings )
4278 if ( input.type() == QVariant::List )
4280 if ( !mAllowMultiple )
4283 const QVariantList values = input.toList();
4287 for (
const QVariant &val : values )
4289 if ( !mOptions.contains( val.toString() ) )
4295 else if ( input.type() == QVariant::StringList )
4297 if ( !mAllowMultiple )
4300 const QStringList values = input.toStringList();
4305 if ( values.count() > 1 && !mAllowMultiple )
4308 for (
const QString &val : values )
4310 if ( !mOptions.contains( val ) )
4315 else if ( input.type() == QVariant::String )
4317 QStringList parts = input.toString().split(
',' );
4318 if ( parts.count() > 1 && !mAllowMultiple )
4321 const auto constParts = parts;
4322 for (
const QString &part : constParts )
4324 if ( !mOptions.contains( part ) )
4332 if ( input.type() == QVariant::List )
4334 if ( !mAllowMultiple )
4337 const QVariantList values = input.toList();
4341 for (
const QVariant &val : values )
4344 int res = val.toInt( &ok );
4347 else if ( res < 0 || res >= mOptions.count() )
4353 else if ( input.type() == QVariant::String )
4355 QStringList parts = input.toString().split(
',' );
4356 if ( parts.count() > 1 && !mAllowMultiple )
4359 const auto constParts = parts;
4360 for (
const QString &part : constParts )
4363 int res = part.toInt( &ok );
4366 else if ( res < 0 || res >= mOptions.count() )
4371 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
4374 int res = input.toInt( &ok );
4377 else if ( res >= 0 && res < mOptions.count() )
4387 if ( !value.isValid() )
4388 return QStringLiteral(
"None" );
4391 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4393 if ( mUsesStaticStrings )
4395 if ( value.type() == QVariant::StringList )
4398 const QStringList constList = value.toStringList();
4399 for (
const QString &val : constList )
4403 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4405 else if ( value.type() == QVariant::String )
4408 const QStringList constList = value.toString().split(
',' );
4409 if ( constList.count() > 1 )
4411 for (
const QString &val : constList )
4415 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4423 if ( value.type() == QVariant::List )
4426 const auto constToList = value.toList();
4427 for (
const QVariant &val : constToList )
4429 parts << QString::number( static_cast< int >( val.toDouble() ) );
4431 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4433 else if ( value.type() == QVariant::String )
4435 QStringList parts = value.toString().split(
',' );
4436 if ( parts.count() > 1 )
4438 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4442 return QString::number(
static_cast< int >( value.toDouble() ) );
4448 if ( !value.isValid() )
4454 if ( mUsesStaticStrings )
4460 if ( value.type() == QVariant::List )
4463 const QVariantList toList = value.toList();
4464 parts.reserve( toList.size() );
4465 for (
const QVariant &val : toList )
4467 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
4469 return parts.join(
',' );
4471 else if ( value.type() == QVariant::String )
4473 const QStringList parts = value.toString().split(
',' );
4474 QStringList comments;
4475 if ( parts.count() > 1 )
4477 for (
const QString &part : parts )
4480 int val = part.toInt( &ok );
4482 comments << mOptions.value( val );
4484 return comments.join(
',' );
4488 return mOptions.value(
static_cast< int >( value.toDouble() ) );
4494 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4496 code += QLatin1String(
"optional " );
4497 code += QLatin1String(
"enum " );
4499 if ( mAllowMultiple )
4500 code += QLatin1String(
"multiple " );
4502 if ( mUsesStaticStrings )
4503 code += QLatin1String(
"static " );
4505 code += mOptions.join(
';' ) +
' ';
4508 return code.trimmed();
4513 switch ( outputType )
4517 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', '%2'" ).arg(
name(),
description() );
4519 code += QLatin1String(
", optional=True" );
4522 options.reserve( mOptions.size() );
4523 for (
const QString &o : mOptions )
4525 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
4527 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4529 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4552 return mAllowMultiple;
4562 return mUsesStaticStrings;
4573 map.insert( QStringLiteral(
"options" ), mOptions );
4574 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
4575 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
4582 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
4583 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
4584 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
4591 QString def = definition;
4593 bool multiple =
false;
4594 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
4600 bool staticStrings =
false;
4601 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
4603 staticStrings =
true;
4607 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
4608 QRegularExpressionMatch m = re.match( def );
4609 QString values = def;
4612 values = m.captured( 1 ).trimmed();
4613 defaultVal = m.captured( 2 );
4621 , mMultiLine( multiLine )
4633 if ( !value.isValid() || value.isNull() )
4634 return QStringLiteral(
"None" );
4637 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4639 QString s = value.toString();
4645 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4647 code += QLatin1String(
"optional " );
4648 code += QLatin1String(
"string " );
4651 code += QLatin1String(
"long " );
4654 return code.trimmed();
4659 switch ( outputType )
4663 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', '%2'" ).arg(
name(),
description() );
4665 code += QLatin1String(
", optional=True" );
4666 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4689 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
4696 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
4702 QString def = definition;
4704 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
4710 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
4712 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
4716 if ( def == QLatin1String(
"None" ) )
4739 if ( !value.isValid() )
4740 return QStringLiteral(
"None" );
4742 QString s = value.toString();
4748 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4750 code += QLatin1String(
"optional " );
4751 code += QLatin1String(
"authcfg " );
4754 return code.trimmed();
4759 QString def = definition;
4761 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
4763 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
4767 if ( def == QLatin1String(
"None" ) )
4780 , mParentLayerParameterName( parentLayerParameterName )
4792 if ( !value.isValid() )
4793 return QStringLiteral(
"None" );
4796 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4798 QString s = value.toString();
4804 QStringList depends;
4805 if ( !mParentLayerParameterName.isEmpty() )
4806 depends << mParentLayerParameterName;
4812 switch ( outputType )
4816 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', '%2'" ).arg(
name(),
description() );
4818 code += QLatin1String(
", optional=True" );
4820 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4832 return mParentLayerParameterName;
4843 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4850 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4891 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
4894 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4912 if ( !val.isValid() )
4913 return QStringLiteral(
"None" );
4919 p.insert(
name(), val );
4927 switch ( outputType )
4931 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', '%2'" ).arg(
name(),
description() );
4933 code += QLatin1String(
", optional=True" );
4937 QStringList options;
4940 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
4974 map.insert( QStringLiteral(
"data_types" ), types );
4982 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
4983 for (
const QVariant &val : values )
4996 const QString &description,
4997 const QVariant &defaultValue,
5029 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5032 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5050 if ( !val.isValid() )
5051 return QStringLiteral(
"None" );
5057 p.insert(
name(), val );
5075 , mParentLayerParameterName( parentLayerParameterName )
5077 , mAllowMultiple( allowMultiple )
5078 , mDefaultToAllFields( defaultToAllFields )
5091 if ( !input.isValid() )
5099 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5101 if ( !mAllowMultiple )
5107 else if ( input.type() == QVariant::String )
5109 if ( input.toString().isEmpty() )
5112 QStringList parts = input.toString().split(
';' );
5113 if ( parts.count() > 1 && !mAllowMultiple )
5118 if ( input.toString().isEmpty() )
5126 if ( !value.isValid() )
5127 return QStringLiteral(
"None" );
5130 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5132 if ( value.type() == QVariant::List )
5135 const auto constToList = value.toList();
5136 for (
const QVariant &val : constToList )
5140 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5142 else if ( value.type() == QVariant::StringList )
5145 const auto constToStringList = value.toStringList();
5146 for ( QString s : constToStringList )
5150 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5158 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5160 code += QLatin1String(
"optional " );
5161 code += QLatin1String(
"field " );
5163 switch ( mDataType )
5166 code += QLatin1String(
"numeric " );
5170 code += QLatin1String(
"string " );
5174 code += QLatin1String(
"datetime " );
5181 if ( mAllowMultiple )
5182 code += QLatin1String(
"multiple " );
5184 if ( mDefaultToAllFields )
5185 code += QLatin1String(
"default_to_all_fields " );
5187 code += mParentLayerParameterName +
' ';
5190 return code.trimmed();
5195 switch ( outputType )
5199 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', '%2'" ).arg(
name(),
description() );
5201 code += QLatin1String(
", optional=True" );
5204 switch ( mDataType )
5207 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
5211 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
5215 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
5219 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
5222 code += QStringLiteral(
", type=%1" ).arg(
dataType );
5224 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5225 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5229 if ( mDefaultToAllFields )
5230 code += QLatin1String(
", defaultToAllFields=True" );
5242 QStringList depends;
5243 if ( !mParentLayerParameterName.isEmpty() )
5244 depends << mParentLayerParameterName;
5250 return mParentLayerParameterName;
5270 return mAllowMultiple;
5280 return mDefaultToAllFields;
5285 mDefaultToAllFields = enabled;
5291 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5292 map.insert( QStringLiteral(
"data_type" ), mDataType );
5293 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5294 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
5301 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5302 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
5303 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5304 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
5314 QString def = definition;
5316 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
5321 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
5326 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
5332 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5335 def = def.mid( 8 ).trimmed();
5338 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
5341 def = def.mid( 21 ).trimmed();
5344 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5345 QRegularExpressionMatch m = re.match( def );
5348 parent = m.captured( 1 ).trimmed();
5349 def = m.captured( 2 );
5374 QVariant var = input;
5375 if ( !var.isValid() )
5402 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
5407 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5425 if ( !value.isValid() )
5426 return QStringLiteral(
"None" );
5429 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5434 QString geometryCheckString;
5438 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
5442 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
5446 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
5452 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagOverrideDefaultGeometryCheck )
5453 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
5454 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagCreateIndividualOutputPerInputFeature )
5455 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
5456 if ( !
flags.empty() )
5457 flagString =
flags.join( QLatin1String(
" | " ) );
5464 layerString = layer->source();
5468 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" ).arg( layerString,
5471 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
5472 geometryCheckString );
5483 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" )
5487 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
5488 geometryCheckString );
5492 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
5496 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
5501 QString layerString = value.toString();
5505 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
5512 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5514 code += QLatin1String(
"optional " );
5515 code += QLatin1String(
"source " );
5522 code += QLatin1String(
"point " );
5526 code += QLatin1String(
"line " );
5530 code += QLatin1String(
"polygon " );
5537 return code.trimmed();
5542 switch ( outputType )
5546 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', '%2'" ).arg(
name(),
description() );
5548 code += QLatin1String(
", optional=True" );
5552 QStringList options;
5556 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5573 : mDataTypes( types )
5586 map.insert( QStringLiteral(
"data_types" ), types );
5594 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5595 for (
const QVariant &val : values )
5605 QString def = definition;
5608 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5614 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5620 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5635 , mSupportsAppend( supportsAppend )
5646 QVariant var = input;
5647 if ( !var.isValid() )
5669 if ( var.type() != QVariant::String )
5672 if ( var.toString().isEmpty() )
5680 if ( !value.isValid() )
5681 return QStringLiteral(
"None" );
5684 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5695 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5704 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5706 code += QLatin1String(
"optional " );
5707 code += QLatin1String(
"sink " );
5709 switch ( mDataType )
5712 code += QLatin1String(
"point " );
5716 code += QLatin1String(
"line " );
5720 code += QLatin1String(
"polygon " );
5724 code += QLatin1String(
"table " );
5732 return code.trimmed();
5744 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
5748 return p->defaultVectorFileExtension(
hasGeometry() );
5758 return QStringLiteral(
"dbf" );
5765 switch ( outputType )
5769 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', '%2'" ).arg(
name(),
description() );
5771 code += QLatin1String(
", optional=True" );
5775 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5776 if ( mSupportsAppend )
5777 code += QLatin1String(
", supportsAppend=True" );
5790 QStringList filters;
5791 for (
const QString &ext : exts )
5793 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5795 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
5804 return lOriginalProvider->supportedOutputVectorLayerExtensions();
5806 return lOriginalProvider->supportedOutputTableExtensions();
5811 return p->supportedOutputVectorLayerExtensions();
5813 return p->supportedOutputTableExtensions();
5828 switch ( mDataType )
5854 map.insert( QStringLiteral(
"data_type" ), mDataType );
5855 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
5863 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
5870 return QStringLiteral(
"memory:%1" ).arg(
description() );
5878 QString def = definition;
5879 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5884 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5889 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5894 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
5905 return mSupportsAppend;
5925 QVariant var = input;
5926 if ( !var.isValid() )
5948 if ( var.type() != QVariant::String )
5951 if ( var.toString().isEmpty() )
5959 if ( !value.isValid() )
5960 return QStringLiteral(
"None" );
5963 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5974 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5990 return lOriginalProvider->defaultRasterFileExtension();
5994 return p->defaultRasterFileExtension();
6005 QStringList filters;
6006 for (
const QString &ext : exts )
6008 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6010 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6017 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6021 return p->supportedOutputRasterLayerExtensions();
6037 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6049 QVariant var = input;
6050 if ( !var.isValid() )
6072 if ( var.type() != QVariant::String )
6075 if ( var.toString().isEmpty() )
6085 if ( !value.isValid() )
6086 return QStringLiteral(
"None" );
6089 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6100 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6109 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6121 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6122 return QStringLiteral(
"file" );
6125 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6126 QRegularExpressionMatch match = rx.match( mFileFilter );
6127 if ( !match.hasMatch() )
6128 return QStringLiteral(
"file" );
6130 return match.captured( 1 );
6135 switch ( outputType )
6139 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', '%2'" ).arg(
name(),
description() );
6141 code += QLatin1String(
", optional=True" );
6145 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6157 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
6173 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
6180 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
6201 QVariant var = input;
6202 if ( !var.isValid() )
6218 if ( var.type() != QVariant::String )
6221 if ( var.toString().isEmpty() )
6244 , mCreateByDefault( createByDefault )
6252 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
6253 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
6260 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
6261 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
6267 switch ( outputType )
6274 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
6276 code += QLatin1String(
", optional=True" );
6278 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6293 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
6300 QRegularExpression rx( QStringLiteral(
"[.]" ) );
6301 QString sanitizedName =
name();
6302 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
6317 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
6326 return mCreateByDefault;
6348 QVariant var = input;
6349 if ( !var.isValid() )
6371 if ( var.type() != QVariant::String )
6374 if ( var.toString().isEmpty() )
6382 if ( !value.isValid() )
6383 return QStringLiteral(
"None" );
6386 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6397 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6406 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6408 code += QLatin1String(
"optional " );
6409 code += QLatin1String(
"vectorDestination " );
6411 switch ( mDataType )
6414 code += QLatin1String(
"point " );
6418 code += QLatin1String(
"line " );
6422 code += QLatin1String(
"polygon " );
6430 return code.trimmed();
6442 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6446 return p->defaultVectorFileExtension(
hasGeometry() );
6456 return QStringLiteral(
"dbf" );
6463 switch ( outputType )
6467 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', '%2'" ).arg(
name(),
description() );
6469 code += QLatin1String(
", optional=True" );
6473 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6486 QStringList filters;
6487 for (
const QString &ext : exts )
6489 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6491 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6499 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6501 return lOriginalProvider->supportedOutputTableExtensions();
6506 return p->supportedOutputVectorLayerExtensions();
6508 return p->supportedOutputTableExtensions();
6523 switch ( mDataType )
6549 map.insert( QStringLiteral(
"data_type" ), mDataType );
6563 QString def = definition;
6564 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6569 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6574 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6585 , mParentLayerParameterName( parentLayerParameterName )
6586 , mAllowMultiple( allowMultiple )
6598 if ( !input.isValid() )
6606 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
6608 if ( !mAllowMultiple )
6617 double res = input.toInt( &ok );
6627 return mAllowMultiple;
6637 if ( !value.isValid() )
6638 return QStringLiteral(
"None" );
6641 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6643 if ( value.type() == QVariant::List )
6646 QVariantList values = value.toList();
6647 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
6649 parts << QString::number( static_cast< int >( it->toDouble() ) );
6651 return parts.join(
',' ).prepend(
'[' ).append(
']' );
6653 else if ( value.type() == QVariant::StringList )
6656 QStringList values = value.toStringList();
6657 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
6659 parts << QString::number( static_cast< int >( it->toDouble() ) );
6661 return parts.join(
',' ).prepend(
'[' ).append(
']' );
6664 return value.toString();
6669 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6671 code += QLatin1String(
"optional " );
6672 code += QLatin1String(
"band " );
6674 if ( mAllowMultiple )
6675 code += QLatin1String(
"multiple " );
6677 code += mParentLayerParameterName +
' ';
6680 return code.trimmed();
6685 QStringList depends;
6686 if ( !mParentLayerParameterName.isEmpty() )
6687 depends << mParentLayerParameterName;
6693 switch ( outputType )
6697 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', '%2'" ).arg(
name(),
description() );
6699 code += QLatin1String(
", optional=True" );
6701 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
6702 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6714 return mParentLayerParameterName;
6725 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6726 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6733 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6734 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6741 QString def = definition;
6744 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6747 def = def.mid( 8 ).trimmed();
6750 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6751 QRegularExpressionMatch m = re.match( def );
6754 parent = m.captured( 1 ).trimmed();
6755 def = m.captured( 2 );
6772 , mParentParameterName( parentParameterName )
6789 QStringList depends;
6790 if ( !mParentParameterName.isEmpty() )
6791 depends << mParentParameterName;
6797 switch ( outputType )
6801 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', '%2'" ).arg(
name(),
description() );
6803 code += QLatin1String(
", optional=True" );
6805 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
6807 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
6808 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
6809 if (
maximum() != std::numeric_limits<double>::max() )
6810 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
6821 return mParentParameterName;
6832 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
6833 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
6840 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
6868 switch ( outputType )
6872 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', '%2'" ).arg(
name(),
description() );
6874 code += QLatin1String(
", optional=True" );
6886 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
6905 if ( !value.isValid() || value.isNull() )
6906 return QStringLiteral(
"None" );
6909 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6911 QString s = value.toString();
6917 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6919 code += QLatin1String(
"optional " );
6920 code += QLatin1String(
"layout " );
6923 return code.trimmed();
6928 switch ( outputType )
6932 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', '%2'" ).arg(
name(),
description() );
6934 code += QLatin1String(
", optional=True" );
6945 QString def = definition;
6947 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6949 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6953 if ( def == QLatin1String(
"None" ) )
6966 , mParentLayoutParameterName( parentLayoutParameterName )
6967 , mItemType( itemType )
6979 if ( !value.isValid() || value.isNull() )
6980 return QStringLiteral(
"None" );
6983 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6985 QString s = value.toString();
6991 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6993 code += QLatin1String(
"optional " );
6994 code += QLatin1String(
"layoutitem " );
6995 if ( mItemType >= 0 )
6996 code += QString::number( mItemType ) +
' ';
6998 code += mParentLayoutParameterName +
' ';
7001 return code.trimmed();
7006 switch ( outputType )
7010 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', '%2'" ).arg(
name(),
description() );
7012 code += QLatin1String(
", optional=True" );
7014 if ( mItemType >= 0 )
7015 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
7017 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
7030 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
7031 map.insert( QStringLiteral(
"item_type" ), mItemType );
7038 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
7039 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
7045 QStringList depends;
7046 if ( !mParentLayoutParameterName.isEmpty() )
7047 depends << mParentLayoutParameterName;
7054 QString def = definition;
7056 QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
7057 QRegularExpressionMatch m = re.match( def );
7060 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
7061 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
7062 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
7075 return mParentLayoutParameterName;
7080 mParentLayoutParameterName =
name;
7099 , mAllowOpacity( opacityEnabled )
7111 if ( !value.isValid() || value.isNull() )
7112 return QStringLiteral(
"None" );
7115 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7117 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
7118 return QStringLiteral(
"QColor()" );
7120 if ( value.canConvert< QColor >() )
7122 QColor
c = value.value< QColor >();
7123 if ( !mAllowOpacity ||
c.alpha() == 255 )
7124 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
7126 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
7129 QString s = value.toString();
7135 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7137 code += QLatin1String(
"optional " );
7138 code += QLatin1String(
"color " );
7140 if ( mAllowOpacity )
7141 code += QLatin1String(
"withopacity " );
7144 return code.trimmed();
7149 switch ( outputType )
7153 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', '%2'" ).arg(
name(),
description() );
7155 code += QLatin1String(
", optional=True" );
7157 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7169 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
7172 if ( !input.isValid() )
7175 if ( input.type() == QVariant::Color )
7184 if ( input.type() != QVariant::String || input.toString().isEmpty() )
7187 bool containsAlpha =
false;
7194 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
7201 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
7207 return mAllowOpacity;
7212 mAllowOpacity = enabled;
7217 QString def = definition;
7219 bool allowOpacity =
false;
7220 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
7222 allowOpacity =
true;
7223 def = def.mid( 12 );
7226 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7228 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7232 if ( def == QLatin1String(
"None" ) )
7243 , mSourceParameterName( sourceCrsParameterName )
7244 , mDestParameterName( destinationCrsParameterName )
7245 , mSourceCrs( staticSourceCrs )
7246 , mDestCrs( staticDestinationCrs )
7258 if ( !value.isValid() || value.isNull() )
7259 return QStringLiteral(
"None" );
7264 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
7270 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7273 p.insert(
name(), value );
7278 QString s = value.toString();
7284 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7286 code += QLatin1String(
"optional " );
7287 code += QLatin1String(
"coordinateoperation " );
7290 return code.trimmed();
7295 switch ( outputType )
7300 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', '%2'" ).arg(
name(),
description() );
7302 code += QLatin1String(
", optional=True" );
7303 if ( !mSourceParameterName.isEmpty() )
7304 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
7305 if ( !mDestParameterName.isEmpty() )
7306 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
7308 if ( mSourceCrs.isValid() )
7310 if ( mDestCrs.isValid() )
7311 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
7323 if ( !mSourceParameterName.isEmpty() )
7324 res << mSourceParameterName;
7325 if ( !mDestParameterName.isEmpty() )
7326 res << mDestParameterName;
7333 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
7334 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
7335 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
7336 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
7343 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
7344 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
7345 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
7346 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
7352 QString def = definition;
7354 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7356 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7360 if ( def == QLatin1String(
"None" ) )
7385 if ( !input.isValid() && !
mDefault.isValid() )
7388 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7389 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7397 if ( !value.isValid() )
7398 return QStringLiteral(
"None" );
7401 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7408 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7410 code += QLatin1String(
"optional " );
7411 code += QLatin1String(
"maptheme " );
7414 return code.trimmed();
7419 switch ( outputType )
7423 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', '%2'" ).arg(
name(),
description() );
7425 code += QLatin1String(
", optional=True" );
7452 QString def = definition;
7453 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7455 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7477 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
7479 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
7490 QVariant input = value;
7491 if ( !input.isValid() )
7504 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
7507 if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType ==
Time )
7510 if ( input.type() == QVariant::String )
7512 QString s = input.toString();
7516 input = QDateTime::fromString( s, Qt::ISODate );
7517 if ( mDataType ==
Time )
7519 if ( !input.toDateTime().isValid() )
7520 input = QTime::fromString( s );
7522 input = input.toDateTime().time();
7526 if ( mDataType !=
Time )
7528 QDateTime res = input.toDateTime();
7529 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
7533 QTime res = input.toTime();
7534 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
7540 if ( !value.isValid() )
7541 return QStringLiteral(
"None" );
7544 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7546 if ( value.type() == QVariant::DateTime )
7548 const QDateTime dt = value.toDateTime();
7549 if ( !dt.isValid() )
7550 return QStringLiteral(
"QDateTime()" );
7552 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
7553 .arg( dt.date().month() )
7554 .arg( dt.date().day() )
7555 .arg( dt.time().hour() )
7556 .arg( dt.time().minute() )
7557 .arg( dt.time().second() );
7559 else if ( value.type() == QVariant::Date )
7561 const QDate dt = value.toDate();
7562 if ( !dt.isValid() )
7563 return QStringLiteral(
"QDate()" );
7565 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
7569 else if ( value.type() == QVariant::Time )
7571 const QTime dt = value.toTime();
7572 if ( !dt.isValid() )
7573 return QStringLiteral(
"QTime()" );
7575 return QStringLiteral(
"QTime(%4, %5, %6)" )
7578 .arg( dt.second() );
7580 return value.toString();
7587 if ( mMin.isValid() )
7588 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
7589 if ( mMax.isValid() )
7590 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
7592 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
DateTime ?
mDefault.toDateTime().toString( Qt::ISODate ) :
7593 ( mDataType ==
Date ?
mDefault.toDate().toString( Qt::ISODate ) :
mDefault.toTime( ).toString() ) );
7594 QString extra = parts.join( QLatin1String(
"<br />" ) );
7595 if ( !extra.isEmpty() )
7596 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
7602 switch ( outputType )
7606 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', '%2'" ).arg(
name(),
description() );
7608 code += QLatin1String(
", optional=True" );
7610 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
DateTime ? QStringLiteral(
"QgsProcessingParameterDateTime.DateTime" )
7611 : mDataType ==
Date ? QStringLiteral(
"QgsProcessingParameterDateTime.Date" )
7612 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
7615 if ( mMin.isValid() )
7617 if ( mMax.isValid() )
7659 map.insert( QStringLiteral(
"min" ), mMin );
7660 map.insert( QStringLiteral(
"max" ), mMax );
7661 map.insert( QStringLiteral(
"data_type" ), mDataType );
7668 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
7669 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
7670 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
7677 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7688 , mProviderId( provider )
7701 if ( !input.isValid() && !
mDefault.isValid() )
7704 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7705 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7713 if ( !value.isValid() )
7714 return QStringLiteral(
"None" );
7717 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7724 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7726 code += QLatin1String(
"optional " );
7727 code += QLatin1String(
"providerconnection " );
7728 code += mProviderId +
' ';
7731 return code.trimmed();
7736 switch ( outputType )
7740 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', '%2', '%3'" ).arg(
name(),
description(), mProviderId );
7742 code += QLatin1String(
", optional=True" );
7756 map.insert( QStringLiteral(
"provider" ), mProviderId );
7763 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
7771 QString def = definition;
7773 if ( def.contains(
' ' ) )
7775 provider = def.left( def.indexOf(
' ' ) );
7776 def = def.mid( def.indexOf(
' ' ) + 1 );
7784 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7786 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7804 , mParentConnectionParameterName( parentLayerParameterName )
7817 if ( !input.isValid() && !
mDefault.isValid() )
7820 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7821 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7829 if ( !value.isValid() )
7830 return QStringLiteral(
"None" );
7833 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7840 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7842 code += QLatin1String(
"optional " );
7843 code += QLatin1String(
"databaseschema " );
7845 code += mParentConnectionParameterName +
' ';
7848 return code.trimmed();
7853 switch ( outputType )
7857 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', '%2'" ).arg(
name(),
description() );
7859 code += QLatin1String(
", optional=True" );
7861 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7875 QStringList depends;
7876 if ( !mParentConnectionParameterName.isEmpty() )
7877 depends << mParentConnectionParameterName;
7883 return mParentConnectionParameterName;
7888 mParentConnectionParameterName =
name;
7894 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
7901 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
7908 QString def = definition;
7910 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7911 QRegularExpressionMatch m = re.match( def );
7914 parent = m.captured( 1 ).trimmed();
7915 def = m.captured( 2 );
7931 const QString &connectionParameterName,
7932 const QString &schemaParameterName,
7933 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
7935 , mParentConnectionParameterName( connectionParameterName )
7936 , mParentSchemaParameterName( schemaParameterName )
7937 , mAllowNewTableNames( allowNewTableNames )
7950 if ( !input.isValid() && !
mDefault.isValid() )
7953 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7954 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7962 if ( !value.isValid() )
7963 return QStringLiteral(
"None" );
7966 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7973 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7975 code += QLatin1String(
"optional " );
7976 code += QLatin1String(
"databasetable " );
7978 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
7979 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
7982 return code.trimmed();
7987 switch ( outputType )
7991 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', '%2'" ).arg(
name(),
description() );
7993 code += QLatin1String(
", optional=True" );
7995 if ( mAllowNewTableNames )
7996 code += QLatin1String(
", allowNewTableNames=True" );
7998 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7999 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
8013 QStringList depends;
8014 if ( !mParentConnectionParameterName.isEmpty() )
8015 depends << mParentConnectionParameterName;
8016 if ( !mParentSchemaParameterName.isEmpty() )
8017 depends << mParentSchemaParameterName;
8023 return mParentConnectionParameterName;
8028 mParentConnectionParameterName =
name;
8033 return mParentSchemaParameterName;
8038 mParentSchemaParameterName =
name;
8044 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8045 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
8046 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
8053 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8054 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
8055 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
8063 QString def = definition;
8065 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
8066 QRegularExpressionMatch m = re.match( def );
8069 connection = m.captured( 1 ).trimmed();
8070 if ( connection == QLatin1String(
"none" ) )
8072 schema = m.captured( 2 ).trimmed();
8073 if ( schema == QLatin1String(
"none" ) )
8075 def = m.captured( 3 );
8083 return mAllowNewTableNames;
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString authid() const
Returns the authority identifier for the CRS.
@ 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 QString addExtensionFromFilter(const QString &fileName, const QString &filter)
Ensures that a fileName ends with an extension from the specified 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) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
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) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
QgsWkbTypes::GeometryType type
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QString lastError() const SIP_HOLDGIL
Returns an error string referring to the last error encountered either when this geometry was created...
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
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
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).
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.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
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.
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...
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 raster layer output for processing algorithms.
A vector layer output for processing algorithms.
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.
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.
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.
QVariant defaultValue() const
Returns the default value for the parameter.
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...
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.
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.
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.
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.
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.
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 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.
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 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.
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.
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
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.
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 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 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.
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.
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.
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 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 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.
@ Vector
Vector layer type.
@ Mesh
Mesh layer type, since QGIS 3.6.
@ Raster
Raster layer type.
@ UnknownType
Unknown layer type.
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 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 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.
@ TypeVectorLine
Vector line layers.
@ TypeMapLayer
Any map layer type (raster or vector or mesh)
@ TypeVectorPolygon
Vector polygon layers.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
@ 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,...
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.
@ StaticProperty
Static property (QgsStaticProperty)
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.
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 yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
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.
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