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