summaryrefslogtreecommitdiffstats
path: root/src/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 8294e4b..1799ac6 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -60,7 +60,8 @@ constexpr int kQueriesFormatVersion = 1;
const QStringList kQueryGenerators = { QStringLiteral("unread"),
QStringLiteral("inbox"),
QStringLiteral("flagged"),
- QStringLiteral("sent") };
+ QStringLiteral("sent"),
+ QStringLiteral("trash") };
/// The tag a generator matches, for the three filters that are a plain tag
/// query. Empty for "sent", which composes from each account's folder instead
@@ -152,6 +153,11 @@ QString Config::allDraftsQuery() const
return joinAccountQueries(m_accounts, &Account::draftsQuery);
}
+QString Config::allTrashQuery() const
+{
+ return joinAccountQueries(m_accounts, &Account::trashQuery);
+}
+
QString Config::defaultPath()
{
const QString base =
@@ -737,6 +743,8 @@ QString Config::resolvedQuery(const SavedQuery &query) const
if (query.isGenerated()) {
if (query.generated == QStringLiteral("sent"))
return allSentQuery();
+ if (query.generated == QStringLiteral("trash"))
+ return allTrashQuery();
// An unknown generator was reported on load. Empty rather than the
// bare stored query, which for a generated entry is empty anyway and
// would otherwise run as "match everything".
@@ -809,6 +817,11 @@ SavedQuery Config::builtinFilter(const QString &generator)
// thread would fold the user's sent message back into the conversation
// it belongs to, which is item 63's finding.
filter.flat = true;
+ } else if (generator == QStringLiteral("trash")) {
+ filter.name = tr("Trash");
+ // NOT flat, unlike Sent. A deleted message still belongs to its
+ // conversation, and folding it back is what Sent had to avoid rather
+ // than something every folder filter wants.
}
return filter;
@@ -833,6 +846,10 @@ QString Config::resolvedQuery(const SavedQuery &query,
const QString all = allSentQuery();
return all.isEmpty() ? matchNothingQuery() : all;
}
+ if (query.generated == QStringLiteral("trash")) {
+ const QString all = allTrashQuery();
+ return all.isEmpty() ? matchNothingQuery() : all;
+ }
return QStringLiteral("tag:%1").arg(generatorTag(query.generated));
}
@@ -853,6 +870,14 @@ QString Config::resolvedQuery(const SavedQuery &query,
return sent.isEmpty() ? matchNothingQuery() : sent;
}
+ if (query.generated == QStringLiteral("trash")) {
+ // The account's OWN trash query, for the reason spelled out above the
+ // sent case: wrapping the all-accounts query in this account's path
+ // works by accident of path: being hierarchical.
+ const QString trash = scope.trashQuery();
+ return trash.isEmpty() ? matchNothingQuery() : trash;
+ }
+
// A tag filter carries no path of its own, so scoping is exactly what
// scopedQuery() does. Its parentheses are load-bearing: `path:... and a or
// b` binds as `(path:... and a) or b`.