summaryrefslogtreecommitdiffstats
path: root/src/mainwindow.h
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-07 12:03:14 +0200
committerDanilo M. <danix@danix.xyz>2026-08-07 12:03:14 +0200
commit5a4d8f5f021dc98b2a7cc471125aa3040c02675c (patch)
tree181eccf726124f39ae6a1c14734cfa18ac42ed9f /src/mainwindow.h
parent0a9ef3c77c7c593f3568f25761aad5d1f55e0e33 (diff)
downloadqtmaildir-5a4d8f5f021dc98b2a7cc471125aa3040c02675c.tar.gz
qtmaildir-5a4d8f5f021dc98b2a7cc471125aa3040c02675c.zip
feat(tags): mark every thread in the view read, in one undoable step
An action removing "unread" from every thread in the current view, on the toolbar, the Message menu and Ctrl+Shift+U. It deliberately ignores the selection, which makes it the one action in the window that does, and it routes through the same funnel as every other tag change, so it is one write rather than one per thread. Disabled until the query reports its total. Threads arrive in batches, so before then the model holds only what has landed, and an action saying "all" must not silently skip the rest. A greyed control says "not yet" without needing a dialog or a stall the user cannot see. The state is also set at registration, since QAction starts enabled and a window that has not run a query has nothing to act on. Two things came out differently from the plan, both forced by existing code. It carries a default binding, because everyActionHasAShortcut requires every registered action to have one: an unbound action is unreachable from the keyboard, and that invariant is deliberate, so the action was given Ctrl+Shift+U rather than the invariant relaxed. And only the threads that are actually unread are sent, because sending the rest would inflate the pending-edit count with writes that change nothing, and the quit prompt reads that count. A view with nothing unread does nothing, pushes no command and says so: an undo entry that restores nothing is worse than none, since it absorbs a Ctrl+Z meant for the previous action. undoDepthForTesting() is new and exists for a reason worth recording: undo->isEnabled() cannot answer "was a command pushed", because the undo QAction is always enabled and tests canUndo() when triggered. The first version of the no-op test asserted on it and passed against a mutant with the unread filter removed. Closes item 43. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/mainwindow.h')
-rw-r--r--src/mainwindow.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 3984e78..adb973c 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -119,6 +119,19 @@ public:
static void setLocksPathForTesting(const QString &path);
static QString locksPath();
+ /// How many commands are on the undo stack.
+ ///
+ /// A test seam. The undo QAction is always enabled and checks canUndo()
+ /// when triggered, so its enabled state says nothing about whether a
+ /// command was pushed, which is what "this did nothing" has to assert.
+ int undoDepthForTesting() const { return m_undoStack.count(); }
+
+ /// The generation a worker reply must carry to be accepted.
+ ///
+ /// A test seam: onQueryFinished() discards a reply whose generation is
+ /// stale, so a test standing in for the worker has to know the current one.
+ quint64 currentGenerationForTesting() const { return m_generation; }
+
protected:
void closeEvent(QCloseEvent *event) override;
@@ -232,6 +245,14 @@ private:
/// when the phase or its detail changes.
void feedSyncPhase(const QString &chunk);
+ /// Removes `unread` from every thread in the current view, as one write and
+ /// one undo entry, ignoring the selection.
+ void markAllRead();
+
+ /// Enables or disables the actions that claim to act on a whole view,
+ /// according to whether the result set is complete.
+ void updateViewWideActions();
+
/// Applies the sync progress bar and button state from BOTH sync sources.
///
/// One function of both, never two assignments: with a local and a
@@ -383,6 +404,11 @@ private:
QStringList m_knownTags;
quint64 m_generation = 0;
+
+ /// True once the running query has reported its total, so the model holds
+ /// the whole result set rather than the batches that have arrived so far.
+ /// Gates mark_all_read, which cannot honestly say "all" before then.
+ bool m_queryComplete = false;
QString m_lastQuery;
QString m_currentThreadId;