summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2015-03-03 01:44:51 -0800
committerSzabolcs David <davidsz@inf.u-szeged.hu>2015-03-04 20:46:23 +0000
commit594dbb09fbeb4303d49f7297922c094c0d800e1d (patch)
treeea83cefc9f3a973c2bf898594b645df17a6a0d15
parent378fbbcbc9c65d1462ea6994f1f680412531a043 (diff)
Move findText to the public API
- Add a default 0 value for the FindFlags parameter - Update tests and examples - Import documentation from the Widgets side Change-Id: Ifb627a81247028416bc7a31068676ea871f6dcf4 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
-rw-r--r--src/webengine/api/qquickwebengineview.cpp2
-rw-r--r--src/webengine/api/qquickwebengineview_p.h8
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h8
-rw-r--r--src/webengine/doc/src/qquickwebengineview_lgpl.qdoc52
-rw-r--r--tests/auto/quick/qmltests/data/tst_findText.qml15
-rw-r--r--tests/quicktestbrowser/BrowserWindow.qml6
6 files changed, 71 insertions, 20 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index c1d2ac2b..6fa3798c 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -806,7 +806,7 @@ QQmlComponent *QQuickWebEngineViewExperimental::extraContextMenuEntriesComponent
return d_ptr->contextMenuExtraItems;
}
-void QQuickWebEngineViewExperimental::findText(const QString &subString, FindFlags options, const QJSValue &callback)
+void QQuickWebEngineView::findText(const QString &subString, FindFlags options, const QJSValue &callback)
{
Q_D(QQuickWebEngineView);
if (!d->adapter)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 93e9ad61..3ff6ab66 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -75,6 +75,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_ENUMS(ErrorDomain);
Q_ENUMS(NewViewDestination);
Q_ENUMS(JavaScriptConsoleMessageLevel);
+ Q_FLAGS(FindFlags);
public:
QQuickWebEngineView(QQuickItem *parent = 0);
@@ -142,6 +143,12 @@ public:
ErrorMessageLevel
};
+ enum FindFlag {
+ FindBackward = 1,
+ FindCaseSensitively = 2,
+ };
+ Q_DECLARE_FLAGS(FindFlags, FindFlag)
+
// QmlParserStatus
virtual void componentComplete() Q_DECL_OVERRIDE;
@@ -162,6 +169,7 @@ public Q_SLOTS:
void goBackOrForward(int index);
void reload();
void stop();
+ Q_REVISION(1) void findText(const QString &subString, FindFlags options = 0, const QJSValue &callback = QJSValue());
Q_SIGNALS:
void titleChanged();
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 377dcc91..7a33605d 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -81,7 +81,6 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewExperimental : public QObjec
Q_PROPERTY(QQmlComponent *extraContextMenuEntriesComponent READ extraContextMenuEntriesComponent WRITE setExtraContextMenuEntriesComponent NOTIFY extraContextMenuEntriesComponentChanged)
Q_PROPERTY(bool isFullScreen READ isFullScreen WRITE setIsFullScreen NOTIFY isFullScreenChanged)
Q_ENUMS(Feature)
- Q_FLAGS(FindFlags)
public:
enum Feature {
@@ -91,12 +90,6 @@ public:
Geolocation
};
- enum FindFlag {
- FindBackward = 1,
- FindCaseSensitively = 2,
- };
- Q_DECLARE_FLAGS(FindFlags, FindFlag)
-
void setIsFullScreen(bool fullscreen);
bool isFullScreen() const;
QQuickWebEngineViewport *viewport() const;
@@ -104,7 +97,6 @@ public:
QQmlComponent *extraContextMenuEntriesComponent() const;
public Q_SLOTS:
- void findText(const QString&, FindFlags, const QJSValue & = QJSValue());
void grantFeaturePermission(const QUrl &securityOrigin, Feature, bool granted);
Q_SIGNALS:
diff --git a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc b/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc
index b3e7779f..73c084da 100644
--- a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc
@@ -206,6 +206,45 @@
*/
/*!
+ \qmlmethod void WebEngineView::findText(string subString)
+ \since QtWebEngine 1.1
+ Finds the specified string, \a subString, in the page.
+
+ To clear the selection, just pass an empty string.
+*/
+
+/*!
+ \qmlmethod void WebEngineView::findText(string subString, FindFlags options)
+ \since QtWebEngine 1.1
+ Finds the specified string, \a subString, in the page, using the given \a options.
+
+ To clear the selection, just pass an empty string.
+
+ \code
+ findText("Qt", WebEngineView.FindBackward | WebEngineView.FindCaseSensitively);
+ \endcode
+*/
+
+/*!
+ \qmlmethod void WebEngineView::findText(string subString, FindFlags options, variant resultCallback)
+ \since QtWebEngine 1.1
+ Finds the specified string, \a subString, in the page, using the given \a options.
+
+ To clear the selection, just pass an empty string.
+
+ The \a resultCallback must take a boolean parameter. It will be called with
+ a value of true if the \a subString was found; otherwise the callback value
+ will be false.
+
+ \code
+ findText("Qt", WebEngineView.FindCaseSensitively, function(success) {
+ if (success)
+ console.log("Qt was found!");
+ });
+ \endcode
+*/
+
+/*!
\qmlsignal WebEngineView::loadingChanged(loadRequest)
This signal is emitted when a page load begins, ends, or fails.
@@ -364,3 +403,16 @@
\sa WebEngineNewViewRequest::destination
*/
+
+/*!
+ \qmlproperty enumeration WebEngineView::FindFlags
+
+ This enum describes the options available to the findText() function. The options
+ can be OR-ed together from the following list:
+
+ \value FindBackward Searches backwards instead of forwards.
+ \value FindCaseSensitively By default findText() works case insensitive. Specifying
+ this option changes the behavior to a case sensitive find operation.
+
+ \sa WebEngineView::findText()
+*/
diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml
index 1cb23a1c..5f72c52f 100644
--- a/tests/auto/quick/qmltests/data/tst_findText.qml
+++ b/tests/auto/quick/qmltests/data/tst_findText.qml
@@ -42,7 +42,6 @@
import QtQuick 2.0
import QtTest 1.0
import QtWebEngine 1.1
-import QtWebEngine.experimental 1.0
TestWebEngineView {
id: webEngineView
@@ -67,12 +66,12 @@ TestWebEngineView {
name: "WebViewFindText"
function test_findText() {
- var findFlags = WebEngineViewExperimental.FindCaseSensitively
+ var findFlags = WebEngineView.FindCaseSensitively
webEngineView.url = Qt.resolvedUrl("test1.html")
verify(webEngineView.waitForLoadSucceeded())
webEngineView.clear()
- webEngineView.experimental.findText("Hello", findFlags, webEngineView.findTextCallback)
+ webEngineView.findText("Hello", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 1)
verify(!findFailed)
}
@@ -83,7 +82,7 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded())
webEngineView.clear()
- webEngineView.experimental.findText("heLLo", findFlags, webEngineView.findTextCallback)
+ webEngineView.findText("heLLo", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 1)
verify(!findFailed)
}
@@ -94,19 +93,19 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded())
webEngineView.clear()
- webEngineView.experimental.findText("bla", findFlags, webEngineView.findTextCallback)
+ webEngineView.findText("bla", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 100)
verify(!findFailed)
}
function test_findTextFailCaseSensitive() {
- var findFlags = WebEngineViewExperimental.FindCaseSensitively
+ var findFlags = WebEngineView.FindCaseSensitively
webEngineView.url = Qt.resolvedUrl("test1.html")
verify(webEngineView.waitForLoadSucceeded())
webEngineView.clear()
- webEngineView.experimental.findText("heLLo", findFlags, webEngineView.findTextCallback)
+ webEngineView.findText("heLLo", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 0)
verify(findFailed)
}
@@ -117,7 +116,7 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded())
webEngineView.clear()
- webEngineView.experimental.findText("string-that-is-not-threre", findFlags, webEngineView.findTextCallback)
+ webEngineView.findText("string-that-is-not-threre", findFlags, webEngineView.findTextCallback)
tryCompare(webEngineView, "matchCount", 0)
verify(findFailed)
}
diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml
index b111edb6..cb7de84d 100644
--- a/tests/quicktestbrowser/BrowserWindow.qml
+++ b/tests/quicktestbrowser/BrowserWindow.qml
@@ -418,18 +418,18 @@ ApplicationWindow {
TextField {
id: findTextField
onAccepted: {
- webEngineView.experimental.findText(text, 0)
+ webEngineView.findText(text)
}
}
ToolButton {
id: findBackwardButton
iconSource: "icons/go-previous.png"
- onClicked: webEngineView.experimental.findText(findTextField.text, WebEngineViewExperimental.FindBackward)
+ onClicked: webEngineView.findText(findTextField.text, WebEngineView.FindBackward)
}
ToolButton {
id: findForwardButton
iconSource: "icons/go-next.png"
- onClicked: webEngineView.experimental.findText(findTextField.text, 0)
+ onClicked: webEngineView.findText(findTextField.text)
}
ToolButton {
id: findCancelButton