1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 17:48:12 +00:00

LibGUI: Move GUI::Model::Role to GUI::ModelRole

This is preparation for using ModelRole in the ModelIndex API.
This commit is contained in:
Andreas Kling 2020-08-16 16:00:07 +02:00
parent f6d7204689
commit a1e381a0f8
66 changed files with 201 additions and 167 deletions

View file

@ -59,7 +59,7 @@ void ListView::update_content_size()
int content_width = 0;
for (int row = 0, row_count = model()->row_count(); row < row_count; ++row) {
auto text = model()->data(model()->index(row, m_model_column), Model::Role::Display);
auto text = model()->data(model()->index(row, m_model_column), ModelRole::Display);
content_width = max(content_width, font().width(text.to_string()));
}
@ -162,11 +162,11 @@ void ListView::paint_event(PaintEvent& event)
if (is_selected_row)
text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text();
else
text_color = model()->data(index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role()));
text_color = model()->data(index, ModelRole::ForegroundColor).to_color(palette().color(foreground_role()));
auto text_rect = row_rect;
text_rect.move_by(horizontal_padding(), 0);
text_rect.set_width(text_rect.width() - horizontal_padding() * 2);
auto text_alignment = model()->data(index, Model::Role::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterLeft);
auto text_alignment = model()->data(index, ModelRole::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterLeft);
painter.draw_text(text_rect, data.to_string(), font, text_alignment, text_color);
}