]> cloud.milkyroute.net Git - dolphin.git/commitdiff
We won't get translated labels for Nepomuk literals in KDE 4.3.0... At least assure...
authorPeter Penz <peter.penz19@gmail.com>
Sat, 20 Jun 2009 11:45:34 +0000 (11:45 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 20 Jun 2009 11:45:34 +0000 (11:45 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=984190

src/panels/information/informationpanel.cpp
src/panels/information/informationpanel.h

index 30a41fefc2745d2ad392c6da26c14d934801a92e..1fa5565d766186c2fbd45d1a4b1381a7cfffa668 100644 (file)
@@ -583,9 +583,11 @@ void InformationPanel::showMetaInfo()
                 Nepomuk::Types::Property prop(it.key());
                 const QString label = prop.label();
                 if (settings.readEntry(label, true)) {
-                    // TODO: use Nepomuk::formatValue(res, prop) if available
+                    // TODO #1: use Nepomuk::formatValue(res, prop) if available
                     // instead of it.value().toString()
-                    m_metaTextLabel->add(label, it.value().toString());
+                    // TODO #2: using tunedLabel() is a workaround for KDE 4.3 until
+                    // we get translated labels
+                    m_metaTextLabel->add(tunedLabel(label), it.value().toString());
                 }
                 ++it;
             }
@@ -714,6 +716,25 @@ void InformationPanel::updatePhononWidget()
     }
 }
 
+QString InformationPanel::tunedLabel(const QString& label) const
+{
+    QString tunedLabel;
+    const int labelLength = label.length();
+    if (labelLength > 0) {
+        tunedLabel.reserve(labelLength);
+        tunedLabel = label[0].toUpper();
+        for (int i = 1; i < labelLength; ++i) {
+            if (label[i].isUpper() && !label[i - 1].isSpace() && !label[i - 1].isUpper()) {
+                tunedLabel += ' ';
+                tunedLabel += label[i].toLower();
+            } else {
+                tunedLabel += label[i];
+            }
+        }
+    }
+    return tunedLabel;
+}
+
 void InformationPanel::init()
 {
     m_infoTimer = new QTimer(this);
index 46f0805078b3da34ea01faa5592981eb653d54cb..76af6a66a3db218bed32dcffd83700fb37667352 100644 (file)
@@ -194,6 +194,13 @@ private:
 
     void updatePhononWidget();
 
+    /**
+     * Temporary helper method for KDE 4.3 as we currently don't get
+     * translated labels for Nepmok literals: Replaces camelcase labels
+     * like "fileLocation" by "File Location:".
+     */
+    QString tunedLabel(const QString& label) const;
+
     void init();
 
 private: