Skip to content

Commit b75a174

Browse files
committed
Rename QgsProcessingFeatureSinkDefinition to QgsProcessingOutputLayerDefinition
Since it also applies to raster layer outputs, we need a more generic name
1 parent f64f74f commit b75a174

File tree

7 files changed

+40
-40
lines changed

7 files changed

+40
-40
lines changed

python/core/processing/qgsprocessingparameters.sip

+11-11
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ Allows direct construction of QVariants.
5656

5757

5858

59-
class QgsProcessingFeatureSinkDefinition
59+
class QgsProcessingOutputLayerDefinition
6060
{
6161
%Docstring
6262

63-
Encapsulates settings relating to a feature sink input to a processing algorithm.
63+
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
6464

6565
.. versionadded:: 3.0
6666
%End
@@ -70,35 +70,35 @@ class QgsProcessingFeatureSinkDefinition
7070
%End
7171
public:
7272

73-
QgsProcessingFeatureSinkDefinition( const QString &sink = QString(), QgsProject *destinationProject = 0 );
73+
QgsProcessingOutputLayerDefinition( const QString &sink = QString(), QgsProject *destinationProject = 0 );
7474
%Docstring
75-
Constructor for QgsProcessingFeatureSinkDefinition, accepting a static string sink.
75+
Constructor for QgsProcessingOutputLayerDefinition, accepting a static sink/layer string.
7676
The ``destinationProject`` parameter can be set to a QgsProject instance in which
77-
to automatically load the resulting sink after completing processing.
77+
to automatically load the resulting sink/layer after completing processing.
7878
%End
7979

80-
QgsProcessingFeatureSinkDefinition( const QgsProperty &sink, QgsProject *destinationProject = 0 );
80+
QgsProcessingOutputLayerDefinition( const QgsProperty &sink, QgsProject *destinationProject = 0 );
8181
%Docstring
82-
Constructor for QgsProcessingFeatureSinkDefinition, accepting a QgsProperty sink.
82+
Constructor for QgsProcessingOutputLayerDefinition, accepting a QgsProperty sink/layer.
8383
The ``destinationProject`` parameter can be set to a QgsProject instance in which
84-
to automatically load the resulting sink after completing processing.
84+
to automatically load the resulting sink/layer after completing processing.
8585
%End
8686

8787
QgsProperty sink;
8888
%Docstring
89-
Sink definition. Usually a static property set to the destination file name for the sink's layer.
89+
Sink/layer definition. Usually a static property set to the destination file name for the sink's layer.
9090
%End
9191

9292
QgsProject *destinationProject;
9393
%Docstring
9494
Destination project. Can be set to a QgsProject instance in which
95-
to automatically load the resulting sink after completing processing.
95+
to automatically load the resulting sink/layer after completing processing.
9696
The default behavior is not to load the result into any project (None).
9797
%End
9898

9999
QVariantMap createOptions;
100100
%Docstring
101-
Map of optional sink creation options, which
101+
Map of optional sink/layer creation options, which
102102
are passed to the underlying provider when creating new layers. Known options also
103103
include 'fileEncoding', which is used to specify a file encoding to use for created
104104
files.

python/plugins/processing/gui/AlgorithmDialog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
QgsMessageLog,
3636
QgsProcessingParameterDefinition,
3737
QgsProcessingOutputVectorLayer,
38-
QgsProcessingFeatureSinkDefinition,
38+
QgsProcessingOutputLayerDefinition,
3939
QgsProcessingParameterFeatureSink,
4040
QgsProcessingAlgorithm)
4141
from qgis.gui import QgsMessageBar

python/plugins/processing/gui/DestinationSelectionPanel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
QgsExpression,
4040
QgsSettings,
4141
QgsProcessingParameterFeatureSink,
42-
QgsProcessingFeatureSinkDefinition)
42+
QgsProcessingOutputLayerDefinition)
4343
from processing.core.ProcessingConfig import ProcessingConfig
4444
from processing.core.outputs import OutputVector
4545
from processing.core.outputs import OutputDirectory
@@ -234,6 +234,6 @@ def getValue(self):
234234
key = 'memory:'
235235
else:
236236
key = self.leText.text()
237-
value = QgsProcessingFeatureSinkDefinition(key)
237+
value = QgsProcessingOutputLayerDefinition(key)
238238
value.createOptions = {'fileEncoding': self.encoding}
239239
return value

src/core/processing/qgsprocessingparameters.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ QgsFeatureSink *QgsProcessingParameters::parameterAsSink( const QgsProcessingPar
215215

216216
QgsProject *destinationProject = nullptr;
217217
QVariantMap createOptions;
218-
if ( val.canConvert<QgsProcessingFeatureSinkDefinition>() )
218+
if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
219219
{
220-
// input is a QgsProcessingFeatureSinkDefinition - get extra properties from it
221-
QgsProcessingFeatureSinkDefinition fromVar = qvariant_cast<QgsProcessingFeatureSinkDefinition>( val );
220+
// input is a QgsProcessingOutputLayerDefinition - get extra properties from it
221+
QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
222222
destinationProject = fromVar.destinationProject;
223223
createOptions = fromVar.createOptions;
224224
val = fromVar.sink;
@@ -1323,9 +1323,9 @@ bool QgsProcessingParameterFeatureSink::checkValueIsAcceptable( const QVariant &
13231323
if ( !var.isValid() )
13241324
return mFlags & FlagOptional;
13251325

1326-
if ( var.canConvert<QgsProcessingFeatureSinkDefinition>() )
1326+
if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
13271327
{
1328-
QgsProcessingFeatureSinkDefinition fromVar = qvariant_cast<QgsProcessingFeatureSinkDefinition>( var );
1328+
QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
13291329
var = fromVar.sink;
13301330
}
13311331

src/core/processing/qgsprocessingparameters.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -83,52 +83,52 @@ class CORE_EXPORT QgsProcessingFeatureSourceDefinition
8383
Q_DECLARE_METATYPE( QgsProcessingFeatureSourceDefinition )
8484

8585
/**
86-
* \class QgsProcessingFeatureSinkDefinition
86+
* \class QgsProcessingOutputLayerDefinition
8787
* \ingroup core
8888
*
89-
* Encapsulates settings relating to a feature sink input to a processing algorithm.
89+
* Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
9090
*
9191
* \since QGIS 3.0
9292
*/
9393

94-
class CORE_EXPORT QgsProcessingFeatureSinkDefinition
94+
class CORE_EXPORT QgsProcessingOutputLayerDefinition
9595
{
9696
public:
9797

9898
/**
99-
* Constructor for QgsProcessingFeatureSinkDefinition, accepting a static string sink.
99+
* Constructor for QgsProcessingOutputLayerDefinition, accepting a static sink/layer string.
100100
* The \a destinationProject parameter can be set to a QgsProject instance in which
101-
* to automatically load the resulting sink after completing processing.
101+
* to automatically load the resulting sink/layer after completing processing.
102102
*/
103-
QgsProcessingFeatureSinkDefinition( const QString &sink = QString(), QgsProject *destinationProject = nullptr )
103+
QgsProcessingOutputLayerDefinition( const QString &sink = QString(), QgsProject *destinationProject = nullptr )
104104
: sink( QgsProperty::fromValue( sink ) )
105105
, destinationProject( destinationProject )
106106
{}
107107

108108
/**
109-
* Constructor for QgsProcessingFeatureSinkDefinition, accepting a QgsProperty sink.
109+
* Constructor for QgsProcessingOutputLayerDefinition, accepting a QgsProperty sink/layer.
110110
* The \a destinationProject parameter can be set to a QgsProject instance in which
111-
* to automatically load the resulting sink after completing processing.
111+
* to automatically load the resulting sink/layer after completing processing.
112112
*/
113-
QgsProcessingFeatureSinkDefinition( const QgsProperty &sink, QgsProject *destinationProject = nullptr )
113+
QgsProcessingOutputLayerDefinition( const QgsProperty &sink, QgsProject *destinationProject = nullptr )
114114
: sink( sink )
115115
, destinationProject( destinationProject )
116116
{}
117117

118118
/**
119-
* Sink definition. Usually a static property set to the destination file name for the sink's layer.
119+
* Sink/layer definition. Usually a static property set to the destination file name for the sink's layer.
120120
*/
121121
QgsProperty sink;
122122

123123
/**
124124
* Destination project. Can be set to a QgsProject instance in which
125-
* to automatically load the resulting sink after completing processing.
125+
* to automatically load the resulting sink/layer after completing processing.
126126
* The default behavior is not to load the result into any project (nullptr).
127127
*/
128128
QgsProject *destinationProject;
129129

130130
/**
131-
* Map of optional sink creation options, which
131+
* Map of optional sink/layer creation options, which
132132
* are passed to the underlying provider when creating new layers. Known options also
133133
* include 'fileEncoding', which is used to specify a file encoding to use for created
134134
* files.
@@ -144,7 +144,7 @@ class CORE_EXPORT QgsProcessingFeatureSinkDefinition
144144

145145
};
146146

147-
Q_DECLARE_METATYPE( QgsProcessingFeatureSinkDefinition )
147+
Q_DECLARE_METATYPE( QgsProcessingOutputLayerDefinition )
148148

149149

150150

src/core/qgsapplication.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void QgsApplication::init( QString customConfigPath )
131131

132132
qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
133133
qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( "QgsProcessingFeatureSourceDefinition" );
134-
qRegisterMetaType<QgsProcessingFeatureSinkDefinition>( "QgsProcessingFeatureSinkDefinition" );
134+
qRegisterMetaType<QgsProcessingOutputLayerDefinition>( "QgsProcessingOutputLayerDefinition" );
135135

136136
QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
137137
// QgsDebugMsg( QString( "prefixPath(): %1" ).arg( prefixPath ) );

tests/src/core/testqgsprocessing.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ void TestQgsProcessing::parameters()
11511151

11521152
// QgsProcessingFeatureSinkDefinition as parameter
11531153
QgsProject p;
1154-
QgsProcessingFeatureSinkDefinition fs( QStringLiteral( "test.shp" ) );
1154+
QgsProcessingOutputLayerDefinition fs( QStringLiteral( "test.shp" ) );
11551155
fs.destinationProject = &p;
11561156
QVERIFY( context.layersToLoadOnCompletion().isEmpty() );
11571157
params.insert( QStringLiteral( "fs" ), QVariant::fromValue( fs ) );
@@ -2272,7 +2272,7 @@ void TestQgsProcessing::parameterFeatureSink()
22722272
QVERIFY( def->checkValueIsAcceptable( "layer12312312" ) );
22732273
QVERIFY( !def->checkValueIsAcceptable( "" ) );
22742274
QVERIFY( !def->checkValueIsAcceptable( QVariant() ) );
2275-
QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSinkDefinition( "layer1231123" ) ) );
2275+
QVERIFY( def->checkValueIsAcceptable( QgsProcessingOutputLayerDefinition( "layer1231123" ) ) );
22762276

22772277
// should be OK with or without context - it's an output layer!
22782278
QVERIFY( def->checkValueIsAcceptable( "c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.shp" ) );
@@ -2287,7 +2287,7 @@ void TestQgsProcessing::parameterFeatureSink()
22872287
QVERIFY( def->checkValueIsAcceptable( "c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.shp" ) );
22882288
QVERIFY( def->checkValueIsAcceptable( "" ) );
22892289
QVERIFY( def->checkValueIsAcceptable( QVariant() ) );
2290-
QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSinkDefinition( "layer1231123" ) ) );
2290+
QVERIFY( def->checkValueIsAcceptable( QgsProcessingOutputLayerDefinition( "layer1231123" ) ) );
22912291

22922292
// test hasGeometry
22932293
QVERIFY( QgsProcessingParameterFeatureSink( "test", QString(), QgsProcessingParameterDefinition::TypeAny ).hasGeometry() );
@@ -2391,15 +2391,15 @@ void TestQgsProcessing::processingFeatureSink()
23912391
{
23922392
QString sinkString( QStringLiteral( "test.shp" ) );
23932393
QgsProject p;
2394-
QgsProcessingFeatureSinkDefinition fs( sinkString, &p );
2394+
QgsProcessingOutputLayerDefinition fs( sinkString, &p );
23952395
QCOMPARE( fs.sink.staticValue().toString(), sinkString );
23962396
QCOMPARE( fs.destinationProject, &p );
23972397

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

2402-
QgsProcessingFeatureSinkDefinition fromVar = qvariant_cast<QgsProcessingFeatureSinkDefinition>( fsInVariant );
2402+
QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( fsInVariant );
24032403
QCOMPARE( fromVar.sink.staticValue().toString(), sinkString );
24042404
QCOMPARE( fromVar.destinationProject, &p );
24052405

@@ -2410,7 +2410,7 @@ void TestQgsProcessing::processingFeatureSink()
24102410
// first using static string definition
24112411
QgsProcessingParameterDefinition *def = new QgsProcessingParameterString( QStringLiteral( "layer" ) );
24122412
QVariantMap params;
2413-
params.insert( QStringLiteral( "layer" ), QgsProcessingFeatureSinkDefinition( "memory:test", nullptr ) );
2413+
params.insert( QStringLiteral( "layer" ), QgsProcessingOutputLayerDefinition( "memory:test", nullptr ) );
24142414
QString dest;
24152415
std::unique_ptr< QgsFeatureSink > sink( QgsProcessingParameters::parameterAsSink( def, params, QgsFields(), QgsWkbTypes::Point, QgsCoordinateReferenceSystem( "EPSG:3111" ), context, dest ) );
24162416
QVERIFY( sink.get() );
@@ -2419,7 +2419,7 @@ void TestQgsProcessing::processingFeatureSink()
24192419
QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:3111" ) );
24202420

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

0 commit comments

Comments
 (0)