mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Allow access to parent algorithm for processing parameters
This commit is contained in:
parent
7cfbb6fb1c
commit
2a280d69aa
@ -353,6 +353,13 @@ class QgsProcessingParameterDefinition
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
QgsProcessingAlgorithm *algorithm() const;
|
||||
%Docstring
|
||||
Returns a pointer to the algorithm which owns this parameter. May be None
|
||||
for non-owned parameters.
|
||||
:rtype: QgsProcessingAlgorithm
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@ -360,6 +367,8 @@ class QgsProcessingParameterDefinition
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
QFlags<QgsProcessingParameterDefinition::Flag> operator|(QgsProcessingParameterDefinition::Flag f1, QFlags<QgsProcessingParameterDefinition::Flag> f2);
|
||||
|
@ -242,6 +242,7 @@ bool QgsProcessingAlgorithm::addParameter( QgsProcessingParameterDefinition *def
|
||||
}
|
||||
|
||||
mParameters << definition;
|
||||
definition->mAlgorithm = this;
|
||||
|
||||
if ( createOutput )
|
||||
return createAutoOutputForParameter( definition );
|
||||
|
@ -1237,6 +1237,11 @@ bool QgsProcessingParameterDefinition::fromVariantMap( const QVariantMap &map )
|
||||
return true;
|
||||
}
|
||||
|
||||
QgsProcessingAlgorithm *QgsProcessingParameterDefinition::algorithm() const
|
||||
{
|
||||
return mAlgorithm;
|
||||
}
|
||||
|
||||
QgsProcessingParameterBoolean::QgsProcessingParameterBoolean( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
|
||||
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
|
||||
{}
|
||||
|
@ -391,6 +391,12 @@ class CORE_EXPORT QgsProcessingParameterDefinition
|
||||
*/
|
||||
virtual QStringList dependsOnOtherParameters() const { return QStringList(); }
|
||||
|
||||
/**
|
||||
* Returns a pointer to the algorithm which owns this parameter. May be nullptr
|
||||
* for non-owned parameters.
|
||||
*/
|
||||
QgsProcessingAlgorithm *algorithm() const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Parameter name
|
||||
@ -408,6 +414,12 @@ class CORE_EXPORT QgsProcessingParameterDefinition
|
||||
//! Freeform metadata for parameter. Mostly used by widget wrappers to customise their appearance and behavior.
|
||||
QVariantMap mMetadata;
|
||||
|
||||
//! Pointer to algorithm which owns this parameter
|
||||
QgsProcessingAlgorithm *mAlgorithm = nullptr;
|
||||
|
||||
// To allow access to mAlgorithm. We don't want a public setter for this!
|
||||
friend class QgsProcessingAlgorithm;
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingParameterDefinition::Flags )
|
||||
|
@ -75,6 +75,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
||||
QVERIFY( addParameter( new QgsProcessingParameterBoolean( "p1" ) ) );
|
||||
QCOMPARE( parameterDefinitions().count(), 1 );
|
||||
QCOMPARE( parameterDefinitions().at( 0 )->name(), QString( "p1" ) );
|
||||
QCOMPARE( parameterDefinitions().at( 0 )->algorithm(), this );
|
||||
|
||||
QVERIFY( !addParameter( nullptr ) );
|
||||
QCOMPARE( parameterDefinitions().count(), 1 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user