diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-31 11:42:24 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-17 10:26:19 +0100 |
| commit | a7d12f9608d1105e5f3d6da6ad6c9f3fa4d9b458 (patch) | |
| tree | f5a3703c60090ed1cd67c7e7b0710e0868838e54 /src/tagrules.cpp | |
| parent | 4161ac9a31e160c0dbdd8b1998a1895fe95dcf93 (diff) | |
| download | qtmaildir-a7d12f9608d1105e5f3d6da6ad6c9f3fa4d9b458.tar.gz qtmaildir-a7d12f9608d1105e5f3d6da6ad6c9f3fa4d9b458.zip | |
feat: an optional allow_archive field on a tagging rule
Both readers learn it together, as the rule format requires. No version
bump: the field is optional, and each writer emits it only on a rule that
removes inbox, so a file without one saves unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/tagrules.cpp')
| -rw-r--r-- | src/tagrules.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tagrules.cpp b/src/tagrules.cpp index d88a70f..4e1d179 100644 --- a/src/tagrules.cpp +++ b/src/tagrules.cpp @@ -42,6 +42,7 @@ bool isKnownKey(const QString &key) QStringLiteral("enabled"), QStringLiteral("add"), QStringLiteral("remove"), QStringLiteral("query"), QStringLiteral("note"), QStringLiteral("move"), + QStringLiteral("allow_archive"), }; return known.contains(key); } @@ -285,6 +286,8 @@ void TagRules::load(const QString &path) rule.stage = object.value(QStringLiteral("stage")).toInt(kDefaultStage); rule.enabled = object.value(QStringLiteral("enabled")).toBool(true); rule.note = object.value(QStringLiteral("note")).toString(); + rule.allowArchive = + object.value(QStringLiteral("allow_archive")).toBool(false); for (auto it = object.begin(); it != object.end(); ++it) { if (!isKnownKey(it.key())) @@ -296,6 +299,13 @@ void TagRules::load(const QString &path) } } +bool TagRules::hookWouldSkip(const TagRule &rule) +{ + if (rule.remove.contains(QStringLiteral("unread"))) + return true; + return rule.remove.contains(QStringLiteral("inbox")) && !rule.allowArchive; +} + bool TagRules::save(const QString &path) const { const QString target = path.isEmpty() ? defaultPath() : path; @@ -317,6 +327,10 @@ bool TagRules::save(const QString &path) const object.insert(QStringLiteral("move"), rule.move); object.insert(QStringLiteral("query"), rule.query); object.insert(QStringLiteral("note"), rule.note); + // Written only where it does something, so a file without an + // archiving rule saves byte-identical (item 213). + if (rule.allowArchive && rule.remove.contains(QStringLiteral("inbox"))) + object.insert(QStringLiteral("allow_archive"), true); for (auto it = rule.unknown.begin(); it != rule.unknown.end(); ++it) { // A bad move kept from load must not overwrite the role the user // has since chosen in the dialog. |
