]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Update the Places Panel entries when switching the language
authorFrank Reininghaus <frank78ac@googlemail.com>
Fri, 15 Nov 2013 08:16:22 +0000 (09:16 +0100)
committerFrank Reininghaus <frank78ac@googlemail.com>
Fri, 15 Nov 2013 08:20:10 +0000 (09:20 +0100)
Before this commit, we stored the translated "Places" in
.kde4/share/apps/kfileplaces/bookmarks.xml. This was not intentional -
it only happened because
PlacesItem::updateBookmarkForRole(const QByteArray& role) always stored
the translated text (returned by PlacesItem::text()) in the KBookmark.

This is be fixed by first checking if the text() is equal to the
translation of the text that is already stored in the KBookmark, and
not updating it in that case.

Note that we have to make sure that all "Places"-related use the same
context "KFile System Bookmarks" to make that work.

Thanks to Burkhard Lück and Albert Astals Cid for helping to fix this
problem!

BUG: 319282
FIXED-IN: 4.12.0
REVIEW: 113850

src/panels/places/placesitem.cpp

index 76b51e3aa62b8da39f41a01332a7b57aa1fb7116..41f22cce43d30aee00c3108d75a8170d4e6d7e4a 100644 (file)
@@ -120,6 +120,10 @@ Solid::Device PlacesItem::device() const
 
 void PlacesItem::setBookmark(const KBookmark& bookmark)
 {
+    if (bookmark == m_bookmark) {
+        return;
+    }
+
     m_bookmark = bookmark;
 
     delete m_access;
@@ -302,7 +306,15 @@ void PlacesItem::updateBookmarkForRole(const QByteArray& role)
     if (role == "iconName") {
         m_bookmark.setIcon(icon());
     } else if (role == "text") {
-        m_bookmark.setFullText(text());
+        // Only store the text in the KBookmark if it is not the translation of
+        // the current text. This makes sure that the text is re-translated if
+        // the user chooses another language, or the translation itself changes.
+        //
+        // NOTE: It is important to use "KFile System Bookmarks" as context
+        // (see PlacesItemModel::createSystemBookmarks()).
+        if (text() != i18nc("KFile System Bookmarks", m_bookmark.text().toUtf8().data())) {
+            m_bookmark.setFullText(text());
+        }
     } else if (role == "url") {
         m_bookmark.setUrl(url());
     } else if (role == "udi)") {