Commit be01acf1 authored by Jack Hill's avatar Jack Hill
Browse files

Add SI units to bit rate and sample rate

Format bit rate as "kbps" with no decimal places
Format sample rate as "kHz" with one decimal place

BUG: 447897
parent a07ba7c7
Pipeline #158946 passed with stage
in 3 minutes and 45 seconds
......@@ -14,6 +14,8 @@
#include <algorithm>
#include <KFormat>
TrackMetadataModel::TrackMetadataModel(QObject *parent)
: QAbstractListModel(parent)
{
......@@ -76,7 +78,8 @@ QVariant TrackMetadataModel::data(const QModelIndex &index, int role) const
{
auto bitRate = mTrackData.bitRate();
if (bitRate > 0) {
result = bitRate;
result = KFormat().formatValue(bitRate, QStringLiteral("bps"), 0,
KFormat::UnitPrefix::Kilo, KFormat::MetricBinaryDialect);
}
break;
}
......@@ -84,7 +87,8 @@ QVariant TrackMetadataModel::data(const QModelIndex &index, int role) const
{
auto sampleRate = mTrackData.sampleRate();
if (sampleRate > 0) {
result = sampleRate;
result = KFormat().formatValue(sampleRate, KFormat::Unit::Hertz, 1,
KFormat::UnitPrefix::Kilo, KFormat::MetricBinaryDialect);
}
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment