]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/information/informationpanel.cpp
Simplify how Nepomuk comments can be edited by the user:
[dolphin.git] / src / panels / information / informationpanel.cpp
index 2c9edcc18b4dd1858de5a14ad9353393e74ddf6c..2150c64659862522d28342488551de169be23024 100644 (file)
@@ -302,7 +302,7 @@ void InformationPanel::contextMenuEvent(QContextMenuEvent* event)
         }
 
         if (!skip) {
-            const QString label = key; // TODO
+            const QString label = tunedLabel(key); // TODO
             QAction* action = new QAction(label, &popup);
             action->setCheckable(true);
             action->setChecked(settings.readEntry(key, true));
@@ -446,25 +446,9 @@ void InformationPanel::showPreview(const KFileItem& item,
 
 void InformationPanel::slotFileRenamed(const QString& source, const QString& dest)
 {
-    const KUrl sourceUrl = KUrl(source);
-
-    // Verify whether the renamed item is selected. If this is the case, the
-    // selection must be updated with the renamed item.
-    bool isSelected = false;
-    for (int i = m_selection.size() - 1; i >= 0; --i) {
-        if (m_selection[i].url() == sourceUrl) {
-            m_selection.removeAt(i);
-            isSelected = true;
-            break;
-        }
-    }
-
-    if ((m_shownUrl == sourceUrl) || isSelected) {
+    if (m_shownUrl == KUrl(source)) {
         m_shownUrl = KUrl(dest);
         m_fileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
-        if (isSelected) {
-            m_selection.append(m_fileItem);
-        }
         showItemInfo();
     }
 }
@@ -599,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;
             }
@@ -686,14 +672,20 @@ void InformationPanel::initMetaInfoSettings(KConfigGroup& group)
     if (!group.readEntry("initialized", false)) {
         // The resource file is read the first time. Assure
         // that some meta information is disabled per default.
-        group.writeEntry("fileExtension", false);
-        group.writeEntry("url", false);
-        group.writeEntry("sourceModified", false);
-        group.writeEntry("parentUrl", false);
-        group.writeEntry("size", false);
-        group.writeEntry("mime type", false);
-        group.writeEntry("depth", false);
-        group.writeEntry("name", false);
+
+        static const char* disabledProperties[] = {
+            "asText", "contentSize", "depth", "fileExtension",
+            "fileName", "fileSize", "isPartOf", "mimetype", "name",
+            "parentUrl", "plainTextContent", "sourceModified",
+            "size", "url",
+            0 // mandatory last entry
+        };
+
+        int i = 0;
+        while (disabledProperties[i] != 0) {
+            group.writeEntry(disabledProperties[i], false);
+            ++i;
+        }
 
         // mark the group as initialized
         group.writeEntry("initialized", true);
@@ -730,6 +722,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);