diff options
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. |
