From ef7c9c67bfaf8cdaadd3a58d8b8257887dff24f7 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 26 Sep 2017 23:26:05 +0200 Subject: [PATCH] Implement continuous search Show non-intrusive info messages whenever the search start over from the beginning or the bottom of the document, instead of asking the user if s/he wants to continue the search. This is consistent with search in KWrite/Kate and with web browsers. Based on work of and reviewed by Elvis Angelaccio --- core/document.cpp | 14 ++++++++------ core/document.h | 3 ++- ui/searchlineedit.cpp | 9 --------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/core/document.cpp b/core/document.cpp index 91c623b58..564c6479f 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -1609,13 +1609,15 @@ void DocumentPrivate::doContinueDirectionMatchSearch(void *doContinueDirectionMa if (search->pagesDone < pageCount) { doContinue = true; - if ( searchStruct->currentPage >= pageCount || searchStruct->currentPage < 0 ) + if ( searchStruct->currentPage >= pageCount ) { - doContinue = false; - search->isCurrentlySearching = false; - search->continueOnPage = forward ? 0 : pageCount - 1; - search->continueOnMatch = RegularAreaRect(); - emit m_parent->searchFinished ( searchStruct->searchID, Document::EndOfDocumentReached ); + searchStruct->currentPage = 0; + emit m_parent->notice(i18n("Continuing search from beginning"), 3000); + } + else if ( searchStruct->currentPage < 0 ) + { + searchStruct->currentPage = pageCount - 1; + emit m_parent->notice(i18n("Continuing search from bottom"), 3000); } } } diff --git a/core/document.h b/core/document.h index 124526289..a52dedd20 100644 --- a/core/document.h +++ b/core/document.h @@ -608,12 +608,13 @@ class OKULARCORE_EXPORT Document : public QObject /** * Describes how search ended */ + // TODO remove EndOfDocumentReached when we break API enum SearchStatus { MatchFound, ///< Any match was found NoMatchFound, ///< No match was found SearchCancelled, ///< The search was cancelled - EndOfDocumentReached ///< The end of document was reached without any match @since 0.20 (KDE 4.14) + EndOfDocumentReached ///< This is not ever emitted since 1.3. The end of document was reached without any match @since 0.20 (KDE 4.14) }; /** diff --git a/ui/searchlineedit.cpp b/ui/searchlineedit.cpp index 74e6ef60c..7d6612928 100644 --- a/ui/searchlineedit.cpp +++ b/ui/searchlineedit.cpp @@ -271,15 +271,6 @@ void SearchLineEdit::searchFinished( int id, Okular::Document::SearchStatus endS setPalette( pal ); } - if ( endStatus == Okular::Document::EndOfDocumentReached ) { - const bool forward = m_searchType == Okular::Document::NextMatch; - const QString question = forward ? i18n("End of document reached.\nContinue from the beginning?") : i18n("Beginning of document reached.\nContinue from the bottom?"); - if ( KMessageBox::questionYesNo(window(), question, QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::Yes ) { - m_document->continueSearch( m_id, m_searchType ); - return; - } - } - m_searchRunning = false; emit searchStopped(); }