diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-09 09:51:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-09 09:53:28 +0200 |
commit | a06548eaf7bbef50544ca31557a87ce45d94b4eb (patch) | |
tree | 81a95b213e65c3cb0d57dcba2f6c712ad811acf7 /Libraries/LibGUI/ModelSelection.cpp | |
parent | bdb6b2ced3f6abeb331207e0d859b48993ea147c (diff) | |
download | serenity-a06548eaf7bbef50544ca31557a87ce45d94b4eb.zip |
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.
Diffstat (limited to 'Libraries/LibGUI/ModelSelection.cpp')
-rw-r--r-- | Libraries/LibGUI/ModelSelection.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibGUI/ModelSelection.cpp b/Libraries/LibGUI/ModelSelection.cpp index 7bcec232cf..dbae384466 100644 --- a/Libraries/LibGUI/ModelSelection.cpp +++ b/Libraries/LibGUI/ModelSelection.cpp @@ -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()); |