24QString QgsConditionalBranchAlgorithm::name()
const
26 return QStringLiteral(
"condition" );
29QString QgsConditionalBranchAlgorithm::displayName()
const
31 return QObject::tr(
"Conditional branch" );
34QStringList QgsConditionalBranchAlgorithm::tags()
const
36 return QObject::tr(
"if,logic,test" ).split(
',' );
39QString QgsConditionalBranchAlgorithm::group()
const
41 return QObject::tr(
"Modeler tools" );
44QString QgsConditionalBranchAlgorithm::groupId()
const
46 return QStringLiteral(
"modelertools" );
54QString QgsConditionalBranchAlgorithm::shortHelpString()
const
56 return QObject::tr(
"This algorithm adds a conditional branch into a model, allowing parts of the model to be executed based on the result of an expression evaluation." );
59QString QgsConditionalBranchAlgorithm::shortDescription()
const
61 return QObject::tr(
"Adds a conditional branch into a model, allowing parts of the model to be selectively executed." );
64QgsConditionalBranchAlgorithm *QgsConditionalBranchAlgorithm::createInstance()
const
66 return new QgsConditionalBranchAlgorithm();
69QgsConditionalBranchAlgorithm::~QgsConditionalBranchAlgorithm()
71 qDeleteAll( mOutputs );
74void QgsConditionalBranchAlgorithm::initAlgorithm(
const QVariantMap &configuration )
76 const QVariantList branches = configuration.value( QStringLiteral(
"conditions" ) ).toList();
77 for (
const QVariant &branch : branches )
79 const QVariantMap branchDef = branch.toMap();
80 const QString name = branchDef.value( QStringLiteral(
"name" ) ).toString();
81 mOutputs.append(
new Output( name, branchDef.value( QStringLiteral(
"expression" ) ).toString() ) );
91 for ( Output *output : std::as_const( mOutputs ) )
93 output->expression.prepare( &expressionContext );
94 const QVariant res = output->expression.evaluate( &expressionContext );
95 results.insert( output->name, res );
98 feedback->
pushInfo( QObject::tr(
"Condition %1 passed" ).arg( output->name ) );
102 feedback->
pushInfo( QObject::tr(
"Condition %1 failed" ).arg( output->name ) );
105 qDeleteAll( mOutputs );
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
@ HideFromToolbox
Algorithm should be hidden from the toolbox.
@ SkipGenericModelLogging
When running as part of a model, the generic algorithm setup and results logging should be skipped.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A conditional branch output for processing algorithms, which represents a possible model logic flow w...