mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +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
|
@ -110,8 +110,8 @@ void AbstractView::did_update_selection()
|
|||
{
|
||||
if (!model() || selection().first() != m_edit_index)
|
||||
stop_editing();
|
||||
if (model() && on_selection && selection().first().is_valid())
|
||||
on_selection(selection().first());
|
||||
if (model() && on_selection_change)
|
||||
on_selection_change();
|
||||
}
|
||||
|
||||
void AbstractView::did_scroll()
|
||||
|
@ -194,8 +194,6 @@ void AbstractView::activate_selected()
|
|||
void AbstractView::notify_selection_changed(Badge<ModelSelection>)
|
||||
{
|
||||
did_update_selection();
|
||||
if (on_selection_change)
|
||||
on_selection_change();
|
||||
if (!m_suppress_update_on_selection_change)
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ public:
|
|||
|
||||
Function<void()> on_selection_change;
|
||||
Function<void(const ModelIndex&)> on_activation;
|
||||
Function<void(const ModelIndex&)> on_selection;
|
||||
Function<void(const ModelIndex&, const ContextMenuEvent&)> on_context_menu_request;
|
||||
Function<void(const ModelIndex&, const DropEvent&)> on_drop;
|
||||
|
||||
|
|
|
@ -101,8 +101,9 @@ ComboBox::ComboBox()
|
|||
m_list_view->set_hover_highlighting(true);
|
||||
m_list_view->set_frame_thickness(1);
|
||||
m_list_view->set_frame_shadow(Gfx::FrameShadow::Plain);
|
||||
m_list_view->on_selection = [this](auto& index) {
|
||||
m_list_view->on_selection_change = [this] {
|
||||
VERIFY(model());
|
||||
const auto& index = m_list_view->selection().first();
|
||||
m_list_view->set_activates_on_selection(true);
|
||||
if (m_updating_model)
|
||||
selection_updated(index);
|
||||
|
|
|
@ -56,7 +56,8 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo
|
|||
});
|
||||
quick_sort(m_families);
|
||||
|
||||
m_family_list_view->on_selection = [this](auto& index) {
|
||||
m_family_list_view->on_selection_change = [this] {
|
||||
const auto& index = m_family_list_view->selection().first();
|
||||
m_family = index.data().to_string();
|
||||
m_weights.clear();
|
||||
Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) {
|
||||
|
@ -76,7 +77,8 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo
|
|||
update_font();
|
||||
};
|
||||
|
||||
m_weight_list_view->on_selection = [this](auto& index) {
|
||||
m_weight_list_view->on_selection_change = [this] {
|
||||
const auto& index = m_weight_list_view->selection().first();
|
||||
bool font_is_fixed_size = false;
|
||||
m_weight = index.data(ModelRole::Custom).to_i32();
|
||||
m_sizes.clear();
|
||||
|
@ -130,7 +132,8 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo
|
|||
update_font();
|
||||
};
|
||||
|
||||
m_size_list_view->on_selection = [this](auto& index) {
|
||||
m_size_list_view->on_selection_change = [this] {
|
||||
const auto& index = m_size_list_view->selection().first();
|
||||
m_size = index.data().to_i32();
|
||||
m_size_spin_box->set_value(m_size.value());
|
||||
update_font();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue