![]() |
Mapper
0.9.0
API documentation
|
Abstract base class for map editing undo steps. More...
#include <undo.h>
Public Types | |
enum | Type { ReplaceObjectsUndoStepType = 0, DeleteObjectsUndoStepType = 1, AddObjectsUndoStepType = 2, SwitchSymbolUndoStepType = 3, SwitchDashesUndoStepType = 4, CombinedUndoStepType = 5, ValidNoOpUndoStepType = 6, ObjectTagsUndoStepType = 7, MapPartUndoStepType = 8, SwitchPartUndoStepTypeV0 = 9, SwitchPartUndoStepType = 10, InvalidUndoStepType = 999 } |
Types of undo steps for identification. More... | |
typedef std::set< int > | PartSet |
A set of integers referring to parts. More... | |
typedef std::set< Object * > | ObjectSet |
A set of pointers to objects. More... | |
Public Member Functions | |
UndoStep (Type type, Map *map) | |
Constructs an undo step having the given type. More... | |
UndoStep (const UndoStep &)=delete | |
UndoStep (UndoStep &&)=delete | |
virtual | ~UndoStep () |
Destructor. More... | |
UndoStep & | operator= (const UndoStep &)=delete |
UndoStep & | operator= (UndoStep &&)=delete |
Type | getType () const |
Returns the type of the undo step. More... | |
virtual bool | isValid () const |
Returns true if the step can still be undone. More... | |
virtual UndoStep * | undo ()=0 |
Undoes the action and returns a new UndoStep. More... | |
virtual bool | getModifiedParts (PartSet &out) const |
Adds the list of the step's modified parts to the container provided by out. More... | |
virtual void | getModifiedObjects (int part_index, ObjectSet &out) const |
Adds the list of the step's modified objects to the container provided by out. More... | |
void | save (QXmlStreamWriter &xml) const |
Saves the undo step to the stream in xml format. More... | |
Static Public Member Functions | |
static UndoStep * | getUndoStepForType (Type type, Map *map) |
Constructs an undo step of the given type. More... | |
static UndoStep * | load (QXmlStreamReader &xml, Map *map, SymbolDictionary &symbol_dict) |
Loads the undo step from the stream in xml format. More... | |
Protected Member Functions | |
virtual void | saveImpl (QXmlStreamWriter &xml) const |
Saves undo properties to the the xml stream. More... | |
virtual void | loadImpl (QXmlStreamReader &xml, SymbolDictionary &symbol_dict) |
Loads undo properties from the the xml stream. More... | |
Protected Attributes | |
Type const | type |
The type of the undo step. More... | |
Map *const | map |
The map this undo step belongs. More... | |
Abstract base class for map editing undo steps.
UndoStep stores information which is necessary for executing an undo step. While executing the step, creates a new UndoStep for the corresponding redo step.
typedef std::set<Object*> OpenOrienteering::UndoStep::ObjectSet |
A set of pointers to objects.
typedef std::set<int> OpenOrienteering::UndoStep::PartSet |
A set of integers referring to parts.
Types of undo steps for identification.
This is used by the file formats - do not change existing values.
Constructs an undo step having the given type.
|
delete |
|
delete |
|
virtual |
Destructor.
|
virtual |
Adds the list of the step's modified objects to the container provided by out.
Only objects which belong to the given part are dealt with.
The default implementation does nothing.
Reimplemented in OpenOrienteering::SwitchPartUndoStep, OpenOrienteering::DeleteObjectsUndoStep, OpenOrienteering::CombinedUndoStep, OpenOrienteering::ObjectCreatingUndoStep, OpenOrienteering::ObjectModifyingUndoStep, and OpenOrienteering::MapPartUndoStep.
Adds the list of the step's modified parts to the container provided by out.
The default implementation does nothing and returns false.
Reimplemented in OpenOrienteering::SwitchPartUndoStep, OpenOrienteering::DeleteObjectsUndoStep, OpenOrienteering::CombinedUndoStep, OpenOrienteering::ObjectModifyingUndoStep, and OpenOrienteering::MapPartUndoStep.
|
inline |
Returns the type of the undo step.
Constructs an undo step of the given type.
|
virtual |
Returns true if the step can still be undone.
Initially (after generating the step) this must return true. (However, this is different for InvalidUndoStep.)
Derived classes may return false to indicate that the step is no longer valid. This may happen after an object the step depends on, which is not tracked by the undo system, is deleted.
Example: changing a map object's symbol to a different one, then deleting the first symbol. Then changing the symbol cannot be undone as the old symbol does not exist anymore.
Reimplemented in OpenOrienteering::SwitchSymbolUndoStep, OpenOrienteering::NoOpUndoStep, OpenOrienteering::CombinedUndoStep, OpenOrienteering::ObjectCreatingUndoStep, and OpenOrienteering::MapPartUndoStep.
|
static |
Loads the undo step from the stream in xml format.
|
protectedvirtual |
Loads undo properties from the the xml stream.
Implementations in derived classes shall first check the element's name for one of their own elements, and otherwise call the parent class' implementation.
Reimplemented in OpenOrienteering::SwitchSymbolUndoStep, OpenOrienteering::SwitchPartUndoStep, OpenOrienteering::CombinedUndoStep, OpenOrienteering::ObjectCreatingUndoStep, OpenOrienteering::ObjectModifyingUndoStep, and OpenOrienteering::MapPartUndoStep.
void OpenOrienteering::UndoStep::save | ( | QXmlStreamWriter & | xml | ) | const |
Saves the undo step to the stream in xml format.
This method is not to be overwritten.
|
protectedvirtual |
Saves undo properties to the the xml stream.
Implementations in derived classes shall first call the parent class' implementation, and then start a new element for additional properties.
Reimplemented in OpenOrienteering::SwitchSymbolUndoStep, OpenOrienteering::SwitchPartUndoStep, OpenOrienteering::CombinedUndoStep, OpenOrienteering::ObjectCreatingUndoStep, OpenOrienteering::ObjectModifyingUndoStep, and OpenOrienteering::MapPartUndoStep.
|
pure virtual |
Undoes the action and returns a new UndoStep.
The returned UndoStep can redo the action again.
Implemented in OpenOrienteering::ObjectTagsUndoStep, OpenOrienteering::SwitchDashesUndoStep, OpenOrienteering::SwitchSymbolUndoStep, OpenOrienteering::SwitchPartUndoStep, OpenOrienteering::NoOpUndoStep, OpenOrienteering::AddObjectsUndoStep, OpenOrienteering::DeleteObjectsUndoStep, OpenOrienteering::ReplaceObjectsUndoStep, OpenOrienteering::CombinedUndoStep, and OpenOrienteering::MapPartUndoStep.
|
protected |
The map this undo step belongs.
|
protected |
The type of the undo step.