summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/ListView.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-16 16:14:39 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-16 16:44:09 +0200
commit9102b624ac6b83d4e4418fecefd491f67d4603f8 (patch)
tree31b52c008e1b69fa1465913451270d45868dc853 /Libraries/LibGUI/ListView.cpp
parent96f98b1fc92fec77d222c5b7b356b278c660429b (diff)
downloadserenity-9102b624ac6b83d4e4418fecefd491f67d4603f8.zip
LibGUI+DevTools+Applications: Use ModelIndex::data() in many places
This way you don't have to keep track of which model it came from.
Diffstat (limited to 'Libraries/LibGUI/ListView.cpp')
-rw-r--r--Libraries/LibGUI/ListView.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibGUI/ListView.cpp b/Libraries/LibGUI/ListView.cpp
index 73bea486f1..a4572f0e39 100644
--- a/Libraries/LibGUI/ListView.cpp
+++ b/Libraries/LibGUI/ListView.cpp
@@ -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), ModelRole::Display);
+ auto text = model()->index(row, m_model_column).data();
content_width = max(content_width, font().width(text.to_string()));
}
@@ -150,7 +150,7 @@ void ListView::paint_event(PaintEvent& event)
Gfx::IntRect row_rect(0, y, content_width(), item_height());
painter.fill_rect(row_rect, background_color);
auto index = model()->index(row_index, m_model_column);
- auto data = model()->data(index);
+ auto data = index.data();
auto font = font_for_index(index);
if (data.is_bitmap()) {
painter.blit(row_rect.location(), data.as_bitmap(), data.as_bitmap().rect());
@@ -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, ModelRole::ForegroundColor).to_color(palette().color(foreground_role()));
+ text_color = index.data(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, ModelRole::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterLeft);
+ auto text_alignment = index.data(ModelRole::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterLeft);
painter.draw_text(text_rect, data.to_string(), font, text_alignment, text_color);
}