MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / undo

Method undo

src/undo/map_part_undo.cpp:87–116  ·  view source on GitHub ↗

virtual

Source from the content-addressed store, hash-verified

85
86// virtual
87UndoStep* MapPartUndoStep::undo()
88{
89 UndoStep* redo_step = nullptr;
90 switch (change)
91 {
92 case AddMapPart:
93 Q_ASSERT(map->getNumParts()+1 > index);
94 map->addPart(new MapPart(name, map), index);
95 redo_step = new MapPartUndoStep(map, RemoveMapPart, index);
96 break;
97 case RemoveMapPart:
98 Q_ASSERT(map->getPart(index)->getNumObjects() == 0);
99 redo_step = new MapPartUndoStep(map, AddMapPart, index);
100 map->removePart(index);
101 break;
102 case ModifyMapPart:
103 Q_ASSERT(map->getNumParts() > index);
104 redo_step = new MapPartUndoStep(map, ModifyMapPart, index);
105 map->getPart(index)->setName(name);
106 break;
107 case UndefinedChange:
108 Q_ASSERT(false);
109 redo_step = new NoOpUndoStep(map, true);
110 break;
111 // default: nothing left (but watch compiler warnings).
112 }
113
114 Q_ASSERT(redo_step);
115 return redo_step;
116}
117
118// virtual
119bool MapPartUndoStep::getModifiedParts(PartSet &out) const

Callers

nothing calls this directly

Calls 6

addPartMethod · 0.80
removePartMethod · 0.80
getNumPartsMethod · 0.45
getNumObjectsMethod · 0.45
getPartMethod · 0.45
setNameMethod · 0.45

Tested by

no test coverage detected