mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00:00
LibGUI: Properly handle range selections in ColumnsView
Previously we would always select the left most column when selecting a range of rows. This patch fixes this issue by always applying a selection to the column in which the selection ends.
This commit is contained in:
parent
30d68d71b4
commit
2d681279d4
2 changed files with 16 additions and 0 deletions
|
@ -234,6 +234,20 @@ ModelIndex ColumnsView::index_at_event_position(Gfx::IntPoint const& a_position)
|
|||
return {};
|
||||
}
|
||||
|
||||
void ColumnsView::select_range(ModelIndex const& index)
|
||||
{
|
||||
auto min_row = min(selection_start_index().row(), index.row());
|
||||
auto max_row = max(selection_start_index().row(), index.row());
|
||||
auto parent = index.parent();
|
||||
|
||||
clear_selection();
|
||||
for (auto row = min_row; row <= max_row; ++row) {
|
||||
auto new_index = model()->index(row, m_model_column, parent);
|
||||
if (new_index.is_valid())
|
||||
toggle_selection(new_index);
|
||||
}
|
||||
}
|
||||
|
||||
void ColumnsView::mousedown_event(MouseEvent& event)
|
||||
{
|
||||
AbstractView::mousedown_event(event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue