summaryrefslogtreecommitdiffstats
path: root/src/core/api/qwebenginehistory_p.h
blob: fe28f4a0ebaf6d5acd14e0e20e3c1f480292e254 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QWEBENGINEHISTORY_P_H
#define QWEBENGINEHISTORY_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qtwebenginecoreglobal_p.h"
#include "qwebenginehistory.h"
#include <QtCore/qshareddata.h>

namespace QtWebEngineCore {
class WebContentsAdapter;
class WebContentsAdapterClient;
}

QT_BEGIN_NAMESPACE

class QWebEnginePagePrivate;

class QWebEngineHistoryItemPrivate : public QSharedData
{
public:
    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_EXPORT QWebEngineHistoryPrivate
{
public:
    typedef std::function<QUrl (const QUrl &)> 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; }

    mutable QList<QWebEngineHistoryItem> items;
    mutable QScopedPointer<QWebEngineHistoryModel> navigationModel;
    mutable QScopedPointer<QWebEngineHistoryModel> backNavigationModel;
    mutable QScopedPointer<QWebEngineHistoryModel> forwardNavigationModel;
};

QT_END_NAMESPACE

#endif // QWEBENGINEHISTORY_P_H