From 742b9db0e34c8fc08e9f50c3053aed5f501f08d2 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 18 Dec 2020 20:02:02 +0100 Subject: Merge WebEngineHistory's quick implementation into QWebEngineHistory [ChangeLog][QWebEngineCore][QWebEngineHistory] New methods to access navigation history as a model through new class QWebEngineHistoryModel. [ChangeLog][QWebEngineQuick] QQuickWebEngineHistory is merged into QWebEngineHistory. Task-number: QTBUG-74585 Change-Id: I9f9a73bbaf3954282dfc220cfc2c4cb08a37fb73 Reviewed-by: Allan Sandfeld Jensen --- src/core/api/qwebenginehistory_p.h | 60 ++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 5 deletions(-) (limited to 'src/core/api/qwebenginehistory_p.h') diff --git a/src/core/api/qwebenginehistory_p.h b/src/core/api/qwebenginehistory_p.h index 2ca944e5b..fb52f799c 100644 --- a/src/core/api/qwebenginehistory_p.h +++ b/src/core/api/qwebenginehistory_p.h @@ -51,33 +51,83 @@ // We mean it. // #include "qtwebenginecoreglobal_p.h" +#include "qwebenginehistory.h" #include namespace QtWebEngineCore { +class WebContentsAdapter; class WebContentsAdapterClient; } QT_BEGIN_NAMESPACE + class QWebEnginePagePrivate; class QWebEngineHistoryItemPrivate : public QSharedData { public: - QWebEngineHistoryItemPrivate(QtWebEngineCore::WebContentsAdapterClient *adapter = nullptr, - int index = 0); - QtWebEngineCore::WebContentsAdapterClient *m_adapter; + QWebEngineHistoryItemPrivate(QtWebEngineCore::WebContentsAdapterClient *client = nullptr, int index = 0); + QtWebEngineCore::WebContentsAdapter *adapter() const; + QtWebEngineCore::WebContentsAdapterClient *client; int index; }; +class QWebEngineHistoryModelPrivate +{ +public: + QWebEngineHistoryModelPrivate(const QWebEngineHistoryPrivate *history); + virtual ~QWebEngineHistoryModelPrivate(); + + virtual int count() const; + virtual int index(int) const; + virtual int offsetForIndex(int) const; + + QtWebEngineCore::WebContentsAdapter *adapter() const; + const QWebEngineHistoryPrivate *history; +}; + +class QWebEngineBackHistoryModelPrivate : public QWebEngineHistoryModelPrivate +{ +public: + QWebEngineBackHistoryModelPrivate(const QWebEngineHistoryPrivate *history) + : QWebEngineHistoryModelPrivate(history) { } + + int count() const override; + int index(int) const override; + int offsetForIndex(int) const override; +}; + +class QWebEngineForwardHistoryModelPrivate : public QWebEngineHistoryModelPrivate +{ +public: + QWebEngineForwardHistoryModelPrivate(const QWebEngineHistoryPrivate *history) + : QWebEngineHistoryModelPrivate(history) { } + + int count() const override; + int index(int) const override; + int offsetForIndex(int) const override; +}; + class Q_WEBENGINECORE_PRIVATE_EXPORT QWebEngineHistoryPrivate { public: - QWebEngineHistoryPrivate(QtWebEngineCore::WebContentsAdapterClient *adapter); + typedef std::function ImageProviderUrl; + QWebEngineHistoryPrivate(QtWebEngineCore::WebContentsAdapterClient *client, + const ImageProviderUrl &imageProviderUrl = ImageProviderUrl()); ~QWebEngineHistoryPrivate(); + void updateItems() const; + QtWebEngineCore::WebContentsAdapter *adapter() const; + + QtWebEngineCore::WebContentsAdapterClient *client; + + ImageProviderUrl imageProviderUrl; + QUrl urlOrImageProviderUrl(const QUrl &url) const { return imageProviderUrl ? imageProviderUrl(url) : url; } - QtWebEngineCore::WebContentsAdapterClient *m_adapter; mutable QList items; + mutable QScopedPointer navigationModel; + mutable QScopedPointer backNavigationModel; + mutable QScopedPointer forwardNavigationModel; }; QT_END_NAMESPACE -- cgit v1.2.3