mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 06:18:12 +00:00
Spreadsheet: Add CellUndoMetadataCommand class
Enables the ability to undo changes in metadata without undoing chages in data. Previously there was only CellUndoData which cannot undo things such as changes in cell background color.
This commit is contained in:
parent
40725c7c8c
commit
7c204745ee
2 changed files with 30 additions and 0 deletions
|
@ -221,4 +221,23 @@ void CellsUndoCommand::redo()
|
|||
}
|
||||
}
|
||||
|
||||
CellsUndoMetadataCommand::CellsUndoMetadataCommand(Vector<CellChange> cell_changes)
|
||||
{
|
||||
m_cell_changes = move(cell_changes);
|
||||
}
|
||||
|
||||
void CellsUndoMetadataCommand::undo()
|
||||
{
|
||||
for (size_t i = 0; i < m_cell_changes.size(); ++i) {
|
||||
m_cell_changes[i].cell().set_type_metadata(m_cell_changes[i].previous_type_metadata());
|
||||
}
|
||||
}
|
||||
|
||||
void CellsUndoMetadataCommand::redo()
|
||||
{
|
||||
for (size_t i = 0; i < m_cell_changes.size(); ++i) {
|
||||
m_cell_changes[i].cell().set_type_metadata(m_cell_changes[i].new_type_metadata());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,4 +58,15 @@ private:
|
|||
Vector<CellChange> m_cell_changes;
|
||||
};
|
||||
|
||||
class CellsUndoMetadataCommand : public GUI::Command {
|
||||
public:
|
||||
CellsUndoMetadataCommand(Vector<CellChange>);
|
||||
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
|
||||
private:
|
||||
Vector<CellChange> m_cell_changes;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue