aboutsummaryrefslogtreecommitdiffstats
path: root/src/querycompleter.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-18 15:37:52 +0200
committerDanilo M. <danix@danix.xyz>2026-09-18 15:37:52 +0200
commit06586027b0f328ba0aa4b2c6c3c77471d72aac52 (patch)
treec18d68bee7edb7d48e13fe31869d7894cfb72f6c /src/querycompleter.cpp
parent9d4fb5444438bdf188a6149a6667788dc3fc7bc0 (diff)
downloadqtmaildir-06586027b0f328ba0aa4b2c6c3c77471d72aac52.tar.gz
qtmaildir-06586027b0f328ba0aa4b2c6c3c77471d72aac52.zip
feat: complete contacts in the query bar
from: and to: now offer the vCard store's addresses, each quoted via SearchTerm::quote() with the contact's name as the description. The store is the enumerator libnotmuch does not expose, which is what the old complete-nothing comment said was missing; it keeps that role for folder:, subject:, attachment:, thread: and id:. With no store configured the branch returns {} and the behaviour is unchanged.
Diffstat (limited to 'src/querycompleter.cpp')
-rw-r--r--src/querycompleter.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/querycompleter.cpp b/src/querycompleter.cpp
index 9848faf..1b4c2fc 100644
--- a/src/querycompleter.cpp
+++ b/src/querycompleter.cpp
@@ -19,6 +19,7 @@
#include "querycompleter.h"
#include "config.h"
+#include "searchterm.h"
#include <QCompleter>
#include <QCoreApplication>
@@ -597,6 +598,11 @@ void QueryCompleter::setTags(const QStringList &tags)
m_tags = tags;
}
+void QueryCompleter::setContacts(const QList<Contact> &contacts)
+{
+ m_contacts = contacts;
+}
+
QList<CompletionEntry> QueryCompleter::entriesFor(
const CompletionContext &context) const
{
@@ -649,10 +655,27 @@ QList<CompletionEntry> QueryCompleter::entriesFor(
return entries;
}
- // from:, to:, folder:, subject:, attachment:, thread:, id: complete no
- // values. Addresses need an enumerator libnotmuch does not expose;
- // folder: matches a Maildir folder name that config cannot enumerate, and
- // the rest are free text.
+ // The addresses live in the vCard store, which is the enumerator
+ // libnotmuch does not expose. The VALUE is the bare address because that
+ // is what notmuch matches on; the contact's name is the description, so
+ // the popup says who owns it.
+ if (context.prefix == QStringLiteral("from")
+ || context.prefix == QStringLiteral("to")) {
+ QList<CompletionEntry> entries;
+ entries.reserve(m_contacts.size());
+ for (const Contact &contact : m_contacts) {
+ const QString address = SearchTerm::quote(contact.email);
+ if (address.isEmpty())
+ continue;
+ entries.append({ address, contact.name });
+ }
+ return entries;
+ }
+
+ // folder:, subject:, attachment:, thread:, id: complete no values. folder:
+ // matches a Maildir folder name that config cannot enumerate, and the rest
+ // are free text. from: and to: no longer belong in this list: the vCards
+ // are the enumerator they lacked.
return {};
}