diff --git a/runners/baloo/baloosearchrunner.h b/runners/baloo/baloosearchrunner.h --- a/runners/baloo/baloosearchrunner.h +++ b/runners/baloo/baloosearchrunner.h @@ -46,7 +46,7 @@ private: void performMatch(); RemoteMatches matchInternal(const QString &searchTerm, const QString& type, - const QString& category); + const QString& category, QSet &foundUrls); QDBusMessage m_lastRequest; QString m_searchTerm; diff --git a/runners/baloo/baloosearchrunner.cpp b/runners/baloo/baloosearchrunner.cpp --- a/runners/baloo/baloosearchrunner.cpp +++ b/runners/baloo/baloosearchrunner.cpp @@ -116,21 +116,24 @@ void SearchRunner::performMatch() { + // Filter out duplicates + QSet foundUrls; + RemoteMatches matches; - matches << matchInternal(m_searchTerm, QStringLiteral("Audio"), i18n("Audio")); - matches << matchInternal(m_searchTerm, QStringLiteral("Image"), i18n("Image")); - matches << matchInternal(m_searchTerm, QStringLiteral("Document"), i18n("Document")); - matches << matchInternal(m_searchTerm, QStringLiteral("Video"), i18n("Video")); - matches << matchInternal(m_searchTerm, QStringLiteral("Folder"), i18n("Folder")); - matches << matchInternal(m_searchTerm, QStringLiteral("Archive"), i18n("Archive")); - matches << matchInternal(m_searchTerm, QStringLiteral("Spreadsheet"), i18n("Spreadsheet")); - matches << matchInternal(m_searchTerm, QStringLiteral("Presentation"), i18n("Presentation")); + matches << matchInternal(m_searchTerm, QStringLiteral("Audio"), i18n("Audio"), foundUrls); + matches << matchInternal(m_searchTerm, QStringLiteral("Image"), i18n("Image"), foundUrls); + matches << matchInternal(m_searchTerm, QStringLiteral("Video"), i18n("Video"), foundUrls); + matches << matchInternal(m_searchTerm, QStringLiteral("Spreadsheet"), i18n("Spreadsheet"), foundUrls); + matches << matchInternal(m_searchTerm, QStringLiteral("Presentation"), i18n("Presentation"), foundUrls); + matches << matchInternal(m_searchTerm, QStringLiteral("Folder"), i18n("Folder"), foundUrls); + matches << matchInternal(m_searchTerm, QStringLiteral("Document"), i18n("Document"), foundUrls); + matches << matchInternal(m_searchTerm, QStringLiteral("Archive"), i18n("Archive"), foundUrls); QDBusConnection::sessionBus().send(m_lastRequest.createReply(QVariant::fromValue(matches))); m_lastRequest = QDBusMessage(); } -RemoteMatches SearchRunner::matchInternal(const QString& searchTerm, const QString &type, const QString &category) +RemoteMatches SearchRunner::matchInternal(const QString& searchTerm, const QString &type, const QString &category, QSet &foundUrls) { Baloo::Query query; query.setSearchString(searchTerm); @@ -154,6 +157,13 @@ RemoteMatch match; QString localUrl = it.filePath(); const QUrl url = QUrl::fromLocalFile(localUrl); + + if (foundUrls.contains(url)) { + continue; + } + + foundUrls.insert(url); + match.id = it.filePath(); match.text = url.fileName(); match.iconName = mimeDb.mimeTypeForFile(localUrl).iconName();