widgets/qwidgettextcontrol.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10static QTextLine currentTextLine(const QTextCursor &cursor) -
11{ -
12 const QTextBlock block = cursor.block(); -
13 if (!block.isValid())
partially evaluated: !block.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
14 return QTextLine();
never executed: return QTextLine();
0
15 -
16 const QTextLayout *layout = block.layout(); -
17 if (!layout)
partially evaluated: !layout
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
18 return QTextLine();
never executed: return QTextLine();
0
19 -
20 const int relativePos = cursor.position() - block.position(); -
21 return layout->lineForTextPosition(relativePos);
executed: return layout->lineForTextPosition(relativePos);
Execution Count:5
5
22} -
23 -
24QWidgetTextControlPrivate::QWidgetTextControlPrivate() -
25 : doc(0), cursorOn(false), cursorIsFocusIndicator(false), -
26 interactionFlags(Qt::TextEditorInteraction), -
27 dragEnabled(true), -
28 -
29 mousePressed(false), mightStartDrag(false), -
30 -
31 lastSelectionPosition(0), lastSelectionAnchor(0), -
32 ignoreAutomaticScrollbarAdjustement(false), -
33 overwriteMode(false), -
34 acceptRichText(true), -
35 preeditCursor(0), hideCursor(false), -
36 hasFocus(false), -
37 -
38 -
39 -
40 isEnabled(true), -
41 hadSelectionOnMousePress(false), -
42 ignoreUnusedNavigationEvents(false), -
43 openExternalLinks(false), -
44 wordSelectionEnabled(false) -
45{}
executed: }
Execution Count:291
291
46 -
47bool QWidgetTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e) -
48{ -
49 -
50 -
51 -
52 -
53 QWidgetTextControl * const q = q_func(); -
54 if (cursor.isNull())
partially evaluated: cursor.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:154
0-154
55 return false;
never executed: return false;
0
56 -
57 const QTextCursor oldSelection = cursor; -
58 const int oldCursorPos = cursor.position(); -
59 -
60 QTextCursor::MoveMode mode = QTextCursor::MoveAnchor; -
61 QTextCursor::MoveOperation op = QTextCursor::NoMove; -
62 -
63 if (false) {
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:154
0-154
64 }
never executed: }
0
65 -
66 if (e == QKeySequence::MoveToNextChar) {
evaluated: e == QKeySequence::MoveToNextChar
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:150
4-150
67 op = QTextCursor::Right; -
68 }
executed: }
Execution Count:4
4
69 else if (e == QKeySequence::MoveToPreviousChar) {
evaluated: e == QKeySequence::MoveToPreviousChar
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:147
3-147
70 op = QTextCursor::Left; -
71 }
executed: }
Execution Count:3
3
72 else if (e == QKeySequence::SelectNextChar) {
evaluated: e == QKeySequence::SelectNextChar
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:143
4-143
73 op = QTextCursor::Right; -
74 mode = QTextCursor::KeepAnchor; -
75 }
executed: }
Execution Count:4
4
76 else if (e == QKeySequence::SelectPreviousChar) {
evaluated: e == QKeySequence::SelectPreviousChar
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:130
13-130
77 op = QTextCursor::Left; -
78 mode = QTextCursor::KeepAnchor; -
79 }
executed: }
Execution Count:13
13
80 else if (e == QKeySequence::SelectNextWord) {
partially evaluated: e == QKeySequence::SelectNextWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
81 op = QTextCursor::WordRight; -
82 mode = QTextCursor::KeepAnchor; -
83 }
never executed: }
0
84 else if (e == QKeySequence::SelectPreviousWord) {
partially evaluated: e == QKeySequence::SelectPreviousWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
85 op = QTextCursor::WordLeft; -
86 mode = QTextCursor::KeepAnchor; -
87 }
never executed: }
0
88 else if (e == QKeySequence::SelectStartOfLine) {
partially evaluated: e == QKeySequence::SelectStartOfLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
89 op = QTextCursor::StartOfLine; -
90 mode = QTextCursor::KeepAnchor; -
91 }
never executed: }
0
92 else if (e == QKeySequence::SelectEndOfLine) {
partially evaluated: e == QKeySequence::SelectEndOfLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
93 op = QTextCursor::EndOfLine; -
94 mode = QTextCursor::KeepAnchor; -
95 }
never executed: }
0
96 else if (e == QKeySequence::SelectStartOfBlock) {
partially evaluated: e == QKeySequence::SelectStartOfBlock
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
97 op = QTextCursor::StartOfBlock; -
98 mode = QTextCursor::KeepAnchor; -
99 }
never executed: }
0
100 else if (e == QKeySequence::SelectEndOfBlock) {
partially evaluated: e == QKeySequence::SelectEndOfBlock
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
101 op = QTextCursor::EndOfBlock; -
102 mode = QTextCursor::KeepAnchor; -
103 }
never executed: }
0
104 else if (e == QKeySequence::SelectStartOfDocument) {
partially evaluated: e == QKeySequence::SelectStartOfDocument
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
105 op = QTextCursor::Start; -
106 mode = QTextCursor::KeepAnchor; -
107 }
never executed: }
0
108 else if (e == QKeySequence::SelectEndOfDocument) {
partially evaluated: e == QKeySequence::SelectEndOfDocument
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
109 op = QTextCursor::End; -
110 mode = QTextCursor::KeepAnchor; -
111 }
never executed: }
0
112 else if (e == QKeySequence::SelectPreviousLine) {
partially evaluated: e == QKeySequence::SelectPreviousLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
113 op = QTextCursor::Up; -
114 mode = QTextCursor::KeepAnchor; -
115 }
never executed: }
0
116 else if (e == QKeySequence::SelectNextLine) {
evaluated: e == QKeySequence::SelectNextLine
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:125
5-125
117 op = QTextCursor::Down; -
118 mode = QTextCursor::KeepAnchor; -
119 { -
120 QTextBlock block = cursor.block(); -
121 QTextLine line = currentTextLine(cursor); -
122 if (!block.next().isValid()
evaluated: !block.next().isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
123 && line.isValid()
partially evaluated: line.isValid()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
124 && line.lineNumber() == block.layout()->lineCount() - 1)
evaluated: line.lineNumber() == block.layout()->lineCount() - 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
125 op = QTextCursor::End;
executed: op = QTextCursor::End;
Execution Count:2
2
126 } -
127 }
executed: }
Execution Count:5
5
128 else if (e == QKeySequence::MoveToNextWord) {
partially evaluated: e == QKeySequence::MoveToNextWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:125
0-125
129 op = QTextCursor::WordRight; -
130 }
never executed: }
0
131 else if (e == QKeySequence::MoveToPreviousWord) {
partially evaluated: e == QKeySequence::MoveToPreviousWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:125
0-125
132 op = QTextCursor::WordLeft; -
133 }
never executed: }
0
134 else if (e == QKeySequence::MoveToEndOfBlock) {
partially evaluated: e == QKeySequence::MoveToEndOfBlock
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:125
0-125
135 op = QTextCursor::EndOfBlock; -
136 }
never executed: }
0
137 else if (e == QKeySequence::MoveToStartOfBlock) {
partially evaluated: e == QKeySequence::MoveToStartOfBlock
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:125
0-125
138 op = QTextCursor::StartOfBlock; -
139 }
never executed: }
0
140 else if (e == QKeySequence::MoveToNextLine) {
evaluated: e == QKeySequence::MoveToNextLine
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:120
5-120
141 op = QTextCursor::Down; -
142 }
executed: }
Execution Count:5
5
143 else if (e == QKeySequence::MoveToPreviousLine) {
partially evaluated: e == QKeySequence::MoveToPreviousLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
144 op = QTextCursor::Up; -
145 }
never executed: }
0
146 else if (e == QKeySequence::MoveToPreviousLine) {
partially evaluated: e == QKeySequence::MoveToPreviousLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
147 op = QTextCursor::Up; -
148 }
never executed: }
0
149 else if (e == QKeySequence::MoveToStartOfLine) {
partially evaluated: e == QKeySequence::MoveToStartOfLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
150 op = QTextCursor::StartOfLine; -
151 }
never executed: }
0
152 else if (e == QKeySequence::MoveToEndOfLine) {
partially evaluated: e == QKeySequence::MoveToEndOfLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
153 op = QTextCursor::EndOfLine; -
154 }
never executed: }
0
155 else if (e == QKeySequence::MoveToStartOfDocument) {
partially evaluated: e == QKeySequence::MoveToStartOfDocument
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
156 op = QTextCursor::Start; -
157 }
never executed: }
0
158 else if (e == QKeySequence::MoveToEndOfDocument) {
partially evaluated: e == QKeySequence::MoveToEndOfDocument
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
159 op = QTextCursor::End; -
160 }
never executed: }
0
161 -
162 else { -
163 return false;
executed: return false;
Execution Count:120
120
164 } -
165 bool visualNavigation = cursor.visualNavigation(); -
166 cursor.setVisualNavigation(true); -
167 const bool moved = cursor.movePosition(op, mode); -
168 cursor.setVisualNavigation(visualNavigation); -
169 q->ensureCursorVisible(); -
170 -
171 bool ignoreNavigationEvents = ignoreUnusedNavigationEvents; -
172 bool isNavigationEvent = e->key() == Qt::Key_Up || e->key() == Qt::Key_Down;
partially evaluated: e->key() == Qt::Key_Up
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
evaluated: e->key() == Qt::Key_Down
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:24
0-34
173 -
174 -
175 -
176 -
177 -
178 -
179 -
180 isNavigationEvent = isNavigationEvent || e->key() == Qt::Key_Left || e->key() == Qt::Key_Right;
evaluated: isNavigationEvent
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:24
evaluated: e->key() == Qt::Key_Left
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:8
partially evaluated: e->key() == Qt::Key_Right
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-24
181 -
182 -
183 if (moved) {
evaluated: moved
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:5
5-29
184 if (cursor.position() != oldCursorPos)
partially evaluated: cursor.position() != oldCursorPos
TRUEFALSE
yes
Evaluation Count:29
no
Evaluation Count:0
0-29
185 q->cursorPositionChanged();
executed: q->cursorPositionChanged();
Execution Count:29
29
186 q->microFocusChanged(); -
187 } else if (ignoreNavigationEvents && isNavigationEvent && oldSelection.anchor() == cursor.anchor()) {
executed: }
Execution Count:29
partially evaluated: ignoreNavigationEvents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: isNavigationEvent
never evaluated: oldSelection.anchor() == cursor.anchor()
0-29
188 return false;
never executed: return false;
0
189 } -
190 -
191 selectionChanged( (mode == QTextCursor::KeepAnchor)); -
192 -
193 repaintOldAndNewSelection(oldSelection); -
194 -
195 return true;
executed: return true;
Execution Count:34
34
196} -
197 -
198void QWidgetTextControlPrivate::updateCurrentCharFormat() -
199{ -
200 QWidgetTextControl * const q = q_func(); -
201 -
202 QTextCharFormat fmt = cursor.charFormat(); -
203 if (fmt == lastCharFormat)
evaluated: fmt == lastCharFormat
TRUEFALSE
yes
Evaluation Count:1558
yes
Evaluation Count:44
44-1558
204 return;
executed: return;
Execution Count:1558
1558
205 lastCharFormat = fmt; -
206 -
207 q->currentCharFormatChanged(fmt); -
208 q->microFocusChanged(); -
209}
executed: }
Execution Count:44
44
210 -
211void QWidgetTextControlPrivate::indent() -
212{ -
213 QTextBlockFormat blockFmt = cursor.blockFormat(); -
214 -
215 QTextList *list = cursor.currentList(); -
216 if (!list) {
never evaluated: !list
0
217 QTextBlockFormat modifier; -
218 modifier.setIndent(blockFmt.indent() + 1); -
219 cursor.mergeBlockFormat(modifier); -
220 } else {
never executed: }
0
221 QTextListFormat format = list->format(); -
222 format.setIndent(format.indent() + 1); -
223 -
224 if (list->itemNumber(cursor.block()) == 1)
never evaluated: list->itemNumber(cursor.block()) == 1
0
225 list->setFormat(format);
never executed: list->setFormat(format);
0
226 else -
227 cursor.createList(format);
never executed: cursor.createList(format);
0
228 } -
229} -
230 -
231void QWidgetTextControlPrivate::outdent() -
232{ -
233 QTextBlockFormat blockFmt = cursor.blockFormat(); -
234 -
235 QTextList *list = cursor.currentList(); -
236 -
237 if (!list) {
never evaluated: !list
0
238 QTextBlockFormat modifier; -
239 modifier.setIndent(blockFmt.indent() - 1); -
240 cursor.mergeBlockFormat(modifier); -
241 } else {
never executed: }
0
242 QTextListFormat listFmt = list->format(); -
243 listFmt.setIndent(listFmt.indent() - 1); -
244 list->setFormat(listFmt); -
245 }
never executed: }
0
246} -
247 -
248void QWidgetTextControlPrivate::gotoNextTableCell() -
249{ -
250 QTextTable *table = cursor.currentTable(); -
251 QTextTableCell cell = table->cellAt(cursor); -
252 -
253 int newColumn = cell.column() + cell.columnSpan(); -
254 int newRow = cell.row(); -
255 -
256 if (newColumn >= table->columns()) {
never evaluated: newColumn >= table->columns()
0
257 newColumn = 0; -
258 ++newRow; -
259 if (newRow >= table->rows())
never evaluated: newRow >= table->rows()
0
260 table->insertRows(table->rows(), 1);
never executed: table->insertRows(table->rows(), 1);
0
261 }
never executed: }
0
262 -
263 cell = table->cellAt(newRow, newColumn); -
264 cursor = cell.firstCursorPosition(); -
265}
never executed: }
0
266 -
267void QWidgetTextControlPrivate::gotoPreviousTableCell() -
268{ -
269 QTextTable *table = cursor.currentTable(); -
270 QTextTableCell cell = table->cellAt(cursor); -
271 -
272 int newColumn = cell.column() - 1; -
273 int newRow = cell.row(); -
274 -
275 if (newColumn < 0) {
never evaluated: newColumn < 0
0
276 newColumn = table->columns() - 1; -
277 --newRow; -
278 if (newRow < 0)
never evaluated: newRow < 0
0
279 return;
never executed: return;
0
280 }
never executed: }
0
281 -
282 cell = table->cellAt(newRow, newColumn); -
283 cursor = cell.firstCursorPosition(); -
284}
never executed: }
0
285 -
286void QWidgetTextControlPrivate::createAutoBulletList() -
287{ -
288 cursor.beginEditBlock(); -
289 -
290 QTextBlockFormat blockFmt = cursor.blockFormat(); -
291 -
292 QTextListFormat listFmt; -
293 listFmt.setStyle(QTextListFormat::ListDisc); -
294 listFmt.setIndent(blockFmt.indent() + 1); -
295 -
296 blockFmt.setIndent(0); -
297 cursor.setBlockFormat(blockFmt); -
298 -
299 cursor.createList(listFmt); -
300 -
301 cursor.endEditBlock(); -
302}
never executed: }
0
303 -
304void QWidgetTextControlPrivate::init(Qt::TextFormat format, const QString &text, QTextDocument *document) -
305{ -
306 QWidgetTextControl * const q = q_func(); -
307 setContent(format, text, document); -
308 -
309 doc->setUndoRedoEnabled(interactionFlags & Qt::TextEditable); -
310 q->setCursorWidth(-1); -
311}
executed: }
Execution Count:291
291
312 -
313void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString &text, QTextDocument *document) -
314{ -
315 QWidgetTextControl * const q = q_func(); -
316 -
317 -
318 -
319 const QTextCharFormat charFormatForInsertion = cursor.charFormat(); -
320 -
321 bool clearDocument = true; -
322 if (!doc) {
evaluated: !doc
TRUEFALSE
yes
Evaluation Count:387
yes
Evaluation Count:267
267-387
323 if (document) {
evaluated: document
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:291
96-291
324 doc = document; -
325 clearDocument = false; -
326 } else {
executed: }
Execution Count:96
96
327 palette = QApplication::palette("QWidgetTextControl"); -
328 doc = new QTextDocument(q); -
329 }
executed: }
Execution Count:291
291
330 _q_documentLayoutChanged(); -
331 cursor = QTextCursor(doc); -
332 -
333 -
334 -
335 QObject::connect(doc, "2""contentsChanged()", q, "1""_q_updateCurrentCharFormatAndSelection()"); -
336 QObject::connect(doc, "2""cursorPositionChanged(QTextCursor)", q, "1""_q_emitCursorPosChanged(QTextCursor)"); -
337 QObject::connect(doc, "2""documentLayoutChanged()", q, "1""_q_documentLayoutChanged()"); -
338 -
339 -
340 QObject::connect(doc, "2""undoAvailable(bool)", q, "2""undoAvailable(bool)"); -
341 QObject::connect(doc, "2""redoAvailable(bool)", q, "2""redoAvailable(bool)"); -
342 QObject::connect(doc, "2""modificationChanged(bool)", q, "2""modificationChanged(bool)"); -
343 QObject::connect(doc, "2""blockCountChanged(int)", q, "2""blockCountChanged(int)"); -
344 }
executed: }
Execution Count:387
387
345 -
346 bool previousUndoRedoState = doc->isUndoRedoEnabled(); -
347 if (!document)
evaluated: !document
TRUEFALSE
yes
Evaluation Count:558
yes
Evaluation Count:96
96-558
348 doc->setUndoRedoEnabled(false);
executed: doc->setUndoRedoEnabled(false);
Execution Count:558
558
349 -
350 -
351 static int contentsChangedIndex = QMetaMethod::fromSignal(&QTextDocument::contentsChanged).methodIndex(); -
352 static int textChangedIndex = QMetaMethod::fromSignal(&QWidgetTextControl::textChanged).methodIndex(); -
353 -
354 QMetaObject::disconnect(doc, contentsChangedIndex, q, textChangedIndex); -
355 -
356 if (!text.isEmpty()) {
evaluated: !text.isEmpty()
TRUEFALSE
yes
Evaluation Count:232
yes
Evaluation Count:422
232-422
357 -
358 -
359 -
360 -
361 -
362 -
363 cursor = QTextCursor(); -
364 if (format == Qt::PlainText) {
evaluated: format == Qt::PlainText
TRUEFALSE
yes
Evaluation Count:161
yes
Evaluation Count:71
71-161
365 QTextCursor formatCursor(doc); -
366 -
367 -
368 -
369 formatCursor.beginEditBlock(); -
370 doc->setPlainText(text); -
371 doc->setUndoRedoEnabled(false); -
372 formatCursor.select(QTextCursor::Document); -
373 formatCursor.setCharFormat(charFormatForInsertion); -
374 formatCursor.endEditBlock(); -
375 } else {
executed: }
Execution Count:161
161
376 -
377 doc->setHtml(text); -
378 -
379 -
380 -
381 doc->setUndoRedoEnabled(false); -
382 }
executed: }
Execution Count:71
71
383 cursor = QTextCursor(doc); -
384 } else if (clearDocument) {
evaluated: clearDocument
TRUEFALSE
yes
Evaluation Count:326
yes
Evaluation Count:96
executed: }
Execution Count:232
96-326
385 doc->clear(); -
386 }
executed: }
Execution Count:326
326
387 cursor.setCharFormat(charFormatForInsertion); -
388 -
389 QMetaObject::connect(doc, contentsChangedIndex, q, textChangedIndex); -
390 q->textChanged(); -
391 if (!document)
evaluated: !document
TRUEFALSE
yes
Evaluation Count:558
yes
Evaluation Count:96
96-558
392 doc->setUndoRedoEnabled(previousUndoRedoState);
executed: doc->setUndoRedoEnabled(previousUndoRedoState);
Execution Count:558
558
393 _q_updateCurrentCharFormatAndSelection(); -
394 if (!document)
evaluated: !document
TRUEFALSE
yes
Evaluation Count:558
yes
Evaluation Count:96
96-558
395 doc->setModified(false);
executed: doc->setModified(false);
Execution Count:558
558
396 -
397 q->ensureCursorVisible(); -
398 q->cursorPositionChanged(); -
399}
executed: }
Execution Count:654
654
400 -
401void QWidgetTextControlPrivate::startDrag() -
402{ -
403 -
404 QWidgetTextControl * const q = q_func(); -
405 mousePressed = false; -
406 if (!contextWidget)
never evaluated: !contextWidget
0
407 return;
never executed: return;
0
408 QMimeData *data = q->createMimeDataFromSelection(); -
409 -
410 QDrag *drag = new QDrag(contextWidget); -
411 drag->setMimeData(data); -
412 -
413 Qt::DropActions actions = Qt::CopyAction; -
414 Qt::DropAction action; -
415 if (interactionFlags & Qt::TextEditable) {
never evaluated: interactionFlags & Qt::TextEditable
0
416 actions |= Qt::MoveAction; -
417 action = drag->exec(actions, Qt::MoveAction); -
418 } else {
never executed: }
0
419 action = drag->exec(actions, Qt::CopyAction); -
420 }
never executed: }
0
421 -
422 if (action == Qt::MoveAction && drag->target() != contextWidget)
never evaluated: action == Qt::MoveAction
never evaluated: drag->target() != contextWidget
0
423 cursor.removeSelectedText();
never executed: cursor.removeSelectedText();
0
424 -
425}
never executed: }
0
426 -
427void QWidgetTextControlPrivate::setCursorPosition(const QPointF &pos) -
428{ -
429 QWidgetTextControl * const q = q_func(); -
430 const int cursorPos = q->hitTest(pos, Qt::FuzzyHit); -
431 if (cursorPos == -1)
never evaluated: cursorPos == -1
0
432 return;
never executed: return;
0
433 cursor.setPosition(cursorPos); -
434}
never executed: }
0
435 -
436void QWidgetTextControlPrivate::setCursorPosition(int pos, QTextCursor::MoveMode mode) -
437{ -
438 cursor.setPosition(pos, mode); -
439 -
440 if (mode != QTextCursor::KeepAnchor) {
partially evaluated: mode != QTextCursor::KeepAnchor
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
441 selectedWordOnDoubleClick = QTextCursor(); -
442 selectedBlockOnTrippleClick = QTextCursor(); -
443 }
executed: }
Execution Count:2
2
444}
executed: }
Execution Count:2
2
445 -
446void QWidgetTextControlPrivate::repaintCursor() -
447{ -
448 QWidgetTextControl * const q = q_func(); -
449 q->updateRequest(cursorRectPlusUnicodeDirectionMarkers(cursor)); -
450}
executed: }
Execution Count:428
428
451 -
452void QWidgetTextControlPrivate::repaintOldAndNewSelection(const QTextCursor &oldSelection) -
453{ -
454 QWidgetTextControl * const q = q_func(); -
455 if (cursor.hasSelection()
evaluated: cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:155
59-155
456 && oldSelection.hasSelection()
evaluated: oldSelection.hasSelection()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:41
18-41
457 && cursor.currentFrame() == oldSelection.currentFrame()
partially evaluated: cursor.currentFrame() == oldSelection.currentFrame()
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
458 && !cursor.hasComplexSelection()
partially evaluated: !cursor.hasComplexSelection()
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
459 && !oldSelection.hasComplexSelection()
partially evaluated: !oldSelection.hasComplexSelection()
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
460 && cursor.anchor() == oldSelection.anchor()
evaluated: cursor.anchor() == oldSelection.anchor()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:1
1-17
461 ) { -
462 QTextCursor differenceSelection(doc); -
463 differenceSelection.setPosition(oldSelection.position()); -
464 differenceSelection.setPosition(cursor.position(), QTextCursor::KeepAnchor); -
465 q->updateRequest(q->selectionRect(differenceSelection)); -
466 } else {
executed: }
Execution Count:17
17
467 if (!oldSelection.isNull())
evaluated: !oldSelection.isNull()
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:130
67-130
468 q->updateRequest(q->selectionRect(oldSelection) | cursorRectPlusUnicodeDirectionMarkers(oldSelection));
executed: q->updateRequest(q->selectionRect(oldSelection) | cursorRectPlusUnicodeDirectionMarkers(oldSelection));
Execution Count:67
67
469 q->updateRequest(q->selectionRect() | cursorRectPlusUnicodeDirectionMarkers(cursor)); -
470 }
executed: }
Execution Count:197
197
471} -
472 -
473void QWidgetTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged ) -
474{ -
475 QWidgetTextControl * const q = q_func(); -
476 if (forceEmitSelectionChanged) {
evaluated: forceEmitSelectionChanged
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:1564
27-1564
477 q->selectionChanged(); -
478 -
479 if (q->parent()) {
partially evaluated: q->parent()
TRUEFALSE
yes
Evaluation Count:27
no
Evaluation Count:0
0-27
480 QAccessibleTextSelectionEvent ev(q->parent(), cursor.anchor(), cursor.position()); -
481 QAccessible::updateAccessibility(&ev); -
482 }
executed: }
Execution Count:27
27
483 -
484 }
executed: }
Execution Count:27
27
485 -
486 if (cursor.position() == lastSelectionPosition
evaluated: cursor.position() == lastSelectionPosition
TRUEFALSE
yes
Evaluation Count:908
yes
Evaluation Count:683
683-908
487 && cursor.anchor() == lastSelectionAnchor)
evaluated: cursor.anchor() == lastSelectionAnchor
TRUEFALSE
yes
Evaluation Count:901
yes
Evaluation Count:7
7-901
488 return;
executed: return;
Execution Count:901
901
489 -
490 bool selectionStateChange = (cursor.hasSelection() -
491 != (lastSelectionPosition != lastSelectionAnchor)); -
492 if (selectionStateChange)
evaluated: selectionStateChange
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:643
47-643
493 q->copyAvailable(cursor.hasSelection());
executed: q->copyAvailable(cursor.hasSelection());
Execution Count:47
47
494 -
495 if (!forceEmitSelectionChanged
evaluated: !forceEmitSelectionChanged
TRUEFALSE
yes
Evaluation Count:663
yes
Evaluation Count:27
27-663
496 && (selectionStateChange
evaluated: selectionStateChange
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:630
33-630
497 || (cursor.hasSelection()
evaluated: cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:629
1-629
498 && (cursor.position() != lastSelectionPosition
partially evaluated: cursor.position() != lastSelectionPosition
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
499 || cursor.anchor() != lastSelectionAnchor)))) {
never evaluated: cursor.anchor() != lastSelectionAnchor
0
500 q->selectionChanged(); -
501 -
502 if (q->parent()) {
partially evaluated: q->parent()
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
503 QAccessibleTextSelectionEvent ev(q->parent(), cursor.anchor(), cursor.position()); -
504 QAccessible::updateAccessibility(&ev); -
505 }
executed: }
Execution Count:34
34
506 -
507 }
executed: }
Execution Count:34
34
508 q->microFocusChanged(); -
509 lastSelectionPosition = cursor.position(); -
510 lastSelectionAnchor = cursor.anchor(); -
511}
executed: }
Execution Count:690
690
512 -
513void QWidgetTextControlPrivate::_q_updateCurrentCharFormatAndSelection() -
514{ -
515 updateCurrentCharFormat(); -
516 selectionChanged(); -
517}
executed: }
Execution Count:1479
1479
518 -
519 -
520void QWidgetTextControlPrivate::setClipboardSelection() -
521{ -
522 QClipboard *clipboard = QApplication::clipboard(); -
523 if (!cursor.hasSelection() || !clipboard->supportsSelection())
never evaluated: !cursor.hasSelection()
never evaluated: !clipboard->supportsSelection()
0
524 return;
never executed: return;
0
525 QWidgetTextControl * const q = q_func(); -
526 QMimeData *data = q->createMimeDataFromSelection(); -
527 clipboard->setMimeData(data, QClipboard::Selection); -
528}
never executed: }
0
529 -
530 -
531void QWidgetTextControlPrivate::_q_emitCursorPosChanged(const QTextCursor &someCursor) -
532{ -
533 QWidgetTextControl * const q = q_func(); -
534 if (someCursor.isCopyOf(cursor)) {
evaluated: someCursor.isCopyOf(cursor)
TRUEFALSE
yes
Evaluation Count:147
yes
Evaluation Count:240
147-240
535 q->cursorPositionChanged(); -
536 q->microFocusChanged(); -
537 }
executed: }
Execution Count:147
147
538}
executed: }
Execution Count:387
387
539 -
540void QWidgetTextControlPrivate::_q_documentLayoutChanged() -
541{ -
542 QWidgetTextControl * const q = q_func(); -
543 QAbstractTextDocumentLayout *layout = doc->documentLayout(); -
544 QObject::connect(layout, "2""update(QRectF)", q, "2""updateRequest(QRectF)"); -
545 QObject::connect(layout, "2""updateBlock(QTextBlock)", q, "1""_q_updateBlock(QTextBlock)"); -
546 QObject::connect(layout, "2""documentSizeChanged(QSizeF)", q, "2""documentSizeChanged(QSizeF)"); -
547 -
548}
executed: }
Execution Count:387
387
549 -
550void QWidgetTextControlPrivate::setBlinkingCursorEnabled(bool enable) -
551{ -
552 QWidgetTextControl * const q = q_func(); -
553 -
554 if (enable && QApplication::cursorFlashTime() > 0)
evaluated: enable
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:73
partially evaluated: QApplication::cursorFlashTime() > 0
TRUEFALSE
yes
Evaluation Count:53
no
Evaluation Count:0
0-73
555 cursorBlinkTimer.start(QApplication::cursorFlashTime() / 2, q);
executed: cursorBlinkTimer.start(QApplication::cursorFlashTime() / 2, q);
Execution Count:53
53
556 else -
557 cursorBlinkTimer.stop();
executed: cursorBlinkTimer.stop();
Execution Count:73
73
558 -
559 cursorOn = enable; -
560 -
561 repaintCursor(); -
562}
executed: }
Execution Count:126
126
563 -
564void QWidgetTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition) -
565{ -
566 QWidgetTextControl * const q = q_func(); -
567 -
568 -
569 if (suggestedNewPosition >= selectedWordOnDoubleClick.selectionStart()
never evaluated: suggestedNewPosition >= selectedWordOnDoubleClick.selectionStart()
0
570 && suggestedNewPosition <= selectedWordOnDoubleClick.selectionEnd()) {
never evaluated: suggestedNewPosition <= selectedWordOnDoubleClick.selectionEnd()
0
571 q->setTextCursor(selectedWordOnDoubleClick); -
572 return;
never executed: return;
0
573 } -
574 -
575 QTextCursor curs = selectedWordOnDoubleClick; -
576 curs.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor); -
577 -
578 if (!curs.movePosition(QTextCursor::StartOfWord))
never evaluated: !curs.movePosition(QTextCursor::StartOfWord)
0
579 return;
never executed: return;
0
580 const int wordStartPos = curs.position(); -
581 -
582 const int blockPos = curs.block().position(); -
583 const QPointF blockCoordinates = q->blockBoundingRect(curs.block()).topLeft(); -
584 -
585 QTextLine line = currentTextLine(curs); -
586 if (!line.isValid())
never evaluated: !line.isValid()
0
587 return;
never executed: return;
0
588 -
589 const qreal wordStartX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x(); -
590 -
591 if (!curs.movePosition(QTextCursor::EndOfWord))
never evaluated: !curs.movePosition(QTextCursor::EndOfWord)
0
592 return;
never executed: return;
0
593 const int wordEndPos = curs.position(); -
594 -
595 const QTextLine otherLine = currentTextLine(curs); -
596 if (otherLine.textStart() != line.textStart()
never evaluated: otherLine.textStart() != line.textStart()
0
597 || wordEndPos == wordStartPos)
never evaluated: wordEndPos == wordStartPos
0
598 return;
never executed: return;
0
599 -
600 const qreal wordEndX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x(); -
601 -
602 if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX))
never evaluated: !wordSelectionEnabled
never evaluated: mouseXPosition < wordStartX
never evaluated: mouseXPosition > wordEndX
0
603 return;
never executed: return;
0
604 -
605 if (wordSelectionEnabled) {
never evaluated: wordSelectionEnabled
0
606 if (suggestedNewPosition < selectedWordOnDoubleClick.position()) {
never evaluated: suggestedNewPosition < selectedWordOnDoubleClick.position()
0
607 cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); -
608 setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); -
609 } else {
never executed: }
0
610 cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); -
611 setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); -
612 }
never executed: }
0
613 } else { -
614 -
615 -
616 if (suggestedNewPosition < selectedWordOnDoubleClick.position())
never evaluated: suggestedNewPosition < selectedWordOnDoubleClick.position()
0
617 cursor.setPosition(selectedWordOnDoubleClick.selectionEnd());
never executed: cursor.setPosition(selectedWordOnDoubleClick.selectionEnd());
0
618 else -
619 cursor.setPosition(selectedWordOnDoubleClick.selectionStart());
never executed: cursor.setPosition(selectedWordOnDoubleClick.selectionStart());
0
620 -
621 const qreal differenceToStart = mouseXPosition - wordStartX; -
622 const qreal differenceToEnd = wordEndX - mouseXPosition; -
623 -
624 if (differenceToStart < differenceToEnd)
never evaluated: differenceToStart < differenceToEnd
0
625 setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
never executed: setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
0
626 else -
627 setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
never executed: setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
0
628 } -
629 -
630 if (interactionFlags & Qt::TextSelectableByMouse) {
never evaluated: interactionFlags & Qt::TextSelectableByMouse
0
631 -
632 setClipboardSelection(); -
633 -
634 selectionChanged(true); -
635 }
never executed: }
0
636}
never executed: }
0
637 -
638void QWidgetTextControlPrivate::extendBlockwiseSelection(int suggestedNewPosition) -
639{ -
640 QWidgetTextControl * const q = q_func(); -
641 -
642 -
643 if (suggestedNewPosition >= selectedBlockOnTrippleClick.selectionStart()
never evaluated: suggestedNewPosition >= selectedBlockOnTrippleClick.selectionStart()
0
644 && suggestedNewPosition <= selectedBlockOnTrippleClick.selectionEnd()) {
never evaluated: suggestedNewPosition <= selectedBlockOnTrippleClick.selectionEnd()
0
645 q->setTextCursor(selectedBlockOnTrippleClick); -
646 return;
never executed: return;
0
647 } -
648 -
649 if (suggestedNewPosition < selectedBlockOnTrippleClick.position()) {
never evaluated: suggestedNewPosition < selectedBlockOnTrippleClick.position()
0
650 cursor.setPosition(selectedBlockOnTrippleClick.selectionEnd()); -
651 cursor.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor); -
652 cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); -
653 } else {
never executed: }
0
654 cursor.setPosition(selectedBlockOnTrippleClick.selectionStart()); -
655 cursor.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor); -
656 cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); -
657 cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); -
658 }
never executed: }
0
659 -
660 if (interactionFlags & Qt::TextSelectableByMouse) {
never evaluated: interactionFlags & Qt::TextSelectableByMouse
0
661 -
662 setClipboardSelection(); -
663 -
664 selectionChanged(true); -
665 }
never executed: }
0
666}
never executed: }
0
667 -
668void QWidgetTextControlPrivate::_q_deleteSelected() -
669{ -
670 if (!(interactionFlags & Qt::TextEditable) || !cursor.hasSelection())
never evaluated: !(interactionFlags & Qt::TextEditable)
never evaluated: !cursor.hasSelection()
0
671 return;
never executed: return;
0
672 cursor.removeSelectedText(); -
673}
never executed: }
0
674 -
675void QWidgetTextControl::undo() -
676{ -
677 QWidgetTextControlPrivate * const d = d_func(); -
678 d->repaintSelection(); -
679 const int oldCursorPos = d->cursor.position(); -
680 d->doc->undo(&d->cursor); -
681 if (d->cursor.position() != oldCursorPos)
partially evaluated: d->cursor.position() != oldCursorPos
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
682 cursorPositionChanged();
executed: cursorPositionChanged();
Execution Count:5
5
683 microFocusChanged(); -
684 ensureCursorVisible(); -
685}
executed: }
Execution Count:5
5
686 -
687void QWidgetTextControl::redo() -
688{ -
689 QWidgetTextControlPrivate * const d = d_func(); -
690 d->repaintSelection(); -
691 const int oldCursorPos = d->cursor.position(); -
692 d->doc->redo(&d->cursor); -
693 if (d->cursor.position() != oldCursorPos)
partially evaluated: d->cursor.position() != oldCursorPos
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
694 cursorPositionChanged();
executed: cursorPositionChanged();
Execution Count:5
5
695 microFocusChanged(); -
696 ensureCursorVisible(); -
697}
executed: }
Execution Count:5
5
698 -
699QWidgetTextControl::QWidgetTextControl(QObject *parent) -
700 : QObject(*new QWidgetTextControlPrivate, parent) -
701{ -
702 QWidgetTextControlPrivate * const d = d_func(); -
703 d->init(); -
704}
executed: }
Execution Count:291
291
705 -
706QWidgetTextControl::QWidgetTextControl(const QString &text, QObject *parent) -
707 : QObject(*new QWidgetTextControlPrivate, parent) -
708{ -
709 QWidgetTextControlPrivate * const d = d_func(); -
710 d->init(Qt::RichText, text); -
711}
never executed: }
0
712 -
713QWidgetTextControl::QWidgetTextControl(QTextDocument *doc, QObject *parent) -
714 : QObject(*new QWidgetTextControlPrivate, parent) -
715{ -
716 QWidgetTextControlPrivate * const d = d_func(); -
717 d->init(Qt::RichText, QString(), doc); -
718}
never executed: }
0
719 -
720QWidgetTextControl::~QWidgetTextControl() -
721{ -
722} -
723 -
724void QWidgetTextControl::setDocument(QTextDocument *document) -
725{ -
726 QWidgetTextControlPrivate * const d = d_func(); -
727 if (d->doc == document)
partially evaluated: d->doc == document
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:96
0-96
728 return;
never executed: return;
0
729 -
730 d->doc->disconnect(this); -
731 d->doc->documentLayout()->disconnect(this); -
732 d->doc->documentLayout()->setPaintDevice(0); -
733 -
734 if (d->doc->parent() == this)
evaluated: d->doc->parent() == this
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:1
1-95
735 delete d->doc;
executed: delete d->doc;
Execution Count:95
95
736 -
737 d->doc = 0; -
738 d->setContent(Qt::RichText, QString(), document); -
739}
executed: }
Execution Count:96
96
740 -
741QTextDocument *QWidgetTextControl::document() const -
742{ -
743 const QWidgetTextControlPrivate * const d = d_func(); -
744 return d->doc;
executed: return d->doc;
Execution Count:7884
7884
745} -
746 -
747void QWidgetTextControl::setTextCursor(const QTextCursor &cursor) -
748{ -
749 QWidgetTextControlPrivate * const d = d_func(); -
750 d->cursorIsFocusIndicator = false; -
751 const bool posChanged = cursor.position() != d->cursor.position(); -
752 const QTextCursor oldSelection = d->cursor; -
753 d->cursor = cursor; -
754 d->cursorOn = d->hasFocus && (d->interactionFlags & Qt::TextEditable);
evaluated: d->hasFocus
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:18
evaluated: (d->interactionFlags & Qt::TextEditable)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10
2-18
755 d->_q_updateCurrentCharFormatAndSelection(); -
756 ensureCursorVisible(); -
757 d->repaintOldAndNewSelection(oldSelection); -
758 if (posChanged)
evaluated: posChanged
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:5
5-25
759 cursorPositionChanged();
executed: cursorPositionChanged();
Execution Count:25
25
760}
executed: }
Execution Count:30
30
761 -
762QTextCursor QWidgetTextControl::textCursor() const -
763{ -
764 const QWidgetTextControlPrivate * const d = d_func(); -
765 return d->cursor;
executed: return d->cursor;
Execution Count:1025
1025
766} -
767 -
768 -
769 -
770void QWidgetTextControl::cut() -
771{ -
772 QWidgetTextControlPrivate * const d = d_func(); -
773 if (!(d->interactionFlags & Qt::TextEditable) || !d->cursor.hasSelection())
partially evaluated: !(d->interactionFlags & Qt::TextEditable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
partially evaluated: !d->cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
774 return;
never executed: return;
0
775 copy(); -
776 d->cursor.removeSelectedText(); -
777}
executed: }
Execution Count:4
4
778 -
779void QWidgetTextControl::copy() -
780{ -
781 QWidgetTextControlPrivate * const d = d_func(); -
782 if (!d->cursor.hasSelection())
partially evaluated: !d->cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
783 return;
never executed: return;
0
784 QMimeData *data = createMimeDataFromSelection(); -
785 QApplication::clipboard()->setMimeData(data); -
786}
executed: }
Execution Count:7
7
787 -
788void QWidgetTextControl::paste(QClipboard::Mode mode) -
789{ -
790 const QMimeData *md = QApplication::clipboard()->mimeData(mode); -
791 if (md)
partially evaluated: md
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
792 insertFromMimeData(md);
executed: insertFromMimeData(md);
Execution Count:3
3
793}
executed: }
Execution Count:3
3
794 -
795 -
796void QWidgetTextControl::clear() -
797{ -
798 QWidgetTextControlPrivate * const d = d_func(); -
799 -
800 d->extraSelections.clear(); -
801 d->setContent(); -
802}
executed: }
Execution Count:28
28
803 -
804 -
805void QWidgetTextControl::selectAll() -
806{ -
807 QWidgetTextControlPrivate * const d = d_func(); -
808 const int selectionLength = qAbs(d->cursor.position() - d->cursor.anchor()); -
809 d->cursor.select(QTextCursor::Document); -
810 d->selectionChanged(selectionLength != qAbs(d->cursor.position() - d->cursor.anchor())); -
811 d->cursorIsFocusIndicator = false; -
812 updateRequest(); -
813}
executed: }
Execution Count:5
5
814 -
815void QWidgetTextControl::processEvent(QEvent *e, const QPointF &coordinateOffset, QWidget *contextWidget) -
816{ -
817 QMatrix m; -
818 m.translate(coordinateOffset.x(), coordinateOffset.y()); -
819 processEvent(e, m, contextWidget); -
820}
executed: }
Execution Count:496
496
821 -
822void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget) -
823{ -
824 QWidgetTextControlPrivate * const d = d_func(); -
825 if (d->interactionFlags == Qt::NoTextInteraction) {
evaluated: d->interactionFlags == Qt::NoTextInteraction
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:494
2-494
826 e->ignore(); -
827 return;
executed: return;
Execution Count:2
2
828 } -
829 -
830 d->contextWidget = contextWidget; -
831 -
832 if (!d->contextWidget) {
evaluated: !d->contextWidget
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:472
22-472
833 switch (e->type()) { -
834 -
835 case QEvent::GraphicsSceneMouseMove: -
836 case QEvent::GraphicsSceneMousePress: -
837 case QEvent::GraphicsSceneMouseRelease: -
838 case QEvent::GraphicsSceneMouseDoubleClick: -
839 case QEvent::GraphicsSceneContextMenu: -
840 case QEvent::GraphicsSceneHoverEnter: -
841 case QEvent::GraphicsSceneHoverMove: -
842 case QEvent::GraphicsSceneHoverLeave: -
843 case QEvent::GraphicsSceneHelp: -
844 case QEvent::GraphicsSceneDragEnter: -
845 case QEvent::GraphicsSceneDragMove: -
846 case QEvent::GraphicsSceneDragLeave: -
847 case QEvent::GraphicsSceneDrop: { -
848 QGraphicsSceneEvent *ev = static_cast<QGraphicsSceneEvent *>(e); -
849 d->contextWidget = ev->widget(); -
850 break;
never executed: break;
0
851 } -
852 -
853 default: break;
executed: break;
Execution Count:22
22
854 }; -
855 }
executed: }
Execution Count:22
22
856 -
857 switch (e->type()) { -
858 case QEvent::KeyPress: -
859 d->keyPressEvent(static_cast<QKeyEvent *>(e)); -
860 break;
executed: break;
Execution Count:165
165
861 case QEvent::MouseButtonPress: { -
862 QMouseEvent *ev = static_cast<QMouseEvent *>(e); -
863 d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), -
864 ev->buttons(), ev->globalPos()); -
865 break; }
executed: break;
Execution Count:7
7
866 case QEvent::MouseMove: { -
867 QMouseEvent *ev = static_cast<QMouseEvent *>(e); -
868 d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), -
869 ev->buttons(), ev->globalPos()); -
870 break; }
executed: break;
Execution Count:1
1
871 case QEvent::MouseButtonRelease: { -
872 QMouseEvent *ev = static_cast<QMouseEvent *>(e); -
873 d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), -
874 ev->buttons(), ev->globalPos()); -
875 break; }
executed: break;
Execution Count:1
1
876 case QEvent::MouseButtonDblClick: { -
877 QMouseEvent *ev = static_cast<QMouseEvent *>(e); -
878 d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), -
879 ev->buttons(), ev->globalPos()); -
880 break; }
never executed: break;
0
881 case QEvent::InputMethod: -
882 d->inputMethodEvent(static_cast<QInputMethodEvent *>(e)); -
883 break;
never executed: break;
0
884 -
885 case QEvent::ContextMenu: { -
886 QContextMenuEvent *ev = static_cast<QContextMenuEvent *>(e); -
887 d->contextMenuEvent(ev->globalPos(), matrix.map(ev->pos()), contextWidget); -
888 break; }
never executed: break;
0
889 -
890 case QEvent::FocusIn: -
891 case QEvent::FocusOut: -
892 d->focusEvent(static_cast<QFocusEvent *>(e)); -
893 break;
executed: break;
Execution Count:149
149
894 -
895 case QEvent::EnabledChange: -
896 d->isEnabled = e->isAccepted(); -
897 break;
never executed: break;
0
898 -
899 -
900 case QEvent::ToolTip: { -
901 QHelpEvent *ev = static_cast<QHelpEvent *>(e); -
902 d->showToolTip(ev->globalPos(), matrix.map(ev->pos()), contextWidget); -
903 break;
never executed: break;
0
904 } -
905 -
906 -
907 -
908 case QEvent::DragEnter: { -
909 QDragEnterEvent *ev = static_cast<QDragEnterEvent *>(e); -
910 if (d->dragEnterEvent(e, ev->mimeData()))
never evaluated: d->dragEnterEvent(e, ev->mimeData())
0
911 ev->acceptProposedAction();
never executed: ev->acceptProposedAction();
0
912 break;
never executed: break;
0
913 } -
914 case QEvent::DragLeave: -
915 d->dragLeaveEvent(); -
916 break;
never executed: break;
0
917 case QEvent::DragMove: { -
918 QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e); -
919 if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
never evaluated: d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos()))
0
920 ev->acceptProposedAction();
never executed: ev->acceptProposedAction();
0
921 break;
never executed: break;
0
922 } -
923 case QEvent::Drop: { -
924 QDropEvent *ev = static_cast<QDropEvent *>(e); -
925 if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
never evaluated: d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source())
0
926 ev->acceptProposedAction();
never executed: ev->acceptProposedAction();
0
927 break;
never executed: break;
0
928 } -
929 -
930 -
931 -
932 case QEvent::GraphicsSceneMousePress: { -
933 QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e); -
934 d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), -
935 ev->screenPos()); -
936 break; }
never executed: break;
0
937 case QEvent::GraphicsSceneMouseMove: { -
938 QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e); -
939 d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), -
940 ev->screenPos()); -
941 break; }
never executed: break;
0
942 case QEvent::GraphicsSceneMouseRelease: { -
943 QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e); -
944 d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), -
945 ev->screenPos()); -
946 break; }
never executed: break;
0
947 case QEvent::GraphicsSceneMouseDoubleClick: { -
948 QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e); -
949 d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), -
950 ev->screenPos()); -
951 break; }
never executed: break;
0
952 case QEvent::GraphicsSceneContextMenu: { -
953 QGraphicsSceneContextMenuEvent *ev = static_cast<QGraphicsSceneContextMenuEvent *>(e); -
954 d->contextMenuEvent(ev->screenPos(), matrix.map(ev->pos()), contextWidget); -
955 break; }
never executed: break;
0
956 -
957 case QEvent::GraphicsSceneHoverMove: { -
958 QGraphicsSceneHoverEvent *ev = static_cast<QGraphicsSceneHoverEvent *>(e); -
959 d->mouseMoveEvent(ev, Qt::NoButton, matrix.map(ev->pos()), ev->modifiers(),Qt::NoButton, -
960 ev->screenPos()); -
961 break; }
never executed: break;
0
962 -
963 case QEvent::GraphicsSceneDragEnter: { -
964 QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e); -
965 if (d->dragEnterEvent(e, ev->mimeData()))
never evaluated: d->dragEnterEvent(e, ev->mimeData())
0
966 ev->acceptProposedAction();
never executed: ev->acceptProposedAction();
0
967 break; }
never executed: break;
0
968 case QEvent::GraphicsSceneDragLeave: -
969 d->dragLeaveEvent(); -
970 break;
never executed: break;
0
971 case QEvent::GraphicsSceneDragMove: { -
972 QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e); -
973 if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
never evaluated: d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos()))
0
974 ev->acceptProposedAction();
never executed: ev->acceptProposedAction();
0
975 break; }
never executed: break;
0
976 case QEvent::GraphicsSceneDrop: { -
977 QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e); -
978 if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
never evaluated: d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source())
0
979 ev->accept();
never executed: ev->accept();
0
980 break; }
never executed: break;
0
981 case QEvent::ShortcutOverride: -
982 if (d->interactionFlags & Qt::TextEditable) {
evaluated: d->interactionFlags & Qt::TextEditable
TRUEFALSE
yes
Evaluation Count:159
yes
Evaluation Count:11
11-159
983 QKeyEvent* ke = static_cast<QKeyEvent *>(e); -
984 if (ke->modifiers() == Qt::NoModifier
evaluated: ke->modifiers() == Qt::NoModifier
TRUEFALSE
yes
Evaluation Count:89
yes
Evaluation Count:70
70-89
985 || ke->modifiers() == Qt::ShiftModifier
evaluated: ke->modifiers() == Qt::ShiftModifier
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:18
18-52
986 || ke->modifiers() == Qt::KeypadModifier) {
evaluated: ke->modifiers() == Qt::KeypadModifier
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:17
1-17
987 if (ke->key() < Qt::Key_Escape) {
evaluated: ke->key() < Qt::Key_Escape
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:72
70-72
988 ke->accept(); -
989 } else {
executed: }
Execution Count:70
70
990 switch (ke->key()) { -
991 case Qt::Key_Return: -
992 case Qt::Key_Enter: -
993 case Qt::Key_Delete: -
994 case Qt::Key_Home: -
995 case Qt::Key_End: -
996 case Qt::Key_Backspace: -
997 case Qt::Key_Left: -
998 case Qt::Key_Right: -
999 case Qt::Key_Up: -
1000 case Qt::Key_Down: -
1001 case Qt::Key_Tab: -
1002 ke->accept(); -
1003 default: -
1004 break;
executed: break;
Execution Count:72
72
1005 } -
1006 }
executed: }
Execution Count:72
72
1007 -
1008 } else if (ke == QKeySequence::Copy
partially evaluated: ke == QKeySequence::Copy
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
1009 || ke == QKeySequence::Paste
partially evaluated: ke == QKeySequence::Paste
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
1010 || ke == QKeySequence::Cut
evaluated: ke == QKeySequence::Cut
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:15
2-15
1011 || ke == QKeySequence::Redo
partially evaluated: ke == QKeySequence::Redo
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1012 || ke == QKeySequence::Undo
partially evaluated: ke == QKeySequence::Undo
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1013 || ke == QKeySequence::MoveToNextWord
partially evaluated: ke == QKeySequence::MoveToNextWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1014 || ke == QKeySequence::MoveToPreviousWord
partially evaluated: ke == QKeySequence::MoveToPreviousWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1015 || ke == QKeySequence::MoveToStartOfDocument
partially evaluated: ke == QKeySequence::MoveToStartOfDocument
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1016 || ke == QKeySequence::MoveToEndOfDocument
partially evaluated: ke == QKeySequence::MoveToEndOfDocument
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1017 || ke == QKeySequence::SelectNextWord
partially evaluated: ke == QKeySequence::SelectNextWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1018 || ke == QKeySequence::SelectPreviousWord
partially evaluated: ke == QKeySequence::SelectPreviousWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1019 || ke == QKeySequence::SelectStartOfLine
partially evaluated: ke == QKeySequence::SelectStartOfLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1020 || ke == QKeySequence::SelectEndOfLine
partially evaluated: ke == QKeySequence::SelectEndOfLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1021 || ke == QKeySequence::SelectStartOfBlock
partially evaluated: ke == QKeySequence::SelectStartOfBlock
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1022 || ke == QKeySequence::SelectEndOfBlock
partially evaluated: ke == QKeySequence::SelectEndOfBlock
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1023 || ke == QKeySequence::SelectStartOfDocument
partially evaluated: ke == QKeySequence::SelectStartOfDocument
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1024 || ke == QKeySequence::SelectEndOfDocument
partially evaluated: ke == QKeySequence::SelectEndOfDocument
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1025 || ke == QKeySequence::SelectAll
partially evaluated: ke == QKeySequence::SelectAll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1026 ) { -
1027 ke->accept(); -
1028 -
1029 }
executed: }
Execution Count:2
2
1030 } -
1031 break;
executed: break;
Execution Count:170
170
1032 default: -
1033 break;
executed: break;
Execution Count:1
1
1034 } -
1035}
executed: }
Execution Count:494
494
1036 -
1037bool QWidgetTextControl::event(QEvent *e) -
1038{ -
1039 return QObject::event(e);
executed: return QObject::event(e);
Execution Count:476
476
1040} -
1041 -
1042void QWidgetTextControl::timerEvent(QTimerEvent *e) -
1043{ -
1044 QWidgetTextControlPrivate * const d = d_func(); -
1045 if (e->timerId() == d->cursorBlinkTimer.timerId()) {
partially evaluated: e->timerId() == d->cursorBlinkTimer.timerId()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1046 d->cursorOn = !d->cursorOn; -
1047 -
1048 if (d->cursor.hasSelection())
partially evaluated: d->cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1049 d->cursorOn &= (QApplication::style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected) 0
1050 != 0);
never executed: d->cursorOn &= (QApplication::style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected) != 0);
0
1051 -
1052 d->repaintCursor(); -
1053 } else if (e->timerId() == d->trippleClickTimer.timerId()) {
executed: }
Execution Count:1
never evaluated: e->timerId() == d->trippleClickTimer.timerId()
0-1
1054 d->trippleClickTimer.stop(); -
1055 }
never executed: }
0
1056} -
1057 -
1058void QWidgetTextControl::setPlainText(const QString &text) -
1059{ -
1060 QWidgetTextControlPrivate * const d = d_func(); -
1061 d->setContent(Qt::PlainText, text); -
1062}
executed: }
Execution Count:167
167
1063 -
1064void QWidgetTextControl::setHtml(const QString &text) -
1065{ -
1066 QWidgetTextControlPrivate * const d = d_func(); -
1067 d->setContent(Qt::RichText, text); -
1068}
executed: }
Execution Count:72
72
1069 -
1070void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e) -
1071{ -
1072 QWidgetTextControl * const q = q_func(); -
1073 -
1074 if (e == QKeySequence::SelectAll) {
evaluated: e == QKeySequence::SelectAll
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:164
1-164
1075 e->accept(); -
1076 q->selectAll(); -
1077 return;
executed: return;
Execution Count:1
1
1078 } -
1079 -
1080 else if (e == QKeySequence::Copy) {
evaluated: e == QKeySequence::Copy
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:163
1-163
1081 e->accept(); -
1082 q->copy(); -
1083 return;
executed: return;
Execution Count:1
1
1084 } -
1085 -
1086 -
1087 -
1088 if (interactionFlags & Qt::TextSelectableByKeyboard
evaluated: interactionFlags & Qt::TextSelectableByKeyboard
TRUEFALSE
yes
Evaluation Count:154
yes
Evaluation Count:9
9-154
1089 && cursorMoveKeyEvent(e))
evaluated: cursorMoveKeyEvent(e)
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:120
34-120
1090 goto accept;
executed: goto accept;
Execution Count:34
34
1091 -
1092 if (interactionFlags & Qt::LinksAccessibleByKeyboard) {
evaluated: interactionFlags & Qt::LinksAccessibleByKeyboard
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:123
6-123
1093 if ((e->key() == Qt::Key_Return
partially evaluated: e->key() == Qt::Key_Return
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1094 || e->key() == Qt::Key_Enter
partially evaluated: e->key() == Qt::Key_Enter
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1095 -
1096 -
1097 -
1098 ) -
1099 && cursor.hasSelection()) {
partially evaluated: cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1100 -
1101 e->accept(); -
1102 activateLinkUnderCursor(); -
1103 return;
executed: return;
Execution Count:6
6
1104 } -
1105 }
never executed: }
0
1106 -
1107 if (!(interactionFlags & Qt::TextEditable)) {
evaluated: !(interactionFlags & Qt::TextEditable)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:120
3-120
1108 e->ignore(); -
1109 return;
executed: return;
Execution Count:3
3
1110 } -
1111 -
1112 if (e->key() == Qt::Key_Direction_L || e->key() == Qt::Key_Direction_R) {
partially evaluated: e->key() == Qt::Key_Direction_L
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
partially evaluated: e->key() == Qt::Key_Direction_R
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
1113 QTextBlockFormat fmt; -
1114 fmt.setLayoutDirection((e->key() == Qt::Key_Direction_L) ? Qt::LeftToRight : Qt::RightToLeft); -
1115 cursor.mergeBlockFormat(fmt); -
1116 goto accept;
never executed: goto accept;
0
1117 } -
1118 -
1119 -
1120 -
1121 -
1122 -
1123 repaintSelection(); -
1124 -
1125 if (e->key() == Qt::Key_Backspace && !(e->modifiers() & ~Qt::ShiftModifier)) {
evaluated: e->key() == Qt::Key_Backspace
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:114
partially evaluated: !(e->modifiers() & ~Qt::ShiftModifier)
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-114
1126 QTextBlockFormat blockFmt = cursor.blockFormat(); -
1127 QTextList *list = cursor.currentList(); -
1128 if (list && cursor.atBlockStart() && !cursor.hasSelection()) {
evaluated: list
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
evaluated: cursor.atBlockStart()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: !cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-4
1129 list->remove(cursor.block()); -
1130 } else if (cursor.atBlockStart() && blockFmt.indent() > 0) {
executed: }
Execution Count:2
evaluated: cursor.atBlockStart()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: blockFmt.indent() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1131 blockFmt.setIndent(blockFmt.indent() - 1); -
1132 cursor.setBlockFormat(blockFmt); -
1133 } else {
executed: }
Execution Count:2
2
1134 QTextCursor localCursor = cursor; -
1135 localCursor.deletePreviousChar(); -
1136 }
executed: }
Execution Count:2
2
1137 goto accept;
executed: goto accept;
Execution Count:6
6
1138 } -
1139 -
1140 else if (e == QKeySequence::InsertParagraphSeparator) {
evaluated: e == QKeySequence::InsertParagraphSeparator
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:110
4-110
1141 cursor.insertBlock(); -
1142 e->accept(); -
1143 goto accept;
executed: goto accept;
Execution Count:4
4
1144 } else if (e == QKeySequence::InsertLineSeparator) {
evaluated: e == QKeySequence::InsertLineSeparator
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:109
1-109
1145 cursor.insertText(QString(QChar::LineSeparator)); -
1146 e->accept(); -
1147 goto accept;
executed: goto accept;
Execution Count:1
1
1148 } -
1149 -
1150 if (false) {
partially evaluated: false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:109
0-109
1151 }
never executed: }
0
1152 -
1153 else if (e == QKeySequence::Undo) {
partially evaluated: e == QKeySequence::Undo
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:109
0-109
1154 q->undo(); -
1155 }
never executed: }
0
1156 else if (e == QKeySequence::Redo) {
partially evaluated: e == QKeySequence::Redo
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:109
0-109
1157 q->redo(); -
1158 }
never executed: }
0
1159 -
1160 else if (e == QKeySequence::Cut) {
evaluated: e == QKeySequence::Cut
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:107
2-107
1161 q->cut(); -
1162 }
executed: }
Execution Count:2
2
1163 else if (e == QKeySequence::Paste) {
partially evaluated: e == QKeySequence::Paste
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
1164 QClipboard::Mode mode = QClipboard::Clipboard; -
1165 if (QGuiApplication::clipboard()->supportsSelection()) {
never evaluated: QGuiApplication::clipboard()->supportsSelection()
0
1166 if (e->modifiers() == (Qt::CTRL | Qt::SHIFT) && e->key() == Qt::Key_Insert)
never evaluated: e->modifiers() == (Qt::CTRL | Qt::SHIFT)
never evaluated: e->key() == Qt::Key_Insert
0
1167 mode = QClipboard::Selection;
never executed: mode = QClipboard::Selection;
0
1168 }
never executed: }
0
1169 q->paste(mode); -
1170 }
never executed: }
0
1171 -
1172 else if (e == QKeySequence::Delete) {
partially evaluated: e == QKeySequence::Delete
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
1173 QTextCursor localCursor = cursor; -
1174 localCursor.deleteChar(); -
1175 }
never executed: }
0
1176 else if (e == QKeySequence::DeleteEndOfWord) {
partially evaluated: e == QKeySequence::DeleteEndOfWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
1177 if (!cursor.hasSelection())
never evaluated: !cursor.hasSelection()
0
1178 cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);
never executed: cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);
0
1179 cursor.removeSelectedText(); -
1180 }
never executed: }
0
1181 else if (e == QKeySequence::DeleteStartOfWord) {
partially evaluated: e == QKeySequence::DeleteStartOfWord
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
1182 if (!cursor.hasSelection())
never evaluated: !cursor.hasSelection()
0
1183 cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
never executed: cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
0
1184 cursor.removeSelectedText(); -
1185 }
never executed: }
0
1186 else if (e == QKeySequence::DeleteEndOfLine) {
partially evaluated: e == QKeySequence::DeleteEndOfLine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
1187 QTextBlock block = cursor.block(); -
1188 if (cursor.position() == block.position() + block.length() - 2)
never evaluated: cursor.position() == block.position() + block.length() - 2
0
1189 cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
never executed: cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
0
1190 else -
1191 cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
never executed: cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
0
1192 cursor.removeSelectedText(); -
1193 }
never executed: }
0
1194 -
1195 else { -
1196 goto process;
executed: goto process;
Execution Count:107
107
1197 } -
1198 goto accept;
executed: goto accept;
Execution Count:2
2
1199 -
1200process: -
1201 { -
1202 QString text = e->text(); -
1203 if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
evaluated: !text.isEmpty()
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:36
partially evaluated: text.at(0).isPrint()
TRUEFALSE
yes
Evaluation Count:71
no
Evaluation Count:0
never evaluated: text.at(0) == QLatin1Char('\t')
0-71
1204 if (overwriteMode
evaluated: overwriteMode
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:61
10-61
1205 -
1206 -
1207 && !cursor.hasSelection()
partially evaluated: !cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
1208 && !cursor.atBlockEnd())
evaluated: !cursor.atBlockEnd()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
1209 cursor.deleteChar();
executed: cursor.deleteChar();
Execution Count:5
5
1210 -
1211 cursor.insertText(text); -
1212 selectionChanged(); -
1213 } else {
executed: }
Execution Count:71
71
1214 e->ignore(); -
1215 return;
executed: return;
Execution Count:36
36
1216 } -
1217 } -
1218 -
1219 accept:
code before this statement executed: accept:
Execution Count:71
71
1220 -
1221 e->accept(); -
1222 cursorOn = true; -
1223 -
1224 q->ensureCursorVisible(); -
1225 -
1226 updateCurrentCharFormat(); -
1227}
executed: }
Execution Count:118
118
1228 -
1229QVariant QWidgetTextControl::loadResource(int type, const QUrl &name) -
1230{ -
1231 -
1232 -
1233 -
1234 -
1235 if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(parent())) {
partially evaluated: QTextEdit *textEdit = qobject_cast<QTextEdit *>(parent())
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1236 QUrl resolvedName = textEdit->d_func()->resolveUrl(name); -
1237 return textEdit->loadResource(type, resolvedName);
executed: return textEdit->loadResource(type, resolvedName);
Execution Count:6
6
1238 } -
1239 -
1240 return QVariant();
never executed: return QVariant();
0
1241} -
1242 -
1243void QWidgetTextControlPrivate::_q_updateBlock(const QTextBlock &block) -
1244{ -
1245 QWidgetTextControl * const q = q_func(); -
1246 QRectF br = q->blockBoundingRect(block); -
1247 br.setRight(qreal(2147483647)); -
1248 q->updateRequest(br); -
1249}
executed: }
Execution Count:355
355
1250 -
1251QRectF QWidgetTextControlPrivate::rectForPosition(int position) const -
1252{ -
1253 const QWidgetTextControl * const q = q_func(); -
1254 const QTextBlock block = doc->findBlock(position); -
1255 if (!block.isValid())
partially evaluated: !block.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2107
0-2107
1256 return QRectF();
never executed: return QRectF();
0
1257 const QAbstractTextDocumentLayout *docLayout = doc->documentLayout(); -
1258 const QTextLayout *layout = block.layout(); -
1259 const QPointF layoutPos = q->blockBoundingRect(block).topLeft(); -
1260 int relativePos = position - block.position(); -
1261 if (preeditCursor != 0) {
partially evaluated: preeditCursor != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2107
0-2107
1262 int preeditPos = layout->preeditAreaPosition(); -
1263 if (relativePos == preeditPos)
never evaluated: relativePos == preeditPos
0
1264 relativePos += preeditCursor;
never executed: relativePos += preeditCursor;
0
1265 else if (relativePos > preeditPos)
never evaluated: relativePos > preeditPos
0
1266 relativePos += layout->preeditAreaText().length();
never executed: relativePos += layout->preeditAreaText().length();
0
1267 } -
1268 QTextLine line = layout->lineForTextPosition(relativePos); -
1269 -
1270 int cursorWidth; -
1271 { -
1272 bool ok = false; -
1273 -
1274 cursorWidth = docLayout->property("cursorWidth").toInt(&ok); -
1275 -
1276 if (!ok)
partially evaluated: !ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2107
0-2107
1277 cursorWidth = 1;
never executed: cursorWidth = 1;
0
1278 } -
1279 -
1280 QRectF r; -
1281 -
1282 if (line.isValid()) {
evaluated: line.isValid()
TRUEFALSE
yes
Evaluation Count:2087
yes
Evaluation Count:20
20-2087
1283 qreal x = line.cursorToX(relativePos); -
1284 qreal w = 0; -
1285 if (overwriteMode) {
evaluated: overwriteMode
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:2044
43-2044
1286 if (relativePos < line.textLength() - line.textStart())
evaluated: relativePos < line.textLength() - line.textStart()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:23
20-23
1287 w = line.cursorToX(relativePos + 1) - x;
executed: w = line.cursorToX(relativePos + 1) - x;
Execution Count:20
20
1288 else -
1289 w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' '));
executed: w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' '));
Execution Count:23
23
1290 } -
1291 r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), -
1292 cursorWidth + w, line.height()); -
1293 } else {
executed: }
Execution Count:2087
2087
1294 r = QRectF(layoutPos.x(), layoutPos.y(), cursorWidth, 10); -
1295 }
executed: }
Execution Count:20
20
1296 -
1297 return r;
executed: return r;
Execution Count:2107
2107
1298} -
1299 -
1300namespace { -
1301struct QTextFrameComparator { -
1302 -
1303 -
1304 -
1305 -
1306 bool operator()(QTextFrame *frame, int position) { return frame->firstPosition() < position; }
never executed: return frame->firstPosition() < position;
0
1307 bool operator()(int position, QTextFrame *frame) { return position < frame->firstPosition(); }
never executed: return position < frame->firstPosition();
0
1308}; -
1309} -
1310 -
1311static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor) -
1312{ -
1313 QRectF r; -
1314 QTextFrame *frame = cursor.currentFrame(); -
1315 const QList<QTextFrame *> children = frame->childFrames(); -
1316 -
1317 const QList<QTextFrame *>::ConstIterator firstFrame = std::lower_bound(children.constBegin(), children.constEnd(), -
1318 cursor.selectionStart(), QTextFrameComparator()); -
1319 const QList<QTextFrame *>::ConstIterator lastFrame = std::upper_bound(children.constBegin(), children.constEnd(), -
1320 cursor.selectionEnd(), QTextFrameComparator()); -
1321 for (QList<QTextFrame *>::ConstIterator it = firstFrame; it != lastFrame; ++it) {
partially evaluated: it != lastFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1322 if ((*it)->frameFormat().position() != QTextFrameFormat::InFlow)
never evaluated: (*it)->frameFormat().position() != QTextFrameFormat::InFlow
0
1323 r |= frame->document()->documentLayout()->frameBoundingRect(*it);
never executed: r |= frame->document()->documentLayout()->frameBoundingRect(*it);
0
1324 }
never executed: }
0
1325 return r;
executed: return r;
Execution Count:7
7
1326} -
1327 -
1328QRectF QWidgetTextControl::selectionRect(const QTextCursor &cursor) const -
1329{ -
1330 const QWidgetTextControlPrivate * const d = d_func(); -
1331 -
1332 QRectF r = d->rectForPosition(cursor.selectionStart()); -
1333 -
1334 if (cursor.hasComplexSelection() && cursor.currentTable()) {
partially evaluated: cursor.hasComplexSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:454
never evaluated: cursor.currentTable()
0-454
1335 QTextTable *table = cursor.currentTable(); -
1336 -
1337 r = d->doc->documentLayout()->frameBoundingRect(table); -
1338 } else if (cursor.hasSelection()) {
never executed: }
evaluated: cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:378
0-378
1339 const int position = cursor.selectionStart(); -
1340 const int anchor = cursor.selectionEnd(); -
1341 const QTextBlock posBlock = d->doc->findBlock(position); -
1342 const QTextBlock anchorBlock = d->doc->findBlock(anchor); -
1343 if (posBlock == anchorBlock && posBlock.isValid() && posBlock.layout()->lineCount()) {
evaluated: posBlock == anchorBlock
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:7
partially evaluated: posBlock.isValid()
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
partially evaluated: posBlock.layout()->lineCount()
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
0-69
1344 const QTextLine posLine = posBlock.layout()->lineForTextPosition(position - posBlock.position()); -
1345 const QTextLine anchorLine = anchorBlock.layout()->lineForTextPosition(anchor - anchorBlock.position()); -
1346 -
1347 const int firstLine = qMin(posLine.lineNumber(), anchorLine.lineNumber()); -
1348 const int lastLine = qMax(posLine.lineNumber(), anchorLine.lineNumber()); -
1349 const QTextLayout *layout = posBlock.layout(); -
1350 r = QRectF(); -
1351 for (int i = firstLine; i <= lastLine; ++i) {
evaluated: i <= lastLine
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:69
69-77
1352 r |= layout->lineAt(i).rect(); -
1353 r |= layout->lineAt(i).naturalTextRect(); -
1354 }
executed: }
Execution Count:77
77
1355 r.translate(blockBoundingRect(posBlock).topLeft()); -
1356 } else {
executed: }
Execution Count:69
69
1357 QRectF anchorRect = d->rectForPosition(cursor.selectionEnd()); -
1358 r |= anchorRect; -
1359 r |= boundingRectOfFloatsInSelection(cursor); -
1360 QRectF frameRect(d->doc->documentLayout()->frameBoundingRect(cursor.currentFrame())); -
1361 r.setLeft(frameRect.left()); -
1362 r.setRight(frameRect.right()); -
1363 }
executed: }
Execution Count:7
7
1364 if (r.isValid())
partially evaluated: r.isValid()
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
0-76
1365 r.adjust(-1, -1, 1, 1);
executed: r.adjust(-1, -1, 1, 1);
Execution Count:76
76
1366 }
executed: }
Execution Count:76
76
1367 -
1368 return r;
executed: return r;
Execution Count:454
454
1369} -
1370 -
1371QRectF QWidgetTextControl::selectionRect() const -
1372{ -
1373 const QWidgetTextControlPrivate * const d = d_func(); -
1374 return selectionRect(d->cursor);
executed: return selectionRect(d->cursor);
Execution Count:367
367
1375} -
1376 -
1377void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, -
1378 Qt::MouseButtons buttons, const QPoint &globalPos) -
1379{ -
1380 QWidgetTextControl * const q = q_func(); -
1381 -
1382 mousePressPos = pos.toPoint(); -
1383 -
1384 -
1385 mightStartDrag = false; -
1386 -
1387 -
1388 if (sendMouseEventToInputContext( 0-7
1389 e, QEvent::MouseButtonPress, button, pos, modifiers, buttons, globalPos)) {
partially evaluated: sendMouseEventToInputContext( e, QEvent::MouseButtonPress, button, pos, modifiers, buttons, globalPos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1390 return;
never executed: return;
0
1391 } -
1392 -
1393 if (interactionFlags & Qt::LinksAccessibleByMouse) {
evaluated: interactionFlags & Qt::LinksAccessibleByMouse
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1394 anchorOnMousePress = q->anchorAt(pos); -
1395 -
1396 if (cursorIsFocusIndicator) {
partially evaluated: cursorIsFocusIndicator
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1397 cursorIsFocusIndicator = false; -
1398 repaintSelection(); -
1399 cursor.clearSelection(); -
1400 }
never executed: }
0
1401 }
executed: }
Execution Count:2
2
1402 if (!(button & Qt::LeftButton) ||
partially evaluated: !(button & Qt::LeftButton)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1403 !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) {
evaluated: (interactionFlags & Qt::TextSelectableByMouse)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
partially evaluated: (interactionFlags & Qt::TextEditable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1404 e->ignore(); -
1405 return;
executed: return;
Execution Count:5
5
1406 } -
1407 -
1408 cursorIsFocusIndicator = false; -
1409 const QTextCursor oldSelection = cursor; -
1410 const int oldCursorPos = cursor.position(); -
1411 -
1412 mousePressed = (interactionFlags & Qt::TextSelectableByMouse); -
1413 -
1414 commitPreedit(); -
1415 -
1416 if (trippleClickTimer.isActive()
partially evaluated: trippleClickTimer.isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1417 && ((pos - trippleClickPoint).toPoint().manhattanLength() < QApplication::startDragDistance())) {
never evaluated: ((pos - trippleClickPoint).toPoint().manhattanLength() < QApplication::startDragDistance())
0
1418 -
1419 cursor.movePosition(QTextCursor::StartOfBlock); -
1420 cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); -
1421 cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); -
1422 selectedBlockOnTrippleClick = cursor; -
1423 -
1424 anchorOnMousePress = QString(); -
1425 -
1426 trippleClickTimer.stop(); -
1427 } else {
never executed: }
0
1428 int cursorPos = q->hitTest(pos, Qt::FuzzyHit); -
1429 if (cursorPos == -1) {
partially evaluated: cursorPos == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1430 e->ignore(); -
1431 return;
never executed: return;
0
1432 } -
1433 -
1434 if (modifiers == Qt::ShiftModifier && (interactionFlags & Qt::TextSelectableByMouse)) {
partially evaluated: modifiers == Qt::ShiftModifier
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: (interactionFlags & Qt::TextSelectableByMouse)
0-2
1435 if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
never evaluated: wordSelectionEnabled
never evaluated: !selectedWordOnDoubleClick.hasSelection()
0
1436 selectedWordOnDoubleClick = cursor; -
1437 selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor); -
1438 }
never executed: }
0
1439 -
1440 if (selectedBlockOnTrippleClick.hasSelection())
never evaluated: selectedBlockOnTrippleClick.hasSelection()
0
1441 extendBlockwiseSelection(cursorPos);
never executed: extendBlockwiseSelection(cursorPos);
0
1442 else if (selectedWordOnDoubleClick.hasSelection())
never evaluated: selectedWordOnDoubleClick.hasSelection()
0
1443 extendWordwiseSelection(cursorPos, pos.x());
never executed: extendWordwiseSelection(cursorPos, pos.x());
0
1444 else if (!wordSelectionEnabled)
never evaluated: !wordSelectionEnabled
0
1445 setCursorPosition(cursorPos, QTextCursor::KeepAnchor);
never executed: setCursorPosition(cursorPos, QTextCursor::KeepAnchor);
0
1446 } else { -
1447 -
1448 if (dragEnabled
partially evaluated: dragEnabled
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1449 && cursor.hasSelection()
partially evaluated: cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1450 && !cursorIsFocusIndicator
never evaluated: !cursorIsFocusIndicator
0
1451 && cursorPos >= cursor.selectionStart()
never evaluated: cursorPos >= cursor.selectionStart()
0
1452 && cursorPos <= cursor.selectionEnd()
never evaluated: cursorPos <= cursor.selectionEnd()
0
1453 && q->hitTest(pos, Qt::ExactHit) != -1) {
never evaluated: q->hitTest(pos, Qt::ExactHit) != -1
0
1454 -
1455 mightStartDrag = true; -
1456 -
1457 return;
never executed: return;
0
1458 } -
1459 -
1460 setCursorPosition(cursorPos); -
1461 }
executed: }
Execution Count:2
2
1462 } -
1463 -
1464 if (interactionFlags & Qt::TextEditable) {
partially evaluated: interactionFlags & Qt::TextEditable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1465 q->ensureCursorVisible(); -
1466 if (cursor.position() != oldCursorPos)
never evaluated: cursor.position() != oldCursorPos
0
1467 q->cursorPositionChanged();
never executed: q->cursorPositionChanged();
0
1468 _q_updateCurrentCharFormatAndSelection(); -
1469 } else {
never executed: }
0
1470 if (cursor.position() != oldCursorPos) {
partially evaluated: cursor.position() != oldCursorPos
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1471 q->cursorPositionChanged(); -
1472 q->microFocusChanged(); -
1473 }
executed: }
Execution Count:2
2
1474 selectionChanged(); -
1475 }
executed: }
Execution Count:2
2
1476 repaintOldAndNewSelection(oldSelection); -
1477 hadSelectionOnMousePress = cursor.hasSelection(); -
1478}
executed: }
Execution Count:2
2
1479 -
1480void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &mousePos, Qt::KeyboardModifiers modifiers, -
1481 Qt::MouseButtons buttons, const QPoint &globalPos) -
1482{ -
1483 QWidgetTextControl * const q = q_func(); -
1484 -
1485 if (interactionFlags & Qt::LinksAccessibleByMouse) {
partially evaluated: interactionFlags & Qt::LinksAccessibleByMouse
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1486 QString anchor = q->anchorAt(mousePos); -
1487 if (anchor != highlightedAnchor) {
partially evaluated: anchor != highlightedAnchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1488 highlightedAnchor = anchor; -
1489 q->linkHovered(anchor); -
1490 }
never executed: }
0
1491 }
executed: }
Execution Count:1
1
1492 -
1493 if (buttons & Qt::LeftButton) {
partially evaluated: buttons & Qt::LeftButton
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1494 const bool editable = interactionFlags & Qt::TextEditable; -
1495 -
1496 if (!(mousePressed
never evaluated: mousePressed
0
1497 || editable
never evaluated: editable
0
1498 || mightStartDrag
never evaluated: mightStartDrag
0
1499 || selectedWordOnDoubleClick.hasSelection()
never evaluated: selectedWordOnDoubleClick.hasSelection()
0
1500 || selectedBlockOnTrippleClick.hasSelection()))
never evaluated: selectedBlockOnTrippleClick.hasSelection()
0
1501 return;
never executed: return;
0
1502 -
1503 const QTextCursor oldSelection = cursor; -
1504 const int oldCursorPos = cursor.position(); -
1505 -
1506 if (mightStartDrag) {
never evaluated: mightStartDrag
0
1507 if ((mousePos.toPoint() - mousePressPos).manhattanLength() > QApplication::startDragDistance())
never evaluated: (mousePos.toPoint() - mousePressPos).manhattanLength() > QApplication::startDragDistance()
0
1508 startDrag();
never executed: startDrag();
0
1509 return;
never executed: return;
0
1510 } -
1511 -
1512 if (!mousePressed)
never evaluated: !mousePressed
0
1513 return;
never executed: return;
0
1514 -
1515 const qreal mouseX = qreal(mousePos.x()); -
1516 -
1517 int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit); -
1518 -
1519 if (isPreediting()) {
never evaluated: isPreediting()
0
1520 -
1521 int selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit); -
1522 -
1523 if (newCursorPos != selectionStartPos) {
never evaluated: newCursorPos != selectionStartPos
0
1524 commitPreedit(); -
1525 -
1526 newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit); -
1527 selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit); -
1528 setCursorPosition(selectionStartPos); -
1529 }
never executed: }
0
1530 }
never executed: }
0
1531 -
1532 if (newCursorPos == -1)
never evaluated: newCursorPos == -1
0
1533 return;
never executed: return;
0
1534 -
1535 if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
never evaluated: wordSelectionEnabled
never evaluated: !selectedWordOnDoubleClick.hasSelection()
0
1536 selectedWordOnDoubleClick = cursor; -
1537 selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor); -
1538 }
never executed: }
0
1539 -
1540 if (selectedBlockOnTrippleClick.hasSelection())
never evaluated: selectedBlockOnTrippleClick.hasSelection()
0
1541 extendBlockwiseSelection(newCursorPos);
never executed: extendBlockwiseSelection(newCursorPos);
0
1542 else if (selectedWordOnDoubleClick.hasSelection())
never evaluated: selectedWordOnDoubleClick.hasSelection()
0
1543 extendWordwiseSelection(newCursorPos, mouseX);
never executed: extendWordwiseSelection(newCursorPos, mouseX);
0
1544 else if (!isPreediting())
never evaluated: !isPreediting()
0
1545 setCursorPosition(newCursorPos, QTextCursor::KeepAnchor);
never executed: setCursorPosition(newCursorPos, QTextCursor::KeepAnchor);
0
1546 -
1547 if (interactionFlags & Qt::TextEditable) {
never evaluated: interactionFlags & Qt::TextEditable
0
1548 -
1549 -
1550 -
1551 if (cursor.position() != oldCursorPos)
never evaluated: cursor.position() != oldCursorPos
0
1552 q->cursorPositionChanged();
never executed: q->cursorPositionChanged();
0
1553 _q_updateCurrentCharFormatAndSelection(); -
1554 -
1555 if (contextWidget)
never evaluated: contextWidget
0
1556 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImQueryInput);
never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImQueryInput);
0
1557 -
1558 } else {
never executed: }
0
1559 -
1560 if (cursor.position() != oldCursorPos) {
never evaluated: cursor.position() != oldCursorPos
0
1561 q->cursorPositionChanged(); -
1562 q->microFocusChanged(); -
1563 }
never executed: }
0
1564 }
never executed: }
0
1565 selectionChanged(true); -
1566 repaintOldAndNewSelection(oldSelection); -
1567 }
never executed: }
0
1568 -
1569 sendMouseEventToInputContext(e, QEvent::MouseMove, button, mousePos, modifiers, buttons, globalPos); -
1570}
executed: }
Execution Count:1
1
1571 -
1572void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, -
1573 Qt::MouseButtons buttons, const QPoint &globalPos) -
1574{ -
1575 QWidgetTextControl * const q = q_func(); -
1576 -
1577 if (sendMouseEventToInputContext( 0-1
1578 e, QEvent::MouseButtonRelease, button, pos, modifiers, buttons, globalPos)) {
partially evaluated: sendMouseEventToInputContext( e, QEvent::MouseButtonRelease, button, pos, modifiers, buttons, globalPos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1579 return;
never executed: return;
0
1580 } -
1581 -
1582 const QTextCursor oldSelection = cursor; -
1583 const int oldCursorPos = cursor.position(); -
1584 -
1585 -
1586 if (mightStartDrag && (button & Qt::LeftButton)) {
partially evaluated: mightStartDrag
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: (button & Qt::LeftButton)
0-1
1587 mousePressed = false; -
1588 setCursorPosition(pos); -
1589 cursor.clearSelection(); -
1590 selectionChanged(); -
1591 }
never executed: }
0
1592 -
1593 if (mousePressed) {
partially evaluated: mousePressed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1594 mousePressed = false; -
1595 -
1596 setClipboardSelection(); -
1597 selectionChanged(true); -
1598 } else if (button == Qt::MidButton
never executed: }
partially evaluated: button == Qt::MidButton
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1599 && (interactionFlags & Qt::TextEditable)
never evaluated: (interactionFlags & Qt::TextEditable)
0
1600 && QApplication::clipboard()->supportsSelection()) {
never evaluated: QApplication::clipboard()->supportsSelection()
0
1601 setCursorPosition(pos); -
1602 const QMimeData *md = QApplication::clipboard()->mimeData(QClipboard::Selection); -
1603 if (md)
never evaluated: md
0
1604 q->insertFromMimeData(md);
never executed: q->insertFromMimeData(md);
0
1605 -
1606 }
never executed: }
0
1607 -
1608 repaintOldAndNewSelection(oldSelection); -
1609 -
1610 if (cursor.position() != oldCursorPos) {
partially evaluated: cursor.position() != oldCursorPos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1611 q->cursorPositionChanged(); -
1612 q->microFocusChanged(); -
1613 }
never executed: }
0
1614 -
1615 if (interactionFlags & Qt::LinksAccessibleByMouse) {
partially evaluated: interactionFlags & Qt::LinksAccessibleByMouse
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1616 if (!(button & Qt::LeftButton))
partially evaluated: !(button & Qt::LeftButton)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1617 return;
never executed: return;
0
1618 -
1619 const QString anchor = q->anchorAt(pos); -
1620 -
1621 if (anchor.isEmpty())
partially evaluated: anchor.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1622 return;
executed: return;
Execution Count:1
1
1623 -
1624 if (!cursor.hasSelection()
never evaluated: !cursor.hasSelection()
0
1625 || (anchor == anchorOnMousePress && hadSelectionOnMousePress)) {
never evaluated: anchor == anchorOnMousePress
never evaluated: hadSelectionOnMousePress
0
1626 -
1627 const int anchorPos = q->hitTest(pos, Qt::ExactHit); -
1628 if (anchorPos != -1) {
never evaluated: anchorPos != -1
0
1629 cursor.setPosition(anchorPos); -
1630 -
1631 QString anchor = anchorOnMousePress; -
1632 anchorOnMousePress = QString(); -
1633 activateLinkUnderCursor(anchor); -
1634 }
never executed: }
0
1635 }
never executed: }
0
1636 }
never executed: }
0
1637}
never executed: }
0
1638 -
1639void QWidgetTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, -
1640 Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, -
1641 const QPoint &globalPos) -
1642{ -
1643 QWidgetTextControl * const q = q_func(); -
1644 -
1645 if (button == Qt::LeftButton
never evaluated: button == Qt::LeftButton
0
1646 && (interactionFlags & Qt::TextSelectableByMouse)) {
never evaluated: (interactionFlags & Qt::TextSelectableByMouse)
0
1647 -
1648 -
1649 mightStartDrag = false; -
1650 -
1651 commitPreedit(); -
1652 -
1653 const QTextCursor oldSelection = cursor; -
1654 setCursorPosition(pos); -
1655 QTextLine line = currentTextLine(cursor); -
1656 bool doEmit = false; -
1657 if (line.isValid() && line.textLength()) {
never evaluated: line.isValid()
never evaluated: line.textLength()
0
1658 cursor.select(QTextCursor::WordUnderCursor); -
1659 doEmit = true; -
1660 }
never executed: }
0
1661 repaintOldAndNewSelection(oldSelection); -
1662 -
1663 cursorIsFocusIndicator = false; -
1664 selectedWordOnDoubleClick = cursor; -
1665 -
1666 trippleClickPoint = pos; -
1667 trippleClickTimer.start(QApplication::doubleClickInterval(), q); -
1668 if (doEmit) {
never evaluated: doEmit
0
1669 selectionChanged(); -
1670 -
1671 setClipboardSelection(); -
1672 -
1673 q->cursorPositionChanged(); -
1674 }
never executed: }
0
1675 } else if (!sendMouseEventToInputContext(e, QEvent::MouseButtonDblClick, button, pos,
never executed: }
0
1676 modifiers, buttons, globalPos)) {
never evaluated: !sendMouseEventToInputContext(e, QEvent::MouseButtonDblClick, button, pos, modifiers, buttons, globalPos)
0
1677 e->ignore(); -
1678 }
never executed: }
0
1679} -
1680 -
1681bool QWidgetTextControlPrivate::sendMouseEventToInputContext( -
1682 QEvent *e, QEvent::Type eventType, Qt::MouseButton button, const QPointF &pos, -
1683 Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos) -
1684{ -
1685 (void)eventType;; -
1686 (void)button;; -
1687 (void)pos;; -
1688 (void)modifiers;; -
1689 (void)buttons;; -
1690 (void)globalPos;; -
1691 -
1692 QWidgetTextControl * const q = q_func(); -
1693 -
1694 if (isPreediting()) {
partially evaluated: isPreediting()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
1695 QTextLayout *layout = cursor.block().layout(); -
1696 int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position(); -
1697 -
1698 if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length())
never evaluated: cursorPos < 0
never evaluated: cursorPos > layout->preeditAreaText().length()
0
1699 cursorPos = -1;
never executed: cursorPos = -1;
0
1700 -
1701 if (cursorPos >= 0) {
never evaluated: cursorPos >= 0
0
1702 if (eventType == QEvent::MouseButtonRelease)
never evaluated: eventType == QEvent::MouseButtonRelease
0
1703 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->invokeAction(QInputMethod::Click, cursorPos);
never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->invokeAction(QInputMethod::Click, cursorPos);
0
1704 -
1705 e->setAccepted(true); -
1706 return true;
never executed: return true;
0
1707 } -
1708 }
never executed: }
0
1709 -
1710 -
1711 -
1712 return false;
executed: return false;
Execution Count:9
9
1713} -
1714 -
1715void QWidgetTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget) -
1716{ -
1717 -
1718 -
1719 -
1720 -
1721 -
1722 QWidgetTextControl * const q = q_func(); -
1723 if (!hasFocus)
never evaluated: !hasFocus
0
1724 return;
never executed: return;
0
1725 QMenu *menu = q->createStandardContextMenu(docPos, contextWidget); -
1726 if (!menu)
never evaluated: !menu
0
1727 return;
never executed: return;
0
1728 menu->setAttribute(Qt::WA_DeleteOnClose); -
1729 menu->popup(screenPos); -
1730 -
1731}
never executed: }
0
1732 -
1733bool QWidgetTextControlPrivate::dragEnterEvent(QEvent *e, const QMimeData *mimeData) -
1734{ -
1735 QWidgetTextControl * const q = q_func(); -
1736 if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
never evaluated: !(interactionFlags & Qt::TextEditable)
never evaluated: !q->canInsertFromMimeData(mimeData)
0
1737 e->ignore(); -
1738 return false;
never executed: return false;
0
1739 } -
1740 -
1741 dndFeedbackCursor = QTextCursor(); -
1742 -
1743 return true;
never executed: return true;
0
1744} -
1745 -
1746void QWidgetTextControlPrivate::dragLeaveEvent() -
1747{ -
1748 QWidgetTextControl * const q = q_func(); -
1749 -
1750 const QRectF crect = q->cursorRect(dndFeedbackCursor); -
1751 dndFeedbackCursor = QTextCursor(); -
1752 -
1753 if (crect.isValid())
never evaluated: crect.isValid()
0
1754 q->updateRequest(crect);
never executed: q->updateRequest(crect);
0
1755}
never executed: }
0
1756 -
1757bool QWidgetTextControlPrivate::dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos) -
1758{ -
1759 QWidgetTextControl * const q = q_func(); -
1760 if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
never evaluated: !(interactionFlags & Qt::TextEditable)
never evaluated: !q->canInsertFromMimeData(mimeData)
0
1761 e->ignore(); -
1762 return false;
never executed: return false;
0
1763 } -
1764 -
1765 const int cursorPos = q->hitTest(pos, Qt::FuzzyHit); -
1766 if (cursorPos != -1) {
never evaluated: cursorPos != -1
0
1767 QRectF crect = q->cursorRect(dndFeedbackCursor); -
1768 if (crect.isValid())
never evaluated: crect.isValid()
0
1769 q->updateRequest(crect);
never executed: q->updateRequest(crect);
0
1770 -
1771 dndFeedbackCursor = cursor; -
1772 dndFeedbackCursor.setPosition(cursorPos); -
1773 -
1774 crect = q->cursorRect(dndFeedbackCursor); -
1775 q->updateRequest(crect); -
1776 }
never executed: }
0
1777 -
1778 return true;
never executed: return true;
0
1779} -
1780 -
1781bool QWidgetTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QObject *source) -
1782{ -
1783 QWidgetTextControl * const q = q_func(); -
1784 dndFeedbackCursor = QTextCursor(); -
1785 -
1786 if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData))
never evaluated: !(interactionFlags & Qt::TextEditable)
never evaluated: !q->canInsertFromMimeData(mimeData)
0
1787 return false;
never executed: return false;
0
1788 -
1789 repaintSelection(); -
1790 -
1791 QTextCursor insertionCursor = q->cursorForPosition(pos); -
1792 insertionCursor.beginEditBlock(); -
1793 -
1794 if (dropAction == Qt::MoveAction && source == contextWidget)
never evaluated: dropAction == Qt::MoveAction
never evaluated: source == contextWidget
0
1795 cursor.removeSelectedText();
never executed: cursor.removeSelectedText();
0
1796 -
1797 cursor = insertionCursor; -
1798 q->insertFromMimeData(mimeData); -
1799 insertionCursor.endEditBlock(); -
1800 q->ensureCursorVisible(); -
1801 return true;
never executed: return true;
0
1802} -
1803 -
1804void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) -
1805{ -
1806 QWidgetTextControl * const q = q_func(); -
1807 if (!(interactionFlags & Qt::TextEditable) || cursor.isNull()) {
never evaluated: !(interactionFlags & Qt::TextEditable)
never evaluated: cursor.isNull()
0
1808 e->ignore(); -
1809 return;
never executed: return;
0
1810 } -
1811 bool isGettingInput = !e->commitString().isEmpty()
never evaluated: !e->commitString().isEmpty()
0
1812 || e->preeditString() != cursor.block().layout()->preeditAreaText()
never evaluated: e->preeditString() != cursor.block().layout()->preeditAreaText()
0
1813 || e->replacementLength() > 0;
never evaluated: e->replacementLength() > 0
0
1814 -
1815 cursor.beginEditBlock(); -
1816 if (isGettingInput) {
never evaluated: isGettingInput
0
1817 cursor.removeSelectedText(); -
1818 }
never executed: }
0
1819 -
1820 -
1821 if (!e->commitString().isEmpty() || e->replacementLength()) {
never evaluated: !e->commitString().isEmpty()
never evaluated: e->replacementLength()
0
1822 QTextCursor c = cursor; -
1823 c.setPosition(c.position() + e->replacementStart()); -
1824 c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor); -
1825 c.insertText(e->commitString()); -
1826 }
never executed: }
0
1827 -
1828 for (int i = 0; i < e->attributes().size(); ++i) {
never evaluated: i < e->attributes().size()
0
1829 const QInputMethodEvent::Attribute &a = e->attributes().at(i); -
1830 if (a.type == QInputMethodEvent::Selection) {
never evaluated: a.type == QInputMethodEvent::Selection
0
1831 QTextCursor oldCursor = cursor; -
1832 int blockStart = a.start + cursor.block().position(); -
1833 cursor.setPosition(blockStart, QTextCursor::MoveAnchor); -
1834 cursor.setPosition(blockStart + a.length, QTextCursor::KeepAnchor); -
1835 q->ensureCursorVisible(); -
1836 repaintOldAndNewSelection(oldCursor); -
1837 }
never executed: }
0
1838 }
never executed: }
0
1839 -
1840 QTextBlock block = cursor.block(); -
1841 QTextLayout *layout = block.layout(); -
1842 if (isGettingInput)
never evaluated: isGettingInput
0
1843 layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
never executed: layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
0
1844 QList<QTextLayout::FormatRange> overrides; -
1845 const int oldPreeditCursor = preeditCursor; -
1846 preeditCursor = e->preeditString().length(); -
1847 hideCursor = false; -
1848 for (int i = 0; i < e->attributes().size(); ++i) {
never evaluated: i < e->attributes().size()
0
1849 const QInputMethodEvent::Attribute &a = e->attributes().at(i); -
1850 if (a.type == QInputMethodEvent::Cursor) {
never evaluated: a.type == QInputMethodEvent::Cursor
0
1851 preeditCursor = a.start; -
1852 hideCursor = !a.length; -
1853 } else if (a.type == QInputMethodEvent::TextFormat) {
never executed: }
never evaluated: a.type == QInputMethodEvent::TextFormat
0
1854 QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat(); -
1855 if (f.isValid()) {
never evaluated: f.isValid()
0
1856 QTextLayout::FormatRange o; -
1857 o.start = a.start + cursor.position() - block.position(); -
1858 o.length = a.length; -
1859 o.format = f; -
1860 overrides.append(o); -
1861 }
never executed: }
0
1862 }
never executed: }
0
1863 } -
1864 layout->setAdditionalFormats(overrides); -
1865 -
1866 cursor.endEditBlock(); -
1867 -
1868 if (cursor.d)
never evaluated: cursor.d
0
1869 cursor.d->setX();
never executed: cursor.d->setX();
0
1870 if (oldPreeditCursor != preeditCursor)
never evaluated: oldPreeditCursor != preeditCursor
0
1871 q->microFocusChanged();
never executed: q->microFocusChanged();
0
1872}
never executed: }
0
1873 -
1874QVariant QWidgetTextControl::inputMethodQuery(Qt::InputMethodQuery property) const -
1875{ -
1876 const QWidgetTextControlPrivate * const d = d_func(); -
1877 QTextBlock block = d->cursor.block(); -
1878 switch(property) { -
1879 case Qt::ImCursorRectangle: -
1880 return cursorRect();
never executed: return cursorRect();
0
1881 case Qt::ImFont: -
1882 return QVariant(d->cursor.charFormat().font());
never executed: return QVariant(d->cursor.charFormat().font());
0
1883 case Qt::ImCursorPosition: -
1884 return QVariant(d->cursor.position() - block.position());
never executed: return QVariant(d->cursor.position() - block.position());
0
1885 case Qt::ImSurroundingText: -
1886 return QVariant(block.text());
never executed: return QVariant(block.text());
0
1887 case Qt::ImCurrentSelection: -
1888 return QVariant(d->cursor.selectedText());
never executed: return QVariant(d->cursor.selectedText());
0
1889 case Qt::ImMaximumTextLength: -
1890 return QVariant();
never executed: return QVariant();
0
1891 case Qt::ImAnchorPosition: -
1892 return QVariant(d->cursor.anchor() - block.position());
never executed: return QVariant(d->cursor.anchor() - block.position());
0
1893 default: -
1894 return QVariant();
executed: return QVariant();
Execution Count:463
463
1895 } -
1896}
never executed: }
0
1897 -
1898void QWidgetTextControl::setFocus(bool focus, Qt::FocusReason reason) -
1899{ -
1900 QFocusEvent ev(focus ? QEvent::FocusIn : QEvent::FocusOut, -
1901 reason); -
1902 processEvent(&ev); -
1903}
executed: }
Execution Count:23
23
1904 -
1905void QWidgetTextControlPrivate::focusEvent(QFocusEvent *e) -
1906{ -
1907 QWidgetTextControl * const q = q_func(); -
1908 q->updateRequest(q->selectionRect()); -
1909 if (e->gotFocus()) {
evaluated: e->gotFocus()
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:72
72-77
1910 -
1911 -
1912 -
1913 cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard); -
1914 if (interactionFlags & Qt::TextEditable) {
evaluated: interactionFlags & Qt::TextEditable
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:25
25-52
1915 setBlinkingCursorEnabled(true); -
1916 }
executed: }
Execution Count:52
52
1917 -
1918 -
1919 -
1920 } else {
executed: }
Execution Count:77
77
1921 setBlinkingCursorEnabled(false); -
1922 -
1923 if (cursorIsFocusIndicator
partially evaluated: cursorIsFocusIndicator
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:72
0-72
1924 && e->reason() != Qt::ActiveWindowFocusReason
never evaluated: e->reason() != Qt::ActiveWindowFocusReason
0
1925 && e->reason() != Qt::PopupFocusReason
never evaluated: e->reason() != Qt::PopupFocusReason
0
1926 && cursor.hasSelection()) {
never evaluated: cursor.hasSelection()
0
1927 cursor.clearSelection(); -
1928 }
never executed: }
0
1929 }
executed: }
Execution Count:72
72
1930 hasFocus = e->gotFocus(); -
1931}
executed: }
Execution Count:149
149
1932 -
1933QString QWidgetTextControlPrivate::anchorForCursor(const QTextCursor &anchorCursor) const -
1934{ -
1935 if (anchorCursor.hasSelection()) {
never evaluated: anchorCursor.hasSelection()
0
1936 QTextCursor cursor = anchorCursor; -
1937 if (cursor.selectionStart() != cursor.position())
never evaluated: cursor.selectionStart() != cursor.position()
0
1938 cursor.setPosition(cursor.selectionStart());
never executed: cursor.setPosition(cursor.selectionStart());
0
1939 cursor.movePosition(QTextCursor::NextCharacter); -
1940 QTextCharFormat fmt = cursor.charFormat(); -
1941 if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref))
never evaluated: fmt.isAnchor()
never evaluated: fmt.hasProperty(QTextFormat::AnchorHref)
0
1942 return fmt.stringProperty(QTextFormat::AnchorHref);
never executed: return fmt.stringProperty(QTextFormat::AnchorHref);
0
1943 }
never executed: }
0
1944 return QString();
never executed: return QString();
0
1945} -
1946QMenu *QWidgetTextControl::createStandardContextMenu(const QPointF &pos, QWidget *parent) -
1947{ -
1948 QWidgetTextControlPrivate * const d = d_func(); -
1949 -
1950 const bool showTextSelectionActions = d->interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); -
1951 -
1952 d->linkToCopy = QString(); -
1953 if (!pos.isNull())
partially evaluated: !pos.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1954 d->linkToCopy = anchorAt(pos);
never executed: d->linkToCopy = anchorAt(pos);
0
1955 -
1956 if (d->linkToCopy.isEmpty() && !showTextSelectionActions)
partially evaluated: d->linkToCopy.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !showTextSelectionActions
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1957 return 0;
never executed: return 0;
0
1958 -
1959 QMenu *menu = new QMenu(parent); -
1960 QAction *a; -
1961 -
1962 if (d->interactionFlags & Qt::TextEditable) {
partially evaluated: d->interactionFlags & Qt::TextEditable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1963 a = menu->addAction(tr("&Undo") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Undo) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Undo).toString(QKeySequence::NativeText) : QString()), this, "1""undo()"); -
1964 a->setEnabled(d->doc->isUndoAvailable()); -
1965 a = menu->addAction(tr("&Redo") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Redo) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Redo).toString(QKeySequence::NativeText) : QString()), this, "1""redo()"); -
1966 a->setEnabled(d->doc->isRedoAvailable()); -
1967 menu->addSeparator(); -
1968 -
1969 a = menu->addAction(tr("Cu&t") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Cut) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Cut).toString(QKeySequence::NativeText) : QString()), this, "1""cut()"); -
1970 a->setEnabled(d->cursor.hasSelection()); -
1971 }
never executed: }
0
1972 -
1973 if (showTextSelectionActions) {
partially evaluated: showTextSelectionActions
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1974 a = menu->addAction(tr("&Copy") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Copy) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Copy).toString(QKeySequence::NativeText) : QString()), this, "1""copy()"); -
1975 a->setEnabled(d->cursor.hasSelection()); -
1976 }
executed: }
Execution Count:1
1
1977 -
1978 if ((d->interactionFlags & Qt::LinksAccessibleByKeyboard)
partially evaluated: (d->interactionFlags & Qt::LinksAccessibleByKeyboard)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1979 || (d->interactionFlags & Qt::LinksAccessibleByMouse)) {
partially evaluated: (d->interactionFlags & Qt::LinksAccessibleByMouse)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1980 -
1981 a = menu->addAction(tr("Copy &Link Location"), this, "1""_q_copyLink()"); -
1982 a->setEnabled(!d->linkToCopy.isEmpty()); -
1983 }
never executed: }
0
1984 -
1985 if (d->interactionFlags & Qt::TextEditable) {
partially evaluated: d->interactionFlags & Qt::TextEditable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1986 -
1987 a = menu->addAction(tr("&Paste") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Paste) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Paste).toString(QKeySequence::NativeText) : QString()), this, "1""paste()"); -
1988 a->setEnabled(canPaste()); -
1989 -
1990 a = menu->addAction(tr("Delete"), this, "1""_q_deleteSelected()"); -
1991 a->setEnabled(d->cursor.hasSelection()); -
1992 }
never executed: }
0
1993 -
1994 -
1995 if (showTextSelectionActions) {
partially evaluated: showTextSelectionActions
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1996 menu->addSeparator(); -
1997 a = menu->addAction(tr("Select All") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::SelectAll) ? QLatin1Char('\t') + QKeySequence(QKeySequence::SelectAll).toString(QKeySequence::NativeText) : QString()), this, "1""selectAll()"); -
1998 a->setEnabled(!d->doc->isEmpty()); -
1999 }
executed: }
Execution Count:1
1
2000 -
2001 if ((d->interactionFlags & Qt::TextEditable) && (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->useRtlExtensions()) {
partially evaluated: (d->interactionFlags & Qt::TextEditable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->useRtlExtensions()
0-1
2002 menu->addSeparator(); -
2003 QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, menu); -
2004 menu->addMenu(ctrlCharacterMenu); -
2005 }
never executed: }
0
2006 -
2007 return menu;
executed: return menu;
Execution Count:1
1
2008} -
2009 -
2010 -
2011QTextCursor QWidgetTextControl::cursorForPosition(const QPointF &pos) const -
2012{ -
2013 const QWidgetTextControlPrivate * const d = d_func(); -
2014 int cursorPos = hitTest(pos, Qt::FuzzyHit); -
2015 if (cursorPos == -1)
never evaluated: cursorPos == -1
0
2016 cursorPos = 0;
never executed: cursorPos = 0;
0
2017 QTextCursor c(d->doc); -
2018 c.setPosition(cursorPos); -
2019 return c;
never executed: return c;
0
2020} -
2021 -
2022QRectF QWidgetTextControl::cursorRect(const QTextCursor &cursor) const -
2023{ -
2024 const QWidgetTextControlPrivate * const d = d_func(); -
2025 if (cursor.isNull())
partially evaluated: cursor.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:369
0-369
2026 return QRectF();
never executed: return QRectF();
0
2027 -
2028 return d->rectForPosition(cursor.position());
executed: return d->rectForPosition(cursor.position());
Execution Count:369
369
2029} -
2030 -
2031QRectF QWidgetTextControl::cursorRect() const -
2032{ -
2033 const QWidgetTextControlPrivate * const d = d_func(); -
2034 return cursorRect(d->cursor);
never executed: return cursorRect(d->cursor);
0
2035} -
2036 -
2037QRectF QWidgetTextControlPrivate::cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const -
2038{ -
2039 if (cursor.isNull())
partially evaluated: cursor.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:692
0-692
2040 return QRectF();
never executed: return QRectF();
0
2041 -
2042 return rectForPosition(cursor.position()).adjusted(-4, 0, 4, 0);
executed: return rectForPosition(cursor.position()).adjusted(-4, 0, 4, 0);
Execution Count:692
692
2043} -
2044 -
2045QString QWidgetTextControl::anchorAt(const QPointF &pos) const -
2046{ -
2047 const QWidgetTextControlPrivate * const d = d_func(); -
2048 return d->doc->documentLayout()->anchorAt(pos);
executed: return d->doc->documentLayout()->anchorAt(pos);
Execution Count:4
4
2049} -
2050 -
2051QString QWidgetTextControl::anchorAtCursor() const -
2052{ -
2053 const QWidgetTextControlPrivate * const d = d_func(); -
2054 -
2055 return d->anchorForCursor(d->cursor);
never executed: return d->anchorForCursor(d->cursor);
0
2056} -
2057 -
2058bool QWidgetTextControl::overwriteMode() const -
2059{ -
2060 const QWidgetTextControlPrivate * const d = d_func(); -
2061 return d->overwriteMode;
executed: return d->overwriteMode;
Execution Count:9
9
2062} -
2063 -
2064void QWidgetTextControl::setOverwriteMode(bool overwrite) -
2065{ -
2066 QWidgetTextControlPrivate * const d = d_func(); -
2067 d->overwriteMode = overwrite; -
2068}
executed: }
Execution Count:5
5
2069 -
2070int QWidgetTextControl::cursorWidth() const -
2071{ -
2072 -
2073 const QWidgetTextControlPrivate * const d = d_func(); -
2074 return d->doc->documentLayout()->property("cursorWidth").toInt();
executed: return d->doc->documentLayout()->property("cursorWidth").toInt();
Execution Count:6
6
2075 -
2076 -
2077 -
2078} -
2079 -
2080void QWidgetTextControl::setCursorWidth(int width) -
2081{ -
2082 QWidgetTextControlPrivate * const d = d_func(); -
2083 -
2084 -
2085 -
2086 if (width == -1)
partially evaluated: width == -1
TRUEFALSE
yes
Evaluation Count:291
no
Evaluation Count:0
0-291
2087 width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth);
executed: width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth);
Execution Count:291
291
2088 d->doc->documentLayout()->setProperty("cursorWidth", width); -
2089 -
2090 d->repaintCursor(); -
2091}
executed: }
Execution Count:291
291
2092 -
2093bool QWidgetTextControl::acceptRichText() const -
2094{ -
2095 const QWidgetTextControlPrivate * const d = d_func(); -
2096 return d->acceptRichText;
never executed: return d->acceptRichText;
0
2097} -
2098 -
2099void QWidgetTextControl::setAcceptRichText(bool accept) -
2100{ -
2101 QWidgetTextControlPrivate * const d = d_func(); -
2102 d->acceptRichText = accept; -
2103}
executed: }
Execution Count:87
87
2104 -
2105 -
2106 -
2107void QWidgetTextControl::setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections) -
2108{ -
2109 QWidgetTextControlPrivate * const d = d_func(); -
2110 -
2111 QHash<int, int> hash; -
2112 for (int i = 0; i < d->extraSelections.count(); ++i) {
evaluated: i < d->extraSelections.count()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
2113 const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(i); -
2114 hash.insertMulti(esel.cursor.anchor(), i); -
2115 }
executed: }
Execution Count:1
1
2116 -
2117 for (int i = 0; i < selections.count(); ++i) {
evaluated: i < selections.count()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
2118 const QTextEdit::ExtraSelection &sel = selections.at(i); -
2119 QHash<int, int>::iterator it = hash.find(sel.cursor.anchor()); -
2120 if (it != hash.end()) {
partially evaluated: it != hash.end()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2121 const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value()); -
2122 if (esel.cursor.position() == sel.cursor.position()
never evaluated: esel.cursor.position() == sel.cursor.position()
0
2123 && esel.format == sel.format) {
never evaluated: esel.format == sel.format
0
2124 hash.erase(it); -
2125 continue;
never executed: continue;
0
2126 } -
2127 }
never executed: }
0
2128 QRectF r = selectionRect(sel.cursor); -
2129 if (sel.format.boolProperty(QTextFormat::FullWidthSelection)) {
partially evaluated: sel.format.boolProperty(QTextFormat::FullWidthSelection)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2130 r.setLeft(0); -
2131 r.setWidth(qreal(2147483647)); -
2132 }
never executed: }
0
2133 updateRequest(r); -
2134 }
executed: }
Execution Count:2
2
2135 -
2136 for (QHash<int, int>::iterator it = hash.begin(); it != hash.end(); ++it) {
evaluated: it != hash.end()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
2137 const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value()); -
2138 QRectF r = selectionRect(esel.cursor); -
2139 if (esel.format.boolProperty(QTextFormat::FullWidthSelection)) {
partially evaluated: esel.format.boolProperty(QTextFormat::FullWidthSelection)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2140 r.setLeft(0); -
2141 r.setWidth(qreal(2147483647)); -
2142 }
never executed: }
0
2143 updateRequest(r); -
2144 }
executed: }
Execution Count:1
1
2145 -
2146 d->extraSelections.resize(selections.count()); -
2147 for (int i = 0; i < selections.count(); ++i) {
evaluated: i < selections.count()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
2148 d->extraSelections[i].cursor = selections.at(i).cursor; -
2149 d->extraSelections[i].format = selections.at(i).format; -
2150 }
executed: }
Execution Count:2
2
2151}
executed: }
Execution Count:2
2
2152 -
2153QList<QTextEdit::ExtraSelection> QWidgetTextControl::extraSelections() const -
2154{ -
2155 const QWidgetTextControlPrivate * const d = d_func(); -
2156 QList<QTextEdit::ExtraSelection> selections; -
2157 for (int i = 0; i < d->extraSelections.count(); ++i) {
evaluated: i < d->extraSelections.count()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2158 QTextEdit::ExtraSelection sel; -
2159 sel.cursor = d->extraSelections.at(i).cursor; -
2160 sel.format = d->extraSelections.at(i).format; -
2161 selections.append(sel); -
2162 }
executed: }
Execution Count:1
1
2163 return selections;
executed: return selections;
Execution Count:1
1
2164} -
2165 -
2166 -
2167 -
2168void QWidgetTextControl::setTextWidth(qreal width) -
2169{ -
2170 QWidgetTextControlPrivate * const d = d_func(); -
2171 d->doc->setTextWidth(width); -
2172}
executed: }
Execution Count:197
197
2173 -
2174qreal QWidgetTextControl::textWidth() const -
2175{ -
2176 const QWidgetTextControlPrivate * const d = d_func(); -
2177 return d->doc->textWidth();
executed: return d->doc->textWidth();
Execution Count:102
102
2178} -
2179 -
2180QSizeF QWidgetTextControl::size() const -
2181{ -
2182 const QWidgetTextControlPrivate * const d = d_func(); -
2183 return d->doc->size();
executed: return d->doc->size();
Execution Count:206
206
2184} -
2185 -
2186void QWidgetTextControl::setOpenExternalLinks(bool open) -
2187{ -
2188 QWidgetTextControlPrivate * const d = d_func(); -
2189 d->openExternalLinks = open; -
2190}
executed: }
Execution Count:23
23
2191 -
2192bool QWidgetTextControl::openExternalLinks() const -
2193{ -
2194 const QWidgetTextControlPrivate * const d = d_func(); -
2195 return d->openExternalLinks;
never executed: return d->openExternalLinks;
0
2196} -
2197 -
2198bool QWidgetTextControl::ignoreUnusedNavigationEvents() const -
2199{ -
2200 const QWidgetTextControlPrivate * const d = d_func(); -
2201 return d->ignoreUnusedNavigationEvents;
never executed: return d->ignoreUnusedNavigationEvents;
0
2202} -
2203 -
2204void QWidgetTextControl::setIgnoreUnusedNavigationEvents(bool ignore) -
2205{ -
2206 QWidgetTextControlPrivate * const d = d_func(); -
2207 d->ignoreUnusedNavigationEvents = ignore; -
2208}
never executed: }
0
2209 -
2210void QWidgetTextControl::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode) -
2211{ -
2212 QWidgetTextControlPrivate * const d = d_func(); -
2213 const QTextCursor oldSelection = d->cursor; -
2214 const bool moved = d->cursor.movePosition(op, mode); -
2215 d->_q_updateCurrentCharFormatAndSelection(); -
2216 ensureCursorVisible(); -
2217 d->repaintOldAndNewSelection(oldSelection); -
2218 if (moved)
evaluated: moved
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:3
3-8
2219 cursorPositionChanged();
executed: cursorPositionChanged();
Execution Count:8
8
2220}
executed: }
Execution Count:11
11
2221 -
2222bool QWidgetTextControl::canPaste() const -
2223{ -
2224 -
2225 const QWidgetTextControlPrivate * const d = d_func(); -
2226 if (d->interactionFlags & Qt::TextEditable) {
evaluated: d->interactionFlags & Qt::TextEditable
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
1-9
2227 const QMimeData *md = QApplication::clipboard()->mimeData(); -
2228 return md && canInsertFromMimeData(md);
executed: return md && canInsertFromMimeData(md);
Execution Count:9
9
2229 } -
2230 -
2231 return false;
executed: return false;
Execution Count:1
1
2232} -
2233 -
2234void QWidgetTextControl::setCursorIsFocusIndicator(bool b) -
2235{ -
2236 QWidgetTextControlPrivate * const d = d_func(); -
2237 d->cursorIsFocusIndicator = b; -
2238 d->repaintCursor(); -
2239}
executed: }
Execution Count:10
10
2240 -
2241bool QWidgetTextControl::cursorIsFocusIndicator() const -
2242{ -
2243 const QWidgetTextControlPrivate * const d = d_func(); -
2244 return d->cursorIsFocusIndicator;
executed: return d->cursorIsFocusIndicator;
Execution Count:54
54
2245} -
2246 -
2247 -
2248void QWidgetTextControl::setDragEnabled(bool enabled) -
2249{ -
2250 QWidgetTextControlPrivate * const d = d_func(); -
2251 d->dragEnabled = enabled; -
2252}
never executed: }
0
2253 -
2254bool QWidgetTextControl::isDragEnabled() const -
2255{ -
2256 const QWidgetTextControlPrivate * const d = d_func(); -
2257 return d->dragEnabled;
never executed: return d->dragEnabled;
0
2258} -
2259 -
2260void QWidgetTextControl::setWordSelectionEnabled(bool enabled) -
2261{ -
2262 QWidgetTextControlPrivate * const d = d_func(); -
2263 d->wordSelectionEnabled = enabled; -
2264}
never executed: }
0
2265 -
2266bool QWidgetTextControl::isWordSelectionEnabled() const -
2267{ -
2268 const QWidgetTextControlPrivate * const d = d_func(); -
2269 return d->wordSelectionEnabled;
never executed: return d->wordSelectionEnabled;
0
2270} -
2271 -
2272 -
2273void QWidgetTextControl::print(QPagedPaintDevice *printer) const -
2274{ -
2275 const QWidgetTextControlPrivate * const d = d_func(); -
2276 if (!printer)
never evaluated: !printer
0
2277 return;
never executed: return;
0
2278 QTextDocument *tempDoc = 0; -
2279 const QTextDocument *doc = d->doc; -
2280 if (QPagedPaintDevicePrivate::get(printer)->printSelectionOnly) {
never evaluated: QPagedPaintDevicePrivate::get(printer)->printSelectionOnly
0
2281 if (!d->cursor.hasSelection())
never evaluated: !d->cursor.hasSelection()
0
2282 return;
never executed: return;
0
2283 tempDoc = new QTextDocument(const_cast<QTextDocument *>(doc)); -
2284 tempDoc->setMetaInformation(QTextDocument::DocumentTitle, doc->metaInformation(QTextDocument::DocumentTitle)); -
2285 tempDoc->setPageSize(doc->pageSize()); -
2286 tempDoc->setDefaultFont(doc->defaultFont()); -
2287 tempDoc->setUseDesignMetrics(doc->useDesignMetrics()); -
2288 QTextCursor(tempDoc).insertFragment(d->cursor.selection()); -
2289 doc = tempDoc; -
2290 -
2291 -
2292 doc->documentLayout()->d_func()->handlers = d->doc->documentLayout()->d_func()->handlers; -
2293 }
never executed: }
0
2294 doc->print(printer); -
2295 delete tempDoc; -
2296}
never executed: }
0
2297 -
2298 -
2299QMimeData *QWidgetTextControl::createMimeDataFromSelection() const -
2300{ -
2301 const QWidgetTextControlPrivate * const d = d_func(); -
2302 const QTextDocumentFragment fragment(d->cursor); -
2303 return new QTextEditMimeData(fragment);
executed: return new QTextEditMimeData(fragment);
Execution Count:7
7
2304} -
2305 -
2306bool QWidgetTextControl::canInsertFromMimeData(const QMimeData *source) const -
2307{ -
2308 const QWidgetTextControlPrivate * const d = d_func(); -
2309 if (d->acceptRichText)
partially evaluated: d->acceptRichText
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
2310 return (source->hasText() && !source->text().isEmpty()) 0
2311 || source->hasHtml() 0
2312 || source->hasFormat(QLatin1String("application/x-qrichtext")) 0
2313 || source->hasFormat(QLatin1String("application/x-qt-richtext"));
never executed: return (source->hasText() && !source->text().isEmpty()) || source->hasHtml() || source->hasFormat(QLatin1String("application/x-qrichtext")) || source->hasFormat(QLatin1String("application/x-qt-richtext"));
0
2314 else -
2315 return source->hasText() && !source->text().isEmpty();
executed: return source->hasText() && !source->text().isEmpty();
Execution Count:9
9
2316} -
2317 -
2318void QWidgetTextControl::insertFromMimeData(const QMimeData *source) -
2319{ -
2320 QWidgetTextControlPrivate * const d = d_func(); -
2321 if (!(d->interactionFlags & Qt::TextEditable) || !source)
partially evaluated: !(d->interactionFlags & Qt::TextEditable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: !source
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2322 return;
never executed: return;
0
2323 -
2324 bool hasData = false; -
2325 QTextDocumentFragment fragment; -
2326 -
2327 if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) {
partially evaluated: source->hasFormat(QLatin1String("application/x-qrichtext"))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: d->acceptRichText
0-3
2328 -
2329 QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext"))); -
2330 richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />")); -
2331 fragment = QTextDocumentFragment::fromHtml(richtext, d->doc); -
2332 hasData = true; -
2333 } else if (source->hasHtml() && d->acceptRichText) {
never executed: }
evaluated: source->hasHtml()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
partially evaluated: d->acceptRichText
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2334 fragment = QTextDocumentFragment::fromHtml(source->html(), d->doc); -
2335 hasData = true; -
2336 } else {
never executed: }
0
2337 QString text = source->text(); -
2338 if (!text.isNull()) {
partially evaluated: !text.isNull()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2339 fragment = QTextDocumentFragment::fromPlainText(text); -
2340 hasData = true; -
2341 }
executed: }
Execution Count:3
3
2342 }
executed: }
Execution Count:3
3
2343 -
2344 -
2345 -
2346 -
2347 if (hasData)
partially evaluated: hasData
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2348 d->cursor.insertFragment(fragment);
executed: d->cursor.insertFragment(fragment);
Execution Count:3
3
2349 ensureCursorVisible(); -
2350}
executed: }
Execution Count:3
3
2351 -
2352bool QWidgetTextControl::findNextPrevAnchor(const QTextCursor &startCursor, bool next, QTextCursor &newAnchor) -
2353{ -
2354 QWidgetTextControlPrivate * const d = d_func(); -
2355 -
2356 int anchorStart = -1; -
2357 QString anchorHref; -
2358 int anchorEnd = -1; -
2359 -
2360 if (next) {
evaluated: next
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2
2-9
2361 const int startPos = startCursor.selectionEnd(); -
2362 -
2363 QTextBlock block = d->doc->findBlock(startPos); -
2364 QTextBlock::Iterator it = block.begin(); -
2365 -
2366 while (!it.atEnd() && it.fragment().position() < startPos)
evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:1
evaluated: it.fragment().position() < startPos
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:8
1-13
2367 ++it;
executed: ++it;
Execution Count:5
5
2368 -
2369 while (block.isValid()) {
evaluated: block.isValid()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1
1-10
2370 anchorStart = -1; -
2371 -
2372 -
2373 for (; !it.atEnd(); ++it) {
evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:2
2-14
2374 const QTextFragment fragment = it.fragment(); -
2375 const QTextCharFormat fmt = fragment.charFormat(); -
2376 -
2377 if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
evaluated: fmt.isAnchor()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:6
partially evaluated: fmt.hasProperty(QTextFormat::AnchorHref)
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
2378 anchorStart = fragment.position(); -
2379 anchorHref = fmt.anchorHref(); -
2380 break;
executed: break;
Execution Count:8
8
2381 } -
2382 }
executed: }
Execution Count:6
6
2383 -
2384 if (anchorStart != -1) {
evaluated: anchorStart != -1
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2
2-8
2385 anchorEnd = -1; -
2386 -
2387 -
2388 for (; !it.atEnd(); ++it) {
evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:2
2-14
2389 const QTextFragment fragment = it.fragment(); -
2390 const QTextCharFormat fmt = fragment.charFormat(); -
2391 -
2392 if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
evaluated: !fmt.isAnchor()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:9
evaluated: fmt.anchorHref() != anchorHref
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-9
2393 anchorEnd = fragment.position(); -
2394 break;
executed: break;
Execution Count:6
6
2395 } -
2396 }
executed: }
Execution Count:8
8
2397 -
2398 if (anchorEnd == -1)
evaluated: anchorEnd == -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
2-6
2399 anchorEnd = block.position() + block.length() - 1;
executed: anchorEnd = block.position() + block.length() - 1;
Execution Count:2
2
2400 -
2401 -
2402 break;
executed: break;
Execution Count:8
8
2403 } -
2404 -
2405 block = block.next(); -
2406 it = block.begin(); -
2407 }
executed: }
Execution Count:2
2
2408 } else {
executed: }
Execution Count:9
9
2409 int startPos = startCursor.selectionStart(); -
2410 if (startPos > 0)
partially evaluated: startPos > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2411 --startPos;
executed: --startPos;
Execution Count:2
2
2412 -
2413 QTextBlock block = d->doc->findBlock(startPos); -
2414 QTextBlock::Iterator blockStart = block.begin(); -
2415 QTextBlock::Iterator it = block.end(); -
2416 -
2417 if (startPos == block.position()) {
partially evaluated: startPos == block.position()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2418 it = block.begin(); -
2419 } else {
never executed: }
0
2420 do { -
2421 if (it == blockStart) {
partially evaluated: it == blockStart
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2422 it = QTextBlock::Iterator(); -
2423 block = QTextBlock(); -
2424 } else {
never executed: }
0
2425 --it; -
2426 }
executed: }
Execution Count:3
3
2427 } while (!it.atEnd() && it.fragment().position() + it.fragment().length() - 1 > startPos);
partially evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
evaluated: it.fragment().position() + it.fragment().length() - 1 > startPos
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
0-3
2428 }
executed: }
Execution Count:2
2
2429 -
2430 while (block.isValid()) {
partially evaluated: block.isValid()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2431 anchorStart = -1; -
2432 -
2433 if (!it.atEnd()) {
partially evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2434 do { -
2435 const QTextFragment fragment = it.fragment(); -
2436 const QTextCharFormat fmt = fragment.charFormat(); -
2437 -
2438 if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
partially evaluated: fmt.isAnchor()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: fmt.hasProperty(QTextFormat::AnchorHref)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2439 anchorStart = fragment.position() + fragment.length(); -
2440 anchorHref = fmt.anchorHref(); -
2441 break;
executed: break;
Execution Count:2
2
2442 } -
2443 -
2444 if (it == blockStart)
never evaluated: it == blockStart
0
2445 it = QTextBlock::Iterator();
never executed: it = QTextBlock::Iterator();
0
2446 else -
2447 --it;
never executed: --it;
0
2448 } while (!it.atEnd());
never evaluated: !it.atEnd()
0
2449 }
executed: }
Execution Count:2
2
2450 -
2451 if (anchorStart != -1 && !it.atEnd()) {
partially evaluated: anchorStart != -1
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2452 anchorEnd = -1; -
2453 -
2454 do { -
2455 const QTextFragment fragment = it.fragment(); -
2456 const QTextCharFormat fmt = fragment.charFormat(); -
2457 -
2458 if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
partially evaluated: !fmt.isAnchor()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
evaluated: fmt.anchorHref() != anchorHref
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
0-3
2459 anchorEnd = fragment.position() + fragment.length(); -
2460 break;
executed: break;
Execution Count:1
1
2461 } -
2462 -
2463 if (it == blockStart)
evaluated: it == blockStart
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2464 it = QTextBlock::Iterator();
executed: it = QTextBlock::Iterator();
Execution Count:1
1
2465 else -
2466 --it;
executed: --it;
Execution Count:1
1
2467 } while (!it.atEnd());
evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2468 -
2469 if (anchorEnd == -1)
evaluated: anchorEnd == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2470 anchorEnd = qMax(0, block.position());
executed: anchorEnd = qMax(0, block.position());
Execution Count:1
1
2471 -
2472 break;
executed: break;
Execution Count:2
2
2473 } -
2474 -
2475 block = block.previous(); -
2476 it = block.end(); -
2477 if (it != block.begin())
never evaluated: it != block.begin()
0
2478 --it;
never executed: --it;
0
2479 blockStart = block.begin(); -
2480 }
never executed: }
0
2481 -
2482 }
executed: }
Execution Count:2
2
2483 -
2484 if (anchorStart != -1 && anchorEnd != -1) {
evaluated: anchorStart != -1
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1
partially evaluated: anchorEnd != -1
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
2485 newAnchor = d->cursor; -
2486 newAnchor.setPosition(anchorStart); -
2487 newAnchor.setPosition(anchorEnd, QTextCursor::KeepAnchor); -
2488 return true;
executed: return true;
Execution Count:10
10
2489 } -
2490 -
2491 return false;
executed: return false;
Execution Count:1
1
2492} -
2493 -
2494void QWidgetTextControlPrivate::activateLinkUnderCursor(QString href) -
2495{ -
2496 QTextCursor oldCursor = cursor; -
2497 -
2498 if (href.isEmpty()) {
partially evaluated: href.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
2499 QTextCursor tmp = cursor; -
2500 if (tmp.selectionStart() != tmp.position())
partially evaluated: tmp.selectionStart() != tmp.position()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
2501 tmp.setPosition(tmp.selectionStart());
executed: tmp.setPosition(tmp.selectionStart());
Execution Count:6
6
2502 tmp.movePosition(QTextCursor::NextCharacter); -
2503 href = tmp.charFormat().anchorHref(); -
2504 }
executed: }
Execution Count:6
6
2505 if (href.isEmpty())
partially evaluated: href.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2506 return;
never executed: return;
0
2507 -
2508 if (!cursor.hasSelection()) {
partially evaluated: !cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2509 QTextBlock block = cursor.block(); -
2510 const int cursorPos = cursor.position(); -
2511 -
2512 QTextBlock::Iterator it = block.begin(); -
2513 QTextBlock::Iterator linkFragment; -
2514 -
2515 for (; !it.atEnd(); ++it) {
never evaluated: !it.atEnd()
0
2516 QTextFragment fragment = it.fragment(); -
2517 const int fragmentPos = fragment.position(); -
2518 if (fragmentPos <= cursorPos &&
never evaluated: fragmentPos <= cursorPos
0
2519 fragmentPos + fragment.length() > cursorPos) {
never evaluated: fragmentPos + fragment.length() > cursorPos
0
2520 linkFragment = it; -
2521 break;
never executed: break;
0
2522 } -
2523 }
never executed: }
0
2524 -
2525 if (!linkFragment.atEnd()) {
never evaluated: !linkFragment.atEnd()
0
2526 it = linkFragment; -
2527 cursor.setPosition(it.fragment().position()); -
2528 if (it != block.begin()) {
never evaluated: it != block.begin()
0
2529 do { -
2530 --it; -
2531 QTextFragment fragment = it.fragment(); -
2532 if (fragment.charFormat().anchorHref() != href)
never evaluated: fragment.charFormat().anchorHref() != href
0
2533 break;
never executed: break;
0
2534 cursor.setPosition(fragment.position()); -
2535 } while (it != block.begin());
never executed: }
never evaluated: it != block.begin()
0
2536 }
never executed: }
0
2537 -
2538 for (it = linkFragment; !it.atEnd(); ++it) {
never evaluated: !it.atEnd()
0
2539 QTextFragment fragment = it.fragment(); -
2540 if (fragment.charFormat().anchorHref() != href)
never evaluated: fragment.charFormat().anchorHref() != href
0
2541 break;
never executed: break;
0
2542 cursor.setPosition(fragment.position() + fragment.length(), QTextCursor::KeepAnchor); -
2543 }
never executed: }
0
2544 }
never executed: }
0
2545 }
never executed: }
0
2546 -
2547 if (hasFocus) {
partially evaluated: hasFocus
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
2548 cursorIsFocusIndicator = true; -
2549 } else {
executed: }
Execution Count:6
6
2550 cursorIsFocusIndicator = false; -
2551 cursor.clearSelection(); -
2552 }
never executed: }
0
2553 repaintOldAndNewSelection(oldCursor); -
2554 -
2555 -
2556 if (openExternalLinks)
partially evaluated: openExternalLinks
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2557 QDesktopServices::openUrl(href);
never executed: QDesktopServices::openUrl(href);
0
2558 else -
2559 -
2560 q_func()->linkActivated(href);
executed: q_func()->linkActivated(href);
Execution Count:6
6
2561} -
2562 -
2563 -
2564void QWidgetTextControlPrivate::showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget) -
2565{ -
2566 const QString toolTip = q_func()->cursorForPosition(pos).charFormat().toolTip(); -
2567 if (toolTip.isEmpty())
never evaluated: toolTip.isEmpty()
0
2568 return;
never executed: return;
0
2569 QToolTip::showText(globalPos, toolTip, contextWidget); -
2570}
never executed: }
0
2571 -
2572 -
2573bool QWidgetTextControlPrivate::isPreediting() const -
2574{ -
2575 QTextLayout *layout = cursor.block().layout(); -
2576 if (layout && !layout->preeditAreaText().isEmpty())
partially evaluated: layout
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
partially evaluated: !layout->preeditAreaText().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
2577 return true;
never executed: return true;
0
2578 -
2579 return false;
executed: return false;
Execution Count:11
11
2580} -
2581 -
2582void QWidgetTextControlPrivate::commitPreedit() -
2583{ -
2584 if (!isPreediting())
partially evaluated: !isPreediting()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2585 return;
executed: return;
Execution Count:2
2
2586 -
2587 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit(); -
2588 -
2589 if (!isPreediting())
never evaluated: !isPreediting()
0
2590 return;
never executed: return;
0
2591 -
2592 cursor.beginEditBlock(); -
2593 preeditCursor = 0; -
2594 QTextBlock block = cursor.block(); -
2595 QTextLayout *layout = block.layout(); -
2596 layout->setPreeditArea(-1, QString()); -
2597 layout->clearAdditionalFormats(); -
2598 cursor.endEditBlock(); -
2599}
never executed: }
0
2600 -
2601bool QWidgetTextControl::setFocusToNextOrPreviousAnchor(bool next) -
2602{ -
2603 QWidgetTextControlPrivate * const d = d_func(); -
2604 -
2605 if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
partially evaluated: !(d->interactionFlags & Qt::LinksAccessibleByKeyboard)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
2606 return false;
never executed: return false;
0
2607 -
2608 QRectF crect = selectionRect(); -
2609 updateRequest(crect); -
2610 -
2611 -
2612 if (!d->cursor.hasSelection()) {
evaluated: !d->cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:4
4-7
2613 d->cursor = QTextCursor(d->doc); -
2614 if (next)
evaluated: next
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
2615 d->cursor.movePosition(QTextCursor::Start);
executed: d->cursor.movePosition(QTextCursor::Start);
Execution Count:6
6
2616 else -
2617 d->cursor.movePosition(QTextCursor::End);
executed: d->cursor.movePosition(QTextCursor::End);
Execution Count:1
1
2618 } -
2619 -
2620 QTextCursor newAnchor; -
2621 if (findNextPrevAnchor(d->cursor, next, newAnchor)) {
evaluated: findNextPrevAnchor(d->cursor, next, newAnchor)
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1
1-10
2622 d->cursor = newAnchor; -
2623 d->cursorIsFocusIndicator = true; -
2624 } else {
executed: }
Execution Count:10
10
2625 d->cursor.clearSelection(); -
2626 }
executed: }
Execution Count:1
1
2627 -
2628 if (d->cursor.hasSelection()) {
evaluated: d->cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1
1-10
2629 crect = selectionRect(); -
2630 updateRequest(crect); -
2631 visibilityRequest(crect); -
2632 return true;
executed: return true;
Execution Count:10
10
2633 } else { -
2634 return false;
executed: return false;
Execution Count:1
1
2635 } -
2636} -
2637 -
2638bool QWidgetTextControl::setFocusToAnchor(const QTextCursor &newCursor) -
2639{ -
2640 QWidgetTextControlPrivate * const d = d_func(); -
2641 -
2642 if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
never evaluated: !(d->interactionFlags & Qt::LinksAccessibleByKeyboard)
0
2643 return false;
never executed: return false;
0
2644 -
2645 -
2646 const QString anchorHref = d->anchorForCursor(newCursor); -
2647 if (anchorHref.isEmpty())
never evaluated: anchorHref.isEmpty()
0
2648 return false;
never executed: return false;
0
2649 -
2650 -
2651 QRectF crect = selectionRect(); -
2652 updateRequest(crect); -
2653 -
2654 d->cursor.setPosition(newCursor.selectionStart()); -
2655 d->cursor.setPosition(newCursor.selectionEnd(), QTextCursor::KeepAnchor); -
2656 d->cursorIsFocusIndicator = true; -
2657 -
2658 crect = selectionRect(); -
2659 updateRequest(crect); -
2660 visibilityRequest(crect); -
2661 return true;
never executed: return true;
0
2662} -
2663 -
2664void QWidgetTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags) -
2665{ -
2666 QWidgetTextControlPrivate * const d = d_func(); -
2667 if (flags == d->interactionFlags)
evaluated: flags == d->interactionFlags
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:166
12-166
2668 return;
executed: return;
Execution Count:12
12
2669 d->interactionFlags = flags; -
2670 -
2671 if (d->hasFocus)
evaluated: d->hasFocus
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:164
2-164
2672 d->setBlinkingCursorEnabled(flags & Qt::TextEditable);
executed: d->setBlinkingCursorEnabled(flags & Qt::TextEditable);
Execution Count:2
2
2673}
executed: }
Execution Count:166
166
2674 -
2675Qt::TextInteractionFlags QWidgetTextControl::textInteractionFlags() const -
2676{ -
2677 const QWidgetTextControlPrivate * const d = d_func(); -
2678 return d->interactionFlags;
executed: return d->interactionFlags;
Execution Count:192
192
2679} -
2680 -
2681void QWidgetTextControl::mergeCurrentCharFormat(const QTextCharFormat &modifier) -
2682{ -
2683 QWidgetTextControlPrivate * const d = d_func(); -
2684 d->cursor.mergeCharFormat(modifier); -
2685 d->updateCurrentCharFormat(); -
2686}
executed: }
Execution Count:5
5
2687 -
2688void QWidgetTextControl::setCurrentCharFormat(const QTextCharFormat &format) -
2689{ -
2690 QWidgetTextControlPrivate * const d = d_func(); -
2691 d->cursor.setCharFormat(format); -
2692 d->updateCurrentCharFormat(); -
2693}
never executed: }
0
2694 -
2695QTextCharFormat QWidgetTextControl::currentCharFormat() const -
2696{ -
2697 const QWidgetTextControlPrivate * const d = d_func(); -
2698 return d->cursor.charFormat();
never executed: return d->cursor.charFormat();
0
2699} -
2700 -
2701void QWidgetTextControl::insertPlainText(const QString &text) -
2702{ -
2703 QWidgetTextControlPrivate * const d = d_func(); -
2704 d->cursor.insertText(text); -
2705}
executed: }
Execution Count:3
3
2706 -
2707 -
2708void QWidgetTextControl::insertHtml(const QString &text) -
2709{ -
2710 QWidgetTextControlPrivate * const d = d_func(); -
2711 d->cursor.insertHtml(text); -
2712}
never executed: }
0
2713 -
2714 -
2715QPointF QWidgetTextControl::anchorPosition(const QString &name) const -
2716{ -
2717 const QWidgetTextControlPrivate * const d = d_func(); -
2718 if (name.isEmpty())
partially evaluated: name.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
2719 return QPointF();
never executed: return QPointF();
0
2720 -
2721 QRectF r; -
2722 for (QTextBlock block = d->doc->begin(); block.isValid(); block = block.next()) {
evaluated: block.isValid()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:4
4-10
2723 QTextCharFormat format = block.charFormat(); -
2724 if (format.isAnchor() && format.anchorNames().contains(name)) {
evaluated: format.isAnchor()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
evaluated: format.anchorNames().contains(name)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-7
2725 r = d->rectForPosition(block.position()); -
2726 break;
executed: break;
Execution Count:1
1
2727 } -
2728 -
2729 for (QTextBlock::Iterator it = block.begin(); !it.atEnd(); ++it) {
evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:5
5-14
2730 QTextFragment fragment = it.fragment(); -
2731 format = fragment.charFormat(); -
2732 if (format.isAnchor() && format.anchorNames().contains(name)) {
evaluated: format.isAnchor()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:6
evaluated: format.anchorNames().contains(name)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4-8
2733 r = d->rectForPosition(fragment.position()); -
2734 block = QTextBlock(); -
2735 break;
executed: break;
Execution Count:4
4
2736 } -
2737 }
executed: }
Execution Count:10
10
2738 }
executed: }
Execution Count:9
9
2739 if (!r.isValid())
partially evaluated: !r.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
2740 return QPointF();
never executed: return QPointF();
0
2741 return QPointF(0, r.top());
executed: return QPointF(0, r.top());
Execution Count:5
5
2742} -
2743 -
2744void QWidgetTextControl::adjustSize() -
2745{ -
2746 QWidgetTextControlPrivate * const d = d_func(); -
2747 d->doc->adjustSize(); -
2748}
executed: }
Execution Count:7
7
2749 -
2750bool QWidgetTextControl::find(const QString &exp, QTextDocument::FindFlags options) -
2751{ -
2752 QWidgetTextControlPrivate * const d = d_func(); -
2753 QTextCursor search = d->doc->find(exp, d->cursor, options); -
2754 if (search.isNull())
never evaluated: search.isNull()
0
2755 return false;
never executed: return false;
0
2756 -
2757 setTextCursor(search); -
2758 return true;
never executed: return true;
0
2759} -
2760 -
2761QString QWidgetTextControl::toPlainText() const -
2762{ -
2763 return document()->toPlainText();
executed: return document()->toPlainText();
Execution Count:33
33
2764} -
2765 -
2766 -
2767QString QWidgetTextControl::toHtml() const -
2768{ -
2769 return document()->toHtml();
executed: return document()->toHtml();
Execution Count:1
1
2770} -
2771 -
2772 -
2773void QWidgetTextControlPrivate::append(const QString &text, Qt::TextFormat format) -
2774{ -
2775 QTextCursor tmp(doc); -
2776 tmp.beginEditBlock(); -
2777 tmp.movePosition(QTextCursor::End); -
2778 -
2779 if (!doc->isEmpty())
evaluated: !doc->isEmpty()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:5
5-8
2780 tmp.insertBlock(cursor.blockFormat(), cursor.charFormat());
executed: tmp.insertBlock(cursor.blockFormat(), cursor.charFormat());
Execution Count:8
8
2781 else -
2782 tmp.setCharFormat(cursor.charFormat());
executed: tmp.setCharFormat(cursor.charFormat());
Execution Count:5
5
2783 -
2784 -
2785 QTextCharFormat oldCharFormat = cursor.charFormat(); -
2786 -
2787 -
2788 if (format == Qt::RichText || (format == Qt::AutoText && Qt::mightBeRichText(text))) {
evaluated: format == Qt::RichText
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:9
partially evaluated: format == Qt::AutoText
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
never evaluated: Qt::mightBeRichText(text)
0-9
2789 tmp.insertHtml(text); -
2790 } else {
executed: }
Execution Count:4
4
2791 tmp.insertText(text); -
2792 }
executed: }
Execution Count:9
9
2793 -
2794 -
2795 -
2796 if (!cursor.hasSelection())
evaluated: !cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
2797 cursor.setCharFormat(oldCharFormat);
executed: cursor.setCharFormat(oldCharFormat);
Execution Count:12
12
2798 -
2799 tmp.endEditBlock(); -
2800}
executed: }
Execution Count:13
13
2801 -
2802void QWidgetTextControl::append(const QString &text) -
2803{ -
2804 QWidgetTextControlPrivate * const d = d_func(); -
2805 d->append(text, Qt::AutoText); -
2806}
never executed: }
0
2807 -
2808void QWidgetTextControl::appendHtml(const QString &html) -
2809{ -
2810 QWidgetTextControlPrivate * const d = d_func(); -
2811 d->append(html, Qt::RichText); -
2812}
executed: }
Execution Count:4
4
2813 -
2814void QWidgetTextControl::appendPlainText(const QString &text) -
2815{ -
2816 QWidgetTextControlPrivate * const d = d_func(); -
2817 d->append(text, Qt::PlainText); -
2818}
executed: }
Execution Count:9
9
2819 -
2820 -
2821void QWidgetTextControl::ensureCursorVisible() -
2822{ -
2823 QWidgetTextControlPrivate * const d = d_func(); -
2824 QRectF crect = d->rectForPosition(d->cursor.position()).adjusted(-5, 0, 5, 0); -
2825 visibilityRequest(crect); -
2826 microFocusChanged(); -
2827}
executed: }
Execution Count:580
580
2828 -
2829QPalette QWidgetTextControl::palette() const -
2830{ -
2831 const QWidgetTextControlPrivate * const d = d_func(); -
2832 return d->palette;
never executed: return d->palette;
0
2833} -
2834 -
2835void QWidgetTextControl::setPalette(const QPalette &pal) -
2836{ -
2837 QWidgetTextControlPrivate * const d = d_func(); -
2838 d->palette = pal; -
2839}
executed: }
Execution Count:210
210
2840 -
2841QAbstractTextDocumentLayout::PaintContext QWidgetTextControl::getPaintContext(QWidget *widget) const -
2842{ -
2843 const QWidgetTextControlPrivate * const d = d_func(); -
2844 -
2845 QAbstractTextDocumentLayout::PaintContext ctx; -
2846 -
2847 ctx.selections = d->extraSelections; -
2848 ctx.palette = d->palette; -
2849 if (d->cursorOn && d->isEnabled) {
evaluated: d->cursorOn
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:262
partially evaluated: d->isEnabled
TRUEFALSE
yes
Evaluation Count:40
no
Evaluation Count:0
0-262
2850 if (d->hideCursor)
partially evaluated: d->hideCursor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
2851 ctx.cursorPosition = -1;
never executed: ctx.cursorPosition = -1;
0
2852 else if (d->preeditCursor != 0)
partially evaluated: d->preeditCursor != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
2853 ctx.cursorPosition = - (d->preeditCursor + 2);
never executed: ctx.cursorPosition = - (d->preeditCursor + 2);
0
2854 else -
2855 ctx.cursorPosition = d->cursor.position();
executed: ctx.cursorPosition = d->cursor.position();
Execution Count:40
40
2856 } -
2857 -
2858 if (!d->dndFeedbackCursor.isNull())
partially evaluated: !d->dndFeedbackCursor.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:302
0-302
2859 ctx.cursorPosition = d->dndFeedbackCursor.position();
never executed: ctx.cursorPosition = d->dndFeedbackCursor.position();
0
2860 -
2861 -
2862 -
2863 if (d->cursor.hasSelection()) {
partially evaluated: d->cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:302
0-302
2864 QAbstractTextDocumentLayout::Selection selection; -
2865 selection.cursor = d->cursor; -
2866 if (d->cursorIsFocusIndicator) {
never evaluated: d->cursorIsFocusIndicator
0
2867 QStyleOption opt; -
2868 opt.palette = ctx.palette; -
2869 QStyleHintReturnVariant ret; -
2870 QStyle *style = QApplication::style(); -
2871 if (widget)
never evaluated: widget
0
2872 style = widget->style();
never executed: style = widget->style();
0
2873 style->styleHint(QStyle::SH_TextControl_FocusIndicatorTextCharFormat, &opt, widget, &ret); -
2874 selection.format = qvariant_cast<QTextFormat>(ret.variant).toCharFormat(); -
2875 } else {
never executed: }
0
2876 QPalette::ColorGroup cg = d->hasFocus ? QPalette::Active : QPalette::Inactive;
never evaluated: d->hasFocus
0
2877 selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight)); -
2878 selection.format.setForeground(ctx.palette.brush(cg, QPalette::HighlightedText)); -
2879 QStyleOption opt; -
2880 QStyle *style = QApplication::style(); -
2881 if (widget) {
never evaluated: widget
0
2882 opt.initFrom(widget); -
2883 style = widget->style(); -
2884 }
never executed: }
0
2885 if (style->styleHint(QStyle::SH_RichText_FullWidthSelection, &opt, widget))
never evaluated: style->styleHint(QStyle::SH_RichText_FullWidthSelection, &opt, widget)
0
2886 selection.format.setProperty(QTextFormat::FullWidthSelection, true);
never executed: selection.format.setProperty(QTextFormat::FullWidthSelection, true);
0
2887 }
never executed: }
0
2888 ctx.selections.append(selection); -
2889 }
never executed: }
0
2890 -
2891 return ctx;
executed: return ctx;
Execution Count:302
302
2892} -
2893 -
2894void QWidgetTextControl::drawContents(QPainter *p, const QRectF &rect, QWidget *widget) -
2895{ -
2896 QWidgetTextControlPrivate * const d = d_func(); -
2897 p->save(); -
2898 QAbstractTextDocumentLayout::PaintContext ctx = getPaintContext(widget); -
2899 if (rect.isValid())
evaluated: rect.isValid()
TRUEFALSE
yes
Evaluation Count:271
yes
Evaluation Count:24
24-271
2900 p->setClipRect(rect, Qt::IntersectClip);
executed: p->setClipRect(rect, Qt::IntersectClip);
Execution Count:271
271
2901 ctx.clip = rect; -
2902 -
2903 d->doc->documentLayout()->draw(p, ctx); -
2904 p->restore(); -
2905}
executed: }
Execution Count:295
295
2906 -
2907void QWidgetTextControlPrivate::_q_copyLink() -
2908{ -
2909 -
2910 QMimeData *md = new QMimeData; -
2911 md->setText(linkToCopy); -
2912 QApplication::clipboard()->setMimeData(md); -
2913 -
2914}
never executed: }
0
2915 -
2916int QWidgetTextControl::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const -
2917{ -
2918 const QWidgetTextControlPrivate * const d = d_func(); -
2919 return d->doc->documentLayout()->hitTest(point, accuracy);
executed: return d->doc->documentLayout()->hitTest(point, accuracy);
Execution Count:2
2
2920} -
2921 -
2922QRectF QWidgetTextControl::blockBoundingRect(const QTextBlock &block) const -
2923{ -
2924 const QWidgetTextControlPrivate * const d = d_func(); -
2925 return d->doc->documentLayout()->blockBoundingRect(block);
executed: return d->doc->documentLayout()->blockBoundingRect(block);
Execution Count:1292
1292
2926} -
2927 -
2928 -
2929 -
2930const struct QUnicodeControlCharacter { -
2931 const char *text; -
2932 ushort character; -
2933} qt_controlCharacters[10] = { -
2934 { "LRM Left-to-right mark", 0x200e }, -
2935 { "RLM Right-to-left mark", 0x200f }, -
2936 { "ZWJ Zero width joiner", 0x200d }, -
2937 { "ZWNJ Zero width non-joiner", 0x200c }, -
2938 { "ZWSP Zero width space", 0x200b }, -
2939 { "LRE Start of left-to-right embedding", 0x202a }, -
2940 { "RLE Start of right-to-left embedding", 0x202b }, -
2941 { "LRO Start of left-to-right override", 0x202d }, -
2942 { "RLO Start of right-to-left override", 0x202e }, -
2943 { "PDF Pop directional formatting", 0x202c }, -
2944}; -
2945 -
2946QUnicodeControlCharacterMenu::QUnicodeControlCharacterMenu(QObject *_editWidget, QWidget *parent) -
2947 : QMenu(parent), editWidget(_editWidget) -
2948{ -
2949 setTitle(tr("Insert Unicode control character")); -
2950 for (int i = 0; i < 10; ++i) {
never evaluated: i < 10
0
2951 addAction(tr(qt_controlCharacters[i].text), this, "1""menuActionTriggered()"); -
2952 }
never executed: }
0
2953}
never executed: }
0
2954 -
2955void QUnicodeControlCharacterMenu::menuActionTriggered() -
2956{ -
2957 QAction *a = qobject_cast<QAction *>(sender()); -
2958 int idx = actions().indexOf(a); -
2959 if (idx < 0 || idx >= 10)
never evaluated: idx < 0
never evaluated: idx >= 10
0
2960 return;
never executed: return;
0
2961 QChar c(qt_controlCharacters[idx].character); -
2962 QString str(c); -
2963 -
2964 -
2965 if (QTextEdit *edit = qobject_cast<QTextEdit *>(editWidget)) {
never evaluated: QTextEdit *edit = qobject_cast<QTextEdit *>(editWidget)
0
2966 edit->insertPlainText(str); -
2967 return;
never executed: return;
0
2968 } -
2969 -
2970 if (QWidgetTextControl *control = qobject_cast<QWidgetTextControl *>(editWidget)) {
never evaluated: QWidgetTextControl *control = qobject_cast<QWidgetTextControl *>(editWidget)
0
2971 control->insertPlainText(str); -
2972 }
never executed: }
0
2973 -
2974 if (QLineEdit *edit = qobject_cast<QLineEdit *>(editWidget)) {
never evaluated: QLineEdit *edit = qobject_cast<QLineEdit *>(editWidget)
0
2975 edit->insert(str); -
2976 return;
never executed: return;
0
2977 } -
2978 -
2979}
never executed: }
0
2980 -
2981 -
2982QStringList QTextEditMimeData::formats() const -
2983{ -
2984 if (!fragment.isEmpty())
evaluated: !fragment.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
2985 return QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("text/html") 4
2986 4
2987 << QString::fromLatin1("application/vnd.oasis.opendocument.text") 4
2988 4
2989 ;
executed: return QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("text/html") << QString::fromLatin1("application/vnd.oasis.opendocument.text") ;
Execution Count:4
4
2990 else -
2991 return QMimeData::formats();
executed: return QMimeData::formats();
Execution Count:1
1
2992} -
2993 -
2994QVariant QTextEditMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const -
2995{ -
2996 if (!fragment.isEmpty())
evaluated: !fragment.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
2997 setup();
executed: setup();
Execution Count:3
3
2998 return QMimeData::retrieveData(mimeType, type);
executed: return QMimeData::retrieveData(mimeType, type);
Execution Count:4
4
2999} -
3000 -
3001void QTextEditMimeData::setup() const -
3002{ -
3003 QTextEditMimeData *that = const_cast<QTextEditMimeData *>(this); -
3004 -
3005 that->setData(QLatin1String("text/html"), fragment.toHtml("utf-8").toUtf8()); -
3006 -
3007 -
3008 { -
3009 QBuffer buffer; -
3010 QTextDocumentWriter writer(&buffer, "ODF"); -
3011 writer.write(fragment); -
3012 buffer.close(); -
3013 that->setData(QLatin1String("application/vnd.oasis.opendocument.text"), buffer.data()); -
3014 } -
3015 -
3016 that->setText(fragment.toPlainText()); -
3017 fragment = QTextDocumentFragment(); -
3018}
executed: }
Execution Count:3
3
3019 -
3020 -
3021 -
3022 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial