forked from teamnwah/openmw-tes3coop
Merge remote-tracking branch 'smbas/master'
This commit is contained in:
commit
53b4c15d85
2 changed files with 18 additions and 1 deletions
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
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_), mHasRecordState(false)
|
||||||
{
|
{
|
||||||
if (QAbstractProxyModel *proxy = dynamic_cast<QAbstractProxyModel *> (&model))
|
if (QAbstractProxyModel *proxy = dynamic_cast<QAbstractProxyModel *> (&model))
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,15 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setText ("Modify " + mModel->headerData (mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString());
|
setText ("Modify " + mModel->headerData (mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString());
|
||||||
|
|
||||||
|
// Remember record state before the modification
|
||||||
|
if (CSMWorld::IdTable *table = dynamic_cast<IdTable *>(mModel))
|
||||||
|
{
|
||||||
|
mHasRecordState = true;
|
||||||
|
int stateColumnIndex = table->findColumnIndex(Columns::ColumnId_Modification);
|
||||||
|
mRecordStateIndex = table->index(mIndex.row(), stateColumnIndex);
|
||||||
|
mOldRecordState = static_cast<CSMWorld::RecordBase::State>(table->data(mRecordStateIndex).toInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::ModifyCommand::redo()
|
void CSMWorld::ModifyCommand::redo()
|
||||||
|
@ -38,6 +47,10 @@ void CSMWorld::ModifyCommand::redo()
|
||||||
void CSMWorld::ModifyCommand::undo()
|
void CSMWorld::ModifyCommand::undo()
|
||||||
{
|
{
|
||||||
mModel->setData (mIndex, mOld);
|
mModel->setData (mIndex, mOld);
|
||||||
|
if (mHasRecordState)
|
||||||
|
{
|
||||||
|
mModel->setData(mRecordStateIndex, mOldRecordState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,10 @@ namespace CSMWorld
|
||||||
QVariant mNew;
|
QVariant mNew;
|
||||||
QVariant mOld;
|
QVariant mOld;
|
||||||
|
|
||||||
|
bool mHasRecordState;
|
||||||
|
QModelIndex mRecordStateIndex;
|
||||||
|
CSMWorld::RecordBase::State mOldRecordState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ModifyCommand (QAbstractItemModel& model, const QModelIndex& index, const QVariant& new_,
|
ModifyCommand (QAbstractItemModel& model, const QModelIndex& index, const QVariant& new_,
|
||||||
|
|
Loading…
Reference in a new issue