Skip to content
Permalink
Browse files

Advanced logic for QgsVectorLayer::hasFeatures()

  • Loading branch information
m-kuhn committed Jun 4, 2018
1 parent 6049e40 commit 8be4cc6079ef51f74d91eede196e1a6d329779df
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/core/qgsvectorlayer.cpp
@@ -2767,7 +2767,18 @@ long QgsVectorLayer::featureCount() const

QgsFeatureSource::FeatureAvailability QgsVectorLayer::hasFeatures() const
{
if ( mDataProvider->empty() && ( !mEditBuffer || mEditBuffer->addedFeatures().empty() ) )
const QgsFeatureIds deletedFeatures = mEditBuffer->deletedFeatureIds();
const QgsFeatureMap addedFeatures = mEditBuffer->addedFeatures();

if ( mEditBuffer && !deletedFeatures.empty() )
{
if ( addedFeatures.size() > deletedFeatures.size() )
return QgsFeatureSource::FeatureAvailability::FeaturesAvailable;
else
return QgsFeatureSource::FeatureAvailability::FeaturesMaybeAvailable;
}

if ( ( !mEditBuffer || addedFeatures.empty() ) && mDataProvider->empty() )
return QgsFeatureSource::FeatureAvailability::NoFeaturesAvailable;
else
return QgsFeatureSource::FeatureAvailability::FeaturesAvailable;

0 comments on commit 8be4cc6

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