From 78b3a9c1769d37ff7344360b6fed66b12b2f0649 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 14 Aug 2026 18:01:28 +0200 Subject: refactor(search): carry SearchMode instead of bool extend Four signatures, no behaviour change: the two shipped operations map to Replace and Narrow. runSearchFromPane becomes a switch and gains the Exclude arm, which nothing can reach until the menu entry exists. Seven call sites across three test files moved with it, two more than the plan predicted: test_messageview and test_mainwindow also drive these signals directly. mainwindow.h and messagedetailsdialog.h now include searchterm.h for the type; messageview.h already did. Co-Authored-By: Claude Opus 5 --- src/mainwindow.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 115646e..e82e61d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1651,13 +1651,30 @@ void MainWindow::onPlaceholderQueryRequested(const QString &query) runCurrentQuery(); } -void MainWindow::runSearchFromPane(const QString &query, bool extend) +void MainWindow::runSearchFromPane(const QString &query, + SearchTerm::SearchMode mode) { if (query.isEmpty()) return; - const QString next = - extend ? SearchTerm::extend(m_queryEdit->text(), query) : query; + QString next; + switch (mode) { + case SearchTerm::SearchMode::Replace: + next = query; + break; + case SearchTerm::SearchMode::Narrow: + next = SearchTerm::extend(m_queryEdit->text(), query); + break; + case SearchTerm::SearchMode::Exclude: + next = SearchTerm::exclude(m_queryEdit->text(), query); + break; + } + + // exclude() returns empty when there is nothing to exclude from, which the + // greyed menu entry should already have prevented. Running it would clear + // the query bar and show the whole Maildir, so refuse instead. + if (next.isEmpty()) + return; // Through the query bar and the existing runner, so the account scope, the // generation counter and the flat-mode reset all behave exactly as they do -- cgit v1.2.3