File tree 2 files changed +33
-2
lines changed
2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -1159,6 +1159,25 @@ bool QgsOgrProvider::createSpatialIndex()
1159
1159
}
1160
1160
}
1161
1161
1162
+ bool QgsOgrProvider::deleteFeatures (std::list<int > const & id)
1163
+ {
1164
+ bool returnvalue=true ;
1165
+ for (std::list<int >::const_iterator it=id.begin ();it!=id.end ();++it)
1166
+ {
1167
+ if (!deleteFeature (*it))
1168
+ {
1169
+ returnvalue=false ;
1170
+ }
1171
+ }
1172
+ return returnvalue;
1173
+ }
1174
+
1175
+ bool QgsOgrProvider::deleteFeature (int id)
1176
+ {
1177
+ OGRErr res = ogrLayer->DeleteFeature (id);
1178
+ return (res == OGRERR_NONE);
1179
+ }
1180
+
1162
1181
int QgsOgrProvider::capabilities () const
1163
1182
{
1164
1183
int ability = NoCapabilities;
@@ -1185,6 +1204,12 @@ int QgsOgrProvider::capabilities() const
1185
1204
ability |= QgsVectorDataProvider::AddFeatures;
1186
1205
}
1187
1206
1207
+ if (ogrLayer->TestCapability (" DeleteFeature" ))
1208
+ // TRUE if this layer can delete its features
1209
+ {
1210
+ ability |= DeleteFeatures;
1211
+ }
1212
+
1188
1213
if (ogrLayer->TestCapability (" RandomWrite" ))
1189
1214
// TRUE if the SetFeature() method is operational on this layer.
1190
1215
{
@@ -1232,9 +1257,10 @@ int QgsOgrProvider::capabilities() const
1232
1257
{
1233
1258
// No use required for this QGIS release.
1234
1259
}
1235
-
1260
+
1236
1261
#ifdef QGISDEBUG
1237
- std::cout << " QgsOgrProvider::capabilities: GDAL Version Num is 'GDAL_VERSION_NUM'." << std::endl;
1262
+ std::cout << " QgsOgrProvider::capabilities: GDAL Version Num is '" <<
1263
+ GDAL_VERSION_NUM << " '." << std::endl;
1238
1264
#endif
1239
1265
1240
1266
if (1 )
Original file line number Diff line number Diff line change @@ -147,6 +147,9 @@ class QgsOgrProvider:public QgsVectorDataProvider
147
147
/* *Writes a list of features to the file*/
148
148
bool addFeatures (std::list<QgsFeature*> const flist);
149
149
150
+ /* *Deletes a feature*/
151
+ bool deleteFeatures (std::list<int > const & id);
152
+
150
153
/* *Adds new attributess. Unfortunately not supported for layers with features in it*/
151
154
bool addAttributes (std::map<QString,QString> const & name);
152
155
@@ -260,6 +263,8 @@ class QgsOgrProvider:public QgsVectorDataProvider
260
263
OGRPolygon * mSelectionRectangle ;
261
264
/* *Adds one feature*/
262
265
bool addFeature (QgsFeature* f);
266
+ /* *Deletes one feature*/
267
+ bool deleteFeature (int id);
263
268
// ! The geometry factory
264
269
geos::GeometryFactory *geometryFactory;
265
270
// ! The well known text reader
You can’t perform that action at this time.
0 commit comments