Skip to content
Permalink
Browse files

Improve selected features offline editing performance

  • Loading branch information
m-kuhn committed Sep 15, 2016
1 parent fe66dc0 commit 60fcddf56a8318a87a587a0765d2784417bd30da
Showing with 17 additions and 7 deletions.
  1. +17 −7 src/core/qgsofflineediting.cpp
@@ -633,20 +633,30 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
// NOTE: force feature recount for PostGIS layer, else only visible features are counted, before iterating over all features (WORKAROUND)
layer->setSubsetString( layer->subsetString() );

QgsFeatureIterator fit = layer->dataProvider()->getFeatures();
QgsFeatureRequest req;

QgsFeatureIds selectedFids = layer->selectedFeaturesIds();
if ( onlySelected )
{
QgsFeatureIds selectedFids = layer->selectedFeaturesIds();
if ( !selectedFids.isEmpty() )
req.setFilterFids( selectedFids );
}

QgsFeatureIterator fit = layer->dataProvider()->getFeatures( req );

emit progressModeSet( QgsOfflineEditing::CopyFeatures, layer->dataProvider()->featureCount() );
if ( req.filterType() == QgsFeatureRequest::FilterFids )
{
emit progressModeSet( QgsOfflineEditing::CopyFeatures, layer->selectedFeaturesIds().size() );
}
else
{
emit progressModeSet( QgsOfflineEditing::CopyFeatures, layer->dataProvider()->featureCount() );
}
int featureCount = 1;

QList<QgsFeatureId> remoteFeatureIds;
while ( fit.nextFeature( f ) )
{
// Check if we only want selected feature, if the selection is not empty and the current feature is not selected: dismiss it
if ( onlySelected && !selectedFids.isEmpty() && !selectedFids.contains( f.id() ) )
continue;

remoteFeatureIds << f.id();

// NOTE: Spatialite provider ignores position of geometry column

0 comments on commit 60fcddf

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