]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kbaloorolesprovider.cpp
Merge branch 'Applications/19.04'
[dolphin.git] / src / kitemviews / private / kbaloorolesprovider.cpp
index 6732d08ecb4de6cbc44e6a59c45d8e8ac86ac553..469f0791550a9a5d152a8f8a0c35a1e44bf74582 100644 (file)
@@ -56,9 +56,6 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
 {
     QHash<QByteArray, QVariant> values;
 
-    int width = -1;
-    int height = -1;
-
     QMapIterator<KFileMetaData::Property::Property, QVariant> it(file.properties());
     while (it.hasNext()) {
         it.next();
@@ -70,38 +67,7 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
             continue;
         }
 
-        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") {
-            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 if (pi.valueType() == QVariant::StringList) {
-            values.insert(role, value.toStringList().join(QStringLiteral(", ")));
-        } else {
-            values.insert(role, value.toString());
-        }
+        values.insert(role, pi.formatAsDisplayString(it.value()));
     }
 
     KFileMetaData::UserMetaData md(file.path());
@@ -137,8 +103,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" },
@@ -146,15 +111,17 @@ KBalooRolesProvider::KBalooRolesProvider() :
         { "title",         "title" },
         { "wordCount",     "wordCount" },
         { "lineCount",     "lineCount" },
-        { "width",         "imageSize" },
-        { "height",        "imageSize" },
+        { "width",         "width" },
+        { "height",        "height" },
         { "imageDateTime",   "imageDateTime"},
-        { "nexif.orientation", "orientation", },
+        { "imageOrientation", "orientation", },
         { "artist",     "artist" },
         { "genre",     "genre"  },
         { "album",    "album" },
         { "duration",      "duration" },
         { "bitRate", "bitrate" },
+        { "aspectRatio", "aspectRatio" },
+        { "frameRate", "frameRate" },
         { "releaseYear",    "releaseYear" },
         { "trackNumber",   "track" },
         { "originUrl", "originUrl" }
@@ -174,37 +141,3 @@ QString KBalooRolesProvider::tagsFromValues(const QStringList& values) const
     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
-{
-    QString string;
-    switch (value) {
-    case 1: string = i18nc("@item:intable Image orientation", "Unchanged"); break;
-    case 2: string = i18nc("@item:intable Image orientation", "Horizontally flipped"); break;
-    case 3: string = i18nc("@item:intable image orientation", "180° rotated"); break;
-    case 4: string = i18nc("@item:intable image orientation", "Vertically flipped"); break;
-    case 5: string = i18nc("@item:intable image orientation", "Transposed"); break;
-    case 6: string = i18nc("@item:intable image orientation", "90° rotated"); break;
-    case 7: string = i18nc("@item:intable image orientation", "Transversed"); break;
-    case 8: string = i18nc("@item:intable image orientation", "270° rotated"); break;
-    default:
-        break;
-    }
-    return string;
-}
-
-QString KBalooRolesProvider::durationFromValue(int value) const
-{
-    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;
-}
-