]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Ignore baloo urls created from new KIO model
authorRenato Araujo Oliveira Filho <renato.araujo@kdab.com>
Fri, 15 Dec 2017 12:10:47 +0000 (09:10 -0300)
committerRenato Araujo Oliveira Filho <renato.araujo@kdab.com>
Tue, 2 Jan 2018 13:15:47 +0000 (10:15 -0300)
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

src/panels/places/placesitemmodel.cpp

index 680d513b5c166dcd214984eaa3d9b5ac44da58d8..abdd4c20b65bf1b8933fa7207930b0f3367954e7 100644 (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)