mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
LibGUI: Convert various little things to GModelSelection
All the little things that were using the per-model seletion are now moving over to GModelSelection.
This commit is contained in:
parent
d2d1a30d61
commit
fb18613e8a
3 changed files with 6 additions and 9 deletions
|
@ -31,16 +31,16 @@ void GAbstractView::set_model(RefPtr<GModel>&& model)
|
||||||
|
|
||||||
void GAbstractView::did_update_model()
|
void GAbstractView::did_update_model()
|
||||||
{
|
{
|
||||||
if (!model() || model()->selected_index() != m_edit_index)
|
if (!model() || selection().first() != m_edit_index)
|
||||||
stop_editing();
|
stop_editing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GAbstractView::did_update_selection()
|
void GAbstractView::did_update_selection()
|
||||||
{
|
{
|
||||||
if (!model() || model()->selected_index() != m_edit_index)
|
if (!model() || selection().first() != m_edit_index)
|
||||||
stop_editing();
|
stop_editing();
|
||||||
if (model() && on_selection && model()->selected_index().is_valid())
|
if (model() && on_selection && selection().first().is_valid())
|
||||||
on_selection(model()->selected_index());
|
on_selection(selection().first());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GAbstractView::did_scroll()
|
void GAbstractView::did_scroll()
|
||||||
|
|
|
@ -12,7 +12,7 @@ GComboBox::GComboBox(GWidget* parent)
|
||||||
m_editor = new GTextEditor(GTextEditor::Type::SingleLine, this);
|
m_editor = new GTextEditor(GTextEditor::Type::SingleLine, this);
|
||||||
m_editor->on_change = [this] {
|
m_editor->on_change = [this] {
|
||||||
if (on_change)
|
if (on_change)
|
||||||
on_change(m_editor->text(), model()->selected_index());
|
on_change(m_editor->text(), m_list_view->selection().first());
|
||||||
};
|
};
|
||||||
m_editor->on_return_pressed = [this] {
|
m_editor->on_return_pressed = [this] {
|
||||||
if (on_return_pressed)
|
if (on_return_pressed)
|
||||||
|
|
|
@ -194,11 +194,8 @@ GVariant GFileSystemModel::data(const GModelIndex& index, Role role) const
|
||||||
if (role == GModel::Role::Display)
|
if (role == GModel::Role::Display)
|
||||||
return node.name;
|
return node.name;
|
||||||
if (role == GModel::Role::Icon) {
|
if (role == GModel::Role::Icon) {
|
||||||
if (node.type == Node::Directory) {
|
if (node.type == Node::Directory)
|
||||||
if (selected_index() == index)
|
|
||||||
return m_open_folder_icon;
|
|
||||||
return m_closed_folder_icon;
|
return m_closed_folder_icon;
|
||||||
}
|
|
||||||
return m_file_icon;
|
return m_file_icon;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue