26bool QgsProcessingModelChildParameterSource::operator==(
const QgsProcessingModelChildParameterSource &other )
const
28 if ( mSource != other.mSource )
34 return mStaticValue == other.mStaticValue;
36 return mChildId == other.mChildId && mOutputName == other.mOutputName;
38 return mParameterName == other.mParameterName;
40 return mExpression == other.mExpression;
42 return mExpressionText == other.mExpressionText;
49QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromStaticValue(
const QVariant &value )
51 QgsProcessingModelChildParameterSource src;
53 src.mStaticValue = value;
57QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromModelParameter(
const QString ¶meterName )
59 QgsProcessingModelChildParameterSource src;
61 src.mParameterName = parameterName;
65QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromChildOutput(
const QString &childId,
const QString &outputName )
67 QgsProcessingModelChildParameterSource src;
69 src.mChildId = childId;
70 src.mOutputName = outputName;
74QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromExpression(
const QString &expression )
76 QgsProcessingModelChildParameterSource src;
78 src.mExpression = expression;
82QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromExpressionText(
const QString &text )
84 QgsProcessingModelChildParameterSource src;
86 src.mExpressionText = text;
100QVariant QgsProcessingModelChildParameterSource::toVariant()
const
103 map.insert( QStringLiteral(
"source" ),
static_cast< int >( mSource ) );
107 map.insert( QStringLiteral(
"parameter_name" ), mParameterName );
111 map.insert( QStringLiteral(
"child_id" ), mChildId );
112 map.insert( QStringLiteral(
"output_name" ), mOutputName );
116 map.insert( QStringLiteral(
"static_value" ), mStaticValue );
120 map.insert( QStringLiteral(
"expression" ), mExpression );
124 map.insert( QStringLiteral(
"expression_text" ), mExpressionText );
133bool QgsProcessingModelChildParameterSource::loadVariant(
const QVariantMap &map )
139 mParameterName = map.value( QStringLiteral(
"parameter_name" ) ).toString();
143 mChildId = map.value( QStringLiteral(
"child_id" ) ).toString();
144 mOutputName = map.value( QStringLiteral(
"output_name" ) ).toString();
148 mStaticValue = map.value( QStringLiteral(
"static_value" ) );
152 mExpression = map.value( QStringLiteral(
"expression" ) ).toString();
156 mExpressionText = map.value( QStringLiteral(
"expression_text" ) ).toString();
170 return QStringLiteral(
"parameters['%1']" ).arg( mParameterName );
173 return QStringLiteral(
"outputs['%1']['%2']" ).arg( friendlyChildNames.value( mChildId, mChildId ), mOutputName );
190 return mExpressionText;
223QString QgsProcessingModelChildParameterSource::friendlyIdentifier( QgsProcessingModelAlgorithm *model )
const
234 return paramDefinition->description();
238 return mParameterName;
244 const QgsProcessingModelChildAlgorithm &alg = model->childAlgorithm( mChildId );
245 QString outputName = alg.algorithm() && alg.algorithm()->outputDefinition( mOutputName ) ? alg.algorithm()->outputDefinition( mOutputName )->description() : mOutputName;
247 const QMap<QString, QgsProcessingModelOutput> outputs = alg.modelOutputs();
248 for (
auto it = outputs.constBegin(); it != outputs.constEnd(); ++it )
250 if ( it.value().childOutputName() == mOutputName )
252 outputName = it.key();
256 return QObject::tr(
"'%1' from algorithm '%2'" ).arg( outputName, alg.description() );
260 return QObject::tr(
"'%1' from algorithm '%2'" ).arg( mOutputName, mChildId );
265 return mStaticValue.toString();
271 return mExpressionText;
279QDataStream &
operator<<( QDataStream &out,
const QgsProcessingModelChildParameterSource &source )
281 out << static_cast< int >( source.source() );
282 out << source.staticValue();
283 out << source.parameterName();
284 out << source.outputChildId();
285 out << source.outputName();
286 out << source.expression();
287 out << source.expressionText();
291QDataStream &
operator>>( QDataStream &in, QgsProcessingModelChildParameterSource &source )
294 QVariant staticValue;
295 QString parameterName;
296 QString outputChildId;
299 QString expressionText;
301 in >> sourceType >> staticValue >> parameterName >> outputChildId >> outputName >> expression >> expressionText;
303 source.setStaticValue( staticValue );
304 source.setParameterName( parameterName );
305 source.setOutputChildId( outputChildId );
306 source.setOutputName( outputName );
307 source.setExpression( expression );
308 source.setExpressionText( expressionText );
ProcessingModelChildParameterSource
Processing model child parameter sources.
@ ExpressionText
Parameter value is taken from a text with expressions, evaluated just before the algorithm runs.
@ ModelOutput
Parameter value is linked to an output parameter for the model.
@ ChildOutput
Parameter value is taken from an output generated by a child algorithm.
@ ModelParameter
Parameter value is taken from a parent model parameter.
@ StaticValue
Parameter value is a static value.
@ Expression
Parameter value is taken from an expression, evaluated just before the algorithm runs.
Contains information about the context in which a processing algorithm is executed.
Base class for the definition of processing parameters.
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual QString valueAsPythonComment(const QVariant &value, QgsProcessingContext &context) const
Returns a Python comment explaining a parameter value, or an empty string if no comment is required.
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.
PythonOutputType
Available Python output types.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QDataStream & operator<<(QDataStream &out, const QgsFeature &feature)
Writes the feature to stream out. QGIS version compatibility is not guaranteed.
QDataStream & operator>>(QDataStream &in, QgsFeature &feature)
Reads a feature from stream in into feature. QGIS version compatibility is not guaranteed.