Merge branch 'Plasma/5.14'

wilder-broken-krunner
Kai Uwe Broulik 7 years ago
commit 0934dfba8f
  1. 2
      applets/clipboard/contents/ui/TextItemDelegate.qml
  2. 28
      runners/baloo/baloosearchrunner.cpp
  3. 2
      runners/baloo/baloosearchrunner.h

@ -30,7 +30,7 @@ PlasmaComponents.Label {
text: {
var highlightFontTag = "<font color='" + theme.highlightColor + "'>%1</font>"
var text = DisplayRole
var text = DisplayRole.slice(0, 100)
// first escape any HTML characters to prevent privacy issues
text = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")

@ -116,21 +116,24 @@ RemoteMatches SearchRunner::Match(const QString& searchTerm)
void SearchRunner::performMatch()
{
// Filter out duplicates
QSet<QUrl> 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<QUrl> &foundUrls)
{
Baloo::Query query;
query.setSearchString(searchTerm);
@ -154,6 +157,13 @@ RemoteMatches SearchRunner::matchInternal(const QString& searchTerm, const QStri
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();

@ -46,7 +46,7 @@ public:
private:
void performMatch();
RemoteMatches matchInternal(const QString &searchTerm, const QString& type,
const QString& category);
const QString& category, QSet<QUrl> &foundUrls);
QDBusMessage m_lastRequest;
QString m_searchTerm;

Loading…
Cancel
Save