Added possibility to delete features for OGR layers.

However then I've found out that nearly no OGR drivers support it :-)


git-svn-id: http://svn.osgeo.org/qgis/trunk@5062 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
wonder 2006-03-19 09:28:27 +00:00
parent 643bd1e9ee
commit 7c9442a8b8
2 changed files with 33 additions and 2 deletions

View File

@ -1159,6 +1159,25 @@ bool QgsOgrProvider::createSpatialIndex()
}
}
bool QgsOgrProvider::deleteFeatures(std::list<int> const & id)
{
bool returnvalue=true;
for(std::list<int>::const_iterator it=id.begin();it!=id.end();++it)
{
if(!deleteFeature(*it))
{
returnvalue=false;
}
}
return returnvalue;
}
bool QgsOgrProvider::deleteFeature(int id)
{
OGRErr res = ogrLayer->DeleteFeature(id);
return (res == OGRERR_NONE);
}
int QgsOgrProvider::capabilities() const
{
int ability = NoCapabilities;
@ -1185,6 +1204,12 @@ int QgsOgrProvider::capabilities() const
ability |= QgsVectorDataProvider::AddFeatures;
}
if (ogrLayer->TestCapability("DeleteFeature"))
// TRUE if this layer can delete its features
{
ability |= DeleteFeatures;
}
if (ogrLayer->TestCapability("RandomWrite"))
// TRUE if the SetFeature() method is operational on this layer.
{
@ -1232,9 +1257,10 @@ int QgsOgrProvider::capabilities() const
{
// No use required for this QGIS release.
}
#ifdef QGISDEBUG
std::cout << "QgsOgrProvider::capabilities: GDAL Version Num is 'GDAL_VERSION_NUM'." << std::endl;
std::cout << "QgsOgrProvider::capabilities: GDAL Version Num is '" <<
GDAL_VERSION_NUM << "'." << std::endl;
#endif
if (1)

View File

@ -147,6 +147,9 @@ class QgsOgrProvider:public QgsVectorDataProvider
/**Writes a list of features to the file*/
bool addFeatures(std::list<QgsFeature*> const flist);
/**Deletes a feature*/
bool deleteFeatures(std::list<int> const & id);
/**Adds new attributess. Unfortunately not supported for layers with features in it*/
bool addAttributes(std::map<QString,QString> const & name);
@ -260,6 +263,8 @@ class QgsOgrProvider:public QgsVectorDataProvider
OGRPolygon * mSelectionRectangle;
/**Adds one feature*/
bool addFeature(QgsFeature* f);
/**Deletes one feature*/
bool deleteFeature(int id);
//! The geometry factory
geos::GeometryFactory *geometryFactory;
//! The well known text reader