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

Method findText

core/textpage.cpp:550–603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548}
549
550RegularAreaRect *TextPage::findText(int searchID, const QString &query, SearchDirection direct, Qt::CaseSensitivity caseSensitivity, const RegularAreaRect *area)
551{
552 SearchDirection dir = direct;
553 // invalid search request
554 if (d->m_words.isEmpty() || query.isEmpty() || (area && area->isNull())) {
555 return nullptr;
556 }
557 TextEntity::List::ConstIterator start;
558 int start_offset = 0;
559 TextEntity::List::ConstIterator end;
560 const QMap<int, SearchPoint *>::const_iterator sIt = d->m_searchPoints.constFind(searchID);
561 if (sIt == d->m_searchPoints.constEnd()) {
562 // if no previous run of this search is found, then set it to start
563 // from the beginning (respecting the search direction)
564 if (dir == NextResult) {
565 dir = FromTop;
566 } else if (dir == PreviousResult) {
567 dir = FromBottom;
568 }
569 }
570 bool forward = true;
571 switch (dir) {
572 case FromTop:
573 start = d->m_words.constBegin();
574 start_offset = 0;
575 end = d->m_words.constEnd();
576 break;
577 case FromBottom:
578 start = d->m_words.constEnd();
579 start_offset = 0;
580 end = d->m_words.constBegin();
581 forward = false;
582 break;
583 case NextResult:
584 start = (*sIt)->it_end;
585 start_offset = (*sIt)->offset_end;
586 end = d->m_words.constEnd();
587 break;
588 case PreviousResult:
589 start = (*sIt)->it_begin;
590 start_offset = (*sIt)->offset_begin;
591 end = d->m_words.constBegin();
592 forward = false;
593 break;
594 };
595 RegularAreaRect *ret = nullptr;
596 const TextComparisonFunction cmpFn = caseSensitivity == Qt::CaseSensitive ? CaseSensitiveCmpFn : CaseInsensitiveCmpFn;
597 if (forward) {
598 ret = d->findTextInternalForward(searchID, query, cmpFn, start, start_offset, end);
599 } else {
600 ret = d->findTextInternalBackward(searchID, query, cmpFn, start, start_offset, end);
601 }
602 return ret;
603}
604
605// hyphenated '-' must be at the end of a word, so hyphenation means
606// we have a '-' just followed by a '\n' character

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.80
isNullMethod · 0.45

Tested by

no test coverage detected