diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2020-01-29 14:59:19 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-30 15:27:53 +0100 |
commit | cec9604fbf0ac13cca56ae55dc3213f8eba78a65 (patch) | |
tree | 56dd154460bb69c862d2833f97dfbc8169bd9289 | |
parent | 95ec7e63ceb051a861a08a0885fe26a3c42de424 (diff) |
Add clear method to QQuickWebEngineHistory
Fixes: QTBUG-71619
Change-Id: I35c5ecbbe78da3114d30945f8ce030937e17d98e
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r-- | src/webengine/api/qquickwebenginehistory.cpp | 14 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginehistory_p.h | 1 | ||||
-rw-r--r-- | src/webengine/plugin/plugin.cpp | 1 | ||||
-rw-r--r-- | tests/auto/quick/publicapi/tst_publicapi.cpp | 1 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_navigationHistory.qml | 7 |
5 files changed, 24 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp index d3c4a0026..e77974a0f 100644 --- a/src/webengine/api/qquickwebenginehistory.cpp +++ b/src/webengine/api/qquickwebenginehistory.cpp @@ -327,6 +327,20 @@ QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::forwardItems() const return d->m_forwardNavigationModel.data(); } +/*! + \qmlmethod void WebEngineHistory::clear() + \since QtWebEngine 1.11 + + Clears the history. +*/ +void QQuickWebEngineHistory::clear() +{ + Q_D(QQuickWebEngineHistory); + d->m_view->adapter->clearNavigationHistory(); + d->m_view->updateNavigationActions(); + reset(); +} + void QQuickWebEngineHistory::reset() { Q_D(QQuickWebEngineHistory); diff --git a/src/webengine/api/qquickwebenginehistory_p.h b/src/webengine/api/qquickwebenginehistory_p.h index bf049b2a6..5d4783e96 100644 --- a/src/webengine/api/qquickwebenginehistory_p.h +++ b/src/webengine/api/qquickwebenginehistory_p.h @@ -107,6 +107,7 @@ public: QQuickWebEngineHistoryListModel *items() const; QQuickWebEngineHistoryListModel *backItems() const; QQuickWebEngineHistoryListModel *forwardItems() const; + Q_REVISION(1) Q_INVOKABLE void clear(); void reset(); diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index 3acf7d058..ecd381371 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -137,6 +137,7 @@ public: qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 1, "WebEngine", webEngineSingletonProvider); qmlRegisterUncreatableType<QQuickWebEngineHistory>(uri, 1, 1, "NavigationHistory", msgUncreatableType("NavigationHistory")); + qmlRegisterUncreatableType<QQuickWebEngineHistory, 1>(uri, 1, 11, "NavigationHistory", msgUncreatableType("NavigationHistory")); qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel", msgUncreatableType("NavigationHistory")); qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest", diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index 321972057..3c97f2410 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -300,6 +300,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineFullScreenRequest.reject() --> void" << "QQuickWebEngineFullScreenRequest.toggleOn --> bool" << "QQuickWebEngineHistory.backItems --> QQuickWebEngineHistoryListModel*" + << "QQuickWebEngineHistory.clear() --> void" << "QQuickWebEngineHistory.forwardItems --> QQuickWebEngineHistoryListModel*" << "QQuickWebEngineHistory.items --> QQuickWebEngineHistoryListModel*" << "QQuickWebEngineJavaScriptDialogRequest.DialogTypeAlert --> DialogType" diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml index 77664e645..6ed232589 100644 --- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml +++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml @@ -134,6 +134,13 @@ TestWebEngineView { compare(forwardItemsList.count, 1) compare(backItemsList.currentItem.text, Qt.resolvedUrl("test1.html")) compare(forwardItemsList.currentItem.text, Qt.resolvedUrl("javascript.html")) + + webEngineView.navigationHistory.clear() + compare(webEngineView.url, Qt.resolvedUrl("test2.html")) + compare(webEngineView.canGoBack, false) + compare(webEngineView.canGoForward, false) + compare(backItemsList.count, 0) + compare(forwardItemsList.count, 0) } } } |