From fc3073f452e28733c3910ceda403531b3e17404d Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 3 Aug 2026 21:11:30 +0200 Subject: feat(completion): wire query completion into the main window Adds the complete_query action, whose registration the assertion in registerActions() has been demanding since keymap gained the name: a known action nothing implements would have been a silently dead binding. Also lands the QueryCompleter half of the manual trigger, which the keymap commit left behind: triggerCompletion() and the focus-in filter gated on completion_on_focus. Tags refresh at startup, after a sync, and after a mutation introduces a tag not already known, since that is the tag most likely to be typed again. onAllTagsReady deliberately drops the generation the signal carries: a tag list is not an ordered query result, so a later one is always at least as good as an earlier one and discarding on staleness could only throw away a good list. --- src/mainwindow.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/mainwindow.h') diff --git a/src/mainwindow.h b/src/mainwindow.h index f4186ff..3623b04 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -44,6 +44,7 @@ class ThreadListModel; class MessageView; class MailSync; class NotmuchWorker; +class QueryCompleter; class MainWindow : public QMainWindow { @@ -81,6 +82,7 @@ private slots: void onThreadLoaded(const QVector &messages, quint64 generation); void onWorkerError(const QString &message); void onSyncFinished(bool success, int exitCode); + void onAllTagsReady(const QStringList &tags); private: void buildUi(); @@ -93,6 +95,10 @@ private: void registerActions(); void buildMenus(); void wireWorker(); + + /// Asks the worker to re-enumerate the database tags for the completer. + void requestAllTags(); + void showWarnings(); void showShortcutReference(); void showAbout(); @@ -131,6 +137,7 @@ private: QUndoStack m_undoStack; QLineEdit *m_queryEdit = nullptr; + QueryCompleter *m_queryCompleter = nullptr; QTableView *m_threadView = nullptr; QSplitter *m_splitter = nullptr; QComboBox *m_accountBox = nullptr; @@ -147,6 +154,11 @@ private: /// parallel with them. QHash m_actionDescriptions; + /// The tag list last received from the worker. Held here and not only in + /// the completer so a mutation can ask whether it introduced a tag the + /// completer does not yet offer, without a round trip. + QStringList m_knownTags; + quint64 m_generation = 0; QString m_lastQuery; QString m_currentThreadId; -- cgit v1.2.3