Skip to content

Commit

Permalink
[processing] Add metadata for feature sink parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 31, 2018
1 parent db916bc commit 297cfd5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/core/processing/qgsprocessingparametertypeimpl.h
Expand Up @@ -956,4 +956,57 @@ class CORE_EXPORT QgsProcessingParameterTypeBand : public QgsProcessingParameter

};

/**
* A feature sink parameter for Processing algorithms.
*
* \ingroup core
* \note No Python bindings available. Get your copy from QgsApplication.processingRegistry().parameterType('band')
* \since QGIS 3.2
*/
class CORE_EXPORT QgsProcessingParameterTypeFeatureSink : public QgsProcessingParameterType
{
QgsProcessingParameterDefinition *create( const QString &name ) const override SIP_FACTORY
{
return new QgsProcessingParameterFeatureSink( name );
}

ParameterFlags flags() const override
{
ParameterFlags flags = QgsProcessingParameterType::flags();

#if QT_VERSION >= 0x50700
flags.setFlag( ParameterFlag::ExposeToModeler, false );
#else
flags &= ~ParameterFlag::ExposeToModeler;
#endif

return flags;
}

QString description() const override
{
return QCoreApplication::translate( "Processing", "A feature sink destination parameter." );
}

QString name() const override
{
return QCoreApplication::translate( "Processing", "Feature Sink" );
}

QString id() const override
{
return QStringLiteral( "sink" );
}

QStringList acceptedPythonTypes() const override
{
return QStringList() << QObject::tr( "str: destination vector file, e.g. 'd:/test.shp'" )
<< QObject::tr( "str: 'memory:' to store result in temporary memory layer" )
<< QObject::tr( "str: using vector provider ID prefix and destination URI, e.g. 'postgres:...' to store result in PostGIS table" )
<< QStringLiteral( "QgsProcessingOutputLayerDefinition" )
<< QStringLiteral( "QgsProperty" );
}

};

#endif // QGSPROCESSINGPARAMETERTYPEIMPL_H
1 change: 1 addition & 0 deletions src/core/processing/qgsprocessingregistry.cpp
Expand Up @@ -45,6 +45,7 @@ QgsProcessingRegistry::QgsProcessingRegistry( QObject *parent SIP_TRANSFERTHIS )
addParameterType( new QgsProcessingParameterTypeNumber() );
addParameterType( new QgsProcessingParameterTypeDistance() );
addParameterType( new QgsProcessingParameterTypeBand() );
addParameterType( new QgsProcessingParameterTypeFeatureSink() );
}

QgsProcessingRegistry::~QgsProcessingRegistry()
Expand Down

0 comments on commit 297cfd5

Please sign in to comment.