From 7781f437a05b4e860353c012cb2f31860fd48cf6 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 14 Aug 2026 17:58:22 +0200 Subject: feat(search): add SearchTerm::exclude Parenthesises both sides, as extend() does: unparenthesised, a disjunction in the query bar binds so the exclusion covers only its last term and leaves the excluded mail on screen, with nothing reporting an error. An empty existing query returns empty rather than the addition alone, which is where this deliberately differs from extend(). Excluding from nothing means the whole Maildir minus one value; the menus will grey the entry out and this is the second layer. Co-Authored-By: Claude Opus 5 --- src/searchterm.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/searchterm.cpp') diff --git a/src/searchterm.cpp b/src/searchterm.cpp index acc64c6..6bfb521 100644 --- a/src/searchterm.cpp +++ b/src/searchterm.cpp @@ -90,4 +90,19 @@ QString extend(const QString &existing, const QString &addition) return QStringLiteral("(%1) AND (%2)").arg(left, right); } +QString exclude(const QString &existing, const QString &addition) +{ + const QString left = existing.trimmed(); + const QString right = addition.trimmed(); + + if (right.isEmpty()) + return left; + // NOT a replace, unlike extend(): see the header. An empty left would make + // this "everything except", which no right-click asked for. + if (left.isEmpty()) + return QString(); + + return QStringLiteral("(%1) AND NOT (%2)").arg(left, right); +} + } // namespace SearchTerm -- cgit v1.2.3