1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 20:15:07 +00:00

LibGUI: Allow override the font on a per-index basis in GListView

This should be ported to all of the GAbstractView subclasses.
This commit is contained in:
Andreas Kling 2019-10-22 21:38:04 +02:00
parent b89f64cb55
commit 31b5047894
4 changed files with 21 additions and 2 deletions

View file

@ -108,3 +108,18 @@ void GAbstractView::notify_selection_changed(Badge<GModelSelection>)
on_selection_change();
update();
}
NonnullRefPtr<Font> GAbstractView::font_for_index(const GModelIndex& index) const
{
if (!model())
return font();
auto font_data = model()->data(index, GModel::Role::Font);
if (font_data.is_font())
return font_data.as_font();
auto column_metadata = model()->column_metadata(index.column());
if (column_metadata.font)
return *column_metadata.font;
return font();
}