From 889749a4933b4b641320363cad2b007cfef17658 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 26 Apr 2015 15:44:40 +1000 Subject: [PATCH] Allow non-empty mOriginalCell (case where a moved ref is moved again) --- apps/opencs/model/doc/savingstages.cpp | 17 ++++++++++++++--- apps/opencs/model/world/commands.cpp | 7 +------ apps/opencs/model/world/commands.hpp | 1 - 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/doc/savingstages.cpp b/apps/opencs/model/doc/savingstages.cpp index 1f6da2580..7363f999e 100644 --- a/apps/opencs/model/doc/savingstages.cpp +++ b/apps/opencs/model/doc/savingstages.cpp @@ -238,8 +238,19 @@ void CSMDoc::CollectionReferencesStage::perform (int stage, Messages& messages) mState.getSubRecords()[Misc::StringUtils::lowerCase (cellId)]; // collect moved references at the end of the container - if (!record.get().mOriginalCell.empty() && - record.get().mOriginalCell!=record.get().mCell) + bool interior = cellId.substr (0, 1)!="#"; + std::ostringstream stream; + if (!interior) + { + // recalculate the ref's cell location + std::pair index = record.get().getCellIndex(); + stream << "#" << index.first << " " << index.second; + } + + // An empty mOriginalCell is meant to indicate that it is the same as + // the current cell. It is possible that a moved ref is moved again. + if ((record.get().mOriginalCell.empty() ? + record.get().mCell : record.get().mOriginalCell) != stream.str() && !interior) indices.push_back (i); else indices.push_front (i); @@ -314,7 +325,7 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages) // An empty mOriginalCell is meant to indicate that it is the same as // the current cell. It is possible that a moved ref is moved again. if ((ref.get().mOriginalCell.empty() ? ref.get().mCell : ref.get().mOriginalCell) - != stream.str()) + != stream.str() && !interior) { ESM::MovedCellRef moved; moved.mRefNum = ref.get().mRefNum; diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index afc4fcb96..4fe965148 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -8,11 +8,10 @@ #include #include +#include "idtable.hpp" #include "idtree.hpp" #include "nestedtablewrapper.hpp" -#include "idtable.hpp" - CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index, const QVariant& new_, QUndoCommand* parent) : QUndoCommand (parent), mModel (&model), mIndex (index), mNew (new_) @@ -227,10 +226,6 @@ void CSMWorld::UpdateCellCommand::undo() } - - - - CSMWorld::DeleteNestedCommand::DeleteNestedCommand (IdTree& model, const std::string& id, int nestedRow, diff --git a/apps/opencs/model/world/commands.hpp b/apps/opencs/model/world/commands.hpp index ca7c13fea..f3d2b852a 100644 --- a/apps/opencs/model/world/commands.hpp +++ b/apps/opencs/model/world/commands.hpp @@ -20,7 +20,6 @@ class QAbstractItemModel; namespace CSMWorld { class IdTable; - class RecordBase; class IdTree; struct RecordBase; struct NestedTableWrapperBase;