mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
added add nested command
This commit is contained in:
parent
7b5bf637ab
commit
d73f4cbd7b
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user