1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

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
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_root_path(FileSystemPath(root_path).string())
, m_mode(mode) , 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(); update();
} }
@ -188,10 +191,10 @@ GVariant GFileSystemModel::data(const GModelIndex& index, Role role) const
if (role == GModel::Role::Icon) { if (role == GModel::Role::Icon) {
if (node.type == Node::Directory) { if (node.type == Node::Directory) {
if (selected_index() == index) if (selected_index() == index)
return GIcon::default_icon("filetype-folder-open"); return m_open_folder_icon;
return GIcon::default_icon("filetype-folder"); return m_closed_folder_icon;
} }
return GIcon::default_icon("filetype-unknown"); return m_file_icon;
} }
return { }; return { };
} }

View file

@ -33,4 +33,8 @@ private:
struct Node; struct Node;
Node* m_root { nullptr }; Node* m_root { nullptr };
GIcon m_open_folder_icon;
GIcon m_closed_folder_icon;
GIcon m_file_icon;
}; };