From: Luca Beltrame Date: Thu, 18 Jan 2018 08:09:49 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/Applications/17.12' X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/1a6b3c0a2baba955259d6083c0a3f25dfb44a682 Merge remote-tracking branch 'origin/Applications/17.12' Conflicts: CMakeLists.txt [versions] src/panels/places/placesitemmodel.cpp --- 1a6b3c0a2baba955259d6083c0a3f25dfb44a682 diff --cc src/panels/places/placesitemmodel.cpp index 422db8fc3,abdd4c20b..ad01ea87e --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@@ -630,11 -841,130 +641,17 @@@ bool PlacesItemModel::acceptBookmark(co const QString udi = bookmark.metaDataItem(QStringLiteral("UDI")); const QUrl url = bookmark.url(); const QString appName = bookmark.metaDataItem(QStringLiteral("OnlyInApp")); - const bool deviceAvailable = availableDevices.contains(udi); + + if (balooURLs.contains(url) && appName.isEmpty()) { + // Does not accept baloo URLS with empty appName, this came from new KIO model and will cause duplications + qCWarning(DolphinDebug) << "Ignore KIO url:" << url; + return false; + } - const bool allowedHere = (appName.isEmpty() || appName == KAboutData::applicationData().componentName() - || appName == KAboutData::applicationData().componentName() + AppNamePrefix) - && (m_fileIndexingEnabled || (url.scheme() != QLatin1String("timeline") && - url.scheme() != QLatin1String("search"))); + || appName == KAboutData::applicationData().componentName() + AppNamePrefix); - return (udi.isEmpty() && allowedHere) || deviceAvailable; -} - -PlacesItem* PlacesItemModel::createSystemPlacesItem(const SystemBookmarkData& data) -{ - KBookmark bookmark = PlacesItem::createBookmark(m_bookmarkManager, - data.text, - data.url, - data.icon); - - const QString protocol = data.url.scheme(); - if (protocol == QLatin1String("timeline") || protocol == QLatin1String("search")) { - // As long as the KFilePlacesView from kdelibs is available, the system-bookmarks - // for "Recently Saved" and "Search For" should be a setting available only - // in the Places Panel (see description of AppNamePrefix for more details). - const QString appName = KAboutData::applicationData().componentName() + AppNamePrefix; - bookmark.setMetaDataItem(QStringLiteral("OnlyInApp"), appName); - } - - PlacesItem* item = new PlacesItem(bookmark); - item->setSystemItem(true); - - // Create default view-properties for all "Search For" and "Recently Saved" bookmarks - // in case if the user has not already created custom view-properties for a corresponding - // query yet. - const bool createDefaultViewProperties = (item->groupType() == PlacesItem::SearchForType || - item->groupType() == PlacesItem::RecentlySavedType) && - !GeneralSettings::self()->globalViewProps(); - if (createDefaultViewProperties) { - ViewProperties props(convertedUrl(data.url)); - if (!props.exist()) { - const QString path = data.url.path(); - if (path == QLatin1String("/documents")) { - props.setViewMode(DolphinView::DetailsView); - props.setPreviewsShown(false); - props.setVisibleRoles({"text", "path"}); - } else if (path == QLatin1String("/images")) { - props.setViewMode(DolphinView::IconsView); - props.setPreviewsShown(true); - props.setVisibleRoles({"text", "imageSize"}); - } else if (path == QLatin1String("/audio")) { - props.setViewMode(DolphinView::DetailsView); - props.setPreviewsShown(false); - props.setVisibleRoles({"text", "artist", "album"}); - } else if (path == QLatin1String("/videos")) { - props.setViewMode(DolphinView::IconsView); - props.setPreviewsShown(true); - props.setVisibleRoles({"text"}); - } else if (data.url.scheme() == QLatin1String("timeline")) { - props.setViewMode(DolphinView::DetailsView); - props.setVisibleRoles({"text", "modificationtime"}); - } - } - } - - return item; -} - -void PlacesItemModel::createSystemBookmarks() -{ - Q_ASSERT(m_systemBookmarks.isEmpty()); - Q_ASSERT(m_systemBookmarksIndexes.isEmpty()); - - // Note: The context of the I18N_NOOP2 must be "KFile System Bookmarks". The real - // i18nc call is done after reading the bookmark. The reason why the i18nc call is not - // done here is because otherwise switching the language would not result in retranslating the - // bookmarks. - m_systemBookmarks.append(SystemBookmarkData(QUrl::fromLocalFile(QDir::homePath()), - QStringLiteral("user-home"), - I18N_NOOP2("KFile System Bookmarks", "Home"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("remote:/")), - QStringLiteral("network-workgroup"), - I18N_NOOP2("KFile System Bookmarks", "Network"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl::fromLocalFile(QStringLiteral("/")), - QStringLiteral("folder-red"), - I18N_NOOP2("KFile System Bookmarks", "Root"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("trash:/")), - QStringLiteral("user-trash"), - I18N_NOOP2("KFile System Bookmarks", "Trash"))); - - if (m_fileIndexingEnabled) { - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("timeline:/today")), - QStringLiteral("go-jump-today"), - I18N_NOOP2("KFile System Bookmarks", "Today"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("timeline:/yesterday")), - QStringLiteral("view-calendar-day"), - I18N_NOOP2("KFile System Bookmarks", "Yesterday"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("timeline:/thismonth")), - QStringLiteral("view-calendar-month"), - I18N_NOOP2("KFile System Bookmarks", "This Month"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("timeline:/lastmonth")), - QStringLiteral("view-calendar-month"), - I18N_NOOP2("KFile System Bookmarks", "Last Month"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("search:/documents")), - QStringLiteral("folder-text"), - I18N_NOOP2("KFile System Bookmarks", "Documents"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("search:/images")), - QStringLiteral("folder-images"), - I18N_NOOP2("KFile System Bookmarks", "Images"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("search:/audio")), - QStringLiteral("folder-sound"), - I18N_NOOP2("KFile System Bookmarks", "Audio Files"))); - m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("search:/videos")), - QStringLiteral("folder-videos"), - I18N_NOOP2("KFile System Bookmarks", "Videos"))); - } - - for (int i = 0; i < m_systemBookmarks.count(); ++i) { - m_systemBookmarksIndexes.insert(m_systemBookmarks[i].url, i); - } + return (udi.isEmpty() && allowedHere); } void PlacesItemModel::clear() {