mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
Spreadsheet: Implement undo functionality where missing
Implement undo/redo functionality in the Spreadsheet application for the "extend" function, the drag-and-drop function, and when copying and pasting.
This commit is contained in:
parent
22575c9370
commit
356eca7e33
5 changed files with 28 additions and 9 deletions
|
@ -193,7 +193,8 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|||
return;
|
||||
|
||||
auto first_position = source_positions.take_first();
|
||||
sheet.copy_cells(move(source_positions), move(target_positions), first_position, action == "cut" ? Spreadsheet::Sheet::CopyOperation::Cut : Spreadsheet::Sheet::CopyOperation::Copy);
|
||||
auto cell_changes = sheet.copy_cells(move(source_positions), move(target_positions), first_position, action == "cut" ? Spreadsheet::Sheet::CopyOperation::Cut : Spreadsheet::Sheet::CopyOperation::Copy);
|
||||
undo_stack().push(make<CellsUndoCommand>(cell_changes));
|
||||
} else {
|
||||
for (auto& cell : sheet.selected_cells())
|
||||
sheet.ensure(cell).set_data(StringView { data.data.data(), data.data.size() });
|
||||
|
@ -284,6 +285,10 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
|||
undo_stack().push(make<CellsUndoCommand>(cell, previous_data));
|
||||
window()->set_modified(true);
|
||||
};
|
||||
new_view.model()->on_cells_data_change = [&](Vector<CellChange> cell_changes) {
|
||||
undo_stack().push(make<CellsUndoCommand>(cell_changes));
|
||||
window()->set_modified(true);
|
||||
};
|
||||
new_view.on_selection_changed = [&](Vector<Position>&& selection) {
|
||||
auto* sheet_ptr = current_worksheet_if_available();
|
||||
// How did this even happen?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue