]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Provide proper translation for orientation-EXIF-value
authorPeter Penz <peter.penz19@gmail.com>
Sat, 7 Apr 2012 07:49:00 +0000 (09:49 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 7 Apr 2012 07:49:31 +0000 (09:49 +0200)
src/kitemviews/knepomukrolesprovider.cpp
src/kitemviews/knepomukrolesprovider_p.h

index 5c2e4e1da9303db67e9b612c180c397a78d4bcb6..ac371e1890b89c5a9f413713f6f49350618ccb54 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <KDebug>
 #include <KGlobal>
+#include <KLocale>
 
 #include <Nepomuk/Resource>
 #include <Nepomuk/Tag>
@@ -91,6 +92,9 @@ QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk::Res
         } else if (role == "tags") {
             const QString tags = tagsFromValues(value.toStringList());
             values.insert(role, tags);
+        } else if (role == "orientation") {
+            const QString orientation = orientationFromValue(value.toInt());
+            values.insert(role, orientation);
         } else {
             values.insert(role, value.toString());
         }
@@ -157,3 +161,21 @@ QString KNepomukRolesProvider::tagsFromValues(const QStringList& values) const
     return tags;
 }
 
+QString KNepomukRolesProvider::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;
+}
+
index ca5e186ba7ecec88b8fa27c62f8731e4d8afd97f..c7781cd002bd52bc167ddb1cbf720ca8d8fc6602 100644 (file)
@@ -59,8 +59,18 @@ protected:
     KNepomukRolesProvider();
 
 private:
+    /**
+     * @return User visible string for the given tag-values.
+     */
     QString tagsFromValues(const QStringList& values) const;
 
+    /**
+     * @return User visible string for the EXIF-orientation property
+     *         which can have the values 0 to 8.
+     *         (see http://sylvana.net/jpegcrop/exif_orientation.html)
+     */
+    QString orientationFromValue(int value) const;
+
 private:
     QSet<QByteArray> m_roles;
     QHash<QUrl, QByteArray> m_roleForUri;