mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
* [FEATURE] adds undo/redo for transaction groups [needs-docs] the undo/redo now works with transcation groups. Just check that there is no restriction in the transaction groups doc concerning undo. related to #14799 The undo/redo is implemented using SAVEPOINT. The QgsTransaction interface has been enlarged to allow savepoints creation and management. The savepoint is destroyed on rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO SAVEPPOINT. To avoid the creation of a savepoint for each feature modified in bulk editing (e.g. paste, field calculator) the logic is a bit complicated: the savepoint is created on QgsVectorLayer::editCommandStarted and the first actual undo command (QgsVectorLayerUndoPassthroughCommand) is responsible for the re-creation of the savepoint in case of undo-redo. Since the behavior must be different in case edition doesn't take place inside an edit command, a member function has been added to QgsVectorLayer to expose the mEditCommandActive state. Another (commented) tricky bit is the modification of the database structure on add/delete attributes. On undo, the attribute is removed before the rollback to savepoint, i.e. there is a useless ALTER TABLE issued to restore the structure just before restoring it with the ROLLBACK TO SAVEPOINT. This is necessary to make the provider aware of the change of structure. It could be nicer/cleaner to have a way to reload providers metadata. The editPaste function has also been modified to use addFeatures instead of addFeature (plural/singular), this is at the expense of an additional "cpy" of the clipboard in memory, but it should improve perf with postgis provider. * fixup operator aliases
231 lines
5.8 KiB
Plaintext
231 lines
5.8 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/qgsvectorlayerundocommand.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgsVectorLayerUndoCommand : QUndoCommand
|
|
{
|
|
%Docstring
|
|
Base class for undo commands within a QgsVectorLayerEditBuffer.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsvectorlayerundocommand.h"
|
|
%End
|
|
public:
|
|
|
|
QgsVectorLayerUndoCommand( QgsVectorLayerEditBuffer *buffer /Transfer/ );
|
|
%Docstring
|
|
Constructor for QgsVectorLayerUndoCommand
|
|
\param buffer associated edit buffer
|
|
%End
|
|
|
|
QgsVectorLayer *layer();
|
|
%Docstring
|
|
Returns the layer associated with the undo command
|
|
:rtype: QgsVectorLayer
|
|
%End
|
|
|
|
virtual int id() const;
|
|
virtual bool mergeWith( const QUndoCommand * );
|
|
|
|
protected:
|
|
};
|
|
|
|
|
|
|
|
class QgsVectorLayerUndoCommandAddFeature : QgsVectorLayerUndoCommand
|
|
{
|
|
%Docstring
|
|
Undo command for adding a feature to a vector layer.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsvectorlayerundocommand.h"
|
|
%End
|
|
public:
|
|
|
|
QgsVectorLayerUndoCommandAddFeature( QgsVectorLayerEditBuffer *buffer /Transfer/, QgsFeature &f );
|
|
%Docstring
|
|
Constructor for QgsVectorLayerUndoCommandAddFeature
|
|
\param buffer associated edit buffer
|
|
\param f feature to add to layer
|
|
%End
|
|
|
|
virtual void undo();
|
|
virtual void redo();
|
|
|
|
};
|
|
|
|
|
|
|
|
class QgsVectorLayerUndoCommandDeleteFeature : QgsVectorLayerUndoCommand
|
|
{
|
|
%Docstring
|
|
Undo command for deleting a feature from a vector layer.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsvectorlayerundocommand.h"
|
|
%End
|
|
public:
|
|
|
|
QgsVectorLayerUndoCommandDeleteFeature( QgsVectorLayerEditBuffer *buffer /Transfer/, QgsFeatureId fid );
|
|
%Docstring
|
|
Constructor for QgsVectorLayerUndoCommandDeleteFeature
|
|
\param buffer associated edit buffer
|
|
\param fid feature ID of feature to delete from layer
|
|
%End
|
|
|
|
virtual void undo();
|
|
virtual void redo();
|
|
|
|
};
|
|
|
|
|
|
class QgsVectorLayerUndoCommandChangeGeometry : QgsVectorLayerUndoCommand
|
|
{
|
|
%Docstring
|
|
Undo command for modifying the geometry of a feature from a vector layer.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsvectorlayerundocommand.h"
|
|
%End
|
|
public:
|
|
|
|
QgsVectorLayerUndoCommandChangeGeometry( QgsVectorLayerEditBuffer *buffer /Transfer/, QgsFeatureId fid, const QgsGeometry &newGeom );
|
|
%Docstring
|
|
Constructor for QgsVectorLayerUndoCommandChangeGeometry
|
|
\param buffer associated edit buffer
|
|
\param fid feature ID of feature to modify geometry of
|
|
\param newGeom new geometry for feature
|
|
%End
|
|
|
|
virtual void undo();
|
|
virtual void redo();
|
|
virtual int id() const;
|
|
virtual bool mergeWith( const QUndoCommand * );
|
|
|
|
};
|
|
|
|
|
|
|
|
class QgsVectorLayerUndoCommandChangeAttribute : QgsVectorLayerUndoCommand
|
|
{
|
|
%Docstring
|
|
Undo command for modifying an attribute of a feature from a vector layer.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsvectorlayerundocommand.h"
|
|
%End
|
|
public:
|
|
|
|
QgsVectorLayerUndoCommandChangeAttribute( QgsVectorLayerEditBuffer *buffer /Transfer/, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue );
|
|
%Docstring
|
|
Constructor for QgsVectorLayerUndoCommandChangeAttribute
|
|
\param buffer associated edit buffer
|
|
\param fid feature ID of feature to modify
|
|
\param fieldIndex index of field to modify
|
|
\param newValue new value of attribute
|
|
\param oldValue previous value of attribute
|
|
%End
|
|
virtual void undo();
|
|
virtual void redo();
|
|
|
|
};
|
|
|
|
|
|
class QgsVectorLayerUndoCommandAddAttribute : QgsVectorLayerUndoCommand
|
|
{
|
|
%Docstring
|
|
Undo command for adding a new attribute to a vector layer.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsvectorlayerundocommand.h"
|
|
%End
|
|
public:
|
|
|
|
QgsVectorLayerUndoCommandAddAttribute( QgsVectorLayerEditBuffer *buffer /Transfer/, const QgsField &field );
|
|
%Docstring
|
|
Constructor for QgsVectorLayerUndoCommandAddAttribute
|
|
\param buffer associated edit buffer
|
|
\param field definition of new field to add
|
|
%End
|
|
|
|
virtual void undo();
|
|
virtual void redo();
|
|
|
|
};
|
|
|
|
|
|
class QgsVectorLayerUndoCommandDeleteAttribute : QgsVectorLayerUndoCommand
|
|
{
|
|
%Docstring
|
|
Undo command for removing an existing attribute from a vector layer.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsvectorlayerundocommand.h"
|
|
%End
|
|
public:
|
|
|
|
QgsVectorLayerUndoCommandDeleteAttribute( QgsVectorLayerEditBuffer *buffer /Transfer/, int fieldIndex );
|
|
%Docstring
|
|
Constructor for QgsVectorLayerUndoCommandDeleteAttribute
|
|
\param buffer associated edit buffer
|
|
\param fieldIndex index of field to delete
|
|
%End
|
|
|
|
virtual void undo();
|
|
virtual void redo();
|
|
|
|
};
|
|
|
|
|
|
|
|
class QgsVectorLayerUndoCommandRenameAttribute : QgsVectorLayerUndoCommand
|
|
{
|
|
%Docstring
|
|
Undo command for renaming an existing attribute of a vector layer.
|
|
.. versionadded:: 2.16
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsvectorlayerundocommand.h"
|
|
%End
|
|
public:
|
|
|
|
QgsVectorLayerUndoCommandRenameAttribute( QgsVectorLayerEditBuffer *buffer /Transfer/, int fieldIndex, const QString &newName );
|
|
%Docstring
|
|
Constructor for QgsVectorLayerUndoCommandRenameAttribute
|
|
\param buffer associated edit buffer
|
|
\param fieldIndex index of field to rename
|
|
\param newName new name for field
|
|
%End
|
|
|
|
virtual void undo();
|
|
virtual void redo();
|
|
|
|
};
|
|
|
|
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/qgsvectorlayerundocommand.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|