mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Allow processing plugins to load their own parameters
This commit is contained in:
parent
88734647ce
commit
ecae50f1d3
@ -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 ¶meters, 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:
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user