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:
parent
8a7d2c3336
commit
2f2a705a8e
3 changed files with 13 additions and 8 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue