diff options
| author | Peter Penz <[email protected]> | 2012-05-16 13:46:28 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-05-16 13:47:30 +0200 |
| commit | 88c68592846b83cdc4c2de89aaf81412f3f42f3a (patch) | |
| tree | 5994457c3f301e6e699583dc284573c3302ebef2 /src/panels/places/placesitem.cpp | |
| parent | d47d83c9ae484d489e3f3bb6be775e5bb002e0ab (diff) | |
Implement bookmark synchronization
Whenever the bookmarks are changed by another application, the
state must be synchronized within the model.
Diffstat (limited to 'src/panels/places/placesitem.cpp')
| -rw-r--r-- | src/panels/places/placesitem.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp index 436d69668..9e4cb6846 100644 --- a/src/panels/places/placesitem.cpp +++ b/src/panels/places/placesitem.cpp @@ -63,7 +63,14 @@ PlacesItem::~PlacesItem() void PlacesItem::setUrl(const KUrl& url) { - setDataValue("url", url); + // The default check in KStandardItem::setDataValue() + // for equal values does not work with a custom value + // like KUrl. Hence do a manual check to prevent that + // setting an equal URL results in an itemsChanged() + // signal. + if (dataValue("url").value<KUrl>() != url) { + setDataValue("url", url); + } } KUrl PlacesItem::url() const @@ -84,9 +91,6 @@ QString PlacesItem::udi() const void PlacesItem::setHidden(bool hidden) { setDataValue("isHidden", hidden); - if (!m_bookmark.isNull()) { - m_bookmark.setMetaDataItem("IsHidden", hidden ? "true" : "false"); - } } bool PlacesItem::isHidden() const @@ -121,9 +125,8 @@ void PlacesItem::setBookmark(const KBookmark& bookmark) const QString udi = bookmark.metaDataItem("UDI"); if (udi.isEmpty()) { setIcon(bookmark.icon()); - setText(bookmark.description()); + setText(bookmark.text()); setUrl(bookmark.url()); - setDataValue("address", bookmark.address()); } else { initializeDevice(udi); } @@ -173,7 +176,7 @@ KBookmark PlacesItem::createBookmark(KBookmarkManager* manager, } KBookmark bookmark = root.addBookmark(text, url, iconName); - bookmark.setDescription(text); + bookmark.setFullText(text); bookmark.setMetaDataItem("ID", generateNewId()); return bookmark; @@ -259,7 +262,7 @@ void PlacesItem::updateBookmarkForRole(const QByteArray& role) if (role == "iconName") { m_bookmark.setIcon(icon()); } else if (role == "text") { - m_bookmark.setDescription(text()); + m_bookmark.setFullText(text()); } else if (role == "url") { m_bookmark.setUrl(url()); } else if (role == "udi)") { @@ -273,6 +276,11 @@ void PlacesItem::updateBookmarkForRole(const QByteArray& role) QString PlacesItem::generateNewId() { + // The ID-generation must be different as done in KFilePlacesItem from kdelibs + // to prevent identical IDs, because 'count' is of course not shared. We append a + // " (V2)" to indicate that the ID has been generated by + // a new version of the places view. static int count = 0; - return QString::number(QDateTime::currentDateTime().toTime_t()) + '/' + QString::number(count++); + return QString::number(QDateTime::currentDateTime().toTime_t()) + + '/' + QString::number(count++) + " (V2)"; } |
