Mapper  0.9.0
API documentation
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OpenOrienteering::UndoStep Class Referenceabstract

Abstract base class for map editing undo steps. More...

#include <undo.h>

Inheritance diagram for OpenOrienteering::UndoStep:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::UndoStep:
Collaboration graph
[legend]

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...
 
UndoStepoperator= (const UndoStep &)=delete
 
UndoStepoperator= (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 UndoStepundo ()=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 UndoStepgetUndoStepForType (Type type, Map *map)
 Constructs an undo step of the given type. More...
 
static UndoStepload (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...
 

Detailed Description

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.

See also
UndoManager

Member Typedef Documentation

◆ ObjectSet

A set of pointers to objects.

◆ PartSet

typedef std::set<int> OpenOrienteering::UndoStep::PartSet

A set of integers referring to parts.

Member Enumeration Documentation

◆ Type

Types of undo steps for identification.

This is used by the file formats - do not change existing values.

Enumerator
ReplaceObjectsUndoStepType 
DeleteObjectsUndoStepType 
AddObjectsUndoStepType 
SwitchSymbolUndoStepType 
SwitchDashesUndoStepType 
CombinedUndoStepType 
ValidNoOpUndoStepType 
ObjectTagsUndoStepType 
MapPartUndoStepType 
SwitchPartUndoStepTypeV0 
SwitchPartUndoStepType 
InvalidUndoStepType 

Constructor & Destructor Documentation

◆ UndoStep() [1/3]

OpenOrienteering::UndoStep::UndoStep ( Type  type,
Map map 
)

Constructs an undo step having the given type.

◆ UndoStep() [2/3]

OpenOrienteering::UndoStep::UndoStep ( const UndoStep )
delete

◆ UndoStep() [3/3]

OpenOrienteering::UndoStep::UndoStep ( UndoStep &&  )
delete

◆ ~UndoStep()

OpenOrienteering::UndoStep::~UndoStep ( )
virtual

Destructor.

Member Function Documentation

◆ getModifiedObjects()

void OpenOrienteering::UndoStep::getModifiedObjects ( int  part_index,
ObjectSet out 
) const
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.

◆ getModifiedParts()

bool OpenOrienteering::UndoStep::getModifiedParts ( PartSet out) const
virtual

Adds the list of the step's modified parts to the container provided by out.

The default implementation does nothing and returns false.

Returns
True if there are parts (and objects!) modified by this undo step, false otherwise.

Reimplemented in OpenOrienteering::SwitchPartUndoStep, OpenOrienteering::DeleteObjectsUndoStep, OpenOrienteering::CombinedUndoStep, OpenOrienteering::ObjectModifyingUndoStep, and OpenOrienteering::MapPartUndoStep.

◆ getType()

UndoStep::Type OpenOrienteering::UndoStep::getType ( ) const
inline

Returns the type of the undo step.

◆ getUndoStepForType()

UndoStep * OpenOrienteering::UndoStep::getUndoStepForType ( Type  type,
Map map 
)
static

Constructs an undo step of the given type.

◆ isValid()

bool OpenOrienteering::UndoStep::isValid ( ) const
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.

◆ load()

UndoStep * OpenOrienteering::UndoStep::load ( QXmlStreamReader xml,
Map map,
SymbolDictionary symbol_dict 
)
static

Loads the undo step from the stream in xml format.

◆ loadImpl()

void OpenOrienteering::UndoStep::loadImpl ( QXmlStreamReader xml,
SymbolDictionary symbol_dict 
)
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.

◆ operator=() [1/2]

UndoStep& OpenOrienteering::UndoStep::operator= ( const UndoStep )
delete

◆ operator=() [2/2]

UndoStep& OpenOrienteering::UndoStep::operator= ( UndoStep &&  )
delete

◆ save()

void OpenOrienteering::UndoStep::save ( QXmlStreamWriter xml) const

Saves the undo step to the stream in xml format.

This method is not to be overwritten.

See also
saveImpl()

◆ saveImpl()

void OpenOrienteering::UndoStep::saveImpl ( QXmlStreamWriter xml) const
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.

◆ undo()

virtual UndoStep* OpenOrienteering::UndoStep::undo ( )
pure virtual

Member Data Documentation

◆ map

Map* const OpenOrienteering::UndoStep::map
protected

The map this undo step belongs.

◆ type

Type const OpenOrienteering::UndoStep::type
protected

The type of the undo step.


The documentation for this class was generated from the following files: