1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 09:45:40 +00:00

Feat(CS): Add undo stack as a member of CSVRender::Cell

This commit is contained in:
Dave Corley 2023-12-10 11:12:06 -06:00
parent b5d118f5ee
commit c941245cd0
4 changed files with 15 additions and 7 deletions

View file

@ -1,6 +1,7 @@
#include "cell.hpp"
#include <algorithm>
#include <qundostack.h>
#include <set>
#include <utility>
@ -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)

View file

@ -9,6 +9,8 @@
#include <osg/Vec3d>
#include <osg/ref_ptr>
#include <QUndoStack>
#include "../../model/world/cellcoordinates.hpp"
#include "instancedragmodes.hpp"
#include <components/esm/refid.hpp>
@ -46,6 +48,7 @@ namespace CSVRender
class Cell
{
CSMWorld::Data& mData;
QUndoStack& mUndoStack;
ESM::RefId mId;
osg::ref_ptr<osg::Group> mCellNode;
std::map<std::string, Object*, Misc::StringUtils::CiComp> 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();

View file

@ -86,8 +86,8 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
{
modified = true;
auto cell = std::make_unique<Cell>(
mDocument.getData(), mRootNode, iter->first.getId(mWorldspace), deleted);
auto cell = std::make_unique<Cell>(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<Cell>(mDocument.getData(), mRootNode, coordinates.getId(mWorldspace), deleted);
auto cell = std::make_unique<Cell>(
mDocument.getData(), mDocument.getUndoStack(), mRootNode, coordinates.getId(mWorldspace), deleted);
EditMode* editMode = getEditMode();
cell->setSubMode(editMode->getSubMode(), editMode->getInteractionMask());

View file

@ -79,7 +79,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget(
update();
mCell = std::make_unique<Cell>(document.getData(), mRootNode, mCellId);
mCell = std::make_unique<Cell>(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<Cell>(getDocument().getData(), mRootNode, mCellId);
mCell = std::make_unique<Cell>(getDocument().getData(), getDocument().getUndoStack(), mRootNode, mCellId);
mCamPositionSet = false;
mOrbitCamControl->reset();