Skip to content
Permalink
Browse files

Added infrastructure for vector editing undo/redo functionality.

Note - when implementing edit tools for vector layer:
All editation should be done between beginEditCommand() and endEditCommand()
calls so that the operation are stored. 

Note - when doing changes inside QgsVectorLayer code:
When doing any changes inside QgsVectorLayer they should be done using edit*() functions
and _not_ directly e.g. mChangedGeometries[fid] = (...) otherwise the change won't be
stored in the undo stack and it would lead to invalid behaviour of undo.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10920 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jun 14, 2009
1 parent d88e175 commit 915637188056a0572c09dafed0b456204ef06c38
@@ -249,6 +249,9 @@ public:
*/
virtual QString saveNamedStyle( const QString theURI, bool & theResultFlag );

/** Return pointer to layer's undo stack */
QUndoStack* undoStack();

public slots:

/** Event handler for when a coordinate transform fails due to bad vertex error */
@@ -389,6 +389,25 @@ public:
*/
QgsVectorOverlay* findOverlayByType( const QString& typeName );


/**
* Create edit command for undo/redo operations
* @param text text which is to be displayed in undo window
*/
void beginEditCommand(QString text);

/** Finish edit command and add it to undo/redo stack */
void endEditCommand();

/** Destroy active command and deletes all changes in it */
void destroyEditCommand();

/** Execute undo operation. To be called only from QgsVectorLayerUndoCommand. */
// (not necessary) void undoEditCommand(QgsUndoCommand* cmd);

/** Execute redo operation. To be called only from QgsVectorLayerUndoCommand. */
// (not necessary) void redoEditCommand(QgsUndoCommand* cmd);

public slots:

/** Select feature by its ID, optionally emit signal selectionChanged() */
@@ -51,6 +51,7 @@ SET(QGIS_CORE_SRCS
qgsvectordataprovider.cpp
qgsvectorfilewriter.cpp
qgsvectorlayer.cpp
qgsvectorlayerundocommand.cpp
qgsvectoroverlay.cpp

composer/qgscomposeritem.cpp
@@ -715,3 +715,11 @@ QString QgsMapLayer::saveNamedStyle( const QString theURI, bool & theResultFlag

return myErrorMessage;
}




QUndoStack* QgsMapLayer::undoStack()
{
return &mUndoStack;
}
@@ -23,6 +23,7 @@
#include <map>

#include <QObject>
#include <QUndoStack>

#include "qgsrectangle.h"

@@ -259,6 +260,9 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
virtual bool writeSymbology( QDomNode&, QDomDocument& doc, QString& errorMessage ) const = 0;

/** Return pointer to layer's undo stack */
QUndoStack* undoStack();

public slots:

/** Event handler for when a coordinate transform fails due to bad vertex error */
@@ -356,6 +360,8 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** A flag that tells us whether to use the above vars to restrict layer visibility */
bool mScaleBasedVisibility;

QUndoStack mUndoStack;

};

#endif

0 comments on commit 9156371

Please sign in to comment.
You can’t perform that action at this time.