Skip to content
Permalink
Browse files

Allow processing plugins to load their own parameters

  • Loading branch information
m-kuhn committed Mar 1, 2018
1 parent 8873464 commit ecae50f1d388e2eaabc9f6365b2f47a70c53a0cd
@@ -204,6 +204,17 @@ Returns the matching algorithm by ``name``, or a None if no matching
algorithm is contained by this provider.

.. seealso:: :py:func:`algorithms`
%End

virtual QgsProcessingParameterDefinition *createParameter( const QString &type, const QString &name ) /Factory/;
%Docstring
Returns a new parameter from of the given type and name.
This should be reimplemented by providers that implement custom types.
If the provider does not implement the parameter with ``type``, a None will be returned.

By default, this returns a None.

.. versionadded:: 3.2
%End

signals:
@@ -25,6 +25,7 @@
#include "qgssettings.h"
#include "qgsvectorfilewriter.h"
#include "qgsreferencedgeometry.h"
#include "qgsprocessingregistry.h"
#include <functional>

bool QgsProcessingParameters::isDynamic( const QVariantMap &parameters, const QString &name )
@@ -1079,6 +1080,21 @@ QgsProcessingParameterDefinition *QgsProcessingParameters::parameterFromVariantM
def.reset( new QgsProcessingParameterFolderDestination( name ) );
else if ( type == QgsProcessingParameterBand::typeName() )
def.reset( new QgsProcessingParameterBand( name ) );
else
{
const QList<QgsProcessingProvider *> providers = QgsApplication::instance()->processingRegistry()->providers();

for ( QgsProcessingProvider *provider : providers )
{
QgsProcessingParameterDefinition *param = provider->createParameter( type, name );

if ( param )
{
def.reset( param );
break;
}
}
}

if ( !def )
return nullptr;
@@ -74,6 +74,13 @@ const QgsProcessingAlgorithm *QgsProcessingProvider::algorithm( const QString &n
return mAlgorithms.value( name );
}

QgsProcessingParameterDefinition *QgsProcessingProvider::createParameter( const QString &type, const QString &name )
{
Q_UNUSED( type )
Q_UNUSED( name )
return nullptr;
}

bool QgsProcessingProvider::addAlgorithm( QgsProcessingAlgorithm *algorithm )
{
if ( !algorithm )
@@ -203,6 +203,17 @@ class CORE_EXPORT QgsProcessingProvider : public QObject
*/
const QgsProcessingAlgorithm *algorithm( const QString &name ) const;

/**
* Returns a new parameter from of the given type and name.
* This should be reimplemented by providers that implement custom types.
* If the provider does not implement the parameter with \a type, a nullptr will be returned.
*
* By default, this returns a nullptr.
*
* \since QGIS 3.2
*/
virtual QgsProcessingParameterDefinition *createParameter( const QString &type, const QString &name ) SIP_FACTORY;

signals:

/**

0 comments on commit ecae50f

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