diff options
Diffstat (limited to 'src/pdf/qpdfsearchmodel.cpp')
-rw-r--r-- | src/pdf/qpdfsearchmodel.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pdf/qpdfsearchmodel.cpp b/src/pdf/qpdfsearchmodel.cpp index a8946ccfe..3109430f0 100644 --- a/src/pdf/qpdfsearchmodel.cpp +++ b/src/pdf/qpdfsearchmodel.cpp @@ -20,7 +20,6 @@ Q_LOGGING_CATEGORY(qLcS, "qt.pdf.search") static const int UpdateTimerInterval = 100; static const int ContextChars = 64; -static const double CharacterHitTolerance = 6.0; /*! \class QPdfSearchModel @@ -195,11 +194,23 @@ void QPdfSearchModel::setDocument(QPdfDocument *document) if (d->document == document) return; + disconnect(d->documentConnection); + d->documentConnection = connect(document, &QPdfDocument::pageCountChanged, this, + &QPdfSearchModel::onDocumentPageCountChanged); + d->document = document; d->clearResults(); emit documentChanged(); } +void QPdfSearchModel::onDocumentPageCountChanged(int count) +{ + Q_UNUSED(count); + + Q_D(QPdfSearchModel); + d->clearResults(); +} + void QPdfSearchModel::timerEvent(QTimerEvent *event) { Q_D(QPdfSearchModel); @@ -257,6 +268,7 @@ bool QPdfSearchModelPrivate::doSearch(int page) } FPDF_SCHHANDLE sh = FPDFText_FindStart(textPage, searchString.utf16(), 0, 0); QList<QPdfLink> newSearchResults; + constexpr double CharacterHitTolerance = 6.0; while (FPDFText_FindNext(sh)) { int idx = FPDFText_GetSchResultIndex(sh); int count = FPDFText_GetSchCount(sh); |