Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qpdfselection.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
"qpdfselection.h"
5
#
include
"qpdfselection_p.h"
6
#
include
<
QGuiApplication
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\class QPdfSelection
12
\since 5.15
13
\inmodule QtPdf
14
15
\brief The QPdfSelection class defines a range of text that has been selected
16
on one page in a PDF document, and its geometric boundaries.
17
18
\sa QPdfDocument::getSelection()
19
*/
20
21
/*!
22
Constructs an invalid selection.
23
24
\sa valid
25
*/
26
QPdfSelection::QPdfSelection()
27
: d(
new
QPdfSelectionPrivate())
28
{
29
}
30
31
/*!
32
\internal
33
Constructs a selection including the range of characters that make up the
34
\a text string, and which take up space on the page within the polygon
35
regions given in \a bounds.
36
*/
37
QPdfSelection
::QPdfSelection(
const
QString &text, QList<QPolygonF> bounds, QRectF boundingRect,
int
startIndex,
int
endIndex)
38
: d(
new
QPdfSelectionPrivate(text, bounds, boundingRect, startIndex, endIndex))
39
{
40
}
41
42
QPdfSelection
::QPdfSelection(QPdfSelectionPrivate *d)
43
: d(d)
44
{
45
}
46
47
QPdfSelection
::~QPdfSelection() =
default
;
48
QPdfSelection
::QPdfSelection(
const
QPdfSelection
&other) =
default
;
49
QPdfSelection
::QPdfSelection(
QPdfSelection
&&other)
noexcept
=
default
;
50
QPdfSelection
&
QPdfSelection
::operator=(
const
QPdfSelection
&other) =
default
;
51
52
/*!
53
\property QPdfSelection::valid
54
55
This property holds whether the selection is valid.
56
*/
57
bool
QPdfSelection
::
isValid
()
const
58
{
59
return
!d->bounds.isEmpty();
60
}
61
62
/*!
63
\property QPdfSelection::bounds
64
65
This property holds a set of regions that the selected text occupies on the
66
page, represented as polygons. The coordinate system for the polygons has
67
the origin at the upper-left corner of the page, and the units are
68
\l {https://en.wikipedia.org/wiki/Point_(typography)}{points}.
69
70
\note For now, the polygons returned from \l QPdfDocument::getSelection()
71
are always rectangles; but in the future it may be possible to represent
72
more complex regions.
73
*/
74
QList<QPolygonF>
QPdfSelection
::bounds()
const
75
{
76
return
d->bounds;
77
}
78
79
/*!
80
\property QPdfSelection::text
81
82
This property holds the selected text.
83
*/
84
QString
QPdfSelection
::text()
const
85
{
86
return
d->text;
87
}
88
89
/*!
90
\property QPdfSelection::boundingRectangle
91
92
This property holds the overall bounding rectangle (convex hull) around \l bounds.
93
*/
94
QRectF
QPdfSelection
::boundingRectangle()
const
95
{
96
return
d->boundingRect;
97
}
98
99
/*!
100
\property QPdfSelection::startIndex
101
102
This property holds the index at the beginning of \l text within the full text on the page.
103
*/
104
int
QPdfSelection
::
startIndex
()
const
105
{
106
return
d->startIndex;
107
}
108
109
/*!
110
\property QPdfSelection::endIndex
111
112
This property holds the index at the end of \l text within the full text on the page.
113
*/
114
int
QPdfSelection
::
endIndex
()
const
115
{
116
return
d->endIndex;
117
}
118
119
#
if
QT_CONFIG
(
clipboard
)
120
/*!
121
Copies \l text to the \l {QGuiApplication::clipboard()}{system clipboard}
122
depending on the \a mode selected.
123
*/
124
void
QPdfSelection::copyToClipboard(QClipboard::Mode mode)
const
125
{
126
QGuiApplication::clipboard()->setText(d->text, mode);
127
}
128
#
endif
129
130
QT_END_NAMESPACE
131
132
#
include
"moc_qpdfselection.cpp"
QPdfSelection
The QPdfSelection class defines a range of text that has been selected on one page in a PDF document,...
Definition
qpdfselection.h:19
QPdfSelection::isValid
Q_PDF_EXPORT bool isValid() const
Definition
qpdfselection.cpp:57
QPdfSelection::startIndex
Q_PDF_EXPORT int startIndex() const
Definition
qpdfselection.cpp:104
QPdfSelection::endIndex
Q_PDF_EXPORT int endIndex() const
Definition
qpdfselection.cpp:114
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtwebengine
src
pdf
qpdfselection.cpp
Generated on
for Qt by
1.18.0