Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickpdfselection_p.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 QQUICKPDFSELECTION_P_H
5#define QQUICKPDFSELECTION_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtPdfQuick/private/qtpdfquickglobal_p.h>
19#include <QtPdfQuick/private/qquickpdfdocument_p.h>
20
21#include <QtCore/QPointF>
22#include <QtCore/QVariant>
23#include <QtGui/QPolygonF>
24#include <QtQml/QQmlEngine>
25#include <QtQuick/QQuickItem>
26
28class QPdfSelection;
29
31{
33 Q_PROPERTY(QQuickPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged)
34 Q_PROPERTY(int page READ page WRITE setPage NOTIFY pageChanged)
35 Q_PROPERTY(qreal renderScale READ renderScale WRITE setRenderScale NOTIFY renderScaleChanged)
36 Q_PROPERTY(QPointF from READ from WRITE setFrom NOTIFY fromChanged)
37 Q_PROPERTY(QPointF to READ to WRITE setTo NOTIFY toChanged)
38 Q_PROPERTY(bool hold READ hold WRITE setHold NOTIFY holdChanged)
39
41 Q_PROPERTY(QList<QPolygonF> geometry READ geometry NOTIFY selectedAreaChanged)
42 QML_NAMED_ELEMENT(PdfSelection)
44
45public:
46 explicit QQuickPdfSelection(QQuickItem *parent = nullptr);
47 ~QQuickPdfSelection() override;
48
49 QQuickPdfDocument *document() const;
50 void setDocument(QQuickPdfDocument * document);
51 int page() const;
52 void setPage(int page);
53 qreal renderScale() const;
54 void setRenderScale(qreal scale);
55 QPointF from() const;
56 void setFrom(QPointF from);
57 QPointF to() const;
58 void setTo(QPointF to);
59 bool hold() const;
60 void setHold(bool hold);
61
62 QString text() const;
63 QList<QPolygonF> geometry() const;
64
65 Q_INVOKABLE void clear();
67#if QT_CONFIG(clipboard)
68 Q_INVOKABLE void copyToClipboard() const;
69#endif
70
76 void toChanged();
80
81protected:
82#if QT_CONFIG(im)
83 void keyReleaseEvent(QKeyEvent *ev) override;
84 void inputMethodEvent(QInputMethodEvent *event) override;
85 Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const;
86 QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
87#endif
88
89private:
90 void resetPoints();
91 void updateResults();
92 void update(const QPdfSelection &sel, bool textAndGeometryOnly = false);
93 const QString &pageText() const;
94
95private:
96 QQuickPdfDocument *m_document = nullptr;
97 mutable QPointF m_hitPoint;
98 QPointF m_from;
99 mutable QPointF m_to;
100 qreal m_renderScale = 1;
101 mutable qreal m_heightAtAnchor = 0;
102 mutable qreal m_heightAtCursor = 0;
103 QString m_text; // selected text
104 mutable QString m_pageText; // all text on the page
105 QList<QPolygonF> m_geometry;
106 int m_page = 0;
107 int m_fromCharIndex = -1; // same as anchor position
108 mutable int m_toCharIndex = -1; // same as cursor position
109 bool m_hold = false;
110 mutable bool m_pageTextDirty = true;
111
112 Q_DISABLE_COPY(QQuickPdfSelection)
113};
114
116
118
119#endif // QQUICKPDFSELECTION_P_H
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
The QKeyEvent class describes a key event.
Definition qevent.h:424
Definition qlist.h:75
The QPdfSelection class defines a range of text that has been selected on one page in a PDF document,...
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QPolygonF class provides a list of points using floating point precision.
Definition qpolygon.h:96
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key release events for an item.
void update()
Schedules a call to updatePaintNode() for this item.
void selectedAreaChanged()
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
b clear()
QString text
void textChanged(const QString &newText)
Combined button and popup list for selecting options.
InputMethodQuery
static jboolean selectAll(JNIEnv *, jobject)
struct _cl_event * event
GLenum query
GLenum GLenum GLenum GLenum GLenum scale
#define QML_DECLARE_TYPE(TYPE)
Definition qqml.h:19
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define signals
#define Q_PDFQUICK_EXPORT
double qreal
Definition qtypes.h:187
#define explicit
QByteArray page
[45]
QDBusArgument argument