27 if ( mSource != other.mSource )
33 return mStaticValue == other.mStaticValue;
35 return mChildId == other.mChildId && mOutputName == other.mOutputName;
37 return mParameterName == other.mParameterName;
39 return mExpression == other.mExpression;
41 return mExpressionText == other.mExpressionText;
48QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromStaticValue(
const QVariant &value )
50 QgsProcessingModelChildParameterSource src;
51 src.mSource = StaticValue;
52 src.mStaticValue = value;
56QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromModelParameter(
const QString ¶meterName )
58 QgsProcessingModelChildParameterSource src;
59 src.mSource = ModelParameter;
60 src.mParameterName = parameterName;
64QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromChildOutput(
const QString &childId,
const QString &outputName )
66 QgsProcessingModelChildParameterSource src;
67 src.mSource = ChildOutput;
68 src.mChildId = childId;
69 src.mOutputName = outputName;
73QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromExpression(
const QString &expression )
75 QgsProcessingModelChildParameterSource src;
76 src.mSource = Expression;
77 src.mExpression = expression;
81QgsProcessingModelChildParameterSource QgsProcessingModelChildParameterSource::fromExpressionText(
const QString &text )
83 QgsProcessingModelChildParameterSource src;
84 src.mSource = ExpressionText;
85 src.mExpressionText = text;
89QgsProcessingModelChildParameterSource::Source QgsProcessingModelChildParameterSource::source()
const
94void QgsProcessingModelChildParameterSource::setSource( QgsProcessingModelChildParameterSource::Source source )
99QVariant QgsProcessingModelChildParameterSource::toVariant()
const
102 map.insert( QStringLiteral(
"source" ), mSource );
106 map.insert( QStringLiteral(
"parameter_name" ), mParameterName );
110 map.insert( QStringLiteral(
"child_id" ), mChildId );
111 map.insert( QStringLiteral(
"output_name" ), mOutputName );
115 map.insert( QStringLiteral(
"static_value" ), mStaticValue );
119 map.insert( QStringLiteral(
"expression" ), mExpression );
123 map.insert( QStringLiteral(
"expression_text" ), mExpressionText );
132bool QgsProcessingModelChildParameterSource::loadVariant(
const QVariantMap &map )
134 mSource =
static_cast< Source
>( map.value( QStringLiteral(
"source" ) ).toInt() );
138 mParameterName = map.value( QStringLiteral(
"parameter_name" ) ).toString();
142 mChildId = map.value( QStringLiteral(
"child_id" ) ).toString();
143 mOutputName = map.value( QStringLiteral(
"output_name" ) ).toString();
147 mStaticValue = map.value( QStringLiteral(
"static_value" ) );
151 mExpression = map.value( QStringLiteral(
"expression" ) ).toString();
155 mExpressionText = map.value( QStringLiteral(
"expression_text" ) ).toString();
169 return QStringLiteral(
"parameters['%1']" ).arg( mParameterName );
172 return QStringLiteral(
"outputs['%1']['%2']" ).arg( friendlyChildNames.value( mChildId, mChildId ), mOutputName );
189 return mExpressionText;
222QString QgsProcessingModelChildParameterSource::friendlyIdentifier( QgsProcessingModelAlgorithm *model )
const
227 return model ? model->parameterDefinition( mParameterName )->description() : mParameterName;
233 const QgsProcessingModelChildAlgorithm &alg = model->childAlgorithm( mChildId );
234 QString outputName = alg.algorithm() && alg.algorithm()->outputDefinition( mOutputName ) ? alg.algorithm()->outputDefinition( mOutputName )->description() : mOutputName;
236 const QMap<QString, QgsProcessingModelOutput> outputs = alg.modelOutputs();
237 for (
auto it = outputs.constBegin(); it != outputs.constEnd(); ++it )
239 if ( it.value().childOutputName() == mOutputName )
241 outputName = it.key();
245 return QObject::tr(
"'%1' from algorithm '%2'" ).arg( outputName, alg.description() );
249 return QObject::tr(
"'%1' from algorithm '%2'" ).arg( mOutputName, mChildId );
254 return mStaticValue.toString();
260 return mExpressionText;
268QDataStream &
operator<<( QDataStream &out,
const QgsProcessingModelChildParameterSource &source )
270 out << source.source();
271 out << source.staticValue();
272 out << source.parameterName();
273 out << source.outputChildId();
274 out << source.outputName();
275 out << source.expression();
276 out << source.expressionText();
280QDataStream &
operator>>( QDataStream &in, QgsProcessingModelChildParameterSource &source )
283 QVariant staticValue;
284 QString parameterName;
285 QString outputChildId;
288 QString expressionText;
290 in >> sourceType >> staticValue >> parameterName >> outputChildId >> outputName >> expression >> expressionText;
292 source.setStaticValue( staticValue );
293 source.setParameterName( parameterName );
294 source.setOutputChildId( outputChildId );
295 source.setOutputName( outputName );
296 source.setExpression( expression );
297 source.setExpressionText( expressionText );
298 source.setSource(
static_cast<QgsProcessingModelChildParameterSource::Source
>( sourceType ) );
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.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)