[Qgis-developer] Remove Feature

Alexandre Badez alexandre.badez at gmail.com
Tue Feb 28 11:25:06 EST 2012


Hi everyone,

I'm coding a plugin in python and I would like to understand what
append during this:
    self._layer.dataProvider().deleteFeatures([v.id() for v in
self._object_map.itervalues()])
and
    self._layer.dataProvider().addFeatures([v for v in
self._object_map.itervalues()])
because features are not delete...

So... I get a look in the C++ code.. here is what I've found in
src/core/qgsvectordataprovider.cpp.
    bool QgsVectorDataProvider::addFeatures( QgsFeatureList &flist )
    {
       Q_UNUSED( flist );
       return false;
    }

    bool QgsVectorDataProvider::deleteFeatures( const QgsFeatureIds &ids )
    {
       Q_UNUSED( ids );
       return false;
    }


Well... the data provider do not seems to do anything really useful...

So I get a look to the QgsVectorLayer:

Code: Select all
    bool QgsVectorLayer::addFeature( QgsFeature& f, bool alsoUpdateExtent )
    {
      // does a lot of things
    }


So here is my questions:

    * My python code hat use the data provider "work" as expected (it
display something) but if I do this:
        self._layer.addFeatures([v for v in self._object_map.itervalues()])
    it do not work (do not display anything).
    Why ??

    * The deleteFeature do not seems to work neither on the data
provider nor on the layer... why ? Is it a bug ?

    * What am I missing, or doing wrong ?

By the way, I also check the code on SVN, (qgsvectorlayer v15857 and
qgsvectordataprovider v15197) and the code is similar to the one on
doxygen.

-- 
Alex


More information about the Qgis-developer mailing list