25 template <
class Key,
class T>
void mapToReversedLists(
const QMap< Key, T >& map, QList<Key>& ks, QList<T>& vs )
27 ks.reserve( map.size() );
28 vs.reserve( map.size() );
29 typename QMap<Key, T>::const_iterator i = map.constEnd();
30 while ( i-- != map.constBegin() )
33 vs.append( i.value() );
57 QgsDebugMsg( QString(
"undo index changed %1" ).arg( index ) );
102 for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
103 attrs[it.key()] = it.value();
131 for ( QgsFeatureList::iterator iter = features.begin(); iter != features.end(); ++iter )
212 if ( field.
name().isEmpty() )
216 for (
int idx = 0; idx < updatedFields.
count(); ++idx )
218 if ( updatedFields[idx].name() == field.
name() )
256 commitErrors.clear();
266 bool attributesChanged =
false;
271 commitErrors <<
tr(
"SUCCESS: %n attribute(s) deleted.",
"deleted attributes count",
mDeletedAttributeIds.size() );
276 attributesChanged =
true;
280 commitErrors <<
tr(
"ERROR: %n attribute(s) not deleted.",
"not deleted attributes count",
mDeletedAttributeIds.size() );
282 QString list =
"ERROR: Pending attribute deletes:";
287 commitErrors << list;
300 commitErrors <<
tr(
"SUCCESS: %n attribute(s) added.",
"added attributes count",
mAddedAttributes.size() );
305 attributesChanged =
true;
309 commitErrors <<
tr(
"ERROR: %n new attribute(s) not added",
"not added attributes count",
mAddedAttributes.size() );
311 QString list =
"ERROR: Pending adds:";
314 list.append(
" " + f.
name() );
316 commitErrors << list;
325 bool attributeChangesOk =
true;
326 if ( attributesChanged )
333 commitErrors <<
tr(
"ERROR: the count of fields is incorrect after addition/removal of fields!" );
334 attributeChangesOk =
false;
337 for (
int i = 0; i < qMin( oldFields.
count(), newFields.
count() ); ++i )
339 const QgsField& oldField = oldFields[i];
340 const QgsField& newField = newFields[i];
341 if ( attributeChangesOk && oldField != newField )
344 <<
tr(
"ERROR: field with index %1 is not the same!" ).arg( i )
347 << QString(
"%1: name=%2 type=%3 typeName=%4 len=%5 precision=%6" )
348 .arg(
tr(
"expected field" ) )
349 .arg( oldField.
name() )
350 .arg( QVariant::typeToName( oldField.
type() ) )
354 << QString(
"%1: name=%2 type=%3 typeName=%4 len=%5 precision=%6" )
355 .arg(
tr(
"retrieved field" ) )
356 .arg( newField.
name() )
357 .arg( QVariant::typeToName( newField.
type() ) )
361 attributeChangesOk =
false;
366 if ( attributeChangesOk )
375 commitErrors <<
tr(
"SUCCESS: %n attribute value(s) changed.",
"changed attribute values count",
mChangedAttributeValues.size() );
383 commitErrors <<
tr(
"ERROR: %n attribute value change(s) not applied.",
"not changed attribute values count",
mChangedAttributeValues.size() );
385 QString list =
"ERROR: pending changes:";
395 commitErrors << list;
408 commitErrors <<
tr(
"SUCCESS: %n feature(s) deleted.",
"deleted features count",
mDeletedFeatureIds.size() );
422 commitErrors <<
tr(
"ERROR: %n feature(s) not deleted.",
"not deleted features count",
mDeletedFeatureIds.size() );
424 QString list =
"ERROR: pending deletes:";
429 commitErrors << list;
442 QList<QgsFeatureId> ids;
450 commitErrors <<
tr(
"SUCCESS: %n feature(s) added.",
"added features count", featuresToAdd.size() );
455 for (
int i = 0; i < featuresToAdd.count(); ++i )
457 if ( featuresToAdd[i].
id() != ids[i] )
460 if (
L->mSelectedFeatureIds.contains( ids[i] ) )
462 L->mSelectedFeatureIds.remove( ids[i] );
463 L->mSelectedFeatureIds.insert( featuresToAdd[i].
id() );
474 commitErrors <<
tr(
"ERROR: %n feature(s) not added.",
"not added features count",
mAddedFeatures.size() );
476 QString list =
"ERROR: pending adds:";
486 commitErrors << list;
493 commitErrors <<
tr(
"ERROR: %n feature(s) not added - provider doesn't support adding features.",
"not added features count",
mAddedFeatures.size() );
510 commitErrors <<
tr(
"SUCCESS: %n geometries were changed.",
"changed geometries count",
mChangedGeometries.size() );
518 commitErrors <<
tr(
"ERROR: %n geometries not changed.",
"not changed geometries count",
mChangedGeometries.size() );
525 commitErrors <<
tr(
"\n Provider errors:" );
526 foreach ( QString e, provider->
errors() )
528 commitErrors <<
" " + e.replace(
"\n",
"\n " );
554 QString QgsVectorLayerEditBuffer::dumpEditBuffer()
559 msg +=
"CHANGED GEOMETRIES:\n";
563 msg += QString(
"- FID %1: %2" ).arg( it.key() ).arg( it.value().to );
583 attrs.insert( index, QVariant() );
594 if ( attrMap.contains( index ) )
595 attrMap.remove( index );
606 attrs.remove( index );
615 for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
617 int attrIndex = it.key();
618 updatedMap.insert( attrIndex < index ? attrIndex : attrIndex + offset, it.value() );