1 | // Copyright (C) 2016 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 QABSTRACTTEXTDOCUMENTLAYOUT_P_H |
5 | #define QABSTRACTTEXTDOCUMENTLAYOUT_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 <QtGui/private/qtguiglobal_p.h> |
19 | #include "private/qobject_p.h" |
20 | #include "qtextdocument_p.h" |
21 | #include "qabstracttextdocumentlayout.h" |
22 | #include "QtCore/qhash.h" |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | struct QTextObjectHandler |
27 | { |
28 | QTextObjectHandler() : iface(nullptr) {} |
29 | QTextObjectInterface *iface; |
30 | QPointer<QObject> component; |
31 | }; |
32 | typedef QHash<int, QTextObjectHandler> HandlerHash; |
33 | |
34 | class Q_GUI_EXPORT QAbstractTextDocumentLayoutPrivate : public QObjectPrivate |
35 | { |
36 | public: |
37 | Q_DECLARE_PUBLIC(QAbstractTextDocumentLayout) |
38 | |
39 | inline QAbstractTextDocumentLayoutPrivate() |
40 | : paintDevice(nullptr) {} |
41 | ~QAbstractTextDocumentLayoutPrivate(); |
42 | |
43 | inline void setDocument(QTextDocument *doc) { |
44 | document = doc; |
45 | docPrivate = nullptr; |
46 | if (doc) |
47 | docPrivate = QTextDocumentPrivate::get(document: doc); |
48 | } |
49 | |
50 | static QAbstractTextDocumentLayoutPrivate *get(QAbstractTextDocumentLayout *layout) |
51 | { |
52 | return layout->d_func(); |
53 | } |
54 | |
55 | bool hasHandlers() const |
56 | { |
57 | return !handlers.isEmpty(); |
58 | } |
59 | |
60 | inline int _q_dynamicPageCountSlot() const |
61 | { return q_func()->pageCount(); } |
62 | inline QSizeF _q_dynamicDocumentSizeSlot() const |
63 | { return q_func()->documentSize(); } |
64 | |
65 | HandlerHash handlers; |
66 | |
67 | void _q_handlerDestroyed(QObject *obj); |
68 | QPaintDevice *paintDevice; |
69 | |
70 | QTextDocument *document; |
71 | QTextDocumentPrivate *docPrivate; |
72 | }; |
73 | |
74 | QT_END_NAMESPACE |
75 | |
76 | #endif // QABSTRACTTEXTDOCUMENTLAYOUT_P_H |
77 |