Skip to content
Permalink
Browse files

Fix build

  • Loading branch information
nyalldawson committed Jun 21, 2017
1 parent 312c810 commit 1d69939ddee92b6672b7261b13697f66b5d581fb
@@ -1432,7 +1432,7 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter
};


class QgsProcessingParameterVectorOutput : QgsProcessingParameterDefinition
class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
{
%Docstring
A vector layer output parameter. Consider using the more flexible QgsProcessingParameterFeatureSink wherever
@@ -1452,11 +1452,14 @@ class QgsProcessingParameterVectorOutput : QgsProcessingParameterDefinition
%End

virtual QString type() const;
virtual bool isDestination() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QgsProcessingOutputDefinition *toOutputDefinition() const /Factory/;

virtual QString defaultFileExtension() const;


QgsProcessingParameterDefinition::LayerType dataType() const;
%Docstring
@@ -2345,7 +2345,7 @@ QString QgsProcessingDestinationParameter::generateTemporaryDestination() const
}

QgsProcessingParameterVectorOutput::QgsProcessingParameterVectorOutput( const QString &name, const QString &description, QgsProcessingParameterDefinition::LayerType type, const QVariant &defaultValue, bool optional )
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
: QgsProcessingDestinationParameter( name, description, defaultValue, optional )
, mDataType( type )
{

@@ -2398,6 +2398,24 @@ QString QgsProcessingParameterVectorOutput::valueAsPythonString( const QVariant
return value.toString().prepend( '\'' ).append( '\'' );
}

QgsProcessingOutputDefinition *QgsProcessingParameterVectorOutput::toOutputDefinition() const
{
return new QgsProcessingOutputVectorLayer( name(), description(), mDataType );
}

QString QgsProcessingParameterVectorOutput::defaultFileExtension() const
{
QgsSettings settings;
if ( hasGeometry() )
{
return settings.value( QStringLiteral( "Processing/DefaultOutputVectorLayerExt" ), QStringLiteral( "shp" ), QgsSettings::Core ).toString();
}
else
{
return QStringLiteral( "dbf" );
}
}

QgsProcessingParameterDefinition::LayerType QgsProcessingParameterVectorOutput::dataType() const
{
return mDataType;
@@ -1386,7 +1386,7 @@ class CORE_EXPORT QgsProcessingParameterFeatureSink : public QgsProcessingDestin
* possible.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsProcessingParameterVectorOutput : public QgsProcessingParameterDefinition
class CORE_EXPORT QgsProcessingParameterVectorOutput : public QgsProcessingDestinationParameter
{
public:

@@ -1397,9 +1397,10 @@ class CORE_EXPORT QgsProcessingParameterVectorOutput : public QgsProcessingParam
bool optional = false );

QString type() const override { return QStringLiteral( "vectorOut" ); }
bool isDestination() const override { return true; }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
QgsProcessingOutputDefinition *toOutputDefinition() const override SIP_FACTORY;
QString defaultFileExtension() const override;

/**
* Returns the layer type for layers associated with the parameter.
@@ -2881,6 +2881,10 @@ void TestQgsProcessing::parameterVectorOut()
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( QgsProperty::fromExpression( "\"abc\" || \"def\"" ) ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition(QgsProperty.fromExpression('\"abc\" || \"def\"'))" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );

QCOMPARE( def->defaultFileExtension(), QStringLiteral( "shp" ) );
QVERIFY( def->generateTemporaryDestination().endsWith( QStringLiteral( ".shp" ) ) );
QVERIFY( def->generateTemporaryDestination().startsWith( QgsProcessingUtils::tempFolder() ) );

QVariantMap map = def->toVariantMap();
QgsProcessingParameterVectorOutput fromMap( "x" );
QVERIFY( fromMap.fromVariantMap( map ) );

0 comments on commit 1d69939

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