From 49a062f81d8e943e64a142f3f1f0fe955ebcf470 Mon Sep 17 00:00:00 2001 From: Federico Guerinoni Date: Thu, 25 Mar 2021 22:01:29 +0100 Subject: LibGUI: Show human readable size in filemanager The size is visible only in TableView mode of the filemanager. --- Userland/Applications/FileManager/DirectoryView.cpp | 6 ++---- Userland/Libraries/LibGUI/FileSystemModel.cpp | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index d5972146d8..3e1f57d229 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -413,10 +413,8 @@ void DirectoryView::update_statusbar() size_t selected_byte_count = 0; current_view().selection().for_each_index([&](auto& index) { - auto& model = *current_view().model(); - auto size_index = model.index(index.row(), GUI::FileSystemModel::Column::Size, model.parent_index(index)); - auto file_size = size_index.data().to_i32(); - selected_byte_count += file_size; + const auto& node = this->node(index); + selected_byte_count += node.size; }); StringBuilder builder; diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp index b04c4cb70d..330daa0fe2 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.cpp +++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include @@ -439,7 +440,7 @@ Variant FileSystemModel::data(const ModelIndex& index, ModelRole role) const case Column::Name: return node.name; case Column::Size: - return (int)node.size; + return human_readable_size(node.size); case Column::Owner: return name_for_uid(node.uid); case Column::Group: -- cgit v1.2.3