OpenCoverage

qquicktextedit.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicktextedit.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qquicktextedit_p.h"-
41#include "qquicktextedit_p_p.h"-
42#include "qquicktextcontrol_p.h"-
43#include "qquicktextdocument_p.h"-
44#include "qquickevents_p_p.h"-
45#include "qquickwindow.h"-
46#include "qquicktextnode_p.h"-
47#include "qquicktextnodeengine_p.h"-
48-
49#include <QtCore/qmath.h>-
50#include <QtGui/qguiapplication.h>-
51#include <QtGui/qevent.h>-
52#include <QtGui/qpainter.h>-
53#include <QtGui/qtextobject.h>-
54#include <QtGui/qtexttable.h>-
55#include <QtQml/qqmlinfo.h>-
56#include <QtQuick/qsgsimplerectnode.h>-
57-
58#include <private/qqmlglobal_p.h>-
59#include <private/qqmlproperty_p.h>-
60#include <private/qtextengine_p.h>-
61#include <private/qsgadaptationlayer_p.h>-
62-
63#include "qquicktextdocument.h"-
64-
65#include <algorithm>-
66-
67QT_BEGIN_NAMESPACE-
68-
69/*!-
70 \qmltype TextEdit-
71 \instantiates QQuickTextEdit-
72 \inqmlmodule QtQuick-
73 \ingroup qtquick-visual-
74 \ingroup qtquick-input-
75 \inherits Item-
76 \brief Displays multiple lines of editable formatted text.-
77-
78 The TextEdit item displays a block of editable, formatted text.-
79-
80 It can display both plain and rich text. For example:-
81-
82 \qml-
83TextEdit {-
84 width: 240-
85 text: "<b>Hello</b> <i>World!</i>"-
86 font.family: "Helvetica"-
87 font.pointSize: 20-
88 color: "blue"-
89 focus: true-
90}-
91 \endqml-
92-
93 \image declarative-textedit.gif-
94-
95 Setting \l {Item::focus}{focus} to \c true enables the TextEdit item to receive keyboard focus.-
96-
97 Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific-
98 to a look-and-feel. For example, to add flickable scrolling that follows the cursor:-
99-
100 \snippet qml/texteditor.qml 0-
101-
102 A particular look-and-feel might use smooth scrolling (eg. using SmoothedAnimation), might have a visible-
103 scrollbar, or a scrollbar that fades in to show location, etc.-
104-
105 Clipboard support is provided by the cut(), copy(), and paste() functions, and the selection can-
106 be handled in a traditional "mouse" mechanism by setting selectByMouse, or handled completely-
107 from QML by manipulating selectionStart and selectionEnd, or using selectAll() or selectWord().-
108-
109 You can translate between cursor positions (characters from the start of the document) and pixel-
110 points using positionAt() and positionToRectangle().-
111-
112 \sa Text, TextInput-
113*/-
114-
115/*!-
116 \qmlsignal QtQuick::TextEdit::linkActivated(string link)-
117-
118 This signal is emitted when the user clicks on a link embedded in the text.-
119 The link must be in rich text or HTML format and the-
120 \a link string provides access to the particular link.-
121-
122 The corresponding handler is \c onLinkActivated.-
123*/-
124-
125// This is a pretty arbitrary figure. The idea is that we don't want to break down the document-
126// into text nodes corresponding to a text block each so that the glyph node grouping doesn't become pointless.-
127static const int nodeBreakingSize = 300;-
128-
129namespace {-
130 class ProtectedLayoutAccessor: public QAbstractTextDocumentLayout-
131 {-
132 public:-
133 inline QTextCharFormat formatAccessor(int pos)-
134 {-
135 return format(pos);
never executed: return format(pos);
0
136 }-
137 };-
138-
139 class RootNode : public QSGTransformNode-
140 {-
141 public:-
142 RootNode() : cursorNode(nullptr), frameDecorationsNode(nullptr)-
143 { }
executed 234 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
234
144-
145 void resetFrameDecorations(QQuickTextNode* newNode)-
146 {-
147 if (frameDecorationsNode) {
frameDecorationsNodeDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 234 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
58-234
148 removeChildNode(frameDecorationsNode);-
149 delete frameDecorationsNode;-
150 }
executed 58 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
58
151 frameDecorationsNode = newNode;-
152 newNode->setFlag(QSGNode::OwnedByParent);-
153 }
executed 292 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
292
154-
155 void resetCursorNode(QSGInternalRectangleNode* newNode)-
156 {-
157 if (cursorNode)
cursorNodeDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 324 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
12-324
158 removeChildNode(cursorNode);
executed 12 times by 1 test: removeChildNode(cursorNode);
Executed by:
  • tst_qquicktextedit
12
159 delete cursorNode;-
160 cursorNode = newNode;-
161 if (cursorNode) {
cursorNodeDescription
TRUEevaluated 140 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
FALSEevaluated 196 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
140-196
162 appendChildNode(cursorNode);-
163 cursorNode->setFlag(QSGNode::OwnedByParent);-
164 }
executed 140 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
140
165 }
executed 336 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
336
166-
167 QSGInternalRectangleNode *cursorNode;-
168 QQuickTextNode* frameDecorationsNode;-
169-
170 };-
171}-
172-
173QQuickTextEdit::QQuickTextEdit(QQuickItem *parent)-
174: QQuickImplicitSizeItem(*(new QQuickTextEditPrivate), parent)-
175{-
176 Q_D(QQuickTextEdit);-
177 d->init();-
178}
executed 1076 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
1076
179-
180QQuickTextEdit::QQuickTextEdit(QQuickTextEditPrivate &dd, QQuickItem *parent)-
181: QQuickImplicitSizeItem(dd, parent)-
182{-
183 Q_D(QQuickTextEdit);-
184 d->init();-
185}
never executed: end of block
0
186-
187QString QQuickTextEdit::text() const-
188{-
189 Q_D(const QQuickTextEdit);-
190 if (!d->textCached && isComponentComplete()) {
!d->textCachedDescription
TRUEevaluated 1496 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
FALSEevaluated 168 times by 1 test
Evaluated by:
  • tst_qquicktextedit
isComponentComplete()Description
TRUEevaluated 532 times by 2 tests
Evaluated by:
  • tst_qquicktextdocument
  • tst_qquicktextedit
FALSEevaluated 964 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
168-1496
191 QQuickTextEditPrivate *d = const_cast<QQuickTextEditPrivate *>(d_func());-
192#if QT_CONFIG(texthtmlparser)-
193 if (d->richText)
d->richTextDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 510 times by 2 tests
Evaluated by:
  • tst_qquicktextdocument
  • tst_qquicktextedit
22-510
194 d->text = d->control->toHtml();
executed 22 times by 1 test: d->text = d->control->toHtml();
Executed by:
  • tst_qquicktextedit
22
195 else-
196#endif-
197 d->text = d->control->toPlainText();
executed 510 times by 2 tests: d->text = d->control->toPlainText();
Executed by:
  • tst_qquicktextdocument
  • tst_qquicktextedit
510
198 d->textCached = true;-
199 }
executed 532 times by 2 tests: end of block
Executed by:
  • tst_qquicktextdocument
  • tst_qquicktextedit
532
200 return d->text;
executed 1664 times by 5 tests: return d->text;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
1664
201}-
202-
203/*!-
204 \qmlproperty string QtQuick::TextEdit::font.family-
205-
206 Sets the family name of the font.-
207-
208 The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]".-
209 If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen.-
210 If the family isn't available a family will be set using the font matching algorithm.-
211*/-
212-
213/*!-
214 \qmlproperty string QtQuick::TextEdit::font.styleName-
215 \since 5.6-
216-
217 Sets the style name of the font.-
218-
219 The style name is case insensitive. If set, the font will be matched against style name instead-
220 of the font properties \l font.weight, \l font.bold and \l font.italic.-
221*/-
222-
223-
224/*!-
225 \qmlproperty bool QtQuick::TextEdit::font.bold-
226-
227 Sets whether the font weight is bold.-
228*/-
229-
230/*!-
231 \qmlproperty enumeration QtQuick::TextEdit::font.weight-
232-
233 Sets the font's weight.-
234-
235 The weight can be one of:-
236 \list-
237 \li Font.Thin-
238 \li Font.Light-
239 \li Font.ExtraLight-
240 \li Font.Normal - the default-
241 \li Font.Medium-
242 \li Font.DemiBold-
243 \li Font.Bold-
244 \li Font.ExtraBold-
245 \li Font.Black-
246 \endlist-
247-
248 \qml-
249 TextEdit { text: "Hello"; font.weight: Font.DemiBold }-
250 \endqml-
251*/-
252-
253/*!-
254 \qmlproperty bool QtQuick::TextEdit::font.italic-
255-
256 Sets whether the font has an italic style.-
257*/-
258-
259/*!-
260 \qmlproperty bool QtQuick::TextEdit::font.underline-
261-
262 Sets whether the text is underlined.-
263*/-
264-
265/*!-
266 \qmlproperty bool QtQuick::TextEdit::font.strikeout-
267-
268 Sets whether the font has a strikeout style.-
269*/-
270-
271/*!-
272 \qmlproperty real QtQuick::TextEdit::font.pointSize-
273-
274 Sets the font size in points. The point size must be greater than zero.-
275*/-
276-
277/*!-
278 \qmlproperty int QtQuick::TextEdit::font.pixelSize-
279-
280 Sets the font size in pixels.-
281-
282 Using this function makes the font device dependent. Use-
283 \l{TextEdit::font.pointSize} to set the size of the font in a-
284 device independent manner.-
285*/-
286-
287/*!-
288 \qmlproperty real QtQuick::TextEdit::font.letterSpacing-
289-
290 Sets the letter spacing for the font.-
291-
292 Letter spacing changes the default spacing between individual letters in the font.-
293 A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing.-
294*/-
295-
296/*!-
297 \qmlproperty real QtQuick::TextEdit::font.wordSpacing-
298-
299 Sets the word spacing for the font.-
300-
301 Word spacing changes the default spacing between individual words.-
302 A positive value increases the word spacing by a corresponding amount of pixels,-
303 while a negative value decreases the inter-word spacing accordingly.-
304*/-
305-
306/*!-
307 \qmlproperty enumeration QtQuick::TextEdit::font.capitalization-
308-
309 Sets the capitalization for the text.-
310-
311 \list-
312 \li Font.MixedCase - This is the normal text rendering option where no capitalization change is applied.-
313 \li Font.AllUppercase - This alters the text to be rendered in all uppercase type.-
314 \li Font.AllLowercase - This alters the text to be rendered in all lowercase type.-
315 \li Font.SmallCaps - This alters the text to be rendered in small-caps type.-
316 \li Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character.-
317 \endlist-
318-
319 \qml-
320 TextEdit { text: "Hello"; font.capitalization: Font.AllLowercase }-
321 \endqml-
322*/-
323-
324/*!-
325 \qmlproperty enumeration QtQuick::TextEdit::font.hintingPreference-
326 \since 5.8-
327-
328 Sets the preferred hinting on the text. This is a hint to the underlying text rendering system-
329 to use a certain level of hinting, and has varying support across platforms. See the table in-
330 the documentation for QFont::HintingPreference for more details.-
331-
332 \note This property only has an effect when used together with render type TextEdit.NativeRendering.-
333-
334 \list-
335 \value Font.PreferDefaultHinting - Use the default hinting level for the target platform.-
336 \value Font.PreferNoHinting - If possible, render text without hinting the outlines-
337 of the glyphs. The text layout will be typographically accurate, using the same metrics-
338 as are used e.g. when printing.-
339 \value Font.PreferVerticalHinting - If possible, render text with no horizontal hinting,-
340 but align glyphs to the pixel grid in the vertical direction. The text will appear-
341 crisper on displays where the density is too low to give an accurate rendering-
342 of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's-
343 layout will be scalable to higher density devices (such as printers) without impacting-
344 details such as line breaks.-
345 \value Font.PreferFullHinting - If possible, render text with hinting in both horizontal and-
346 vertical directions. The text will be altered to optimize legibility on the target-
347 device, but since the metrics will depend on the target size of the text, the positions-
348 of glyphs, line breaks, and other typographical detail will not scale, meaning that a-
349 text layout may look different on devices with different pixel densities.-
350 \endlist-
351-
352 \qml-
353 TextEdit { text: "Hello"; renderType: TextEdit.NativeRendering; font.hintingPreference: Font.PreferVerticalHinting }-
354 \endqml-
355*/-
356-
357/*!-
358 \qmlproperty bool QtQuick::TextEdit::font.kerning-
359 \since 5.10-
360-
361 Enables or disables the kerning OpenType feature when shaping the text. Disabling this may-
362 improve performance when creating or changing the text, at the expense of some cosmetic-
363 features. The default value is true.-
364-
365 \qml-
366 TextEdit { text: "OATS FLAVOUR WAY"; kerning: font.false }-
367 \endqml-
368*/-
369-
370/*!-
371 \qmlproperty bool QtQuick::TextEdit::font.preferShaping-
372 \since 5.10-
373-
374 Sometimes, a font will apply complex rules to a set of characters in order to-
375 display them correctly. In some writing systems, such as Brahmic scripts, this is-
376 required in order for the text to be legible, but in e.g. Latin script, it is merely-
377 a cosmetic feature. Setting the \c preferShaping property to false will disable all-
378 such features when they are not required, which will improve performance in most cases.-
379-
380 The default value is true.-
381-
382 \qml-
383 TextEdit { text: "Some text"; font.preferShaping: false }-
384 \endqml-
385*/-
386-
387/*!-
388 \qmlproperty string QtQuick::TextEdit::text-
389-
390 The text to display. If the text format is AutoText the text edit will-
391 automatically determine whether the text should be treated as-
392 rich text. This determination is made using Qt::mightBeRichText().-
393-
394 The text-property is mostly suitable for setting the initial content and-
395 handling modifications to relatively small text content. The append(),-
396 insert() and remove() methods provide more fine-grained control and-
397 remarkably better performance for modifying especially large rich text-
398 content.-
399-
400 \sa clear()-
401*/-
402void QQuickTextEdit::setText(const QString &text)-
403{-
404 Q_D(QQuickTextEdit);-
405 if (QQuickTextEdit::text() == text)
QQuickTextEdit::text() == textDescription
TRUEevaluated 16 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextdocument
  • tst_qquicktextedit
FALSEevaluated 1052 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
16-1052
406 return;
executed 16 times by 3 tests: return;
Executed by:
  • tst_examples
  • tst_qquicktextdocument
  • tst_qquicktextedit
16
407-
408 d->document->clearResources();-
409 d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text));
d->format == RichTextDescription
TRUEevaluated 42 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 1010 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
d->format == AutoTextDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 992 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
Qt::mightBeRichText(text)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
6-1010
410 if (!isComponentComplete()) {
!isComponentComplete()Description
TRUEevaluated 900 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 152 times by 2 tests
Evaluated by:
  • tst_qquicktextdocument
  • tst_qquicktextedit
152-900
411 d->text = text;-
412 } else if (d->richText) {
executed 900 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
d->richTextDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 142 times by 2 tests
Evaluated by:
  • tst_qquicktextdocument
  • tst_qquicktextedit
10-900
413#if QT_CONFIG(texthtmlparser)-
414 d->control->setHtml(text);-
415#else-
416 d->control->setPlainText(text);-
417#endif-
418 } else {
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
10
419 d->control->setPlainText(text);-
420 }
executed 142 times by 2 tests: end of block
Executed by:
  • tst_qquicktextdocument
  • tst_qquicktextedit
142
421}-
422-
423/*!-
424 \qmlproperty string QtQuick::TextEdit::preeditText-
425 \readonly-
426 \since 5.7-
427-
428 This property contains partial text input from an input method.-
429*/-
430QString QQuickTextEdit::preeditText() const-
431{-
432 Q_D(const QQuickTextEdit);-
433 return d->control->preeditText();
executed 8 times by 1 test: return d->control->preeditText();
Executed by:
  • tst_qquicktextedit
8
434}-
435-
436/*!-
437 \qmlproperty enumeration QtQuick::TextEdit::textFormat-
438-
439 The way the text property should be displayed.-
440-
441 \list-
442 \li TextEdit.AutoText-
443 \li TextEdit.PlainText-
444 \li TextEdit.RichText-
445 \endlist-
446-
447 The default is TextEdit.PlainText. If the text format is TextEdit.AutoText the text edit-
448 will automatically determine whether the text should be treated as-
449 rich text. This determination is made using Qt::mightBeRichText().-
450-
451 \table-
452 \row-
453 \li-
454 \qml-
455Column {-
456 TextEdit {-
457 font.pointSize: 24-
458 text: "<b>Hello</b> <i>World!</i>"-
459 }-
460 TextEdit {-
461 font.pointSize: 24-
462 textFormat: TextEdit.RichText-
463 text: "<b>Hello</b> <i>World!</i>"-
464 }-
465 TextEdit {-
466 font.pointSize: 24-
467 textFormat: TextEdit.PlainText-
468 text: "<b>Hello</b> <i>World!</i>"-
469 }-
470}-
471 \endqml-
472 \li \image declarative-textformat.png-
473 \endtable-
474*/-
475QQuickTextEdit::TextFormat QQuickTextEdit::textFormat() const-
476{-
477 Q_D(const QQuickTextEdit);-
478 return d->format;
executed 26 times by 1 test: return d->format;
Executed by:
  • tst_qquicktextedit
26
479}-
480-
481void QQuickTextEdit::setTextFormat(TextFormat format)-
482{-
483 Q_D(QQuickTextEdit);-
484 if (format == d->format)
format == d->formatDescription
TRUEevaluated 116 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 136 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
116-136
485 return;
executed 116 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
116
486-
487 bool wasRich = d->richText;-
488 d->richText = format == RichText || (format == AutoText && (wasRich || Qt::mightBeRichText(text())));
format == RichTextDescription
TRUEevaluated 78 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
format == AutoTextDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
wasRichDescription
TRUEnever evaluated
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquicktextedit
Qt::mightBeRichText(text())Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquicktextedit
0-78
489-
490#if QT_CONFIG(texthtmlparser)-
491 if (isComponentComplete()) {
isComponentComplete()Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 112 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
24-112
492 if (wasRich && !d->richText) {
wasRichDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquicktextedit
!d->richTextDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-22
493 d->control->setPlainText(!d->textCached ? d->control->toHtml() : d->text);-
494 updateSize();-
495 } else if (!wasRich && d->richText) {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
!wasRichDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
d->richTextDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
0-22
496 d->control->setHtml(!d->textCached ? d->control->toPlainText() : d->text);-
497 updateSize();-
498 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
14
499 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
24
500#endif-
501-
502 d->format = format;-
503 d->control->setAcceptRichText(d->format != PlainText);-
504 emit textFormatChanged(d->format);-
505}
executed 136 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
136
506-
507/*!-
508 \qmlproperty enumeration QtQuick::TextEdit::renderType-
509-
510 Override the default rendering type for this component.-
511-
512 Supported render types are:-
513 \list-
514 \li Text.QtRendering-
515 \li Text.NativeRendering-
516 \endlist-
517-
518 Select Text.NativeRendering if you prefer text to look native on the target platform and do-
519 not require advanced features such as transformation of the text. Using such features in-
520 combination with the NativeRendering render type will lend poor and sometimes pixelated-
521 results.-
522-
523 The default rendering type is determined by \l QQuickWindow::textRenderType().-
524*/-
525QQuickTextEdit::RenderType QQuickTextEdit::renderType() const-
526{-
527 Q_D(const QQuickTextEdit);-
528 return d->renderType;
executed 6 times by 1 test: return d->renderType;
Executed by:
  • tst_qquicktextedit
6
529}-
530-
531void QQuickTextEdit::setRenderType(QQuickTextEdit::RenderType renderType)-
532{-
533 Q_D(QQuickTextEdit);-
534 if (d->renderType == renderType)
d->renderType == renderTypeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-4
535 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
2
536-
537 d->renderType = renderType;-
538 emit renderTypeChanged();-
539 d->updateDefaultTextOption();-
540-
541 if (isComponentComplete())
isComponentComplete()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
542 updateSize();
executed 4 times by 1 test: updateSize();
Executed by:
  • tst_qquicktextedit
4
543}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
4
544-
545QFont QQuickTextEdit::font() const-
546{-
547 Q_D(const QQuickTextEdit);-
548 return d->sourceFont;
executed 148 times by 3 tests: return d->sourceFont;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
148
549}-
550-
551void QQuickTextEdit::setFont(const QFont &font)-
552{-
553 Q_D(QQuickTextEdit);-
554 if (d->sourceFont == font)
d->sourceFont == fontDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 76 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
28-76
555 return;
executed 28 times by 1 test: return;
Executed by:
  • tst_examples
28
556-
557 d->sourceFont = font;-
558 QFont oldFont = d->font;-
559 d->font = font;-
560 if (d->font.pointSizeF() != -1) {
d->font.pointSizeF() != -1Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 62 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
14-62
561 // 0.5pt resolution-
562 qreal size = qRound(d->font.pointSizeF()*2.0);-
563 d->font.setPointSizeF(size/2.0);-
564 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
14
565-
566 if (oldFont != d->font) {
oldFont != d->fontDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
FALSEnever evaluated
0-76
567 d->document->setDefaultFont(d->font);-
568 if (d->cursorItem) {
d->cursorItemDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 74 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
2-74
569 d->cursorItem->setHeight(QFontMetrics(d->font).height());-
570 moveCursorDelegate();-
571 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
2
572 updateSize();-
573 updateWholeDocument();-
574#if QT_CONFIG(im)-
575 updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle | Qt::ImFont);-
576#endif-
577 }
executed 76 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
76
578 emit fontChanged(d->sourceFont);-
579}
executed 76 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquicktextedit
76
580-
581/*!-
582 \qmlproperty color QtQuick::TextEdit::color-
583-
584 The text color.-
585-
586 \qml-
587 // green text using hexadecimal notation-
588 TextEdit { color: "#00FF00" }-
589 \endqml-
590-
591 \qml-
592 // steelblue text using SVG color name-
593 TextEdit { color: "steelblue" }-
594 \endqml-
595*/-
596QColor QQuickTextEdit::color() const-
597{-
598 Q_D(const QQuickTextEdit);-
599 return d->color;
executed 32 times by 1 test: return d->color;
Executed by:
  • tst_qquicktextedit
32
600}-
601-
602void QQuickTextEdit::setColor(const QColor &color)-
603{-
604 Q_D(QQuickTextEdit);-
605 if (d->color == color)
d->color == colorDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
4-32
606 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
4
607-
608 d->color = color;-
609 updateWholeDocument();-
610 emit colorChanged(d->color);-
611}
executed 32 times by 2 tests: end of block
Executed by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
32
612-
613/*!-
614 \qmlproperty color QtQuick::TextEdit::selectionColor-
615-
616 The text highlight color, used behind selections.-
617*/-
618QColor QQuickTextEdit::selectionColor() const-
619{-
620 Q_D(const QQuickTextEdit);-
621 return d->selectionColor;
executed 30 times by 1 test: return d->selectionColor;
Executed by:
  • tst_qquicktextedit
30
622}-
623-
624void QQuickTextEdit::setSelectionColor(const QColor &color)-
625{-
626 Q_D(QQuickTextEdit);-
627 if (d->selectionColor == color)
d->selectionColor == colorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-28
628 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
2
629-
630 d->selectionColor = color;-
631 updateWholeDocument();-
632 emit selectionColorChanged(d->selectionColor);-
633}
executed 28 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
28
634-
635/*!-
636 \qmlproperty color QtQuick::TextEdit::selectedTextColor-
637-
638 The selected text color, used in selections.-
639*/-
640QColor QQuickTextEdit::selectedTextColor() const-
641{-
642 Q_D(const QQuickTextEdit);-
643 return d->selectedTextColor;
executed 30 times by 1 test: return d->selectedTextColor;
Executed by:
  • tst_qquicktextedit
30
644}-
645-
646void QQuickTextEdit::setSelectedTextColor(const QColor &color)-
647{-
648 Q_D(QQuickTextEdit);-
649 if (d->selectedTextColor == color)
d->selectedTextColor == colorDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextedit
4-26
650 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
4
651-
652 d->selectedTextColor = color;-
653 updateWholeDocument();-
654 emit selectedTextColorChanged(d->selectedTextColor);-
655}
executed 26 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
26
656-
657/*!-
658 \qmlproperty enumeration QtQuick::TextEdit::horizontalAlignment-
659 \qmlproperty enumeration QtQuick::TextEdit::verticalAlignment-
660 \qmlproperty enumeration QtQuick::TextEdit::effectiveHorizontalAlignment-
661-
662 Sets the horizontal and vertical alignment of the text within the TextEdit item's-
663 width and height. By default, the text alignment follows the natural alignment-
664 of the text, for example text that is read from left to right will be aligned to-
665 the left.-
666-
667 Valid values for \c horizontalAlignment are:-
668 \list-
669 \li TextEdit.AlignLeft (default)-
670 \li TextEdit.AlignRight-
671 \li TextEdit.AlignHCenter-
672 \li TextEdit.AlignJustify-
673 \endlist-
674-
675 Valid values for \c verticalAlignment are:-
676 \list-
677 \li TextEdit.AlignTop (default)-
678 \li TextEdit.AlignBottom-
679 \li TextEdit.AlignVCenter-
680 \endlist-
681-
682 When using the attached property LayoutMirroring::enabled to mirror application-
683 layouts, the horizontal alignment of text will also be mirrored. However, the property-
684 \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment-
685 of TextEdit, use the read-only property \c effectiveHorizontalAlignment.-
686*/-
687QQuickTextEdit::HAlignment QQuickTextEdit::hAlign() const-
688{-
689 Q_D(const QQuickTextEdit);-
690 return d->hAlign;
executed 122 times by 2 tests: return d->hAlign;
Executed by:
  • tst_examples
  • tst_qquicktextedit
122
691}-
692-
693void QQuickTextEdit::setHAlign(HAlignment align)-
694{-
695 Q_D(QQuickTextEdit);-
696 bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror;
d->hAlignImplicitDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
d->effectiveLayoutMirrorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 64 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-66
697 d->hAlignImplicit = false;-
698 if (d->setHAlign(align, forceAlign) && isComponentComplete()) {
d->setHAlign(a...n, forceAlign)Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquicktextedit
isComponentComplete()Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextedit
22-52
699 d->updateDefaultTextOption();-
700 updateSize();-
701 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
24
702}
executed 74 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
74
703-
704void QQuickTextEdit::resetHAlign()-
705{-
706 Q_D(QQuickTextEdit);-
707 d->hAlignImplicit = true;-
708 if (d->determineHorizontalAlignment() && isComponentComplete()) {
d->determineHo...talAlignment()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
isComponentComplete()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-32
709 d->updateDefaultTextOption();-
710 updateSize();-
711 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
4
712}
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextedit
36
713-
714QQuickTextEdit::HAlignment QQuickTextEdit::effectiveHAlign() const-
715{-
716 Q_D(const QQuickTextEdit);-
717 QQuickTextEdit::HAlignment effectiveAlignment = d->hAlign;-
718 if (!d->hAlignImplicit && d->effectiveLayoutMirror) {
!d->hAlignImplicitDescription
TRUEevaluated 368 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 10458 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
d->effectiveLayoutMirrorDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 348 times by 1 test
Evaluated by:
  • tst_qquicktextedit
20-10458
719 switch (d->hAlign) {-
720 case QQuickTextEdit::AlignLeft:
executed 8 times by 1 test: case QQuickTextEdit::AlignLeft:
Executed by:
  • tst_qquicktextedit
8
721 effectiveAlignment = QQuickTextEdit::AlignRight;-
722 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qquicktextedit
8
723 case QQuickTextEdit::AlignRight:
executed 12 times by 1 test: case QQuickTextEdit::AlignRight:
Executed by:
  • tst_qquicktextedit
12
724 effectiveAlignment = QQuickTextEdit::AlignLeft;-
725 break;
executed 12 times by 1 test: break;
Executed by:
  • tst_qquicktextedit
12
726 default:
never executed: default:
0
727 break;
never executed: break;
0
728 }-
729 }-
730 return effectiveAlignment;
executed 10826 times by 6 tests: return effectiveAlignment;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
10826
731}-
732-
733bool QQuickTextEditPrivate::setHAlign(QQuickTextEdit::HAlignment alignment, bool forceAlign)-
734{-
735 Q_Q(QQuickTextEdit);-
736 if (hAlign != alignment || forceAlign) {
hAlign != alignmentDescription
TRUEevaluated 94 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
FALSEevaluated 4226 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
forceAlignDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 4224 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
2-4226
737 QQuickTextEdit::HAlignment oldEffectiveHAlign = q->effectiveHAlign();-
738 hAlign = alignment;-
739 emit q->horizontalAlignmentChanged(alignment);-
740 if (oldEffectiveHAlign != q->effectiveHAlign())
oldEffectiveHA...ectiveHAlign()Description
TRUEevaluated 94 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-94
741 emit q->effectiveHorizontalAlignmentChanged();
executed 94 times by 2 tests: q->effectiveHorizontalAlignmentChanged();
Executed by:
  • tst_examples
  • tst_qquicktextedit
94
742 return true;
executed 96 times by 2 tests: return true;
Executed by:
  • tst_examples
  • tst_qquicktextedit
96
743 }-
744 return false;
executed 4224 times by 6 tests: return false;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
4224
745}-
746-
747-
748Qt::LayoutDirection QQuickTextEditPrivate::textDirection(const QString &text) const-
749{-
750 const QChar *character = text.constData();-
751 while (!character->isNull()) {
!character->isNull()Description
TRUEevaluated 3978 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
FALSEevaluated 2692 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
2692-3978
752 switch (character->direction()) {-
753 case QChar::DirL:
executed 2448 times by 5 tests: case QChar::DirL:
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
2448
754 return Qt::LeftToRight;
executed 2448 times by 5 tests: return Qt::LeftToRight;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
2448
755 case QChar::DirR:
never executed: case QChar::DirR:
0
756 case QChar::DirAL:
executed 24 times by 2 tests: case QChar::DirAL:
Executed by:
  • tst_examples
  • tst_qquicktextedit
24
757 case QChar::DirAN:
never executed: case QChar::DirAN:
0
758 return Qt::RightToLeft;
executed 24 times by 2 tests: return Qt::RightToLeft;
Executed by:
  • tst_examples
  • tst_qquicktextedit
24
759 default:
executed 1506 times by 2 tests: default:
Executed by:
  • tst_examples
  • tst_qquicktextedit
1506
760 break;
executed 1506 times by 2 tests: break;
Executed by:
  • tst_examples
  • tst_qquicktextedit
1506
761 }-
762 character++;-
763 }
executed 1506 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextedit
1506
764 return Qt::LayoutDirectionAuto;
executed 2692 times by 6 tests: return Qt::LayoutDirectionAuto;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
2692
765}-
766-
767bool QQuickTextEditPrivate::determineHorizontalAlignment()-
768{-
769 Q_Q(QQuickTextEdit);-
770 if (hAlignImplicit && q->isComponentComplete()) {
hAlignImplicitDescription
TRUEevaluated 4342 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 84 times by 1 test
Evaluated by:
  • tst_qquicktextedit
q->isComponentComplete()Description
TRUEevaluated 4246 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 96 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
84-4342
771 Qt::LayoutDirection direction = contentDirection;-
772#if QT_CONFIG(im)-
773 if (direction == Qt::LayoutDirectionAuto) {
direction == Q...tDirectionAutoDescription
TRUEevaluated 1374 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 2872 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
1374-2872
774 const QString preeditText = control->textCursor().block().layout()->preeditAreaText();-
775 direction = textDirection(preeditText);-
776 }
executed 1374 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
1374
777 if (direction == Qt::LayoutDirectionAuto)
direction == Q...tDirectionAutoDescription
TRUEevaluated 1352 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 2894 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
1352-2894
778 direction = qGuiApp->inputMethod()->inputDirection();
executed 1352 times by 6 tests: direction = (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->inputDirection();
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
1352
779#endif-
780-
781 return setHAlign(direction == Qt::RightToLeft ? QQuickTextEdit::AlignRight : QQuickTextEdit::AlignLeft);
executed 4246 times by 6 tests: return setHAlign(direction == Qt::RightToLeft ? QQuickTextEdit::AlignRight : QQuickTextEdit::AlignLeft);
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
4246
782 }-
783 return false;
executed 180 times by 2 tests: return false;
Executed by:
  • tst_examples
  • tst_qquicktextedit
180
784}-
785-
786void QQuickTextEditPrivate::mirrorChange()-
787{-
788 Q_Q(QQuickTextEdit);-
789 if (q->isComponentComplete()) {
q->isComponentComplete()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
790 if (!hAlignImplicit && (hAlign == QQuickTextEdit::AlignRight || hAlign == QQuickTextEdit::AlignLeft)) {
!hAlignImplicitDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
hAlign == QQui...it::AlignRightDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
hAlign == QQui...dit::AlignLeftDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-2
791 updateDefaultTextOption();-
792 q->updateSize();-
793 emit q->effectiveHorizontalAlignmentChanged();-
794 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
2
795 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
4
796}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
4
797-
798#if QT_CONFIG(im)-
799Qt::InputMethodHints QQuickTextEditPrivate::effectiveInputMethodHints() const-
800{-
801 return inputMethodHints | Qt::ImhMultiLine;
executed 338 times by 3 tests: return inputMethodHints | Qt::ImhMultiLine;
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
338
802}-
803#endif-
804-
805void QQuickTextEditPrivate::setTopPadding(qreal value, bool reset)-
806{-
807 Q_Q(QQuickTextEdit);-
808 qreal oldPadding = q->topPadding();-
809 if (!reset || extra.isAllocated()) {
!resetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
extra.isAllocated()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
810 extra.value().topPadding = value;-
811 extra.value().explicitTopPadding = !reset;-
812 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
813 if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
!resetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
!qFuzzyCompare...adding, value)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
resetDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
!qFuzzyCompare...ng, padding())Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
814 q->updateSize();-
815 emit q->topPaddingChanged();-
816 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
817}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
818-
819void QQuickTextEditPrivate::setLeftPadding(qreal value, bool reset)-
820{-
821 Q_Q(QQuickTextEdit);-
822 qreal oldPadding = q->leftPadding();-
823 if (!reset || extra.isAllocated()) {
!resetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
extra.isAllocated()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
824 extra.value().leftPadding = value;-
825 extra.value().explicitLeftPadding = !reset;-
826 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
827 if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
!resetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
!qFuzzyCompare...adding, value)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
resetDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
!qFuzzyCompare...ng, padding())Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
828 q->updateSize();-
829 emit q->leftPaddingChanged();-
830 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
831}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
832-
833void QQuickTextEditPrivate::setRightPadding(qreal value, bool reset)-
834{-
835 Q_Q(QQuickTextEdit);-
836 qreal oldPadding = q->rightPadding();-
837 if (!reset || extra.isAllocated()) {
!resetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
extra.isAllocated()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
838 extra.value().rightPadding = value;-
839 extra.value().explicitRightPadding = !reset;-
840 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
841 if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
!resetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
!qFuzzyCompare...adding, value)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
resetDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
!qFuzzyCompare...ng, padding())Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
842 q->updateSize();-
843 emit q->rightPaddingChanged();-
844 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
845}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
846-
847void QQuickTextEditPrivate::setBottomPadding(qreal value, bool reset)-
848{-
849 Q_Q(QQuickTextEdit);-
850 qreal oldPadding = q->bottomPadding();-
851 if (!reset || extra.isAllocated()) {
!resetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
extra.isAllocated()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
852 extra.value().bottomPadding = value;-
853 extra.value().explicitBottomPadding = !reset;-
854 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
855 if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
!resetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
!qFuzzyCompare...adding, value)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
resetDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
!qFuzzyCompare...ng, padding())Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-4
856 q->updateSize();-
857 emit q->bottomPaddingChanged();-
858 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
859}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
860-
861bool QQuickTextEditPrivate::isImplicitResizeEnabled() const-
862{-
863 return !extra.isAllocated() || extra->implicitResize;
executed 5290 times by 6 tests: return !extra.isAllocated() || extra->implicitResize;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
5290
864}-
865-
866void QQuickTextEditPrivate::setImplicitResizeEnabled(bool enabled)-
867{-
868 if (!enabled)
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
869 extra.value().implicitResize = false;
never executed: extra.value().implicitResize = false;
0
870 else if (extra.isAllocated())
extra.isAllocated()Description
TRUEnever evaluated
FALSEnever evaluated
0
871 extra->implicitResize = true;
never executed: extra->implicitResize = true;
0
872}
never executed: end of block
0
873-
874QQuickTextEdit::VAlignment QQuickTextEdit::vAlign() const-
875{-
876 Q_D(const QQuickTextEdit);-
877 return d->vAlign;
executed 42 times by 1 test: return d->vAlign;
Executed by:
  • tst_qquicktextedit
42
878}-
879-
880void QQuickTextEdit::setVAlign(QQuickTextEdit::VAlignment alignment)-
881{-
882 Q_D(QQuickTextEdit);-
883 if (alignment == d->vAlign)
alignment == d->vAlignDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquicktextedit
20-42
884 return;
executed 20 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
20
885 d->vAlign = alignment;-
886 d->updateDefaultTextOption();-
887 updateSize();-
888 moveCursorDelegate();-
889 emit verticalAlignmentChanged(d->vAlign);-
890}
executed 42 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
42
891/*!-
892 \qmlproperty enumeration QtQuick::TextEdit::wrapMode-
893-
894 Set this property to wrap the text to the TextEdit item's width.-
895 The text will only wrap if an explicit width has been set.-
896-
897 \list-
898 \li TextEdit.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width.-
899 \li TextEdit.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width.-
900 \li TextEdit.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.-
901 \li TextEdit.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.-
902 \endlist-
903-
904 The default is TextEdit.NoWrap. If you set a width, consider using TextEdit.Wrap.-
905*/-
906QQuickTextEdit::WrapMode QQuickTextEdit::wrapMode() const-
907{-
908 Q_D(const QQuickTextEdit);-
909 return d->wrapMode;
executed 6 times by 1 test: return d->wrapMode;
Executed by:
  • tst_qquicktextedit
6
910}-
911-
912void QQuickTextEdit::setWrapMode(WrapMode mode)-
913{-
914 Q_D(QQuickTextEdit);-
915 if (mode == d->wrapMode)
mode == d->wrapModeDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 108 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
10-108
916 return;
executed 10 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
10
917 d->wrapMode = mode;-
918 d->updateDefaultTextOption();-
919 updateSize();-
920 emit wrapModeChanged();-
921}
executed 108 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
108
922-
923/*!-
924 \qmlproperty int QtQuick::TextEdit::lineCount-
925-
926 Returns the total number of lines in the TextEdit item.-
927*/-
928int QQuickTextEdit::lineCount() const-
929{-
930 Q_D(const QQuickTextEdit);-
931 return d->lineCount;
executed 52 times by 1 test: return d->lineCount;
Executed by:
  • tst_qquicktextedit
52
932}-
933-
934/*!-
935 \qmlproperty int QtQuick::TextEdit::length-
936-
937 Returns the total number of plain text characters in the TextEdit item.-
938-
939 As this number doesn't include any formatting markup it may not be the same as the-
940 length of the string returned by the \l text property.-
941-
942 This property can be faster than querying the length the \l text property as it doesn't-
943 require any copying or conversion of the TextEdit's internal string data.-
944*/-
945-
946int QQuickTextEdit::length() const-
947{-
948 Q_D(const QQuickTextEdit);-
949 // QTextDocument::characterCount() includes the terminating null character.-
950 return qMax(0, d->document->characterCount() - 1);
executed 160 times by 1 test: return qMax(0, d->document->characterCount() - 1);
Executed by:
  • tst_qquicktextedit
160
951}-
952-
953/*!-
954 \qmlproperty real QtQuick::TextEdit::contentWidth-
955-
956 Returns the width of the text, including the width past the width-
957 which is covered due to insufficient wrapping if \l wrapMode is set.-
958*/-
959qreal QQuickTextEdit::contentWidth() const-
960{-
961 Q_D(const QQuickTextEdit);-
962 return d->contentSize.width();
executed 24 times by 2 tests: return d->contentSize.width();
Executed by:
  • tst_examples
  • tst_qquicktextedit
24
963}-
964-
965/*!-
966 \qmlproperty real QtQuick::TextEdit::contentHeight-
967-
968 Returns the height of the text, including the height past the height-
969 that is covered if the text does not fit within the set height.-
970*/-
971qreal QQuickTextEdit::contentHeight() const-
972{-
973 Q_D(const QQuickTextEdit);-
974 return d->contentSize.height();
executed 22 times by 2 tests: return d->contentSize.height();
Executed by:
  • tst_examples
  • tst_qquicktextedit
22
975}-
976-
977/*!-
978 \qmlproperty url QtQuick::TextEdit::baseUrl-
979-
980 This property specifies a base URL which is used to resolve relative URLs-
981 within the text.-
982-
983 The default value is the url of the QML file instantiating the TextEdit item.-
984*/-
985-
986QUrl QQuickTextEdit::baseUrl() const-
987{-
988 Q_D(const QQuickTextEdit);-
989 if (d->baseUrl.isEmpty()) {
d->baseUrl.isEmpty()Description
TRUEevaluated 1060 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
18-1060
990 if (QQmlContext *context = qmlContext(this))
QQmlContext *c...lContext(this)Description
TRUEevaluated 1058 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-1058
991 const_cast<QQuickTextEditPrivate *>(d)->baseUrl = context->baseUrl();
executed 1058 times by 6 tests: const_cast<QQuickTextEditPrivate *>(d)->baseUrl = context->baseUrl();
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
1058
992 }
executed 1060 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
1060
993 return d->baseUrl;
executed 1078 times by 6 tests: return d->baseUrl;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
1078
994}-
995-
996void QQuickTextEdit::setBaseUrl(const QUrl &url)-
997{-
998 Q_D(QQuickTextEdit);-
999 if (baseUrl() != url) {
baseUrl() != urlDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-8
1000 d->baseUrl = url;-
1001-
1002 d->document->setBaseUrl(url);-
1003 emit baseUrlChanged();-
1004 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
8
1005}
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
10
1006-
1007void QQuickTextEdit::resetBaseUrl()-
1008{-
1009 if (QQmlContext *context = qmlContext(this))
QQmlContext *c...lContext(this)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-2
1010 setBaseUrl(context->baseUrl());
executed 2 times by 1 test: setBaseUrl(context->baseUrl());
Executed by:
  • tst_qquicktextedit
2
1011 else-
1012 setBaseUrl(QUrl());
never executed: setBaseUrl(QUrl());
0
1013}-
1014-
1015/*!-
1016 \qmlmethod rectangle QtQuick::TextEdit::positionToRectangle(position)-
1017-
1018 Returns the rectangle at the given \a position in the text. The x, y,-
1019 and height properties correspond to the cursor that would describe-
1020 that position.-
1021*/-
1022QRectF QQuickTextEdit::positionToRectangle(int pos) const-
1023{-
1024 Q_D(const QQuickTextEdit);-
1025 QTextCursor c(d->document);-
1026 c.setPosition(pos);-
1027 return d->control->cursorRect(c).translated(d->xoff, d->yoff);
executed 340 times by 2 tests: return d->control->cursorRect(c).translated(d->xoff, d->yoff);
Executed by:
  • tst_examples
  • tst_qquicktextedit
340
1028-
1029}-
1030-
1031/*!-
1032 \qmlmethod int QtQuick::TextEdit::positionAt(int x, int y)-
1033-
1034 Returns the text position closest to pixel position (\a x, \a y).-
1035-
1036 Position 0 is before the first character, position 1 is after the first character-
1037 but before the second, and so on until position \l {text}.length, which is after all characters.-
1038*/-
1039int QQuickTextEdit::positionAt(qreal x, qreal y) const-
1040{-
1041 Q_D(const QQuickTextEdit);-
1042 x -= d->xoff;-
1043 y -= d->yoff;-
1044-
1045 int r = d->document->documentLayout()->hitTest(QPointF(x, y), Qt::FuzzyHit);-
1046#if QT_CONFIG(im)-
1047 QTextCursor cursor = d->control->textCursor();-
1048 if (r > cursor.position()) {
r > cursor.position()Description
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextedit
14-58
1049 // The cursor position includes positions within the preedit text, but only positions in the-
1050 // same text block are offset so it is possible to get a position that is either part of the-
1051 // preedit or the next text block.-
1052 QTextLayout *layout = cursor.block().layout();-
1053 const int preeditLength = layout
layoutDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-58
1054 ? layout->preeditAreaText().length()-
1055 : 0;-
1056 if (preeditLength > 0
preeditLength > 0Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
12-46
1057 && d->document->documentLayout()->blockBoundingRect(cursor.block()).contains(x, y)) {
d->document->d...contains(x, y)Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
12-34
1058 r = r > cursor.position() + preeditLength
r > cursor.pos... preeditLengthDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquicktextedit
12-22
1059 ? r - preeditLength-
1060 : cursor.position();-
1061 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
34
1062 }
executed 58 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
58
1063#endif-
1064 return r;
executed 72 times by 1 test: return r;
Executed by:
  • tst_qquicktextedit
72
1065}-
1066-
1067/*!-
1068 \qmlmethod QtQuick::TextEdit::moveCursorSelection(int position, SelectionMode mode = TextEdit.SelectCharacters)-
1069-
1070 Moves the cursor to \a position and updates the selection according to the optional \a mode-
1071 parameter. (To only move the cursor, set the \l cursorPosition property.)-
1072-
1073 When this method is called it additionally sets either the-
1074 selectionStart or the selectionEnd (whichever was at the previous cursor position)-
1075 to the specified position. This allows you to easily extend and contract the selected-
1076 text range.-
1077-
1078 The selection mode specifies whether the selection is updated on a per character or a per word-
1079 basis. If not specified the selection mode will default to TextEdit.SelectCharacters.-
1080-
1081 \list-
1082 \li TextEdit.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at-
1083 the previous cursor position) to the specified position.-
1084 \li TextEdit.SelectWords - Sets the selectionStart and selectionEnd to include all-
1085 words between the specified position and the previous cursor position. Words partially in the-
1086 range are included.-
1087 \endlist-
1088-
1089 For example, take this sequence of calls:-
1090-
1091 \code-
1092 cursorPosition = 5-
1093 moveCursorSelection(9, TextEdit.SelectCharacters)-
1094 moveCursorSelection(7, TextEdit.SelectCharacters)-
1095 \endcode-
1096-
1097 This moves the cursor to position 5, extend the selection end from 5 to 9-
1098 and then retract the selection end from 9 to 7, leaving the text from position 5 to 7-
1099 selected (the 6th and 7th characters).-
1100-
1101 The same sequence with TextEdit.SelectWords will extend the selection start to a word boundary-
1102 before or on position 5 and extend the selection end to a word boundary on or past position 9.-
1103*/-
1104void QQuickTextEdit::moveCursorSelection(int pos)-
1105{-
1106 //Note that this is the same as setCursorPosition but with the KeepAnchor flag set-
1107 Q_D(QQuickTextEdit);-
1108 QTextCursor cursor = d->control->textCursor();-
1109 if (cursor.position() == pos)
cursor.position() == posDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
0-2
1110 return;
never executed: return;
0
1111 cursor.setPosition(pos, QTextCursor::KeepAnchor);-
1112 d->control->setTextCursor(cursor);-
1113}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
2
1114-
1115void QQuickTextEdit::moveCursorSelection(int pos, SelectionMode mode)-
1116{-
1117 Q_D(QQuickTextEdit);-
1118 QTextCursor cursor = d->control->textCursor();-
1119 if (cursor.position() == pos)
cursor.position() == posDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 236 times by 1 test
Evaluated by:
  • tst_qquicktextedit
60-236
1120 return;
executed 60 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
60
1121 if (mode == SelectCharacters) {
mode == SelectCharactersDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 196 times by 1 test
Evaluated by:
  • tst_qquicktextedit
40-196
1122 cursor.setPosition(pos, QTextCursor::KeepAnchor);-
1123 } else if (cursor.anchor() < pos || (cursor.anchor() == pos && cursor.position() < pos)) {
executed 40 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
cursor.anchor() < posDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qquicktextedit
cursor.anchor() == posDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquicktextedit
cursor.position() < posDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-100
1124 if (cursor.anchor() > cursor.position()) {
cursor.anchor(...sor.position()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 90 times by 1 test
Evaluated by:
  • tst_qquicktextedit
8-90
1125 cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);-
1126 cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);-
1127 if (cursor.position() == cursor.anchor())
cursor.positio...ursor.anchor()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-6
1128 cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor);
executed 2 times by 1 test: cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor);
Executed by:
  • tst_qquicktextedit
2
1129 else-
1130 cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor);
executed 6 times by 1 test: cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor);
Executed by:
  • tst_qquicktextedit
6
1131 } else {-
1132 cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);-
1133 cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);-
1134 }
executed 90 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
90
1135-
1136 cursor.setPosition(pos, QTextCursor::KeepAnchor);-
1137 cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);-
1138 if (cursor.position() != pos)
cursor.position() != posDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquicktextedit
42-56
1139 cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
executed 56 times by 1 test: cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
Executed by:
  • tst_qquicktextedit
56
1140 } else if (cursor.anchor() > pos || (cursor.anchor() == pos && cursor.position() > pos)) {
executed 98 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
cursor.anchor() > posDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
cursor.anchor() == posDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
cursor.position() > posDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-98
1141 if (cursor.anchor() < cursor.position()) {
cursor.anchor(...sor.position()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 90 times by 1 test
Evaluated by:
  • tst_qquicktextedit
8-90
1142 cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);-
1143 cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::MoveAnchor);-
1144 } else {
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
8
1145 cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);-
1146 cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);-
1147 cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);-
1148 if (cursor.position() != cursor.anchor()) {
cursor.positio...ursor.anchor()Description
TRUEevaluated 54 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_qquicktextedit
36-54
1149 cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor);-
1150 cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::MoveAnchor);-
1151 }
executed 54 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
54
1152 }
executed 90 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
90
1153-
1154 cursor.setPosition(pos, QTextCursor::KeepAnchor);-
1155 cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);-
1156 if (cursor.position() != pos) {
cursor.position() != posDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquicktextedit
40-58
1157 cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);-
1158 cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);-
1159 }
executed 58 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
58
1160 }
executed 98 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
98
1161 d->control->setTextCursor(cursor);-
1162}
executed 236 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
236
1163-
1164/*!-
1165 \qmlproperty bool QtQuick::TextEdit::cursorVisible-
1166 If true the text edit shows a cursor.-
1167-
1168 This property is set and unset when the text edit gets active focus, but it can also-
1169 be set directly (useful, for example, if a KeyProxy might forward keys to it).-
1170*/-
1171bool QQuickTextEdit::isCursorVisible() const-
1172{-
1173 Q_D(const QQuickTextEdit);-
1174 return d->cursorVisible;
executed 108 times by 1 test: return d->cursorVisible;
Executed by:
  • tst_qquicktextedit
108
1175}-
1176-
1177void QQuickTextEdit::setCursorVisible(bool on)-
1178{-
1179 Q_D(QQuickTextEdit);-
1180 if (d->cursorVisible == on)
d->cursorVisible == onDescription
TRUEevaluated 342 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 482 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
342-482
1181 return;
executed 342 times by 2 tests: return;
Executed by:
  • tst_qquickitem2
  • tst_qquicktextedit
342
1182 d->cursorVisible = on;-
1183 if (on && isComponentComplete())
onDescription
TRUEevaluated 370 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 112 times by 3 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
isComponentComplete()Description
TRUEevaluated 338 times by 3 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
32-370
1184 QQuickTextUtil::createCursor(d);
executed 338 times by 3 tests: QQuickTextUtil::createCursor(d);
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
338
1185 if (!on && !d->persistentSelection)
!onDescription
TRUEevaluated 112 times by 3 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 370 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
!d->persistentSelectionDescription
TRUEevaluated 110 times by 3 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-370
1186 d->control->setCursorIsFocusIndicator(true);
executed 110 times by 3 tests: d->control->setCursorIsFocusIndicator(true);
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
110
1187 d->control->setCursorVisible(on);-
1188 emit cursorVisibleChanged(d->cursorVisible);-
1189}
executed 482 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
482
1190-
1191/*!-
1192 \qmlproperty int QtQuick::TextEdit::cursorPosition-
1193 The position of the cursor in the TextEdit.-
1194*/-
1195int QQuickTextEdit::cursorPosition() const-
1196{-
1197 Q_D(const QQuickTextEdit);-
1198 return d->control->textCursor().position();
executed 326 times by 1 test: return d->control->textCursor().position();
Executed by:
  • tst_qquicktextedit
326
1199}-
1200-
1201void QQuickTextEdit::setCursorPosition(int pos)-
1202{-
1203 Q_D(QQuickTextEdit);-
1204 if (pos < 0 || pos >= d->document->characterCount()) // characterCount includes the terminating null.
pos < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 670 times by 1 test
Evaluated by:
  • tst_qquicktextedit
pos >= d->docu...aracterCount()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 664 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-670
1205 return;
executed 8 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
8
1206 QTextCursor cursor = d->control->textCursor();-
1207 if (cursor.position() == pos && cursor.anchor() == pos)
cursor.position() == posDescription
TRUEevaluated 144 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 520 times by 1 test
Evaluated by:
  • tst_qquicktextedit
cursor.anchor() == posDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquicktextedit
56-520
1208 return;
executed 88 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
88
1209 cursor.setPosition(pos);-
1210 d->control->setTextCursor(cursor);-
1211 d->control->updateCursorRectangle(true);-
1212}
executed 576 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
576
1213-
1214/*!-
1215 \qmlproperty Component QtQuick::TextEdit::cursorDelegate-
1216 The delegate for the cursor in the TextEdit.-
1217-
1218 If you set a cursorDelegate for a TextEdit, this delegate will be used for-
1219 drawing the cursor instead of the standard cursor. An instance of the-
1220 delegate will be created and managed by the text edit when a cursor is-
1221 needed, and the x and y properties of delegate instance will be set so as-
1222 to be one pixel before the top left of the current character.-
1223-
1224 Note that the root item of the delegate component must be a QQuickItem or-
1225 QQuickItem derived item.-
1226*/-
1227QQmlComponent* QQuickTextEdit::cursorDelegate() const-
1228{-
1229 Q_D(const QQuickTextEdit);-
1230 return d->cursorComponent;
never executed: return d->cursorComponent;
0
1231}-
1232-
1233void QQuickTextEdit::setCursorDelegate(QQmlComponent* c)-
1234{-
1235 Q_D(QQuickTextEdit);-
1236 QQuickTextUtil::setCursorDelegate(d, c);-
1237}
executed 36 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
36
1238-
1239void QQuickTextEdit::createCursor()-
1240{-
1241 Q_D(QQuickTextEdit);-
1242 d->cursorPending = true;-
1243 QQuickTextUtil::createCursor(d);-
1244}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
2
1245-
1246/*!-
1247 \qmlproperty int QtQuick::TextEdit::selectionStart-
1248-
1249 The cursor position before the first character in the current selection.-
1250-
1251 This property is read-only. To change the selection, use select(start,end),-
1252 selectAll(), or selectWord().-
1253-
1254 \sa selectionEnd, cursorPosition, selectedText-
1255*/-
1256int QQuickTextEdit::selectionStart() const-
1257{-
1258 Q_D(const QQuickTextEdit);-
1259 return d->control->textCursor().selectionStart();
executed 1062 times by 4 tests: return d->control->textCursor().selectionStart();
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
1062
1260}-
1261-
1262/*!-
1263 \qmlproperty int QtQuick::TextEdit::selectionEnd-
1264-
1265 The cursor position after the last character in the current selection.-
1266-
1267 This property is read-only. To change the selection, use select(start,end),-
1268 selectAll(), or selectWord().-
1269-
1270 \sa selectionStart, cursorPosition, selectedText-
1271*/-
1272int QQuickTextEdit::selectionEnd() const-
1273{-
1274 Q_D(const QQuickTextEdit);-
1275 return d->control->textCursor().selectionEnd();
executed 1062 times by 4 tests: return d->control->textCursor().selectionEnd();
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
1062
1276}-
1277-
1278/*!-
1279 \qmlproperty string QtQuick::TextEdit::selectedText-
1280-
1281 This read-only property provides the text currently selected in the-
1282 text edit.-
1283-
1284 It is equivalent to the following snippet, but is faster and easier-
1285 to use.-
1286 \code-
1287 //myTextEdit is the id of the TextEdit-
1288 myTextEdit.text.toString().substring(myTextEdit.selectionStart,-
1289 myTextEdit.selectionEnd);-
1290 \endcode-
1291*/-
1292QString QQuickTextEdit::selectedText() const-
1293{-
1294 Q_D(const QQuickTextEdit);-
1295#if QT_CONFIG(texthtmlparser)-
1296 return d->richText
executed 1516 times by 1 test: return d->richText ? d->control->textCursor().selectedText() : d->control->textCursor().selection().toPlainText();
Executed by:
  • tst_qquicktextedit
1516
1297 ? d->control->textCursor().selectedText()
executed 1516 times by 1 test: return d->richText ? d->control->textCursor().selectedText() : d->control->textCursor().selection().toPlainText();
Executed by:
  • tst_qquicktextedit
1516
1298 : d->control->textCursor().selection().toPlainText();
executed 1516 times by 1 test: return d->richText ? d->control->textCursor().selectedText() : d->control->textCursor().selection().toPlainText();
Executed by:
  • tst_qquicktextedit
1516
1299#else-
1300 return d->control->textCursor().selection().toPlainText();-
1301#endif-
1302}-
1303-
1304/*!-
1305 \qmlproperty bool QtQuick::TextEdit::activeFocusOnPress-
1306-
1307 Whether the TextEdit should gain active focus on a mouse press. By default this is-
1308 set to true.-
1309*/-
1310bool QQuickTextEdit::focusOnPress() const-
1311{-
1312 Q_D(const QQuickTextEdit);-
1313 return d->focusOnPress;
executed 10 times by 1 test: return d->focusOnPress;
Executed by:
  • tst_qquicktextedit
10
1314}-
1315-
1316void QQuickTextEdit::setFocusOnPress(bool on)-
1317{-
1318 Q_D(QQuickTextEdit);-
1319 if (d->focusOnPress == on)
d->focusOnPress == onDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextedit
10-96
1320 return;
executed 96 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
96
1321 d->focusOnPress = on;-
1322 emit activeFocusOnPressChanged(d->focusOnPress);-
1323}
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
10
1324-
1325/*!-
1326 \qmlproperty bool QtQuick::TextEdit::persistentSelection-
1327-
1328 Whether the TextEdit should keep the selection visible when it loses active focus to another-
1329 item in the scene. By default this is set to false.-
1330*/-
1331bool QQuickTextEdit::persistentSelection() const-
1332{-
1333 Q_D(const QQuickTextEdit);-
1334 return d->persistentSelection;
executed 6 times by 1 test: return d->persistentSelection;
Executed by:
  • tst_qquicktextedit
6
1335}-
1336-
1337void QQuickTextEdit::setPersistentSelection(bool on)-
1338{-
1339 Q_D(QQuickTextEdit);-
1340 if (d->persistentSelection == on)
d->persistentSelection == onDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2
1341 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
2
1342 d->persistentSelection = on;-
1343 emit persistentSelectionChanged(d->persistentSelection);-
1344}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
2
1345-
1346/*!-
1347 \qmlproperty real QtQuick::TextEdit::textMargin-
1348-
1349 The margin, in pixels, around the text in the TextEdit.-
1350*/-
1351qreal QQuickTextEdit::textMargin() const-
1352{-
1353 Q_D(const QQuickTextEdit);-
1354 return d->textMargin;
executed 70 times by 1 test: return d->textMargin;
Executed by:
  • tst_qquicktextedit
70
1355}-
1356-
1357void QQuickTextEdit::setTextMargin(qreal margin)-
1358{-
1359 Q_D(QQuickTextEdit);-
1360 if (d->textMargin == margin)
d->textMargin == marginDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-68
1361 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
2
1362 d->textMargin = margin;-
1363 d->document->setDocumentMargin(d->textMargin);-
1364 emit textMarginChanged(d->textMargin);-
1365}
executed 68 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
68
1366-
1367/*!-
1368 \qmlproperty enumeration QtQuick::TextEdit::inputMethodHints-
1369-
1370 Provides hints to the input method about the expected content of the text edit and how it-
1371 should operate.-
1372-
1373 The value is a bit-wise combination of flags or Qt.ImhNone if no hints are set.-
1374-
1375 Flags that alter behaviour are:-
1376-
1377 \list-
1378 \li Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords.-
1379 \li Qt.ImhSensitiveData - Typed text should not be stored by the active input method-
1380 in any persistent storage like predictive user dictionary.-
1381 \li Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case-
1382 when a sentence ends.-
1383 \li Qt.ImhPreferNumbers - Numbers are preferred (but not required).-
1384 \li Qt.ImhPreferUppercase - Upper case letters are preferred (but not required).-
1385 \li Qt.ImhPreferLowercase - Lower case letters are preferred (but not required).-
1386 \li Qt.ImhNoPredictiveText - Do not use predictive text (i.e. dictionary lookup) while typing.-
1387-
1388 \li Qt.ImhDate - The text editor functions as a date field.-
1389 \li Qt.ImhTime - The text editor functions as a time field.-
1390 \endlist-
1391-
1392 Flags that restrict input (exclusive flags) are:-
1393-
1394 \list-
1395 \li Qt.ImhDigitsOnly - Only digits are allowed.-
1396 \li Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign.-
1397 \li Qt.ImhUppercaseOnly - Only upper case letter input is allowed.-
1398 \li Qt.ImhLowercaseOnly - Only lower case letter input is allowed.-
1399 \li Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed.-
1400 \li Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed.-
1401 \li Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed.-
1402 \endlist-
1403-
1404 Masks:-
1405-
1406 \list-
1407 \li Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used.-
1408 \endlist-
1409*/-
1410-
1411Qt::InputMethodHints QQuickTextEdit::inputMethodHints() const-
1412{-
1413#if !QT_CONFIG(im)-
1414 return Qt::ImhNone;-
1415#else-
1416 Q_D(const QQuickTextEdit);-
1417 return d->inputMethodHints;
executed 6 times by 1 test: return d->inputMethodHints;
Executed by:
  • tst_qquicktextedit
6
1418#endif // im-
1419}-
1420-
1421void QQuickTextEdit::setInputMethodHints(Qt::InputMethodHints hints)-
1422{-
1423#if !QT_CONFIG(im)-
1424 Q_UNUSED(hints);-
1425#else-
1426 Q_D(QQuickTextEdit);-
1427-
1428 if (hints == d->inputMethodHints)
hints == d->inputMethodHintsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-4
1429 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
2
1430-
1431 d->inputMethodHints = hints;-
1432 updateInputMethod(Qt::ImHints);-
1433 emit inputMethodHintsChanged();-
1434#endif // im-
1435}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
4
1436-
1437void QQuickTextEdit::geometryChanged(const QRectF &newGeometry,-
1438 const QRectF &oldGeometry)-
1439{-
1440 Q_D(QQuickTextEdit);-
1441 if (!d->inLayout && ((newGeometry.width() != oldGeometry.width() && widthValid())
!d->inLayoutDescription
TRUEevaluated 4150 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextedit
newGeometry.wi...ometry.width()Description
TRUEevaluated 3892 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 258 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
widthValid()Description
TRUEevaluated 170 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 3722 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
14-4150
1442 || (newGeometry.height() != oldGeometry.height() && heightValid()))) {
newGeometry.he...metry.height()Description
TRUEevaluated 1452 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 2528 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
heightValid()Description
TRUEevaluated 78 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 1374 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
78-2528
1443 updateSize();-
1444 updateWholeDocument();-
1445 moveCursorDelegate();-
1446 }
executed 248 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
248
1447 QQuickImplicitSizeItem::geometryChanged(newGeometry, oldGeometry);-
1448-
1449}
executed 4164 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
4164
1450-
1451/*!-
1452 Ensures any delayed caching or data loading the class-
1453 needs to performed is complete.-
1454*/-
1455void QQuickTextEdit::componentComplete()-
1456{-
1457 Q_D(QQuickTextEdit);-
1458 QQuickImplicitSizeItem::componentComplete();-
1459-
1460 d->document->setBaseUrl(baseUrl());-
1461#if QT_CONFIG(texthtmlparser)-
1462 if (d->richText)
d->richTextDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 984 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
76-984
1463 d->control->setHtml(d->text);
executed 76 times by 3 tests: d->control->setHtml(d->text);
Executed by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
76
1464 else-
1465#endif-
1466 if (!d->text.isEmpty())
!d->text.isEmpty()Description
TRUEevaluated 824 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 160 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
160-824
1467 d->control->setPlainText(d->text);
executed 824 times by 4 tests: d->control->setPlainText(d->text);
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
824
1468-
1469 if (d->dirty) {
d->dirtyDescription
TRUEevaluated 246 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 814 times by 3 tests
Evaluated by:
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
246-814
1470 d->determineHorizontalAlignment();-
1471 d->updateDefaultTextOption();-
1472 updateSize();-
1473 d->dirty = false;-
1474 }
executed 246 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
246
1475 if (d->cursorComponent && isCursorVisible())
d->cursorComponentDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 1038 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
isCursorVisible()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
4-1038
1476 QQuickTextUtil::createCursor(d);
executed 4 times by 1 test: QQuickTextUtil::createCursor(d);
Executed by:
  • tst_qquicktextedit
4
1477}
executed 1060 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
1060
1478-
1479/*!-
1480 \qmlproperty bool QtQuick::TextEdit::selectByKeyboard-
1481 \since 5.1-
1482-
1483 Defaults to true when the editor is editable, and false-
1484 when read-only.-
1485-
1486 If true, the user can use the keyboard to select text-
1487 even if the editor is read-only. If false, the user-
1488 cannot use the keyboard to select text even if the-
1489 editor is editable.-
1490-
1491 \sa readOnly-
1492*/-
1493bool QQuickTextEdit::selectByKeyboard() const-
1494{-
1495 Q_D(const QQuickTextEdit);-
1496 if (d->selectByKeyboardSet)
d->selectByKeyboardSetDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquicktextedit
8-38
1497 return d->selectByKeyboard;
executed 8 times by 1 test: return d->selectByKeyboard;
Executed by:
  • tst_qquicktextedit
8
1498 return !isReadOnly();
executed 38 times by 1 test: return !isReadOnly();
Executed by:
  • tst_qquicktextedit
38
1499}-
1500-
1501void QQuickTextEdit::setSelectByKeyboard(bool on)-
1502{-
1503 Q_D(QQuickTextEdit);-
1504 bool was = selectByKeyboard();-
1505 if (!d->selectByKeyboardSet || was != on) {
!d->selectByKeyboardSetDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
was != onDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
0-34
1506 d->selectByKeyboardSet = true;-
1507 d->selectByKeyboard = on;-
1508 if (on)
onDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
18
1509 d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByKeyboard);
executed 18 times by 1 test: d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByKeyboard);
Executed by:
  • tst_qquicktextedit
18
1510 else-
1511 d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByKeyboard);
executed 18 times by 1 test: d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByKeyboard);
Executed by:
  • tst_qquicktextedit
18
1512 emit selectByKeyboardChanged(on);-
1513 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
36
1514}
executed 36 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
36
1515-
1516/*!-
1517 \qmlproperty bool QtQuick::TextEdit::selectByMouse-
1518-
1519 Defaults to false.-
1520-
1521 If true, the user can use the mouse to select text in some-
1522 platform-specific way. Note that for some platforms this may-
1523 not be an appropriate interaction; it may conflict with how-
1524 the text needs to behave inside a Flickable, for example.-
1525*/-
1526bool QQuickTextEdit::selectByMouse() const-
1527{-
1528 Q_D(const QQuickTextEdit);-
1529 return d->selectByMouse;
executed 6 times by 1 test: return d->selectByMouse;
Executed by:
  • tst_qquicktextedit
6
1530}-
1531-
1532void QQuickTextEdit::setSelectByMouse(bool on)-
1533{-
1534 Q_D(QQuickTextEdit);-
1535 if (d->selectByMouse != on) {
d->selectByMouse != onDescription
TRUEevaluated 114 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
8-114
1536 d->selectByMouse = on;-
1537 setKeepMouseGrab(on);-
1538 if (on)
onDescription
TRUEevaluated 112 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextedit
2-112
1539 d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByMouse);
executed 112 times by 2 tests: d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByMouse);
Executed by:
  • tst_examples
  • tst_qquicktextedit
112
1540 else-
1541 d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByMouse);
executed 2 times by 1 test: d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByMouse);
Executed by:
  • tst_qquicktextedit
2
1542 emit selectByMouseChanged(on);-
1543 }
executed 114 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextedit
114
1544}
executed 122 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextedit
122
1545-
1546/*!-
1547 \qmlproperty enumeration QtQuick::TextEdit::mouseSelectionMode-
1548-
1549 Specifies how text should be selected using a mouse.-
1550-
1551 \list-
1552 \li TextEdit.SelectCharacters - The selection is updated with individual characters. (Default)-
1553 \li TextEdit.SelectWords - The selection is updated with whole words.-
1554 \endlist-
1555-
1556 This property only applies when \l selectByMouse is true.-
1557*/-
1558QQuickTextEdit::SelectionMode QQuickTextEdit::mouseSelectionMode() const-
1559{-
1560 Q_D(const QQuickTextEdit);-
1561 return d->mouseSelectionMode;
executed 6 times by 1 test: return d->mouseSelectionMode;
Executed by:
  • tst_qquicktextedit
6
1562}-
1563-
1564void QQuickTextEdit::setMouseSelectionMode(SelectionMode mode)-
1565{-
1566 Q_D(QQuickTextEdit);-
1567 if (d->mouseSelectionMode != mode) {
d->mouseSelectionMode != modeDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
4-30
1568 d->mouseSelectionMode = mode;-
1569 d->control->setWordSelectionEnabled(mode == SelectWords);-
1570 emit mouseSelectionModeChanged(mode);-
1571 }
executed 30 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
30
1572}
executed 34 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
34
1573-
1574/*!-
1575 \qmlproperty bool QtQuick::TextEdit::readOnly-
1576-
1577 Whether the user can interact with the TextEdit item. If this-
1578 property is set to true the text cannot be edited by user interaction.-
1579-
1580 By default this property is false.-
1581*/-
1582void QQuickTextEdit::setReadOnly(bool r)-
1583{-
1584 Q_D(QQuickTextEdit);-
1585 if (r == isReadOnly())
r == isReadOnly()Description
TRUEevaluated 36 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 62 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
36-62
1586 return;
executed 36 times by 3 tests: return;
Executed by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextedit
36
1587-
1588#if QT_CONFIG(im)-
1589 setFlag(QQuickItem::ItemAcceptsInputMethod, !r);-
1590#endif-
1591 Qt::TextInteractionFlags flags = Qt::LinksAccessibleByMouse;-
1592 if (d->selectByMouse)
d->selectByMouseDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 50 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
12-50
1593 flags = flags | Qt::TextSelectableByMouse;
executed 12 times by 1 test: flags = flags | Qt::TextSelectableByMouse;
Executed by:
  • tst_qquicktextedit
12
1594 if (d->selectByKeyboardSet && d->selectByKeyboard)
d->selectByKeyboardSetDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 44 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
d->selectByKeyboardDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
8-44
1595 flags = flags | Qt::TextSelectableByKeyboard;
executed 10 times by 1 test: flags = flags | Qt::TextSelectableByKeyboard;
Executed by:
  • tst_qquicktextedit
10
1596 else if (!d->selectByKeyboardSet && !r)
!d->selectByKeyboardSetDescription
TRUEevaluated 44 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
!rDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 28 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
8-44
1597 flags = flags | Qt::TextSelectableByKeyboard;
executed 16 times by 1 test: flags = flags | Qt::TextSelectableByKeyboard;
Executed by:
  • tst_qquicktextedit
16
1598 if (!r)
!rDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 44 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
18-44
1599 flags = flags | Qt::TextEditable;
executed 18 times by 1 test: flags = flags | Qt::TextEditable;
Executed by:
  • tst_qquicktextedit
18
1600 d->control->setTextInteractionFlags(flags);-
1601 d->control->moveCursor(QTextCursor::End);-
1602-
1603#if QT_CONFIG(im)-
1604 updateInputMethod(Qt::ImEnabled);-
1605#endif-
1606 q_canPasteChanged();-
1607 emit readOnlyChanged(r);-
1608 if (!d->selectByKeyboardSet)
!d->selectByKeyboardSetDescription
TRUEevaluated 44 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
18-44
1609 emit selectByKeyboardChanged(!r);
executed 44 times by 2 tests: selectByKeyboardChanged(!r);
Executed by:
  • tst_qquickitem2
  • tst_qquicktextedit
44
1610 if (r) {
rDescription
TRUEevaluated 44 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
18-44
1611 setCursorVisible(false);-
1612 } else if (hasActiveFocus()) {
executed 44 times by 2 tests: end of block
Executed by:
  • tst_qquickitem2
  • tst_qquicktextedit
hasActiveFocus()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextedit
6-44
1613 setCursorVisible(true);-
1614 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
12
1615}
executed 62 times by 2 tests: end of block
Executed by:
  • tst_qquickitem2
  • tst_qquicktextedit
62
1616-
1617bool QQuickTextEdit::isReadOnly() const-
1618{-
1619 Q_D(const QQuickTextEdit);-
1620 return !(d->control->textInteractionFlags() & Qt::TextEditable);
executed 1732 times by 4 tests: return !(d->control->textInteractionFlags() & Qt::TextEditable);
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
1732
1621}-
1622-
1623/*!-
1624 \qmlproperty rectangle QtQuick::TextEdit::cursorRectangle-
1625-
1626 The rectangle where the standard text cursor is rendered-
1627 within the text edit. Read-only.-
1628-
1629 The position and height of a custom cursorDelegate are updated to follow the cursorRectangle-
1630 automatically when it changes. The width of the delegate is unaffected by changes in the-
1631 cursor rectangle.-
1632*/-
1633QRectF QQuickTextEdit::cursorRectangle() const-
1634{-
1635 Q_D(const QQuickTextEdit);-
1636 return d->control->cursorRect().translated(d->xoff, d->yoff);
executed 2190 times by 2 tests: return d->control->cursorRect().translated(d->xoff, d->yoff);
Executed by:
  • tst_examples
  • tst_qquicktextedit
2190
1637}-
1638-
1639bool QQuickTextEdit::event(QEvent *event)-
1640{-
1641 Q_D(QQuickTextEdit);-
1642 if (event->type() == QEvent::ShortcutOverride) {
event->type() ...ortcutOverrideDescription
TRUEevaluated 660 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
FALSEevaluated 7114 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
660-7114
1643 d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));-
1644 return event->isAccepted();
executed 660 times by 2 tests: return event->isAccepted();
Executed by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
660
1645 }-
1646 return QQuickImplicitSizeItem::event(event);
executed 7114 times by 6 tests: return QQuickImplicitSizeItem::event(event);
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextdocument
  • tst_qquicktextedit
  • tst_qquicktextinput
7114
1647}-
1648-
1649/*!-
1650 \qmlproperty bool QtQuick::TextEdit::overwriteMode-
1651 \since 5.8-
1652 Whether text entered by the user will overwrite existing text.-
1653-
1654 As with many text editors, the text editor widget can be configured-
1655 to insert or overwrite existing text with new text entered by the user.-
1656-
1657 If this property is \c true, existing text is overwritten, character-for-character-
1658 by new text; otherwise, text is inserted at the cursor position, displacing-
1659 existing text.-
1660-
1661 By default, this property is \c false (new text does not overwrite existing text).-
1662*/-
1663bool QQuickTextEdit::overwriteMode() const-
1664{-
1665 Q_D(const QQuickTextEdit);-
1666 return d->control->overwriteMode();
executed 6 times by 1 test: return d->control->overwriteMode();
Executed by:
  • tst_qquicktextedit
6
1667}-
1668-
1669void QQuickTextEdit::setOverwriteMode(bool overwrite)-
1670{-
1671 Q_D(QQuickTextEdit);-
1672 d->control->setOverwriteMode(overwrite);-
1673}
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
10
1674-
1675/*!-
1676\overload-
1677Handles the given key \a event.-
1678*/-
1679void QQuickTextEdit::keyPressEvent(QKeyEvent *event)-
1680{-
1681 Q_D(QQuickTextEdit);-
1682 d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));-
1683 if (!event->isAccepted())
!event->isAccepted()Description
TRUEevaluated 222 times by 3 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 806 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
222-806
1684 QQuickImplicitSizeItem::keyPressEvent(event);
executed 222 times by 3 tests: QQuickImplicitSizeItem::keyPressEvent(event);
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
222
1685}
executed 1028 times by 3 tests: end of block
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
1028
1686-
1687/*!-
1688\overload-
1689Handles the given key \a event.-
1690*/-
1691void QQuickTextEdit::keyReleaseEvent(QKeyEvent *event)-
1692{-
1693 Q_D(QQuickTextEdit);-
1694 d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));-
1695 if (!event->isAccepted())
!event->isAccepted()Description
TRUEnever evaluated
FALSEevaluated 1012 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
0-1012
1696 QQuickImplicitSizeItem::keyReleaseEvent(event);
never executed: QQuickImplicitSizeItem::keyReleaseEvent(event);
0
1697}
executed 1012 times by 2 tests: end of block
Executed by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
1012
1698-
1699/*!-
1700 \qmlmethod QtQuick::TextEdit::deselect()-
1701-
1702 Removes active text selection.-
1703*/-
1704void QQuickTextEdit::deselect()-
1705{-
1706 Q_D(QQuickTextEdit);-
1707 QTextCursor c = d->control->textCursor();-
1708 c.clearSelection();-
1709 d->control->setTextCursor(c);-
1710}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
4
1711-
1712/*!-
1713 \qmlmethod QtQuick::TextEdit::selectAll()-
1714-
1715 Causes all text to be selected.-
1716*/-
1717void QQuickTextEdit::selectAll()-
1718{-
1719 Q_D(QQuickTextEdit);-
1720 d->control->selectAll();-
1721}
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
14
1722-
1723/*!-
1724 \qmlmethod QtQuick::TextEdit::selectWord()-
1725-
1726 Causes the word closest to the current cursor position to be selected.-
1727*/-
1728void QQuickTextEdit::selectWord()-
1729{-
1730 Q_D(QQuickTextEdit);-
1731 QTextCursor c = d->control->textCursor();-
1732 c.select(QTextCursor::WordUnderCursor);-
1733 d->control->setTextCursor(c);-
1734}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
4
1735-
1736/*!-
1737 \qmlmethod QtQuick::TextEdit::select(int start, int end)-
1738-
1739 Causes the text from \a start to \a end to be selected.-
1740-
1741 If either start or end is out of range, the selection is not changed.-
1742-
1743 After calling this, selectionStart will become the lesser-
1744 and selectionEnd will become the greater (regardless of the order passed-
1745 to this method).-
1746-
1747 \sa selectionStart, selectionEnd-
1748*/-
1749void QQuickTextEdit::select(int start, int end)-
1750{-
1751 Q_D(QQuickTextEdit);-
1752 if (start < 0 || end < 0 || start >= d->document->characterCount() || end >= d->document->characterCount())
start < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 360 times by 1 test
Evaluated by:
  • tst_qquicktextedit
end < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 356 times by 1 test
Evaluated by:
  • tst_qquicktextedit
start >= d->do...aracterCount()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 352 times by 1 test
Evaluated by:
  • tst_qquicktextedit
end >= d->docu...aracterCount()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 348 times by 1 test
Evaluated by:
  • tst_qquicktextedit
4-360
1753 return;
executed 16 times by 1 test: return;
Executed by:
  • tst_qquicktextedit
16
1754 QTextCursor cursor = d->control->textCursor();-
1755 cursor.beginEditBlock();-
1756 cursor.setPosition(start, QTextCursor::MoveAnchor);-
1757 cursor.setPosition(end, QTextCursor::KeepAnchor);-
1758 cursor.endEditBlock();-
1759 d->control->setTextCursor(cursor);-
1760-
1761 // QTBUG-11100-
1762 updateSelection();-
1763#if QT_CONFIG(im)-
1764 updateInputMethod();-
1765#endif-
1766}
executed 348 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
348
1767-
1768/*!-
1769 \qmlmethod QtQuick::TextEdit::isRightToLeft(int start, int end)-
1770-
1771 Returns true if the natural reading direction of the editor text-
1772 found between positions \a start and \a end is right to left.-
1773*/-
1774bool QQuickTextEdit::isRightToLeft(int start, int end)-
1775{-
1776 if (start > end) {
start > endDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 164 times by 1 test
Evaluated by:
  • tst_qquicktextedit
4-164
1777 qmlWarning(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";-
1778 return false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_qquicktextedit
4
1779 } else {-
1780 return getText(start, end).isRightToLeft();
executed 164 times by 1 test: return getText(start, end).isRightToLeft();
Executed by:
  • tst_qquicktextedit
164
1781 }-
1782}-
1783-
1784#if QT_CONFIG(clipboard)-
1785/*!-
1786 \qmlmethod QtQuick::TextEdit::cut()-
1787-
1788 Moves the currently selected text to the system clipboard.-
1789*/-
1790void QQuickTextEdit::cut()-
1791{-
1792 Q_D(QQuickTextEdit);-
1793 d->control->cut();-
1794}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
1795-
1796/*!-
1797 \qmlmethod QtQuick::TextEdit::copy()-
1798-
1799 Copies the currently selected text to the system clipboard.-
1800*/-
1801void QQuickTextEdit::copy()-
1802{-
1803 Q_D(QQuickTextEdit);-
1804 d->control->copy();-
1805}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
6
1806-
1807/*!-
1808 \qmlmethod QtQuick::TextEdit::paste()-
1809-
1810 Replaces the currently selected text by the contents of the system clipboard.-
1811*/-
1812void QQuickTextEdit::paste()-
1813{-
1814 Q_D(QQuickTextEdit);-
1815 d->control->paste();-
1816}
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
10
1817#endif // clipboard-
1818-
1819-
1820/*!-
1821 \qmlmethod QtQuick::TextEdit::undo()-
1822-
1823 Undoes the last operation if undo is \l {canUndo}{available}. Deselects any-
1824 current selection, and updates the selection start to the current cursor-
1825 position.-
1826*/-
1827-
1828void QQuickTextEdit::undo()-
1829{-
1830 Q_D(QQuickTextEdit);-
1831 d->control->undo();-
1832}
executed 108 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
108
1833-
1834/*!-
1835 \qmlmethod QtQuick::TextEdit::redo()-
1836-
1837 Redoes the last operation if redo is \l {canRedo}{available}.-
1838*/-
1839-
1840void QQuickTextEdit::redo()-
1841{-
1842 Q_D(QQuickTextEdit);-
1843 d->control->redo();-
1844}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
8
1845-
1846/*!-
1847\overload-
1848Handles the given mouse \a event.-
1849*/-
1850void QQuickTextEdit::mousePressEvent(QMouseEvent *event)-
1851{-
1852 Q_D(QQuickTextEdit);-
1853 d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));-
1854 if (d->focusOnPress){
d->focusOnPressDescription
TRUEevaluated 498 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextedit
16-498
1855 bool hadActiveFocus = hasActiveFocus();-
1856 forceActiveFocus(Qt::MouseFocusReason);-
1857 // re-open input panel on press if already focused-
1858#if QT_CONFIG(im)-
1859 if (hasActiveFocus() && hadActiveFocus && !isReadOnly())
hasActiveFocus()Description
TRUEevaluated 498 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
hadActiveFocusDescription
TRUEevaluated 480 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
!isReadOnly()Description
TRUEevaluated 462 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextedit
0-498
1860 qGuiApp->inputMethod()->show();
executed 462 times by 1 test: (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->show();
Executed by:
  • tst_qquicktextedit
462
1861#else-
1862 Q_UNUSED(hadActiveFocus);-
1863#endif-
1864 }
executed 498 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
498
1865 if (!event->isAccepted())
!event->isAccepted()Description
TRUEnever evaluated
FALSEevaluated 514 times by 1 test
Evaluated by:
  • tst_qquicktextedit
0-514
1866 QQuickImplicitSizeItem::mousePressEvent(event);
never executed: QQuickImplicitSizeItem::mousePressEvent(event);
0
1867}
executed 514 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
514
1868-
1869/*!-
1870\overload-
1871Handles the given mouse \a event.-
1872*/-
1873void QQuickTextEdit::mouseReleaseEvent(QMouseEvent *event)-
1874{-
1875 Q_D(QQuickTextEdit);-
1876 d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));-
1877-
1878 if (!event->isAccepted())
!event->isAccepted()Description
TRUEnever evaluated
FALSEevaluated 514 times by 1 test
Evaluated by:
  • tst_qquicktextedit
0-514
1879 QQuickImplicitSizeItem::mouseReleaseEvent(event);
never executed: QQuickImplicitSizeItem::mouseReleaseEvent(event);
0
1880}
executed 514 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
514
1881-
1882/*!-
1883\overload-
1884Handles the given mouse \a event.-
1885*/-
1886void QQuickTextEdit::mouseDoubleClickEvent(QMouseEvent *event)-
1887{-
1888 Q_D(QQuickTextEdit);-
1889 d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));-
1890 if (!event->isAccepted())
!event->isAccepted()Description
TRUEnever evaluated
FALSEevaluated 104 times by 1 test
Evaluated by:
  • tst_qquicktextedit
0-104
1891 QQuickImplicitSizeItem::mouseDoubleClickEvent(event);
never executed: QQuickImplicitSizeItem::mouseDoubleClickEvent(event);
0
1892}
executed 104 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
104
1893-
1894/*!-
1895\overload-
1896Handles the given mouse \a event.-
1897*/-
1898void QQuickTextEdit::mouseMoveEvent(QMouseEvent *event)-
1899{-
1900 Q_D(QQuickTextEdit);-
1901 d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));-
1902 if (!event->isAccepted())
!event->isAccepted()Description
TRUEnever evaluated
FALSEevaluated 138 times by 1 test
Evaluated by:
  • tst_qquicktextedit
0-138
1903 QQuickImplicitSizeItem::mouseMoveEvent(event);
never executed: QQuickImplicitSizeItem::mouseMoveEvent(event);
0
1904}
executed 138 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
138
1905-
1906#if QT_CONFIG(im)-
1907/*!-
1908\overload-
1909Handles the given input method \a event.-
1910*/-
1911void QQuickTextEdit::inputMethodEvent(QInputMethodEvent *event)-
1912{-
1913 Q_D(QQuickTextEdit);-
1914 const bool wasComposing = isInputMethodComposing();-
1915 d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));-
1916 setCursorVisible(d->control->cursorVisible());-
1917 if (wasComposing != isInputMethodComposing())
wasComposing !...hodComposing()Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 274 times by 1 test
Evaluated by:
  • tst_qquicktextedit
50-274
1918 emit inputMethodComposingChanged();
executed 50 times by 1 test: inputMethodComposingChanged();
Executed by:
  • tst_qquicktextedit
50
1919}
executed 324 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
324
1920-
1921/*!-
1922\overload-
1923Returns the value of the given \a property and \a argument.-
1924*/-
1925QVariant QQuickTextEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const-
1926{-
1927 Q_D(const QQuickTextEdit);-
1928-
1929 QVariant v;-
1930 switch (property) {-
1931 case Qt::ImEnabled:
executed 544 times by 3 tests: case Qt::ImEnabled:
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
544
1932 v = (bool)(flags() & ItemAcceptsInputMethod);-
1933 break;
executed 544 times by 3 tests: break;
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
544
1934 case Qt::ImHints:
executed 338 times by 3 tests: case Qt::ImHints:
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
338
1935 v = (int)d->effectiveInputMethodHints();-
1936 break;
executed 338 times by 3 tests: break;
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
338
1937 case Qt::ImInputItemClipRectangle:
never executed: case Qt::ImInputItemClipRectangle:
0
1938 v = QQuickItem::inputMethodQuery(property);-
1939 break;
never executed: break;
0
1940 default:
executed 26 times by 1 test: default:
Executed by:
  • tst_qquicktextedit
26
1941 if (property == Qt::ImCursorPosition && !argument.isNull())
property == Qt...CursorPositionDescription
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextedit
!argument.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0-26
1942 argument = QVariant(argument.toPointF() - QPointF(d->xoff, d->yoff));
never executed: argument = QVariant(argument.toPointF() - QPointF(d->xoff, d->yoff));
0
1943 v = d->control->inputMethodQuery(property, argument);-
1944 if (property == Qt::ImCursorRectangle || property == Qt::ImAnchorRectangle)
property == Qt...ursorRectangleDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEnever evaluated
property == Qt...nchorRectangleDescription
TRUEnever evaluated
FALSEnever evaluated
0-26
1945 v = QVariant(v.toRectF().translated(d->xoff, d->yoff));
executed 26 times by 1 test: v = QVariant(v.toRectF().translated(d->xoff, d->yoff));
Executed by:
  • tst_qquicktextedit
26
1946 break;
executed 26 times by 1 test: break;
Executed by:
  • tst_qquicktextedit
26
1947 }-
1948 return v;
executed 908 times by 3 tests: return v;
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
908
1949}-
1950-
1951/*!-
1952\overload-
1953Returns the value of the given \a property.-
1954*/-
1955QVariant QQuickTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const-
1956{-
1957 return inputMethodQuery(property, QVariant());
executed 908 times by 3 tests: return inputMethodQuery(property, QVariant());
Executed by:
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
908
1958}-
1959#endif // im-
1960-
1961void QQuickTextEdit::triggerPreprocess()-
1962{-
1963 Q_D(QQuickTextEdit);-
1964 if (d->updateType == QQuickTextEditPrivate::UpdateNone)
d->updateType ...te::UpdateNoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1965 d->updateType = QQuickTextEditPrivate::UpdateOnlyPreprocess;
never executed: d->updateType = QQuickTextEditPrivate::UpdateOnlyPreprocess;
0
1966 polish();-
1967 update();-
1968}
never executed: end of block
0
1969-
1970typedef QQuickTextEditPrivate::Node TextNode;-
1971using TextNodeIterator = QQuickTextEditPrivate::TextNodeIterator;-
1972-
1973static inline bool operator<(const TextNode &n1, const TextNode &n2)-
1974{-
1975 return n1.startPos() < n2.startPos();
executed 5896 times by 2 tests: return n1.startPos() < n2.startPos();
Executed by:
  • tst_examples
  • tst_qquicktextedit
5896
1976}-
1977-
1978static inline void updateNodeTransform(QQuickTextNode* node, const QPointF &topLeft)-
1979{-
1980 QMatrix4x4 transformMatrix;-
1981 transformMatrix.translate(topLeft.x(), topLeft.y());-
1982 node->setMatrix(transformMatrix);-
1983}
executed 562 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
562
1984-
1985/*!-
1986 * \internal-
1987 *-
1988 * Invalidates font caches owned by the text objects owned by the element-
1989 * to work around the fact that text objects cannot be used from multiple threads.-
1990 */-
1991void QQuickTextEdit::invalidateFontCaches()-
1992{-
1993 Q_D(QQuickTextEdit);-
1994 if (d->document == nullptr)
d->document == nullptrDescription
TRUEnever evaluated
FALSEevaluated 842 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
0-842
1995 return;
never executed: return;
0
1996-
1997 QTextBlock block;-
1998 for (block = d->document->firstBlock(); block.isValid(); block = block.next()) {
block.isValid()Description
TRUEevaluated 1826 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 842 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
842-1826
1999 if (block.layout() != nullptr && block.layout()->engine() != nullptr)
block.layout() != nullptrDescription
TRUEevaluated 1826 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEnever evaluated
block.layout()...e() != nullptrDescription
TRUEevaluated 1826 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEnever evaluated
0-1826
2000 block.layout()->engine()->resetFontEngineCache();
executed 1826 times by 4 tests: block.layout()->engine()->resetFontEngineCache();
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
1826
2001 }
executed 1826 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
1826
2002}
executed 842 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
842
2003-
2004inline void resetEngine(QQuickTextNodeEngine *engine, const QColor& textColor, const QColor& selectedTextColor, const QColor& selectionColor)-
2005{-
2006 *engine = QQuickTextNodeEngine();-
2007 engine->setTextColor(textColor);-
2008 engine->setSelectedTextColor(selectedTextColor);-
2009 engine->setSelectionColor(selectionColor);-
2010}
executed 854 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
854
2011-
2012QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData)-
2013{-
2014 Q_UNUSED(updatePaintNodeData);-
2015 Q_D(QQuickTextEdit);-
2016-
2017 if (d->updateType != QQuickTextEditPrivate::UpdatePaintNode && oldNode != nullptr) {
d->updateType ...pdatePaintNodeDescription
TRUEnever evaluated
FALSEevaluated 422 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
oldNode != nullptrDescription
TRUEnever evaluated
FALSEnever evaluated
0-422
2018 // Update done in preprocess() in the nodes-
2019 d->updateType = QQuickTextEditPrivate::UpdateNone;-
2020 return oldNode;
never executed: return oldNode;
0
2021 }-
2022-
2023 d->updateType = QQuickTextEditPrivate::UpdateNone;-
2024-
2025 if (!oldNode) {
!oldNodeDescription
TRUEevaluated 234 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 188 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
188-234
2026 // If we had any QQuickTextNode node references, they were deleted along with the root node-
2027 // But here we must delete the Node structures in textNodeMap-
2028 d->textNodeMap.clear();-
2029 }
executed 234 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
234
2030-
2031 RootNode *rootNode = static_cast<RootNode *>(oldNode);-
2032 TextNodeIterator nodeIterator = d->textNodeMap.begin();-
2033 while (nodeIterator != d->textNodeMap.end() && !nodeIterator->dirty())
nodeIterator !...tNodeMap.end()Description
TRUEevaluated 304 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
FALSEevaluated 364 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
!nodeIterator->dirty()Description
TRUEevaluated 246 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
58-364
2034 ++nodeIterator;
executed 246 times by 2 tests: ++nodeIterator;
Executed by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
246
2035-
2036 QQuickTextNodeEngine engine;-
2037 QQuickTextNodeEngine frameDecorationsEngine;-
2038-
2039 if (!oldNode || nodeIterator < d->textNodeMap.end()) {
!oldNodeDescription
TRUEevaluated 234 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 188 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
nodeIterator <...tNodeMap.end()Description
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 130 times by 2 tests
Evaluated by:
  • tst_qquickfocusscope
  • tst_qquicktextedit
58-234
2040-
2041 if (!oldNode)
!oldNodeDescription
TRUEevaluated 234 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
58-234
2042 rootNode = new RootNode;
executed 234 times by 4 tests: rootNode = new RootNode;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
234
2043-
2044 int firstDirtyPos = 0;-
2045 if (nodeIterator != d->textNodeMap.end()) {
nodeIterator !...tNodeMap.end()Description
TRUEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 234 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
58-234
2046 firstDirtyPos = nodeIterator->startPos();-
2047 do {-
2048 rootNode->removeChildNode(nodeIterator->textNode());-
2049 delete nodeIterator->textNode();-
2050 nodeIterator = d->textNodeMap.erase(nodeIterator);-
2051 } while (nodeIterator != d->textNodeMap.end() && nodeIterator->dirty());
executed 70 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
nodeIterator !...tNodeMap.end()Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquicktextedit
nodeIterator->dirty()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquicktextedit
12-70
2052 }
executed 58 times by 1 test: end of block
Executed by:
  • tst_qquicktextedit
58
2053-
2054 // FIXME: the text decorations could probably be handled separately (only updated for affected textFrames)-
2055 rootNode->resetFrameDecorations(d->createTextNode());-
2056 resetEngine(&frameDecorationsEngine, d->color, d->selectedTextColor, d->selectionColor);-
2057-
2058 QQuickTextNode *node = nullptr;-
2059-
2060 int currentNodeSize = 0;-
2061 int nodeStart = firstDirtyPos;-
2062 QPointF basePosition(d->xoff, d->yoff);-
2063 QMatrix4x4 basePositionMatrix;-
2064 basePositionMatrix.translate(basePosition.x(), basePosition.y());-
2065 rootNode->setMatrix(basePositionMatrix);-
2066-
2067 QPointF nodeOffset;-
2068 const TextNode firstCleanNode = (nodeIterator != d->textNodeMap.end()) ? *nodeIterator
(nodeIterator ...NodeMap.end())Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 254 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
38-254
2069 : TextNode();-
2070-
2071 QList<QTextFrame *> frames;-
2072 frames.append(d->document->rootFrame());-
2073-
2074 while (!frames.isEmpty()) {
!frames.isEmpty()Description
TRUEevaluated 292 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 292 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
292
2075 QTextFrame *textFrame = frames.takeFirst();-
2076 frames.append(textFrame->childFrames());-
2077 frameDecorationsEngine.addFrameDecorations(d->document, textFrame);-
2078-
2079 if (textFrame->lastPosition() < firstDirtyPos
textFrame->las... firstDirtyPosDescription
TRUEnever evaluated
FALSEevaluated 292 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
0-292
2080 || textFrame->firstPosition() >= firstCleanNode.startPos())
textFrame->fir...ode.startPos()Description
TRUEnever evaluated
FALSEevaluated 292 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
0-292
2081 continue;
never executed: continue;
0
2082 node = d->createTextNode();-
2083 resetEngine(&engine, d->color, d->selectedTextColor, d->selectionColor);-
2084-
2085 if (textFrame->firstPosition() > textFrame->lastPosition()
textFrame->fir...lastPosition()Description
TRUEnever evaluated
FALSEevaluated 292 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
0-292
2086 && textFrame->frameFormat().position() != QTextFrameFormat::InFlow) {
textFrame->fra...Format::InFlowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2087 updateNodeTransform(node, d->document->documentLayout()->frameBoundingRect(textFrame).topLeft());-
2088 const int pos = textFrame->firstPosition() - 1;-
2089 ProtectedLayoutAccessor *a = static_cast<ProtectedLayoutAccessor *>(d->document->documentLayout());-
2090 QTextCharFormat format = a->formatAccessor(pos);-
2091 QTextBlock block = textFrame->firstCursorPosition().block();-
2092 engine.setCurrentLine(block.layout()->lineForTextPosition(pos - block.position()));-
2093 engine.addTextObject(QPointF(0, 0), format, QQuickTextNodeEngine::Unselected, d->document,-
2094 pos, textFrame->frameFormat().position());-
2095 nodeStart = pos;-
2096 } else {
never executed: end of block
0
2097 // Having nodes spanning across frame boundaries will break the current bookkeeping mechanism. We need to prevent that.-
2098 QList<int> frameBoundaries;-
2099 frameBoundaries.reserve(frames.size());-
2100 for (QTextFrame *frame : qAsConst(frames))-
2101 frameBoundaries.append(frame->firstPosition());
never executed: frameBoundaries.append(frame->firstPosition());
0
2102 std::sort(frameBoundaries.begin(), frameBoundaries.end());-
2103-
2104 QTextFrame::iterator it = textFrame->begin();-
2105 while (!it.atEnd()) {
!it.atEnd()Description
TRUEevaluated 570 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEnever evaluated
0-570
2106 QTextBlock block = it.currentBlock();-
2107 ++it;-
2108 if (block.position() < firstDirtyPos)
block.position... firstDirtyPosDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 562 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
8-562
2109 continue;
executed 8 times by 1 test: continue;
Executed by:
  • tst_qquicktextedit
8
2110-
2111 if (!engine.hasContents()) {
!engine.hasContents()Description
TRUEevaluated 562 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEnever evaluated
0-562
2112 nodeOffset = d->document->documentLayout()->blockBoundingRect(block).topLeft();-
2113 updateNodeTransform(node, nodeOffset);-
2114 nodeStart = block.position();-
2115 }
executed 562 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
562
2116-
2117 engine.addTextBlock(d->document, block, -nodeOffset, d->color, QColor(), selectionStart(), selectionEnd() - 1);-
2118 currentNodeSize += block.length();-
2119-
2120 if ((it.atEnd()) || block.next().position() >= firstCleanNode.startPos())
(it.atEnd())Description
TRUEevaluated 254 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
FALSEevaluated 308 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
block.next().p...ode.startPos()Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 270 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
38-308
2121 break; // last node that needed replacing or last block of the frame
executed 292 times by 4 tests: break;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
292
2122-
2123 QList<int>::const_iterator lowerBound = std::lower_bound(frameBoundaries.constBegin(), frameBoundaries.constEnd(), block.next().position());-
2124 if (currentNodeSize > nodeBreakingSize || lowerBound == frameBoundaries.constEnd() || *lowerBound > nodeStart) {
currentNodeSiz...deBreakingSizeDescription
TRUEnever evaluated
FALSEevaluated 270 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
lowerBound == ...ies.constEnd()Description
TRUEevaluated 270 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextedit
FALSEnever evaluated
*lowerBound > nodeStartDescription
TRUEnever evaluated
FALSEnever evaluated
0-270
2125 currentNodeSize = 0;-
2126 d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);-
2127 node = d->createTextNode();-
2128 resetEngine(&engine, d->color, d->selectedTextColor, d->selectionColor);-
2129 nodeStart = block.next().position();-
2130 }
executed 270 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextedit
270
2131 }
executed 270 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextedit
270
2132 }
executed 292 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
292
2133 d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);-
2134 }
executed 292 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
292
2135 frameDecorationsEngine.addToSceneGraph(rootNode->frameDecorationsNode, QQuickText::Normal, QColor());-
2136 // Now prepend the frame decorations since we want them rendered first, with the text nodes and cursor in front.-
2137 rootNode->prependChildNode(rootNode->frameDecorationsNode);-
2138-
2139 Q_ASSERT(nodeIterator == d->textNodeMap.end()-
2140 || (nodeIterator->textNode() == firstCleanNode.textNode()-
2141 && nodeIterator->startPos() == firstCleanNode.startPos()));-
2142 // Update the position of the subsequent text blocks.-
2143 if (firstCleanNode.textNode() != nullptr) {
firstCleanNode...e() != nullptrDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 254 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem2
  • tst_qquicktextedit
38-254
2144 QPointF oldOffset = firstCleanNode.textNode()->matrix().map(QPointF(0,0));-
2145 QPointF currentOffset = d->document->documentLayout()->blockBoundingRect(-
2146 d->document->findBlock(firstCleanNode.startPos())).topLeft();-
2147 QPointF delta = currentOffset - oldOffset;-
2148 while (nodeIterator != d->textNodeMap.end()) {
nodeIterator !...tNodeMap.end()Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • tst_qquicktextedit
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquicktextedit
38-106
2149 QMatrix4x4 transformMatrix = nodeIterator->textNode()->matrix();-
2150 transformMatrix.translate(delta.x(), delta.y());-
2151 nodeIterator->textNode()->setMatrix(transformMatrix);-
2152 ++nodeIterator;-
2153 }
executed 106 times by 1 test: end of block
Executed by: