Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | QAbstractTextDocumentLayoutPrivate::~QAbstractTextDocumentLayoutPrivate() | - |
6 | { | - |
7 | } | - |
8 | | - |
9 | QTextObjectInterface::~QTextObjectInterface() | - |
10 | { | - |
11 | | - |
12 | } | - |
13 | QAbstractTextDocumentLayout::QAbstractTextDocumentLayout(QTextDocument *document) | - |
14 | : QObject(*new QAbstractTextDocumentLayoutPrivate, document) | - |
15 | { | - |
16 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
17 | d->setDocument(document); | - |
18 | } | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | QAbstractTextDocumentLayout::QAbstractTextDocumentLayout(QAbstractTextDocumentLayoutPrivate &p, QTextDocument *document) | - |
24 | :QObject(p, document) | - |
25 | { | - |
26 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
27 | d->setDocument(document); | - |
28 | } | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | QAbstractTextDocumentLayout::~QAbstractTextDocumentLayout() | - |
34 | { | - |
35 | } | - |
36 | void QAbstractTextDocumentLayout::registerHandler(int objectType, QObject *component) | - |
37 | { | - |
38 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
39 | | - |
40 | QTextObjectInterface *iface = qobject_cast<QTextObjectInterface *>(component); | - |
41 | if (!iface) | - |
42 | return; | - |
43 | | - |
44 | connect(component, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "432""438"), this, qFlagLocation("1""_q_handlerDestroyed(QObject*)" "\0" __FILE__ ":" "432""438")); | - |
45 | | - |
46 | QTextObjectHandler h; | - |
47 | h.iface = iface; | - |
48 | h.component = component; | - |
49 | d->handlers.insert(objectType, h); | - |
50 | } | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | void QAbstractTextDocumentLayout::unregisterHandler(int objectType, QObject *component) | - |
59 | { | - |
60 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
61 | | - |
62 | HandlerHash::iteratorconst auto it = d->handlers.findconstFind(objectType); | - |
63 | if (it != d->handlers.endcend()TRUE | never evaluated | FALSE | never evaluated |
&& (!componentTRUE | never evaluated | FALSE | never evaluated |
|| component == it->componentTRUE | never evaluated | FALSE | never evaluated |
)) { | 0 |
64 | if (componentTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
65 | disconnect(component, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "453""459"), this, qFlagLocation("1""_q_handlerDestroyed(QObject*)" "\0" __FILE__ ":" "453""459")); never executed: disconnect(component, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "459"), this, qFlagLocation("1""_q_handlerDestroyed(QObject*)" "\0" __FILE__ ":" "459")); | 0 |
66 | d->handlers.erase(it); | - |
67 | } never executed: end of block | 0 |
68 | } never executed: end of block | 0 |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | QTextObjectInterface *QAbstractTextDocumentLayout::handlerForObject(int objectType) const | - |
74 | { | - |
75 | const QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
76 | | - |
77 | QTextObjectHandler handler = d->handlers.value(objectType); | - |
78 | if (!handler.component) | - |
79 | return 0; | - |
80 | | - |
81 | return handler.iface; | - |
82 | } | - |
83 | void QAbstractTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) | - |
84 | { | - |
85 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
86 | | - |
87 | QTextCharFormat f = format.toCharFormat(); | - |
88 | ((!(f.isValid())) ? qt_assert("f.isValid()",__FILE__,488494) : qt_noop()); | - |
89 | QTextObjectHandler handler = d->handlers.value(f.objectType()); | - |
90 | if (!handler.component) | - |
91 | return; | - |
92 | | - |
93 | QSizeF s = handler.iface->intrinsicSize(document(), posInDocument, format); | - |
94 | item.setWidth(s.width()); | - |
95 | item.setAscent(s.height()); | - |
96 | item.setDescent(0); | - |
97 | } | - |
98 | void QAbstractTextDocumentLayout::positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) | - |
99 | { | - |
100 | (void)item;; | - |
101 | (void)posInDocument;; | - |
102 | (void)format;; | - |
103 | } | - |
104 | void QAbstractTextDocumentLayout::drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item, | - |
105 | int posInDocument, const QTextFormat &format) | - |
106 | { | - |
107 | (void)item;; | - |
108 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
109 | | - |
110 | QTextCharFormat f = format.toCharFormat(); | - |
111 | ((!(f.isValid())) ? qt_assert("f.isValid()",__FILE__,539545) : qt_noop()); | - |
112 | QTextObjectHandler handler = d->handlers.value(f.objectType()); | - |
113 | if (!handler.component) | - |
114 | return; | - |
115 | | - |
116 | handler.iface->drawObject(p, rect, document(), posInDocument, format); | - |
117 | } | - |
118 | | - |
119 | void QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(QObject *obj) | - |
120 | { | - |
121 | HandlerHash::Iterator it = handlers.begin(); | - |
122 | while (it != handlers.end()) | - |
123 | if ((*it).component == obj) | - |
124 | it = handlers.erase(it); | - |
125 | else | - |
126 | ++it; | - |
127 | } | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | int QAbstractTextDocumentLayout::formatIndex(int pos) | - |
135 | { | - |
136 | QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle(); | - |
137 | return pieceTable->find(pos).value()->format; | - |
138 | } | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | QTextCharFormat QAbstractTextDocumentLayout::format(int pos) | - |
146 | { | - |
147 | QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle(); | - |
148 | int idx = pieceTable->find(pos).value()->format; | - |
149 | return pieceTable->formatCollection()->charFormat(idx); | - |
150 | } | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | QTextDocument *QAbstractTextDocumentLayout::document() const | - |
158 | { | - |
159 | const QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
160 | return d->document; | - |
161 | } | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const | - |
170 | { | - |
171 | int cursorPos = hitTest(pos, Qt::ExactHit); | - |
172 | if (cursorPos == -1) | - |
173 | return QString(); | - |
174 | | - |
175 | | - |
176 | QTextBlock block = document()->firstBlock(); | - |
177 | while (block.isValid()) { | - |
178 | QRectF blockBr = blockBoundingRect(block); | - |
179 | if (blockBr.contains(pos)) { | - |
180 | QTextLayout *layout = block.layout(); | - |
181 | int relativeCursorPos = cursorPos - block.position(); | - |
182 | const int preeditLength = layout ? layout->preeditAreaText().length() : 0; | - |
183 | if (preeditLength > 0 && relativeCursorPos > layout->preeditAreaPosition()) | - |
184 | cursorPos -= qMin(cursorPos - layout->preeditAreaPosition(), preeditLength); | - |
185 | break; | - |
186 | } | - |
187 | block = block.next(); | - |
188 | } | - |
189 | | - |
190 | QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle(); | - |
191 | QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); | - |
192 | QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); | - |
193 | return fmt.anchorHref(); | - |
194 | } | - |
195 | void QAbstractTextDocumentLayout::setPaintDevice(QPaintDevice *device) | - |
196 | { | - |
197 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
198 | d->paintDevice = device; | - |
199 | } | - |
200 | | - |
201 | | - |
202 | | - |
203 | | - |
204 | | - |
205 | | - |
206 | QPaintDevice *QAbstractTextDocumentLayout::paintDevice() const | - |
207 | { | - |
208 | const QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - |
209 | return d->paintDevice; | - |
210 | } | - |
211 | | - |
212 | | - |
213 | | - |
| | |