1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 03:53:54 +00:00

added add nested command

This commit is contained in:
Marek Kochanowicz 2014-06-24 19:19:40 +02:00
parent 7b5bf637ab
commit d73f4cbd7b
2 changed files with 43 additions and 0 deletions

View file

@ -211,3 +211,27 @@ void CSMWorld::DeleteNestedCommand::undo()
{
//TODO
}
CSMWorld::AddNestedCommand::AddNestedCommand(IdTable& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent)
: mModel(model),
mId(id),
mNewRow(nestedRow),
mParentColumn(parentColumn),
QUndoCommand(parent)
{
setText (("Added nested row in " + mId).c_str());
}
void CSMWorld::AddNestedCommand::redo()
{
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
mModel.addNestedRow (parentIndex, mNewRow);
}
void CSMWorld::AddNestedCommand::undo()
{
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
mModel.removeRows(mNewRow, 1, parentIndex);
}

View file

@ -157,6 +157,25 @@ namespace CSMWorld
virtual void undo();
};
class AddNestedCommand : public QUndoCommand
{
IdTable& mModel;
std::string mId;
int mNewRow;
int mParentColumn;
public:
AddNestedCommand(IdTable& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent);
virtual void redo();
virtual void undo();
};
}
#endif