From a0146e2e28cc58c409962c719f3047529327fa32 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 24 Jun 2014 19:34:02 +0200 Subject: [PATCH] Added undo for delete command --- apps/opencs/model/world/commands.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index 42a5a7f7e..012736697 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -209,7 +209,16 @@ void CSMWorld::DeleteNestedCommand::redo() void CSMWorld::DeleteNestedCommand::undo() { - //TODO + const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn); + + mModel.addNestedRow(parentIndex, mNestedRow); + + for (int i = 0; i < mModel.columnCount(parentIndex); ++i) + { + const QModelIndex& current = mModel.index(mNestedRow, i, parentIndex); + + mModel.setData(current, mOld[i]); + } } CSMWorld::AddNestedCommand::AddNestedCommand(IdTable& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent)