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

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