aboutsummaryrefslogtreecommitdiffstats
path: root/src/notmuchworker.h
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-10 08:29:57 +0200
committerDanilo M. <danix@danix.xyz>2026-08-10 08:29:57 +0200
commitc56d826673ec1bbd821cf703e6ee12cbef1a7ffc (patch)
treed0af4a2cba33005e1a768a9ba6ca5135adeee607 /src/notmuchworker.h
parent2d062241732f7396e8cb12295962d3f3e5c1a2b0 (diff)
downloadqtmaildir-c56d826673ec1bbd821cf703e6ee12cbef1a7ffc.tar.gz
qtmaildir-c56d826673ec1bbd821cf703e6ee12cbef1a7ffc.zip
feat(worker): let a query choose newest or oldest first
Sorting was hardcoded NEWEST_FIRST. Two orders only: notmuch's other two are MESSAGE_ID and UNSORTED, neither of which is an order a human wants, and sorting by sender or subject would have to happen in the model after results arrive, which fights the batching that makes a large query paint immediately. loadThread keeps OLDEST_FIRST unconditionally: a thread reads chronologically whichever way the list is sorted.
Diffstat (limited to 'src/notmuchworker.h')
-rw-r--r--src/notmuchworker.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/notmuchworker.h b/src/notmuchworker.h
index df1799d..1d8c8c0 100644
--- a/src/notmuchworker.h
+++ b/src/notmuchworker.h
@@ -44,10 +44,24 @@ public:
/// Threads emitted per threadsReady() signal.
static constexpr int kBatchSize = 200;
+ /// The sort orders offered to the user.
+ ///
+ /// Two, not four. notmuch also has NOTMUCH_SORT_MESSAGE_ID and
+ /// NOTMUCH_SORT_UNSORTED, and neither is an order a human wants. Sorting
+ /// by sender or subject is deliberately absent: notmuch cannot do it, so
+ /// the model would have to sort after results arrive, which fights the
+ /// batching that makes a 10k-thread query paint immediately.
+ enum SortOrder {
+ NewestFirst,
+ OldestFirst,
+ };
+ Q_ENUM(SortOrder)
+
public slots:
/// Runs a query. generation lets the UI discard results from a superseded
/// query without the worker needing to know about cancellation.
- void runQuery(const QString &query, quint64 generation);
+ void runQuery(const QString &query, quint64 generation,
+ SortOrder sort = NewestFirst);
/// Loads the messages of one thread, oldest first. matchQuery is the
/// user's current query; messages matching it render expanded, the rest