mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
LibGUI: Keep still-valid indexes in selection after a model update
This is a stop-gap patch solution for the annoying problem of models being bad at updating. At least the process table will retain your selection in SystemMonitor now.
This commit is contained in:
@@ -31,6 +31,17 @@
|
||||
|
||||
namespace GUI {
|
||||
|
||||
void ModelSelection::remove_matching(Function<bool(const ModelIndex&)> filter)
|
||||
{
|
||||
Vector<ModelIndex> to_remove;
|
||||
for (auto& index : m_indexes) {
|
||||
if (filter(index))
|
||||
to_remove.append(index);
|
||||
}
|
||||
for (auto& index : to_remove)
|
||||
m_indexes.remove(index);
|
||||
}
|
||||
|
||||
void ModelSelection::set(const ModelIndex& index)
|
||||
{
|
||||
ASSERT(index.is_valid());
|
||||
|
||||
Reference in New Issue
Block a user