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 --- tests/test_mainwindow.cpp | 9 ++++++--- tests/test_messagedetailsdialog.cpp | 14 ++++++++------ tests/test_messageview.cpp | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/test_mainwindow.cpp b/tests/test_mainwindow.cpp index 8b60e37..0bf8925 100644 --- a/tests/test_mainwindow.cpp +++ b/tests/test_mainwindow.cpp @@ -3741,7 +3741,8 @@ void TestMainWindow::aSearchFromThePaneReplacesTheQuery() QVERIFY2(view, "no message view"); queryEdit->setText(QStringLiteral("tag:inbox")); - emit view->searchRequested(QStringLiteral("from:\"foo@example.org\""), false); + emit view->searchRequested(QStringLiteral("from:\"foo@example.org\""), + SearchTerm::SearchMode::Replace); QCOMPARE(queryEdit->text(), QStringLiteral("from:\"foo@example.org\"")); } @@ -3763,7 +3764,8 @@ void TestMainWindow::aSearchFromThePaneCanNarrowTheQuery() QVERIFY2(view, "no message view"); queryEdit->setText(QStringLiteral("tag:inbox or tag:flagged")); - emit view->searchRequested(QStringLiteral("from:\"foo@example.org\""), true); + emit view->searchRequested(QStringLiteral("from:\"foo@example.org\""), + SearchTerm::SearchMode::Narrow); QCOMPARE(queryEdit->text(), QStringLiteral("(tag:inbox or tag:flagged) AND (from:\"foo@example.org\")")); @@ -3783,7 +3785,8 @@ void TestMainWindow::narrowingAnEmptyQueryBarIsAPlainSearch() QVERIFY2(view, "no message view"); queryEdit->clear(); - emit view->searchRequested(QStringLiteral("tag:inbox"), true); + emit view->searchRequested(QStringLiteral("tag:inbox"), + SearchTerm::SearchMode::Narrow); QCOMPARE(queryEdit->text(), QStringLiteral("tag:inbox")); } diff --git a/tests/test_messagedetailsdialog.cpp b/tests/test_messagedetailsdialog.cpp index 4e685ce..403750b 100644 --- a/tests/test_messagedetailsdialog.cpp +++ b/tests/test_messagedetailsdialog.cpp @@ -131,13 +131,15 @@ void TestMessageDetailsDialog::offersASearchForEachValue() QVERIFY2(date != rows.cend(), "no Date row"); QCOMPARE(date->query, QStringLiteral("date:2026-08-14..2026-08-14")); - // Replacing and narrowing are both offered, and the flag distinguishes them. - dialog.requestSearch(*from, false); - dialog.requestSearch(*from, true); + // Replacing and narrowing are both offered, and the mode distinguishes them. + dialog.requestSearch(*from, SearchTerm::SearchMode::Replace); + dialog.requestSearch(*from, SearchTerm::SearchMode::Narrow); QCOMPARE(spy.count(), 2); QCOMPARE(spy.at(0).at(0).toString(), from->query); - QCOMPARE(spy.at(0).at(1).toBool(), false); - QCOMPARE(spy.at(1).at(1).toBool(), true); + QCOMPARE(spy.at(0).at(1).value(), + SearchTerm::SearchMode::Replace); + QCOMPARE(spy.at(1).at(1).value(), + SearchTerm::SearchMode::Narrow); } void TestMessageDetailsDialog::omitsAnEmptyHeader() @@ -174,7 +176,7 @@ void TestMessageDetailsDialog::messageIdIsShownButNotSearchable() // And asking to search it emits nothing rather than an empty query. QSignalSpy spy(&dialog, &MessageDetailsDialog::searchRequested); - dialog.requestSearch(*id, false); + dialog.requestSearch(*id, SearchTerm::SearchMode::Replace); QCOMPARE(spy.count(), 0); } diff --git a/tests/test_messageview.cpp b/tests/test_messageview.cpp index edcba03..c97a216 100644 --- a/tests/test_messageview.cpp +++ b/tests/test_messageview.cpp @@ -734,7 +734,7 @@ void TestMessageView::aSearchFromTheDetailsDialogClosesIt() return; } - dialog->requestSearch(*from, false); + dialog->requestSearch(*from, SearchTerm::SearchMode::Replace); }); view.showDetailsDialog(); -- cgit v1.2.3