diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -287,7 +287,7 @@ // User visible roles available with Baloo: CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole, WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, - OriginUrlRole, + BitrateRole, OriginUrlRole, // Non-visible roles: IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole, // Mandatory last entry: diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -2314,6 +2314,7 @@ { "genre", GenreRole, I18N_NOOP2_NOSTRIP("@label", "Genre"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, { "album", AlbumRole, I18N_NOOP2_NOSTRIP("@label", "Album"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, { "duration", DurationRole, I18N_NOOP2_NOSTRIP("@label", "Duration"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "bitrate", BitrateRole, I18N_NOOP2_NOSTRIP("@label", "Bitrate"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, { "track", TrackRole, I18N_NOOP2_NOSTRIP("@label", "Track"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, { "path", PathRole, I18N_NOOP2_NOSTRIP("@label", "Path"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, { "deletiontime",DeletionTimeRole,I18N_NOOP2_NOSTRIP("@label", "Deletion Time"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, diff --git a/src/kitemviews/private/kbaloorolesprovider.h b/src/kitemviews/private/kbaloorolesprovider.h --- a/src/kitemviews/private/kbaloorolesprovider.h +++ b/src/kitemviews/private/kbaloorolesprovider.h @@ -79,6 +79,12 @@ */ QString durationFromValue(int value) const; + /** + * @return Bitrate in the format N kB/s for the value given + * in b/s. + */ + QString bitrateFromValue(int value) const; + private: QSet m_roles; QHash m_roleForProperty; diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -95,6 +96,9 @@ } else if (role == "duration") { const QString duration = durationFromValue(value.toInt()); values.insert(role, duration); + } else if (role == "bitrate") { + const QString bitrate = bitrateFromValue(value.toInt()); + values.insert(role, bitrate); } else { values.insert(role, value.toString()); } @@ -149,6 +153,7 @@ { "genre", "genre" }, { "album", "album" }, { "duration", "duration" }, + { "bitRate", "bitrate" }, { "trackNumber", "track" }, { "originUrl", "originUrl" } }; @@ -193,3 +198,11 @@ return duration.toString(QStringLiteral("hh:mm:ss")); } + +QString KBalooRolesProvider::bitrateFromValue(int value) const +{ + KFormat form; + QString bitrate = i18nc("@label bitrate (per second)", "%1/s", form.formatByteSize(value, 1, KFormat::MetricBinaryDialect)); + return bitrate; +} +