summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/GItemView.cpp
diff options
context:
space:
mode:
authorDAlperin <DAlperin@users.noreply.github.com>2020-01-07 10:18:12 -0500
committerAndreas Kling <awesomekling@gmail.com>2020-01-07 16:18:12 +0100
commitdcc4704fb5ea46b84fcb677a492ca38cbd083ed4 (patch)
treec2f32bb59547ee387e1630b055ef9c25d8c64075 /Libraries/LibGUI/GItemView.cpp
parent5387a192689ba61b4cc5002be91fb6779534b8b2 (diff)
downloadserenity-dcc4704fb5ea46b84fcb677a492ca38cbd083ed4.zip
LibGUI: Preserve existing GItemView selection on rubber band (#1031)
Diffstat (limited to 'Libraries/LibGUI/GItemView.cpp')
-rw-r--r--Libraries/LibGUI/GItemView.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/Libraries/LibGUI/GItemView.cpp b/Libraries/LibGUI/GItemView.cpp
index d7b64c24b3..8064b6f7d1 100644
--- a/Libraries/LibGUI/GItemView.cpp
+++ b/Libraries/LibGUI/GItemView.cpp
@@ -116,7 +116,13 @@ void GItemView::mousedown_event(GMouseEvent& event)
if (event.button() == GMouseButton::Left) {
m_left_mousedown_position = event.position();
if (item_index == -1) {
- selection().clear();
+ if(event.modifiers() & Mod_Ctrl) {
+ selection().for_each_index([&](auto& index) {
+ m_rubber_band_remembered_selection.append(index);
+ });
+ } else {
+ selection().clear();
+ }
m_rubber_banding = true;
m_rubber_band_origin = event.position();
m_rubber_band_current = event.position();
@@ -136,6 +142,7 @@ void GItemView::mouseup_event(GMouseEvent& event)
{
if (m_rubber_banding && event.button() == GMouseButton::Left) {
m_rubber_banding = false;
+ m_rubber_band_remembered_selection.clear();
update();
return;
}
@@ -155,6 +162,11 @@ void GItemView::mousemove_event(GMouseEvent& event)
for (auto item_index : items_intersecting_rect(rubber_band_rect)) {
selection().add(model()->index(item_index, model_column()));
}
+ if(event.modifiers() & Mod_Ctrl) {
+ for (auto storeditem : m_rubber_band_remembered_selection) {
+ selection().add(storeditem);
+ }
+ }
update();
return;
}