Skip to content
Permalink
Browse files

Also use FilterFids when field calculator is only updating selected

features. Results in similar speed improvements when updating
only selected features from a large PostGIS layer

(cherry-picked from 33fe0e2)
  • Loading branch information
nyalldawson committed Nov 18, 2015
1 parent 57381f4 commit e604a483863c0eee3208e516c7e09f85451585be
Showing with 6 additions and 12 deletions.
  1. +6 −12 src/app/qgsfieldcalculator.cpp
@@ -246,9 +246,6 @@ void QgsFieldCalculator::accept()
bool calculationSuccess = true;
QString error;

bool onlySelected = mOnlyUpdateSelectedCheckBox->isChecked();
QgsFeatureIds selectedIds = mVectorLayer->selectedFeaturesIds();

bool useGeometry = exp.needsGeometry();
int rownum = 1;

@@ -259,17 +256,14 @@ void QgsFieldCalculator::accept()
if ( newField )
emptyAttribute = QVariant( field.type() );

QgsFeatureIterator fit = mVectorLayer->getFeatures( QgsFeatureRequest().setFlags( useGeometry ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );
QgsFeatureRequest req = QgsFeatureRequest().setFlags( useGeometry ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry );
if ( mOnlyUpdateSelectedCheckBox->isChecked() )
{
req.setFilterFids( mVectorLayer->selectedFeaturesIds() );
}
QgsFeatureIterator fit = mVectorLayer->getFeatures( req );
while ( fit.nextFeature( feature ) )
{
if ( onlySelected )
{
if ( !selectedIds.contains( feature.id() ) )
{
continue;
}
}

expContext.setFeature( feature );
expContext.lastScope()->setVariable( QString( "row_number" ), rownum );

0 comments on commit e604a48

Please sign in to comment.
You can’t perform that action at this time.