]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Nicer formatting of the values - only a temp solution just like tuneLabel. To many...
authorSebastian Trueg <sebastian@trueg.de>
Thu, 5 Nov 2009 08:04:54 +0000 (08:04 +0000)
committerSebastian Trueg <sebastian@trueg.de>
Thu, 5 Nov 2009 08:04:54 +0000 (08:04 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1044996

src/panels/information/kloadmetadatathread.cpp
src/panels/information/kloadmetadatathread_p.h

index 20575ac9bbe6d8909903038e118f0a4da6bf2bc3..c2824847cc2202073cdb887d5cc2088a88105981 100644 (file)
@@ -1,5 +1,6 @@
 /*****************************************************************************
  * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                      *
 /*****************************************************************************
  * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                      *
+ * Copyright (C) 2009 by Sebastian Trueg <trueg@kde.org>                     *
  *                                                                           *
  * This library is free software; you can redistribute it and/or             *
  * modify it under the terms of the GNU Library General Public               *
  *                                                                           *
  * This library is free software; you can redistribute it and/or             *
  * modify it under the terms of the GNU Library General Public               *
 
 #include <kconfig.h>
 #include <kconfiggroup.h>
 
 #include <kconfig.h>
 #include <kconfiggroup.h>
+#include <kglobal.h>
+#include <klocale.h>
 
 #include <nepomuk/variant.h>
 
 #include <nepomuk/variant.h>
+#include <nepomuk/resource.h>
 
 KLoadMetaDataThread::KLoadMetaDataThread() :
     m_rating(0),
 
 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()));
                     // 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;
             }
                 }
                 ++it;
             }
@@ -165,4 +169,19 @@ QString KLoadMetaDataThread::tunedLabel(const QString& label) const
     return tunedLabel + ':';
 }
 
     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"
 #include "kloadmetadatathread_p.moc"
index e229766d659524f1f50fbe8026dee8cf07d88f2f..296b2192fbf3a9de218ecbc03f027c12d1d73bb8 100644 (file)
@@ -83,6 +83,12 @@ private:
      */
     QString tunedLabel(const QString& label) const;
 
      */
     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;
 private:
     int m_rating;
     QString m_comment;