Quantum GIS API Documentation  1.7.4
Classes | Public Types | Public Member Functions | Private Attributes | Friends
QgsUndoCommand Class Reference

Class to support universal undo command sequence for application, basic for. More...

#include <qgsvectorlayerundocommand.h>

Collaboration diagram for QgsUndoCommand:
Collaboration graph
[legend]

List of all members.

Classes

class  AttributeChangeEntry
 change structure for attribute for undo/redo purpose More...
class  GeometryChangeEntry
 change structure to geometry for undo/redo purpose More...

Public Types

typedef QMap< int,
AttributeChangeEntry
AttributeChanges

Public Member Functions

 QgsUndoCommand (QgsVectorLayer *layer, QString text)
void undo ()
 Necessary function to provide undo operation.
void redo ()
 Necessary function to provide redo operation.
void storeGeometryChange (int featureId, QgsGeometry &original, QgsGeometry &target)
 Function to store changes in geometry to be returned to this state after undo/redo.
void storeAttributeChange (int featureId, int field, QVariant original, QVariant target, bool isFirstChange)
 Stores changes of attributes for the feature to be returned to this state after undo/redo.
void storeFeatureDelete (int featureId)
 Add id of feature to deleted list to be reverted if needed afterwards.
void storeFeatureAdd (QgsFeature &feature)
 Add new feature to list of new features to be stored for undo/redo operations.
void storeAttributeAdd (int index, const QgsField &value)
 Add new attribute to list of attributes to be used for attributes of features for undo/redo operations.
void storeAttributeDelete (int index, const QgsField &orig)
 Add deleted attribute which is to be stored for undo/redo operations.

Private Attributes

bool mFirstRun
 Variable to disable first run of undo, because it's automaticaly done after push.
QgsVectorLayermLayer
 Layer on which operations should be performed.
QMap< int, GeometryChangeEntrymGeometryChange
 Map of changes of geometry for features it describes changes of geometry.
QMap< int, AttributeChangesmAttributeChange
 Map of changes of atrributes for features which describes changes of attributes.
QgsFeatureIds mDeletedFeatureIdChange
 Deleted feature IDs which are not commited.
QgsFieldMap mAddedAttributes
 added attributes fields which are not commited
QgsFieldMap mDeletedAttributes
 deleted attributes fields which are not commited
QgsFeatureList mAddedFeatures
 New features which are not commited.

Friends

class QgsVectorLayer

Detailed Description

Class to support universal undo command sequence for application, basic for.

Definition at line 28 of file qgsvectorlayerundocommand.h.


Member Typedef Documentation

Definition at line 41 of file qgsvectorlayerundocommand.h.


Constructor & Destructor Documentation

QgsUndoCommand::QgsUndoCommand ( QgsVectorLayer layer,
QString  text 
)

Definition at line 46 of file qgsvectorlayerundocommand.cpp.

References mFirstRun, and mLayer.


Member Function Documentation

Necessary function to provide redo operation.

Definition at line 54 of file qgsvectorlayerundocommand.cpp.

References mFirstRun, mLayer, and QgsVectorLayer::redoEditCommand().

void QgsUndoCommand::storeAttributeAdd ( int  index,
const QgsField value 
)

Add new attribute to list of attributes to be used for attributes of features for undo/redo operations.

Parameters:
indexindex of attribute which is to be added
valuefield description which is to be stored

Definition at line 98 of file qgsvectorlayerundocommand.cpp.

References mAddedAttributes.

Referenced by QgsVectorLayer::addAttribute().

void QgsUndoCommand::storeAttributeChange ( int  featureId,
int  field,
QVariant  original,
QVariant  target,
bool  isFirstChange 
)

Stores changes of attributes for the feature to be returned to this state after undo/redo.

Parameters:
featureIdid of feature for which this chaged is stored
fieldfield identifier of field which was changed
originaloriginal value of attribute before change
targettarget value of attribute after change
isFirstChangeflag if this change is the first one

Definition at line 89 of file qgsvectorlayerundocommand.cpp.

References QgsUndoCommand::AttributeChangeEntry::isFirstChange, mAttributeChange, QgsUndoCommand::AttributeChangeEntry::original, and QgsUndoCommand::AttributeChangeEntry::target.

Referenced by QgsVectorLayer::editAttributeChange().

void QgsUndoCommand::storeAttributeDelete ( int  index,
const QgsField orig 
)

Add deleted attribute which is to be stored for undo/redo operations.

Parameters:
indexindex od attribute definition which is to be deleted
origdeleted field's description

Definition at line 103 of file qgsvectorlayerundocommand.cpp.

References mDeletedAttributes.

Referenced by QgsVectorLayer::deleteAttribute().

Add new feature to list of new features to be stored for undo/redo operations.

Parameters:
featurefeature which is to be added

Definition at line 113 of file qgsvectorlayerundocommand.cpp.

References mAddedFeatures.

Referenced by QgsVectorLayer::editFeatureAdd().

void QgsUndoCommand::storeFeatureDelete ( int  featureId)

Add id of feature to deleted list to be reverted if needed afterwards.

Parameters:
featureIdid of feature which is to be deleted

Definition at line 108 of file qgsvectorlayerundocommand.cpp.

References mDeletedFeatureIdChange.

Referenced by QgsVectorLayer::editFeatureDelete().

void QgsUndoCommand::storeGeometryChange ( int  featureId,
QgsGeometry original,
QgsGeometry target 
)

Function to store changes in geometry to be returned to this state after undo/redo.

Parameters:
featureIdid of feature edited
originaloriginal geometry of feature which was changed
targetchanged geometry which was changed

Definition at line 73 of file qgsvectorlayerundocommand.cpp.

References mGeometryChange.

Referenced by QgsVectorLayer::editGeometryChange().

Necessary function to provide undo operation.

Definition at line 67 of file qgsvectorlayerundocommand.cpp.

References mLayer, and QgsVectorLayer::undoEditCommand().


Friends And Related Function Documentation

friend class QgsVectorLayer [friend]

Definition at line 144 of file qgsvectorlayerundocommand.h.


Member Data Documentation

added attributes fields which are not commited

Definition at line 134 of file qgsvectorlayerundocommand.h.

Referenced by QgsVectorLayer::redoEditCommand(), storeAttributeAdd(), and QgsVectorLayer::undoEditCommand().

New features which are not commited.

Note a feature can be added and then changed, therefore the details here can be overridden by mChangedAttributeValues and mChangedGeometries.

Definition at line 142 of file qgsvectorlayerundocommand.h.

Referenced by QgsVectorLayer::redoEditCommand(), storeFeatureAdd(), and QgsVectorLayer::undoEditCommand().

Map of changes of atrributes for features which describes changes of attributes.

Definition at line 125 of file qgsvectorlayerundocommand.h.

Referenced by QgsVectorLayer::redoEditCommand(), storeAttributeChange(), and QgsVectorLayer::undoEditCommand().

deleted attributes fields which are not commited

Definition at line 137 of file qgsvectorlayerundocommand.h.

Referenced by QgsVectorLayer::redoEditCommand(), storeAttributeDelete(), and QgsVectorLayer::undoEditCommand().

Deleted feature IDs which are not commited.

Note a feature can be added and then deleted again before the change is committed - in that case the added feature would be removed from mAddedFeatures only and *not* entered here.

Definition at line 131 of file qgsvectorlayerundocommand.h.

Referenced by QgsVectorLayer::redoEditCommand(), storeFeatureDelete(), and QgsVectorLayer::undoEditCommand().

bool QgsUndoCommand::mFirstRun [private]

Variable to disable first run of undo, because it's automaticaly done after push.

Definition at line 116 of file qgsvectorlayerundocommand.h.

Referenced by QgsUndoCommand(), and redo().

Map of changes of geometry for features it describes changes of geometry.

Definition at line 122 of file qgsvectorlayerundocommand.h.

Referenced by QgsVectorLayer::redoEditCommand(), storeGeometryChange(), and QgsVectorLayer::undoEditCommand().

Layer on which operations should be performed.

Definition at line 119 of file qgsvectorlayerundocommand.h.

Referenced by QgsUndoCommand(), redo(), and undo().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines