1
Fork 0
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:
huttongrabiel 2023-04-02 16:30:45 -07:00 committed by Sam Atkins
parent 40725c7c8c
commit 7c204745ee
2 changed files with 30 additions and 0 deletions

View file

@ -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());
}
}
}

View file

@ -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;
};
}