- QSet<KUrl> missingSystemBookmarks;
- foreach (const SystemBookmarkData& data, m_systemBookmarks) {
- missingSystemBookmarks.insert(data.url);
- }
-
- // The bookmarks might have a mixed order of places, devices and search-groups due
- // to the compatibility with the KFilePlacesPanel. In Dolphin's places panel the
- // items should always be collected in one group so the items are collected first
- // in separate lists before inserting them.
- QList<PlacesItem*> placesItems;
- QList<PlacesItem*> recentlyAccessedItems;
- QList<PlacesItem*> searchForItems;
- QList<PlacesItem*> devicesItems;
-
- while (!bookmark.isNull()) {
- if (acceptBookmark(bookmark)) {
- PlacesItem* item = new PlacesItem(bookmark);
- if (item->groupType() == PlacesItem::DevicesType) {
- devices.remove(item->udi());
- devicesItems.append(item);
- } else {
- const KUrl url = bookmark.url();
- if (missingSystemBookmarks.contains(url)) {
- missingSystemBookmarks.remove(url);
-
- // Apply the translated text to the system bookmarks, otherwise an outdated
- // translation might be shown.
- const int index = m_systemBookmarksIndexes.value(url);
- item->setText(m_systemBookmarks[index].text);
- item->setSystemItem(true);
- }
-
- switch (item->groupType()) {
- case PlacesItem::PlacesType: placesItems.append(item); break;
- case PlacesItem::RecentlyAccessedType: recentlyAccessedItems.append(item); break;
- case PlacesItem::SearchForType: searchForItems.append(item); break;
- case PlacesItem::DevicesType:
- default: Q_ASSERT(false); break;
- }
- }
- }
-
- bookmark = root.next(bookmark);
- }
-
- if (!missingSystemBookmarks.isEmpty()) {
- // The current bookmarks don't contain all system-bookmarks. Add the missing
- // bookmarks.
- foreach (const SystemBookmarkData& data, m_systemBookmarks) {
- if (missingSystemBookmarks.contains(data.url)) {
- PlacesItem* item = createSystemPlacesItem(data);
- switch (item->groupType()) {
- case PlacesItem::PlacesType: placesItems.append(item); break;
- case PlacesItem::RecentlyAccessedType: recentlyAccessedItems.append(item); break;
- case PlacesItem::SearchForType: searchForItems.append(item); break;
- case PlacesItem::DevicesType:
- default: Q_ASSERT(false); break;
- }
- }