Skip to content

Commit c9f43f9

Browse files
committedMay 22, 2013
Merge pull request #602 from 3nids/selectall
add selectall features method for vector layers
2 parents 3306c7c + e741ec9 commit c9f43f9

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
 

‎python/core/qgsvectorlayer.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ class QgsVectorLayer : QgsMapLayer
239239

240240
/** Select not selected features and deselect selected ones */
241241
void invertSelection();
242+
243+
/** Select all the features */
244+
void selectAll();
242245

243246
/** Invert selection of features found within the search rectangle (in layer's coordinates) */
244247
void invertSelectionInRectangle( QgsRectangle & rect );

‎src/core/qgsvectorlayer.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,23 @@ void QgsVectorLayer::invertSelection()
812812
setSelectedFeatures( ids );
813813
}
814814

815+
void QgsVectorLayer::selectAll()
816+
{
817+
QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
818+
.setFlags( QgsFeatureRequest::NoGeometry )
819+
.setSubsetOfAttributes( QgsAttributeList() ) );
820+
821+
QgsFeatureIds ids;
822+
823+
QgsFeature fet;
824+
while ( fit.nextFeature( fet ) )
825+
{
826+
ids << fet.id();
827+
}
828+
829+
setSelectedFeatures( ids );
830+
}
831+
815832
void QgsVectorLayer::invertSelectionInRectangle( QgsRectangle & rect )
816833
{
817834
// normalize the rectangle

‎src/core/qgsvectorlayer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
619619
/** Select not selected features and deselect selected ones */
620620
void invertSelection();
621621

622+
/** Select all the features */
623+
void selectAll();
624+
622625
/**
623626
* Invert selection of features found within the search rectangle (in layer's coordinates)
624627
*

0 commit comments

Comments
 (0)
Please sign in to comment.