summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/AbstractView.cpp
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-11-07 23:14:21 +0330
committerAndreas Kling <kling@serenityos.org>2020-11-08 21:46:13 +0100
commit6d1e47e7dd1741aec64dd93a4d95ff1854e3abab (patch)
treed69b6ece9a552535db9d842e9b10b56928c505d5 /Libraries/LibGUI/AbstractView.cpp
parentc930e026240c2c255b77ad8b2322aeea9ab92ea3 (diff)
downloadserenity-6d1e47e7dd1741aec64dd93a4d95ff1854e3abab.zip
LibGUI+WindowServer: Make DragOperation hold a MimeData instance
...instead of maybe bitmap + a single mime type and its corresponding data. This allows drag&drop operations to hold multiple different kinds of data, and the views/applications to choose between those. For instance, Spreadsheet can keep the structure of the dragged cells, and still provide text-only data to be passed to different unrelated editors.
Diffstat (limited to 'Libraries/LibGUI/AbstractView.cpp')
-rw-r--r--Libraries/LibGUI/AbstractView.cpp28
1 files changed, 1 insertions, 27 deletions
diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp
index fe80611d61..4303e50513 100644
--- a/Libraries/LibGUI/AbstractView.cpp
+++ b/Libraries/LibGUI/AbstractView.cpp
@@ -291,33 +291,7 @@ void AbstractView::mousemove_event(MouseEvent& event)
dbg() << "Initiate drag!";
auto drag_operation = DragOperation::construct();
- RefPtr<Gfx::Bitmap> bitmap;
-
- StringBuilder text_builder;
- StringBuilder data_builder;
- bool first = true;
- m_selection.for_each_index([&](auto& index) {
- auto text_data = index.data();
- if (!first)
- text_builder.append(", ");
- text_builder.append(text_data.to_string());
-
- auto drag_data = index.data(ModelRole::DragData);
- data_builder.append(drag_data.to_string());
- data_builder.append('\n');
-
- first = false;
-
- if (!bitmap) {
- Variant icon_data = index.data(ModelRole::Icon);
- if (icon_data.is_icon())
- bitmap = icon_data.as_icon().bitmap_for_size(32);
- }
- });
-
- drag_operation->set_text(text_builder.to_string());
- drag_operation->set_bitmap(bitmap);
- drag_operation->set_data(data_type, data_builder.to_string());
+ drag_operation->set_mime_data(m_model->mime_data(m_selection));
auto outcome = drag_operation->exec();