summaryrefslogtreecommitdiffstats
path: root/src/pdf/qpdflinkmodel_p.h
blob: 48c973d1153d7cb097d112d2f7a53cba0c26d6f7 (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
// Copyright (C) 2020 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 QPDFLINKMODEL_P_H
#define QPDFLINKMODEL_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 "qtpdfglobal.h"
#include "qpdfdocument.h"

#include <QObject>
#include <QAbstractListModel>

QT_BEGIN_NAMESPACE

class QPdfLinkModelPrivate;

class Q_PDF_EXPORT QPdfLinkModel : public QAbstractListModel
{
    Q_OBJECT
    Q_PROPERTY(QPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged)
    Q_PROPERTY(int page READ page WRITE setPage NOTIFY pageChanged)

public:
    enum class Role : int {
        Link = Qt::UserRole,
        Rectangle,
        Url,
        Page,
        Location,
        Zoom,
        _Count
    };
    Q_ENUM(Role)
    explicit QPdfLinkModel(QObject *parent = nullptr);
    ~QPdfLinkModel();

    QPdfDocument *document() const;

    QHash<int, QByteArray> roleNames() const override;
    int rowCount(const QModelIndex &parent) const override;
    QVariant data(const QModelIndex &index, int role) const override;

    int page() const;

public Q_SLOTS:
    void setDocument(QPdfDocument *document);
    void setPage(int page);

Q_SIGNALS:
    void documentChanged();
    void pageChanged(int page);

private Q_SLOTS:
    void onStatusChanged(QPdfDocument::Status status);

private:
    QHash<int, QByteArray> m_roleNames;
    Q_DECLARE_PRIVATE(QPdfLinkModel)
};

QT_END_NAMESPACE

#endif // QPDFLINKMODEL_P_H