Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpdflinkmodel.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPDFLINKMODEL_H
5#define QPDFLINKMODEL_H
6
7#include <QtPdf/qtpdfglobal.h>
8#include <QtPdf/qpdfdocument.h>
9#include <QtPdf/qpdflink.h>
10
11#include <QtCore/QAbstractListModel>
12
13#include <memory>
14
15QT_BEGIN_NAMESPACE
16
17class QPdfLinkModelPrivate;
18
19class Q_PDF_EXPORT QPdfLinkModel : public QAbstractListModel
20{
21 Q_OBJECT
22 Q_PROPERTY(QPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged)
23 Q_PROPERTY(int page READ page WRITE setPage NOTIFY pageChanged)
24
25public:
26 enum class Role {
27 Link = Qt::UserRole,
28 Rectangle,
29 Url,
30 Page,
31 Location,
32 Zoom,
33 NRoles
34 };
35 Q_ENUM(Role)
36 explicit QPdfLinkModel(QObject *parent = nullptr);
37 ~QPdfLinkModel() override;
38
39 QPdfDocument *document() const;
40
41 QHash<int, QByteArray> roleNames() const override;
42 int rowCount(const QModelIndex &parent) const override;
43 QVariant data(const QModelIndex &index, int role) const override;
44
45 int page() const;
46
47 QPdfLink linkAt(QPointF point) const;
48
49public Q_SLOTS:
50 void setDocument(QPdfDocument *document);
51 void setPage(int page);
52
53Q_SIGNALS:
54 void documentChanged();
55 void pageChanged(int page);
56
57private Q_SLOTS:
58 void onStatusChanged(QPdfDocument::Status status);
59
60private:
61 Q_DECLARE_PRIVATE(QPdfLinkModel)
62 const std::unique_ptr<QPdfLinkModelPrivate> d_ptr;
63};
64
65QT_END_NAMESPACE
66
67#endif // QPDFLINKMODEL_H
QHash< int, QByteArray > roleNames
QList< QPdfLink > links
QPdfDocument * document
The QPdfLinkModel class holds the geometry and the destination for each link that the specified \l pa...