Commit 7a57be98 authored by Alexander Stippich's avatar Alexander Stippich Committed by Alexander Stippich

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
parent 4315e5c9
......@@ -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)
......
......@@ -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;
}
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment