mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-05 17:45:32 +00:00
added add nested command
This commit is contained in:
parent
7b5bf637ab
commit
d73f4cbd7b
2 changed files with 43 additions and 0 deletions
|
@ -211,3 +211,27 @@ void CSMWorld::DeleteNestedCommand::undo()
|
||||||
{
|
{
|
||||||
//TODO
|
//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();
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue