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)
40 Q_PROPERTY(QString text READ text NOTIFY textChanged)
41 Q_PROPERTY(QList<QPolygonF> geometry READ geometry NOTIFY selectedAreaChanged)
42 QML_NAMED_ELEMENT(PdfSelection)
43 QML_ADDED_IN_VERSION(5, 15)
46 explicit QQuickPdfSelection(QQuickItem *parent =
nullptr);
47 ~QQuickPdfSelection() override;
49 QQuickPdfDocument *document()
const;
50 void setDocument(QQuickPdfDocument * document);
52 void setPage(
int page);
53 qreal renderScale()
const;
54 void setRenderScale(qreal scale);
56 void setFrom(QPointF from);
58 void setTo(QPointF to);
60 void setHold(
bool hold);
63 QList<QPolygonF> geometry()
const;
65 Q_INVOKABLE
void clear();
66 Q_INVOKABLE
void selectAll();
67#if QT_CONFIG(clipboard)
68 Q_INVOKABLE
void copyToClipboard()
const;
72 void documentChanged();
74 void renderScaleChanged();
79 void selectedAreaChanged();
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;
92 void update(
const QPdfSelection &sel,
bool textAndGeometryOnly =
false);
93 const QString &pageText()
const;
96 QQuickPdfDocument *m_document =
nullptr;
97 mutable QPointF m_hitPoint;
100 qreal m_renderScale = 1;
101 mutable qreal m_heightAtAnchor = 0;
102 mutable qreal m_heightAtCursor = 0;
104 mutable QString m_pageText;
105 QList<QPolygonF> m_geometry;
107 int m_fromCharIndex = -1;
108 mutable int m_toCharIndex = -1;
110 mutable bool m_pageTextDirty =
true;
112 Q_DISABLE_COPY(QQuickPdfSelection)