1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

LibGUI/AbstractView: Remove on_selection

Since the introduction of multi-select, we have had both `on_selection`
and `on_selection_change`, the latter of which was only invoked when a
change in selection came in through the model.

This removes `AbstractView::on_selection` and replaces it usage with
the more explicit `on_selection_change` everywhere.
This commit is contained in:
Jelle Raaijmakers 2021-05-25 22:48:43 +02:00 committed by Ali Mohammad Pur
parent ebe38639bc
commit 2c772d1848
12 changed files with 36 additions and 25 deletions

View file

@ -19,7 +19,8 @@ ClassViewWidget::ClassViewWidget()
set_layout<GUI::VerticalBoxLayout>();
m_class_tree = add<GUI::TreeView>();
m_class_tree->on_selection = [this](auto& index) {
m_class_tree->on_selection_change = [this] {
const auto& index = m_class_tree->selection().first();
if (!index.is_valid())
return;

View file

@ -65,7 +65,8 @@ DebugInfoWidget::DebugInfoWidget()
variables_tab_widget.add_widget("Variables", build_variables_tab());
variables_tab_widget.add_widget("Registers", build_registers_tab());
m_backtrace_view->on_selection = [this](auto& index) {
m_backtrace_view->on_selection_change = [this] {
const auto& index = m_backtrace_view->selection().first();
auto& model = static_cast<BacktraceModel&>(*m_backtrace_view->model());
// Note: The reconstruction of the register set here is obviously incomplete.

View file

@ -44,7 +44,8 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
m_unstaged_files = unstaged.add<GitFilesView>(
[this](const auto& file) { stage_file(file); },
Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png").release_nonnull());
m_unstaged_files->on_selection = [this](const GUI::ModelIndex& index) {
m_unstaged_files->on_selection_change = [this] {
const auto& index = m_unstaged_files->selection().first();
const auto& selected = index.data().as_string();
show_diff(LexicalPath(selected));
};