1/*
2 * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi)
3 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1.  Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2.  Redistributions in binary form must reproduce the above copyright
11 *  notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24*/
25
26#ifndef qwebnavigationhistory_p_h
27#define qwebnavigationhistory_p_h
28
29#include "qwebkitglobal.h"
30#include <QAbstractListModel>
31#include <QObject>
32#include <QUrl>
33#include <QVariant>
34#include <QtQml/qqml.h>
35
36QT_BEGIN_NAMESPACE
37class QAbstractListModel;
38class QString;
39class QUrl;
40QT_END_NAMESPACE
41class QWebNavigationHistoryPrivate;
42class QWebNavigationListModelPrivate;
43
44class QWEBKIT_EXPORT QWebNavigationListModel : public QAbstractListModel {
45    Q_OBJECT
46public:
47    virtual ~QWebNavigationListModel();
48
49    int rowCount(const QModelIndex& parent = QModelIndex()) const;
50    QVariant data(const QModelIndex& index, int role) const;
51    QHash<int, QByteArray> roleNames() const;
52    void reset();
53
54private:
55    QWebNavigationListModel()
56        : QAbstractListModel()
57    { }
58
59    QWebNavigationListModelPrivate* d;
60    friend class QWebNavigationListModelPrivate;
61    friend class QWebNavigationHistory;
62    friend class QWebNavigationHistoryPrivate;
63};
64
65QML_DECLARE_TYPE(QWebNavigationListModel)
66
67class QWEBKIT_EXPORT QWebNavigationHistory : public QObject {
68    Q_OBJECT
69    Q_PROPERTY(QWebNavigationListModel* backItems READ backItems CONSTANT FINAL)
70    Q_PROPERTY(QWebNavigationListModel* forwardItems READ forwardItems CONSTANT FINAL)
71public:
72    enum NavigationHistoryRoles {
73        UrlRole = Qt::UserRole + 1,
74        TitleRole = Qt::UserRole + 2
75    };
76
77    QWebNavigationListModel* backItems() const;
78    QWebNavigationListModel* forwardItems() const;
79
80    virtual ~QWebNavigationHistory();
81
82private:
83    QWebNavigationHistory();
84
85    QWebNavigationHistoryPrivate* d;
86    friend class QWebNavigationHistoryPrivate;
87    friend class QQuickWebViewPrivate;
88    friend class QQuickWebViewExperimental;
89};
90
91QML_DECLARE_TYPE(QWebNavigationHistory)
92
93#endif /* qwebnavigationhistory_p_h */
94