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