Allow non-empty mOriginalCell (case where a moved ref is moved again)

test
cc9cii 10 years ago
parent b54e5714c9
commit 889749a493

@ -238,8 +238,19 @@ void CSMDoc::CollectionReferencesStage::perform (int stage, Messages& messages)
mState.getSubRecords()[Misc::StringUtils::lowerCase (cellId)]; mState.getSubRecords()[Misc::StringUtils::lowerCase (cellId)];
// collect moved references at the end of the container // collect moved references at the end of the container
if (!record.get().mOriginalCell.empty() && bool interior = cellId.substr (0, 1)!="#";
record.get().mOriginalCell!=record.get().mCell) std::ostringstream stream;
if (!interior)
{
// recalculate the ref's cell location
std::pair<int, int> 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); indices.push_back (i);
else else
indices.push_front (i); 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 // 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. // the current cell. It is possible that a moved ref is moved again.
if ((ref.get().mOriginalCell.empty() ? ref.get().mCell : ref.get().mOriginalCell) if ((ref.get().mOriginalCell.empty() ? ref.get().mCell : ref.get().mOriginalCell)
!= stream.str()) != stream.str() && !interior)
{ {
ESM::MovedCellRef moved; ESM::MovedCellRef moved;
moved.mRefNum = ref.get().mRefNum; moved.mRefNum = ref.get().mRefNum;

@ -8,11 +8,10 @@
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QAbstractProxyModel> #include <QAbstractProxyModel>
#include "idtable.hpp"
#include "idtree.hpp" #include "idtree.hpp"
#include "nestedtablewrapper.hpp" #include "nestedtablewrapper.hpp"
#include "idtable.hpp"
CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index, CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index,
const QVariant& new_, QUndoCommand* parent) const QVariant& new_, QUndoCommand* parent)
: QUndoCommand (parent), mModel (&model), mIndex (index), mNew (new_) : QUndoCommand (parent), mModel (&model), mIndex (index), mNew (new_)
@ -227,10 +226,6 @@ void CSMWorld::UpdateCellCommand::undo()
} }
CSMWorld::DeleteNestedCommand::DeleteNestedCommand (IdTree& model, CSMWorld::DeleteNestedCommand::DeleteNestedCommand (IdTree& model,
const std::string& id, const std::string& id,
int nestedRow, int nestedRow,

@ -20,7 +20,6 @@ class QAbstractItemModel;
namespace CSMWorld namespace CSMWorld
{ {
class IdTable; class IdTable;
class RecordBase;
class IdTree; class IdTree;
struct RecordBase; struct RecordBase;
struct NestedTableWrapperBase; struct NestedTableWrapperBase;

Loading…
Cancel
Save