| 3847 | } |
| 3848 | |
| 3849 | void 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 | |
| 3889 | void MapEditorController::renameMapPart() |
| 3890 | { |
nothing calls this directly
no test coverage detected