GFileSystemModel: Don't reload icons every time they are requested.

This was really slugging up the interactive resizing. :^)
This commit is contained in:
Andreas Kling 2019-03-30 04:20:28 +01:00
parent 73f3e05ebb
commit 6ab55801e2
Notes: sideshowbarker 2024-07-19 14:53:33 +09:00
2 changed files with 10 additions and 3 deletions

View file

@ -129,6 +129,9 @@ GFileSystemModel::GFileSystemModel(const String& root_path, Mode mode)
: m_root_path(FileSystemPath(root_path).string())
, m_mode(mode)
{
m_open_folder_icon = GIcon::default_icon("filetype-folder-open");
m_closed_folder_icon = GIcon::default_icon("filetype-folder");
m_file_icon = GIcon::default_icon("filetype-unknown");
update();
}
@ -188,10 +191,10 @@ GVariant GFileSystemModel::data(const GModelIndex& index, Role role) const
if (role == GModel::Role::Icon) {
if (node.type == Node::Directory) {
if (selected_index() == index)
return GIcon::default_icon("filetype-folder-open");
return GIcon::default_icon("filetype-folder");
return m_open_folder_icon;
return m_closed_folder_icon;
}
return GIcon::default_icon("filetype-unknown");
return m_file_icon;
}
return { };
}