Update the Places Panel entries when switching the language

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
This commit is contained in:
Frank Reininghaus 2013-11-15 09:16:22 +01:00
parent 980846ab36
commit ac8722dc7d

View 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)") {