mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 17:55:06 +00:00
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.
This commit is contained in:
parent
207ecf454a
commit
f7116bba43
8 changed files with 31 additions and 25 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue