diff --git a/python/core/processing/qgsprocessingoutputs.sip b/python/core/processing/qgsprocessingoutputs.sip index 5281c90b39ff..c9779d97e0ed 100644 --- a/python/core/processing/qgsprocessingoutputs.sip +++ b/python/core/processing/qgsprocessingoutputs.sip @@ -28,17 +28,17 @@ class QgsProcessingOutputDefinition %End %ConvertToSubClassCode - if ( sipCpp->type() == "outputVector" ) + if ( sipCpp->type() == QgsProcessingOutputVectorLayer::typeName() ) sipType = sipType_QgsProcessingOutputVectorLayer; - else if ( sipCpp->type() == "outputRaster" ) + else if ( sipCpp->type() == QgsProcessingOutputRasterLayer::typeName() ) sipType = sipType_QgsProcessingOutputRasterLayer; - else if ( sipCpp->type() == "outputHtml" ) + else if ( sipCpp->type() == QgsProcessingOutputHtml::typeName() ) sipType = sipType_QgsProcessingOutputHtml; - else if ( sipCpp->type() == "outputNumber" ) + else if ( sipCpp->type() == QgsProcessingOutputNumber::typeName() ) sipType = sipType_QgsProcessingOutputNumber; - else if ( sipCpp->type() == "outputString" ) + else if ( sipCpp->type() == QgsProcessingOutputString::typeName() ) sipType = sipType_QgsProcessingOutputString; - else if ( sipCpp->type() == "outputFolder" ) + else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() ) sipType = sipType_QgsProcessingOutputFolder; %End public: @@ -111,6 +111,11 @@ class QgsProcessingOutputVectorLayer : QgsProcessingOutputDefinition Constructor for QgsProcessingOutputVectorLayer. %End + static QString typeName(); +%Docstring + Returns the type name for the output class. + :rtype: str +%End virtual QString type() const; QgsProcessingParameterDefinition::LayerType dataType() const; @@ -145,7 +150,14 @@ class QgsProcessingOutputRasterLayer : QgsProcessingOutputDefinition Constructor for QgsProcessingOutputRasterLayer. %End + static QString typeName(); +%Docstring + Returns the type name for the output class. + :rtype: str +%End virtual QString type() const; + + }; class QgsProcessingOutputHtml : QgsProcessingOutputDefinition @@ -165,7 +177,13 @@ class QgsProcessingOutputHtml : QgsProcessingOutputDefinition Constructor for QgsProcessingOutputHtml. %End + static QString typeName(); +%Docstring + Returns the type name for the output class. + :rtype: str +%End virtual QString type() const; + }; class QgsProcessingOutputNumber : QgsProcessingOutputDefinition @@ -185,6 +203,11 @@ class QgsProcessingOutputNumber : QgsProcessingOutputDefinition Constructor for QgsProcessingOutputNumber. %End + static QString typeName(); +%Docstring + Returns the type name for the output class. + :rtype: str +%End virtual QString type() const; }; @@ -205,7 +228,13 @@ class QgsProcessingOutputString : QgsProcessingOutputDefinition Constructor for QgsProcessingOutputString. %End + static QString typeName(); +%Docstring + Returns the type name for the output class. + :rtype: str +%End virtual QString type() const; + }; class QgsProcessingOutputFolder : QgsProcessingOutputDefinition @@ -220,12 +249,19 @@ class QgsProcessingOutputFolder : QgsProcessingOutputDefinition %End public: + QgsProcessingOutputFolder( const QString &name, const QString &description = QString() ); %Docstring Constructor for QgsProcessingOutputFolder. %End + static QString typeName(); +%Docstring + Returns the type name for the output class. + :rtype: str +%End virtual QString type() const; + }; diff --git a/python/core/processing/qgsprocessingparameters.sip b/python/core/processing/qgsprocessingparameters.sip index 35eca5ce7ef2..42f408ad01e1 100644 --- a/python/core/processing/qgsprocessingparameters.sip +++ b/python/core/processing/qgsprocessingparameters.sip @@ -145,49 +145,49 @@ class QgsProcessingParameterDefinition %End %ConvertToSubClassCode - if ( sipCpp->type() == "boolean" ) + if ( sipCpp->type() == QgsProcessingParameterBoolean::typeName() ) sipType = sipType_QgsProcessingParameterBoolean; - else if ( sipCpp->type() == "crs" ) + else if ( sipCpp->type() == QgsProcessingParameterCrs::typeName() ) sipType = sipType_QgsProcessingParameterCrs; - else if ( sipCpp->type() == "layer" ) + else if ( sipCpp->type() == QgsProcessingParameterMapLayer::typeName() ) sipType = sipType_QgsProcessingParameterMapLayer; - else if ( sipCpp->type() == "extent" ) + else if ( sipCpp->type() == QgsProcessingParameterExtent::typeName() ) sipType = sipType_QgsProcessingParameterExtent; - else if ( sipCpp->type() == "point" ) + else if ( sipCpp->type() == QgsProcessingParameterPoint::typeName() ) sipType = sipType_QgsProcessingParameterPoint; - else if ( sipCpp->type() == "file" ) + else if ( sipCpp->type() == QgsProcessingParameterFile::typeName() ) sipType = sipType_QgsProcessingParameterFile; - else if ( sipCpp->type() == "matrix" ) + else if ( sipCpp->type() == QgsProcessingParameterMatrix::typeName() ) sipType = sipType_QgsProcessingParameterMatrix; - else if ( sipCpp->type() == "multilayer" ) + else if ( sipCpp->type() == QgsProcessingParameterMultipleLayers::typeName() ) sipType = sipType_QgsProcessingParameterMultipleLayers; - else if ( sipCpp->type() == "number" ) + else if ( sipCpp->type() == QgsProcessingParameterNumber::typeName() ) sipType = sipType_QgsProcessingParameterNumber; - else if ( sipCpp->type() == "range" ) + else if ( sipCpp->type() == QgsProcessingParameterRange::typeName() ) sipType = sipType_QgsProcessingParameterRange; - else if ( sipCpp->type() == "raster" ) + else if ( sipCpp->type() == QgsProcessingParameterRasterLayer::typeName() ) sipType = sipType_QgsProcessingParameterRasterLayer; - else if ( sipCpp->type() == "enum" ) + else if ( sipCpp->type() == QgsProcessingParameterEnum::typeName() ) sipType = sipType_QgsProcessingParameterEnum; - else if ( sipCpp->type() == "string" ) + else if ( sipCpp->type() == QgsProcessingParameterString::typeName() ) sipType = sipType_QgsProcessingParameterString; - else if ( sipCpp->type() == "expression" ) + else if ( sipCpp->type() == QgsProcessingParameterExpression::typeName() ) sipType = sipType_QgsProcessingParameterExpression; - else if ( sipCpp->type() == "vector" ) + else if ( sipCpp->type() == QgsProcessingParameterVectorLayer::typeName() ) sipType = sipType_QgsProcessingParameterVectorLayer; - else if ( sipCpp->type() == "field" ) + else if ( sipCpp->type() == QgsProcessingParameterField::typeName() ) sipType = sipType_QgsProcessingParameterField; - else if ( sipCpp->type() == "source" ) + else if ( sipCpp->type() == QgsProcessingParameterFeatureSource::typeName() ) sipType = sipType_QgsProcessingParameterFeatureSource; - else if ( sipCpp->type() == "sink" ) + else if ( sipCpp->type() == QgsProcessingParameterFeatureSink::typeName() ) sipType = sipType_QgsProcessingParameterFeatureSink; - else if ( sipCpp->type() == "vectorOut" ) + else if ( sipCpp->type() == QgsProcessingParameterVectorOutput::typeName() ) sipType = sipType_QgsProcessingParameterVectorOutput; - else if ( sipCpp->type() == "rasterOut" ) + else if ( sipCpp->type() == QgsProcessingParameterRasterOutput::typeName() ) sipType = sipType_QgsProcessingParameterRasterOutput; - else if ( sipCpp->type() == "fileOut" ) + else if ( sipCpp->type() == QgsProcessingParameterFileOutput::typeName() ) sipType = sipType_QgsProcessingParameterFileOutput; - else if ( sipCpp->type() == "folderOut" ) + else if ( sipCpp->type() == QgsProcessingParameterFolderOutput::typeName() ) sipType = sipType_QgsProcessingParameterFolderOutput; %End public: @@ -607,6 +607,11 @@ class QgsProcessingParameterBoolean : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterBoolean. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const; @@ -638,6 +643,11 @@ class QgsProcessingParameterCrs : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterCrs. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -670,6 +680,11 @@ class QgsProcessingParameterMapLayer : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterMapLayer. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -702,6 +717,11 @@ class QgsProcessingParameterExtent : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterExtent. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -735,6 +755,11 @@ class QgsProcessingParameterPoint : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterPoint. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -771,6 +796,11 @@ class QgsProcessingParameterFile : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterFile. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -836,6 +866,11 @@ class QgsProcessingParameterMatrix : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterMatrix. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -919,6 +954,11 @@ class QgsProcessingParameterMultipleLayers : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterMultipleLayers. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -997,6 +1037,11 @@ class QgsProcessingParameterNumber : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterNumber. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1075,6 +1120,11 @@ class QgsProcessingParameterRange : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterRange. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1125,6 +1175,11 @@ class QgsProcessingParameterRasterLayer : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterRasterLayer. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1159,6 +1214,11 @@ class QgsProcessingParameterEnum : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterEnum. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1225,6 +1285,11 @@ class QgsProcessingParameterString : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterString. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const; @@ -1276,6 +1341,11 @@ class QgsProcessingParameterExpression : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterExpression. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const; @@ -1327,6 +1397,11 @@ class QgsProcessingParameterVectorLayer : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterVectorLayer. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1370,6 +1445,11 @@ class QgsProcessingParameterField : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterField. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1451,6 +1531,11 @@ class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition Constructor for QgsProcessingParameterFeatureSource. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1570,6 +1655,11 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter Constructor for QgsProcessingParameterFeatureSink. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1637,6 +1727,11 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter Constructor for QgsProcessingParameterVectorOutput. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1702,6 +1797,11 @@ class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter Constructor for QgsProcessingParameterRasterOutput. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1739,6 +1839,11 @@ class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter Constructor for QgsProcessingParameterFileOutput. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; @@ -1795,6 +1900,11 @@ class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter Constructor for QgsProcessingParameterFolderOutput. %End + static QString typeName(); +%Docstring + Returns the type name for the parameter class. + :rtype: str +%End virtual QString type() const; virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const; diff --git a/python/plugins/processing/gui/wrappers.py b/python/plugins/processing/gui/wrappers.py index 74edd6562bb9..01122545992f 100644 --- a/python/plugins/processing/gui/wrappers.py +++ b/python/plugins/processing/gui/wrappers.py @@ -909,7 +909,7 @@ def createWidget(self): else: # strings, numbers, files and table fields are all allowed input types strings = self.dialog.getAvailableValuesOfType([QgsProcessingParameterString, QgsProcessingParameterNumber, QgsProcessingParameterFile, - QgsProcessingParameterField, QgsProcessingParameterExpression], QgsProcessingOutputString) + QgsProcessingParameterField, QgsProcessingParameterExpression], [QgsProcessingOutputString]) options = [(self.dialog.resolveValueDescription(s), s) for s in strings] if self.param.multiLine(): widget = MultilineTextPanel(options) diff --git a/python/plugins/processing/modeler/ModelerParametersDialog.py b/python/plugins/processing/modeler/ModelerParametersDialog.py index 1e6e86bdcc6b..13cbb4f2afb4 100644 --- a/python/plugins/processing/modeler/ModelerParametersDialog.py +++ b/python/plugins/processing/modeler/ModelerParametersDialog.py @@ -40,7 +40,8 @@ QgsProcessingParameterFeatureSink, QgsProcessingParameterRasterOutput, QgsProcessingParameterFileOutput, - QgsProcessingParameterFolderOutput) + QgsProcessingParameterFolderOutput, + QgsProcessingOutputDefinition) from qgis.gui import (QgsMessageBar, QgsScrollArea) @@ -65,7 +66,7 @@ def __init__(self, alg, model, algName=None): # The model this algorithm is going to be added to 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 - self._algName = algName + self.childId = algName self.setupUi() self.params = None @@ -191,11 +192,11 @@ def setupUi(self): wrapper.postInitialize(list(self.wrappers.values())) def getAvailableDependencies(self): # spellok - if self._algName is None: + if self.childId is None: dependent = [] else: - dependent = list(self.model.dependentChildAlgorithms(self._algName)) - dependent.append(self._algName) + dependent = list(self.model.dependentChildAlgorithms(self.childId)) + dependent.append(self.childId) opts = [] for alg in list(self.model.childAlgorithms().values()): if alg.childId() not in dependent: @@ -216,7 +217,7 @@ def showAdvancedParametersClicked(self): self.labels[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 if paramType is None: paramType = [] @@ -227,41 +228,8 @@ def getAvailableValuesOfType(self, paramType, outTypes=[], dataType=None): elif not isinstance(outTypes, list): outTypes = [outTypes] - values = [] - inputs = self.model.parameterComponents() - 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 + return self.model.availableSourcesForChild(self.childId, [p.typeName() for p in paramType if issubclass(p, QgsProcessingParameterDefinition)], + [o.typeName() for o in outTypes if issubclass(o, QgsProcessingOutputDefinition)], dataTypes) def resolveValueDescription(self, value): if isinstance(value, QgsProcessingModelAlgorithm.ChildParameterSource): @@ -277,8 +245,8 @@ def resolveValueDescription(self, value): return value def setPreviousValues(self): - if self._algName is not None: - alg = self.model.childAlgorithm(self._algName) + if self.childId is not None: + alg = self.model.childAlgorithm(self.childId) self.descriptionBox.setText(alg.description()) for param in alg.algorithm().parameterDefinitions(): if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden: @@ -308,10 +276,10 @@ def setPreviousValues(self): def createAlgorithm(self): alg = QgsProcessingModelAlgorithm.ChildAlgorithm(self._alg.id()) - if not self._algName: + if not self.childId: alg.generateChildId(self.model) else: - alg.setChildId(self._algName) + alg.setChildId(self.childId) alg.setDescription(self.descriptionBox.text()) for param in self._alg.parameterDefinitions(): if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden: diff --git a/python/plugins/processing/tools/dataobjects.py b/python/plugins/processing/tools/dataobjects.py index 311755e85ccf..3d4a2f0db778 100644 --- a/python/plugins/processing/tools/dataobjects.py +++ b/python/plugins/processing/tools/dataobjects.py @@ -91,16 +91,18 @@ def createExpressionContext(): context.appendScope(QgsExpressionContextUtils.globalScope()) context.appendScope(QgsExpressionContextUtils.projectScope(QgsProject.instance())) - if iface.mapCanvas(): + if iface and iface.mapCanvas(): context.appendScope(QgsExpressionContextUtils.mapSettingsScope(iface.mapCanvas().mapSettings())) processingScope = QgsExpressionContextScope() - extent = iface.mapCanvas().fullExtent() - processingScope.setVariable('fullextent_minx', extent.xMinimum()) - processingScope.setVariable('fullextent_miny', extent.yMinimum()) - processingScope.setVariable('fullextent_maxx', extent.xMaximum()) - processingScope.setVariable('fullextent_maxy', extent.yMaximum()) + if iface and iface.mapCanvas(): + extent = iface.mapCanvas().fullExtent() + processingScope.setVariable('fullextent_minx', extent.xMinimum()) + processingScope.setVariable('fullextent_miny', extent.yMinimum()) + processingScope.setVariable('fullextent_maxx', extent.xMaximum()) + processingScope.setVariable('fullextent_maxy', extent.yMaximum()) + context.appendScope(processingScope) return context diff --git a/src/core/processing/qgsprocessingmodelalgorithm.cpp b/src/core/processing/qgsprocessingmodelalgorithm.cpp index 45e171640500..b6e0a252a551 100644 --- a/src/core/processing/qgsprocessingmodelalgorithm.cpp +++ b/src/core/processing/qgsprocessingmodelalgorithm.cpp @@ -678,7 +678,7 @@ QgsProcessingModelAlgorithm::ChildParameterSources QgsProcessingModelAlgorithm:: { if ( !dataTypes.isEmpty() ) { - if ( def->type() == QStringLiteral( "field" ) ) + if ( def->type() == QgsProcessingParameterField::typeName() ) { const QgsProcessingParameterField *fieldDef = static_cast< const QgsProcessingParameterField * >( def ); if ( !( dataTypes.contains( fieldDef->dataType() ) || fieldDef->dataType() == QgsProcessingParameterField::Any ) ) @@ -686,7 +686,7 @@ QgsProcessingModelAlgorithm::ChildParameterSources QgsProcessingModelAlgorithm:: continue; } } - else if ( def->type() == "source" ) + else if ( def->type() == QgsProcessingParameterFeatureSource::typeName() ) { const QgsProcessingParameterFeatureSource *sourceDef = static_cast< const QgsProcessingParameterFeatureSource *>( def ); bool ok = !sourceDef->dataTypes().isEmpty(); @@ -729,7 +729,7 @@ QgsProcessingModelAlgorithm::ChildParameterSources QgsProcessingModelAlgorithm:: { if ( !dataTypes.isEmpty() ) { - if ( out->type() == QStringLiteral( "outputVector" ) ) + if ( out->type() == QgsProcessingOutputVectorLayer::typeName() ) { const QgsProcessingOutputVectorLayer *vectorOut = static_cast< const QgsProcessingOutputVectorLayer *>( out ); if ( !( dataTypes.contains( vectorOut->dataType() ) || vectorOut->dataType() == QgsProcessingParameterDefinition::TypeAny ) ) diff --git a/src/core/processing/qgsprocessingoutputs.h b/src/core/processing/qgsprocessingoutputs.h index 134362e09880..95b77f684f27 100644 --- a/src/core/processing/qgsprocessingoutputs.h +++ b/src/core/processing/qgsprocessingoutputs.h @@ -43,17 +43,17 @@ class CORE_EXPORT QgsProcessingOutputDefinition #ifdef SIP_RUN SIP_CONVERT_TO_SUBCLASS_CODE - if ( sipCpp->type() == "outputVector" ) + if ( sipCpp->type() == QgsProcessingOutputVectorLayer::typeName() ) sipType = sipType_QgsProcessingOutputVectorLayer; - else if ( sipCpp->type() == "outputRaster" ) + else if ( sipCpp->type() == QgsProcessingOutputRasterLayer::typeName() ) sipType = sipType_QgsProcessingOutputRasterLayer; - else if ( sipCpp->type() == "outputHtml" ) + else if ( sipCpp->type() == QgsProcessingOutputHtml::typeName() ) sipType = sipType_QgsProcessingOutputHtml; - else if ( sipCpp->type() == "outputNumber" ) + else if ( sipCpp->type() == QgsProcessingOutputNumber::typeName() ) sipType = sipType_QgsProcessingOutputNumber; - else if ( sipCpp->type() == "outputString" ) + else if ( sipCpp->type() == QgsProcessingOutputString::typeName() ) sipType = sipType_QgsProcessingOutputString; - else if ( sipCpp->type() == "outputFolder" ) + else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() ) sipType = sipType_QgsProcessingOutputFolder; SIP_END #endif @@ -128,7 +128,11 @@ class CORE_EXPORT QgsProcessingOutputVectorLayer : public QgsProcessingOutputDef */ 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. @@ -162,7 +166,13 @@ class CORE_EXPORT QgsProcessingOutputRasterLayer : public QgsProcessingOutputDef */ 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() ); - 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() ); - 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() ); - 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. */ + 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 diff --git a/src/core/processing/qgsprocessingparameters.cpp b/src/core/processing/qgsprocessingparameters.cpp index 274c4e4eb0b2..625880636d5d 100644 --- a/src/core/processing/qgsprocessingparameters.cpp +++ b/src/core/processing/qgsprocessingparameters.cpp @@ -747,49 +747,49 @@ QgsProcessingParameterDefinition *QgsProcessingParameters::parameterFromVariantM QString type = map.value( QStringLiteral( "parameter_type" ) ).toString(); QString name = map.value( QStringLiteral( "name" ) ).toString(); std::unique_ptr< QgsProcessingParameterDefinition > def; - if ( type == QStringLiteral( "boolean" ) ) + if ( type == QgsProcessingParameterBoolean::typeName() ) def.reset( new QgsProcessingParameterBoolean( name ) ); - else if ( type == QStringLiteral( "crs" ) ) + else if ( type == QgsProcessingParameterCrs::typeName() ) def.reset( new QgsProcessingParameterCrs( name ) ); - else if ( type == QStringLiteral( "layer" ) ) + else if ( type == QgsProcessingParameterMapLayer::typeName() ) def.reset( new QgsProcessingParameterMapLayer( name ) ); - else if ( type == QStringLiteral( "extent" ) ) + else if ( type == QgsProcessingParameterExtent::typeName() ) def.reset( new QgsProcessingParameterExtent( name ) ); - else if ( type == QStringLiteral( "point" ) ) + else if ( type == QgsProcessingParameterPoint::typeName() ) def.reset( new QgsProcessingParameterPoint( name ) ); - else if ( type == QStringLiteral( "file" ) ) + else if ( type == QgsProcessingParameterFile::typeName() ) def.reset( new QgsProcessingParameterFile( name ) ); - else if ( type == QStringLiteral( "matrix" ) ) + else if ( type == QgsProcessingParameterMatrix::typeName() ) def.reset( new QgsProcessingParameterMatrix( name ) ); - else if ( type == QStringLiteral( "multilayer" ) ) + else if ( type == QgsProcessingParameterMultipleLayers::typeName() ) def.reset( new QgsProcessingParameterMultipleLayers( name ) ); - else if ( type == QStringLiteral( "number" ) ) + else if ( type == QgsProcessingParameterNumber::typeName() ) def.reset( new QgsProcessingParameterNumber( name ) ); - else if ( type == QStringLiteral( "range" ) ) + else if ( type == QgsProcessingParameterRange::typeName() ) def.reset( new QgsProcessingParameterRange( name ) ); - else if ( type == QStringLiteral( "raster" ) ) + else if ( type == QgsProcessingParameterRasterLayer::typeName() ) def.reset( new QgsProcessingParameterRasterLayer( name ) ); - else if ( type == QStringLiteral( "enum" ) ) + else if ( type == QgsProcessingParameterEnum::typeName() ) def.reset( new QgsProcessingParameterEnum( name ) ); - else if ( type == QStringLiteral( "string" ) ) + else if ( type == QgsProcessingParameterString::typeName() ) def.reset( new QgsProcessingParameterString( name ) ); - else if ( type == QStringLiteral( "expression" ) ) + else if ( type == QgsProcessingParameterExpression::typeName() ) def.reset( new QgsProcessingParameterExpression( name ) ); - else if ( type == QStringLiteral( "vector" ) ) + else if ( type == QgsProcessingParameterVectorLayer::typeName() ) def.reset( new QgsProcessingParameterVectorLayer( name ) ); - else if ( type == QStringLiteral( "field" ) ) + else if ( type == QgsProcessingParameterField::typeName() ) def.reset( new QgsProcessingParameterField( name ) ); - else if ( type == QStringLiteral( "source" ) ) + else if ( type == QgsProcessingParameterFeatureSource::typeName() ) def.reset( new QgsProcessingParameterFeatureSource( name ) ); - else if ( type == QStringLiteral( "sink" ) ) + else if ( type == QgsProcessingParameterFeatureSink::typeName() ) def.reset( new QgsProcessingParameterFeatureSink( name ) ); - else if ( type == QStringLiteral( "vectorOut" ) ) + else if ( type == QgsProcessingParameterVectorOutput::typeName() ) def.reset( new QgsProcessingParameterVectorOutput( name ) ); - else if ( type == QStringLiteral( "rasterOut" ) ) + else if ( type == QgsProcessingParameterRasterOutput::typeName() ) def.reset( new QgsProcessingParameterRasterOutput( name ) ); - else if ( type == QStringLiteral( "fileOut" ) ) + else if ( type == QgsProcessingParameterFileOutput::typeName() ) def.reset( new QgsProcessingParameterFileOutput( name ) ); - else if ( type == QStringLiteral( "folderOut" ) ) + else if ( type == QgsProcessingParameterFolderOutput::typeName() ) def.reset( new QgsProcessingParameterFolderOutput( name ) ); if ( !def ) diff --git a/src/core/processing/qgsprocessingparameters.h b/src/core/processing/qgsprocessingparameters.h index 8911f0e77022..5f4cab2a4b2f 100644 --- a/src/core/processing/qgsprocessingparameters.h +++ b/src/core/processing/qgsprocessingparameters.h @@ -185,49 +185,49 @@ class CORE_EXPORT QgsProcessingParameterDefinition #ifdef SIP_RUN SIP_CONVERT_TO_SUBCLASS_CODE - if ( sipCpp->type() == "boolean" ) + if ( sipCpp->type() == QgsProcessingParameterBoolean::typeName() ) sipType = sipType_QgsProcessingParameterBoolean; - else if ( sipCpp->type() == "crs" ) + else if ( sipCpp->type() == QgsProcessingParameterCrs::typeName() ) sipType = sipType_QgsProcessingParameterCrs; - else if ( sipCpp->type() == "layer" ) + else if ( sipCpp->type() == QgsProcessingParameterMapLayer::typeName() ) sipType = sipType_QgsProcessingParameterMapLayer; - else if ( sipCpp->type() == "extent" ) + else if ( sipCpp->type() == QgsProcessingParameterExtent::typeName() ) sipType = sipType_QgsProcessingParameterExtent; - else if ( sipCpp->type() == "point" ) + else if ( sipCpp->type() == QgsProcessingParameterPoint::typeName() ) sipType = sipType_QgsProcessingParameterPoint; - else if ( sipCpp->type() == "file" ) + else if ( sipCpp->type() == QgsProcessingParameterFile::typeName() ) sipType = sipType_QgsProcessingParameterFile; - else if ( sipCpp->type() == "matrix" ) + else if ( sipCpp->type() == QgsProcessingParameterMatrix::typeName() ) sipType = sipType_QgsProcessingParameterMatrix; - else if ( sipCpp->type() == "multilayer" ) + else if ( sipCpp->type() == QgsProcessingParameterMultipleLayers::typeName() ) sipType = sipType_QgsProcessingParameterMultipleLayers; - else if ( sipCpp->type() == "number" ) + else if ( sipCpp->type() == QgsProcessingParameterNumber::typeName() ) sipType = sipType_QgsProcessingParameterNumber; - else if ( sipCpp->type() == "range" ) + else if ( sipCpp->type() == QgsProcessingParameterRange::typeName() ) sipType = sipType_QgsProcessingParameterRange; - else if ( sipCpp->type() == "raster" ) + else if ( sipCpp->type() == QgsProcessingParameterRasterLayer::typeName() ) sipType = sipType_QgsProcessingParameterRasterLayer; - else if ( sipCpp->type() == "enum" ) + else if ( sipCpp->type() == QgsProcessingParameterEnum::typeName() ) sipType = sipType_QgsProcessingParameterEnum; - else if ( sipCpp->type() == "string" ) + else if ( sipCpp->type() == QgsProcessingParameterString::typeName() ) sipType = sipType_QgsProcessingParameterString; - else if ( sipCpp->type() == "expression" ) + else if ( sipCpp->type() == QgsProcessingParameterExpression::typeName() ) sipType = sipType_QgsProcessingParameterExpression; - else if ( sipCpp->type() == "vector" ) + else if ( sipCpp->type() == QgsProcessingParameterVectorLayer::typeName() ) sipType = sipType_QgsProcessingParameterVectorLayer; - else if ( sipCpp->type() == "field" ) + else if ( sipCpp->type() == QgsProcessingParameterField::typeName() ) sipType = sipType_QgsProcessingParameterField; - else if ( sipCpp->type() == "source" ) + else if ( sipCpp->type() == QgsProcessingParameterFeatureSource::typeName() ) sipType = sipType_QgsProcessingParameterFeatureSource; - else if ( sipCpp->type() == "sink" ) + else if ( sipCpp->type() == QgsProcessingParameterFeatureSink::typeName() ) sipType = sipType_QgsProcessingParameterFeatureSink; - else if ( sipCpp->type() == "vectorOut" ) + else if ( sipCpp->type() == QgsProcessingParameterVectorOutput::typeName() ) sipType = sipType_QgsProcessingParameterVectorOutput; - else if ( sipCpp->type() == "rasterOut" ) + else if ( sipCpp->type() == QgsProcessingParameterRasterOutput::typeName() ) sipType = sipType_QgsProcessingParameterRasterOutput; - else if ( sipCpp->type() == "fileOut" ) + else if ( sipCpp->type() == QgsProcessingParameterFileOutput::typeName() ) sipType = sipType_QgsProcessingParameterFileOutput; - else if ( sipCpp->type() == "folderOut" ) + else if ( sipCpp->type() == QgsProcessingParameterFolderOutput::typeName() ) sipType = sipType_QgsProcessingParameterFolderOutput; SIP_END #endif @@ -628,7 +628,11 @@ class CORE_EXPORT QgsProcessingParameterBoolean : public QgsProcessingParameterD QgsProcessingParameterBoolean( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(), 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 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(), 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; 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(), 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; 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(), 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; 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(), 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; /** @@ -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(), 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; QString asScriptCode() const override; @@ -829,7 +853,11 @@ class CORE_EXPORT QgsProcessingParameterMatrix : public QgsProcessingParameterDe const QVariant &defaultValue = QVariant(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; @@ -908,7 +936,11 @@ class CORE_EXPORT QgsProcessingParameterMultipleLayers : public QgsProcessingPar const QVariant &defaultValue = QVariant(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString asScriptCode() const override; @@ -982,7 +1014,11 @@ class CORE_EXPORT QgsProcessingParameterNumber : public QgsProcessingParameterDe 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; @@ -1055,7 +1091,11 @@ class CORE_EXPORT QgsProcessingParameterRange : public QgsProcessingParameterDef const QVariant &defaultValue = QVariant(), 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; 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(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; @@ -1129,7 +1173,11 @@ class CORE_EXPORT QgsProcessingParameterEnum : public QgsProcessingParameterDefi const QVariant &defaultValue = QVariant(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString asScriptCode() const override; @@ -1190,7 +1238,11 @@ class CORE_EXPORT QgsProcessingParameterString : public QgsProcessingParameterDe bool multiLine = 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 asScriptCode() const override; @@ -1237,7 +1289,11 @@ class CORE_EXPORT QgsProcessingParameterExpression : public QgsProcessingParamet const QString &parentLayerParameterName = QString(), 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; 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(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; @@ -1323,7 +1383,11 @@ class CORE_EXPORT QgsProcessingParameterField : public QgsProcessingParameterDef bool allowMultiple = 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString asScriptCode() const override; @@ -1398,7 +1462,11 @@ class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingPara const QList< int > &types = QList< int >(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) 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(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) 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(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QString asScriptCode() const override; @@ -1621,7 +1697,11 @@ class CORE_EXPORT QgsProcessingParameterRasterOutput : public QgsProcessingDesti const QVariant &defaultValue = QVariant(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY; @@ -1651,7 +1731,11 @@ class CORE_EXPORT QgsProcessingParameterFileOutput : public QgsProcessingDestina const QVariant &defaultValue = QVariant(), 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; QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override; QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY; @@ -1700,7 +1784,11 @@ class CORE_EXPORT QgsProcessingParameterFolderOutput : public QgsProcessingDesti const QVariant &defaultValue = QVariant(), 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; QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY; QString defaultFileExtension() const override;