diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-31 11:41:08 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-31 11:41:08 +0100 |
| commit | 8804a75ae561a7e504fdce8aea58d3ddc8670b71 (patch) | |
| tree | 85125d2ba1e1880f3439e7d3462247351c46ff1d /src/searchterm.cpp | |
| parent | 8078e8180920984de475db796a2725bb2f470dd8 (diff) | |
| download | qtmaildir-8804a75ae561a7e504fdce8aea58d3ddc8670b71.tar.gz qtmaildir-8804a75ae561a7e504fdce8aea58d3ddc8670b71.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 |
