From 43f26916a5716ddcd2270c513f15a62b183929bb Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Tue, 1 Oct 2019 08:17:50 +0200 Subject: Improve QWebEngineFindTextResult API Implements suggestions from 5.14 API review: - Rename activeMatchOrdinal to activeMatch - Extend documentation - Change QML import version number to 1.10 Task-number: QTBUG-77839 Change-Id: I5eae659cfb5355af8d0c878d3b5f00654c9d6d13 Reviewed-by: Leena Miettinen Reviewed-by: Allan Sandfeld Jensen --- src/core/api/qwebenginefindtextresult.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/core/api/qwebenginefindtextresult.cpp') 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 -- cgit v1.2.3