mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Add Bitrate to Dolphin's Additional Information
Summary: Adds Bitrate to Dolphin's Additional information columns. BUG: 368418 Test Plan: Tested in KDE Neon. A bitrate column can be added and shows the bitrate in kb/s: {F3907210} Works for audio as well as video files! Reviewers: #dolphin, #kde_applications, broulik, aacid, dfaure, emmanuelp Reviewed By: #dolphin, #kde_applications, emmanuelp Subscribers: rkflx, alexeymin, anthonyfieroni Tags: #dolphin Differential Revision: https://phabricator.kde.org/D7763
This commit is contained in:
parent
3749b55527
commit
76698ff82c
|
@ -2314,6 +2314,7 @@ const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
|
||||||
{ "genre", GenreRole, I18N_NOOP2_NOSTRIP("@label", "Genre"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true },
|
{ "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 },
|
{ "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 },
|
{ "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 },
|
{ "track", TrackRole, I18N_NOOP2_NOSTRIP("@label", "Track"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true },
|
||||||
{ "releaseYear", ReleaseYearRole, I18N_NOOP2_NOSTRIP("@label", "Release Year"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true },
|
{ "releaseYear", ReleaseYearRole, I18N_NOOP2_NOSTRIP("@label", "Release Year"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true },
|
||||||
{ "path", PathRole, I18N_NOOP2_NOSTRIP("@label", "Path"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false },
|
{ "path", PathRole, I18N_NOOP2_NOSTRIP("@label", "Path"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false },
|
||||||
|
|
|
@ -287,7 +287,7 @@ private:
|
||||||
// User visible roles available with Baloo:
|
// User visible roles available with Baloo:
|
||||||
CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole,
|
CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole,
|
||||||
WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
|
WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
|
||||||
OriginUrlRole,
|
BitrateRole, OriginUrlRole,
|
||||||
// Non-visible roles:
|
// Non-visible roles:
|
||||||
IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole,
|
IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole,
|
||||||
// Mandatory last entry:
|
// Mandatory last entry:
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <Baloo/File>
|
#include <Baloo/File>
|
||||||
#include <KFileMetaData/PropertyInfo>
|
#include <KFileMetaData/PropertyInfo>
|
||||||
#include <KFileMetaData/UserMetaData>
|
#include <KFileMetaData/UserMetaData>
|
||||||
|
#include <KFormat>
|
||||||
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
@ -95,6 +96,9 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
|
||||||
} else if (role == "duration") {
|
} else if (role == "duration") {
|
||||||
const QString duration = durationFromValue(value.toInt());
|
const QString duration = durationFromValue(value.toInt());
|
||||||
values.insert(role, duration);
|
values.insert(role, duration);
|
||||||
|
} else if (role == "bitrate") {
|
||||||
|
const QString bitrate = bitrateFromValue(value.toInt());
|
||||||
|
values.insert(role, bitrate);
|
||||||
} else {
|
} else {
|
||||||
values.insert(role, value.toString());
|
values.insert(role, value.toString());
|
||||||
}
|
}
|
||||||
|
@ -149,6 +153,7 @@ KBalooRolesProvider::KBalooRolesProvider() :
|
||||||
{ "genre", "genre" },
|
{ "genre", "genre" },
|
||||||
{ "album", "album" },
|
{ "album", "album" },
|
||||||
{ "duration", "duration" },
|
{ "duration", "duration" },
|
||||||
|
{ "bitRate", "bitrate" },
|
||||||
{ "releaseYear", "releaseYear" },
|
{ "releaseYear", "releaseYear" },
|
||||||
{ "trackNumber", "track" },
|
{ "trackNumber", "track" },
|
||||||
{ "originUrl", "originUrl" }
|
{ "originUrl", "originUrl" }
|
||||||
|
@ -194,3 +199,11 @@ QString KBalooRolesProvider::durationFromValue(int value) const
|
||||||
return duration.toString(QStringLiteral("hh:mm:ss"));
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,12 @@ private:
|
||||||
*/
|
*/
|
||||||
QString durationFromValue(int value) const;
|
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:
|
private:
|
||||||
QSet<QByteArray> m_roles;
|
QSet<QByteArray> m_roles;
|
||||||
QHash<QString, QByteArray> m_roleForProperty;
|
QHash<QString, QByteArray> m_roleForProperty;
|
||||||
|
|
Loading…
Reference in a new issue