qwidgettextcontrol.cpp

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

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