diff options
Diffstat (limited to 'Userland/Applications/Spreadsheet/SpreadsheetModel.cpp')
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetModel.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp index b190788b7a..e643f0cf95 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -165,4 +165,29 @@ void SheetModel::update() m_sheet->update(); did_update(UpdateFlag::DontInvalidateIndices); } + +CellsUndoCommand::CellsUndoCommand(Vector<CellChange> cell_changes) +{ + m_cell_changes = cell_changes; +} + +CellsUndoCommand::CellsUndoCommand(Cell& cell, String const& previous_data) +{ + m_cell_changes.append(CellChange(cell, previous_data)); +} + +void CellsUndoCommand::undo() +{ + for (size_t i = 0; i < m_cell_changes.size(); ++i) { + m_cell_changes[i].cell().set_data(m_cell_changes[i].previous_data()); + } +} + +void CellsUndoCommand::redo() +{ + for (size_t i = 0; i < m_cell_changes.size(); ++i) { + m_cell_changes[i].cell().set_data(m_cell_changes[i].new_data()); + } +} + } |