Skip to content

Commit

Permalink
Merge pull request #602 from 3nids/selectall
Browse files Browse the repository at this point in the history
add selectall features method for vector layers
  • Loading branch information
NathanW2 committed May 22, 2013
2 parents 3306c7c + e741ec9 commit c9f43f9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ class QgsVectorLayer : QgsMapLayer

/** Select not selected features and deselect selected ones */
void invertSelection();

/** Select all the features */
void selectAll();

/** Invert selection of features found within the search rectangle (in layer's coordinates) */
void invertSelectionInRectangle( QgsRectangle & rect );
Expand Down
17 changes: 17 additions & 0 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,23 @@ void QgsVectorLayer::invertSelection()
setSelectedFeatures( ids );
}

void QgsVectorLayer::selectAll()
{
QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
.setFlags( QgsFeatureRequest::NoGeometry )
.setSubsetOfAttributes( QgsAttributeList() ) );

QgsFeatureIds ids;

QgsFeature fet;
while ( fit.nextFeature( fet ) )
{
ids << fet.id();
}

setSelectedFeatures( ids );
}

void QgsVectorLayer::invertSelectionInRectangle( QgsRectangle & rect )
{
// normalize the rectangle
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Select not selected features and deselect selected ones */
void invertSelection();

/** Select all the features */
void selectAll();

/**
* Invert selection of features found within the search rectangle (in layer's coordinates)
*
Expand Down

0 comments on commit c9f43f9

Please sign in to comment.