Skip to content

Commit

Permalink
Rename QgsProcessingFeatureSink to QgsProcessingFeatureSinkDefinition
Browse files Browse the repository at this point in the history
For consistency with QgsProcessingFeatureSourceDefinition
  • Loading branch information
nyalldawson committed Jun 5, 2017
1 parent 81da209 commit 77072b1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions python/core/processing/qgsprocessingparameters.sip
Expand Up @@ -56,7 +56,7 @@ Allows direct construction of QVariants.



class QgsProcessingFeatureSink
class QgsProcessingFeatureSinkDefinition
{
%Docstring

Expand All @@ -70,16 +70,16 @@ class QgsProcessingFeatureSink
%End
public:

QgsProcessingFeatureSink( const QString &sink = QString(), QgsProject *destinationProject = 0 );
QgsProcessingFeatureSinkDefinition( const QString &sink = QString(), QgsProject *destinationProject = 0 );
%Docstring
Constructor for QgsProcessingFeatureSink, accepting a static string sink.
Constructor for QgsProcessingFeatureSinkDefinition, accepting a static string sink.
The ``destinationProject`` parameter can be set to a QgsProject instance in which
to automatically load the resulting sink after completing processing.
%End

QgsProcessingFeatureSink( const QgsProperty &sink, QgsProject *destinationProject = 0 );
QgsProcessingFeatureSinkDefinition( const QgsProperty &sink, QgsProject *destinationProject = 0 );
%Docstring
Constructor for QgsProcessingFeatureSink, accepting a QgsProperty sink.
Constructor for QgsProcessingFeatureSinkDefinition, accepting a QgsProperty sink.
The ``destinationProject`` parameter can be set to a QgsProject instance in which
to automatically load the resulting sink after completing processing.
%End
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/AlgorithmDialog.py
Expand Up @@ -35,7 +35,7 @@
QgsMessageLog,
QgsProcessingParameterDefinition,
QgsProcessingOutputVectorLayer,
QgsProcessingFeatureSink,
QgsProcessingFeatureSinkDefinition,
QgsProcessingParameterFeatureSink)
from qgis.gui import QgsMessageBar
from qgis.utils import iface
Expand Down Expand Up @@ -116,7 +116,7 @@ def getParamValues(self):
if self.mainWidget.checkBoxes[param.name()].isChecked():
dest_project = QgsProject.instance()

parameters[param.name()] = QgsProcessingFeatureSink(self.mainWidget.outputWidgets[param.name()].getValue(), dest_project)
parameters[param.name()] = QgsProcessingFeatureSinkDefinition(self.mainWidget.outputWidgets[param.name()].getValue(), dest_project)

return parameters

Expand Down
10 changes: 5 additions & 5 deletions src/core/processing/qgsprocessingparameters.cpp
Expand Up @@ -215,10 +215,10 @@ QgsFeatureSink *QgsProcessingParameters::parameterAsSink( const QgsProcessingPar

QgsProject *destinationProject = nullptr;
QVariantMap createOptions;
if ( val.canConvert<QgsProcessingFeatureSink>() )
if ( val.canConvert<QgsProcessingFeatureSinkDefinition>() )
{
// input is a QgsProcessingFeatureSink - get extra properties from it
QgsProcessingFeatureSink fromVar = qvariant_cast<QgsProcessingFeatureSink>( val );
// input is a QgsProcessingFeatureSinkDefinition - get extra properties from it
QgsProcessingFeatureSinkDefinition fromVar = qvariant_cast<QgsProcessingFeatureSinkDefinition>( val );
destinationProject = fromVar.destinationProject;
createOptions = fromVar.createOptions;
val = fromVar.sink;
Expand Down Expand Up @@ -1323,9 +1323,9 @@ bool QgsProcessingParameterFeatureSink::checkValueIsAcceptable( const QVariant &
if ( !var.isValid() )
return mFlags & FlagOptional;

if ( var.canConvert<QgsProcessingFeatureSink>() )
if ( var.canConvert<QgsProcessingFeatureSinkDefinition>() )
{
QgsProcessingFeatureSink fromVar = qvariant_cast<QgsProcessingFeatureSink>( var );
QgsProcessingFeatureSinkDefinition fromVar = qvariant_cast<QgsProcessingFeatureSinkDefinition>( var );
var = fromVar.sink;
}

Expand Down
14 changes: 7 additions & 7 deletions src/core/processing/qgsprocessingparameters.h
Expand Up @@ -83,34 +83,34 @@ class CORE_EXPORT QgsProcessingFeatureSourceDefinition
Q_DECLARE_METATYPE( QgsProcessingFeatureSourceDefinition )

/**
* \class QgsProcessingFeatureSink
* \class QgsProcessingFeatureSinkDefinition
* \ingroup core
*
* Encapsulates settings relating to a feature sink input to a processing algorithm.
*
* \since QGIS 3.0
*/

class CORE_EXPORT QgsProcessingFeatureSink
class CORE_EXPORT QgsProcessingFeatureSinkDefinition
{
public:

/**
* Constructor for QgsProcessingFeatureSink, accepting a static string sink.
* Constructor for QgsProcessingFeatureSinkDefinition, accepting a static string sink.
* The \a destinationProject parameter can be set to a QgsProject instance in which
* to automatically load the resulting sink after completing processing.
*/
QgsProcessingFeatureSink( const QString &sink = QString(), QgsProject *destinationProject = nullptr )
QgsProcessingFeatureSinkDefinition( const QString &sink = QString(), QgsProject *destinationProject = nullptr )
: sink( QgsProperty::fromValue( sink ) )
, destinationProject( destinationProject )
{}

/**
* Constructor for QgsProcessingFeatureSink, accepting a QgsProperty sink.
* Constructor for QgsProcessingFeatureSinkDefinition, accepting a QgsProperty sink.
* The \a destinationProject parameter can be set to a QgsProject instance in which
* to automatically load the resulting sink after completing processing.
*/
QgsProcessingFeatureSink( const QgsProperty &sink, QgsProject *destinationProject = nullptr )
QgsProcessingFeatureSinkDefinition( const QgsProperty &sink, QgsProject *destinationProject = nullptr )
: sink( sink )
, destinationProject( destinationProject )
{}
Expand Down Expand Up @@ -144,7 +144,7 @@ class CORE_EXPORT QgsProcessingFeatureSink

};

Q_DECLARE_METATYPE( QgsProcessingFeatureSink )
Q_DECLARE_METATYPE( QgsProcessingFeatureSinkDefinition )



Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsapplication.cpp
Expand Up @@ -131,7 +131,7 @@ void QgsApplication::init( QString customConfigPath )

qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( "QgsProcessingFeatureSourceDefinition" );
qRegisterMetaType<QgsProcessingFeatureSink>( "QgsProcessingFeatureSink" );
qRegisterMetaType<QgsProcessingFeatureSinkDefinition>( "QgsProcessingFeatureSinkDefinition" );

QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
// QgsDebugMsg( QString( "prefixPath(): %1" ).arg( prefixPath ) );
Expand Down
16 changes: 8 additions & 8 deletions tests/src/core/testqgsprocessing.cpp
Expand Up @@ -1147,9 +1147,9 @@ void TestQgsProcessing::parameters()
QCOMPARE( layer->wkbType(), wkbType );
QCOMPARE( layer->crs(), crs );

// QgsProcessingFeatureSink as parameter
// QgsProcessingFeatureSinkDefinition as parameter
QgsProject p;
QgsProcessingFeatureSink fs( QStringLiteral( "test.shp" ) );
QgsProcessingFeatureSinkDefinition fs( QStringLiteral( "test.shp" ) );
fs.destinationProject = &p;
QVERIFY( context.layersToLoadOnCompletion().isEmpty() );
params.insert( QStringLiteral( "fs" ), QVariant::fromValue( fs ) );
Expand Down Expand Up @@ -2270,7 +2270,7 @@ void TestQgsProcessing::parameterFeatureSink()
QVERIFY( def->checkValueIsAcceptable( "layer12312312" ) );
QVERIFY( !def->checkValueIsAcceptable( "" ) );
QVERIFY( !def->checkValueIsAcceptable( QVariant() ) );
QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSink( "layer1231123" ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSinkDefinition( "layer1231123" ) ) );

// should be OK with or without context - it's an output layer!
QVERIFY( def->checkValueIsAcceptable( "c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.shp" ) );
Expand All @@ -2285,7 +2285,7 @@ void TestQgsProcessing::parameterFeatureSink()
QVERIFY( def->checkValueIsAcceptable( "c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.shp" ) );
QVERIFY( def->checkValueIsAcceptable( "" ) );
QVERIFY( def->checkValueIsAcceptable( QVariant() ) );
QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSink( "layer1231123" ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSinkDefinition( "layer1231123" ) ) );
}

void TestQgsProcessing::checkParamValues()
Expand Down Expand Up @@ -2378,15 +2378,15 @@ void TestQgsProcessing::processingFeatureSink()
{
QString sinkString( QStringLiteral( "test.shp" ) );
QgsProject p;
QgsProcessingFeatureSink fs( sinkString, &p );
QgsProcessingFeatureSinkDefinition fs( sinkString, &p );
QCOMPARE( fs.sink.staticValue().toString(), sinkString );
QCOMPARE( fs.destinationProject, &p );

// test storing QgsProcessingFeatureSink in variant and retrieving
QVariant fsInVariant = QVariant::fromValue( fs );
QVERIFY( fsInVariant.isValid() );

QgsProcessingFeatureSink fromVar = qvariant_cast<QgsProcessingFeatureSink>( fsInVariant );
QgsProcessingFeatureSinkDefinition fromVar = qvariant_cast<QgsProcessingFeatureSinkDefinition>( fsInVariant );
QCOMPARE( fromVar.sink.staticValue().toString(), sinkString );
QCOMPARE( fromVar.destinationProject, &p );

Expand All @@ -2397,7 +2397,7 @@ void TestQgsProcessing::processingFeatureSink()
// first using static string definition
QgsProcessingParameterDefinition *def = new QgsProcessingParameterString( QStringLiteral( "layer" ) );
QVariantMap params;
params.insert( QStringLiteral( "layer" ), QgsProcessingFeatureSink( "memory:test", nullptr ) );
params.insert( QStringLiteral( "layer" ), QgsProcessingFeatureSinkDefinition( "memory:test", nullptr ) );
QString dest;
std::unique_ptr< QgsFeatureSink > sink( QgsProcessingParameters::parameterAsSink( def, params, QgsFields(), QgsWkbTypes::Point, QgsCoordinateReferenceSystem( "EPSG:3111" ), context, dest ) );
QVERIFY( sink.get() );
Expand All @@ -2406,7 +2406,7 @@ void TestQgsProcessing::processingFeatureSink()
QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:3111" ) );

// next using property based definition
params.insert( QStringLiteral( "layer" ), QgsProcessingFeatureSink( QgsProperty::fromExpression( QStringLiteral( "trim('memory' + ':test2')" ) ), nullptr ) );
params.insert( QStringLiteral( "layer" ), QgsProcessingFeatureSinkDefinition( QgsProperty::fromExpression( QStringLiteral( "trim('memory' + ':test2')" ) ), nullptr ) );
sink.reset( QgsProcessingParameters::parameterAsSink( def, params, QgsFields(), QgsWkbTypes::Point, QgsCoordinateReferenceSystem( "EPSG:3113" ), context, dest ) );
QVERIFY( sink.get() );
QgsVectorLayer *layer2 = qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::mapLayerFromString( dest, context, false ) );
Expand Down

0 comments on commit 77072b1

Please sign in to comment.