mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +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:
parent
bdb6b2ced3
commit
a06548eaf7
Notes:
sideshowbarker
2024-07-19 07:47:19 +09:00
Author: https://github.com/awesomekling
Commit: a06548eaf7
3 changed files with 19 additions and 1 deletions
|
@ -60,10 +60,15 @@ void AbstractView::set_model(RefPtr<Model> model)
|
|||
|
||||
void AbstractView::did_update_model()
|
||||
{
|
||||
// FIXME: It's unfortunate that we lose so much view state when the model updates in any way.
|
||||
stop_editing();
|
||||
m_edit_index = {};
|
||||
m_hovered_index = {};
|
||||
selection().clear();
|
||||
if (model()) {
|
||||
selection().remove_matching([this](auto& index) { return !model()->is_valid(index); });
|
||||
} else {
|
||||
selection().clear();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractView::did_update_selection()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue