18 #ifndef QGSPROCESSINGPARAMETERS_H
19 #define QGSPROCESSINGPARAMETERS_H
21 #include "qgis_core.h"
65 FlagOverrideDefaultGeometryCheck = 1 << 0,
66 FlagCreateIndividualOutputPerInputFeature = 1 << 1,
68 Q_DECLARE_FLAGS( Flags, Flag )
86 , selectedFeaturesOnly( selectedFeaturesOnly )
87 , featureLimit( featureLimit )
89 , geometryCheck( geometryCheck )
108 , selectedFeaturesOnly( selectedFeaturesOnly )
109 , featureLimit( featureLimit )
111 , geometryCheck( geometryCheck )
130 long long featureLimit = -1;
137 Flags flags = Flags();
155 QVariant toVariant()
const;
163 bool loadVariant(
const QVariantMap &map );
167 return source == other.
source
170 && flags == other.
flags
176 return !( *
this == other );
180 operator QVariant()
const
182 return QVariant::fromValue( *
this );
188 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingFeatureSourceDefinition::Flags )
210 , destinationProject( destinationProject )
220 , destinationProject( destinationProject )
283 QVariant toVariant()
const;
291 bool loadVariant(
const QVariantMap &map );
294 operator QVariant()
const
296 return QVariant::fromValue( *
this );
304 bool mUseRemapping =
false;
336 sipType = sipType_QgsProcessingParameterBoolean;
338 sipType = sipType_QgsProcessingParameterCrs;
340 sipType = sipType_QgsProcessingParameterMapLayer;
342 sipType = sipType_QgsProcessingParameterExtent;
344 sipType = sipType_QgsProcessingParameterPoint;
346 sipType = sipType_QgsProcessingParameterFile;
348 sipType = sipType_QgsProcessingParameterMatrix;
350 sipType = sipType_QgsProcessingParameterMultipleLayers;
352 sipType = sipType_QgsProcessingParameterNumber;
354 sipType = sipType_QgsProcessingParameterDistance;
356 sipType = sipType_QgsProcessingParameterScale;
358 sipType = sipType_QgsProcessingParameterRange;
360 sipType = sipType_QgsProcessingParameterRasterLayer;
362 sipType = sipType_QgsProcessingParameterMeshLayer;
364 sipType = sipType_QgsProcessingParameterEnum;
366 sipType = sipType_QgsProcessingParameterString;
368 sipType = sipType_QgsProcessingParameterExpression;
370 sipType = sipType_QgsProcessingParameterAuthConfig;
372 sipType = sipType_QgsProcessingParameterVectorLayer;
374 sipType = sipType_QgsProcessingParameterField;
376 sipType = sipType_QgsProcessingParameterFeatureSource;
378 sipType = sipType_QgsProcessingParameterFeatureSink;
380 sipType = sipType_QgsProcessingParameterVectorDestination;
382 sipType = sipType_QgsProcessingParameterRasterDestination;
384 sipType = sipType_QgsProcessingParameterFileDestination;
386 sipType = sipType_QgsProcessingParameterFolderDestination;
388 sipType = sipType_QgsProcessingParameterBand;
390 sipType = sipType_QgsProcessingParameterLayout;
392 sipType = sipType_QgsProcessingParameterLayoutItem;
394 sipType = sipType_QgsProcessingParameterColor;
396 sipType = sipType_QgsProcessingParameterCoordinateOperation;
398 sipType = sipType_QgsProcessingParameterMapTheme;
400 sipType = sipType_QgsProcessingParameterDateTime;
402 sipType = sipType_QgsProcessingParameterProviderConnection;
404 sipType = sipType_QgsProcessingParameterDatabaseSchema;
406 sipType = sipType_QgsProcessingParameterDatabaseTable;
408 sipType = sipType_QgsProcessingParameterFieldMapping;
419 FlagAdvanced = 1 << 1,
421 FlagOptional = 1 << 3,
422 FlagIsModelOutput = 1 << 4,
424 Q_DECLARE_FLAGS( Flags, Flag )
430 bool optional =
false );
442 virtual QString type()
const = 0;
456 QString
name()
const {
return mName; }
463 void setName(
const QString &name ) { mName = name; }
477 void setDescription(
const QString &description ) { mDescription = description; }
496 Flags
flags()
const {
return mFlags; }
511 virtual bool checkValueIsAcceptable(
const QVariant &input,
QgsProcessingContext *context =
nullptr )
const;
517 virtual QString valueAsPythonString(
const QVariant &value,
QgsProcessingContext &context )
const;
523 virtual QString asScriptCode()
const;
541 virtual QVariantMap toVariantMap()
const;
548 virtual bool fromVariantMap(
const QVariantMap &map );
570 void setMetadata(
const QVariantMap &metadata ) { mMetadata = metadata; }
596 virtual QString toolTip()
const;
713 bool mIsDynamic =
false;
729 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingParameterDefinition::Flags )
761 static bool isDynamic(
const QVariantMap ¶meters,
const QString &name );
1417 static QString descriptionFromName(
const QString &name );
1428 static bool parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition );
1447 bool optional =
false );
1452 static QString
typeName() {
return QStringLiteral(
"boolean" ); }
1477 QgsProcessingParameterCrs(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
1478 bool optional =
false );
1483 static QString
typeName() {
return QStringLiteral(
"crs" ); }
1510 bool optional =
false );
1515 static QString
typeName() {
return QStringLiteral(
"extent" ); }
1542 QgsProcessingParameterPoint(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
1543 bool optional =
false );
1548 static QString
typeName() {
return QStringLiteral(
"point" ); }
1585 QgsProcessingParameterFile(
const QString &name,
const QString &description = QString(), Behavior behavior = File,
const QString &extension = QString(),
const QVariant &defaultValue = QVariant(),
1586 bool optional =
false,
const QString &fileFilter = QString() );
1591 static QString
typeName() {
return QStringLiteral(
"file" ); }
1628 void setExtension(
const QString &extension );
1636 QString fileFilter()
const;
1647 void setFileFilter(
const QString &filter );
1655 static QgsProcessingParameterFile *fromScriptCode(
const QString &name,
const QString &description,
bool isOptional,
const QString &definition, Behavior behavior = File )
SIP_FACTORY;
1659 Behavior mBehavior = File;
1661 QString mFileFilter;
1678 bool hasFixedNumberRows =
false,
const QStringList &headers = QStringList(),
1679 const QVariant &defaultValue = QVariant(),
1680 bool optional =
false );
1685 static QString
typeName() {
return QStringLiteral(
"matrix" ); }
1696 QStringList headers()
const;
1702 void setHeaders(
const QStringList &headers );
1710 int numberRows()
const;
1718 void setNumberRows(
int rows );
1725 bool hasFixedNumberRows()
const;
1732 void setHasFixedNumberRows(
bool hasFixedNumberRows );
1744 QStringList mHeaders;
1745 int mNumberRows = 3;
1746 bool mFixedNumberRows =
false;
1764 const QVariant &defaultValue = QVariant(),
1765 bool optional =
false );
1770 static QString
typeName() {
return QStringLiteral(
"multilayer" ); }
1796 int minimumNumberInputs()
const;
1803 void setMinimumNumberInputs(
int minimum );
1816 int mMinimumNumberInputs = 0;
1853 Type type = Integer,
1854 const QVariant &defaultValue = QVariant(),
1855 bool optional =
false,
1856 double minValue = std::numeric_limits<double>::lowest() + 1,
1857 double maxValue = std::numeric_limits<double>::max()
1863 static QString
typeName() {
return QStringLiteral(
"number" ); }
1868 QString
toolTip()
const override;
1875 double minimum()
const;
1881 void setMinimum(
double minimum );
1887 double maximum()
const;
1893 void setMaximum(
double maximum );
1899 Type dataType()
const;
1905 void setDataType( Type type );
1917 double mMin = std::numeric_limits<double>::lowest() + 1;
1918 double mMax = std::numeric_limits<double>::max();
1919 Type mDataType = Integer;
1949 const QVariant &defaultValue = QVariant(),
1950 const QString &parentParameterName = QString(),
1951 bool optional =
false,
1952 double minValue = std::numeric_limits<double>::lowest() + 1,
1953 double maxValue = std::numeric_limits<double>::max() );
1958 static QString
typeName() {
return QStringLiteral(
"distance" ); }
1962 QString type() const override;
1963 QStringList dependsOnOtherParameters() const override;
1964 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
1970 QString parentParameterName() const;
1976 void setParentParameterName( const QString &parentParameterName );
1999 QString mParentParameterName;
2022 const QVariant &defaultValue = QVariant(),
2023 bool optional =
false );
2028 static QString
typeName() {
return QStringLiteral(
"scale" ); }
2032 QString type() const override;
2033 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
2057 const QVariant &defaultValue = QVariant(),
2058 bool optional =
false );
2063 static QString
typeName() {
return QStringLiteral(
"range" ); }
2109 bool optional =
false );
2114 static QString
typeName() {
return QStringLiteral(
"raster" ); }
2141 QgsProcessingParameterEnum(
const QString &name,
const QString &description = QString(),
const QStringList &options = QStringList(),
2142 bool allowMultiple =
false,
2143 const QVariant &defaultValue = QVariant(),
2144 bool optional =
false );
2149 static QString
typeName() {
return QStringLiteral(
"enum" ); }
2161 QStringList options()
const;
2167 void setOptions(
const QStringList &options );
2173 bool allowMultiple()
const;
2179 void setAllowMultiple(
bool allowMultiple );
2191 QStringList mOptions;
2192 bool mAllowMultiple =
false;
2210 bool multiLine =
false,
2211 bool optional =
false );
2216 static QString
typeName() {
return QStringLiteral(
"string" ); }
2227 bool multiLine()
const;
2233 void setMultiLine(
bool multiLine );
2245 bool mMultiLine =
false;
2270 bool optional =
false );
2275 static QString
typeName() {
return QStringLiteral(
"authcfg" ); }
2302 const QString &parentLayerParameterName = QString(),
2303 bool optional =
false );
2308 static QString
typeName() {
return QStringLiteral(
"expression" ); }
2319 QString parentLayerParameterName()
const;
2325 void setParentLayerParameterName(
const QString &parentLayerParameterName );
2337 QString mParentLayerParameterName;
2361 QList< int > dataTypes()
const;
2367 void setDataTypes(
const QList< int > &types );
2390 const QString &description = QString(),
2391 const QList< int > &types = QList< int >(),
2392 const QVariant &defaultValue = QVariant(),
2393 bool optional =
false );
2398 static QString
typeName() {
return QStringLiteral(
"vector" ); }
2430 const QString &description = QString(),
2431 const QVariant &defaultValue = QVariant(),
2432 bool optional =
false );
2437 static QString
typeName() {
return QStringLiteral(
"mesh" ); }
2464 bool optional =
false,
2465 const QList< int > &types = QList< int >() );
2470 static QString
typeName() {
return QStringLiteral(
"layer" ); }
2511 QgsProcessingParameterField(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
2512 const QString &parentLayerParameterName = QString(),
2513 DataType type = Any,
2514 bool allowMultiple =
false,
2515 bool optional =
false,
2516 bool defaultToAllFields =
false );
2521 static QString
typeName() {
return QStringLiteral(
"field" ); }
2534 QString parentLayerParameterName()
const;
2540 void setParentLayerParameterName(
const QString &parentLayerParameterName );
2546 DataType dataType()
const;
2552 void setDataType( DataType type );
2558 bool allowMultiple()
const;
2564 void setAllowMultiple(
bool allowMultiple );
2575 bool defaultToAllFields()
const;
2586 void setDefaultToAllFields(
bool enabled );
2598 QString mParentLayerParameterName;
2599 DataType mDataType = Any;
2600 bool mAllowMultiple =
false;
2601 bool mDefaultToAllFields =
false;
2620 const QList< int > &types = QList< int >(),
2621 const QVariant &defaultValue = QVariant(),
bool optional =
false );
2626 static QString
typeName() {
return QStringLiteral(
"source" ); }
2663 bool optional =
false,
bool createByDefault =
true );
2695 virtual QString defaultFileExtension()
const = 0;
2702 virtual QString generateTemporaryDestination()
const;
2725 bool createByDefault()
const;
2732 void setCreateByDefault(
bool createByDefault );
2757 bool mSupportsNonFileBasedOutputs =
true;
2758 bool mCreateByDefault =
true;
2760 friend class QgsProcessingModelAlgorithm;
2761 friend class TestQgsProcessing;
2784 bool optional =
false,
bool createByDefault =
true,
bool supportsAppend =
false );
2789 static QString
typeName() {
return QStringLiteral(
"sink" ); }
2796 QString defaultFileExtension() const override;
2797 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
2798 QString createFileFilter() const override;
2805 virtual QStringList supportedOutputVectorLayerExtensions() const;
2817 bool hasGeometry() const;
2833 bool supportsAppend() const;
2843 void setSupportsAppend(
bool supportsAppend );
2845 QVariantMap toVariantMap() const override;
2846 bool fromVariantMap( const QVariantMap &map ) override;
2847 QString generateTemporaryDestination() const override;
2857 bool mSupportsAppend = false;
2882 bool optional =
false,
bool createByDefault =
true );
2887 static QString
typeName() {
return QStringLiteral(
"vectorDestination" ); }
2894 QString defaultFileExtension() const override;
2895 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
2896 QString createFileFilter() const override;
2903 virtual QStringList supportedOutputVectorLayerExtensions() const;
2915 bool hasGeometry() const;
2923 QVariantMap toVariantMap() const override;
2924 bool fromVariantMap( const QVariantMap &map ) override;
2955 const QVariant &defaultValue = QVariant(),
2956 bool optional =
false,
2957 bool createByDefault =
true );
2962 static QString
typeName() {
return QStringLiteral(
"rasterDestination" ); }
2968 QString defaultFileExtension() const override;
2969 QString createFileFilter() const override;
2976 virtual QStringList supportedOutputRasterLayerExtensions() const;
3016 const QString &fileFilter = QString(),
3017 const QVariant &defaultValue = QVariant(),
3018 bool optional =
false,
3019 bool createByDefault =
true );
3024 static QString
typeName() {
return QStringLiteral(
"fileDestination" ); }
3030 QString defaultFileExtension() const override;
3031 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
3032 QString createFileFilter() const override;
3038 QString fileFilter() const;
3044 void setFileFilter( const QString &filter );
3046 QVariantMap toVariantMap() const override;
3047 bool fromVariantMap( const QVariantMap &map ) override;
3057 QString mFileFilter;
3076 const QVariant &defaultValue = QVariant(),
3077 bool optional =
false,
3078 bool createByDefault =
true );
3083 static QString
typeName() {
return QStringLiteral(
"folderDestination" ); }
3088 QString defaultFileExtension() const override;
3110 QgsProcessingParameterBand(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
3111 const QString &parentLayerParameterName = QString(),
3112 bool optional =
false,
3113 bool allowMultiple =
false );
3118 static QString
typeName() {
return QStringLiteral(
"band" ); }
3131 QString parentLayerParameterName()
const;
3137 void setParentLayerParameterName(
const QString &parentLayerParameterName );
3152 bool allowMultiple()
const;
3159 void setAllowMultiple(
bool allowMultiple );
3163 QString mParentLayerParameterName;
3164 bool mAllowMultiple =
false;
3186 bool optional =
false );
3191 static QString
typeName() {
return QStringLiteral(
"layout" ); }
3224 const QString &parentLayoutParameterName = QString(),
3226 bool optional =
false );
3231 static QString
typeName() {
return QStringLiteral(
"layoutitem" ); }
3250 QString parentLayoutParameterName()
const;
3256 void setParentLayoutParameterName(
const QString &name );
3265 int itemType()
const;
3274 void setItemType(
int type );
3277 QString mParentLayoutParameterName;
3299 QgsProcessingParameterColor(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
3300 bool opacityEnabled =
true,
3301 bool optional =
false );
3306 static QString
typeName() {
return QStringLiteral(
"color" ); }
3322 bool opacityEnabled()
const;
3331 void setOpacityEnabled(
bool enabled );
3340 bool mAllowOpacity =
true;
3362 const QString &sourceCrsParameterName = QString(),
const QString &destinationCrsParameterName = QString(),
3363 const QVariant &staticSourceCrs = QVariant(),
const QVariant &staticDestinationCrs = QVariant(),
3364 bool optional =
false );
3369 static QString
typeName() {
return QStringLiteral(
"coordinateoperation" ); }
3443 QString mSourceParameterName;
3444 QString mDestParameterName;
3445 QVariant mSourceCrs;
3468 bool optional =
false );
3473 static QString
typeName() {
return QStringLiteral(
"maptheme" ); }
3519 Type type = DateTime,
3520 const QVariant &defaultValue = QVariant(),
3521 bool optional =
false,
3522 const QDateTime &minValue = QDateTime(),
3523 const QDateTime &maxValue = QDateTime()
3529 static QString
typeName() {
return QStringLiteral(
"datetime" ); }
3534 QString
toolTip()
const override;
3544 QDateTime minimum()
const;
3557 void setMinimum(
const QDateTime &minimum );
3566 QDateTime maximum()
const;
3579 void setMaximum(
const QDateTime &maximum );
3585 Type dataType()
const;
3591 void setDataType( Type type );
3605 Type mDataType = DateTime;
3630 bool optional =
false );
3635 static QString
typeName() {
return QStringLiteral(
"providerconnection" ); }
3664 QString mProviderId;
3690 QgsProcessingParameterDatabaseSchema(
const QString &name,
const QString &description,
const QString &connectionParameterName = QString(),
const QVariant &defaultValue = QVariant(),
3691 bool optional =
false );
3696 static QString
typeName() {
return QStringLiteral(
"databaseschema" ); }
3711 QString parentConnectionParameterName()
const;
3717 void setParentConnectionParameterName(
const QString &name );
3726 QString mParentConnectionParameterName;
3754 const QString &connectionParameterName = QString(),
3755 const QString &schemaParameterName = QString(),
3756 const QVariant &defaultValue = QVariant(),
3757 bool optional =
false,
3758 bool allowNewTableNames =
false );
3763 static QString
typeName() {
return QStringLiteral(
"databasetable" ); }
3778 QString parentConnectionParameterName()
const;
3784 void setParentConnectionParameterName(
const QString &name );
3790 QString parentSchemaParameterName()
const;
3796 void setParentSchemaParameterName(
const QString &name );
3809 bool allowNewTableNames()
const;
3817 void setAllowNewTableNames(
bool allowed );
3821 QString mParentConnectionParameterName;
3822 QString mParentSchemaParameterName;
3823 bool mAllowNewTableNames =
false;
3829 #endif // QGSPROCESSINGPARAMETERS_H