diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-12 12:03:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-12 12:03:33 +0200 |
commit | 8e4751a9632bc675aa9779e233f67614103d394b (patch) | |
tree | 0b35ebafca524ceeecda1429b2684eabcc4c7ef0 /Libraries/LibGUI/AbstractView.cpp | |
parent | 93f2a4edd37c0c7d85b6f7cb099fba9108b53f48 (diff) | |
download | serenity-8e4751a9632bc675aa9779e233f67614103d394b.zip |
LibGUI: Add a way for models to update without invalidating indexes
This is really just a workaround to keep SystemMonitor's process table
working right wrt selection retention during resorts (while also doing
full index invalidation on things like ProfileViewer inversion.)
It's starting to feel like the model abstraction is not super great
and we'll need a better approach if we want to actually build some more
dynamic functionality into our views.
Diffstat (limited to 'Libraries/LibGUI/AbstractView.cpp')
-rw-r--r-- | Libraries/LibGUI/AbstractView.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp index 114aa4253e..551b975148 100644 --- a/Libraries/LibGUI/AbstractView.cpp +++ b/Libraries/LibGUI/AbstractView.cpp @@ -55,19 +55,22 @@ void AbstractView::set_model(RefPtr<Model> model) m_model = move(model); if (m_model) m_model->register_view({}, *this); - did_update_model(); + did_update_model(GUI::Model::InvalidateAllIndexes); } -void AbstractView::did_update_model() +void AbstractView::did_update_model(unsigned flags) { // 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 = {}; - if (model()) { - selection().remove_matching([this](auto& index) { return !model()->is_valid(index); }); - } else { + + dbg() << "did_update_model, flags=" << flags; + dump_backtrace(); + if (!model() || (flags & GUI::Model::InvalidateAllIndexes)) { selection().clear(); + } else { + selection().remove_matching([this](auto& index) { return !model()->is_valid(index); }); } } |