From c941245cd03fdb07fba3318513812cbdfa500f3c Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Sun, 10 Dec 2023 11:12:06 -0600 Subject: [PATCH] Feat(CS): Add undo stack as a member of CSVRender::Cell --- apps/opencs/view/render/cell.cpp | 5 ++++- apps/opencs/view/render/cell.hpp | 6 +++++- apps/opencs/view/render/pagedworldspacewidget.cpp | 7 ++++--- apps/opencs/view/render/unpagedworldspacewidget.cpp | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index c0d3583d02..a67923ecf4 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -1,6 +1,7 @@ #include "cell.hpp" #include +#include #include #include @@ -171,8 +172,10 @@ void CSVRender::Cell::unloadLand() mCellBorder.reset(); } -CSVRender::Cell::Cell(CSMWorld::Data& data, osg::Group* rootNode, const std::string& id, bool deleted) +CSVRender::Cell::Cell( + CSMWorld::Data& data, QUndoStack& undoStack, osg::Group* rootNode, const std::string& id, bool deleted) : mData(data) + , mUndoStack(undoStack) , mId(ESM::RefId::stringRefId(id)) , mDeleted(deleted) , mSubMode(0) diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 5bfce47904..e0672fa350 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -9,6 +9,8 @@ #include #include +#include + #include "../../model/world/cellcoordinates.hpp" #include "instancedragmodes.hpp" #include @@ -46,6 +48,7 @@ namespace CSVRender class Cell { CSMWorld::Data& mData; + QUndoStack& mUndoStack; ESM::RefId mId; osg::ref_ptr mCellNode; std::map mObjects; @@ -89,7 +92,8 @@ namespace CSVRender public: /// \note Deleted covers both cells that are deleted and cells that don't exist in /// the first place. - Cell(CSMWorld::Data& data, osg::Group* rootNode, const std::string& id, bool deleted = false); + Cell(CSMWorld::Data& data, QUndoStack& undoStack, osg::Group* rootNode, const std::string& id, + bool deleted = false); ~Cell(); diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 062882bd04..c2b11c0247 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -86,8 +86,8 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells() { modified = true; - auto cell = std::make_unique( - mDocument.getData(), mRootNode, iter->first.getId(mWorldspace), deleted); + auto cell = std::make_unique(mDocument.getData(), mDocument.getUndoStack(), mRootNode, + iter->first.getId(mWorldspace), deleted); delete iter->second; iter->second = cell.release(); @@ -465,7 +465,8 @@ void CSVRender::PagedWorldspaceWidget::addCellToScene(const CSMWorld::CellCoordi bool deleted = index == -1 || cells.getRecord(index).mState == CSMWorld::RecordBase::State_Deleted; - auto cell = std::make_unique(mDocument.getData(), mRootNode, coordinates.getId(mWorldspace), deleted); + auto cell = std::make_unique( + mDocument.getData(), mDocument.getUndoStack(), mRootNode, coordinates.getId(mWorldspace), deleted); EditMode* editMode = getEditMode(); cell->setSubMode(editMode->getSubMode(), editMode->getInteractionMask()); diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index fee43b5de5..1a223ed41b 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -79,7 +79,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget( update(); - mCell = std::make_unique(document.getData(), mRootNode, mCellId); + mCell = std::make_unique(document.getData(), document.getUndoStack(), mRootNode, mCellId); } void CSVRender::UnpagedWorldspaceWidget::cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) @@ -127,7 +127,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop( mCellId = universalIdData.begin()->getId(); - mCell = std::make_unique(getDocument().getData(), mRootNode, mCellId); + mCell = std::make_unique(getDocument().getData(), getDocument().getUndoStack(), mRootNode, mCellId); mCamPositionSet = false; mOrbitCamControl->reset();