diff --git a/src/filewidgets/kfileplacesitem.cpp b/src/filewidgets/kfileplacesitem.cpp --- a/src/filewidgets/kfileplacesitem.cpp +++ b/src/filewidgets/kfileplacesitem.cpp @@ -74,6 +74,28 @@ } } +bool KFilePlacesItem::hasSupportedScheme(const QStringList &schemes) const +{ + if (schemes.isEmpty()) { + return true; + } + + // StorageAccess is always local, doesn't need to be accessible to know this + if (m_access && schemes.contains(QLatin1String("file"))) { + return true; + } + + if (m_networkShare && schemes.contains(m_networkShare->url().scheme())) { + return true; + } + + if (m_mtp && schemes.contains(QLatin1String("mtp"))) { + return true; + } + + return false; +} + bool KFilePlacesItem::isDevice() const { return !bookmark().metaDataItem(QStringLiteral("UDI")).isEmpty(); diff --git a/src/filewidgets/kfileplacesitem_p.h b/src/filewidgets/kfileplacesitem_p.h --- a/src/filewidgets/kfileplacesitem_p.h +++ b/src/filewidgets/kfileplacesitem_p.h @@ -70,6 +70,8 @@ bool isHidden() const; void setHidden(bool hide); + bool hasSupportedScheme(const QStringList &schemes) const; + static KBookmark createBookmark(KBookmarkManager *manager, const QString &label, const QUrl &url, diff --git a/src/filewidgets/kfileplacesmodel.cpp b/src/filewidgets/kfileplacesmodel.cpp --- a/src/filewidgets/kfileplacesmodel.cpp +++ b/src/filewidgets/kfileplacesmodel.cpp @@ -754,15 +754,19 @@ bool isSupportedUrl = isBalooUrl(url) ? fileIndexingEnabled : true; bool isSupportedScheme = supportedSchemes.isEmpty() || supportedSchemes.contains(url.scheme()); - if (isSupportedScheme && ((isSupportedUrl && udi.isEmpty() && allowedHere) || deviceAvailable)) { - - KFilePlacesItem *item; - if (deviceAvailable) { - item = new KFilePlacesItem(bookmarkManager, bookmark.address(), udi); - // TODO: Update bookmark internal element - } else { - item = new KFilePlacesItem(bookmarkManager, bookmark.address()); + KFilePlacesItem *item = nullptr; + if (deviceAvailable) { + item = new KFilePlacesItem(bookmarkManager, bookmark.address(), udi); + if (!item->hasSupportedScheme(supportedSchemes)) { + delete item; + item = nullptr; } + } else if (isSupportedScheme && isSupportedUrl && udi.isEmpty() && allowedHere) { + // TODO: Update bookmark internal element + item = new KFilePlacesItem(bookmarkManager, bookmark.address()); + } + + if (item) { connect(item, SIGNAL(itemChanged(QString)), q, SLOT(_k_itemChanged(QString)));