X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/97415005de040885cb63ea01fdb879e20226a2f2..ec12391a1b:/src/kitemviews/private/kbaloorolesprovider.cpp diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp index 9f151df92..3d3923b1b 100644 --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -20,15 +20,15 @@ #include "kbaloorolesprovider.h" -#include -#include - #include #include #include +#include +#include +#include +#include #include -#include struct KBalooRolesProviderSingleton { @@ -56,9 +56,6 @@ QHash KBalooRolesProvider::roleValues(const Baloo::File& f { QHash values; - int width = -1; - int height = -1; - QMapIterator it(file.properties()); while (it.hasNext()) { it.next(); @@ -72,28 +69,15 @@ QHash KBalooRolesProvider::roleValues(const Baloo::File& f const QVariant value = it.value(); - if (role == "imageSize") { - // Merge the two properties for width and height - // as one string into the "imageSize" role - if (property == QLatin1String("width")) { - width = value.toInt(); - } - else if (property == QLatin1String("height")) { - height = value.toInt(); - } - - if (width >= 0 && height >= 0) { - QString widthAndHeight = QString::number(width); - widthAndHeight += QLatin1String(" x "); - widthAndHeight += QString::number(height); - values.insert(role, widthAndHeight); - } - } else if (role == "orientation") { + if (role == "orientation") { const QString orientation = orientationFromValue(value.toInt()); values.insert(role, orientation); } 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()); } @@ -132,8 +116,7 @@ KBalooRolesProvider::KBalooRolesProvider() : }; // Mapping from the URIs to the KFileItemModel roles. Note that this must not be - // a 1:1 mapping: One role may contain several URI-values (e.g. the URIs for height and - // width of an image are mapped to the role "imageSize") + // a 1:1 mapping: One role may contain several URI-values static const PropertyInfo propertyInfoList[] = { { "rating", "rating" }, { "tag", "tags" }, @@ -141,12 +124,16 @@ KBalooRolesProvider::KBalooRolesProvider() : { "title", "title" }, { "wordCount", "wordCount" }, { "lineCount", "lineCount" }, - { "width", "imageSize" }, - { "height", "imageSize" }, + { "width", "width" }, + { "height", "height" }, + { "imageDateTime", "imageDateTime"}, { "nexif.orientation", "orientation", }, { "artist", "artist" }, + { "genre", "genre" }, { "album", "album" }, { "duration", "duration" }, + { "bitRate", "bitrate" }, + { "releaseYear", "releaseYear" }, { "trackNumber", "track" }, { "originUrl", "originUrl" } }; @@ -159,7 +146,11 @@ KBalooRolesProvider::KBalooRolesProvider() : QString KBalooRolesProvider::tagsFromValues(const QStringList& values) const { - return values.join(QStringLiteral(", ")); + QStringList alphabeticalOrderTags = values; + QCollator coll; + coll.setNumericMode(true); + std::sort(alphabeticalOrderTags.begin(), alphabeticalOrderTags.end(), [&](const QString& s1, const QString& s2){ return coll.compare(s1, s2) < 0; }); + return alphabeticalOrderTags.join(QStringLiteral(", ")); } QString KBalooRolesProvider::orientationFromValue(int value) const @@ -182,8 +173,16 @@ QString KBalooRolesProvider::orientationFromValue(int value) const QString KBalooRolesProvider::durationFromValue(int value) const { - QTime duration; + QTime duration(0, 0, 0); duration = duration.addSecs(value); 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; +} +