mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 17:45:11 +00:00
LibGUI: Make descendants of AbstractView define their own select_all() (#1201)
AbstractView does not know which column it's displaying which makes it impossible to implement the select_all functionality up there. Now descendants override the pure virtual select_all method and implement it themselves.
This commit is contained in:
parent
6824cb17a6
commit
8e1645423f
10 changed files with 54 additions and 14 deletions
|
@ -29,7 +29,6 @@
|
|||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/ScrollBar.h>
|
||||
#include <LibGfx/CharacterBitmap.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -59,6 +58,28 @@ ColumnsView::~ColumnsView()
|
|||
{
|
||||
}
|
||||
|
||||
void ColumnsView::select_all()
|
||||
{
|
||||
Vector<Column> columns_for_selection;
|
||||
selection().for_each_index([&](auto& index) {
|
||||
for (auto& column : m_columns) {
|
||||
if (column.parent_index == index.parent()) {
|
||||
columns_for_selection.append(column);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
});
|
||||
|
||||
for (Column& column : columns_for_selection) {
|
||||
int row_count = model()->row_count(column.parent_index);
|
||||
for (int row = 0; row < row_count; row++) {
|
||||
ModelIndex index = model()->index(row, m_model_column, column.parent_index);
|
||||
selection().add(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ColumnsView::paint_event(PaintEvent& event)
|
||||
{
|
||||
AbstractView::paint_event(event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue