-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QgsVectorLayer: large internal refactoring
Most important changes: - introduced feature iterator for QgsVectorLayer - vector editing moved to QgsVectorEditBuffer - complete rework of undo/redo commands for vector layers - geometry cache separated from editing (QgsVectorLayerCache) - non-essential editing functionality moved to QgsVectorLayerEditUtils
- Loading branch information
Showing
50 changed files
with
4,082 additions
and
2,473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
|
||
|
||
class QgsVectorLayerEditBuffer : QObject | ||
{ | ||
%TypeHeaderCode | ||
#include "qgsvectorlayereditbuffer.h" | ||
%End | ||
|
||
public: | ||
QgsVectorLayerEditBuffer(QgsVectorLayer* layer); | ||
~QgsVectorLayerEditBuffer(); | ||
|
||
/** Returns true if the provider has been modified since the last commit */ | ||
bool isModified() const; | ||
|
||
|
||
/** Adds a feature | ||
@param f feature to add | ||
@param alsoUpdateExtent If True, will also go to the effort of e.g. updating the extents. | ||
@return True in case of success and False in case of error | ||
*/ | ||
bool addFeature( QgsFeature& f ); | ||
|
||
/** Insert a copy of the given features into the layer (but does not commit it) */ | ||
bool addFeatures( QgsFeatureList& features ); | ||
|
||
/** delete a feature from the layer (but does not commit it) */ | ||
bool deleteFeature( QgsFeatureId fid ); | ||
|
||
/** change feature's geometry | ||
@note added in version 1.2 */ | ||
bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom ); | ||
|
||
/** changed an attribute value (but does not commit it) */ | ||
bool changeAttributeValue( QgsFeatureId fid, int field, QVariant value ); | ||
|
||
/** add an attribute field (but does not commit it) | ||
returns true if the field was added | ||
@note added in version 1.2 */ | ||
bool addAttribute( const QgsField &field ); | ||
|
||
/** delete an attribute field (but does not commit it) */ | ||
bool deleteAttribute( int attr ); | ||
|
||
|
||
/** | ||
Attempts to commit any changes to disk. Returns the result of the attempt. | ||
If a commit fails, the in-memory changes are left alone. | ||
|
||
This allows editing to continue if the commit failed on e.g. a | ||
disallowed value in a Postgres database - the user can re-edit and try | ||
again. | ||
|
||
The commits occur in distinct stages, | ||
(add attributes, add features, change attribute values, change | ||
geometries, delete features, delete attributes) | ||
so if a stage fails, it's difficult to roll back cleanly. | ||
Therefore any error message also includes which stage failed so | ||
that the user has some chance of repairing the damage cleanly. | ||
*/ | ||
bool commitChanges(QStringList& commitErrors); | ||
|
||
/** Stop editing and discard the edits */ | ||
void rollBack(); | ||
|
||
|
||
/** New features which are not commited. */ | ||
const QgsFeatureList& addedFeatures(); | ||
|
||
/** Changed attributes values which are not commited */ | ||
const QgsChangedAttributesMap& changedAttributeValues(); | ||
|
||
/** deleted attributes fields which are not commited. The list is kept sorted. */ | ||
const QgsAttributeList& deletedAttributeIds(); | ||
|
||
/** added attributes fields which are not commited */ | ||
const QList<QgsField>& addedAttributes(); | ||
|
||
/** Changed geometries which are not commited. */ | ||
const QgsGeometryMap& changedGeometries(); | ||
|
||
//QString dumpEditBuffer(); | ||
|
||
signals: | ||
/** This signal is emitted when modifications has been done on layer */ | ||
void layerModified( bool onlyGeometry ); | ||
|
||
void featureAdded( QgsFeatureId fid ); | ||
void featureDeleted( QgsFeatureId fid ); | ||
void geometryChanged( QgsFeatureId fid, QgsGeometry &geom ); | ||
void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & ); | ||
void attributeAdded( int idx ); | ||
void attributeDeleted( int idx ); | ||
|
||
/** Signals emitted after committing changes | ||
\note added in v1.6 */ | ||
void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes ); | ||
void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes ); | ||
void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures ); | ||
void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds ); | ||
void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues ); | ||
void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries ); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.