summaryrefslogtreecommitdiffstats
path: root/src/pdf/qpdfselection.h
blob: 8fcfaf2d883033b83b8bb53b9893f6f955d60710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QPDFSELECTION_H
#define QPDFSELECTION_H

#include <QtPdf/qtpdfglobal.h>

#include <QtCore/qobject.h>
#include <QtCore/qshareddata.h>
#include <QtGui/qclipboard.h>
#include <QtGui/qpolygon.h>

QT_BEGIN_NAMESPACE

class QPdfSelectionPrivate;

class QPdfSelection
{
    Q_GADGET_EXPORT(Q_PDF_EXPORT)
    Q_PROPERTY(bool valid READ isValid)
    Q_PROPERTY(QList<QPolygonF> bounds READ bounds)
    Q_PROPERTY(QRectF boundingRectangle READ boundingRectangle)
    Q_PROPERTY(QString text READ text)
    Q_PROPERTY(int startIndex READ startIndex)
    Q_PROPERTY(int endIndex READ endIndex)

public:
    Q_PDF_EXPORT ~QPdfSelection();
    Q_PDF_EXPORT QPdfSelection(const QPdfSelection &other);
    Q_PDF_EXPORT QPdfSelection &operator=(const QPdfSelection &other);

    Q_PDF_EXPORT QPdfSelection(QPdfSelection &&other) noexcept;
    QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QPdfSelection)

    void swap(QPdfSelection &other) noexcept { d.swap(other.d); }

    Q_PDF_EXPORT bool isValid() const;
    Q_PDF_EXPORT QList<QPolygonF> bounds() const;
    Q_PDF_EXPORT QString text() const;
    Q_PDF_EXPORT QRectF boundingRectangle() const;
    Q_PDF_EXPORT int startIndex() const;
    Q_PDF_EXPORT int endIndex() const;
#if QT_CONFIG(clipboard)
    Q_PDF_EXPORT void copyToClipboard(QClipboard::Mode mode = QClipboard::Clipboard) const;
#endif

private:
    QPdfSelection();
    QPdfSelection(const QString &text, QList<QPolygonF> bounds, QRectF boundingRect, int startIndex, int endIndex);
    QPdfSelection(QPdfSelectionPrivate *d);
    friend class QPdfDocument;
    friend class QQuickPdfSelection;

private:
    QExplicitlySharedDataPointer<QPdfSelectionPrivate> d;
};
Q_DECLARE_SHARED(QPdfSelection)

QT_END_NAMESPACE

#endif // QPDFSELECTION_H