summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/AbstractView.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-28 20:14:17 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-28 21:28:40 +0100
commitf7116bba43cc36d6b6f0916a783d4f807c13af20 (patch)
treee3d8a4c633446306759dcd40ff54f441393a3bf0 /Libraries/LibGUI/AbstractView.cpp
parent207ecf454a34728474ca75e25c251d2f88b5cc12 (diff)
downloadserenity-f7116bba43cc36d6b6f0916a783d4f807c13af20.zip
LibGUI: Refactor AbstractView "multi select" mode into "selection mode"
There are three possible selection modes for a GUI::AbstractView. - NoSelection - SingleSelection - MultiSelection We don't enforce these modes fully yet, this patch mostly adds them in place of the old "multi select" flag.
Diffstat (limited to 'Libraries/LibGUI/AbstractView.cpp')
-rw-r--r--Libraries/LibGUI/AbstractView.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp
index 53e01f8371..4bceeb3028 100644
--- a/Libraries/LibGUI/AbstractView.cpp
+++ b/Libraries/LibGUI/AbstractView.cpp
@@ -403,16 +403,21 @@ void AbstractView::drop_event(DropEvent& event)
on_drop(index, event);
}
-void AbstractView::set_multi_select(bool multi_select)
+void AbstractView::set_selection_mode(SelectionMode selection_mode)
{
- if (m_multi_select == multi_select)
+ if (m_selection_mode == selection_mode)
return;
- m_multi_select = multi_select;
- if (!multi_select && m_selection.size() > 1) {
+ m_selection_mode = selection_mode;
+
+ if (m_selection_mode == SelectionMode::NoSelection)
+ m_selection.clear();
+ else if (m_selection_mode != SelectionMode::SingleSelection && m_selection.size() > 1) {
auto first_selected = m_selection.first();
m_selection.clear();
m_selection.set(first_selected);
}
+
+ update();
}
void AbstractView::set_key_column_and_sort_order(int column, SortOrder sort_order)