1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:37:35 +00:00

Spreadsheet: Cut instead of copy when dragging a cell's items

Use cut instead of copy when dragging one or many cells' contents.
This is more intuitive as most other spreadsheet applications
handle the drag in this manner instead of as a copy operation.
This commit is contained in:
martinfalisse 2022-02-08 15:41:09 +01:00 committed by Ali Mohammad Pur
parent 8a7d2c3336
commit 2f2a705a8e
3 changed files with 13 additions and 8 deletions

View file

@ -294,6 +294,10 @@ Position Sheet::offset_relative_to(const Position& base, const Position& offset,
void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Position> resolve_relative_to, CopyOperation copy_operation)
{
Vector<Position> target_cells;
for (auto& position : from)
target_cells.append(resolve_relative_to.has_value() ? offset_relative_to(to.first(), position, resolve_relative_to.value()) : to.first());
auto copy_to = [&](auto& source_position, Position target_position) {
auto& target_cell = ensure(target_position);
auto* source_cell = at(source_position);
@ -305,7 +309,8 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
target_cell.copy_from(*source_cell);
if (copy_operation == CopyOperation::Cut)
source_cell->set_data("");
if (!target_cells.contains_slow(source_position))
source_cell->set_data("");
};
if (from.size() == to.size()) {