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
qquickpdflinkmodel.cpp
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
#
include
"qquickpdflinkmodel_p.h"
5
#
include
<
QQuickItem
>
6
#
include
<
QQmlEngine
>
7
#
include
<
QStandardPaths
>
8
9
QT_BEGIN_NAMESPACE
10
11
/*!
12
\qmltype PdfLinkModel
13
//! \nativetype QQuickPdfLinkModel
14
\inqmlmodule QtQuick.Pdf
15
\ingroup pdf
16
\brief A representation of links within a PDF document.
17
\since 5.15
18
19
PdfLinkModel provides the geometry and the destination for each link
20
that the specified \l page contains.
21
22
The available model roles are:
23
24
\value rectangle
25
Bounding rectangle around the link.
26
\value url
27
If the link is a web link, the URL for that; otherwise an empty URL.
28
\value page
29
If the link is an internal link, the page number to which the link should jump; otherwise \c {-1}.
30
\value location
31
If the link is an internal link, the location on the page to which the link should jump.
32
\value zoom
33
If the link is an internal link, the intended zoom level on the destination page.
34
35
Normally it will be used with \l {QtQuick::Repeater}{Repeater} to visualize
36
the links and provide the ability to click them:
37
38
\qml
39
Repeater {
40
model: PdfLinkModel {
41
document: root.document
42
page: image.currentFrame
43
}
44
delegate: Rectangle {
45
required property rect rectangle
46
required property url url
47
required property int page
48
color: "transparent"
49
border.color: "lightgrey"
50
x: rectangle.x
51
y: rectangle.y
52
width: rectangle.width
53
height: rectangle.height
54
HoverHandler { cursorShape: Qt.PointingHandCursor }
55
TapHandler {
56
onTapped: {
57
if (page >= 0)
58
image.currentFrame = page
59
else
60
Qt.openUrlExternally(url)
61
}
62
}
63
}
64
}
65
\endqml
66
67
\note General-purpose PDF viewing capabilities are provided by
68
\c PdfScrollablePageView and \c PdfMultiPageView. PdfLinkModel is only needed
69
when building PDF view components from scratch.
70
*/
71
72
QQuickPdfLinkModel::QQuickPdfLinkModel(QObject *parent)
73
: QPdfLinkModel(parent)
74
{
75
}
76
77
/*!
78
\internal
79
*/
80
QQuickPdfLinkModel::~QQuickPdfLinkModel() =
default
;
81
82
/*!
83
\qmlproperty PdfDocument PdfLinkModel::document
84
85
This property holds the PDF document in which links are to be found.
86
*/
87
QQuickPdfDocument *QQuickPdfLinkModel::document()
const
88
{
89
return
m_quickDocument;
90
}
91
92
void
QQuickPdfLinkModel::setDocument(QQuickPdfDocument *document)
93
{
94
if
(document == m_quickDocument)
95
return
;
96
m_quickDocument = document;
97
if
(document)
98
QPdfLinkModel::setDocument(document->document());
99
}
100
101
/*!
102
\qmlproperty int PdfLinkModel::page
103
104
This property holds the page number on which links are to be found.
105
*/
106
107
QT_END_NAMESPACE
108
109
#
include
"moc_qquickpdflinkmodel_p.cpp"
qtwebengine
src
pdfquick
qquickpdflinkmodel.cpp
Generated on
for Qt by
1.14.0