Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 9583c7df authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Recent Documents Runner] Avoid duplicate results

BUG: 381665

Differential Revision: https://phabricator.kde.org/D7476
parent d545538e
......@@ -75,6 +75,9 @@ void RecentDocuments::match(Plasma::RunnerContext &context)
const QString homePath = QDir::homePath();
// avoid duplicates
QSet<QUrl> knownUrls;
foreach (const QString &document, m_recentdocuments) {
if (!context.isValid()) {
return;
......@@ -82,14 +85,22 @@ void RecentDocuments::match(Plasma::RunnerContext &context)
if (document.contains(term, Qt::CaseInsensitive)) {
KDesktopFile config(document);
const QUrl url = QUrl(config.readUrl());
if (knownUrls.contains(url)) {
continue;
}
knownUrls.insert(url);
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::PossibleMatch);
match.setRelevance(1.0);
match.setIconName(config.readIcon());
match.setData(config.readUrl());
match.setData(url);
match.setText(config.readName());
QUrl folderUrl = QUrl(config.readUrl()).adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
QUrl folderUrl = url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
if (folderUrl.isLocalFile()) {
QString folderPath = folderUrl.toLocalFile();
if (folderPath.startsWith(homePath)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment