Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 22e69f40 authored by Alexander Stippich's avatar Alexander Stippich Committed by Alexander Stippich

Use new display string function from KFileMetaData

Summary:
Remove all custom formatting function
in favor of the ones provided by KFileMetaData

Reviewers: #baloo, elvisangelaccio

Reviewed By: elvisangelaccio

Subscribers: elvisangelaccio

Tags: #baloo

Differential Revision: https://phabricator.kde.org/D19106
parent ff0f95ad
......@@ -8,7 +8,7 @@ set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATI
project(baloo-widgets VERSION ${KDE_APPLICATIONS_VERSION})
set(QT_MIN_VERSION "5.8.0")
set(KF5_MIN_VERSION "5.43.0")
set(KF5_MIN_VERSION "5.56.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_PATH})
......
......@@ -26,6 +26,7 @@
#include "KRatingWidget"
#include <KFileMetaData/UserMetaData>
#include <KFileMetaData/PropertyInfo>
#include <QLabel>
#include <QCollator>
......@@ -117,28 +118,21 @@ QWidget* WidgetFactory::createWidget(const QString& prop, const QVariant& value,
widget = createTagWidget( tags, parent );
}
else {
KFormat form;
// vHanda: FIXME: Add links! Take m_noLinks into consideration
QString valueString;
if (prop == QLatin1String("duration")) {
valueString = form.formatDuration(value.toInt() * 1000);
} else if (prop == QLatin1String("bitRate")) {
valueString = i18nc("@label bitrate (per second)", "%1/s", form.formatByteSize(value.toInt(), 0, KFormat::MetricBinaryDialect));
} else if (prop == QLatin1String("sampleRate")) {
valueString = i18nc("@label samplerate in kilohertz", "%1 kHz", QLocale().toString(value.toDouble() / 1000));
} else if (prop == QLatin1String("releaseYear")) {
valueString = value.toString();
} else if (prop == QLatin1String("originUrl")) {
auto pi = KFileMetaData::PropertyInfo::fromName(prop);
if (pi.name() == QLatin1String("originUrl")) {
if (m_noLinks) {
valueString = value.toString();
} else {
valueString = QStringLiteral("<a href=\"%1\">%1</a>").arg(value.toString());
}
} else if (pi.name() != QLatin1String("empty")) {
valueString = pi.formatAsDisplayString(value);
} else {
// Check if Date/DateTime
QDateTime dt = QDateTime::fromString(value.toString(), Qt::ISODate);
if (dt.isValid()) {
KFormat form;
QTime time = dt.time();
if (!time.hour() && !time.minute() && !time.second()){
valueString = form.formatRelativeDate(dt.date(), m_dateFormat);
......
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