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

Method removeMapPart

src/gui/map/map_editor.cpp:3849–3887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3847}
3848
3849void MapEditorController::removeMapPart()
3850{
3851 auto* part = map->getCurrentPart();
3852
3853 QMessageBox::StandardButton button =
3854 QMessageBox::question(
3855 window,
3856 tr("Remove current part"),
3857 tr("Do you want to remove map part \"%1\" and all its objects?").arg(part->getName()),
3858 QMessageBox::Yes | QMessageBox::No );
3859
3860 if (button == QMessageBox::Yes)
3861 {
3862 auto index = map->getCurrentPartIndex();
3863 UndoStep* undo_step = new MapPartUndoStep(map, MapPartUndoStep::AddMapPart, index);
3864
3865 auto i = part->getNumObjects();
3866 if (i > 0)
3867 {
3868 auto* add_step = new AddObjectsUndoStep(map);
3869 do
3870 {
3871 --i;
3872 auto* object = part->getObject(i);
3873 add_step->addObject(i, object);
3874 part->releaseObject(object);
3875 }
3876 while (i > 0);
3877
3878 auto* combined_step = new CombinedUndoStep(map);
3879 combined_step->push(add_step);
3880 combined_step->push(undo_step);
3881 undo_step = combined_step;
3882 }
3883
3884 map->push(undo_step);
3885 map->removePart(index);
3886 }
3887}
3888
3889void MapEditorController::renameMapPart()
3890{

Callers

nothing calls this directly

Calls 8

getCurrentPartMethod · 0.80
getCurrentPartIndexMethod · 0.80
getObjectMethod · 0.80
removePartMethod · 0.80
getNumObjectsMethod · 0.45
addObjectMethod · 0.45
releaseObjectMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected