From: Sebastian Trueg Date: Thu, 5 Nov 2009 08:04:54 +0000 (+0000) Subject: Nicer formatting of the values - only a temp solution just like tuneLabel. To many... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/e3d68e709fdbf426259afa51b8c619c092e4e0d2 Nicer formatting of the values - only a temp solution just like tuneLabel. To many temp solutions... svn path=/trunk/KDE/kdebase/apps/; revision=1044996 --- diff --git a/src/panels/information/kloadmetadatathread.cpp b/src/panels/information/kloadmetadatathread.cpp index 20575ac9b..c2824847c 100644 --- a/src/panels/information/kloadmetadatathread.cpp +++ b/src/panels/information/kloadmetadatathread.cpp @@ -1,5 +1,6 @@ /***************************************************************************** * Copyright (C) 2009 by Peter Penz * + * Copyright (C) 2009 by Sebastian Trueg * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * @@ -20,8 +21,11 @@ #include #include +#include +#include #include +#include KLoadMetaDataThread::KLoadMetaDataThread() : m_rating(0), @@ -101,7 +105,7 @@ void KLoadMetaDataThread::run() // TODO #2: using tunedLabel() is a workaround for KDE 4.3 (4.4?) until // we get translated labels m_metaInfoLabels.append(tunedLabel(prop.label())); - m_metaInfoValues.append(it.value().toString()); + m_metaInfoValues.append(formatValue(it.value())); } ++it; } @@ -165,4 +169,19 @@ QString KLoadMetaDataThread::tunedLabel(const QString& label) const return tunedLabel + ':'; } + +// This is a short hack until we have a proper formatting facility in Nepomuk +QString KLoadMetaDataThread::formatValue(const Nepomuk::Variant& value) +{ + if (value.isDateTime()) { + return KGlobal::locale()->formatDateTime( value.toDateTime(), KLocale::FancyShortDate ); + } + else if (value.isResource()) { + return value.toResource().genericLabel(); + } + else { + return value.toString(); + } +} + #include "kloadmetadatathread_p.moc" diff --git a/src/panels/information/kloadmetadatathread_p.h b/src/panels/information/kloadmetadatathread_p.h index e229766d6..296b2192f 100644 --- a/src/panels/information/kloadmetadatathread_p.h +++ b/src/panels/information/kloadmetadatathread_p.h @@ -83,6 +83,12 @@ private: */ QString tunedLabel(const QString& label) const; + /** + * Temporary helper method which tries to pretty print + * values. + */ + QString formatValue(const Nepomuk::Variant& value); + private: int m_rating; QString m_comment;