qwidgettextcontrol.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9