| 798 | } |
| 799 | |
| 800 | void PDFDocumentView::search(QString searchText, Backend::SearchFlags flags /* = Backend::Search_CaseInsensitive */) |
| 801 | { |
| 802 | if (!_pdf_scene) |
| 803 | return; |
| 804 | |
| 805 | // If `searchText` is the same as for the last search, focus on the next |
| 806 | // search result. |
| 807 | // Note: The primary use case for this is hitting `Enter` several times in the |
| 808 | // search box to go to the next result. |
| 809 | // On the other hand, with this there is no easy way to abort a long-running |
| 810 | // search (e.g., in a large document) and restarting it in another part by |
| 811 | // simply going there and hitting `Enter` again. As a workaround, one can |
| 812 | // change the search text in that case (e.g., to something meaningless and |
| 813 | // then back again to abort the previous search and restart at the new |
| 814 | // location). |
| 815 | if (searchText == _searcher.searchString() && flags == _searcher.searchFlags()) { |
| 816 | nextSearchResult(); |
| 817 | return; |
| 818 | } |
| 819 | |
| 820 | _searcher.ensureStopped(); |
| 821 | |
| 822 | clearSearchResults(); |
| 823 | _currentSearchResult = -1; |
| 824 | |
| 825 | _searcher.setSearchString(searchText); |
| 826 | _searcher.setSearchFlags(flags); |
| 827 | _searcher.setDocument(document()); |
| 828 | _searcher.setStartPage(currentPage()); |
| 829 | _searcher.start(); |
| 830 | } |
| 831 | |
| 832 | void PDFDocumentView::nextSearchResult() |
| 833 | { |
nothing calls this directly
no test coverage detected