diff options
author | kleines Filmröllchen <filmroellchen@serenityos.org> | 2022-04-05 00:26:20 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-06 12:47:50 +0200 |
commit | cd5ed44f64297f10cdfa253354da7da508d8be06 (patch) | |
tree | c6f5ae16c4d19b0cdccc0afc9ec9690691a71875 /Userland/Libraries | |
parent | 0e71c6a7de2f0fffca390a5893875560e1dfb423 (diff) | |
download | serenity-cd5ed44f64297f10cdfa253354da7da508d8be06.zip |
LibGUI: Don't stringify non-textlike data in TreeView's tree column
This would previously cause silly things like [GUI::Icon] to appear if a
non-textlike column was used as the tree column (like, in this example,
an icon column). Let's just not write anything instead.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/TreeView.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/TreeView.cpp b/Userland/Libraries/LibGUI/TreeView.cpp index b5cc4a0978..9ee2e6da09 100644 --- a/Userland/Libraries/LibGUI/TreeView.cpp +++ b/Userland/Libraries/LibGUI/TreeView.cpp @@ -344,7 +344,9 @@ void TreeView::paint_event(PaintEvent& event) } } } - draw_item_text(painter, index, is_selected_row, text_rect, index.data().to_string(), font_for_index(index), Gfx::TextAlignment::CenterLeft, Gfx::TextElision::Right); + auto display_data = index.data(); + if (display_data.is_string() || display_data.is_u32() || display_data.is_i32() || display_data.is_u64() || display_data.is_i64() || display_data.is_bool() || display_data.is_float()) + draw_item_text(painter, index, is_selected_row, text_rect, display_data.to_string(), font_for_index(index), Gfx::TextAlignment::CenterLeft, Gfx::TextElision::Right); if (selection_behavior() == SelectionBehavior::SelectItems && is_focused() && index == cursor_index()) { painter.draw_rect(background_rect, palette().color(background_role())); |