]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use new display string function from KFileMetaData
authorAlexander Stippich <alexander.stippich@rwth-aachen.de>
Fri, 1 Mar 2019 11:01:58 +0000 (12:01 +0100)
committerAlexander Stippich <a.stippich@gmx.net>
Fri, 1 Mar 2019 11:02:03 +0000 (12:02 +0100)
Summary:
Delete all the custom formatting functions
and use the ones provided from KFileMetaData.

Reviewers: #dolphin, elvisangelaccio

Reviewed By: #dolphin, elvisangelaccio

Subscribers: bcooksley, elvisangelaccio, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D19105

CMakeLists.txt
src/kitemviews/private/kbaloorolesprovider.cpp
src/kitemviews/private/kbaloorolesprovider.h

index dc877c89cf30fbfec17ccbafc8dd45f6ad6ef79a..4bb1c43986fa328dc3bd8deeb429e6ce3d1f0b21 100644 (file)
@@ -8,7 +8,7 @@ set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATI
 project(Dolphin VERSION ${KDE_APPLICATIONS_VERSION})
 
 set(QT_MIN_VERSION "5.8.0")
-set(KF5_MIN_VERSION "5.53.0")
+set(KF5_MIN_VERSION "5.56.0")
 
 # ECM setup
 find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED)
index 41184e119ce0f032219972aca46ee9efce8b2911..0eedf180656515769b83796d98c9b38ec378e0f2 100644 (file)
@@ -67,22 +67,7 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
             continue;
         }
 
-        const QVariant value = it.value();
-
-        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());
@@ -154,37 +139,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;
-}
-
index 64b1a5c8276d2eed4f24917543473e34ed319ca7..cd5131df878f8166a9a6acb3867679eb354469f1 100644 (file)
@@ -67,25 +67,6 @@ private:
      */
     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;
-
-    /**
-     * @return Duration in the format HH::MM::SS for the value given
-     *         in seconds.
-     */
-    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<QByteArray> m_roles;
     QHash<QString, QByteArray> m_roleForProperty;