diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-31 11:41:08 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-17 10:26:18 +0100 |
| commit | 4161ac9a31e160c0dbdd8b1998a1895fe95dcf93 (patch) | |
| tree | b3cfc27e16cae1a7d649bc6648108f56db09996c /src/searchterm.cpp | |
| parent | c608ce2bfb5e4a6aba319e23d4a8bd299ebb4a3b (diff) | |
| download | qtmaildir-4161ac9a31e160c0dbdd8b1998a1895fe95dcf93.tar.gz qtmaildir-4161ac9a31e160c0dbdd8b1998a1895fe95dcf93.zip | |
feat: build the query for what a tag change would move
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/searchterm.cpp')
| -rw-r--r-- | src/searchterm.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/searchterm.cpp b/src/searchterm.cpp index 16936df..06d03be 100644 --- a/src/searchterm.cpp +++ b/src/searchterm.cpp @@ -18,6 +18,8 @@ #include "searchterm.h" +#include "config.h" + #include <algorithm> namespace SearchTerm { @@ -108,4 +110,23 @@ QString exclude(const QString &existing, const QString &addition) return QStringLiteral("(%1) AND NOT (%2)").arg(left, right); } +QString changes(const QString &query, const QStringList &add, + const QStringList &remove) +{ + QStringList terms; + for (const QString &name : add) { + const QString term = tag(name); + if (!term.isEmpty()) + terms.append(QStringLiteral("not ") + term); + } + for (const QString &name : remove) { + const QString term = tag(name); + if (!term.isEmpty()) + terms.append(term); + } + if (query.trimmed().isEmpty() || terms.isEmpty()) + return Config::matchNothingQuery(); + return extend(query, terms.join(QStringLiteral(" or "))); +} + } // namespace SearchTerm |
