mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Restore Modified status of a record when adding/removing nested rows
This commit is contained in:
parent
25b653e316
commit
33042c1464
@ -192,6 +192,12 @@ namespace CSMWorld
|
|||||||
ColumnBase::Display_NestedHeader, flags)
|
ColumnBase::Display_NestedHeader, flags)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||||
|
{
|
||||||
|
// There is nothing to do here.
|
||||||
|
// This prevents exceptions from parent's implementation
|
||||||
|
}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
return true; // required by IdTree::hasChildren()
|
return true; // required by IdTree::hasChildren()
|
||||||
|
@ -289,21 +289,24 @@ CSMWorld::DeleteNestedCommand::DeleteNestedCommand (IdTree& model,
|
|||||||
std::string title =
|
std::string title =
|
||||||
model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData();
|
model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData();
|
||||||
setText (("Delete row in " + title + " sub-table of " + mId).c_str());
|
setText (("Delete row in " + title + " sub-table of " + mId).c_str());
|
||||||
|
|
||||||
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
mModifyParentCommand = new ModifyCommand(mModel, parentIndex, parentIndex.data(Qt::EditRole), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::DeleteNestedCommand::redo()
|
void CSMWorld::DeleteNestedCommand::redo()
|
||||||
{
|
{
|
||||||
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
|
||||||
mModel.removeRows (mNestedRow, 1, parentIndex);
|
mModel.removeRows (mNestedRow, 1, parentIndex);
|
||||||
|
mModifyParentCommand->redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSMWorld::DeleteNestedCommand::undo()
|
void CSMWorld::DeleteNestedCommand::undo()
|
||||||
{
|
{
|
||||||
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
|
||||||
mModel.setNestedTable(parentIndex, getOld());
|
mModel.setNestedTable(parentIndex, getOld());
|
||||||
|
mModifyParentCommand->undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::AddNestedCommand::AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent)
|
CSMWorld::AddNestedCommand::AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent)
|
||||||
@ -317,20 +320,23 @@ CSMWorld::AddNestedCommand::AddNestedCommand(IdTree& model, const std::string& i
|
|||||||
std::string title =
|
std::string title =
|
||||||
model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData();
|
model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData();
|
||||||
setText (("Add row in " + title + " sub-table of " + mId).c_str());
|
setText (("Add row in " + title + " sub-table of " + mId).c_str());
|
||||||
|
|
||||||
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
mModifyParentCommand = new ModifyCommand(mModel, parentIndex, parentIndex.data(Qt::EditRole), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::AddNestedCommand::redo()
|
void CSMWorld::AddNestedCommand::redo()
|
||||||
{
|
{
|
||||||
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
|
||||||
mModel.addNestedRow (parentIndex, mNewRow);
|
mModel.addNestedRow (parentIndex, mNewRow);
|
||||||
|
mModifyParentCommand->redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::AddNestedCommand::undo()
|
void CSMWorld::AddNestedCommand::undo()
|
||||||
{
|
{
|
||||||
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
|
||||||
mModel.setNestedTable(parentIndex, getOld());
|
mModel.setNestedTable(parentIndex, getOld());
|
||||||
|
mModifyParentCommand->undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::NestedTableStoring::NestedTableStoring(const IdTree& model, const std::string& id, int parentColumn)
|
CSMWorld::NestedTableStoring::NestedTableStoring(const IdTree& model, const std::string& id, int parentColumn)
|
||||||
|
@ -200,6 +200,9 @@ namespace CSMWorld
|
|||||||
|
|
||||||
int mNestedRow;
|
int mNestedRow;
|
||||||
|
|
||||||
|
// The command to redo/undo the Modified status of a record
|
||||||
|
ModifyCommand *mModifyParentCommand;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DeleteNestedCommand (IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0);
|
DeleteNestedCommand (IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0);
|
||||||
@ -219,6 +222,9 @@ namespace CSMWorld
|
|||||||
|
|
||||||
int mParentColumn;
|
int mParentColumn;
|
||||||
|
|
||||||
|
// The command to redo/undo the Modified status of a record
|
||||||
|
ModifyCommand *mModifyParentCommand;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0);
|
AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user