From 32e5593ca9cab6c1e0a69b0693534c13715708ba Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 19 Jul 2023 14:05:41 +0100 Subject: [PATCH] SoundPlayer: Use AK::human_readable_size() for file sizes --- .../Applications/SoundPlayer/PlaylistWidget.cpp | 14 +------------- Userland/Applications/SoundPlayer/PlaylistWidget.h | 2 -- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/Userland/Applications/SoundPlayer/PlaylistWidget.cpp b/Userland/Applications/SoundPlayer/PlaylistWidget.cpp index 3a43ece1ce8..fa885144cdb 100644 --- a/Userland/Applications/SoundPlayer/PlaylistWidget.cpp +++ b/Userland/Applications/SoundPlayer/PlaylistWidget.cpp @@ -46,7 +46,7 @@ GUI::Variant PlaylistModel::data(const GUI::ModelIndex& index, GUI::ModelRole ro case 4: return m_playlist_items[index.row()].extended_info->album_artist.value_or(""); case 5: - return format_filesize(m_playlist_items[index.row()].extended_info->file_size_in_bytes.value_or(0)); + return human_readable_size(m_playlist_items[index.row()].extended_info->file_size_in_bytes.value_or(0)); } } if (role == GUI::ModelRole::Sort) @@ -57,18 +57,6 @@ GUI::Variant PlaylistModel::data(const GUI::ModelIndex& index, GUI::ModelRole ro return {}; } -DeprecatedString PlaylistModel::format_filesize(u64 size_in_bytes) -{ - if (size_in_bytes > GiB) - return DeprecatedString::formatted("{:.2f} GiB", (double)size_in_bytes / GiB); - else if (size_in_bytes > MiB) - return DeprecatedString::formatted("{:.2f} MiB", (double)size_in_bytes / MiB); - else if (size_in_bytes > KiB) - return DeprecatedString::formatted("{:.2f} KiB", (double)size_in_bytes / KiB); - else - return DeprecatedString::formatted("{} B", size_in_bytes); -} - ErrorOr PlaylistModel::column_name(int column) const { switch (column) { diff --git a/Userland/Applications/SoundPlayer/PlaylistWidget.h b/Userland/Applications/SoundPlayer/PlaylistWidget.h index 2bdf422ebe8..a86fb83d8a4 100644 --- a/Userland/Applications/SoundPlayer/PlaylistWidget.h +++ b/Userland/Applications/SoundPlayer/PlaylistWidget.h @@ -29,8 +29,6 @@ public: private: Vector m_playlist_items; - - static DeprecatedString format_filesize(u64 size_in_bytes); }; class PlaylistTableView : public GUI::TableView {