summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-30 04:20:28 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-30 04:20:28 +0100
commit6ab55801e2334bf1df1819a1e7ee93d873745bcf (patch)
tree324c1ad0a5104e2f763fa8c4d67a333247033930
parent73f3e05ebb46d54f3aa1316742151170f5aef6f5 (diff)
downloadserenity-6ab55801e2334bf1df1819a1e7ee93d873745bcf.zip
GFileSystemModel: Don't reload icons every time they are requested.
This was really slugging up the interactive resizing. :^)
-rw-r--r--LibGUI/GFileSystemModel.cpp9
-rw-r--r--LibGUI/GFileSystemModel.h4
2 files changed, 10 insertions, 3 deletions
diff --git a/LibGUI/GFileSystemModel.cpp b/LibGUI/GFileSystemModel.cpp
index b7500df2fb..3b7d9c1213 100644
--- a/LibGUI/GFileSystemModel.cpp
+++ b/LibGUI/GFileSystemModel.cpp
@@ -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 { };
}
diff --git a/LibGUI/GFileSystemModel.h b/LibGUI/GFileSystemModel.h
index 1169f467de..f553bfbcad 100644
--- a/LibGUI/GFileSystemModel.h
+++ b/LibGUI/GFileSystemModel.h
@@ -33,4 +33,8 @@ private:
struct Node;
Node* m_root { nullptr };
+
+ GIcon m_open_folder_icon;
+ GIcon m_closed_folder_icon;
+ GIcon m_file_icon;
};