MCPcopy Create free account
hub / github.com/KDE/okular / doContinueAllDocumentSearch

Method doContinueAllDocumentSearch

core/document.cpp:1793–1880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1791}
1792
1793void DocumentPrivate::doContinueAllDocumentSearch(QSet<int> *pagesToNotify, QHash<Page *, QList<RegularAreaRect *>> *pageMatches, int currentPage, int searchID)
1794{
1795 RunningSearch *search = m_searches.value(searchID);
1796
1797 if (m_searchCancelled || !search) {
1798 typedef QList<RegularAreaRect *> Matches;
1799
1800 QApplication::restoreOverrideCursor();
1801
1802 if (search) {
1803 search->isCurrentlySearching = false;
1804 }
1805
1806 Q_EMIT m_parent->searchFinished(searchID, Document::SearchCancelled);
1807 for (const Matches &mv : std::as_const(*pageMatches)) {
1808 qDeleteAll(mv);
1809 }
1810 delete pageMatches;
1811 delete pagesToNotify;
1812 return;
1813 }
1814
1815 if (currentPage < m_pagesVector.count()) {
1816 // get page (from the first to the last)
1817 Page *page = m_pagesVector.at(currentPage);
1818
1819 // request search page if needed
1820 if (!page->hasTextPage()) {
1821 int pageNumber = page->number(); // redundant? is it == currentPage ?
1822 m_parent->requestTextPage(pageNumber);
1823 }
1824
1825 // loop on a page adding highlights for all found items
1826 RegularAreaRect *lastMatch = nullptr;
1827 while (true) {
1828 if (lastMatch) {
1829 lastMatch = page->findText(searchID, search->cachedString, NextResult, search->cachedCaseSensitivity, lastMatch);
1830 } else {
1831 lastMatch = page->findText(searchID, search->cachedString, FromTop, search->cachedCaseSensitivity);
1832 }
1833
1834 if (!lastMatch) {
1835 break;
1836 }
1837
1838 // add highlight rect to the matches map
1839 (*pageMatches)[page].append(lastMatch);
1840 }
1841 delete lastMatch;
1842
1843 QTimer::singleShot(0, m_parent, [this, pagesToNotify, pageMatches, currentPage, searchID] { doContinueAllDocumentSearch(pagesToNotify, pageMatches, currentPage + 1, searchID); });
1844 } else {
1845 // reset cursor to previous shape
1846 QApplication::restoreOverrideCursor();
1847
1848 search->isCurrentlySearching = false;
1849 bool foundAMatch = pageMatches->count() != 0;
1850 for (auto [key, value] : pageMatches->asKeyValueRange()) {

Callers 1

searchTextMethod · 0.80

Calls 10

hasTextPageMethod · 0.80
numberMethod · 0.80
requestTextPageMethod · 0.80
appendMethod · 0.80
setHighlightMethod · 0.80
valueMethod · 0.45
countMethod · 0.45
findTextMethod · 0.45
notifySetupMethod · 0.45
notifyPageChangedMethod · 0.45

Tested by

no test coverage detected