Skip to content
Permalink
Browse files

Faster model

  • Loading branch information
nyalldawson committed Jul 8, 2018
1 parent 9de2cc3 commit ba410624db0035c06c6f8c16a6fc5c7b5f0985a9
@@ -139,7 +139,7 @@ Processing toolbox model node corresponding to a Processing provider.
%End
public:

QgsProcessingToolboxModelProviderNode( QgsProcessingProvider *provider, QgsProcessingRegistry *registry );
QgsProcessingToolboxModelProviderNode( QgsProcessingProvider *provider );
%Docstring
Constructor for QgsProcessingToolboxModelProviderNode, linked to the
specified ``provider``.
@@ -216,7 +216,7 @@ Processing toolbox model node corresponding to an algorithm.
%End
public:

QgsProcessingToolboxModelAlgorithmNode( const QgsProcessingAlgorithm *algorithm, QgsProcessingRegistry *registry );
QgsProcessingToolboxModelAlgorithmNode( const QgsProcessingAlgorithm *algorithm );
%Docstring
Constructor for QgsProcessingToolboxModelAlgorithmNode, associated
with the specified ``algorithm``.
@@ -72,14 +72,14 @@ void QgsProcessingToolboxModelNode::deleteChildren()
// QgsProcessingToolboxModelProviderNode
//

QgsProcessingToolboxModelProviderNode::QgsProcessingToolboxModelProviderNode( QgsProcessingProvider *provider, QgsProcessingRegistry *registry )
QgsProcessingToolboxModelProviderNode::QgsProcessingToolboxModelProviderNode( QgsProcessingProvider *provider )
: mProviderId( provider->id() )
, mRegistry( registry )
, mProvider( provider )
{}

QgsProcessingProvider *QgsProcessingToolboxModelProviderNode::provider()
{
return mRegistry->providerById( mProviderId );
return mProvider;
}

//
@@ -95,14 +95,13 @@ QgsProcessingToolboxModelGroupNode::QgsProcessingToolboxModelGroupNode( const QS
// QgsProcessingToolboxModelAlgorithmNode
//

QgsProcessingToolboxModelAlgorithmNode::QgsProcessingToolboxModelAlgorithmNode( const QgsProcessingAlgorithm *algorithm, QgsProcessingRegistry *registry )
: mAlgorithmId( algorithm->id() )
, mRegistry( registry )
QgsProcessingToolboxModelAlgorithmNode::QgsProcessingToolboxModelAlgorithmNode( const QgsProcessingAlgorithm *algorithm )
: mAlgorithm( algorithm )
{}

const QgsProcessingAlgorithm *QgsProcessingToolboxModelAlgorithmNode::algorithm() const
{
return mRegistry->algorithmById( mAlgorithmId );
return mAlgorithm;
}

//
@@ -268,7 +267,7 @@ void QgsProcessingToolboxModel::addProvider( QgsProcessingProvider *provider )
QgsProcessingToolboxModelNode *parentNode = nullptr;
if ( !isTopLevelProvider( provider->id() ) )
{
std::unique_ptr< QgsProcessingToolboxModelProviderNode > node = qgis::make_unique< QgsProcessingToolboxModelProviderNode >( provider, mRegistry );
std::unique_ptr< QgsProcessingToolboxModelProviderNode > node = qgis::make_unique< QgsProcessingToolboxModelProviderNode >( provider );
parentNode = node.get();
mRootNode->addChildNode( node.release() );
}
@@ -280,7 +279,7 @@ void QgsProcessingToolboxModel::addProvider( QgsProcessingProvider *provider )
const QList< const QgsProcessingAlgorithm * > algorithms = provider->algorithms();
for ( const QgsProcessingAlgorithm *algorithm : algorithms )
{
std::unique_ptr< QgsProcessingToolboxModelAlgorithmNode > algorithmNode = qgis::make_unique< QgsProcessingToolboxModelAlgorithmNode >( algorithm, mRegistry );
std::unique_ptr< QgsProcessingToolboxModelAlgorithmNode > algorithmNode = qgis::make_unique< QgsProcessingToolboxModelAlgorithmNode >( algorithm );

const QString groupId = algorithm->groupId();
if ( !groupId.isEmpty() )
@@ -162,7 +162,7 @@ class GUI_EXPORT QgsProcessingToolboxModelProviderNode : public QgsProcessingToo
* Constructor for QgsProcessingToolboxModelProviderNode, linked to the
* specified \a provider.
*/
QgsProcessingToolboxModelProviderNode( QgsProcessingProvider *provider, QgsProcessingRegistry *registry );
QgsProcessingToolboxModelProviderNode( QgsProcessingProvider *provider );

NodeType nodeType() const override { return NodeProvider; }

@@ -179,7 +179,8 @@ class GUI_EXPORT QgsProcessingToolboxModelProviderNode : public QgsProcessingToo
private:

QString mProviderId;
QgsProcessingRegistry *mRegistry = nullptr;
QgsProcessingProvider *mProvider = nullptr;

};

/**
@@ -237,7 +238,7 @@ class GUI_EXPORT QgsProcessingToolboxModelAlgorithmNode : public QgsProcessingTo
* Constructor for QgsProcessingToolboxModelAlgorithmNode, associated
* with the specified \a algorithm.
*/
QgsProcessingToolboxModelAlgorithmNode( const QgsProcessingAlgorithm *algorithm, QgsProcessingRegistry *registry );
QgsProcessingToolboxModelAlgorithmNode( const QgsProcessingAlgorithm *algorithm );

NodeType nodeType() const override { return NodeAlgorithm; }

@@ -248,8 +249,7 @@ class GUI_EXPORT QgsProcessingToolboxModelAlgorithmNode : public QgsProcessingTo

private:

const QString mAlgorithmId;
QgsProcessingRegistry *mRegistry = nullptr;
const QgsProcessingAlgorithm *mAlgorithm = nullptr;

};

0 comments on commit ba41062

Please sign in to comment.
You can’t perform that action at this time.