diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-12 11:49:40 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-12 11:49:40 +0200 |
| commit | 01ecb8c4e3bbf8176ca9d4085734ed2ec0774c80 (patch) | |
| tree | b0051bd24959fd544bf55d099ca91fc51cdd3950 /src/notmuchworker.cpp | |
| parent | d14c0224826f821b34c894037ab668ddfde29a6d (diff) | |
| download | qtmaildir-01ecb8c4e3bbf8176ca9d4085734ed2ec0774c80.tar.gz qtmaildir-01ecb8c4e3bbf8176ca9d4085734ed2ec0774c80.zip | |
feat(worker): count messages as well as threads
requestCounts counts threads, which is right for the placeholder pane.
A tagging rule tags messages, so a dry run over rules needs the message
count or it understates every rule that matches part of a thread.
Diffstat (limited to 'src/notmuchworker.cpp')
| -rw-r--r-- | src/notmuchworker.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/notmuchworker.cpp b/src/notmuchworker.cpp index 24f3fd9..94fb79c 100644 --- a/src/notmuchworker.cpp +++ b/src/notmuchworker.cpp @@ -647,3 +647,34 @@ void NotmuchWorker::requestCounts(const QStringList &queries, quint64 generation emit countsReady(counts, generation); } + +void NotmuchWorker::requestMessageCounts(const QStringList &queries, + quint64 generation) +{ + if (!openReadOnly()) + return; + + QVector<int> counts; + counts.reserve(queries.size()); + + for (const QString &query : queries) { + NmQuery nmQuery(notmuch_query_create(m_db, query.toUtf8().constData())); + + unsigned int count = 0; + // -1 rather than a skipped entry, matching requestCounts: the caller + // pairs these with its own rules positionally, so a dropped answer + // would put a real number against the wrong rule. + if (!nmQuery || + notmuch_query_count_messages(nmQuery.get(), &count) + != NOTMUCH_STATUS_SUCCESS) { + counts.append(-1); + continue; + } + + // Messages, not threads: a rule tags messages, so counting threads + // would understate a rule matching part of a large thread. + counts.append(static_cast<int>(count)); + } + + emit messageCountsReady(counts, generation); +} |
