1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

Spreadsheet: Enable Drag&Drop and Copy/Paste

These currently only work on the current sheet, in the current
Spreadsheet instance, but they're still freakin' cool!
This commit is contained in:
AnotherTest 2020-11-02 20:21:07 +03:30 committed by Andreas Kling
parent 821e875bc0
commit 0e544b8afa
5 changed files with 123 additions and 0 deletions

View file

@ -26,6 +26,7 @@
#include "SpreadsheetModel.h"
#include "ConditionalFormatting.h"
#include <AK/URL.h>
#include <LibJS/Runtime/Error.h>
#include <LibJS/Runtime/Object.h>
@ -68,6 +69,12 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
return cell->typed_display();
}
if (role == GUI::ModelRole::DragData) {
// FIXME: It would be really nice if we could send out a URL *and* some extra data,
// The Event already has support for this, but the user-facing API does not.
return Position { m_sheet->column(index.column()), (size_t)index.row() }.to_url().to_string();
}
if (role == GUI::ModelRole::TextAlignment) {
const auto* cell = m_sheet->at({ m_sheet->column(index.column()), (size_t)index.row() });
if (!cell)