diff options
| author | Alexander Stippich <[email protected]> | 2019-03-01 12:01:58 +0100 |
|---|---|---|
| committer | Alexander Stippich <[email protected]> | 2019-03-01 12:02:03 +0100 |
| commit | 7a57be98126b2d57a5728ded923474d00d98a04d (patch) | |
| tree | 85f08d736138b35087e449f793c42ad86c9910eb | |
| parent | 4315e5c9380e22eed483f00adac3d075369eae49 (diff) | |
Use new display string function from KFileMetaData
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
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/kitemviews/private/kbaloorolesprovider.cpp | 51 | ||||
| -rw-r--r-- | src/kitemviews/private/kbaloorolesprovider.h | 19 |
3 files changed, 2 insertions, 70 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index dc877c89c..4bb1c4398 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp index 41184e119..0eedf1806 100644 --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -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; -} - diff --git a/src/kitemviews/private/kbaloorolesprovider.h b/src/kitemviews/private/kbaloorolesprovider.h index 64b1a5c82..cd5131df8 100644 --- a/src/kitemviews/private/kbaloorolesprovider.h +++ b/src/kitemviews/private/kbaloorolesprovider.h @@ -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; |
