41#include <QRegularExpression>
49 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
50 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
51 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
59 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
60 flags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ), 0 ).toInt() );
73 mRemappingDefinition = definition;
80 map.insert( QStringLiteral(
"create_options" ),
createOptions );
82 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
89 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
90 if ( map.contains( QStringLiteral(
"remapping" ) ) )
97 mUseRemapping =
false;
105 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
110 return !( *
this == other );
115 const QVariant val = parameters.value( name );
116 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
135 QVariant val = value;
136 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
139 if ( !val.isValid() )
148 return destParam->generateTemporaryDestination();
151 return val.toString();
167 const QVariant val = value;
168 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
171 if ( val.isValid() && !val.toString().isEmpty() )
175 return val.toString();
195 QVariant val = value;
196 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
200 const double res = val.toDouble( &ok );
206 return val.toDouble();
222 QVariant val = value;
223 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
227 double dbl = val.toDouble( &ok );
232 dbl = val.toDouble( &ok );
239 const double round = std::round( dbl );
240 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
245 return static_cast< int >( std::round( dbl ) );
254 return QList< int >();
262 return QList< int >();
264 QList< int > resultList;
265 const QVariant val = value;
268 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
270 else if ( val.type() == QVariant::List )
272 const QVariantList list = val.toList();
273 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
274 resultList << it->toInt();
278 const QStringList parts = val.toString().split(
';' );
279 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
280 resultList << it->toInt();
284 if ( resultList.isEmpty() )
289 if ( definition->
defaultValue().type() == QVariant::List )
291 const QVariantList list = definition->
defaultValue().toList();
292 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
293 resultList << it->toInt();
297 const QStringList parts = definition->
defaultValue().toString().split(
';' );
298 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
299 resultList << it->toInt();
320 QVariant val = value;
321 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
324 QDateTime d = val.toDateTime();
325 if ( !d.isValid() && val.type() == QVariant::String )
327 d = QDateTime::fromString( val.toString() );
334 d = val.toDateTime();
336 if ( !d.isValid() && val.type() == QVariant::String )
338 d = QDateTime::fromString( val.toString() );
357 QVariant val = value;
358 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
361 QDate d = val.toDate();
362 if ( !d.isValid() && val.type() == QVariant::String )
364 d = QDate::fromString( val.toString() );
373 if ( !d.isValid() && val.type() == QVariant::String )
375 d = QDate::fromString( val.toString() );
394 QVariant val = value;
395 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
400 if ( val.type() == QVariant::DateTime )
401 d = val.toDateTime().time();
405 if ( !d.isValid() && val.type() == QVariant::String )
407 d = QTime::fromString( val.toString() );
416 if ( !d.isValid() && val.type() == QVariant::String )
418 d = QTime::fromString( val.toString() );
439 if ( enumDef && val >= enumDef->
options().size() )
459 QVariantList resultList;
460 const QVariant val = value;
461 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
463 else if ( val.type() == QVariant::List )
465 const auto constToList = val.toList();
466 for (
const QVariant &var : constToList )
469 else if ( val.type() == QVariant::String )
471 const auto constSplit = val.toString().split(
',' );
472 for (
const QString &var : constSplit )
478 if ( resultList.isEmpty() )
479 return QList< int >();
481 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
485 if ( definition->
defaultValue().type() == QVariant::List )
487 const auto constToList = definition->
defaultValue().toList();
488 for (
const QVariant &var : constToList )
491 else if ( definition->
defaultValue().type() == QVariant::String )
493 const auto constSplit = definition->
defaultValue().toString().split(
',' );
494 for (
const QString &var : constSplit )
503 const auto constResultList = resultList;
504 for (
const QVariant &var : constResultList )
506 const int resInt = var.toInt();
507 if ( !enumDef || resInt < enumDef->options().size() )
530 if ( enumText.isEmpty() || !enumDef->
options().contains( enumText ) )
539 return QStringList();
547 return QStringList();
549 const QVariant val = value;
551 QStringList enumValues;
553 std::function< void(
const QVariant &var ) > processVariant;
554 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
556 if ( var.type() == QVariant::List )
558 const auto constToList = var.toList();
559 for (
const QVariant &listVar : constToList )
561 processVariant( listVar );
564 else if ( var.type() == QVariant::StringList )
566 const auto constToStringList = var.toStringList();
567 for (
const QString &s : constToStringList )
572 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
576 const QStringList parts = var.toString().split(
',' );
577 for (
const QString &s : parts )
584 processVariant( val );
590 const QStringList options = enumDef->
options();
591 const QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
593 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
625 const QVariant val = value;
626 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
628 else if ( val.isValid() )
641 const QVariant val = value;
642 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
644 else if ( val.isValid() )
652 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
653 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
658 val = parameters.value( definition->
name() );
661 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
664QgsFeatureSink *
QgsProcessingParameters::parameterAsSink(
const QgsProcessingParameterDefinition *definition,
const QVariant &value,
const QgsFields &fields,
QgsWkbTypes::Type geometryType,
const QgsCoordinateReferenceSystem &
crs,
QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
666 QVariantMap options = createOptions;
667 QVariant val = value;
672 bool useRemapDefinition =
false;
673 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
684 useRemapDefinition =
true;
690 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
694 else if ( !val.isValid() || val.toString().isEmpty() )
710 dest = val.toString();
715 dest = destParam->generateTemporaryDestination();
718 if ( dest.isEmpty() )
721 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition :
nullptr ) );
722 destinationIdentifier = dest;
724 if ( destinationProject )
726 if ( destName.isEmpty() && definition )
732 outputName = definition->
name();
736 return sink.release();
760 QVariant val = parameters.value( definition->
name() );
762 bool selectedFeaturesOnly =
false;
763 long long featureLimit = -1;
764 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
772 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
779 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
785 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
790 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
794 else if ( !val.isValid() || val.toString().isEmpty() )
800 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
806 layerRef = val.toString();
811 if ( layerRef.isEmpty() )
823 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit );
826 compatibleFormats, preferredFormat, context, feedback, featureLimit );
836 QString *destLayer = layerName;
851 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint );
859 QVariant val = value;
860 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
865 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
870 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
882 if ( !val.isValid() || val.toString().isEmpty() )
888 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
893 QString layerRef = val.toString();
894 if ( layerRef.isEmpty() )
897 if ( layerRef.isEmpty() )
928 val = parameters.value( definition->
name() );
935 QVariant val = value;
939 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
949 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
953 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
960 dest = val.toString();
965 dest = destParam->generateTemporaryDestination();
968 if ( destinationProject )
971 if ( destName.isEmpty() && definition )
976 outputName = definition->
name();
997 val = parameters.value( definition->
name() );
1004 QVariant val = value;
1006 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1014 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
1018 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1025 dest = val.toString();
1030 dest = destParam->generateTemporaryDestination();
1050 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1075 QVariant val = value;
1077 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1081 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1087 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1106 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1112 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1125 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1128 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1131 rectText = val.toString();
1133 if ( rectText.isEmpty() && !layer )
1136 const QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1137 const QRegularExpressionMatch match = rx.match( rectText );
1138 if ( match.hasMatch() )
1140 bool xMinOk =
false;
1141 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1142 bool xMaxOk =
false;
1143 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1144 bool yMinOk =
false;
1145 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1146 bool yMaxOk =
false;
1147 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1148 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1199 QVariant val = parameters.value( definition->
name() );
1201 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1207 g = g.densifyByCount( 20 );
1221 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1227 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1240 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1243 rectText = val.toString();
1245 if ( !rectText.isEmpty() )
1247 const QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1248 const QRegularExpressionMatch match = rx.match( rectText );
1249 if ( match.hasMatch() )
1251 bool xMinOk =
false;
1252 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1253 bool xMaxOk =
false;
1254 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1255 bool yMinOk =
false;
1256 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1257 bool yMaxOk =
false;
1258 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1259 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1285 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1314 const QVariant val = parameters.value( definition->
name() );
1320 QVariant val = value;
1321 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1330 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1336 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1348 QString valueAsString;
1349 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1352 valueAsString = val.toString();
1354 const QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1356 const QRegularExpressionMatch match = rx.match( valueAsString );
1357 if ( match.hasMatch() )
1364 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1370 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1383 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1384 return layer->crs();
1386 return layer->crs();
1388 if (
auto *lProject = context.
project() )
1389 return lProject->crs();
1407 const QVariant val = value;
1408 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1412 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1418 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1437 if ( pointText.isEmpty() )
1440 if ( pointText.isEmpty() )
1443 const QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1446 const QRegularExpressionMatch match = rx.match( valueAsString );
1447 if ( match.hasMatch() )
1450 const double x = match.captured( 1 ).toDouble( &xOk );
1452 const double y = match.captured( 2 ).toDouble( &yOk );
1480 const QVariant val = parameters.value( definition->
name() );
1486 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1495 const QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1498 const QRegularExpressionMatch match = rx.match( valueAsString );
1499 if ( match.hasMatch() )
1506 if (
auto *lProject = context.
project() )
1507 return lProject->crs();
1525 const QVariant val = value;
1526 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1531 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1536 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1541 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1559 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1565 g = g.densifyByCount( 20 );
1579 if ( val.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1598 if ( valueAsString.isEmpty() )
1601 if ( valueAsString.isEmpty() )
1604 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1606 const QRegularExpressionMatch match = rx.match( valueAsString );
1607 if ( match.hasMatch() )
1634 const QVariant val = parameters.value( definition->
name() );
1640 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1649 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1658 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1668 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1671 const QRegularExpressionMatch match = rx.match( valueAsString );
1672 if ( match.hasMatch() )
1679 if (
auto *lProject = context.
project() )
1680 return lProject->crs();
1691 if ( fileText.isEmpty() )
1702 if ( fileText.isEmpty() )
1710 return QVariantList();
1718 return QVariantList();
1720 QString resultString;
1721 const QVariant val = value;
1722 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1724 else if ( val.type() == QVariant::List )
1725 return val.toList();
1727 resultString = val.toString();
1729 if ( resultString.isEmpty() )
1732 if ( definition->
defaultValue().type() == QVariant::List )
1738 QVariantList result;
1739 const auto constSplit = resultString.split(
',' );
1742 for (
const QString &s : constSplit )
1744 number = s.toDouble( &ok );
1745 result << ( ok ? QVariant( number ) : s );
1754 return QList<QgsMapLayer *>();
1762 return QList<QgsMapLayer *>();
1764 const QVariant val = value;
1765 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1767 return QList<QgsMapLayer *>() << layer;
1770 QList<QgsMapLayer *> layers;
1772 std::function< void(
const QVariant &var ) > processVariant;
1773 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1775 if ( var.type() == QVariant::List )
1777 const auto constToList = var.toList();
1778 for (
const QVariant &listVar : constToList )
1780 processVariant( listVar );
1783 else if ( var.type() == QVariant::StringList )
1785 const auto constToStringList = var.toStringList();
1786 for (
const QString &s : constToStringList )
1788 processVariant( s );
1791 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1793 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1797 const QVariant sink = fromVar.
sink;
1798 if ( sink.userType() == QMetaType::type(
"QgsProperty" ) )
1803 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1815 processVariant( val );
1817 if ( layers.isEmpty() )
1820 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1824 else if ( definition->
defaultValue().type() == QVariant::List )
1826 const auto constToList = definition->
defaultValue().toList();
1827 for (
const QVariant &var : constToList )
1829 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1835 processVariant( var );
1849 return QStringList();
1851 const QVariant val = value;
1855 std::function< void(
const QVariant &var ) > processVariant;
1856 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1858 if ( var.type() == QVariant::List )
1860 const auto constToList = var.toList();
1861 for (
const QVariant &listVar : constToList )
1863 processVariant( listVar );
1866 else if ( var.type() == QVariant::StringList )
1868 const auto constToStringList = var.toStringList();
1869 for (
const QString &s : constToStringList )
1871 processVariant( s );
1874 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1878 files << var.toString();
1882 processVariant( val );
1884 if ( files.isEmpty() )
1895 return QStringList();
1903 return QList<double>();
1911 return QList<double>();
1913 QStringList resultStringList;
1914 const QVariant val = value;
1916 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1918 else if ( val.type() == QVariant::List )
1920 const auto constToList = val.toList();
1921 for (
const QVariant &var : constToList )
1922 resultStringList << var.toString();
1925 resultStringList << val.toString();
1927 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1929 resultStringList.clear();
1931 if ( definition->
defaultValue().type() == QVariant::List )
1933 const auto constToList = definition->
defaultValue().toList();
1934 for (
const QVariant &var : constToList )
1935 resultStringList << var.toString();
1938 resultStringList << definition->
defaultValue().toString();
1941 if ( resultStringList.size() == 1 )
1943 resultStringList = resultStringList.at( 0 ).split(
',' );
1946 if ( resultStringList.size() < 2 )
1947 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1949 QList< double > result;
1951 double n = resultStringList.at( 0 ).toDouble( &ok );
1955 result << std::numeric_limits<double>::quiet_NaN() ;
1957 n = resultStringList.at( 1 ).toDouble( &ok );
1961 result << std::numeric_limits<double>::quiet_NaN() ;
1969 return QStringList();
1971 const QStringList resultStringList;
1978 return QStringList();
1980 QStringList resultStringList;
1981 const QVariant val = value;
1982 if ( val.isValid() )
1984 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1986 else if ( val.type() == QVariant::List )
1988 const auto constToList = val.toList();
1989 for (
const QVariant &var : constToList )
1990 resultStringList << var.toString();
1992 else if ( val.type() == QVariant::StringList )
1994 resultStringList = val.toStringList();
1997 resultStringList.append( val.toString().split(
';' ) );
2000 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2002 resultStringList.clear();
2006 if ( definition->
defaultValue().type() == QVariant::List )
2008 const auto constToList = definition->
defaultValue().toList();
2009 for (
const QVariant &var : constToList )
2010 resultStringList << var.toString();
2012 else if ( definition->
defaultValue().type() == QVariant::StringList )
2014 resultStringList = definition->
defaultValue().toStringList();
2017 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2021 return resultStringList;
2035 if ( layoutName.isEmpty() )
2087 QVariant val = value;
2088 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2092 if ( val.type() == QVariant::Color )
2094 QColor
c = val.value< QColor >();
2096 if ( !colorParam->opacityEnabled() )
2104 if ( definition->
defaultValue().type() == QVariant::Color )
2110 if ( colorText.isEmpty() )
2113 bool containsAlpha =
false;
2116 if (
c.isValid() && !colorParam->opacityEnabled() )
2188 const QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2189 const QString name = map.value( QStringLiteral(
"name" ) ).toString();
2190 std::unique_ptr< QgsProcessingParameterDefinition > def;
2263 def.reset( paramType->
create( name ) );
2269 def->fromVariantMap( map );
2270 return def.release();
2275 QString desc = name;
2276 desc.replace(
'_',
' ' );
2282 bool isOptional =
false;
2286 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2291 if ( type == QLatin1String(
"boolean" ) )
2293 else if ( type == QLatin1String(
"crs" ) )
2295 else if ( type == QLatin1String(
"layer" ) )
2297 else if ( type == QLatin1String(
"extent" ) )
2299 else if ( type == QLatin1String(
"point" ) )
2301 else if ( type == QLatin1String(
"geometry" ) )
2303 else if ( type == QLatin1String(
"file" ) )
2305 else if ( type == QLatin1String(
"folder" ) )
2307 else if ( type == QLatin1String(
"matrix" ) )
2309 else if ( type == QLatin1String(
"multiple" ) )
2311 else if ( type == QLatin1String(
"number" ) )
2313 else if ( type == QLatin1String(
"distance" ) )
2315 else if ( type == QLatin1String(
"duration" ) )
2317 else if ( type == QLatin1String(
"scale" ) )
2319 else if ( type == QLatin1String(
"range" ) )
2321 else if ( type == QLatin1String(
"raster" ) )
2323 else if ( type == QLatin1String(
"enum" ) )
2325 else if ( type == QLatin1String(
"string" ) )
2327 else if ( type == QLatin1String(
"authcfg" ) )
2329 else if ( type == QLatin1String(
"expression" ) )
2331 else if ( type == QLatin1String(
"field" ) )
2333 else if ( type == QLatin1String(
"vector" ) )
2335 else if ( type == QLatin1String(
"source" ) )
2337 else if ( type == QLatin1String(
"sink" ) )
2339 else if ( type == QLatin1String(
"vectordestination" ) )
2341 else if ( type == QLatin1String(
"rasterdestination" ) )
2343 else if ( type == QLatin1String(
"pointclouddestination" ) )
2345 else if ( type == QLatin1String(
"filedestination" ) )
2347 else if ( type == QLatin1String(
"folderdestination" ) )
2349 else if ( type == QLatin1String(
"band" ) )
2351 else if ( type == QLatin1String(
"mesh" ) )
2353 else if ( type == QLatin1String(
"layout" ) )
2355 else if ( type == QLatin1String(
"layoutitem" ) )
2357 else if ( type == QLatin1String(
"color" ) )
2359 else if ( type == QLatin1String(
"coordinateoperation" ) )
2361 else if ( type == QLatin1String(
"maptheme" ) )
2363 else if ( type == QLatin1String(
"datetime" ) )
2365 else if ( type == QLatin1String(
"providerconnection" ) )
2367 else if ( type == QLatin1String(
"databaseschema" ) )
2369 else if ( type == QLatin1String(
"databasetable" ) )
2371 else if ( type == QLatin1String(
"pointcloud" ) )
2373 else if ( type == QLatin1String(
"annotation" ) )
2379bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2381 const QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2382 QRegularExpressionMatch m = re.match( code );
2383 if ( !m.hasMatch() )
2386 name = m.captured( 1 );
2387 QString tokens = m.captured( 2 );
2388 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2391 tokens.remove( 0, 8 );
2398 tokens = tokens.trimmed();
2400 const QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2401 m = re2.match( tokens );
2402 if ( !m.hasMatch() )
2404 type = tokens.toLower().trimmed();
2409 type = m.captured( 1 ).toLower().trimmed();
2410 definition = m.captured( 2 );
2421 , mDescription( description )
2423 , mDefault( defaultValue )
2424 , mFlags( optional ? FlagOptional : 0 )
2429 if ( !input.isValid() && !
mDefault.isValid() )
2432 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2433 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2441 if ( !value.isValid() )
2442 return QStringLiteral(
"None" );
2444 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2445 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2457 if ( !value.isValid() )
2461 if ( value.type() == QVariant::Type::Map )
2463 const QVariantMap sourceMap = value.toMap();
2464 QVariantMap resultMap;
2465 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2471 else if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2473 const QVariantList sourceList = value.toList();
2474 QVariantList resultList;
2475 resultList.reserve( sourceList.size() );
2476 for (
const QVariant &v : sourceList )
2484 switch ( value.userType() )
2487 case QMetaType::Bool:
2488 case QMetaType::Char:
2489 case QMetaType::Int:
2490 case QMetaType::Double:
2491 case QMetaType::Float:
2492 case QMetaType::LongLong:
2493 case QMetaType::ULongLong:
2494 case QMetaType::UInt:
2495 case QMetaType::ULong:
2496 case QMetaType::UShort:
2504 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2517 QgsDebugMsg( QStringLiteral(
"could not convert expression/field based property to JSON object" ) );
2523 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2533 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2541 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2550 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2562 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2577 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2583 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2590 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2597 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2602 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2604 const QColor fromVar = value.value< QColor >();
2605 if ( !fromVar.isValid() )
2608 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2610 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2612 const QDateTime fromVar = value.toDateTime();
2613 if ( !fromVar.isValid() )
2616 return fromVar.toString( Qt::ISODate );
2618 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2620 const QDate fromVar = value.toDate();
2621 if ( !fromVar.isValid() )
2624 return fromVar.toString( Qt::ISODate );
2626 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2628 const QTime fromVar = value.toTime();
2629 if ( !fromVar.isValid() )
2632 return fromVar.toString( Qt::ISODate );
2639 p.insert(
name(), value );
2643 if ( !source.isEmpty() )
2650 if ( value.userType() == QMetaType::QString )
2655 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg(
QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2668 if ( !value.isValid() )
2671 switch ( value.userType() )
2674 case QMetaType::Bool:
2675 case QMetaType::Char:
2676 case QMetaType::Int:
2677 case QMetaType::Double:
2678 case QMetaType::Float:
2679 case QMetaType::LongLong:
2680 case QMetaType::ULongLong:
2681 case QMetaType::UInt:
2682 case QMetaType::ULong:
2683 case QMetaType::UShort:
2684 return value.toString();
2690 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2703 QgsDebugMsg( QStringLiteral(
"could not convert expression/field based property to string" ) );
2709 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2719 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2727 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2735 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2747 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2762 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2768 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2775 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2780 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2785 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2787 const QColor fromVar = value.value< QColor >();
2788 if ( !fromVar.isValid() )
2791 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2793 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2795 const QDateTime fromVar = value.toDateTime();
2796 if ( !fromVar.isValid() )
2799 return fromVar.toString( Qt::ISODate );
2801 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2803 const QDate fromVar = value.toDate();
2804 if ( !fromVar.isValid() )
2807 return fromVar.toString( Qt::ISODate );
2809 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2811 const QTime fromVar = value.toTime();
2812 if ( !fromVar.isValid() )
2815 return fromVar.toString( Qt::ISODate );
2822 p.insert(
name(), value );
2826 if ( !source.isEmpty() )
2833 if ( value.userType() == QMetaType::QString )
2834 return value.toString();
2839 return value.toString();
2845 if ( !value.isValid( ) )
2846 return QStringList();
2848 if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2850 const QVariantList sourceList = value.toList();
2851 QStringList resultList;
2852 resultList.reserve( sourceList.size() );
2853 for (
const QVariant &v : sourceList )
2862 return QStringList();
2874 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2876 code += QLatin1String(
"optional " );
2877 code +=
type() +
' ';
2879 return code.trimmed();
2887 switch ( outputType )
2891 QString code = t->className() + QStringLiteral(
"('%1', %2" )
2894 code += QLatin1String(
", optional=True" );
2910 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2911 map.insert( QStringLiteral(
"name" ),
mName );
2912 map.insert( QStringLiteral(
"description" ),
mDescription );
2913 map.insert( QStringLiteral(
"help" ),
mHelp );
2914 map.insert( QStringLiteral(
"default" ),
mDefault );
2915 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2916 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2917 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2923 mName = map.value( QStringLiteral(
"name" ) ).toString();
2924 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2925 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2926 mDefault = map.value( QStringLiteral(
"default" ) );
2927 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2928 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2929 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2945 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
2946 if ( !
help().isEmpty() )
2948 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
2950 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
2965 if ( !val.isValid() )
2966 return QStringLiteral(
"None" );
2968 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2970 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
2975 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2977 code += QLatin1String(
"optional " );
2978 code +=
type() +
' ';
2979 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
2980 return code.trimmed();
3001 if ( !input.isValid() )
3004 if ( input.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3008 else if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3012 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3017 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3023 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3026 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3034 if ( !value.isValid() )
3035 return QStringLiteral(
"None" );
3037 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3040 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
3045 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3046 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3049 p.insert(
name(), value );
3086 if ( !input.isValid() )
3089 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3094 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3099 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3117 if ( !val.isValid() )
3118 return QStringLiteral(
"None" );
3120 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3124 p.insert(
name(), val );
3144 for (
const QString &raster : rasters )
3146 if ( !vectors.contains( raster ) )
3150 for (
const QString &mesh : meshFilters )
3152 if ( !vectors.contains( mesh ) )
3156 for (
const QString &pointCloud : pointCloudFilters )
3158 if ( !vectors.contains( pointCloud ) )
3159 vectors << pointCloud;
3161 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3162 std::sort( vectors.begin(), vectors.end() );
3164 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3174 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3176 code += QLatin1String(
"optional " );
3177 code += QLatin1String(
"layer " );
3184 code += QLatin1String(
"hasgeometry " );
3188 code += QLatin1String(
"point " );
3192 code += QLatin1String(
"line " );
3196 code += QLatin1String(
"polygon " );
3200 code += QLatin1String(
"raster " );
3204 code += QLatin1String(
"mesh " );
3208 code += QLatin1String(
"plugin " );
3212 code += QLatin1String(
"pointcloud " );
3216 code += QLatin1String(
"annotation " );
3222 return code.trimmed();
3228 QString def = definition;
3231 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3234 def = def.mid( 12 );
3237 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3243 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3249 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3255 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3261 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3267 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3273 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3276 def = def.mid( 11 );
3279 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3282 def = def.mid( 11 );
3293 switch ( outputType )
3297 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3300 code += QLatin1String(
", optional=True" );
3307 QStringList options;
3311 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3315 code += QLatin1Char(
')' );
3332 map.insert( QStringLiteral(
"data_types" ), types );
3340 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3341 for (
const QVariant &val : values )
3361 if ( !input.isValid() )
3364 if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3368 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3373 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3378 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3383 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3387 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3394 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3397 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3406 const QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3407 const QRegularExpressionMatch match = rx.match( input.toString() );
3408 if ( match.hasMatch() )
3410 bool xMinOk =
false;
3411 ( void )match.captured( 1 ).toDouble( &xMinOk );
3412 bool xMaxOk =
false;
3413 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3414 bool yMinOk =
false;
3415 ( void )match.captured( 3 ).toDouble( &yMinOk );
3416 bool yMaxOk =
false;
3417 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3418 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3428 if ( !value.isValid() )
3429 return QStringLiteral(
"None" );
3431 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3432 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3434 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3442 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3450 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3455 const QString wkt = g.
asWkt();
3456 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3461 p.insert(
name(), value );
3497 if ( !input.isValid() )
3500 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3505 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3509 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3513 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3518 if ( input.type() == QVariant::String )
3520 if ( input.toString().isEmpty() )
3524 const QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3526 const QRegularExpressionMatch match = rx.match( input.toString() );
3527 if ( match.hasMatch() )
3530 ( void )match.captured( 1 ).toDouble( &xOk );
3532 ( void )match.captured( 2 ).toDouble( &yOk );
3541 if ( !value.isValid() )
3542 return QStringLiteral(
"None" );
3544 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3545 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3547 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3553 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3560 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3565 const QString wkt = g.
asWkt();
3566 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3579 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3581 mGeomTypes( geometryTypes ),
3582 mAllowMultipart( allowMultipart )
3594 if ( !input.isValid() )
3597 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3604 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3606 return ( anyTypeAllowed || mGeomTypes.contains( input.value<
QgsGeometry>().
type() ) ) &&
3607 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3610 if ( input.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3616 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3621 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3626 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3631 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3636 if ( input.type() == QVariant::String )
3638 if ( input.toString().isEmpty() )
3643 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3645 const QRegularExpressionMatch match = rx.match( input.toString() );
3646 if ( match.hasMatch() )
3651 return ( anyTypeAllowed || mGeomTypes.contains( g.
type() ) ) && ( mAllowMultipart || !g.
isMultipart() );
3671 if ( !value.isValid() )
3672 return QStringLiteral(
"None" );
3674 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3677 if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3684 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3691 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3698 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3705 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3712 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3724 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3726 code += QLatin1String(
"optional " );
3727 code +=
type() +
' ';
3729 for (
const int type : mGeomTypes )
3734 code += QLatin1String(
"point " );
3738 code += QLatin1String(
"line " );
3742 code += QLatin1String(
"polygon " );
3746 code += QLatin1String(
"unknown " );
3752 return code.trimmed();
3757 switch ( outputType )
3761 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3764 code += QLatin1String(
", optional=True" );
3766 if ( !mGeomTypes.empty() )
3773 return QStringLiteral(
"PointGeometry" );
3776 return QStringLiteral(
"LineGeometry" );
3779 return QStringLiteral(
"PolygonGeometry" );
3782 return QStringLiteral(
"UnknownGeometry" );
3785 return QStringLiteral(
"NullGeometry" );
3790 QStringList options;
3791 options.reserve( mGeomTypes.size() );
3792 for (
const int type : mGeomTypes )
3796 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3799 if ( ! mAllowMultipart )
3801 code += QLatin1String(
", allowMultipart=False" );
3816 for (
const int type : mGeomTypes )
3820 map.insert( QStringLiteral(
"geometrytypes" ), types );
3821 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3829 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3830 for (
const QVariant &val : values )
3832 mGeomTypes << val.toInt();
3834 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
3845 , mBehavior( behavior )
3846 , mExtension( fileFilter.isEmpty() ? extension : QString() )
3847 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3859 if ( !input.isValid() )
3862 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3867 const QString
string = input.toString().trimmed();
3869 if ( input.type() != QVariant::String ||
string.isEmpty() )
3872 switch ( mBehavior )
3876 if ( !mExtension.isEmpty() )
3878 return string.endsWith( mExtension, Qt::CaseInsensitive );
3880 else if ( !mFileFilter.isEmpty() )
3898 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3900 code += QLatin1String(
"optional " );
3901 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
3903 return code.trimmed();
3908 switch ( outputType )
3913 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
3916 code += QLatin1String(
", optional=True" );
3917 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
3918 if ( !mExtension.isEmpty() )
3919 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
3920 if ( !mFileFilter.isEmpty() )
3921 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
3932 switch ( mBehavior )
3936 if ( !mFileFilter.isEmpty() )
3937 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
3938 else if ( !mExtension.isEmpty() )
3939 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
3941 return QObject::tr(
"All files (*.*)" );
3953 mFileFilter.clear();
3963 mFileFilter = filter;
3970 map.insert( QStringLiteral(
"behavior" ), mBehavior );
3971 map.insert( QStringLiteral(
"extension" ), mExtension );
3972 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
3979 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
3980 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
3981 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
3992 , mHeaders( headers )
3993 , mNumberRows( numberRows )
3994 , mFixedNumberRows( fixedNumberRows )
4006 if ( !input.isValid() )
4009 if ( input.type() == QVariant::String )
4011 if ( input.toString().isEmpty() )
4015 else if ( input.type() == QVariant::List )
4017 if ( input.toList().isEmpty() )
4021 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
4031 if ( !value.isValid() )
4032 return QStringLiteral(
"None" );
4034 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4035 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4038 p.insert(
name(), value );
4046 switch ( outputType )
4050 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4053 code += QLatin1String(
", optional=True" );
4054 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4055 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4058 headers.reserve( mHeaders.size() );
4059 for (
const QString &h : mHeaders )
4061 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4093 return mFixedNumberRows;
4098 mFixedNumberRows = fixedNumberRows;
4104 map.insert( QStringLiteral(
"headers" ), mHeaders );
4105 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4106 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4113 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4114 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4115 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4126 , mLayerType( layerType )
4138 if ( !input.isValid() )
4143 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4149 if ( input.type() == QVariant::String )
4151 if ( input.toString().isEmpty() )
4154 if ( mMinimumNumberInputs > 1 )
4165 else if ( input.type() == QVariant::List )
4167 if ( input.toList().count() < mMinimumNumberInputs )
4170 if ( mMinimumNumberInputs > input.toList().count() )
4178 const auto constToList = input.toList();
4179 for (
const QVariant &v : constToList )
4181 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4190 else if ( input.type() == QVariant::StringList )
4192 if ( input.toStringList().count() < mMinimumNumberInputs )
4195 if ( mMinimumNumberInputs > input.toStringList().count() )
4203 const auto constToStringList = input.toStringList();
4204 for (
const QString &v : constToStringList )
4217 if ( !value.isValid() )
4218 return QStringLiteral(
"None" );
4220 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4221 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4226 if ( value.type() == QVariant::StringList )
4228 const QStringList list = value.toStringList();
4229 parts.reserve( list.count() );
4230 for (
const QString &v : list )
4233 else if ( value.type() == QVariant::List )
4235 const QVariantList list = value.toList();
4236 parts.reserve( list.count() );
4237 for (
const QVariant &v : list )
4240 if ( !parts.isEmpty() )
4241 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4246 p.insert(
name(), value );
4248 if ( !list.isEmpty() )
4251 parts.reserve( list.count() );
4256 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4275 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4277 code += QLatin1String(
"optional " );
4278 switch ( mLayerType )
4281 code += QLatin1String(
"multiple raster" );
4285 code += QLatin1String(
"multiple file" );
4289 code += QLatin1String(
"multiple vector" );
4293 if (
mDefault.type() == QVariant::List )
4296 const auto constToList =
mDefault.toList();
4297 for (
const QVariant &var : constToList )
4299 parts << var.toString();
4301 code += parts.join(
',' );
4303 else if (
mDefault.type() == QVariant::StringList )
4305 code +=
mDefault.toStringList().join(
',' );
4311 return code.trimmed();
4316 switch ( outputType )
4320 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4323 code += QLatin1String(
", optional=True" );
4327 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4338 const QStringList exts;
4339 switch ( mLayerType )
4342 return QObject::tr(
"All files (*.*)" );
4380 return mMinimumNumberInputs;
4392 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
4393 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4401 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4407 QString
type = definition;
4409 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4410 const QRegularExpressionMatch m = re.match( definition );
4413 type = m.captured( 1 ).toLower().trimmed();
4414 defaultVal = m.captured( 2 );
4417 if (
type == QLatin1String(
"vector" ) )
4419 else if (
type == QLatin1String(
"raster" ) )
4421 else if (
type == QLatin1String(
"file" ) )
4434 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4445 QVariant input = value;
4446 if ( !input.isValid() )
4454 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4460 const double res = input.toDouble( &ok );
4464 return !( res < mMin || res > mMax );
4469 if ( !value.isValid() )
4470 return QStringLiteral(
"None" );
4472 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4473 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4475 return value.toString();
4482 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4483 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4484 if ( mMax < std::numeric_limits<double>::max() )
4485 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4487 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
4488 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4489 if ( !extra.isEmpty() )
4490 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4496 switch ( outputType )
4500 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4503 code += QLatin1String(
", optional=True" );
4505 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4507 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4508 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4509 if ( mMax != std::numeric_limits<double>::max() )
4510 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4552 map.insert( QStringLiteral(
"min" ), mMin );
4553 map.insert( QStringLiteral(
"max" ), mMax );
4554 map.insert( QStringLiteral(
"data_type" ), mDataType );
4561 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4562 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4563 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4570 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4587 if ( !input.isValid() )
4590 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4595 if ( input.type() == QVariant::String )
4597 const QStringList list = input.toString().split(
',' );
4598 if ( list.count() != 2 )
4601 list.at( 0 ).toDouble( &ok );
4603 list.at( 1 ).toDouble( &ok2 );
4608 else if ( input.type() == QVariant::List )
4610 if ( input.toList().count() != 2 )
4614 input.toList().at( 0 ).toDouble( &ok );
4616 input.toList().at( 1 ).toDouble( &ok2 );
4627 if ( !value.isValid() )
4628 return QStringLiteral(
"None" );
4630 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4631 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4634 p.insert(
name(), value );
4637 QStringList stringParts;
4638 const auto constParts = parts;
4639 for (
const double v : constParts )
4641 stringParts << QString::number( v );
4643 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4648 switch ( outputType )
4652 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4655 code += QLatin1String(
", optional=True" );
4657 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4680 map.insert( QStringLiteral(
"data_type" ), mDataType );
4694 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4710 if ( !input.isValid() )
4713 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4718 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4721 if ( input.type() != QVariant::String || input.toString().isEmpty() )
4739 if ( !val.isValid() )
4740 return QStringLiteral(
"None" );
4742 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
4746 p.insert(
name(), val );
4774 , mOptions( options )
4775 , mAllowMultiple( allowMultiple )
4776 , mUsesStaticStrings( usesStaticStrings )
4788 QVariant input = value;
4789 if ( !input.isValid() )
4797 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4802 if ( mUsesStaticStrings )
4804 if ( input.type() == QVariant::List )
4806 if ( !mAllowMultiple )
4809 const QVariantList values = input.toList();
4813 for (
const QVariant &val : values )
4815 if ( !mOptions.contains( val.toString() ) )
4821 else if ( input.type() == QVariant::StringList )
4823 if ( !mAllowMultiple )
4826 const QStringList values = input.toStringList();
4831 if ( values.count() > 1 && !mAllowMultiple )
4834 for (
const QString &val : values )
4836 if ( !mOptions.contains( val ) )
4841 else if ( input.type() == QVariant::String )
4843 const QStringList parts = input.toString().split(
',' );
4844 if ( parts.count() > 1 && !mAllowMultiple )
4847 const auto constParts = parts;
4848 for (
const QString &part : constParts )
4850 if ( !mOptions.contains( part ) )
4858 if ( input.type() == QVariant::List )
4860 if ( !mAllowMultiple )
4863 const QVariantList values = input.toList();
4867 for (
const QVariant &val : values )
4870 const int res = val.toInt( &ok );
4873 else if ( res < 0 || res >= mOptions.count() )
4879 else if ( input.type() == QVariant::String )
4881 const QStringList parts = input.toString().split(
',' );
4882 if ( parts.count() > 1 && !mAllowMultiple )
4885 const auto constParts = parts;
4886 for (
const QString &part : constParts )
4889 const int res = part.toInt( &ok );
4892 else if ( res < 0 || res >= mOptions.count() )
4897 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
4900 const int res = input.toInt( &ok );
4903 else if ( res >= 0 && res < mOptions.count() )
4913 if ( !value.isValid() )
4914 return QStringLiteral(
"None" );
4916 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4917 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4919 if ( mUsesStaticStrings )
4921 if ( value.type() == QVariant::StringList )
4924 const QStringList constList = value.toStringList();
4925 for (
const QString &val : constList )
4929 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4931 else if ( value.type() == QVariant::String )
4934 const QStringList constList = value.toString().split(
',' );
4935 if ( constList.count() > 1 )
4937 for (
const QString &val : constList )
4941 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4949 if ( value.type() == QVariant::List )
4952 const auto constToList = value.toList();
4953 for (
const QVariant &val : constToList )
4955 parts << QString::number( static_cast< int >( val.toDouble() ) );
4957 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4959 else if ( value.type() == QVariant::String )
4961 const QStringList parts = value.toString().split(
',' );
4962 if ( parts.count() > 1 )
4964 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4968 return QString::number(
static_cast< int >( value.toDouble() ) );
4974 if ( !value.isValid() )
4977 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4980 if ( mUsesStaticStrings )
4986 if ( value.type() == QVariant::List )
4989 const QVariantList toList = value.toList();
4990 parts.reserve( toList.size() );
4991 for (
const QVariant &val : toList )
4993 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
4995 return parts.join(
',' );
4997 else if ( value.type() == QVariant::String )
4999 const QStringList parts = value.toString().split(
',' );
5000 QStringList comments;
5001 if ( parts.count() > 1 )
5003 for (
const QString &part : parts )
5006 const int val = part.toInt( &ok );
5008 comments << mOptions.value( val );
5010 return comments.join(
',' );
5014 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5020 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5022 code += QLatin1String(
"optional " );
5023 code += QLatin1String(
"enum " );
5025 if ( mAllowMultiple )
5026 code += QLatin1String(
"multiple " );
5028 if ( mUsesStaticStrings )
5029 code += QLatin1String(
"static " );
5031 code += mOptions.join(
';' ) +
' ';
5034 return code.trimmed();
5039 switch ( outputType )
5043 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5046 code += QLatin1String(
", optional=True" );
5049 options.reserve( mOptions.size() );
5050 for (
const QString &o : mOptions )
5052 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5054 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5056 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5079 return mAllowMultiple;
5089 return mUsesStaticStrings;
5100 map.insert( QStringLiteral(
"options" ), mOptions );
5101 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5102 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5109 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5110 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5111 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5118 QString def = definition;
5120 bool multiple =
false;
5121 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5127 bool staticStrings =
false;
5128 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5130 staticStrings =
true;
5134 const QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5135 const QRegularExpressionMatch m = re.match( def );
5136 QString values = def;
5139 values = m.captured( 1 ).trimmed();
5140 defaultVal = m.captured( 2 );
5148 , mMultiLine( multiLine )
5161 return QStringLiteral(
"None" );
5163 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5164 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5166 const QString s = value.toString();
5172 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5174 code += QLatin1String(
"optional " );
5175 code += QLatin1String(
"string " );
5178 code += QLatin1String(
"long " );
5181 return code.trimmed();
5186 switch ( outputType )
5190 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5193 code += QLatin1String(
", optional=True" );
5194 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5217 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5224 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5230 QString def = definition;
5232 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5238 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5240 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5244 if ( def == QLatin1String(
"None" ) )
5267 if ( !value.isValid() )
5268 return QStringLiteral(
"None" );
5270 const QString s = value.toString();
5276 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5278 code += QLatin1String(
"optional " );
5279 code += QLatin1String(
"authcfg " );
5282 return code.trimmed();
5287 QString def = definition;
5289 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5291 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5295 if ( def == QLatin1String(
"None" ) )
5308 , mParentLayerParameterName( parentLayerParameterName )
5320 if ( !value.isValid() )
5321 return QStringLiteral(
"None" );
5323 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5324 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5326 const QString s = value.toString();
5332 QStringList depends;
5333 if ( !mParentLayerParameterName.isEmpty() )
5334 depends << mParentLayerParameterName;
5340 switch ( outputType )
5344 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5347 code += QLatin1String(
", optional=True" );
5349 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5361 return mParentLayerParameterName;
5372 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5379 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5407 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5420 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5423 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5441 if ( !val.isValid() )
5442 return QStringLiteral(
"None" );
5444 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5448 p.insert(
name(), val );
5466 switch ( outputType )
5470 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5473 code += QLatin1String(
", optional=True" );
5477 QStringList options;
5480 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5514 map.insert( QStringLiteral(
"data_types" ), types );
5522 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5523 for (
const QVariant &val : values )
5536 const QVariant &defaultValue,
bool optional )
5554 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5567 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5570 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5588 if ( !val.isValid() )
5589 return QStringLiteral(
"None" );
5591 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5595 p.insert(
name(), val );
5623 , mParentLayerParameterName( parentLayerParameterName )
5625 , mAllowMultiple( allowMultiple )
5626 , mDefaultToAllFields( defaultToAllFields )
5639 if ( !input.isValid() )
5642 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
5647 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5649 if ( !mAllowMultiple )
5655 else if ( input.type() == QVariant::String )
5657 if ( input.toString().isEmpty() )
5660 const QStringList parts = input.toString().split(
';' );
5661 if ( parts.count() > 1 && !mAllowMultiple )
5666 if ( input.toString().isEmpty() )
5674 if ( !value.isValid() )
5675 return QStringLiteral(
"None" );
5677 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5678 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5680 if ( value.type() == QVariant::List )
5683 const auto constToList = value.toList();
5684 for (
const QVariant &val : constToList )
5688 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5690 else if ( value.type() == QVariant::StringList )
5693 const auto constToStringList = value.toStringList();
5694 for (
const QString &s : constToStringList )
5698 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5706 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5708 code += QLatin1String(
"optional " );
5709 code += QLatin1String(
"field " );
5711 switch ( mDataType )
5714 code += QLatin1String(
"numeric " );
5718 code += QLatin1String(
"string " );
5722 code += QLatin1String(
"datetime " );
5729 if ( mAllowMultiple )
5730 code += QLatin1String(
"multiple " );
5732 if ( mDefaultToAllFields )
5733 code += QLatin1String(
"default_to_all_fields " );
5735 code += mParentLayerParameterName +
' ';
5738 return code.trimmed();
5743 switch ( outputType )
5747 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
5750 code += QLatin1String(
", optional=True" );
5753 switch ( mDataType )
5756 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
5760 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
5764 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
5768 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
5771 code += QStringLiteral(
", type=%1" ).arg(
dataType );
5773 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5774 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5778 if ( mDefaultToAllFields )
5779 code += QLatin1String(
", defaultToAllFields=True" );
5791 QStringList depends;
5792 if ( !mParentLayerParameterName.isEmpty() )
5793 depends << mParentLayerParameterName;
5799 return mParentLayerParameterName;
5819 return mAllowMultiple;
5829 return mDefaultToAllFields;
5834 mDefaultToAllFields = enabled;
5840 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5841 map.insert( QStringLiteral(
"data_type" ), mDataType );
5842 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5843 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
5850 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5851 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
5852 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5853 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
5863 QString def = definition;
5865 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
5870 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
5875 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
5881 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5884 def = def.mid( 8 ).trimmed();
5887 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
5890 def = def.mid( 21 ).trimmed();
5893 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5894 const QRegularExpressionMatch m = re.match( def );
5897 parent = m.captured( 1 ).trimmed();
5898 def = m.captured( 2 );
5923 QVariant var = input;
5924 if ( !var.isValid() )
5927 if ( var.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
5932 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
5939 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5951 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
5956 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5974 if ( !value.isValid() )
5975 return QStringLiteral(
"None" );
5977 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5980 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
5983 QString geometryCheckString;
5987 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
5991 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
5995 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6001 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagOverrideDefaultGeometryCheck )
6002 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6003 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagCreateIndividualOutputPerInputFeature )
6004 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6005 if ( !
flags.empty() )
6006 flagString =
flags.join( QLatin1String(
" | " ) );
6013 layerString = layer->source();
6020 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6021 geometryCheckString );
6032 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" )
6036 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6037 geometryCheckString );
6045 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6050 QString layerString = value.toString();
6054 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6071 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6073 code += QLatin1String(
"optional " );
6074 code += QLatin1String(
"source " );
6081 code += QLatin1String(
"point " );
6085 code += QLatin1String(
"line " );
6089 code += QLatin1String(
"polygon " );
6096 return code.trimmed();
6101 switch ( outputType )
6105 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6108 code += QLatin1String(
", optional=True" );
6112 QStringList options;
6116 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6133 : mDataTypes( types )
6146 map.insert( QStringLiteral(
"data_types" ), types );
6154 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6155 for (
const QVariant &val : values )
6165 QString def = definition;
6168 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6174 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6180 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6195 , mSupportsAppend( supportsAppend )
6206 QVariant var = input;
6207 if ( !var.isValid() )
6210 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6216 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6229 if ( var.type() != QVariant::String )
6232 if ( var.toString().isEmpty() )
6240 if ( !value.isValid() )
6241 return QStringLiteral(
"None" );
6243 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6244 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6246 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6255 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6264 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6266 code += QLatin1String(
"optional " );
6267 code += QLatin1String(
"sink " );
6269 switch ( mDataType )
6272 code += QLatin1String(
"point " );
6276 code += QLatin1String(
"line " );
6280 code += QLatin1String(
"polygon " );
6284 code += QLatin1String(
"table " );
6292 return code.trimmed();
6304 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6308 return p->defaultVectorFileExtension(
hasGeometry() );
6318 return QStringLiteral(
"dbf" );
6325 switch ( outputType )
6329 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6332 code += QLatin1String(
", optional=True" );
6336 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6337 if ( mSupportsAppend )
6338 code += QLatin1String(
", supportsAppend=True" );
6351 QStringList filters;
6352 for (
const QString &ext : exts )
6354 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6356 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6365 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6367 return lOriginalProvider->supportedOutputTableExtensions();
6372 return p->supportedOutputVectorLayerExtensions();
6374 return p->supportedOutputTableExtensions();
6389 switch ( mDataType )
6418 map.insert( QStringLiteral(
"data_type" ), mDataType );
6419 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6427 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6434 return QStringLiteral(
"memory:%1" ).arg(
description() );
6442 QString def = definition;
6443 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6448 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6453 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6458 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6469 return mSupportsAppend;
6489 QVariant var = input;
6490 if ( !var.isValid() )
6493 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6499 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6512 if ( var.type() != QVariant::String )
6515 if ( var.toString().isEmpty() )
6523 if ( !value.isValid() )
6524 return QStringLiteral(
"None" );
6526 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6527 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6529 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6538 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6554 return lOriginalProvider->defaultRasterFileExtension();
6558 return p->defaultRasterFileExtension();
6569 QStringList filters;
6570 for (
const QString &ext : exts )
6572 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6574 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6581 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6585 return p->supportedOutputRasterLayerExtensions();
6601 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6613 QVariant var = input;
6614 if ( !var.isValid() )
6617 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6623 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6636 if ( var.type() != QVariant::String )
6639 if ( var.toString().isEmpty() )
6649 if ( !value.isValid() )
6650 return QStringLiteral(
"None" );
6652 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6653 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6655 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6664 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6673 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6685 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6686 return QStringLiteral(
"file" );
6689 const QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6690 const QRegularExpressionMatch match = rx.match( mFileFilter );
6691 if ( !match.hasMatch() )
6692 return QStringLiteral(
"file" );
6694 return match.captured( 1 );
6699 switch ( outputType )
6703 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
6706 code += QLatin1String(
", optional=True" );
6710 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6722 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
6738 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
6745 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
6766 QVariant var = input;
6767 if ( !var.isValid() )
6770 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6783 if ( var.type() != QVariant::String )
6786 if ( var.toString().isEmpty() )
6809 , mCreateByDefault( createByDefault )
6817 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
6818 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
6825 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
6826 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
6832 switch ( outputType )
6839 QString code = t->className() + QStringLiteral(
"('%1', %2" )
6842 code += QLatin1String(
", optional=True" );
6844 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6859 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
6866 const QRegularExpression rx( QStringLiteral(
"[.]" ) );
6867 QString sanitizedName =
name();
6868 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
6883 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
6892 return mCreateByDefault;
6914 QVariant var = input;
6915 if ( !var.isValid() )
6918 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6924 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6937 if ( var.type() != QVariant::String )
6940 if ( var.toString().isEmpty() )
6948 if ( !value.isValid() )
6949 return QStringLiteral(
"None" );
6951 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6952 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6954 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6963 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6972 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6974 code += QLatin1String(
"optional " );
6975 code += QLatin1String(
"vectorDestination " );
6977 switch ( mDataType )
6980 code += QLatin1String(
"point " );
6984 code += QLatin1String(
"line " );
6988 code += QLatin1String(
"polygon " );
6996 return code.trimmed();
7008 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7012 return p->defaultVectorFileExtension(
hasGeometry() );
7022 return QStringLiteral(
"dbf" );
7029 switch ( outputType )
7033 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7036 code += QLatin1String(
", optional=True" );
7040 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7053 QStringList filters;
7054 for (
const QString &ext : exts )
7056 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7058 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7066 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7068 return lOriginalProvider->supportedOutputTableExtensions();
7073 return p->supportedOutputVectorLayerExtensions();
7075 return p->supportedOutputTableExtensions();
7090 switch ( mDataType )
7119 map.insert( QStringLiteral(
"data_type" ), mDataType );
7133 QString def = definition;
7134 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7139 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7144 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7155 , mParentLayerParameterName( parentLayerParameterName )
7156 , mAllowMultiple( allowMultiple )
7168 if ( !input.isValid() )
7171 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7176 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
7178 if ( !mAllowMultiple )
7187 const double res = input.toInt( &ok );
7197 return mAllowMultiple;
7207 if ( !value.isValid() )
7208 return QStringLiteral(
"None" );
7210 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7211 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7213 if ( value.type() == QVariant::List )
7216 const QVariantList values = value.toList();
7217 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7219 parts << QString::number( static_cast< int >( it->toDouble() ) );
7221 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7223 else if ( value.type() == QVariant::StringList )
7226 const QStringList values = value.toStringList();
7227 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7229 parts << QString::number( static_cast< int >( it->toDouble() ) );
7231 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7234 return value.toString();
7239 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7241 code += QLatin1String(
"optional " );
7242 code += QLatin1String(
"band " );
7244 if ( mAllowMultiple )
7245 code += QLatin1String(
"multiple " );
7247 code += mParentLayerParameterName +
' ';
7250 return code.trimmed();
7255 QStringList depends;
7256 if ( !mParentLayerParameterName.isEmpty() )
7257 depends << mParentLayerParameterName;
7263 switch ( outputType )
7267 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7270 code += QLatin1String(
", optional=True" );
7272 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7273 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7285 return mParentLayerParameterName;
7296 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7297 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7304 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7305 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7312 QString def = definition;
7315 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7318 def = def.mid( 8 ).trimmed();
7321 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7322 const QRegularExpressionMatch m = re.match( def );
7325 parent = m.captured( 1 ).trimmed();
7326 def = m.captured( 2 );
7343 , mParentParameterName( parentParameterName )
7360 QStringList depends;
7361 if ( !mParentParameterName.isEmpty() )
7362 depends << mParentParameterName;
7368 switch ( outputType )
7372 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7375 code += QLatin1String(
", optional=True" );
7377 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7379 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7380 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7381 if (
maximum() != std::numeric_limits<double>::max() )
7382 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7393 return mParentParameterName;
7404 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7405 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7412 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7439 switch ( outputType )
7443 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7446 code += QLatin1String(
", optional=True" );
7448 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7449 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7450 if (
maximum() != std::numeric_limits<double>::max() )
7451 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7463 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7497 switch ( outputType )
7501 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7504 code += QLatin1String(
", optional=True" );
7516 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7536 return QStringLiteral(
"None" );
7538 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7539 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7541 const QString s = value.toString();
7547 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7549 code += QLatin1String(
"optional " );
7550 code += QLatin1String(
"layout " );
7553 return code.trimmed();
7558 switch ( outputType )
7562 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
7565 code += QLatin1String(
", optional=True" );
7576 QString def = definition;
7578 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7580 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7584 if ( def == QLatin1String(
"None" ) )
7597 , mParentLayoutParameterName( parentLayoutParameterName )
7598 , mItemType( itemType )
7611 return QStringLiteral(
"None" );
7613 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7614 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7616 const QString s = value.toString();
7622 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7624 code += QLatin1String(
"optional " );
7625 code += QLatin1String(
"layoutitem " );
7626 if ( mItemType >= 0 )
7627 code += QString::number( mItemType ) +
' ';
7629 code += mParentLayoutParameterName +
' ';
7632 return code.trimmed();
7637 switch ( outputType )
7641 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
7644 code += QLatin1String(
", optional=True" );
7646 if ( mItemType >= 0 )
7647 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
7649 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
7662 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
7663 map.insert( QStringLiteral(
"item_type" ), mItemType );
7670 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
7671 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
7677 QStringList depends;
7678 if ( !mParentLayoutParameterName.isEmpty() )
7679 depends << mParentLayoutParameterName;
7686 QString def = definition;
7688 const QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
7689 const QRegularExpressionMatch m = re.match( def );
7692 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
7693 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
7694 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
7707 return mParentLayoutParameterName;
7712 mParentLayoutParameterName =
name;
7731 , mAllowOpacity( opacityEnabled )
7744 return QStringLiteral(
"None" );
7746 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7747 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7749 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
7750 return QStringLiteral(
"QColor()" );
7752 if ( value.canConvert< QColor >() )
7754 const QColor
c = value.value< QColor >();
7755 if ( !mAllowOpacity ||
c.alpha() == 255 )
7756 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
7758 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
7761 const QString s = value.toString();
7767 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7769 code += QLatin1String(
"optional " );
7770 code += QLatin1String(
"color " );
7772 if ( mAllowOpacity )
7773 code += QLatin1String(
"withopacity " );
7776 return code.trimmed();
7781 switch ( outputType )
7785 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
7788 code += QLatin1String(
", optional=True" );
7790 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7802 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
7805 if ( !input.isValid() )
7808 if ( input.type() == QVariant::Color )
7812 else if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7817 if ( input.type() != QVariant::String || input.toString().isEmpty() )
7820 bool containsAlpha =
false;
7827 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
7834 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
7840 return mAllowOpacity;
7845 mAllowOpacity = enabled;
7850 QString def = definition;
7852 bool allowOpacity =
false;
7853 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
7855 allowOpacity =
true;
7856 def = def.mid( 12 );
7859 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7861 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7865 if ( def == QLatin1String(
"None" ) )
7876 , mSourceParameterName( sourceCrsParameterName )
7877 , mDestParameterName( destinationCrsParameterName )
7878 , mSourceCrs( staticSourceCrs )
7879 , mDestCrs( staticDestinationCrs )
7892 return QStringLiteral(
"None" );
7894 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
7897 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
7902 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7903 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7906 p.insert(
name(), value );
7911 const QString s = value.toString();
7917 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7919 code += QLatin1String(
"optional " );
7920 code += QLatin1String(
"coordinateoperation " );
7923 return code.trimmed();
7928 switch ( outputType )
7933 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
7936 code += QLatin1String(
", optional=True" );
7937 if ( !mSourceParameterName.isEmpty() )
7938 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
7939 if ( !mDestParameterName.isEmpty() )
7940 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
7942 if ( mSourceCrs.isValid() )
7944 if ( mDestCrs.isValid() )
7945 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
7957 if ( !mSourceParameterName.isEmpty() )
7958 res << mSourceParameterName;
7959 if ( !mDestParameterName.isEmpty() )
7960 res << mDestParameterName;
7967 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
7968 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
7969 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
7970 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
7977 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
7978 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
7979 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
7980 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
7986 QString def = definition;
7988 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7990 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7994 if ( def == QLatin1String(
"None" ) )
8019 if ( !input.isValid() && !
mDefault.isValid() )
8022 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8023 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8031 if ( !value.isValid() )
8032 return QStringLiteral(
"None" );
8034 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8035 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8042 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8044 code += QLatin1String(
"optional " );
8045 code += QLatin1String(
"maptheme " );
8048 return code.trimmed();
8053 switch ( outputType )
8057 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8060 code += QLatin1String(
", optional=True" );
8085 QString def = definition;
8086 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8088 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8110 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8112 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8123 QVariant input = value;
8124 if ( !input.isValid() )
8132 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8137 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
8140 if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType ==
Time )
8143 if ( input.type() == QVariant::String )
8145 const QString s = input.toString();
8149 input = QDateTime::fromString( s, Qt::ISODate );
8150 if ( mDataType ==
Time )
8152 if ( !input.toDateTime().isValid() )
8153 input = QTime::fromString( s );
8155 input = input.toDateTime().time();
8159 if ( mDataType !=
Time )
8161 const QDateTime res = input.toDateTime();
8162 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8166 const QTime res = input.toTime();
8167 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8173 if ( !value.isValid() )
8174 return QStringLiteral(
"None" );
8176 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8177 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8179 if ( value.type() == QVariant::DateTime )
8181 const QDateTime dt = value.toDateTime();
8182 if ( !dt.isValid() )
8183 return QStringLiteral(
"QDateTime()" );
8185 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8186 .arg( dt.date().month() )
8187 .arg( dt.date().day() )
8188 .arg( dt.time().hour() )
8189 .arg( dt.time().minute() )
8190 .arg( dt.time().second() );
8192 else if ( value.type() == QVariant::Date )
8194 const QDate dt = value.toDate();
8195 if ( !dt.isValid() )
8196 return QStringLiteral(
"QDate()" );
8198 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8202 else if ( value.type() == QVariant::Time )
8204 const QTime dt = value.toTime();
8205 if ( !dt.isValid() )
8206 return QStringLiteral(
"QTime()" );
8208 return QStringLiteral(
"QTime(%4, %5, %6)" )
8211 .arg( dt.second() );
8213 return value.toString();
8220 if ( mMin.isValid() )
8221 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8222 if ( mMax.isValid() )
8223 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8225 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
DateTime ?
mDefault.toDateTime().toString( Qt::ISODate ) :
8226 ( mDataType ==
Date ?
mDefault.toDate().toString( Qt::ISODate ) :
mDefault.toTime( ).toString() ) );
8227 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8228 if ( !extra.isEmpty() )
8229 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8235 switch ( outputType )
8239 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8242 code += QLatin1String(
", optional=True" );
8244 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
DateTime ? QStringLiteral(
"QgsProcessingParameterDateTime.DateTime" )
8245 : mDataType ==
Date ? QStringLiteral(
"QgsProcessingParameterDateTime.Date" )
8246 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8249 if ( mMin.isValid() )
8251 if ( mMax.isValid() )
8293 map.insert( QStringLiteral(
"min" ), mMin );
8294 map.insert( QStringLiteral(
"max" ), mMax );
8295 map.insert( QStringLiteral(
"data_type" ), mDataType );
8302 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8303 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8304 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
8311 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8322 , mProviderId( provider )
8335 if ( !input.isValid() && !
mDefault.isValid() )
8338 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8339 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8347 if ( !value.isValid() )
8348 return QStringLiteral(
"None" );
8350 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8351 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8358 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8360 code += QLatin1String(
"optional " );
8361 code += QLatin1String(
"providerconnection " );
8362 code += mProviderId +
' ';
8365 return code.trimmed();
8370 switch ( outputType )
8374 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8377 code += QLatin1String(
", optional=True" );
8391 map.insert( QStringLiteral(
"provider" ), mProviderId );
8398 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8404 QString def = definition;
8406 if ( def.contains(
' ' ) )
8408 provider = def.left( def.indexOf(
' ' ) );
8409 def = def.mid( def.indexOf(
' ' ) + 1 );
8417 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8419 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8437 , mParentConnectionParameterName( parentLayerParameterName )
8450 if ( !input.isValid() && !
mDefault.isValid() )
8453 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8454 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8462 if ( !value.isValid() )
8463 return QStringLiteral(
"None" );
8465 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8466 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8473 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8475 code += QLatin1String(
"optional " );
8476 code += QLatin1String(
"databaseschema " );
8478 code += mParentConnectionParameterName +
' ';
8481 return code.trimmed();
8486 switch ( outputType )
8490 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8493 code += QLatin1String(
", optional=True" );
8495 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8509 QStringList depends;
8510 if ( !mParentConnectionParameterName.isEmpty() )
8511 depends << mParentConnectionParameterName;
8517 return mParentConnectionParameterName;
8522 mParentConnectionParameterName =
name;
8528 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8535 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8542 QString def = definition;
8544 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
8545 const QRegularExpressionMatch m = re.match( def );
8548 parent = m.captured( 1 ).trimmed();
8549 def = m.captured( 2 );
8565 const QString &connectionParameterName,
8566 const QString &schemaParameterName,
8567 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
8569 , mParentConnectionParameterName( connectionParameterName )
8570 , mParentSchemaParameterName( schemaParameterName )
8571 , mAllowNewTableNames( allowNewTableNames )
8584 if ( !input.isValid() && !
mDefault.isValid() )
8587 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8588 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8596 if ( !value.isValid() )
8597 return QStringLiteral(
"None" );
8599 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8600 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8607 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8609 code += QLatin1String(
"optional " );
8610 code += QLatin1String(
"databasetable " );
8612 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
8613 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
8616 return code.trimmed();
8621 switch ( outputType )
8625 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
8628 code += QLatin1String(
", optional=True" );
8630 if ( mAllowNewTableNames )
8631 code += QLatin1String(
", allowNewTableNames=True" );
8633 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8634 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
8648 QStringList depends;
8649 if ( !mParentConnectionParameterName.isEmpty() )
8650 depends << mParentConnectionParameterName;
8651 if ( !mParentSchemaParameterName.isEmpty() )
8652 depends << mParentSchemaParameterName;
8658 return mParentConnectionParameterName;
8663 mParentConnectionParameterName =
name;
8668 return mParentSchemaParameterName;
8673 mParentSchemaParameterName =
name;
8679 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8680 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
8681 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
8688 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8689 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
8690 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
8698 QString def = definition;
8700 const QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
8701 const QRegularExpressionMatch m = re.match( def );
8704 connection = m.captured( 1 ).trimmed();
8705 if ( connection == QLatin1String(
"none" ) )
8707 schema = m.captured( 2 ).trimmed();
8708 if ( schema == QLatin1String(
"none" ) )
8710 def = m.captured( 3 );
8718 return mAllowNewTableNames;
8731 const QVariant &defaultValue,
bool optional )
8748 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8761 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
8764 if ( var.type() != QVariant::String || var.toString().isEmpty() )
8782 if ( !val.isValid() )
8783 return QStringLiteral(
"None" );
8785 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
8789 p.insert(
name(), val );
8820 const QVariant &defaultValue,
bool optional )
8837 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8850 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
8853 if ( var.type() != QVariant::String || var.toString().isEmpty() )
8871 if ( !val.isValid() )
8872 return QStringLiteral(
"None" );
8874 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
8878 p.insert(
name(), val );
8911 QVariant var = input;
8912 if ( !var.isValid() )
8915 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
8921 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8934 if ( var.type() != QVariant::String )
8937 if ( var.toString().isEmpty() )
8945 if ( !value.isValid() )
8946 return QStringLiteral(
"None" );
8948 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8949 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8951 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
8960 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
8976 return lOriginalProvider->defaultPointCloudFileExtension();
8980 return p->defaultPointCloudFileExtension();
8991 QStringList filters;
8992 for (
const QString &ext : exts )
8994 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
8996 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9003 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9007 return p->supportedOutputPointCloudLayerExtensions();
9012 return QStringList() << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
Represents a map layer containing a set of georeferenced annotations, e.g.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Custom exception class for Coordinate Reference System related exceptions.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool isValid() const
Checks if this expression is valid.
InvalidGeometryCheck
Handling of features with invalid geometries.
@ GeometryNoCheck
No invalid geometry checking.
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
An interface for objects which accept features via addFeature(s) methods.
Container of fields for a vector layer.
static bool fileMatchesFilter(const QString &fileName, const QString &filter)
Returns true if the given fileName matches a file filter string.
A geometry is the spatial representation of a feature.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
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.
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...
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
Base class for graphical items within a QgsLayout.
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found.
QgsLayoutItem * itemById(const QString &id) const
Returns a layout item given its id.
QgsLayoutItem * itemByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout item with matching uuid unique identifier, or nullptr if a matching item could not...
Base class for all map layer types.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QString source() const
Returns the source for the layer.
QgsCoordinateReferenceSystem crs
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Interface for master layout type objects, such as print layouts and reports.
virtual QgsMasterLayoutInterface::Type layoutType() const =0
Returns the master layout type.
@ PrintLayout
Individual print layout (QgsPrintLayout)
Represents a mesh layer supporting display of data on structured or unstructured meshes.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Represents a map layer supporting display of point clouds.
A class to represent a 2D point.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
Details for layers to load into projects.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
void addLayerToLoadOnCompletion(const QString &layer, const QgsProcessingContext::LayerDetails &details)
Adds a layer to load (by ID or datasource) into the canvas upon completion of the algorithm or model.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Base class for all parameter definitions which represent file or layer destinations,...
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter.
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool createByDefault() const
Returns true if the destination should be created by default.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
virtual bool isSupportedOutputValue(const QVariant &value, QgsProcessingContext &context, QString &error) const
Tests whether a value is a supported value for this parameter.
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingDestinationParameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Custom exception class for processing related exceptions.
Encapsulates settings relating to a feature source input to a processing algorithm.
bool loadVariant(const QVariantMap &map)
Loads this source definition from a QVariantMap, wrapped in a QVariant.
Flags flags
Flags which dictate source behavior.
bool selectedFeaturesOnly
true if only selected features in the source should be used by algorithms.
QgsFeatureRequest::InvalidGeometryCheck geometryCheck
Geometry check method to apply to this source.
QgsProperty source
Source definition.
long long featureLimit
If set to a value > 0, places a limit on the maximum number of features which will be read from the s...
QVariant toVariant() const
Saves this source definition to a QVariantMap, wrapped in a QVariant.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
Base class for providing feedback from a processing algorithm.
Base class for the definition of processing outputs.
A file output for processing algorithms.
A folder output for processing algorithms.
A HTML file output for processing algorithms.
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
bool operator!=(const QgsProcessingOutputLayerDefinition &other) const
QgsProject * destinationProject
Destination project.
bool operator==(const QgsProcessingOutputLayerDefinition &other) const
QgsProperty sink
Sink/layer definition.
bool useRemapping() const
Returns true if the output uses a remapping definition.
QgsRemappingSinkDefinition remappingDefinition() const
Returns the output remapping definition, if useRemapping() is true.
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
QString destinationName
Name to use for sink if it's to be loaded into a destination project.
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
void setRemappingDefinition(const QgsRemappingSinkDefinition &definition)
Sets the remapping definition to use when adding features to the output layer.
A pointcloud layer output for processing algorithms.
A raster layer output for processing algorithms.
A vector layer output for processing algorithms.
An annotation layer parameter for processing algorithms.
QgsProcessingParameterAnnotationLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAnnotationLayer.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterAnnotationLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
static QString typeName()
Returns the type name for the parameter class.
A string parameter for authentication configuration ID values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterAuthConfig(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAuthConfig.
static QString typeName()
Returns the type name for the parameter class.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterAuthConfig * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
A raster band parameter for Processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple band selections are permitted.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
QgsProcessingParameterBand(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false, bool allowMultiple=false)
Constructor for QgsProcessingParameterBand.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterBand * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
A boolean parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterBoolean * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterBoolean(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterBoolean.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
A color parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterColor * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setOpacityEnabled(bool enabled)
Sets whether the parameter allows opacity control.
QgsProcessingParameterColor(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool opacityEnabled=true, bool optional=false)
Constructor for QgsProcessingParameterColor.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterCoordinateOperation * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterCoordinateOperation(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &sourceCrsParameterName=QString(), const QString &destinationCrsParameterName=QString(), const QVariant &staticSourceCrs=QVariant(), const QVariant &staticDestinationCrs=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCoordinateOperation.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A coordinate reference system parameter for processing algorithms.
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterCrs * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterDatabaseSchema(const QString &name, const QString &description, const QString &connectionParameterName=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterDatabaseSchema.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterDatabaseSchema * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A database table name parameter for processing algorithms, allowing users to select from existing dat...
QgsProcessingParameterDatabaseTable(const QString &name, const QString &description, const QString &connectionParameterName=QString(), const QString &schemaParameterName=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool allowNewTableNames=false)
Constructor for QgsProcessingParameterDatabaseTable.
void setParentSchemaParameterName(const QString &name)
Sets the name of the parent schema parameter.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterDatabaseTable * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
void setAllowNewTableNames(bool allowed)
Sets whether the parameter allows users to enter names for a new (non-existing) tables.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
A datetime (or pure date or time) parameter for processing algorithms.
@ DateTime
Datetime values.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setMaximum(const QDateTime &maximum)
Sets the maximum value acceptable by the parameter.
static QgsProcessingParameterDateTime * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QDateTime minimum() const
Returns the minimum value acceptable by the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
void setMinimum(const QDateTime &minimum)
Sets the minimum value acceptable by the parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QDateTime maximum() const
Returns the maximum value acceptable by the parameter.
QgsProcessingParameterDateTime(const QString &name, const QString &description=QString(), Type type=DateTime, const QVariant &defaultValue=QVariant(), bool optional=false, const QDateTime &minValue=QDateTime(), const QDateTime &maxValue=QDateTime())
Constructor for QgsProcessingParameterDateTime.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Type dataType() const
Returns the acceptable data type for the parameter.
void setDataType(Type type)
Sets the acceptable data type for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Base class for the definition of processing parameters.
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
QString mHelp
Parameter help.
virtual QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QVariant defaultValue() const
Returns the default value for the parameter.
QString valueAsStringPrivate(const QVariant &value, QgsProcessingContext &context, bool &ok, ValueAsStringFlags flags) const
Internal method for evaluating values as string.
QString help() const
Returns the help for the parameter.
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Processing script.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
virtual QStringList valueAsStringList(const QVariant &value, QgsProcessingContext &context, bool &ok) const
Returns a string list version of the parameter input value (if possible).
Flags mFlags
Parameter flags.
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
@ AllowMapLayerValues
Enable map layer value handling.
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString mName
Parameter name.
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &help=QString())
Constructor for QgsProcessingParameterDefinition.
virtual QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const
Returns a string version of the parameter input value (if possible).
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
@ FlagOptional
Parameter is optional.
QString mDescription
Parameter description.
virtual QString type() const =0
Unique parameter type name.
Flags flags() const
Returns any flags associated with the parameter.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
QString name() const
Returns the name of the parameter.
QVariant mDefault
Default value for parameter.
QVariant mGuiDefault
Default value for parameter in GUI.
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
virtual QString valueAsPythonComment(const QVariant &value, QgsProcessingContext &context) const
Returns a Python comment explaining a parameter value, or an empty string if no comment is required.
QVariant valueAsJsonObjectPrivate(const QVariant &value, QgsProcessingContext &context, ValueAsStringFlags flags) const
Internal method for evaluating values as JSON objects.
A double numeric parameter for distance values.
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
static QString typeName()
Returns the type name for the parameter class.
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString type() const override
Unique parameter type name.
QgsProcessingParameterDistance(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentParameterName=QString(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDistance.
A double numeric parameter for duration values.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDuration * clone() const override
Creates a clone of the parameter definition.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
QgsProcessingParameterDuration(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDuration.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
void setUsesStaticStrings(bool usesStaticStrings)
Sets whether the parameter uses static (non-translated) string values for its enumeration choice list...
static QgsProcessingParameterEnum * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
QgsProcessingParameterEnum(const QString &name, const QString &description=QString(), const QStringList &options=QStringList(), bool allowMultiple=false, const QVariant &defaultValue=QVariant(), bool optional=false, bool usesStaticStrings=false)
Constructor for QgsProcessingParameterEnum.
void setOptions(const QStringList &options)
Sets the list of acceptable options for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
QString valueAsPythonComment(const QVariant &value, QgsProcessingContext &context) const override
Returns a Python comment explaining a parameter value, or an empty string if no comment is required.
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
An expression parameter for processing algorithms.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterExpression * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
A rectangular map extent parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterExtent(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterExtent.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterExtent * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
A feature sink output for processing algorithms.
QString generateTemporaryDestination() const override
Generates a temporary destination value for this parameter.
static QgsProcessingParameterFeatureSink * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool hasGeometry() const
Returns true if sink is likely to include geometries.
QString type() const override
Unique parameter type name.
QgsProcessing::SourceType dataType() const
Returns the layer type for sinks associated with the parameter.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
void setSupportsAppend(bool supportsAppend)
Sets whether the sink supports appending features to an existing table.
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true, bool supportsAppend=false)
Constructor for QgsProcessingParameterFeatureSink.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the sinks associated with the parameter.
bool supportsAppend() const
Returns true if the sink supports appending features to an existing table.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
An input feature source (such as vector layers) parameter for processing algorithms.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterFeatureSource(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSource.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterFeatureSource * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
A vector layer or feature source field parameter for processing algorithms.
QgsProcessingParameterField(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), DataType type=Any, bool allowMultiple=false, bool optional=false, bool defaultToAllFields=false)
Constructor for QgsProcessingParameterField.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
void setDataType(DataType type)
Sets the acceptable data type for the field.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
DataType
Field data types.
@ DateTime
Accepts datetime fields.
@ Numeric
Accepts numeric fields.
@ String
Accepts string fields.
DataType dataType() const
Returns the acceptable data type for the field.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
void setDefaultToAllFields(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterField * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
static QgsProcessingParameterFileDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterFileDestination(const QString &name, const QString &description=QString(), const QString &fileFilter=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFileDestination.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
An input file or folder parameter for processing algorithms.
QString extension() const
Returns any specified file extension for the parameter.
void setExtension(const QString &extension)
Sets a file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
static QgsProcessingParameterFile * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior=File)
Creates a new parameter using the definition from a script code.
Behavior
Parameter behavior.
@ Folder
Parameter is a folder.
@ File
Parameter is a single file.
Behavior behavior() const
Returns the parameter behavior (e.g.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Behavior behavior=File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &fileFilter=QString())
Constructor for QgsProcessingParameterFile.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
static QgsProcessingParameterFolderDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterFolderDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFolderDestination.
A geometry parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString type() const override
Unique parameter type name.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterGeometry(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &geometryTypes=QList< int >(), bool allowMultipart=true)
Constructor for QgsProcessingParameterGeometry.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterGeometry * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
A print layout item parameter, allowing users to select a particular item from a print layout.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterLayoutItem * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterLayoutItem(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayoutParameterName=QString(), int itemType=-1, bool optional=false)
Constructor for QgsProcessingParameterLayoutItem.
void setParentLayoutParameterName(const QString &name)
Sets the name of the parent layout parameter.
QString parentLayoutParameterName() const
Returns the name of the parent layout parameter, or an empty string if this is not set.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
void setItemType(int type)
Sets the acceptable item type, or -1 if any item type is allowed.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A print layout parameter, allowing users to select a print layout.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterLayout * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterLayout(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterLayout.
static QString typeName()
Returns the type name for the parameter class.
Can be inherited by parameters which require limits to their acceptable data types.
void setDataTypes(const QList< int > &types)
Sets the geometry types for sources acceptable by the parameter.
QgsProcessingParameterLimitedDataTypes(const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data types.
QList< int > mDataTypes
List of acceptable data types for the parameter.
QList< int > dataTypes() const
Returns the geometry types for sources acceptable by the parameter.
A map layer parameter for processing algorithms.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterMapLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString type() const override
Unique parameter type name.
QgsProcessingParameterMapLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterMapLayer.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterMapTheme * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterMapTheme(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMapTheme.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A table (matrix) parameter for processing algorithms.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QStringList headers() const
Returns a list of column headers (if set).
void setHeaders(const QStringList &headers)
Sets the list of column headers.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
void setHasFixedNumberRows(bool hasFixedNumberRows)
Sets whether the table has a fixed number of rows.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
void setNumberRows(int rows)
Sets the fixed number of rows in the table.
int numberRows() const
Returns the fixed number of rows in the table.
static QgsProcessingParameterMatrix * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterMatrix(const QString &name, const QString &description=QString(), int numberRows=3, bool hasFixedNumberRows=false, const QStringList &headers=QStringList(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMatrix.
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
A mesh layer parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterMeshLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
A parameter for processing algorithms which accepts multiple map layers.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), QgsProcessing::SourceType layerType=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
static QgsProcessingParameterMultipleLayers * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
QString type() const override
Unique parameter type name.
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
A numeric parameter for processing algorithms.
double minimum() const
Returns the minimum value acceptable by the parameter.
static QgsProcessingParameterNumber * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
void setMaximum(double maximum)
Sets the maximum value acceptable by the parameter.
@ Double
Double/float values.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
double maximum() const
Returns the maximum value acceptable by the parameter.
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Type type=Integer, const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterNumber.
void setDataType(Type type)
Sets the acceptable data type for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Type dataType() const
Returns the acceptable data type for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
A point cloud layer destination parameter, for specifying the destination path for a point cloud laye...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterPointCloudDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
virtual QStringList supportedOutputPointCloudLayerExtensions() const
Returns a list of the point cloud format file extensions supported for this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterPointCloudDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterPointCloudDestination.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
A point cloud layer parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
static QgsProcessingParameterPointCloudLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterPointCloudLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPointCloudLayer.
A point parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterPoint * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterPoint(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPoint.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
A data provider connection parameter for processing algorithms, allowing users to select from availab...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterProviderConnection(const QString &name, const QString &description, const QString &provider, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterProviderConnection, for the specified provider type.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterProviderConnection * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A numeric range parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setDataType(QgsProcessingParameterNumber::Type dataType)
Sets the acceptable data type for the range.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), QgsProcessingParameterNumber::Type type=QgsProcessingParameterNumber::Integer, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRange.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterRange * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterRasterDestination.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter.
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
A raster layer parameter for processing algorithms.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterRasterLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterLayer.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
A double numeric parameter for map scale values.
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterScale * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterScale * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterScale(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterScale.
A string parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setMultiLine(bool multiLine)
Sets whether the parameter allows multiline strings.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterString * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool multiLine() const
Returns true if the parameter allows multiline strings.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Makes metadata of processing parameters available.
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString type() const override
Unique parameter type name.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the created vector layer.
QgsProcessingParameterVectorDestination(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorDestination.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterVectorDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
A vector layer (with or without geometry) parameter for processing algorithms.
static QgsProcessingParameterVectorLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterVectorLayer(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorLayer.
static QString typeName()
Returns the type name for the parameter class.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
static QgsProcessingParameterDefinition * parameterFromVariantMap(const QVariantMap &map)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QgsCoordinateReferenceSystem parameterAsGeometryCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with a geometry parameter value.
static QgsAnnotationLayer * parameterAsAnnotationLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to an annotation layer.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint=QgsProcessingUtils::LayerHint::UnknownType)
Evaluates the parameter with matching definition to a map layer.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
static QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList())
Evaluates the parameter with matching definition to a feature sink.
static bool parameterAsBoolean(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QString parameterAsCompatibleSourceLayerPathAndLayerName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr, QString *layerName=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path and layer name of...
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
static QString parameterAsCompatibleSourceLayerPath(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path of compatible for...
static QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a point cloud layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsGeometry parameterAsExtentGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry cove...
static QStringList parameterAsFileList(const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultip...
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Abstract base class for processing providers.
virtual bool isSupportedOutputValue(const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error) const
Returns true if the specified outputValue is of a supported file format for the given destination par...
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
static QString convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long long featureLimit=-1)
Converts a source vector layer to a file path of a vector layer of compatible format.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
static QString defaultVectorExtension()
Returns the default vector extension to use, in the absence of all other constraints (e....
static QString normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri()
LayerHint
Layer type hints.
@ Annotation
Annotation layer type, since QGIS 3.22.
@ Vector
Vector layer type.
@ Mesh
Mesh layer type, since QGIS 3.6.
@ Raster
Raster layer type.
@ UnknownType
Unknown layer type.
@ PointCloud
Point cloud layer type, since QGIS 3.22.
static QString generateTempFilename(const QString &basename)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
static QString convertToCompatibleFormatAndLayerName(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, QString &layerName, long long featureLimit=-1)
Converts a source vector layer to a file path and layer name of a vector layer of compatible format.
static QString variantToPythonLiteral(const QVariant &value)
Converts a variant to a Python literal.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType)
Interprets a string as a map layer within the supplied context.
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
static QString defaultPointCloudExtension()
Returns the default point cloud extension to use, in the absence of all other constraints (e....
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file.
PythonOutputType
Available Python output types.
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
SourceType
Data source types enum.
@ TypePlugin
Plugin layers.
@ TypeVectorLine
Vector line layers.
@ TypeMapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ TypeVectorPolygon
Vector polygon layers.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
@ TypeAnnotation
Annotation layers.
@ TypePointCloud
Point cloud layers.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ TypeRaster
Raster layers.
@ TypeVectorPoint
Vector point layers.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
static QString sourceTypeToString(SourceType type)
Converts a source type to a string representation.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsAnnotationLayer * mainAnnotationLayer()
Returns the main annotation layer associated with the project.
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
A store for object properties.
@ ExpressionBasedProperty
Expression based property (QgsExpressionBasedProperty)
@ StaticProperty
Static property (QgsStaticProperty)
@ FieldBasedProperty
Field based property (QgsFieldBasedProperty)
@ InvalidProperty
Invalid (not set) property.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
QVariant staticValue() const
Returns the current static value for the property.
Type propertyType() const
Returns the property type.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString fileVectorFilters() const
Returns a file filter string for supported vector files.
QString fileRasterFilters() const
Returns a file filter string for supported raster files.
QString fileMeshFilters() const
Returns a file filter string for supported mesh files.
QString filePointCloudFilters() const
Returns a file filter string for supported point clouds.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
Represents a raster layer.
A rectangle specified with double values.
double 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.
TemporalUnit
Temporal units.
static bool isNull(const QVariant &variant)
Returns true if the specified variant should be considered a NULL value.
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
Represents a vector layer which manages a vector based data sets.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Type
The WKB type describes the number of dimensions a geometry has.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QString parameterAsCompatibleSourceLayerPathInternal(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName)
QString createAllMapLayerFileFilter()
const QgsCoordinateReferenceSystem & crs