MCPcopy Create free account
hub / github.com/TeXworks/texworks / search

Method search

modules/QtPDF/src/PDFDocumentView.cpp:800–830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

798}
799
800void 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
832void PDFDocumentView::nextSearchResult()
833{

Callers

nothing calls this directly

Calls 9

documentFunction · 0.85
searchStringMethod · 0.80
searchFlagsMethod · 0.80
ensureStoppedMethod · 0.80
setSearchStringMethod · 0.80
setSearchFlagsMethod · 0.80
setStartPageMethod · 0.80
startMethod · 0.80
setDocumentMethod · 0.45

Tested by

no test coverage detected