diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/api/qwebenginefindtextresult.cpp | 24 | ||||
-rw-r--r-- | src/core/api/qwebenginefindtextresult.h | 6 | ||||
-rw-r--r-- | src/core/find_text_helper.cpp | 4 | ||||
-rw-r--r-- | src/core/find_text_helper.h | 2 | ||||
-rw-r--r-- | src/webengine/doc/src/webengineview_lgpl.qdoc | 4 |
5 files changed, 26 insertions, 14 deletions
diff --git a/src/core/api/qwebenginefindtextresult.cpp b/src/core/api/qwebenginefindtextresult.cpp index ce1be359e..c0adc6177 100644 --- a/src/core/api/qwebenginefindtextresult.cpp +++ b/src/core/api/qwebenginefindtextresult.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE class QWebEngineFindTextResultPrivate : public QSharedData { public: int numberOfMatches = 0; - int activeMatchOrdinal = 0; + int activeMatch = 0; }; /*! @@ -54,6 +54,18 @@ public: \inmodule QtWebEngineCore + The string search can be initiated by the \l QWebEnginePage::findText() or + \l{WebEngineView::findText()}{WebEngineView.findText()} method. The results of the search + are highlighted in the view. The details of this result are passed as a + QWebEngineFindTextResult object that can be used to show a status message, + such as "2 of 2 matches". For example: + + \code + QObject::connect(view.page(), &QWebEnginePage::findTextFinished, [](const QWebEngineFindTextResult &result) { + qInfo() << result.activeMatch() << "of" << result.numberOfMatches() << "matches"; + }); + \endcode + Results are passed to the user in the \l QWebEnginePage::findTextFinished() and \l{WebEngineView::findTextFinished()}{WebEngineView.findTextFinished()} signals. @@ -67,11 +79,11 @@ QWebEngineFindTextResult::QWebEngineFindTextResult() /*! \internal */ -QWebEngineFindTextResult::QWebEngineFindTextResult(int numberOfMatches, int activeMatchOrdinal) +QWebEngineFindTextResult::QWebEngineFindTextResult(int numberOfMatches, int activeMatch) : d(new QWebEngineFindTextResultPrivate) { d->numberOfMatches = numberOfMatches; - d->activeMatchOrdinal = activeMatchOrdinal; + d->activeMatch = activeMatch; } /*! \internal @@ -103,12 +115,12 @@ int QWebEngineFindTextResult::numberOfMatches() const } /*! - \property QWebEngineFindTextResult::activeMatchOrdinal + \property QWebEngineFindTextResult::activeMatch \brief The index of the currently highlighted match. */ -int QWebEngineFindTextResult::activeMatchOrdinal() const +int QWebEngineFindTextResult::activeMatch() const { - return d->activeMatchOrdinal; + return d->activeMatch; } QT_END_NAMESPACE diff --git a/src/core/api/qwebenginefindtextresult.h b/src/core/api/qwebenginefindtextresult.h index 073a8135f..246e689c3 100644 --- a/src/core/api/qwebenginefindtextresult.h +++ b/src/core/api/qwebenginefindtextresult.h @@ -55,11 +55,11 @@ class QWebEngineFindTextResultPrivate; class Q_WEBENGINECORE_EXPORT QWebEngineFindTextResult { Q_GADGET Q_PROPERTY(int numberOfMatches READ numberOfMatches CONSTANT FINAL) - Q_PROPERTY(int activeMatchOrdinal READ activeMatchOrdinal CONSTANT FINAL) + Q_PROPERTY(int activeMatch READ activeMatch CONSTANT FINAL) public: int numberOfMatches() const; - int activeMatchOrdinal() const; + int activeMatch() const; QWebEngineFindTextResult(); QWebEngineFindTextResult(const QWebEngineFindTextResult &other); @@ -67,7 +67,7 @@ public: ~QWebEngineFindTextResult(); private: - QWebEngineFindTextResult(int numberOfMatches, int activeMatchOrdinal); + QWebEngineFindTextResult(int numberOfMatches, int activeMatch); QSharedDataPointer<QWebEngineFindTextResultPrivate> d; diff --git a/src/core/find_text_helper.cpp b/src/core/find_text_helper.cpp index effda529f..065fed38f 100644 --- a/src/core/find_text_helper.cpp +++ b/src/core/find_text_helper.cpp @@ -135,7 +135,7 @@ bool FindTextHelper::isFindTextInProgress() const } void FindTextHelper::handleFindReply(content::WebContents *source, int requestId, int numberOfMatches, - const gfx::Rect &selectionRect, int activeMatchOrdinal, bool finalUpdate) + const gfx::Rect &selectionRect, int activeMatch, bool finalUpdate) { Q_UNUSED(selectionRect); @@ -146,7 +146,7 @@ void FindTextHelper::handleFindReply(content::WebContents *source, int requestId Q_ASSERT(m_currentFindRequestId == requestId); m_lastCompletedFindRequestId = requestId; - m_viewClient->findTextFinished(QWebEngineFindTextResult(numberOfMatches, activeMatchOrdinal)); + m_viewClient->findTextFinished(QWebEngineFindTextResult(numberOfMatches, activeMatch)); invokeResultCallback(requestId, numberOfMatches); } diff --git a/src/core/find_text_helper.h b/src/core/find_text_helper.h index e8f186272..9843dc8b5 100644 --- a/src/core/find_text_helper.h +++ b/src/core/find_text_helper.h @@ -78,7 +78,7 @@ public: void startFinding(const QString &findText, bool caseSensitively, bool findBackward); void stopFinding(); bool isFindTextInProgress() const; - void handleFindReply(content::WebContents *source, int requestId, int numberOfMatches, const gfx::Rect &selectionRect, int activeMatchOrdinal, bool finalUpdate); + void handleFindReply(content::WebContents *source, int requestId, int numberOfMatches, const gfx::Rect &selectionRect, int activeMatch, bool finalUpdate); void handleLoadCommitted(); private: diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc index 3a7717bd2..df956f03e 100644 --- a/src/webengine/doc/src/webengineview_lgpl.qdoc +++ b/src/webengine/doc/src/webengineview_lgpl.qdoc @@ -1599,7 +1599,7 @@ */ /*! - \qmlproperty int FindTextResult::activeMatchOrdinal + \qmlproperty int FindTextResult::activeMatch \readonly \brief The index of the currently highlighted match. @@ -1607,7 +1607,7 @@ /*! \qmlsignal WebEngineView::findTextFinished(FindTextResult result) - \since QtWebEngine 1.11 + \since QtWebEngine 1.10 This signal is emitted when a string search on a page is completed. \a result is the result of the string search. |