Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make QgsAlgorithm::setProvider() public
Turns out there's valid use cases for calling this from outside
code.
  • Loading branch information
nyalldawson committed Jun 24, 2017
1 parent b1cadb1 commit 5e7fbf4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 5 additions & 1 deletion python/core/processing/qgsprocessingalgorithm.sip
Expand Up @@ -267,6 +267,11 @@ class QgsProcessingAlgorithm
:rtype: str
%End

void setProvider( QgsProcessingProvider *provider );
%Docstring
Associates this algorithm with its provider. No transfer of ownership is involved.
%End

protected:

bool addParameter( QgsProcessingParameterDefinition *parameterDefinition /Transfer/ );
Expand Down Expand Up @@ -473,7 +478,6 @@ class QgsProcessingAlgorithm
:rtype: list of str
%End


private:
QgsProcessingAlgorithm( const QgsProcessingAlgorithm &other );
};
Expand Down
2 changes: 2 additions & 0 deletions python/plugins/processing/modeler/ModelerDialog.py
Expand Up @@ -244,6 +244,7 @@ def _mimeDataAlgorithm(items):

else:
self.model = ModelerAlgorithm()
self.model.setProvider(QgsApplication.processingRegistry().providerById('model'))

self.fillInputsTree()
self.fillAlgorithmTree()
Expand Down Expand Up @@ -476,6 +477,7 @@ def openModel(self):
alg = ModelerAlgorithm()
if alg.fromFile(filename):
self.model = alg
self.model.setProvider(QgsApplication.processingRegistry().providerById('model'))
self.textGroup.setText(alg.group())
self.textName.setText(alg.name())
self.repaintModel()
Expand Down
11 changes: 5 additions & 6 deletions src/core/processing/qgsprocessingalgorithm.h
Expand Up @@ -264,6 +264,11 @@ class CORE_EXPORT QgsProcessingAlgorithm
*/
virtual QString asPythonCommand( const QVariantMap &parameters, QgsProcessingContext &context ) const;

/**
* Associates this algorithm with its provider. No transfer of ownership is involved.
*/
void setProvider( QgsProcessingProvider *provider );

protected:

/**
Expand Down Expand Up @@ -445,18 +450,12 @@ class CORE_EXPORT QgsProcessingAlgorithm
*/
QStringList parameterAsFields( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;


private:

QgsProcessingProvider *mProvider = nullptr;
QgsProcessingParameterDefinitions mParameters;
QgsProcessingOutputDefinitions mOutputs;

/**
* Associates this algorithm with its provider. No transfer of ownership is involved.
*/
void setProvider( QgsProcessingProvider *provider );

// friend class to access setProvider() - we do not want this public!
friend class QgsProcessingProvider;
friend class TestQgsProcessing;
Expand Down

0 comments on commit 5e7fbf4

Please sign in to comment.