80 fields[ renameIt.key()].setName( renameIt.value() );
109 for ( QgsAttributeMap::const_iterator it = map.
begin(); it != map.
end(); ++it )
110 attrs[it.key()] = it.
value();
193 if ( geometry && geometry->
geometry() &&
268 if ( updatedField.
name() == field.
name() )
315 if ( updatedField.
name() == newName )
327 commitErrors.
clear();
344 commitErrors <<
tr(
"SUCCESS: %n geometries were changed.",
"changed geometries count",
mChangedGeometries.
size() );
351 commitErrors <<
tr(
"ERROR: %n geometries not changed.",
"not changed geometries count",
mChangedGeometries.
size() );
361 bool attributesChanged =
false;
371 attributesChanged =
true;
377 QString list =
"ERROR: Pending attribute deletes:";
382 commitErrors << list;
395 commitErrors <<
tr(
"SUCCESS: %n attribute(s) added.",
"added attributes count",
mAddedAttributes.
size() );
400 attributesChanged =
true;
404 commitErrors <<
tr(
"ERROR: %n new attribute(s) not added",
"not added attributes count",
mAddedAttributes.
size() );
406 QString list =
"ERROR: Pending adds:";
411 commitErrors << list;
427 attributesChanged =
true;
431 commitErrors <<
tr(
"ERROR: %n attribute(s) not renamed",
"not renamed attributes count",
mRenamedAttributes.
size() );
439 bool attributeChangesOk =
true;
440 if ( attributesChanged )
447 commitErrors <<
tr(
"ERROR: the count of fields is incorrect after addition/removal of fields!" );
448 attributeChangesOk =
false;
451 for (
int i = 0; i < qMin( oldFields.
count(), newFields.
count() ); ++i )
455 if ( attributeChangesOk && oldField != newField )
458 <<
tr(
"ERROR: field with index %1 is not the same!" ).
arg( i )
461 <<
QString(
"%1: name=%2 type=%3 typeName=%4 len=%5 precision=%6" )
462 .
arg(
tr(
"expected field" ),
468 <<
QString(
"%1: name=%2 type=%3 typeName=%4 len=%5 precision=%6" )
469 .
arg(
tr(
"retrieved field" ),
475 attributeChangesOk =
false;
480 if ( attributeChangesOk )
516 commitErrors <<
tr(
"ERROR: %n attribute value change(s) not applied.",
"not changed attribute values count",
mChangedAttributeValues.
size() );
518 QString list =
"ERROR: pending changes:";
528 commitErrors << list;
558 QString list =
"ERROR: pending deletes:";
563 commitErrors << list;
584 commitErrors <<
tr(
"SUCCESS: %n feature(s) added.",
"added features count", featuresToAdd.
size() );
589 for (
int i = 0; i < featuresToAdd.
count(); ++i )
591 if ( featuresToAdd[i].
id() != ids[i] )
594 if (
L->mSelectedFeatureIds.
contains( ids[i] ) )
596 L->mSelectedFeatureIds.
remove( ids[i] );
597 L->mSelectedFeatureIds.
insert( featuresToAdd[i].
id() );
608 commitErrors <<
tr(
"ERROR: %n feature(s) not added.",
"not added features count",
mAddedFeatures.
size() );
610 QString list =
"ERROR: pending adds:";
620 commitErrors << list;
627 commitErrors <<
tr(
"ERROR: %n feature(s) not added - provider doesn't support adding features.",
"not added features count",
mAddedFeatures.
size() );
639 commitErrors <<
tr(
"\n Provider errors:" );
642 commitErrors <<
" " + e.
replace(
'\n',
"\n " );
668 QString QgsVectorLayerEditBuffer::dumpEditBuffer()
673 msg +=
"CHANGED GEOMETRIES:\n";
677 msg +=
QString(
"- FID %1: %2" ).
arg( it.key() ).arg( it.value().to );
699 featureIt->setAttributes( attrs );
705 qSort( sortedRenamedIndices.
begin(), sortedRenamedIndices.
end(), qGreater< int >() );
706 Q_FOREACH (
int renameIndex, sortedRenamedIndices )
708 if ( renameIndex >= index )
738 featureIt->setAttributes( attrs );
744 qSort( sortedRenamedIndices.
begin(), sortedRenamedIndices.
end() );
747 Q_FOREACH (
int renameIndex, sortedRenamedIndices )
749 if ( renameIndex > index )
765 for ( QgsAttributeMap::const_iterator it = map.
begin(); it != map.
end(); ++it )
767 int attrIndex = it.
key();
768 updatedMap.
insert( attrIndex < index ? attrIndex : attrIndex + offset, it.value() );
783 QgsAttributeMap::const_iterator it;
786 const int field = it.key();
791 oldValue = oldValues[field];
void updateFields()
Assembles mUpdatedFields considering provider fields, joined fields and added fields.
void updateChangedAttributes(QgsFeature &f)
Update feature with uncommited attribute updates.
QString & append(QChar ch)
void handleAttributeDeleted(int index)
Update added and changed features after removal of an attribute.
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
QgsAttributes attributes() const
Returns the feature's attributes.
virtual bool renameAttribute(int attr, const QString &newName)
Renames an attribute field (but does not commit it)
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
virtual bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
int size() const
Return number of items.
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
void undoIndexChanged(int index)
bool contains(const Key &key) const
QgsVectorLayerEditBuffer()
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
Signals emitted after committing changes.
void mapToReversedLists(const QMap< Key, T > &map, QList< Key > &ks, QList< T > &vs)
populate two lists (ks, vs) from map - in reverse order
virtual bool addAttributes(const QList< QgsField > &attributes)
Adds new attributes.
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
virtual bool addFeature(QgsFeature &f)
Adds a feature.
field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
bool adaptGeometry(QgsGeometry *geometry)
Apply geometry modification basing on provider geometry type.
virtual bool deleteFeatures(const QgsFeatureIds &id)
Deletes one or more features.
const_iterator constBegin() const
const T & at(int i) const
virtual bool renameAttributes(const QgsFieldNameMap &renamedAttributes)
Renames existing attributes.
void insert(int i, const T &value)
#define FID_TO_STRING(fid)
friend class QgsVectorLayerUndoCommandChangeGeometry
Container of fields for a vector layer.
virtual void rollBack()
Stop editing and discard the edits.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
QStringList errors()
Get recorded errors.
friend class QgsVectorLayerUndoCommandAddAttribute
QgsChangedAttributesMap mChangedAttributeValues
Changed attributes values which are not commited.
void updateFeatureGeometry(QgsFeature &f)
Update feature with uncommited geometry updates.
Allows deletion of attributes (fields)
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
const_iterator insert(const T &value)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsFieldNameMap mRenamedAttributes
Renamed attributes which are not commited.
friend class QgsVectorLayerUndoCommandRenameAttribute
virtual bool addFeatures(QgsFeatureList &flist)
Adds a list of features.
int count() const
Return number of items.
QString tr(const char *sourceText, const char *disambiguation, int n)
friend class QgsVectorLayerUndoCommandDeleteAttribute
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
virtual void updateExtents()
Update the extents for the layer.
bool supportedType(const QgsField &field) const
check if provider supports type of field
QgsFields fields() const
Returns the list of fields of this layer.
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
QList< Key > keys() const
virtual bool doesStrictFeatureTypeCheck() const
Returns true if the provider is strict about the type of inserted features (e.g.
void featureAdded(QgsFeatureId fid)
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
int count(const T &value) const
void append(const T &value)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
Allows addition of new attributes (fields)
QString typeName() const
Gets the field type.
friend class QgsVectorLayerUndoCommandAddFeature
bool hasErrors()
Provider has errors to report.
virtual bool changeAttributeValues(const QgsChangedAttributesMap &attr_map)
Changes attribute values of existing features.
virtual bool changeFeatures(const QgsChangedAttributesMap &attr_map, const QgsGeometryMap &geometry_map)
Changes attribute values and geometries of existing features.
const_iterator constEnd() const
QgsGeometryMap mChangedGeometries
Changed geometries which are not commited.
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
void handleAttributeAdded(int index)
Update added and changed features after addition of an attribute.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
Allows modifications of geometries.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Append a field. The field must have unique name, otherwise it is rejected (returns false) ...
virtual bool deleteFeatures(const QgsFeatureIds &fid)
Deletes a set of features from the layer (but does not commit it)
void clearErrors()
Clear recorded errors.
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not commited.
Encapsulate a field in an attribute table or data source.
virtual QGis::WkbType geometryType() const =0
Get feature type.
virtual bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes values of attributes (but does not commit it).
virtual bool changeGeometryValues(const QgsGeometryMap &geometry_map)
Changes geometries of existing features.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
void updateAttributeMapIndex(QgsAttributeMap &attrs, int index, int offset) const
Updates an index in an attribute map to a new value (for updates of changed attributes) ...
void remove(int fieldIdx)
Remove a field with the given index.
virtual bool commitChanges(QStringList &commitErrors)
Attempts to commit any changes to disk.
virtual bool deleteAttribute(int attr)
Delete an attribute field (but does not commit it)
friend class QgsVectorLayerUndoCommandDeleteFeature
QgsFeatureId id() const
Get the feature ID for this feature.
bool contains(const T &value) const
QgsGeometry * geometry()
Get the geometry object associated with this feature.
Supports joint updates for attributes and geometry Providers supporting this should still define Chan...
bool contains(const T &value) const
const char * typeToName(Type typ)
const Key key(const T &value) const
QString & replace(int position, int n, QChar after)
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
QList< QgsField > mAddedAttributes
Added attributes fields which are not commited.
~QgsVectorLayerEditBuffer()
bool remove(const T &value)
QgsGeometry * convertToProviderType(const QgsGeometry *geom) const
Converts the geometry to the provider type if possible / necessary this is the list of possible modif...
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
void committedAttributesRenamed(const QString &layerId, const QgsFieldNameMap &renamedAttributes)
Emitted after committing an attribute rename.
int count(const T &value) const
virtual bool deleteAttributes(const QgsAttributeIds &attributes)
Deletes existing attributes.
virtual bool deleteFeature(QgsFeatureId fid)
Delete a feature from the layer (but does not commit it)
QgsFields pendingFields() const
Returns the list of fields of this layer.
virtual bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changed an attribute value (but does not commit it)
Allows deletion of features.
iterator insert(const Key &key, const T &value)
QUndoStack * undoStack()
Return pointer to layer's undo stack.
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
QgsVectorDataProvider * dataProvider()
Returns the data provider.
QString providerType() const
Return the provider type for this layer.
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
This is the base class for vector data providers.
QgsFeatureMap mAddedFeatures
New features which are not commited.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void updateFields(QgsFields &fields)
void layerModified()
This signal is emitted when modifications has been done on layer.
Represents a vector layer which manages a vector based data sets.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
field is calculated from an expression
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QgsAttributeList mDeletedAttributeIds
Deleted attributes fields which are not commited.
Allows modification of attribute values.
virtual bool changeGeometry(QgsFeatureId fid, QgsGeometry *geom)
Change feature's geometry.
void featureDeleted(QgsFeatureId fid)
void push(QUndoCommand *cmd)
Supports renaming attributes (fields).
friend class QgsVectorLayerUndoCommandChangeAttribute
const T value(const Key &key) const
int remove(const Key &key)