Skip to content

Commit e741ec9

Browse files
committed
add select all features methods for vector layers
1 parent b7f1987 commit e741ec9

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

python/core/qgsvectorlayer.sip

+3
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

+17
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

+3
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)