mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Add method to determine whether dependencies exist between model parameters
This commit is contained in:
parent
6483984d0b
commit
921939e4ec
@ -724,6 +724,16 @@ Copies are protected to avoid slicing
|
||||
%Docstring
|
||||
Returns true if any child algorithms depend on the model parameter
|
||||
with the specified ``name``.
|
||||
.. seealso:: otherParametersDependOnParameter()
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
bool otherParametersDependOnParameter( const QString &name ) const;
|
||||
%Docstring
|
||||
Returns true if any other model parameters depend on the parameter
|
||||
with the specified ``name`` (e.g. field parameters where ``name``
|
||||
is the parent layer parameter).
|
||||
.. seealso:: childAlgorithmsDependOnParameter()
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
|
@ -949,6 +949,19 @@ bool QgsProcessingModelAlgorithm::childAlgorithmsDependOnParameter( const QStrin
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QgsProcessingModelAlgorithm::otherParametersDependOnParameter( const QString &name ) const
|
||||
{
|
||||
Q_FOREACH ( const QgsProcessingParameterDefinition *def, mParameters )
|
||||
{
|
||||
if ( def->name() == name )
|
||||
continue;
|
||||
|
||||
if ( def->dependsOnOtherParameters().contains( name ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QMap<QString, QgsProcessingModelAlgorithm::ModelParameter> QgsProcessingModelAlgorithm::parameterComponents() const
|
||||
{
|
||||
return mParameterComponents;
|
||||
|
@ -718,9 +718,18 @@ class CORE_EXPORT QgsProcessingModelAlgorithm : public QgsProcessingAlgorithm
|
||||
/**
|
||||
* Returns true if any child algorithms depend on the model parameter
|
||||
* with the specified \a name.
|
||||
* \see otherParametersDependOnParameter()
|
||||
*/
|
||||
bool childAlgorithmsDependOnParameter( const QString &name ) const;
|
||||
|
||||
/**
|
||||
* Returns true if any other model parameters depend on the parameter
|
||||
* with the specified \a name (e.g. field parameters where \a name
|
||||
* is the parent layer parameter).
|
||||
* \see childAlgorithmsDependOnParameter()
|
||||
*/
|
||||
bool otherParametersDependOnParameter( const QString &name ) const;
|
||||
|
||||
/**
|
||||
* Returns the map of parameter components used by the model. The keys
|
||||
* should match the algorithm's parameter names (see parameterDefinitions() ).
|
||||
|
@ -4458,6 +4458,16 @@ void TestQgsProcessing::modelerAlgorithm()
|
||||
alg4.setChildAlgorithm( c10 );
|
||||
QVERIFY( alg4.childAlgorithmsDependOnParameter( "p1" ) );
|
||||
|
||||
QgsProcessingModelAlgorithm::ModelParameter vlP;
|
||||
alg4.addModelParameter( new QgsProcessingParameterVectorLayer( "layer" ), vlP );
|
||||
QgsProcessingModelAlgorithm::ModelParameter field;
|
||||
alg4.addModelParameter( new QgsProcessingParameterField( "field", QString(), QVariant(), QStringLiteral( "layer" ) ), field );
|
||||
QVERIFY( !alg4.otherParametersDependOnParameter( "p1" ) );
|
||||
QVERIFY( !alg4.otherParametersDependOnParameter( "field" ) );
|
||||
QVERIFY( alg4.otherParametersDependOnParameter( "layer" ) );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// to/from XML
|
||||
|
Loading…
x
Reference in New Issue
Block a user