From b2fe5915900c0435354fa3920f5c1ca845936a3d Mon Sep 17 00:00:00 2001 From: unelsson Date: Thu, 12 Aug 2021 15:24:00 +0300 Subject: [PATCH] Don't do any storing in the constructor --- apps/opencs/model/world/commands.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index a8410b1304..cdb4663390 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -190,10 +190,14 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI const QVariant& new_, QUndoCommand* parent) : QUndoCommand (parent), mModel (&model), mIndex (index), mNew (new_), mHasRecordState(false), mOldRecordState(CSMWorld::RecordBase::State_BaseOnly) { - if (QAbstractProxyModel *proxy = dynamic_cast (&model)) +} + +void CSMWorld::ModifyCommand::redo() +{ + if (QAbstractProxyModel *proxy = dynamic_cast (mModel)) { // Replace proxy with actual model - mIndex = proxy->mapToSource (index); + mIndex = proxy->mapToSource (mIndex); mModel = proxy->sourceModel(); } @@ -223,10 +227,7 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI mRecordStateIndex = table->index(rowIndex, stateColumnIndex); mOldRecordState = static_cast(table->data(mRecordStateIndex).toInt()); } -} -void CSMWorld::ModifyCommand::redo() -{ mOld = mModel->data (mIndex, Qt::EditRole); mModel->setData (mIndex, mNew); }