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

LibGUI: Models should always specify font via Model::Role::Font

This gets rid of one field in ColumnData. The goal is to get rid of all
fields and lose ColumnData entirely.
This commit is contained in:
Andreas Kling 2020-05-21 18:56:52 +02:00
parent 57d15acd4c
commit 04187576ff
8 changed files with 23 additions and 26 deletions

View file

@ -75,6 +75,11 @@ public:
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override
{
if (role == Role::Font) {
if (index.column() == Column::MatchedText)
return Gfx::Font::default_fixed_width_font();
return {};
}
if (role == Role::Display) {
auto& match = m_matches.at(index.row());
switch (index.column()) {
@ -92,12 +97,12 @@ public:
virtual ColumnMetadata column_metadata(int column) const override
{
if (column == Column::MatchedText) {
return { 0, Gfx::TextAlignment::CenterLeft, &Gfx::Font::default_fixed_width_font() };
return { 0, Gfx::TextAlignment::CenterLeft };
}
return {};
}
virtual void update() override {}
virtual void update() override { }
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override { return create_index(row, column, &m_matches.at(row)); }
private: