1
0
mirror of https://github.com/qgis/QGIS.git synced 2025-04-30 00:04:26 -04:00

Use c++ method for available sources

This commit is contained in:
Nyall Dawson 2017-07-03 19:42:29 +10:00
parent 17199c8ffd
commit d8086e549d
9 changed files with 395 additions and 161 deletions

@ -28,17 +28,17 @@ class QgsProcessingOutputDefinition
%End %End
%ConvertToSubClassCode %ConvertToSubClassCode
if ( sipCpp->type() == "outputVector" ) if ( sipCpp->type() == QgsProcessingOutputVectorLayer::typeName() )
sipType = sipType_QgsProcessingOutputVectorLayer; sipType = sipType_QgsProcessingOutputVectorLayer;
else if ( sipCpp->type() == "outputRaster" ) else if ( sipCpp->type() == QgsProcessingOutputRasterLayer::typeName() )
sipType = sipType_QgsProcessingOutputRasterLayer; sipType = sipType_QgsProcessingOutputRasterLayer;
else if ( sipCpp->type() == "outputHtml" ) else if ( sipCpp->type() == QgsProcessingOutputHtml::typeName() )
sipType = sipType_QgsProcessingOutputHtml; sipType = sipType_QgsProcessingOutputHtml;
else if ( sipCpp->type() == "outputNumber" ) else if ( sipCpp->type() == QgsProcessingOutputNumber::typeName() )
sipType = sipType_QgsProcessingOutputNumber; sipType = sipType_QgsProcessingOutputNumber;
else if ( sipCpp->type() == "outputString" ) else if ( sipCpp->type() == QgsProcessingOutputString::typeName() )
sipType = sipType_QgsProcessingOutputString; sipType = sipType_QgsProcessingOutputString;
else if ( sipCpp->type() == "outputFolder" ) else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() )
sipType = sipType_QgsProcessingOutputFolder; sipType = sipType_QgsProcessingOutputFolder;
%End %End
public: public:
@ -111,6 +111,11 @@ class QgsProcessingOutputVectorLayer : QgsProcessingOutputDefinition
Constructor for QgsProcessingOutputVectorLayer. Constructor for QgsProcessingOutputVectorLayer.
%End %End
static QString typeName();
%Docstring
Returns the type name for the output class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
QgsProcessingParameterDefinition::LayerType dataType() const; QgsProcessingParameterDefinition::LayerType dataType() const;
@ -145,7 +150,14 @@ class QgsProcessingOutputRasterLayer : QgsProcessingOutputDefinition
Constructor for QgsProcessingOutputRasterLayer. Constructor for QgsProcessingOutputRasterLayer.
%End %End
static QString typeName();
%Docstring
Returns the type name for the output class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
}; };
class QgsProcessingOutputHtml : QgsProcessingOutputDefinition class QgsProcessingOutputHtml : QgsProcessingOutputDefinition
@ -165,7 +177,13 @@ class QgsProcessingOutputHtml : QgsProcessingOutputDefinition
Constructor for QgsProcessingOutputHtml. Constructor for QgsProcessingOutputHtml.
%End %End
static QString typeName();
%Docstring
Returns the type name for the output class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
}; };
class QgsProcessingOutputNumber : QgsProcessingOutputDefinition class QgsProcessingOutputNumber : QgsProcessingOutputDefinition
@ -185,6 +203,11 @@ class QgsProcessingOutputNumber : QgsProcessingOutputDefinition
Constructor for QgsProcessingOutputNumber. Constructor for QgsProcessingOutputNumber.
%End %End
static QString typeName();
%Docstring
Returns the type name for the output class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
}; };
@ -205,7 +228,13 @@ class QgsProcessingOutputString : QgsProcessingOutputDefinition
Constructor for QgsProcessingOutputString. Constructor for QgsProcessingOutputString.
%End %End
static QString typeName();
%Docstring
Returns the type name for the output class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
}; };
class QgsProcessingOutputFolder : QgsProcessingOutputDefinition class QgsProcessingOutputFolder : QgsProcessingOutputDefinition
@ -220,12 +249,19 @@ class QgsProcessingOutputFolder : QgsProcessingOutputDefinition
%End %End
public: public:
QgsProcessingOutputFolder( const QString &name, const QString &description = QString() ); QgsProcessingOutputFolder( const QString &name, const QString &description = QString() );
%Docstring %Docstring
Constructor for QgsProcessingOutputFolder. Constructor for QgsProcessingOutputFolder.
%End %End
static QString typeName();
%Docstring
Returns the type name for the output class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
}; };

@ -145,49 +145,49 @@ class QgsProcessingParameterDefinition
%End %End
%ConvertToSubClassCode %ConvertToSubClassCode
if ( sipCpp->type() == "boolean" ) if ( sipCpp->type() == QgsProcessingParameterBoolean::typeName() )
sipType = sipType_QgsProcessingParameterBoolean; sipType = sipType_QgsProcessingParameterBoolean;
else if ( sipCpp->type() == "crs" ) else if ( sipCpp->type() == QgsProcessingParameterCrs::typeName() )
sipType = sipType_QgsProcessingParameterCrs; sipType = sipType_QgsProcessingParameterCrs;
else if ( sipCpp->type() == "layer" ) else if ( sipCpp->type() == QgsProcessingParameterMapLayer::typeName() )
sipType = sipType_QgsProcessingParameterMapLayer; sipType = sipType_QgsProcessingParameterMapLayer;
else if ( sipCpp->type() == "extent" ) else if ( sipCpp->type() == QgsProcessingParameterExtent::typeName() )
sipType = sipType_QgsProcessingParameterExtent; sipType = sipType_QgsProcessingParameterExtent;
else if ( sipCpp->type() == "point" ) else if ( sipCpp->type() == QgsProcessingParameterPoint::typeName() )
sipType = sipType_QgsProcessingParameterPoint; sipType = sipType_QgsProcessingParameterPoint;
else if ( sipCpp->type() == "file" ) else if ( sipCpp->type() == QgsProcessingParameterFile::typeName() )
sipType = sipType_QgsProcessingParameterFile; sipType = sipType_QgsProcessingParameterFile;
else if ( sipCpp->type() == "matrix" ) else if ( sipCpp->type() == QgsProcessingParameterMatrix::typeName() )
sipType = sipType_QgsProcessingParameterMatrix; sipType = sipType_QgsProcessingParameterMatrix;
else if ( sipCpp->type() == "multilayer" ) else if ( sipCpp->type() == QgsProcessingParameterMultipleLayers::typeName() )
sipType = sipType_QgsProcessingParameterMultipleLayers; sipType = sipType_QgsProcessingParameterMultipleLayers;
else if ( sipCpp->type() == "number" ) else if ( sipCpp->type() == QgsProcessingParameterNumber::typeName() )
sipType = sipType_QgsProcessingParameterNumber; sipType = sipType_QgsProcessingParameterNumber;
else if ( sipCpp->type() == "range" ) else if ( sipCpp->type() == QgsProcessingParameterRange::typeName() )
sipType = sipType_QgsProcessingParameterRange; sipType = sipType_QgsProcessingParameterRange;
else if ( sipCpp->type() == "raster" ) else if ( sipCpp->type() == QgsProcessingParameterRasterLayer::typeName() )
sipType = sipType_QgsProcessingParameterRasterLayer; sipType = sipType_QgsProcessingParameterRasterLayer;
else if ( sipCpp->type() == "enum" ) else if ( sipCpp->type() == QgsProcessingParameterEnum::typeName() )
sipType = sipType_QgsProcessingParameterEnum; sipType = sipType_QgsProcessingParameterEnum;
else if ( sipCpp->type() == "string" ) else if ( sipCpp->type() == QgsProcessingParameterString::typeName() )
sipType = sipType_QgsProcessingParameterString; sipType = sipType_QgsProcessingParameterString;
else if ( sipCpp->type() == "expression" ) else if ( sipCpp->type() == QgsProcessingParameterExpression::typeName() )
sipType = sipType_QgsProcessingParameterExpression; sipType = sipType_QgsProcessingParameterExpression;
else if ( sipCpp->type() == "vector" ) else if ( sipCpp->type() == QgsProcessingParameterVectorLayer::typeName() )
sipType = sipType_QgsProcessingParameterVectorLayer; sipType = sipType_QgsProcessingParameterVectorLayer;
else if ( sipCpp->type() == "field" ) else if ( sipCpp->type() == QgsProcessingParameterField::typeName() )
sipType = sipType_QgsProcessingParameterField; sipType = sipType_QgsProcessingParameterField;
else if ( sipCpp->type() == "source" ) else if ( sipCpp->type() == QgsProcessingParameterFeatureSource::typeName() )
sipType = sipType_QgsProcessingParameterFeatureSource; sipType = sipType_QgsProcessingParameterFeatureSource;
else if ( sipCpp->type() == "sink" ) else if ( sipCpp->type() == QgsProcessingParameterFeatureSink::typeName() )
sipType = sipType_QgsProcessingParameterFeatureSink; sipType = sipType_QgsProcessingParameterFeatureSink;
else if ( sipCpp->type() == "vectorOut" ) else if ( sipCpp->type() == QgsProcessingParameterVectorOutput::typeName() )
sipType = sipType_QgsProcessingParameterVectorOutput; sipType = sipType_QgsProcessingParameterVectorOutput;
else if ( sipCpp->type() == "rasterOut" ) else if ( sipCpp->type() == QgsProcessingParameterRasterOutput::typeName() )
sipType = sipType_QgsProcessingParameterRasterOutput; sipType = sipType_QgsProcessingParameterRasterOutput;
else if ( sipCpp->type() == "fileOut" ) else if ( sipCpp->type() == QgsProcessingParameterFileOutput::typeName() )
sipType = sipType_QgsProcessingParameterFileOutput; sipType = sipType_QgsProcessingParameterFileOutput;
else if ( sipCpp->type() == "folderOut" ) else if ( sipCpp->type() == QgsProcessingParameterFolderOutput::typeName() )
sipType = sipType_QgsProcessingParameterFolderOutput; sipType = sipType_QgsProcessingParameterFolderOutput;
%End %End
public: public:
@ -607,6 +607,11 @@ class QgsProcessingParameterBoolean : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterBoolean. Constructor for QgsProcessingParameterBoolean.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const; virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;
@ -638,6 +643,11 @@ class QgsProcessingParameterCrs : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterCrs. Constructor for QgsProcessingParameterCrs.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -670,6 +680,11 @@ class QgsProcessingParameterMapLayer : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterMapLayer. Constructor for QgsProcessingParameterMapLayer.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -702,6 +717,11 @@ class QgsProcessingParameterExtent : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterExtent. Constructor for QgsProcessingParameterExtent.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -735,6 +755,11 @@ class QgsProcessingParameterPoint : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterPoint. Constructor for QgsProcessingParameterPoint.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -771,6 +796,11 @@ class QgsProcessingParameterFile : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterFile. Constructor for QgsProcessingParameterFile.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -836,6 +866,11 @@ class QgsProcessingParameterMatrix : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterMatrix. Constructor for QgsProcessingParameterMatrix.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -919,6 +954,11 @@ class QgsProcessingParameterMultipleLayers : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterMultipleLayers. Constructor for QgsProcessingParameterMultipleLayers.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -997,6 +1037,11 @@ class QgsProcessingParameterNumber : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterNumber. Constructor for QgsProcessingParameterNumber.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1075,6 +1120,11 @@ class QgsProcessingParameterRange : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterRange. Constructor for QgsProcessingParameterRange.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1125,6 +1175,11 @@ class QgsProcessingParameterRasterLayer : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterRasterLayer. Constructor for QgsProcessingParameterRasterLayer.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1159,6 +1214,11 @@ class QgsProcessingParameterEnum : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterEnum. Constructor for QgsProcessingParameterEnum.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1225,6 +1285,11 @@ class QgsProcessingParameterString : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterString. Constructor for QgsProcessingParameterString.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const; virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;
@ -1276,6 +1341,11 @@ class QgsProcessingParameterExpression : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterExpression. Constructor for QgsProcessingParameterExpression.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const; virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;
@ -1327,6 +1397,11 @@ class QgsProcessingParameterVectorLayer : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterVectorLayer. Constructor for QgsProcessingParameterVectorLayer.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1370,6 +1445,11 @@ class QgsProcessingParameterField : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterField. Constructor for QgsProcessingParameterField.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1451,6 +1531,11 @@ class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition
Constructor for QgsProcessingParameterFeatureSource. Constructor for QgsProcessingParameterFeatureSource.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1570,6 +1655,11 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter
Constructor for QgsProcessingParameterFeatureSink. Constructor for QgsProcessingParameterFeatureSink.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1637,6 +1727,11 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
Constructor for QgsProcessingParameterVectorOutput. Constructor for QgsProcessingParameterVectorOutput.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1702,6 +1797,11 @@ class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter
Constructor for QgsProcessingParameterRasterOutput. Constructor for QgsProcessingParameterRasterOutput.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1739,6 +1839,11 @@ class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter
Constructor for QgsProcessingParameterFileOutput. Constructor for QgsProcessingParameterFileOutput.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
@ -1795,6 +1900,11 @@ class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter
Constructor for QgsProcessingParameterFolderOutput. Constructor for QgsProcessingParameterFolderOutput.
%End %End
static QString typeName();
%Docstring
Returns the type name for the parameter class.
:rtype: str
%End
virtual QString type() const; virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;

@ -909,7 +909,7 @@ class StringWidgetWrapper(WidgetWrapper, ExpressionWidgetWrapperMixin):
else: else:
# strings, numbers, files and table fields are all allowed input types # strings, numbers, files and table fields are all allowed input types
strings = self.dialog.getAvailableValuesOfType([QgsProcessingParameterString, QgsProcessingParameterNumber, QgsProcessingParameterFile, strings = self.dialog.getAvailableValuesOfType([QgsProcessingParameterString, QgsProcessingParameterNumber, QgsProcessingParameterFile,
QgsProcessingParameterField, QgsProcessingParameterExpression], QgsProcessingOutputString) QgsProcessingParameterField, QgsProcessingParameterExpression], [QgsProcessingOutputString])
options = [(self.dialog.resolveValueDescription(s), s) for s in strings] options = [(self.dialog.resolveValueDescription(s), s) for s in strings]
if self.param.multiLine(): if self.param.multiLine():
widget = MultilineTextPanel(options) widget = MultilineTextPanel(options)

@ -40,7 +40,8 @@ from qgis.core import (QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSink, QgsProcessingParameterFeatureSink,
QgsProcessingParameterRasterOutput, QgsProcessingParameterRasterOutput,
QgsProcessingParameterFileOutput, QgsProcessingParameterFileOutput,
QgsProcessingParameterFolderOutput) QgsProcessingParameterFolderOutput,
QgsProcessingOutputDefinition)
from qgis.gui import (QgsMessageBar, from qgis.gui import (QgsMessageBar,
QgsScrollArea) QgsScrollArea)
@ -65,7 +66,7 @@ class ModelerParametersDialog(QDialog):
# The model this algorithm is going to be added to # The model this algorithm is going to be added to
self.model = model self.model = model
# The name of the algorithm in the model, in case we are editing it and not defining it for the first time # The name of the algorithm in the model, in case we are editing it and not defining it for the first time
self._algName = algName self.childId = algName
self.setupUi() self.setupUi()
self.params = None self.params = None
@ -191,11 +192,11 @@ class ModelerParametersDialog(QDialog):
wrapper.postInitialize(list(self.wrappers.values())) wrapper.postInitialize(list(self.wrappers.values()))
def getAvailableDependencies(self): # spellok def getAvailableDependencies(self): # spellok
if self._algName is None: if self.childId is None:
dependent = [] dependent = []
else: else:
dependent = list(self.model.dependentChildAlgorithms(self._algName)) dependent = list(self.model.dependentChildAlgorithms(self.childId))
dependent.append(self._algName) dependent.append(self.childId)
opts = [] opts = []
for alg in list(self.model.childAlgorithms().values()): for alg in list(self.model.childAlgorithms().values()):
if alg.childId() not in dependent: if alg.childId() not in dependent:
@ -216,7 +217,7 @@ class ModelerParametersDialog(QDialog):
self.labels[param.name()].setVisible(self.showAdvanced) self.labels[param.name()].setVisible(self.showAdvanced)
self.widgets[param.name()].setVisible(self.showAdvanced) self.widgets[param.name()].setVisible(self.showAdvanced)
def getAvailableValuesOfType(self, paramType, outTypes=[], dataType=None): def getAvailableValuesOfType(self, paramType, outTypes=[], dataTypes=[]):
# upgrade paramType to list # upgrade paramType to list
if paramType is None: if paramType is None:
paramType = [] paramType = []
@ -227,41 +228,8 @@ class ModelerParametersDialog(QDialog):
elif not isinstance(outTypes, list): elif not isinstance(outTypes, list):
outTypes = [outTypes] outTypes = [outTypes]
values = [] return self.model.availableSourcesForChild(self.childId, [p.typeName() for p in paramType if issubclass(p, QgsProcessingParameterDefinition)],
inputs = self.model.parameterComponents() [o.typeName() for o in outTypes if issubclass(o, QgsProcessingOutputDefinition)], dataTypes)
for i in list(inputs.values()):
param = self.model.parameterDefinition(i.parameterName())
for t in paramType:
if isinstance(param, t):
if dataType is not None:
if param.datatype in dataType:
values.append(
QgsProcessingModelAlgorithm.ChildParameterSource.fromModelParameter(param.name()))
else:
values.append(QgsProcessingModelAlgorithm.ChildParameterSource.fromModelParameter(param.name()))
break
if not outTypes:
return values
if self._algName is None:
dependent = []
else:
dependent = list(self.model.dependentChildAlgorithms(self._algName))
dependent.append(self._algName)
for alg in list(self.model.childAlgorithms().values()):
if alg.childId() not in dependent:
for out in alg.algorithm().outputDefinitions():
for t in outTypes:
if isinstance(out, t):
if dataType is not None and out.datatype in dataType:
values.append(
QgsProcessingModelAlgorithm.ChildParameterSource.fromChildOutput(alg.childId(),
out.name()))
else:
values.append(
QgsProcessingModelAlgorithm.ChildParameterSource.fromChildOutput(alg.childId(),
out.name()))
return values
def resolveValueDescription(self, value): def resolveValueDescription(self, value):
if isinstance(value, QgsProcessingModelAlgorithm.ChildParameterSource): if isinstance(value, QgsProcessingModelAlgorithm.ChildParameterSource):
@ -277,8 +245,8 @@ class ModelerParametersDialog(QDialog):
return value return value
def setPreviousValues(self): def setPreviousValues(self):
if self._algName is not None: if self.childId is not None:
alg = self.model.childAlgorithm(self._algName) alg = self.model.childAlgorithm(self.childId)
self.descriptionBox.setText(alg.description()) self.descriptionBox.setText(alg.description())
for param in alg.algorithm().parameterDefinitions(): for param in alg.algorithm().parameterDefinitions():
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden: if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:
@ -308,10 +276,10 @@ class ModelerParametersDialog(QDialog):
def createAlgorithm(self): def createAlgorithm(self):
alg = QgsProcessingModelAlgorithm.ChildAlgorithm(self._alg.id()) alg = QgsProcessingModelAlgorithm.ChildAlgorithm(self._alg.id())
if not self._algName: if not self.childId:
alg.generateChildId(self.model) alg.generateChildId(self.model)
else: else:
alg.setChildId(self._algName) alg.setChildId(self.childId)
alg.setDescription(self.descriptionBox.text()) alg.setDescription(self.descriptionBox.text())
for param in self._alg.parameterDefinitions(): for param in self._alg.parameterDefinitions():
if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden: if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden:

@ -91,16 +91,18 @@ def createExpressionContext():
context.appendScope(QgsExpressionContextUtils.globalScope()) context.appendScope(QgsExpressionContextUtils.globalScope())
context.appendScope(QgsExpressionContextUtils.projectScope(QgsProject.instance())) context.appendScope(QgsExpressionContextUtils.projectScope(QgsProject.instance()))
if iface.mapCanvas(): if iface and iface.mapCanvas():
context.appendScope(QgsExpressionContextUtils.mapSettingsScope(iface.mapCanvas().mapSettings())) context.appendScope(QgsExpressionContextUtils.mapSettingsScope(iface.mapCanvas().mapSettings()))
processingScope = QgsExpressionContextScope() processingScope = QgsExpressionContextScope()
if iface and iface.mapCanvas():
extent = iface.mapCanvas().fullExtent() extent = iface.mapCanvas().fullExtent()
processingScope.setVariable('fullextent_minx', extent.xMinimum()) processingScope.setVariable('fullextent_minx', extent.xMinimum())
processingScope.setVariable('fullextent_miny', extent.yMinimum()) processingScope.setVariable('fullextent_miny', extent.yMinimum())
processingScope.setVariable('fullextent_maxx', extent.xMaximum()) processingScope.setVariable('fullextent_maxx', extent.xMaximum())
processingScope.setVariable('fullextent_maxy', extent.yMaximum()) processingScope.setVariable('fullextent_maxy', extent.yMaximum())
context.appendScope(processingScope) context.appendScope(processingScope)
return context return context

@ -678,7 +678,7 @@ QgsProcessingModelAlgorithm::ChildParameterSources QgsProcessingModelAlgorithm::
{ {
if ( !dataTypes.isEmpty() ) if ( !dataTypes.isEmpty() )
{ {
if ( def->type() == QStringLiteral( "field" ) ) if ( def->type() == QgsProcessingParameterField::typeName() )
{ {
const QgsProcessingParameterField *fieldDef = static_cast< const QgsProcessingParameterField * >( def ); const QgsProcessingParameterField *fieldDef = static_cast< const QgsProcessingParameterField * >( def );
if ( !( dataTypes.contains( fieldDef->dataType() ) || fieldDef->dataType() == QgsProcessingParameterField::Any ) ) if ( !( dataTypes.contains( fieldDef->dataType() ) || fieldDef->dataType() == QgsProcessingParameterField::Any ) )
@ -686,7 +686,7 @@ QgsProcessingModelAlgorithm::ChildParameterSources QgsProcessingModelAlgorithm::
continue; continue;
} }
} }
else if ( def->type() == "source" ) else if ( def->type() == QgsProcessingParameterFeatureSource::typeName() )
{ {
const QgsProcessingParameterFeatureSource *sourceDef = static_cast< const QgsProcessingParameterFeatureSource *>( def ); const QgsProcessingParameterFeatureSource *sourceDef = static_cast< const QgsProcessingParameterFeatureSource *>( def );
bool ok = !sourceDef->dataTypes().isEmpty(); bool ok = !sourceDef->dataTypes().isEmpty();
@ -729,7 +729,7 @@ QgsProcessingModelAlgorithm::ChildParameterSources QgsProcessingModelAlgorithm::
{ {
if ( !dataTypes.isEmpty() ) if ( !dataTypes.isEmpty() )
{ {
if ( out->type() == QStringLiteral( "outputVector" ) ) if ( out->type() == QgsProcessingOutputVectorLayer::typeName() )
{ {
const QgsProcessingOutputVectorLayer *vectorOut = static_cast< const QgsProcessingOutputVectorLayer *>( out ); const QgsProcessingOutputVectorLayer *vectorOut = static_cast< const QgsProcessingOutputVectorLayer *>( out );
if ( !( dataTypes.contains( vectorOut->dataType() ) || vectorOut->dataType() == QgsProcessingParameterDefinition::TypeAny ) ) if ( !( dataTypes.contains( vectorOut->dataType() ) || vectorOut->dataType() == QgsProcessingParameterDefinition::TypeAny ) )

@ -43,17 +43,17 @@ class CORE_EXPORT QgsProcessingOutputDefinition
#ifdef SIP_RUN #ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE SIP_CONVERT_TO_SUBCLASS_CODE
if ( sipCpp->type() == "outputVector" ) if ( sipCpp->type() == QgsProcessingOutputVectorLayer::typeName() )
sipType = sipType_QgsProcessingOutputVectorLayer; sipType = sipType_QgsProcessingOutputVectorLayer;
else if ( sipCpp->type() == "outputRaster" ) else if ( sipCpp->type() == QgsProcessingOutputRasterLayer::typeName() )
sipType = sipType_QgsProcessingOutputRasterLayer; sipType = sipType_QgsProcessingOutputRasterLayer;
else if ( sipCpp->type() == "outputHtml" ) else if ( sipCpp->type() == QgsProcessingOutputHtml::typeName() )
sipType = sipType_QgsProcessingOutputHtml; sipType = sipType_QgsProcessingOutputHtml;
else if ( sipCpp->type() == "outputNumber" ) else if ( sipCpp->type() == QgsProcessingOutputNumber::typeName() )
sipType = sipType_QgsProcessingOutputNumber; sipType = sipType_QgsProcessingOutputNumber;
else if ( sipCpp->type() == "outputString" ) else if ( sipCpp->type() == QgsProcessingOutputString::typeName() )
sipType = sipType_QgsProcessingOutputString; sipType = sipType_QgsProcessingOutputString;
else if ( sipCpp->type() == "outputFolder" ) else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() )
sipType = sipType_QgsProcessingOutputFolder; sipType = sipType_QgsProcessingOutputFolder;
SIP_END SIP_END
#endif #endif
@ -128,7 +128,11 @@ class CORE_EXPORT QgsProcessingOutputVectorLayer : public QgsProcessingOutputDef
*/ */
QgsProcessingOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny ); QgsProcessingOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny );
QString type() const override { return QStringLiteral( "outputVector" ); } /**
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputVector" ); }
QString type() const override { return typeName(); }
/** /**
* Returns the layer type for the output layer. * Returns the layer type for the output layer.
@ -162,7 +166,13 @@ class CORE_EXPORT QgsProcessingOutputRasterLayer : public QgsProcessingOutputDef
*/ */
QgsProcessingOutputRasterLayer( const QString &name, const QString &description = QString() ); QgsProcessingOutputRasterLayer( const QString &name, const QString &description = QString() );
QString type() const override { return QStringLiteral( "outputRaster" ); } /**
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputRaster" ); }
QString type() const override { return typeName(); }
}; };
/** /**
@ -180,7 +190,12 @@ class CORE_EXPORT QgsProcessingOutputHtml : public QgsProcessingOutputDefinition
*/ */
QgsProcessingOutputHtml( const QString &name, const QString &description = QString() ); QgsProcessingOutputHtml( const QString &name, const QString &description = QString() );
QString type() const override { return QStringLiteral( "outputHtml" ); } /**
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputHtml" ); }
QString type() const override { return typeName(); }
}; };
/** /**
@ -198,7 +213,11 @@ class CORE_EXPORT QgsProcessingOutputNumber : public QgsProcessingOutputDefiniti
*/ */
QgsProcessingOutputNumber( const QString &name, const QString &description = QString() ); QgsProcessingOutputNumber( const QString &name, const QString &description = QString() );
QString type() const override { return QStringLiteral( "outputNumber" ); } /**
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputNumber" ); }
QString type() const override { return typeName(); }
}; };
/** /**
@ -216,7 +235,12 @@ class CORE_EXPORT QgsProcessingOutputString : public QgsProcessingOutputDefiniti
*/ */
QgsProcessingOutputString( const QString &name, const QString &description = QString() ); QgsProcessingOutputString( const QString &name, const QString &description = QString() );
QString type() const override { return QStringLiteral( "outputString" ); } /**
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputString" ); }
QString type() const override { return typeName(); }
}; };
/** /**
@ -232,9 +256,15 @@ class CORE_EXPORT QgsProcessingOutputFolder : public QgsProcessingOutputDefiniti
/** /**
* Constructor for QgsProcessingOutputFolder. * Constructor for QgsProcessingOutputFolder.
*/ */
QgsProcessingOutputFolder( const QString &name, const QString &description = QString() ); QgsProcessingOutputFolder( const QString &name, const QString &description = QString() );
QString type() const override { return QStringLiteral( "outputFolder" ); } /**
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputFolder" ); }
QString type() const override { return typeName(); }
}; };
#endif // QGSPROCESSINGOUTPUTS_H #endif // QGSPROCESSINGOUTPUTS_H

@ -747,49 +747,49 @@ QgsProcessingParameterDefinition *QgsProcessingParameters::parameterFromVariantM
QString type = map.value( QStringLiteral( "parameter_type" ) ).toString(); QString type = map.value( QStringLiteral( "parameter_type" ) ).toString();
QString name = map.value( QStringLiteral( "name" ) ).toString(); QString name = map.value( QStringLiteral( "name" ) ).toString();
std::unique_ptr< QgsProcessingParameterDefinition > def; std::unique_ptr< QgsProcessingParameterDefinition > def;
if ( type == QStringLiteral( "boolean" ) ) if ( type == QgsProcessingParameterBoolean::typeName() )
def.reset( new QgsProcessingParameterBoolean( name ) ); def.reset( new QgsProcessingParameterBoolean( name ) );
else if ( type == QStringLiteral( "crs" ) ) else if ( type == QgsProcessingParameterCrs::typeName() )
def.reset( new QgsProcessingParameterCrs( name ) ); def.reset( new QgsProcessingParameterCrs( name ) );
else if ( type == QStringLiteral( "layer" ) ) else if ( type == QgsProcessingParameterMapLayer::typeName() )
def.reset( new QgsProcessingParameterMapLayer( name ) ); def.reset( new QgsProcessingParameterMapLayer( name ) );
else if ( type == QStringLiteral( "extent" ) ) else if ( type == QgsProcessingParameterExtent::typeName() )
def.reset( new QgsProcessingParameterExtent( name ) ); def.reset( new QgsProcessingParameterExtent( name ) );
else if ( type == QStringLiteral( "point" ) ) else if ( type == QgsProcessingParameterPoint::typeName() )
def.reset( new QgsProcessingParameterPoint( name ) ); def.reset( new QgsProcessingParameterPoint( name ) );
else if ( type == QStringLiteral( "file" ) ) else if ( type == QgsProcessingParameterFile::typeName() )
def.reset( new QgsProcessingParameterFile( name ) ); def.reset( new QgsProcessingParameterFile( name ) );
else if ( type == QStringLiteral( "matrix" ) ) else if ( type == QgsProcessingParameterMatrix::typeName() )
def.reset( new QgsProcessingParameterMatrix( name ) ); def.reset( new QgsProcessingParameterMatrix( name ) );
else if ( type == QStringLiteral( "multilayer" ) ) else if ( type == QgsProcessingParameterMultipleLayers::typeName() )
def.reset( new QgsProcessingParameterMultipleLayers( name ) ); def.reset( new QgsProcessingParameterMultipleLayers( name ) );
else if ( type == QStringLiteral( "number" ) ) else if ( type == QgsProcessingParameterNumber::typeName() )
def.reset( new QgsProcessingParameterNumber( name ) ); def.reset( new QgsProcessingParameterNumber( name ) );
else if ( type == QStringLiteral( "range" ) ) else if ( type == QgsProcessingParameterRange::typeName() )
def.reset( new QgsProcessingParameterRange( name ) ); def.reset( new QgsProcessingParameterRange( name ) );
else if ( type == QStringLiteral( "raster" ) ) else if ( type == QgsProcessingParameterRasterLayer::typeName() )
def.reset( new QgsProcessingParameterRasterLayer( name ) ); def.reset( new QgsProcessingParameterRasterLayer( name ) );
else if ( type == QStringLiteral( "enum" ) ) else if ( type == QgsProcessingParameterEnum::typeName() )
def.reset( new QgsProcessingParameterEnum( name ) ); def.reset( new QgsProcessingParameterEnum( name ) );
else if ( type == QStringLiteral( "string" ) ) else if ( type == QgsProcessingParameterString::typeName() )
def.reset( new QgsProcessingParameterString( name ) ); def.reset( new QgsProcessingParameterString( name ) );
else if ( type == QStringLiteral( "expression" ) ) else if ( type == QgsProcessingParameterExpression::typeName() )
def.reset( new QgsProcessingParameterExpression( name ) ); def.reset( new QgsProcessingParameterExpression( name ) );
else if ( type == QStringLiteral( "vector" ) ) else if ( type == QgsProcessingParameterVectorLayer::typeName() )
def.reset( new QgsProcessingParameterVectorLayer( name ) ); def.reset( new QgsProcessingParameterVectorLayer( name ) );
else if ( type == QStringLiteral( "field" ) ) else if ( type == QgsProcessingParameterField::typeName() )
def.reset( new QgsProcessingParameterField( name ) ); def.reset( new QgsProcessingParameterField( name ) );
else if ( type == QStringLiteral( "source" ) ) else if ( type == QgsProcessingParameterFeatureSource::typeName() )
def.reset( new QgsProcessingParameterFeatureSource( name ) ); def.reset( new QgsProcessingParameterFeatureSource( name ) );
else if ( type == QStringLiteral( "sink" ) ) else if ( type == QgsProcessingParameterFeatureSink::typeName() )
def.reset( new QgsProcessingParameterFeatureSink( name ) ); def.reset( new QgsProcessingParameterFeatureSink( name ) );
else if ( type == QStringLiteral( "vectorOut" ) ) else if ( type == QgsProcessingParameterVectorOutput::typeName() )
def.reset( new QgsProcessingParameterVectorOutput( name ) ); def.reset( new QgsProcessingParameterVectorOutput( name ) );
else if ( type == QStringLiteral( "rasterOut" ) ) else if ( type == QgsProcessingParameterRasterOutput::typeName() )
def.reset( new QgsProcessingParameterRasterOutput( name ) ); def.reset( new QgsProcessingParameterRasterOutput( name ) );
else if ( type == QStringLiteral( "fileOut" ) ) else if ( type == QgsProcessingParameterFileOutput::typeName() )
def.reset( new QgsProcessingParameterFileOutput( name ) ); def.reset( new QgsProcessingParameterFileOutput( name ) );
else if ( type == QStringLiteral( "folderOut" ) ) else if ( type == QgsProcessingParameterFolderOutput::typeName() )
def.reset( new QgsProcessingParameterFolderOutput( name ) ); def.reset( new QgsProcessingParameterFolderOutput( name ) );
if ( !def ) if ( !def )

@ -185,49 +185,49 @@ class CORE_EXPORT QgsProcessingParameterDefinition
#ifdef SIP_RUN #ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE SIP_CONVERT_TO_SUBCLASS_CODE
if ( sipCpp->type() == "boolean" ) if ( sipCpp->type() == QgsProcessingParameterBoolean::typeName() )
sipType = sipType_QgsProcessingParameterBoolean; sipType = sipType_QgsProcessingParameterBoolean;
else if ( sipCpp->type() == "crs" ) else if ( sipCpp->type() == QgsProcessingParameterCrs::typeName() )
sipType = sipType_QgsProcessingParameterCrs; sipType = sipType_QgsProcessingParameterCrs;
else if ( sipCpp->type() == "layer" ) else if ( sipCpp->type() == QgsProcessingParameterMapLayer::typeName() )
sipType = sipType_QgsProcessingParameterMapLayer; sipType = sipType_QgsProcessingParameterMapLayer;
else if ( sipCpp->type() == "extent" ) else if ( sipCpp->type() == QgsProcessingParameterExtent::typeName() )
sipType = sipType_QgsProcessingParameterExtent; sipType = sipType_QgsProcessingParameterExtent;
else if ( sipCpp->type() == "point" ) else if ( sipCpp->type() == QgsProcessingParameterPoint::typeName() )
sipType = sipType_QgsProcessingParameterPoint; sipType = sipType_QgsProcessingParameterPoint;
else if ( sipCpp->type() == "file" ) else if ( sipCpp->type() == QgsProcessingParameterFile::typeName() )
sipType = sipType_QgsProcessingParameterFile; sipType = sipType_QgsProcessingParameterFile;
else if ( sipCpp->type() == "matrix" ) else if ( sipCpp->type() == QgsProcessingParameterMatrix::typeName() )
sipType = sipType_QgsProcessingParameterMatrix; sipType = sipType_QgsProcessingParameterMatrix;
else if ( sipCpp->type() == "multilayer" ) else if ( sipCpp->type() == QgsProcessingParameterMultipleLayers::typeName() )
sipType = sipType_QgsProcessingParameterMultipleLayers; sipType = sipType_QgsProcessingParameterMultipleLayers;
else if ( sipCpp->type() == "number" ) else if ( sipCpp->type() == QgsProcessingParameterNumber::typeName() )
sipType = sipType_QgsProcessingParameterNumber; sipType = sipType_QgsProcessingParameterNumber;
else if ( sipCpp->type() == "range" ) else if ( sipCpp->type() == QgsProcessingParameterRange::typeName() )
sipType = sipType_QgsProcessingParameterRange; sipType = sipType_QgsProcessingParameterRange;
else if ( sipCpp->type() == "raster" ) else if ( sipCpp->type() == QgsProcessingParameterRasterLayer::typeName() )
sipType = sipType_QgsProcessingParameterRasterLayer; sipType = sipType_QgsProcessingParameterRasterLayer;
else if ( sipCpp->type() == "enum" ) else if ( sipCpp->type() == QgsProcessingParameterEnum::typeName() )
sipType = sipType_QgsProcessingParameterEnum; sipType = sipType_QgsProcessingParameterEnum;
else if ( sipCpp->type() == "string" ) else if ( sipCpp->type() == QgsProcessingParameterString::typeName() )
sipType = sipType_QgsProcessingParameterString; sipType = sipType_QgsProcessingParameterString;
else if ( sipCpp->type() == "expression" ) else if ( sipCpp->type() == QgsProcessingParameterExpression::typeName() )
sipType = sipType_QgsProcessingParameterExpression; sipType = sipType_QgsProcessingParameterExpression;
else if ( sipCpp->type() == "vector" ) else if ( sipCpp->type() == QgsProcessingParameterVectorLayer::typeName() )
sipType = sipType_QgsProcessingParameterVectorLayer; sipType = sipType_QgsProcessingParameterVectorLayer;
else if ( sipCpp->type() == "field" ) else if ( sipCpp->type() == QgsProcessingParameterField::typeName() )
sipType = sipType_QgsProcessingParameterField; sipType = sipType_QgsProcessingParameterField;
else if ( sipCpp->type() == "source" ) else if ( sipCpp->type() == QgsProcessingParameterFeatureSource::typeName() )
sipType = sipType_QgsProcessingParameterFeatureSource; sipType = sipType_QgsProcessingParameterFeatureSource;
else if ( sipCpp->type() == "sink" ) else if ( sipCpp->type() == QgsProcessingParameterFeatureSink::typeName() )
sipType = sipType_QgsProcessingParameterFeatureSink; sipType = sipType_QgsProcessingParameterFeatureSink;
else if ( sipCpp->type() == "vectorOut" ) else if ( sipCpp->type() == QgsProcessingParameterVectorOutput::typeName() )
sipType = sipType_QgsProcessingParameterVectorOutput; sipType = sipType_QgsProcessingParameterVectorOutput;
else if ( sipCpp->type() == "rasterOut" ) else if ( sipCpp->type() == QgsProcessingParameterRasterOutput::typeName() )
sipType = sipType_QgsProcessingParameterRasterOutput; sipType = sipType_QgsProcessingParameterRasterOutput;
else if ( sipCpp->type() == "fileOut" ) else if ( sipCpp->type() == QgsProcessingParameterFileOutput::typeName() )
sipType = sipType_QgsProcessingParameterFileOutput; sipType = sipType_QgsProcessingParameterFileOutput;
else if ( sipCpp->type() == "folderOut" ) else if ( sipCpp->type() == QgsProcessingParameterFolderOutput::typeName() )
sipType = sipType_QgsProcessingParameterFolderOutput; sipType = sipType_QgsProcessingParameterFolderOutput;
SIP_END SIP_END
#endif #endif
@ -628,7 +628,11 @@ class CORE_EXPORT QgsProcessingParameterBoolean : public QgsProcessingParameterD
QgsProcessingParameterBoolean( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(), QgsProcessingParameterBoolean( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "boolean" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "boolean" ); }
QString type() const override { return typeName(); }
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -654,7 +658,11 @@ class CORE_EXPORT QgsProcessingParameterCrs : public QgsProcessingParameterDefin
QgsProcessingParameterCrs( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(), QgsProcessingParameterCrs( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "crs" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "crs" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -681,7 +689,11 @@ class CORE_EXPORT QgsProcessingParameterMapLayer : public QgsProcessingParameter
QgsProcessingParameterMapLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(), QgsProcessingParameterMapLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "layer" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "layer" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -708,7 +720,11 @@ class CORE_EXPORT QgsProcessingParameterExtent : public QgsProcessingParameterDe
QgsProcessingParameterExtent( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(), QgsProcessingParameterExtent( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "extent" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "extent" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -736,7 +752,11 @@ class CORE_EXPORT QgsProcessingParameterPoint : public QgsProcessingParameterDef
QgsProcessingParameterPoint( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(), QgsProcessingParameterPoint( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "point" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "point" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
/** /**
@ -769,7 +789,11 @@ class CORE_EXPORT QgsProcessingParameterFile : public QgsProcessingParameterDefi
QgsProcessingParameterFile( const QString &name, const QString &description = QString(), Behavior behavior = File, const QString &extension = QString(), const QVariant &defaultValue = QVariant(), QgsProcessingParameterFile( const QString &name, const QString &description = QString(), Behavior behavior = File, const QString &extension = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "file" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "file" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -829,7 +853,11 @@ class CORE_EXPORT QgsProcessingParameterMatrix : public QgsProcessingParameterDe
const QVariant &defaultValue = QVariant(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "matrix" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "matrix" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -908,7 +936,11 @@ class CORE_EXPORT QgsProcessingParameterMultipleLayers : public QgsProcessingPar
const QVariant &defaultValue = QVariant(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "multilayer" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "multilayer" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -982,7 +1014,11 @@ class CORE_EXPORT QgsProcessingParameterNumber : public QgsProcessingParameterDe
double maxValue = DBL_MAX double maxValue = DBL_MAX
); );
QString type() const override { return QStringLiteral( "number" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "number" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -1055,7 +1091,11 @@ class CORE_EXPORT QgsProcessingParameterRange : public QgsProcessingParameterDef
const QVariant &defaultValue = QVariant(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "range" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "range" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -1100,7 +1140,11 @@ class CORE_EXPORT QgsProcessingParameterRasterLayer : public QgsProcessingParame
QgsProcessingParameterRasterLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(), QgsProcessingParameterRasterLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "raster" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "raster" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -1129,7 +1173,11 @@ class CORE_EXPORT QgsProcessingParameterEnum : public QgsProcessingParameterDefi
const QVariant &defaultValue = QVariant(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "enum" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "enum" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -1190,7 +1238,11 @@ class CORE_EXPORT QgsProcessingParameterString : public QgsProcessingParameterDe
bool multiLine = false, bool multiLine = false,
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "string" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "string" ); }
QString type() const override { return typeName(); }
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -1237,7 +1289,11 @@ class CORE_EXPORT QgsProcessingParameterExpression : public QgsProcessingParamet
const QString &parentLayerParameterName = QString(), const QString &parentLayerParameterName = QString(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "expression" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "expression" ); }
QString type() const override { return typeName(); }
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QStringList dependsOnOtherParameters() const override; QStringList dependsOnOtherParameters() const override;
@ -1284,7 +1340,11 @@ class CORE_EXPORT QgsProcessingParameterVectorLayer : public QgsProcessingParame
QgsProcessingParameterVectorLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(), QgsProcessingParameterVectorLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "vector" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "vector" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -1323,7 +1383,11 @@ class CORE_EXPORT QgsProcessingParameterField : public QgsProcessingParameterDef
bool allowMultiple = false, bool allowMultiple = false,
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "field" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "field" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -1398,7 +1462,11 @@ class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingPara
const QList< int > &types = QList< int >(), const QList< int > &types = QList< int >(),
const QVariant &defaultValue = QVariant(), bool optional = false ); const QVariant &defaultValue = QVariant(), bool optional = false );
QString type() const override { return QStringLiteral( "source" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "source" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -1508,7 +1576,11 @@ class CORE_EXPORT QgsProcessingParameterFeatureSink : public QgsProcessingDestin
QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(), QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "sink" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "sink" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -1565,7 +1637,11 @@ class CORE_EXPORT QgsProcessingParameterVectorOutput : public QgsProcessingDesti
QgsProcessingParameterVectorOutput( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(), QgsProcessingParameterVectorOutput( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "vectorOut" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "vectorOut" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QString asScriptCode() const override; QString asScriptCode() const override;
@ -1621,7 +1697,11 @@ class CORE_EXPORT QgsProcessingParameterRasterOutput : public QgsProcessingDesti
const QVariant &defaultValue = QVariant(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "rasterOut" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "rasterOut" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY; QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY;
@ -1651,7 +1731,11 @@ class CORE_EXPORT QgsProcessingParameterFileOutput : public QgsProcessingDestina
const QVariant &defaultValue = QVariant(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "fileOut" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "fileOut" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY; QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY;
@ -1700,7 +1784,11 @@ class CORE_EXPORT QgsProcessingParameterFolderOutput : public QgsProcessingDesti
const QVariant &defaultValue = QVariant(), const QVariant &defaultValue = QVariant(),
bool optional = false ); bool optional = false );
QString type() const override { return QStringLiteral( "folderOut" ); } /**
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "folderOut" ); }
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override; bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY; QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY;
QString defaultFileExtension() const override; QString defaultFileExtension() const override;