aboutsummaryrefslogtreecommitdiffstats
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-14 18:01:28 +0200
committerDanilo M. <danix@danix.xyz>2026-08-14 18:01:28 +0200
commit78b3a9c1769d37ff7344360b6fed66b12b2f0649 (patch)
treeacc2f6f4c995f2c378e82a83f5800a9f3d6e6b48 /src/mainwindow.cpp
parentf7fa8bb6aefa5896fc7fdfb694f2a2752eb88ed5 (diff)
downloadqtmaildir-78b3a9c1769d37ff7344360b6fed66b12b2f0649.tar.gz
qtmaildir-78b3a9c1769d37ff7344360b6fed66b12b2f0649.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp23
1 files changed, 20 insertions, 3 deletions
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