mirror of
https://github.com/RGBCube/serenity
synced 2025-08-01 11:47: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:
parent
ebe38639bc
commit
2c772d1848
12 changed files with 36 additions and 25 deletions
|
@ -41,13 +41,15 @@ InspectorWidget::InspectorWidget()
|
|||
auto& top_tab_widget = splitter.add<GUI::TabWidget>();
|
||||
|
||||
m_dom_tree_view = top_tab_widget.add_tab<GUI::TreeView>("DOM");
|
||||
m_dom_tree_view->on_selection = [this](auto& index) {
|
||||
m_dom_tree_view->on_selection_change = [this] {
|
||||
const auto& index = m_dom_tree_view->selection().first();
|
||||
auto* node = static_cast<Web::DOM::Node*>(index.internal_data());
|
||||
set_inspected_node(node);
|
||||
};
|
||||
|
||||
m_layout_tree_view = top_tab_widget.add_tab<GUI::TreeView>("Layout");
|
||||
m_layout_tree_view->on_selection = [this](auto& index) {
|
||||
m_layout_tree_view->on_selection_change = [this] {
|
||||
const auto& index = m_layout_tree_view->selection().first();
|
||||
auto* node = static_cast<Web::Layout::Node*>(index.internal_data());
|
||||
set_inspected_node(node->dom_node());
|
||||
};
|
||||
|
|
|
@ -1049,7 +1049,8 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
}
|
||||
};
|
||||
|
||||
tree_view.on_selection = [&](const GUI::ModelIndex& index) {
|
||||
tree_view.on_selection_change = [&] {
|
||||
const auto& index = tree_view.selection().first();
|
||||
if (directories_model->m_previously_selected_index.is_valid())
|
||||
directories_model->update_node_on_selection(directories_model->m_previously_selected_index, false);
|
||||
|
||||
|
|
|
@ -179,24 +179,25 @@ int main(int argc, char* argv[])
|
|||
GUI::MessageBox::Type::Error);
|
||||
}
|
||||
};
|
||||
search_list_view.on_selection = [&](auto index) {
|
||||
search_list_view.on_selection_change = [&] {
|
||||
const auto& index = search_list_view.selection().first();
|
||||
if (!index.is_valid())
|
||||
return;
|
||||
|
||||
if (auto model = search_list_view.model()) {
|
||||
auto& search_model = *static_cast<GUI::FilteringProxyModel*>(model);
|
||||
index = search_model.map(index);
|
||||
} else {
|
||||
auto view_model = search_list_view.model();
|
||||
if (!view_model) {
|
||||
page_view.load_empty_document();
|
||||
return;
|
||||
}
|
||||
String path = model->page_path(index);
|
||||
auto& search_model = *static_cast<GUI::FilteringProxyModel*>(view_model);
|
||||
const auto& mapped_index = search_model.map(index);
|
||||
String path = model->page_path(mapped_index);
|
||||
if (path.is_null()) {
|
||||
page_view.load_empty_document();
|
||||
return;
|
||||
}
|
||||
tree_view.selection().clear();
|
||||
tree_view.selection().add(index);
|
||||
tree_view.selection().add(mapped_index);
|
||||
history.push(path);
|
||||
update_actions();
|
||||
open_page(path);
|
||||
|
|
|
@ -141,7 +141,8 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
|
|||
auto& type_list = left_side.add<GUI::ListView>();
|
||||
type_list.set_model(*GUI::ItemListModel<String>::create(g_types));
|
||||
type_list.set_should_hide_unnecessary_scrollbars(true);
|
||||
type_list.on_selection = [&](auto& index) {
|
||||
type_list.on_selection_change = [&] {
|
||||
const auto& index = type_list.selection().first();
|
||||
if (!index.is_valid()) {
|
||||
m_type = nullptr;
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue