22using namespace Qt::StringLiterals;
40 if ( input.userType() != QMetaType::Type::QVariantList )
43 const QVariantList variantLayers = input.toList();
45 if ( variantLayers.isEmpty() )
48 for (
const QVariant &variantLayer : variantLayers )
50 if ( variantLayer.userType() != QMetaType::Type::QVariantMap )
52 const QVariantMap layerMap = variantLayer.toMap();
54 if ( !layerMap.contains( u
"source"_s ) ||
55 !layerMap.contains( u
"type"_s ) ||
56 !layerMap.contains( u
"attributeIndex"_s ) )
68 if ( layerMap.value( u
"attributeIndex"_s ).toInt() >= vectorLayer->
fields().
count() )
79 const QVariantList variantLayers = value.toList();
80 for (
const QVariant &variantLayer : variantLayers )
82 const QVariantMap layerMap = variantLayer.toMap();
83 QStringList layerDefParts;
87 const QString layerDef = u
"{%1}"_s.arg( layerDefParts.join(
',' ) );
88 parts.append( layerDef );
90 return parts.join(
',' ).prepend(
'[' ).append(
']' );
105 switch ( outputType )
109 QString code = u
"QgsProcessingParameterTinInputLayers('%1', %2)"_s
Base class for all map layer types.
Contains information about the context in which a processing algorithm is executed.
QString valueAsStringPrivate(const QVariant &value, QgsProcessingContext &context, bool &ok, ValueAsStringFlags flags) const
Internal method for evaluating values as string.
@ AllowMapLayerValues
Enable map layer value handling.
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &help=QString())
Constructor for QgsProcessingParameterDefinition.
QString name() const
Returns the name of the parameter.
QVariant valueAsJsonObjectPrivate(const QVariant &value, QgsProcessingContext &context, ValueAsStringFlags flags) const
Internal method for evaluating values as JSON objects.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
static QString variantToPythonLiteral(const QVariant &value)
Converts a variant to a Python literal.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
PythonOutputType
Available Python output types.
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
Represents a vector layer which manages a vector based dataset.