mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
SoundPlayer: Use AK::human_readable_size() for file sizes
This commit is contained in:
parent
ca3e0288e9
commit
32e5593ca9
2 changed files with 1 additions and 15 deletions
|
@ -46,7 +46,7 @@ GUI::Variant PlaylistModel::data(const GUI::ModelIndex& index, GUI::ModelRole ro
|
||||||
case 4:
|
case 4:
|
||||||
return m_playlist_items[index.row()].extended_info->album_artist.value_or("");
|
return m_playlist_items[index.row()].extended_info->album_artist.value_or("");
|
||||||
case 5:
|
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)
|
if (role == GUI::ModelRole::Sort)
|
||||||
|
@ -57,18 +57,6 @@ GUI::Variant PlaylistModel::data(const GUI::ModelIndex& index, GUI::ModelRole ro
|
||||||
return {};
|
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<String> PlaylistModel::column_name(int column) const
|
ErrorOr<String> PlaylistModel::column_name(int column) const
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
|
|
|
@ -29,8 +29,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<M3UEntry> m_playlist_items;
|
Vector<M3UEntry> m_playlist_items;
|
||||||
|
|
||||||
static DeprecatedString format_filesize(u64 size_in_bytes);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlaylistTableView : public GUI::TableView {
|
class PlaylistTableView : public GUI::TableView {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue