Skip to content

Commit 5da6004

Browse files
committed
Update method's name and add doc
1 parent 03447f8 commit 5da6004

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/core/qgsjsonutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ QString QgsJsonExporter::exportFeatures( const QgsFeatureList &features ) const
238238
}
239239

240240
QString layerName;
241-
if ( mIncludeLayerName )
241+
if ( mIncludeName )
242242
layerName.append( QStringLiteral( "\n \"name\": \"%1\",\n" ).arg( mLayer->name() ) );
243243

244244
return QStringLiteral( "{%1 \"type\": \"FeatureCollection\",\n \"features\":[\n%2\n]}" ).arg( layerName, featureJSON.join( QStringLiteral( ",\n" ) ) );

src/core/qgsjsonutils.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,20 @@ class CORE_EXPORT QgsJsonExporter
7575
*/
7676
bool includeGeometry() const { return mIncludeGeometry; }
7777

78-
void setIncludeLayerName( bool includeLayerName ) { mIncludeLayerName = includeLayerName; }
78+
/**
79+
* Sets whether to include layer's name in the JSON exports.
80+
* \param includeName set to false to prevent name inclusion
81+
* \see includeName()
82+
* \since QGIS 3.6
83+
*/
84+
void setIncludeName( bool includeName ) { mIncludeName = includeName; }
7985

80-
bool includeLayerName() const { return mIncludeLayerName; }
86+
/**
87+
* Returns whether layer's name will be included in the JSON exports.
88+
* \see setIncludeName()
89+
* \since QGIS 3.6
90+
*/
91+
bool includeName() const { return mIncludeName; }
8192

8293
/**
8394
* Sets whether to include attributes in the JSON exports.
@@ -227,7 +238,7 @@ class CORE_EXPORT QgsJsonExporter
227238

228239
QgsCoordinateTransform mTransform;
229240

230-
bool mIncludeLayerName = false;
241+
bool mIncludeName = false;
231242
};
232243

233244
/**

src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ namespace QgsWms
23402340
QgsJsonExporter exporter( vl );
23412341
exporter.setAttributes( attributes );
23422342
exporter.setIncludeGeometry( withGeometry );
2343-
exporter.setIncludeLayerName( true );
2343+
exporter.setIncludeName( true );
23442344

23452345
if ( i > 0 )
23462346
json.append( QStringLiteral( "," ) );

0 commit comments

Comments
 (0)