Skip to content

Commit

Permalink
Rename QgsVectorLayer::selectedFeaturesIterator to getSelectedFeatures
Browse files Browse the repository at this point in the history
It's more in line with QgsVectorLayer::getFeatures, hence a more
discoverable API
  • Loading branch information
nyalldawson committed Apr 27, 2017
1 parent 84471f2 commit 0b0ccc9
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Expand Up @@ -2100,6 +2100,7 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.
- Deprecated editor widget methods and enums and structs: struct RangeData, enum FeatureFormSuppress, enum EditType, addAttributeEditorWidget(), editorWidgetV2(), editorWidgetConfig(), attributeEditorElements(), editType(), setEditType(), editorLayout(), setEditorLayout, setEditorWidgetV2Config(), setCheckedState(), editForm(), setEditForm(), featureFormSuppress(), setFeatureFormSuppress(), editFormInit(), setEditFormInit(), valueMap(), range(), dateFormat(), fieldEditable(), labelOnTop(), setFieldEditable() and setLabelOnTop(). Use editFormConfig()
- select() replaced by selectByRect()
- selectedFeaturesIds() replaced by selectedFeatureIds()
- selectedFeaturesIterator() was replaced by getSelectedFeatures()
- setSelectedFeatures() replaced by selectByIds()
- applyNamedStyle() replaced by applyNamedStyle()
- isReadOnly() use readOnly()
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -586,11 +586,11 @@ Get all feature Ids
:return: A list of QgsFeature

\see selectedFeatureIds()
\see selectedFeaturesIterator() which is more memory friendly when handling large selections
\see getSelectedFeatures() which is more memory friendly when handling large selections
:rtype: QgsFeatureList
%End

QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() ) const;
QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
%Docstring
Get an iterator of the selected features

Expand Down
Expand Up @@ -67,7 +67,7 @@ def processAlgorithm(self, context, feedback):

writer = output.getVectorWriter(vectorLayer.fields(), vectorLayer.wkbType(), vectorLayer.crs(), context)

features = vectorLayer.selectedFeaturesIterator()
features = vectorLayer.getSelectedFeatures()
total = 100.0 / int(vectorLayer.selectedFeatureCount())
for current, feat in enumerate(features):
writer.addFeature(feat)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/tools/vector.py
Expand Up @@ -179,7 +179,7 @@ def spatialindex(layer):
request.setSubsetOfAttributes([])
if ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED) \
and layer.selectedFeatureCount() > 0:
idx = QgsSpatialIndex(layer.selectedFeaturesIterator(request))
idx = QgsSpatialIndex(layer.getSelectedFeatures(request))
else:
idx = QgsSpatialIndex(layer.getFeatures(request))
return idx
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolmovefeature.cpp
Expand Up @@ -134,7 +134,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

mRubberBand = createRubberBand( vlayer->geometryType() );
QgsFeature feat;
QgsFeatureIterator it = vlayer->selectedFeaturesIterator( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
QgsFeatureIterator it = vlayer->getSelectedFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );

while ( it.nextFeature( feat ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolrotatefeature.cpp
Expand Up @@ -284,7 +284,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
mRubberBand = createRubberBand( vlayer->geometryType() ) ;

QgsFeature feat;
QgsFeatureIterator it = vlayer->selectedFeaturesIterator();
QgsFeatureIterator it = vlayer->getSelectedFeatures();
while ( it.nextFeature( feat ) )
{
mRubberBand->addGeometry( feat.geometry(), vlayer );
Expand Down
4 changes: 2 additions & 2 deletions src/core/processing/qgsprocessingutils.cpp
Expand Up @@ -182,7 +182,7 @@ QgsFeatureIterator QgsProcessingUtils::getFeatures( QgsVectorLayer *layer, const
req.setInvalidGeometryCallback( context.invalidGeometryCallback() );
if ( useSelection )
{
return layer->selectedFeaturesIterator( req );
return layer->getSelectedFeatures( req );
}
else
{
Expand Down Expand Up @@ -220,7 +220,7 @@ QList<QVariant> QgsProcessingUtils::uniqueValues( QgsVectorLayer *layer, int fie
// using selection, so we have to iterate through selected features
QSet<QVariant> values;
QgsFeature f;
QgsFeatureIterator it = layer->selectedFeaturesIterator( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() << fieldIndex ).setFlags( QgsFeatureRequest::NoGeometry ) );
QgsFeatureIterator it = layer->getSelectedFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() << fieldIndex ).setFlags( QgsFeatureRequest::NoGeometry ) );
while ( it.nextFeature( f ) )
{
values.insert( f.attribute( fieldIndex ) );
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2531,7 +2531,7 @@ QgsFeatureList QgsVectorLayer::selectedFeatures() const
}
else
{
QgsFeatureIterator it = selectedFeaturesIterator();
QgsFeatureIterator it = getSelectedFeatures();

while ( it.nextFeature( f ) )
{
Expand All @@ -2542,7 +2542,7 @@ QgsFeatureList QgsVectorLayer::selectedFeatures() const
return features;
}

QgsFeatureIterator QgsVectorLayer::selectedFeaturesIterator( QgsFeatureRequest request ) const
QgsFeatureIterator QgsVectorLayer::getSelectedFeatures( QgsFeatureRequest request ) const
{
if ( mSelectedFeatureIds.isEmpty() )
return QgsFeatureIterator();
Expand Down Expand Up @@ -3451,7 +3451,7 @@ QList<QVariant> QgsVectorLayer::getValues( const QString &fieldOrExpression, boo
}
else
{
fit = selectedFeaturesIterator( request );
fit = getSelectedFeatures( request );
}

// create list of non-null attribute values
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayer.h
Expand Up @@ -608,7 +608,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \returns A list of QgsFeature
*
* \see selectedFeatureIds()
* \see selectedFeaturesIterator() which is more memory friendly when handling large selections
* \see getSelectedFeatures() which is more memory friendly when handling large selections
*/
QgsFeatureList selectedFeatures() const;

Expand All @@ -623,7 +623,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \see selectedFeatureIds()
* \see selectedFeatures()
*/
QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() ) const;
QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;

/**
* Return reference to identifiers of selected features
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayereditutils.cpp
Expand Up @@ -322,7 +322,7 @@ int QgsVectorLayerEditUtils::splitFeatures( const QList<QgsPoint> &splitLine, bo

if ( !selectedIds.isEmpty() ) //consider only the selected features if there is a selection
{
features = L->selectedFeaturesIterator();
features = L->getSelectedFeatures();
}
else //else consider all the feature that intersect the bounding box of the split line
{
Expand Down Expand Up @@ -431,7 +431,7 @@ int QgsVectorLayerEditUtils::splitParts( const QList<QgsPoint> &splitLine, bool

if ( L->selectedFeatureCount() > 0 ) //consider only the selected features if there is a selection
{
fit = L->selectedFeaturesIterator();
fit = L->getSelectedFeatures();
}
else //else consider all the feature that intersect the bounding box of the split line
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/spatialquery/qgsreaderfeatures.cpp
Expand Up @@ -37,7 +37,7 @@ void QgsReaderFeatures::initReader( bool useSelection )
{
if ( useSelection )
{
mFit = mLayer->selectedFeaturesIterator( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
mFit = mLayer->getSelectedFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
}
else
{
Expand Down

0 comments on commit 0b0ccc9

Please sign in to comment.