Ignore baloo urls created from new KIO model

Summary:
For now ignore baloo urls that was created by new KIO::KFilePlacesModel,
until we make use of new KIO API.

BUG: 387888

Test Plan:
Open any KIO file dialog using the new API.
Runs dolphin v17.12.0
Make sure that baloo urls does not appear duplicated

Reviewers: ngraham, elvisangelaccio

Reviewed By: ngraham, elvisangelaccio

Subscribers: cfeck, elvisangelaccio, ervin, mlaurent, #dolphin

Differential Revision: https://phabricator.kde.org/D9347
This commit is contained in:
Renato Araujo Oliveira Filho 2017-12-15 09:10:47 -03:00
parent 9d01f723aa
commit 9d3a019445

View file

@ -65,6 +65,17 @@ namespace {
// Hence a prefix to the application-name of the stored bookmarks is
// added, which is only read by PlacesItemModel.
const char AppNamePrefix[] = "-places-panel";
static QList<QUrl> balooURLs = {
QUrl(QStringLiteral("timeline:/today")),
QUrl(QStringLiteral("timeline:/yesterday")),
QUrl(QStringLiteral("timeline:/thismonth")),
QUrl(QStringLiteral("timeline:/lastmonth")),
QUrl(QStringLiteral("search:/documents")),
QUrl(QStringLiteral("search:/images")),
QUrl(QStringLiteral("search:/audio")),
QUrl(QStringLiteral("search:/videos"))
};
}
PlacesItemModel::PlacesItemModel(QObject* parent) :
@ -832,6 +843,12 @@ bool PlacesItemModel::acceptBookmark(const KBookmark& bookmark,
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)