Skip to content
Permalink
Browse files
Rename QgsVectorLayer::selectedFeaturesIterator to getSelectedFeatures
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 0b0ccc9e9defb97e73d5c65952a8b7af9ce93f40
@@ -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()
@@ -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

@@ -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)
@@ -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
@@ -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 ) )
{
@@ -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 );
@@ -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
{
@@ -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 ) );
@@ -2531,7 +2531,7 @@ QgsFeatureList QgsVectorLayer::selectedFeatures() const
}
else
{
QgsFeatureIterator it = selectedFeaturesIterator();
QgsFeatureIterator it = getSelectedFeatures();

while ( it.nextFeature( f ) )
{
@@ -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();
@@ -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
@@ -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;

@@ -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
@@ -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
{
@@ -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
{
@@ -37,7 +37,7 @@ void QgsReaderFeatures::initReader( bool useSelection )
{
if ( useSelection )
{
mFit = mLayer->selectedFeaturesIterator( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
mFit = mLayer->getSelectedFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
}
else
{

0 comments on commit 0b0ccc9

Please sign in to comment.