43 qDebug(
"undo index changed %d", index );
88 for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); it++ )
89 attrs[it.key()] = it.value();
117 for ( QgsFeatureList::iterator iter = features.begin(); iter != features.end(); ++iter )
197 if ( field.
name().isEmpty() )
201 for (
int idx = 0; idx < updatedFields.
count(); ++idx )
203 if ( updatedFields[idx].name() == field.
name() )
241 commitErrors.clear();
253 bool attributesChanged =
false;
258 commitErrors <<
tr(
"SUCCESS: %n attribute(s) deleted.",
"deleted attributes count",
mDeletedAttributeIds.size() );
263 attributesChanged =
true;
267 commitErrors <<
tr(
"ERROR: %n attribute(s) not deleted.",
"not deleted attributes count",
mDeletedAttributeIds.size() );
269 QString list =
"ERROR: Pending attribute deletes:";
274 commitErrors << list;
287 commitErrors <<
tr(
"SUCCESS: %n attribute(s) added.",
"added attributes count",
mAddedAttributes.size() );
292 attributesChanged =
true;
296 commitErrors <<
tr(
"ERROR: %n new attribute(s) not added",
"not added attributes count",
mAddedAttributes.size() );
298 QString list =
"ERROR: Pending adds:";
301 list.append(
" " + f.
name() );
303 commitErrors << list;
312 bool attributeChangesOk =
true;
313 if ( attributesChanged )
320 commitErrors <<
tr(
"ERROR: the count of fields is incorrect after addition/removal of fields!" );
321 attributeChangesOk =
false;
324 for (
int i = 0; i < oldFields.
count(); ++i )
326 const QgsField& oldField = oldFields[i];
327 const QgsField& newField = newFields[i];
328 if ( attributeChangesOk && oldField != newField )
330 commitErrors <<
tr(
"ERROR: field with index %1 is not the same!" ).arg( i );
331 attributeChangesOk =
false;
336 if ( attributeChangesOk )
345 commitErrors <<
tr(
"SUCCESS: %n attribute value(s) changed.",
"changed attribute values count",
mChangedAttributeValues.size() );
353 commitErrors <<
tr(
"ERROR: %n attribute value change(s) not applied.",
"not changed attribute values count",
mChangedAttributeValues.size() );
355 QString list =
"ERROR: pending changes:";
365 commitErrors << list;
378 commitErrors <<
tr(
"SUCCESS: %n feature(s) deleted.",
"deleted features count",
mDeletedFeatureIds.size() );
392 commitErrors <<
tr(
"ERROR: %n feature(s) not deleted.",
"not deleted features count",
mDeletedFeatureIds.size() );
394 QString list =
"ERROR: pending deletes:";
399 commitErrors << list;
417 commitErrors <<
tr(
"SUCCESS: %n feature(s) added.",
"added features count", featuresToAdd.size() );
422 for (
int i = 0; i < featuresToAdd.count(); ++i )
424 if ( featuresToAdd[i].
id() != ids[i] )
441 commitErrors <<
tr(
"ERROR: %n feature(s) not added.",
"not added features count",
mAddedFeatures.size() );
443 QString list =
"ERROR: pending adds:";
453 commitErrors << list;
460 commitErrors <<
tr(
"ERROR: %n feature(s) not added - provider doesn't support adding features.",
"not added features count",
mAddedFeatures.size() );
477 commitErrors <<
tr(
"SUCCESS: %n geometries were changed.",
"changed geometries count",
mChangedGeometries.size() );
485 commitErrors <<
tr(
"ERROR: %n geometries not changed.",
"not changed geometries count",
mChangedGeometries.size() );
499 commitErrors <<
tr(
"\n Provider errors:" );
500 foreach ( QString e, provider->
errors() )
502 commitErrors <<
" " + e.replace(
"\n",
"\n " );
528 QString QgsVectorLayerEditBuffer::dumpEditBuffer()
533 msg +=
"CHANGED GEOMETRIES:\n";
537 msg += QString(
"- FID %1: %2" ).arg( it.key() ).arg( it.value().to );
557 attrs.insert( index, QVariant() );
568 if ( attrMap.contains( index ) )
569 attrMap.remove( index );
580 attrs.remove( index );
589 for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
591 int attrIndex = it.key();
592 updatedMap.insert( attrIndex < index ? attrIndex : attrIndex + offset, it.value() );