From a54a1b994013a03633e2e04b479452dc6c59cea3 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Tue, 17 Apr 2018 17:11:43 +0300 Subject: [PATCH] Command system and undo --- .../opencs/view/render/terraintexturemode.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index 1c331f1ec..8933b5038 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -199,8 +199,8 @@ void CSVRender::TerrainTextureMode::primaryEditPressed(const WorldspaceHitResult CSMDoc::Document& document = getWorldspaceWidget().getDocument(); CSMWorld::IdTable& landTable = dynamic_cast ( *document.getData().getTableModel (CSMWorld::UniversalId::Type_Land)); - /*CSMWorld::IdTable& ltexTable = dynamic_cast ( -*document.getData().getTableModel (CSMWorld::UniversalId::Type_LandTextures));*/ + CSMWorld::IdTable& ltexTable = dynamic_cast ( +*document.getData().getTableModel (CSMWorld::UniversalId::Type_LandTextures)); int textureColumn = landTable.findColumnIndex(CSMWorld::Columns::ColumnId_LandTexturesIndex); CSMWorld::LandTexturesColumn::DataType mPointer = landTable.data(landTable.getModelIndex(cellId, textureColumn)).value(); @@ -245,20 +245,16 @@ void CSVRender::TerrainTextureMode::primaryEditPressed(const WorldspaceHitResult // Not implemented } - // Modify data, this should be done via command system! QVariant variant; variant.setValue(mNew); - landTable.setData(landTable.getModelIndex(cellId, textureColumn), variant); - // Reference - /*CSMWorld::ModifyLandTexturesCommand::ModifyLandTexturesCommand(IdTable& landTable, - IdTable& ltexTable, QUndoCommand* parent)*/ + CSMWorld::CommandMacro macro (document.getUndoStack(), "Edit texture records"); + QModelIndex index(landTable.getModelIndex (cellId, landTable.findColumnIndex (CSMWorld::Columns::ColumnId_LandTexturesIndex))); - // Reference - /*CSMWorld::DeleteCommand* command = new CSMWorld::DeleteCommand(referencesTable, - static_cast(iter->get())->mObject->getReferenceId()); - - getWorldspaceWidget().getDocument().getUndoStack().push(command);*/ + CSMWorld::TouchLandCommand* ltexTouch = new CSMWorld::TouchLandCommand(landTable, ltexTable, cellId); + CSMWorld::ModifyCommand* ltexModify = new CSMWorld::ModifyCommand(landTable, index, variant); + macro.push (ltexTouch); + macro.push (ltexModify); } void CSVRender::TerrainTextureMode::primarySelectPressed(const WorldspaceHitResult& hit)