OpenCoverage

qquicktextinput.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicktextinput.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 "qquicktextinput_p.h"-
41#include "qquicktextinput_p_p.h"-
42#include "qquickwindow.h"-
43-
44#include <private/qqmlglobal_p.h>-
45#include <private/qv4scopedvalue_p.h>-
46-
47#include <QtCore/qcoreapplication.h>-
48#include <QtCore/qmimedata.h>-
49#include <QtQml/qqmlinfo.h>-
50#include <QtGui/qevent.h>-
51#include <QTextBoundaryFinder>-
52#include "qquicktextnode_p.h"-
53#include <QtQuick/qsgsimplerectnode.h>-
54-
55#include <QtGui/qstylehints.h>-
56#include <QtGui/qinputmethod.h>-
57#include <QtCore/qmath.h>-
58-
59#if QT_CONFIG(accessibility)-
60#include "qaccessible.h"-
61#include "qquickaccessibleattached_p.h"-
62#endif-
63-
64#include <QtGui/private/qtextengine_p.h>-
65#include <QtGui/private/qinputcontrol_p.h>-
66-
67QT_BEGIN_NAMESPACE-
68-
69DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
never executed: status = Yes;
never executed: end of block
executed 10 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
executed 7132 times by 5 tests: return status == Yes;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
status == UnknownDescription
TRUEevaluated 10 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 7122 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
__builtin_expe...ELD")), false)Description
TRUEnever evaluated
FALSEevaluated 10 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
v != "0"Description
TRUEnever evaluated
FALSEnever evaluated
v != "false"Description
TRUEnever evaluated
FALSEnever evaluated
0-7132
70-
71/*!-
72 \qmltype TextInput-
73 \instantiates QQuickTextInput-
74 \inqmlmodule QtQuick-
75 \ingroup qtquick-visual-
76 \ingroup qtquick-input-
77 \inherits Item-
78 \brief Displays an editable line of text.-
79-
80 The TextInput type displays a single line of editable plain text.-
81-
82 TextInput is used to accept a line of text input. Input constraints-
83 can be placed on a TextInput item (for example, through a \l validator or \l inputMask),-
84 and setting \l echoMode to an appropriate value enables TextInput to be used for-
85 a password input field.-
86-
87 On \macos, the Up/Down key bindings for Home/End are explicitly disabled.-
88 If you want such bindings (on any platform), you will need to construct them in QML.-
89-
90 \sa TextEdit, Text-
91*/-
92QQuickTextInput::QQuickTextInput(QQuickItem* parent)-
93: QQuickImplicitSizeItem(*(new QQuickTextInputPrivate), parent)-
94{-
95 Q_D(QQuickTextInput);-
96 d->init();-
97}
executed 1042 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
1042
98-
99QQuickTextInput::QQuickTextInput(QQuickTextInputPrivate &dd, QQuickItem *parent)-
100: QQuickImplicitSizeItem(dd, parent)-
101{-
102 Q_D(QQuickTextInput);-
103 d->init();-
104}
never executed: end of block
0
105-
106QQuickTextInput::~QQuickTextInput()-
107{-
108}-
109-
110void QQuickTextInput::componentComplete()-
111{-
112 Q_D(QQuickTextInput);-
113-
114 QQuickImplicitSizeItem::componentComplete();-
115-
116 d->checkIsValid();-
117 d->updateLayout();-
118 updateCursorRectangle();-
119 if (d->cursorComponent && isCursorVisible())
isCursorVisible()Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-14
120 QQuickTextUtil::createCursor(d);
never executed: QQuickTextUtil::createCursor(d);
0
121}
executed 1022 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
1022
122-
123/*!-
124 \qmlproperty string QtQuick::TextInput::text-
125-
126 The text in the TextInput.-
127-
128 \sa clear()-
129*/-
130QString QQuickTextInput::text() const-
131{-
132 Q_D(const QQuickTextInput);-
133-
134 QString content = d->m_text;-
135 QString res = d->m_maskData ? d->stripString(content) : content;
d->m_maskDataDescription
TRUEevaluated 1164 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 3310 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
1164-3310
136 return (res.isNull() ? QString::fromLatin1("") : res);
executed 4474 times by 4 tests: return (res.isNull() ? QString::fromLatin1("") : res);
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
4474
137}-
138-
139void QQuickTextInput::setText(const QString &s)-
140{-
141 Q_D(QQuickTextInput);-
142 if (s == text())
s == text()Description
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 1244 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
36-1244
143 return;
executed 36 times by 2 tests: return;
Executed by:
  • tst_examples
  • tst_qquicktextinput
36
144-
145#if QT_CONFIG(im)-
146 d->cancelPreedit();-
147#endif-
148 d->internalSetText(s, -1, false);-
149}
executed 1244 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
1244
150-
151-
152/*!-
153 \qmlproperty enumeration QtQuick::TextInput::renderType-
154-
155 Override the default rendering type for this component.-
156-
157 Supported render types are:-
158 \list-
159 \li Text.QtRendering-
160 \li Text.NativeRendering-
161 \endlist-
162-
163 Select Text.NativeRendering if you prefer text to look native on the target platform and do-
164 not require advanced features such as transformation of the text. Using such features in-
165 combination with the NativeRendering render type will lend poor and sometimes pixelated-
166 results.-
167-
168 The default rendering type is determined by \l QQuickWindow::textRenderType().-
169*/-
170QQuickTextInput::RenderType QQuickTextInput::renderType() const-
171{-
172 Q_D(const QQuickTextInput);-
173 return d->renderType;
executed 6 times by 1 test: return d->renderType;
Executed by:
  • tst_qquicktextinput
6
174}-
175-
176void QQuickTextInput::setRenderType(QQuickTextInput::RenderType renderType)-
177{-
178 Q_D(QQuickTextInput);-
179 if (d->renderType == renderType)
d->renderType == renderTypeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-4
180 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
2
181-
182 d->renderType = renderType;-
183 emit renderTypeChanged();-
184-
185 if (isComponentComplete())
isComponentComplete()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-4
186 d->updateLayout();
executed 4 times by 1 test: d->updateLayout();
Executed by:
  • tst_qquicktextinput
4
187}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
4
188-
189/*!-
190 \qmlproperty int QtQuick::TextInput::length-
191-
192 Returns the total number of characters in the TextInput item.-
193-
194 If the TextInput has an inputMask the length will include mask characters and may differ-
195 from the length of the string returned by the \l text property.-
196-
197 This property can be faster than querying the length the \l text property as it doesn't-
198 require any copying or conversion of the TextInput's internal string data.-
199*/-
200-
201int QQuickTextInput::length() const-
202{-
203 Q_D(const QQuickTextInput);-
204 return d->m_text.length();
executed 166 times by 1 test: return d->m_text.length();
Executed by:
  • tst_qquicktextinput
166
205}-
206-
207/*!-
208 \qmlmethod string QtQuick::TextInput::getText(int start, int end)-
209-
210 Returns the section of text that is between the \a start and \a end positions.-
211-
212 If the TextInput has an inputMask the length will include mask characters.-
213*/-
214-
215QString QQuickTextInput::getText(int start, int end) const-
216{-
217 Q_D(const QQuickTextInput);-
218-
219 if (start > end)
start > endDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-50
220 qSwap(start, end);
executed 2 times by 1 test: qSwap(start, end);
Executed by:
  • tst_qquicktextinput
2
221-
222 return d->m_text.mid(start, end - start);
executed 52 times by 1 test: return d->m_text.mid(start, end - start);
Executed by:
  • tst_qquicktextinput
52
223}-
224-
225QString QQuickTextInputPrivate::realText() const-
226{-
227 QString res = m_maskData ? stripString(m_text) : m_text;
m_maskDataDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-4
228 return (res.isNull() ? QString::fromLatin1("") : res);
executed 4 times by 1 test: return (res.isNull() ? QString::fromLatin1("") : res);
Executed by:
  • tst_qquicktextinput
4
229}-
230-
231/*!-
232 \qmlproperty string QtQuick::TextInput::font.family-
233-
234 Sets the family name of the font.-
235-
236 The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]".-
237 If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen.-
238 If the family isn't available a family will be set using the font matching algorithm.-
239*/-
240-
241/*!-
242 \qmlproperty string QtQuick::TextInput::font.styleName-
243 \since 5.6-
244-
245 Sets the style name of the font.-
246-
247 The style name is case insensitive. If set, the font will be matched against style name instead-
248 of the font properties \l font.weight, \l font.bold and \l font.italic.-
249*/-
250-
251/*!-
252 \qmlproperty bool QtQuick::TextInput::font.bold-
253-
254 Sets whether the font weight is bold.-
255*/-
256-
257/*!-
258 \qmlproperty enumeration QtQuick::TextInput::font.weight-
259-
260 Sets the font's weight.-
261-
262 The weight can be one of:-
263 \list-
264 \li Font.Thin-
265 \li Font.Light-
266 \li Font.ExtraLight-
267 \li Font.Normal - the default-
268 \li Font.Medium-
269 \li Font.DemiBold-
270 \li Font.Bold-
271 \li Font.ExtraBold-
272 \li Font.Black-
273 \endlist-
274-
275 \qml-
276 TextInput { text: "Hello"; font.weight: Font.DemiBold }-
277 \endqml-
278*/-
279-
280/*!-
281 \qmlproperty bool QtQuick::TextInput::font.italic-
282-
283 Sets whether the font has an italic style.-
284*/-
285-
286/*!-
287 \qmlproperty bool QtQuick::TextInput::font.underline-
288-
289 Sets whether the text is underlined.-
290*/-
291-
292/*!-
293 \qmlproperty bool QtQuick::TextInput::font.strikeout-
294-
295 Sets whether the font has a strikeout style.-
296*/-
297-
298/*!-
299 \qmlproperty real QtQuick::TextInput::font.pointSize-
300-
301 Sets the font size in points. The point size must be greater than zero.-
302*/-
303-
304/*!-
305 \qmlproperty int QtQuick::TextInput::font.pixelSize-
306-
307 Sets the font size in pixels.-
308-
309 Using this function makes the font device dependent.-
310 Use \c pointSize to set the size of the font in a device independent manner.-
311*/-
312-
313/*!-
314 \qmlproperty real QtQuick::TextInput::font.letterSpacing-
315-
316 Sets the letter spacing for the font.-
317-
318 Letter spacing changes the default spacing between individual letters in the font.-
319 A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing.-
320*/-
321-
322/*!-
323 \qmlproperty real QtQuick::TextInput::font.wordSpacing-
324-
325 Sets the word spacing for the font.-
326-
327 Word spacing changes the default spacing between individual words.-
328 A positive value increases the word spacing by a corresponding amount of pixels,-
329 while a negative value decreases the inter-word spacing accordingly.-
330*/-
331-
332/*!-
333 \qmlproperty enumeration QtQuick::TextInput::font.capitalization-
334-
335 Sets the capitalization for the text.-
336-
337 \list-
338 \li Font.MixedCase - This is the normal text rendering option where no capitalization change is applied.-
339 \li Font.AllUppercase - This alters the text to be rendered in all uppercase type.-
340 \li Font.AllLowercase - This alters the text to be rendered in all lowercase type.-
341 \li Font.SmallCaps - This alters the text to be rendered in small-caps type.-
342 \li Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character.-
343 \endlist-
344-
345 \qml-
346 TextInput { text: "Hello"; font.capitalization: Font.AllLowercase }-
347 \endqml-
348*/-
349-
350/*!-
351 \qmlproperty enumeration QtQuick::TextInput::font.hintingPreference-
352 \since 5.8-
353-
354 Sets the preferred hinting on the text. This is a hint to the underlying text rendering system-
355 to use a certain level of hinting, and has varying support across platforms. See the table in-
356 the documentation for QFont::HintingPreference for more details.-
357-
358 \note This property only has an effect when used together with render type TextInput.NativeRendering.-
359-
360 \list-
361 \value Font.PreferDefaultHinting - Use the default hinting level for the target platform.-
362 \value Font.PreferNoHinting - If possible, render text without hinting the outlines-
363 of the glyphs. The text layout will be typographically accurate, using the same metrics-
364 as are used e.g. when printing.-
365 \value Font.PreferVerticalHinting - If possible, render text with no horizontal hinting,-
366 but align glyphs to the pixel grid in the vertical direction. The text will appear-
367 crisper on displays where the density is too low to give an accurate rendering-
368 of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's-
369 layout will be scalable to higher density devices (such as printers) without impacting-
370 details such as line breaks.-
371 \value Font.PreferFullHinting - If possible, render text with hinting in both horizontal and-
372 vertical directions. The text will be altered to optimize legibility on the target-
373 device, but since the metrics will depend on the target size of the text, the positions-
374 of glyphs, line breaks, and other typographical detail will not scale, meaning that a-
375 text layout may look different on devices with different pixel densities.-
376 \endlist-
377-
378 \qml-
379 TextInput { text: "Hello"; renderType: TextInput.NativeRendering; font.hintingPreference: Font.PreferVerticalHinting }-
380 \endqml-
381*/-
382-
383/*!-
384 \qmlproperty bool QtQuick::TextInput::font.kerning-
385 \since 5.10-
386-
387 Enables or disables the kerning OpenType feature when shaping the text. Disabling this may-
388 improve performance when creating or changing the text, at the expense of some cosmetic-
389 features. The default value is true.-
390-
391 \qml-
392 TextInput { text: "OATS FLAVOUR WAY"; font.kerning: false }-
393 \endqml-
394*/-
395-
396/*!-
397 \qmlproperty bool QtQuick::TextInput::font.preferShaping-
398 \since 5.10-
399-
400 Sometimes, a font will apply complex rules to a set of characters in order to-
401 display them correctly. In some writing systems, such as Brahmic scripts, this is-
402 required in order for the text to be legible, but in e.g. Latin script, it is merely-
403 a cosmetic feature. Setting the \c preferShaping property to false will disable all-
404 such features when they are not required, which will improve performance in most cases.-
405-
406 The default value is true.-
407-
408 \qml-
409 TextInput { text: "Some text"; font.preferShaping: false }-
410 \endqml-
411*/-
412QFont QQuickTextInput::font() const-
413{-
414 Q_D(const QQuickTextInput);-
415 return d->sourceFont;
executed 178 times by 2 tests: return d->sourceFont;
Executed by:
  • tst_examples
  • tst_qquicktextinput
178
416}-
417-
418void QQuickTextInput::setFont(const QFont &font)-
419{-
420 Q_D(QQuickTextInput);-
421 if (d->sourceFont == font)
d->sourceFont == fontDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
14-32
422 return;
executed 14 times by 1 test: return;
Executed by:
  • tst_examples
14
423-
424 d->sourceFont = font;-
425 QFont oldFont = d->font;-
426 d->font = font;-
427 if (d->font.pointSizeF() != -1) {
d->font.pointSizeF() != -1Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
16
428 // 0.5pt resolution-
429 qreal size = qRound(d->font.pointSizeF()*2.0);-
430 d->font.setPointSizeF(size/2.0);-
431 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
16
432 if (oldFont != d->font) {
oldFont != d->fontDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEnever evaluated
0-32
433 d->updateLayout();-
434 updateCursorRectangle();-
435#if QT_CONFIG(im)-
436 updateInputMethod(Qt::ImCursorRectangle | Qt::ImFont | Qt::ImAnchorRectangle);-
437#endif-
438 }
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
32
439 emit fontChanged(d->sourceFont);-
440}
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
32
441-
442/*!-
443 \qmlproperty color QtQuick::TextInput::color-
444-
445 The text color.-
446*/-
447QColor QQuickTextInput::color() const-
448{-
449 Q_D(const QQuickTextInput);-
450 return d->color;
executed 32 times by 1 test: return d->color;
Executed by:
  • tst_qquicktextinput
32
451}-
452-
453void QQuickTextInput::setColor(const QColor &c)-
454{-
455 Q_D(QQuickTextInput);-
456 if (c != d->color) {
c != d->colorDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-28
457 d->color = c;-
458 d->textLayoutDirty = true;-
459 d->updateType = QQuickTextInputPrivate::UpdatePaintNode;-
460 polish();-
461 update();-
462 emit colorChanged();-
463 }
executed 28 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
28
464}
executed 32 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
32
465-
466-
467/*!-
468 \qmlproperty color QtQuick::TextInput::selectionColor-
469-
470 The text highlight color, used behind selections.-
471*/-
472QColor QQuickTextInput::selectionColor() const-
473{-
474 Q_D(const QQuickTextInput);-
475 return d->selectionColor;
executed 30 times by 1 test: return d->selectionColor;
Executed by:
  • tst_qquicktextinput
30
476}-
477-
478void QQuickTextInput::setSelectionColor(const QColor &color)-
479{-
480 Q_D(QQuickTextInput);-
481 if (d->selectionColor == color)
d->selectionColor == colorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-28
482 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
2
483-
484 d->selectionColor = color;-
485 if (d->hasSelectedText()) {
d->hasSelectedText()Description
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-28
486 d->textLayoutDirty = true;-
487 d->updateType = QQuickTextInputPrivate::UpdatePaintNode;-
488 polish();-
489 update();-
490 }
never executed: end of block
0
491 emit selectionColorChanged();-
492}
executed 28 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
28
493/*!-
494 \qmlproperty color QtQuick::TextInput::selectedTextColor-
495-
496 The highlighted text color, used in selections.-
497*/-
498QColor QQuickTextInput::selectedTextColor() const-
499{-
500 Q_D(const QQuickTextInput);-
501 return d->selectedTextColor;
executed 30 times by 1 test: return d->selectedTextColor;
Executed by:
  • tst_qquicktextinput
30
502}-
503-
504void QQuickTextInput::setSelectedTextColor(const QColor &color)-
505{-
506 Q_D(QQuickTextInput);-
507 if (d->selectedTextColor == color)
d->selectedTextColor == colorDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-26
508 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
4
509-
510 d->selectedTextColor = color;-
511 if (d->hasSelectedText()) {
d->hasSelectedText()Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-26
512 d->textLayoutDirty = true;-
513 d->updateType = QQuickTextInputPrivate::UpdatePaintNode;-
514 polish();-
515 update();-
516 }
never executed: end of block
0
517 emit selectedTextColorChanged();-
518}
executed 26 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
26
519-
520/*!-
521 \qmlproperty enumeration QtQuick::TextInput::horizontalAlignment-
522 \qmlproperty enumeration QtQuick::TextInput::effectiveHorizontalAlignment-
523 \qmlproperty enumeration QtQuick::TextInput::verticalAlignment-
524-
525 Sets the horizontal alignment of the text within the TextInput item's-
526 width and height. By default, the text alignment follows the natural alignment-
527 of the text, for example text that is read from left to right will be aligned to-
528 the left.-
529-
530 TextInput does not have vertical alignment, as the natural height is-
531 exactly the height of the single line of text. If you set the height-
532 manually to something larger, TextInput will always be top aligned-
533 vertically. You can use anchors to align it however you want within-
534 another item.-
535-
536 The valid values for \c horizontalAlignment are \c TextInput.AlignLeft, \c TextInput.AlignRight and-
537 \c TextInput.AlignHCenter.-
538-
539 Valid values for \c verticalAlignment are \c TextInput.AlignTop (default),-
540 \c TextInput.AlignBottom \c TextInput.AlignVCenter.-
541-
542 When using the attached property LayoutMirroring::enabled to mirror application-
543 layouts, the horizontal alignment of text will also be mirrored. However, the property-
544 \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment-
545 of TextInput, use the read-only property \c effectiveHorizontalAlignment.-
546*/-
547QQuickTextInput::HAlignment QQuickTextInput::hAlign() const-
548{-
549 Q_D(const QQuickTextInput);-
550 return d->hAlign;
executed 66 times by 2 tests: return d->hAlign;
Executed by:
  • tst_examples
  • tst_qquicktextinput
66
551}-
552-
553void QQuickTextInput::setHAlign(HAlignment align)-
554{-
555 Q_D(QQuickTextInput);-
556 bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror;
d->hAlignImplicitDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
d->effectiveLayoutMirrorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-28
557 d->hAlignImplicit = false;-
558 if (d->setHAlign(align, forceAlign) && isComponentComplete()) {
d->setHAlign(a...n, forceAlign)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
isComponentComplete()Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-28
559 d->updateLayout();-
560 updateCursorRectangle();-
561 }
executed 28 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
28
562}
executed 34 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
34
563-
564void QQuickTextInput::resetHAlign()-
565{-
566 Q_D(QQuickTextInput);-
567 d->hAlignImplicit = true;-
568 if (d->determineHorizontalAlignment() && isComponentComplete()) {
d->determineHo...talAlignment()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
isComponentComplete()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-16
569 d->updateLayout();-
570 updateCursorRectangle();-
571 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
4
572}
executed 20 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
20
573-
574QQuickTextInput::HAlignment QQuickTextInput::effectiveHAlign() const-
575{-
576 Q_D(const QQuickTextInput);-
577 QQuickTextInput::HAlignment effectiveAlignment = d->hAlign;-
578 if (!d->hAlignImplicit && d->effectiveLayoutMirror) {
!d->hAlignImplicitDescription
TRUEevaluated 160 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 6190 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
d->effectiveLayoutMirrorDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 138 times by 1 test
Evaluated by:
  • tst_qquicktextinput
22-6190
579 switch (d->hAlign) {-
580 case QQuickTextInput::AlignLeft:
executed 10 times by 1 test: case QQuickTextInput::AlignLeft:
Executed by:
  • tst_qquicktextinput
10
581 effectiveAlignment = QQuickTextInput::AlignRight;-
582 break;
executed 10 times by 1 test: break;
Executed by:
  • tst_qquicktextinput
10
583 case QQuickTextInput::AlignRight:
executed 12 times by 1 test: case QQuickTextInput::AlignRight:
Executed by:
  • tst_qquicktextinput
12
584 effectiveAlignment = QQuickTextInput::AlignLeft;-
585 break;
executed 12 times by 1 test: break;
Executed by:
  • tst_qquicktextinput
12
586 default:
never executed: default:
0
587 break;
never executed: break;
0
588 }-
589 }-
590 return effectiveAlignment;
executed 6350 times by 5 tests: return effectiveAlignment;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
6350
591}-
592-
593bool QQuickTextInputPrivate::setHAlign(QQuickTextInput::HAlignment alignment, bool forceAlign)-
594{-
595 Q_Q(QQuickTextInput);-
596 if ((hAlign != alignment || forceAlign) && alignment <= QQuickTextInput::AlignHCenter) { // justify not supported
hAlign != alignmentDescription
TRUEevaluated 66 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 4724 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
forceAlignDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4722 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
alignment <= Q...::AlignHCenterDescription
TRUEevaluated 68 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEnever evaluated
0-4724
597 QQuickTextInput::HAlignment oldEffectiveHAlign = q->effectiveHAlign();-
598 hAlign = alignment;-
599 emit q->horizontalAlignmentChanged(alignment);-
600 if (oldEffectiveHAlign != q->effectiveHAlign())
oldEffectiveHA...ectiveHAlign()Description
TRUEevaluated 66 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-66
601 emit q->effectiveHorizontalAlignmentChanged();
executed 66 times by 2 tests: q->effectiveHorizontalAlignmentChanged();
Executed by:
  • tst_examples
  • tst_qquicktextinput
66
602 return true;
executed 68 times by 2 tests: return true;
Executed by:
  • tst_examples
  • tst_qquicktextinput
68
603 }-
604 return false;
executed 4722 times by 5 tests: return false;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
4722
605}-
606-
607Qt::LayoutDirection QQuickTextInputPrivate::textDirection() const-
608{-
609 QString text = m_text;-
610#if QT_CONFIG(im)-
611 if (text.isEmpty())
text.isEmpty()Description
TRUEevaluated 1816 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 9088 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
1816-9088
612 text = m_textLayout.preeditAreaText();
executed 1816 times by 5 tests: text = m_textLayout.preeditAreaText();
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
1816
613#endif-
614-
615 const QChar *character = text.constData();-
616 while (!character->isNull()) {
!character->isNull()Description
TRUEevaluated 25808 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 3858 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
3858-25808
617 switch (character->direction()) {-
618 case QChar::DirL:
executed 6958 times by 4 tests: case QChar::DirL:
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
6958
619 return Qt::LeftToRight;
executed 6958 times by 4 tests: return Qt::LeftToRight;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
6958
620 case QChar::DirR:
never executed: case QChar::DirR:
0
621 case QChar::DirAL:
executed 88 times by 2 tests: case QChar::DirAL:
Executed by:
  • tst_examples
  • tst_qquicktextinput
88
622 case QChar::DirAN:
never executed: case QChar::DirAN:
0
623 return Qt::RightToLeft;
executed 88 times by 2 tests: return Qt::RightToLeft;
Executed by:
  • tst_examples
  • tst_qquicktextinput
88
624 default:
executed 18762 times by 2 tests: default:
Executed by:
  • tst_examples
  • tst_qquicktextinput
18762
625 break;
executed 18762 times by 2 tests: break;
Executed by:
  • tst_examples
  • tst_qquicktextinput
18762
626 }-
627 character++;-
628 }
executed 18762 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
18762
629 return Qt::LayoutDirectionAuto;
executed 3858 times by 5 tests: return Qt::LayoutDirectionAuto;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
3858
630}-
631-
632Qt::LayoutDirection QQuickTextInputPrivate::layoutDirection() const-
633{-
634 Qt::LayoutDirection direction = m_layoutDirection;-
635 if (direction == Qt::LayoutDirectionAuto) {
direction == Q...tDirectionAutoDescription
TRUEevaluated 6148 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 58 times by 1 test
Evaluated by:
  • tst_qquicktextinput
58-6148
636 direction = textDirection();-
637#if QT_CONFIG(im)-
638 if (direction == Qt::LayoutDirectionAuto)
direction == Q...tDirectionAutoDescription
TRUEevaluated 1674 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 4474 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
1674-4474
639 direction = QGuiApplication::inputMethod()->inputDirection();
executed 1674 times by 5 tests: direction = QGuiApplication::inputMethod()->inputDirection();
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
1674
640#endif-
641 }
executed 6148 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
6148
642 return (direction == Qt::LayoutDirectionAuto) ? Qt::LeftToRight : direction;
executed 6206 times by 5 tests: return (direction == Qt::LayoutDirectionAuto) ? Qt::LeftToRight : direction;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
6206
643}-
644-
645bool QQuickTextInputPrivate::determineHorizontalAlignment()-
646{-
647 if (hAlignImplicit) {
hAlignImplicitDescription
TRUEevaluated 4756 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
16-4756
648 // if no explicit alignment has been set, follow the natural layout direction of the text-
649 Qt::LayoutDirection direction = textDirection();-
650#if QT_CONFIG(im)-
651 if (direction == Qt::LayoutDirectionAuto)
direction == Q...tDirectionAutoDescription
TRUEevaluated 2184 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 2572 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
2184-2572
652 direction = QGuiApplication::inputMethod()->inputDirection();
executed 2184 times by 5 tests: direction = QGuiApplication::inputMethod()->inputDirection();
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
2184
653#endif-
654 return setHAlign(direction == Qt::RightToLeft ? QQuickTextInput::AlignRight : QQuickTextInput::AlignLeft);
executed 4756 times by 5 tests: return setHAlign(direction == Qt::RightToLeft ? QQuickTextInput::AlignRight : QQuickTextInput::AlignLeft);
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
4756
655 }-
656 return false;
executed 16 times by 1 test: return false;
Executed by:
  • tst_qquicktextinput
16
657}-
658-
659QQuickTextInput::VAlignment QQuickTextInput::vAlign() const-
660{-
661 Q_D(const QQuickTextInput);-
662 return d->vAlign;
executed 6 times by 1 test: return d->vAlign;
Executed by:
  • tst_qquicktextinput
6
663}-
664-
665void QQuickTextInput::setVAlign(QQuickTextInput::VAlignment alignment)-
666{-
667 Q_D(QQuickTextInput);-
668 if (alignment == d->vAlign)
alignment == d->vAlignDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-20
669 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
4
670 d->vAlign = alignment;-
671 emit verticalAlignmentChanged(d->vAlign);-
672 if (isComponentComplete()) {
isComponentComplete()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextinput
8-12
673 updateCursorRectangle();-
674 d->updateBaselineOffset();-
675 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
8
676}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
20
677-
678/*!-
679 \qmlproperty enumeration QtQuick::TextInput::wrapMode-
680-
681 Set this property to wrap the text to the TextInput item's width.-
682 The text will only wrap if an explicit width has been set.-
683-
684 \list-
685 \li TextInput.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width.-
686 \li TextInput.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width.-
687 \li TextInput.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.-
688 \li TextInput.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.-
689 \endlist-
690-
691 The default is TextInput.NoWrap. If you set a width, consider using TextInput.Wrap.-
692*/-
693QQuickTextInput::WrapMode QQuickTextInput::wrapMode() const-
694{-
695 Q_D(const QQuickTextInput);-
696 return d->wrapMode;
executed 8 times by 1 test: return d->wrapMode;
Executed by:
  • tst_qquicktextinput
8
697}-
698-
699void QQuickTextInput::setWrapMode(WrapMode mode)-
700{-
701 Q_D(QQuickTextInput);-
702 if (mode == d->wrapMode)
mode == d->wrapModeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquicktextinput
6-42
703 return;
executed 6 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
6
704 d->wrapMode = mode;-
705 d->updateLayout();-
706 updateCursorRectangle();-
707 emit wrapModeChanged();-
708}
executed 42 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
42
709-
710void QQuickTextInputPrivate::mirrorChange()-
711{-
712 Q_Q(QQuickTextInput);-
713 if (q->isComponentComplete()) {
q->isComponentComplete()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-4
714 if (!hAlignImplicit && (hAlign == QQuickTextInput::AlignRight || hAlign == QQuickTextInput::AlignLeft)) {
!hAlignImplicitDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
hAlign == QQui...ut::AlignRightDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
hAlign == QQui...put::AlignLeftDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-2
715 q->updateCursorRectangle();-
716 emit q->effectiveHorizontalAlignmentChanged();-
717 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
2
718 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
4
719}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
4
720-
721/*!-
722 \qmlproperty bool QtQuick::TextInput::readOnly-
723-
724 Sets whether user input can modify the contents of the TextInput.-
725-
726 If readOnly is set to true, then user input will not affect the text-
727 property. Any bindings or attempts to set the text property will still-
728 work.-
729*/-
730bool QQuickTextInput::isReadOnly() const-
731{-
732 Q_D(const QQuickTextInput);-
733 return d->m_readOnly;
executed 305 times by 4 tests: return d->m_readOnly;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
305
734}-
735-
736void QQuickTextInput::setReadOnly(bool ro)-
737{-
738 Q_D(QQuickTextInput);-
739 if (d->m_readOnly == ro)
d->m_readOnly == roDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 38 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
2-38
740 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
2
741-
742#if QT_CONFIG(im)-
743 setFlag(QQuickItem::ItemAcceptsInputMethod, !ro);-
744#endif-
745 d->m_readOnly = ro;-
746 d->setCursorPosition(d->end());-
747#if QT_CONFIG(im)-
748 updateInputMethod(Qt::ImEnabled);-
749#endif-
750 q_canPasteChanged();-
751 d->emitUndoRedoChanged();-
752 emit readOnlyChanged(ro);-
753 if (ro) {
roDescription
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextinput
14-24
754 setCursorVisible(false);-
755 } else if (hasActiveFocus()) {
executed 24 times by 2 tests: end of block
Executed by:
  • tst_qquickitem2
  • tst_qquicktextinput
hasActiveFocus()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-24
756 setCursorVisible(true);-
757 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
10
758 update();-
759}
executed 38 times by 2 tests: end of block
Executed by:
  • tst_qquickitem2
  • tst_qquicktextinput
38
760-
761/*!-
762 \qmlproperty int QtQuick::TextInput::maximumLength-
763 The maximum permitted length of the text in the TextInput.-
764-
765 If the text is too long, it is truncated at the limit.-
766-
767 By default, this property contains a value of 32767.-
768*/-
769int QQuickTextInput::maxLength() const-
770{-
771 Q_D(const QQuickTextInput);-
772 return d->m_maxLength;
executed 2 times by 1 test: return d->m_maxLength;
Executed by:
  • tst_qquicktextinput
2
773}-
774-
775void QQuickTextInput::setMaxLength(int ml)-
776{-
777 Q_D(QQuickTextInput);-
778 if (d->m_maxLength == ml || d->m_maskData)
d->m_maxLength == mlDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
d->m_maskDataDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-2
779 return;
never executed: return;
0
780-
781 d->m_maxLength = ml;-
782 d->internalSetText(d->m_text, -1, false);-
783-
784 emit maximumLengthChanged(ml);-
785}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
2
786-
787/*!-
788 \qmlproperty bool QtQuick::TextInput::cursorVisible-
789 Set to true when the TextInput shows a cursor.-
790-
791 This property is set and unset when the TextInput gets active focus, so that other-
792 properties can be bound to whether the cursor is currently showing. As it-
793 gets set and unset automatically, when you set the value yourself you must-
794 keep in mind that your value may be overwritten.-
795-
796 It can be set directly in script, for example if a KeyProxy might-
797 forward keys to it and you desire it to look active when this happens-
798 (but without actually giving it active focus).-
799-
800 It should not be set directly on the item, like in the below QML,-
801 as the specified value will be overridden and lost on focus changes.-
802-
803 \code-
804 TextInput {-
805 text: "Text"-
806 cursorVisible: false-
807 }-
808 \endcode-
809-
810 In the above snippet the cursor will still become visible when the-
811 TextInput gains active focus.-
812*/-
813bool QQuickTextInput::isCursorVisible() const-
814{-
815 Q_D(const QQuickTextInput);-
816 return d->cursorVisible;
executed 58 times by 1 test: return d->cursorVisible;
Executed by:
  • tst_qquicktextinput
58
817}-
818-
819void QQuickTextInput::setCursorVisible(bool on)-
820{-
821 Q_D(QQuickTextInput);-
822 if (d->cursorVisible == on)
d->cursorVisible == onDescription
TRUEevaluated 360 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 542 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
360-542
823 return;
executed 360 times by 2 tests: return;
Executed by:
  • tst_qquickitem2
  • tst_qquicktextinput
360
824 d->cursorVisible = on;-
825 if (on && isComponentComplete())
onDescription
TRUEevaluated 404 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 138 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
isComponentComplete()Description
TRUEevaluated 390 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_examples
14-404
826 QQuickTextUtil::createCursor(d);
executed 390 times by 3 tests: QQuickTextUtil::createCursor(d);
Executed by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
390
827 if (!d->cursorItem)
!d->cursorItemDescription
TRUEevaluated 500 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquicktextinput
42-500
828 d->updateCursorBlinking();
executed 500 times by 4 tests: d->updateCursorBlinking();
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
500
829 emit cursorVisibleChanged(d->cursorVisible);-
830}
executed 542 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
542
831-
832/*!-
833 \qmlproperty int QtQuick::TextInput::cursorPosition-
834 The position of the cursor in the TextInput.-
835*/-
836int QQuickTextInput::cursorPosition() const-
837{-
838 Q_D(const QQuickTextInput);-
839 return d->m_cursor;
executed 382 times by 1 test: return d->m_cursor;
Executed by:
  • tst_qquicktextinput
382
840}-
841-
842void QQuickTextInput::setCursorPosition(int cp)-
843{-
844 Q_D(QQuickTextInput);-
845 if (cp < 0 || cp > text().length())
cp < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 916 times by 1 test
Evaluated by:
  • tst_qquicktextinput
cp > text().length()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 908 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-916
846 return;
executed 10 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
10
847 d->moveCursor(cp);-
848}
executed 908 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
908
849-
850/*!-
851 \qmlproperty rectangle QtQuick::TextInput::cursorRectangle-
852-
853 The rectangle where the standard text cursor is rendered within the text input. Read only.-
854-
855 The position and height of a custom cursorDelegate are updated to follow the cursorRectangle-
856 automatically when it changes. The width of the delegate is unaffected by changes in the-
857 cursor rectangle.-
858*/-
859-
860QRectF QQuickTextInput::cursorRectangle() const-
861{-
862 Q_D(const QQuickTextInput);-
863-
864 int c = d->m_cursor;-
865#if QT_CONFIG(im)-
866 c += d->m_preeditCursor;-
867#endif-
868 if (d->m_echoMode == NoEcho)
d->m_echoMode == NoEchoDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 2720 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
2-2720
869 c = 0;
executed 2 times by 1 test: c = 0;
Executed by:
  • tst_qquicktextinput
2
870 QTextLine l = d->m_textLayout.lineForTextPosition(c);-
871 if (!l.isValid())
!l.isValid()Description
TRUEnever evaluated
FALSEevaluated 2722 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
0-2722
872 return QRectF();
never executed: return QRectF();
0
873 qreal x = l.cursorToX(c) - d->hscroll + leftPadding();-
874 qreal y = l.y() - d->vscroll + topPadding();-
875 qreal w = 1;-
876 if (d->overwriteMode) {
d->overwriteModeDescription
TRUEnever evaluated
FALSEevaluated 2722 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
0-2722
877 if (c < text().length())
c < text().length()Description
TRUEnever evaluated
FALSEnever evaluated
0
878 w = l.cursorToX(c + 1) - x;
never executed: w = l.cursorToX(c + 1) - x;
0
879 else-
880 w = QFontMetrics(font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
never executed: w = QFontMetrics(font()).width(QLatin1Char(' '));
0
881 }-
882 return QRectF(x, y, w, l.height());
executed 2722 times by 4 tests: return QRectF(x, y, w, l.height());
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
2722
883}-
884-
885/*!-
886 \qmlproperty int QtQuick::TextInput::selectionStart-
887-
888 The cursor position before the first character in the current selection.-
889-
890 This property is read-only. To change the selection, use select(start,end),-
891 selectAll(), or selectWord().-
892-
893 \sa selectionEnd, cursorPosition, selectedText-
894*/-
895int QQuickTextInput::selectionStart() const-
896{-
897 Q_D(const QQuickTextInput);-
898 return d->lastSelectionStart;
executed 588 times by 1 test: return d->lastSelectionStart;
Executed by:
  • tst_qquicktextinput
588
899}-
900/*!-
901 \qmlproperty int QtQuick::TextInput::selectionEnd-
902-
903 The cursor position after the last character in the current selection.-
904-
905 This property is read-only. To change the selection, use select(start,end),-
906 selectAll(), or selectWord().-
907-
908 \sa selectionStart, cursorPosition, selectedText-
909*/-
910int QQuickTextInput::selectionEnd() const-
911{-
912 Q_D(const QQuickTextInput);-
913 return d->lastSelectionEnd;
executed 586 times by 1 test: return d->lastSelectionEnd;
Executed by:
  • tst_qquicktextinput
586
914}-
915/*!-
916 \qmlmethod QtQuick::TextInput::select(int start, int end)-
917-
918 Causes the text from \a start to \a end to be selected.-
919-
920 If either start or end is out of range, the selection is not changed.-
921-
922 After calling this, selectionStart will become the lesser-
923 and selectionEnd will become the greater (regardless of the order passed-
924 to this method).-
925-
926 \sa selectionStart, selectionEnd-
927*/-
928void QQuickTextInput::select(int start, int end)-
929{-
930 Q_D(QQuickTextInput);-
931 if (start < 0 || end < 0 || start > d->m_text.length() || end > d->m_text.length())
start < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 418 times by 1 test
Evaluated by:
  • tst_qquicktextinput
end < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 414 times by 1 test
Evaluated by:
  • tst_qquicktextinput
start > d->m_text.length()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 410 times by 1 test
Evaluated by:
  • tst_qquicktextinput
end > d->m_text.length()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 406 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-418
932 return;
executed 16 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
16
933 d->setSelection(start, end-start);-
934}
executed 406 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
406
935-
936/*!-
937 \qmlproperty string QtQuick::TextInput::selectedText-
938-
939 This read-only property provides the text currently selected in the-
940 text input.-
941-
942 It is equivalent to the following snippet, but is faster and easier-
943 to use.-
944-
945 \js-
946 myTextInput.text.toString().substring(myTextInput.selectionStart,-
947 myTextInput.selectionEnd);-
948 \endjs-
949*/-
950QString QQuickTextInput::selectedText() const-
951{-
952 Q_D(const QQuickTextInput);-
953 return d->selectedText();
executed 892 times by 1 test: return d->selectedText();
Executed by:
  • tst_qquicktextinput
892
954}-
955-
956/*!-
957 \qmlproperty bool QtQuick::TextInput::activeFocusOnPress-
958-
959 Whether the TextInput should gain active focus on a mouse press. By default this is-
960 set to true.-
961*/-
962bool QQuickTextInput::focusOnPress() const-
963{-
964 Q_D(const QQuickTextInput);-
965 return d->focusOnPress;
executed 12 times by 1 test: return d->focusOnPress;
Executed by:
  • tst_qquicktextinput
12
966}-
967-
968void QQuickTextInput::setFocusOnPress(bool b)-
969{-
970 Q_D(QQuickTextInput);-
971 if (d->focusOnPress == b)
d->focusOnPress == bDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextinput
12-16
972 return;
executed 16 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
16
973-
974 d->focusOnPress = b;-
975-
976 emit activeFocusOnPressChanged(d->focusOnPress);-
977}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
12
978/*!-
979 \qmlproperty bool QtQuick::TextInput::autoScroll-
980-
981 Whether the TextInput should scroll when the text is longer than the width. By default this is-
982 set to true.-
983-
984 \sa ensureVisible()-
985*/-
986bool QQuickTextInput::autoScroll() const-
987{-
988 Q_D(const QQuickTextInput);-
989 return d->autoScroll;
never executed: return d->autoScroll;
0
990}-
991-
992void QQuickTextInput::setAutoScroll(bool b)-
993{-
994 Q_D(QQuickTextInput);-
995 if (d->autoScroll == b)
d->autoScroll == bDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-18
996 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
2
997-
998 d->autoScroll = b;-
999 //We need to repaint so that the scrolling is taking into account.-
1000 updateCursorRectangle();-
1001 emit autoScrollChanged(d->autoScroll);-
1002}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
18
1003-
1004/*!-
1005 \qmlproperty Validator QtQuick::TextInput::validator-
1006-
1007 Allows you to set a validator on the TextInput. When a validator is set-
1008 the TextInput will only accept input which leaves the text property in-
1009 an acceptable or intermediate state. The accepted signal will only be sent-
1010 if the text is in an acceptable state when enter is pressed.-
1011-
1012 Currently supported validators are IntValidator, DoubleValidator and-
1013 RegExpValidator. An example of using validators is shown below, which allows-
1014 input of integers between 11 and 31 into the text input:-
1015-
1016 \code-
1017 import QtQuick 2.0-
1018 TextInput{-
1019 validator: IntValidator{bottom: 11; top: 31;}-
1020 focus: true-
1021 }-
1022 \endcode-
1023-
1024 \sa acceptableInput, inputMask-
1025*/-
1026-
1027QValidator* QQuickTextInput::validator() const-
1028{-
1029#if !QT_CONFIG(validator)-
1030 return 0;-
1031#else-
1032 Q_D(const QQuickTextInput);-
1033 return d->m_validator;
executed 18 times by 1 test: return d->m_validator;
Executed by:
  • tst_qquicktextinput
18
1034#endif // validator-
1035}-
1036-
1037void QQuickTextInput::setValidator(QValidator* v)-
1038{-
1039#if !QT_CONFIG(validator)-
1040 Q_UNUSED(v);-
1041#else-
1042 Q_D(QQuickTextInput);-
1043 if (d->m_validator == v)
d->m_validator == vDescription
TRUEnever evaluated
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
0-36
1044 return;
never executed: return;
0
1045-
1046 if (d->m_validator) {
d->m_validatorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
2-34
1047 qmlobject_disconnect(
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
executed 2 times by 1 test: methodIdx = QQuickTextInput::staticMetaObject.indexOfSlot(method+1);
Executed by:
  • tst_qquicktextinput
never executed: methodIdx = QQuickTextInput::staticMetaObject.indexOfSignal(method+1);
signalIdx < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
methodIdx < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
code == 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-2
1048 d->m_validator, QValidator, SIGNAL(changed()),-
1049 this, QQuickTextInput, SLOT(q_validatorChanged()));-
1050 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
2
1051-
1052 d->m_validator = v;-
1053-
1054 if (d->m_validator) {
d->m_validatorDescription
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEnever evaluated
0-36
1055 qmlobject_connect(
executed 4 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
executed 4 times by 2 tests: methodIdx = QQuickTextInput::staticMetaObject.indexOfSlot(method+1);
Executed by:
  • tst_examples
  • tst_qquicktextinput
never executed: methodIdx = QQuickTextInput::staticMetaObject.indexOfSignal(method+1);
signalIdx < 0Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
methodIdx < 0Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
code == 1Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEnever evaluated
0-32
1056 d->m_validator, QValidator, SIGNAL(changed()),-
1057 this, QQuickTextInput, SLOT(q_validatorChanged()));-
1058 }
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
36
1059-
1060 if (isComponentComplete())
isComponentComplete()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
4-32
1061 d->checkIsValid();
executed 4 times by 1 test: d->checkIsValid();
Executed by:
  • tst_qquicktextinput
4
1062-
1063 emit validatorChanged();-
1064#endif // validator-
1065}
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
36
1066-
1067#if QT_CONFIG(validator)-
1068void QQuickTextInput::q_validatorChanged()-
1069{-
1070 Q_D(QQuickTextInput);-
1071 d->checkIsValid();-
1072}
executed 70 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
70
1073#endif // validator-
1074-
1075QRectF QQuickTextInputPrivate::anchorRectangle() const-
1076{-
1077 Q_Q(const QQuickTextInput);-
1078 QRectF rect;-
1079 int a;-
1080 // Unfortunately we cannot use selectionStart() and selectionEnd()-
1081 // since they always assume that the selectionStart is logically before selectionEnd.-
1082 // To rely on that would cause havoc if the user was interactively moving the end selection-
1083 // handle to become before the start selection-
1084 if (m_selstart == m_selend)
m_selstart == m_selendDescription
TRUEnever evaluated
FALSEnever evaluated
0
1085 // This is to handle the case when there is "no selection" while moving the handle onto the-
1086 // same position as the other handle (in which case it would hide the selection handles)-
1087 a = m_cursor;
never executed: a = m_cursor;
0
1088 else-
1089 a = m_selstart == m_cursor ? m_selend : m_selstart;
never executed: a = m_selstart == m_cursor ? m_selend : m_selstart;
m_selstart == m_cursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1090 if (a >= 0) {
a >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1091#if QT_CONFIG(im)-
1092 a += m_preeditCursor;-
1093#endif-
1094 if (m_echoMode == QQuickTextInput::NoEcho)
m_echoMode == ...tInput::NoEchoDescription
TRUEnever evaluated
FALSEnever evaluated
0
1095 a = 0;
never executed: a = 0;
0
1096 QTextLine l = m_textLayout.lineForTextPosition(a);-
1097 if (l.isValid()) {
l.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1098 qreal x = l.cursorToX(a) - hscroll + q->leftPadding();-
1099 qreal y = l.y() - vscroll + q->topPadding();-
1100 rect.setRect(x, y, 1, l.height());-
1101 }
never executed: end of block
0
1102 }
never executed: end of block
0
1103 return rect;
never executed: return rect;
0
1104}-
1105-
1106void QQuickTextInputPrivate::checkIsValid()-
1107{-
1108 Q_Q(QQuickTextInput);-
1109-
1110 ValidatorState state = hasAcceptableInput(m_text);-
1111 if (!m_maskData)
!m_maskDataDescription
TRUEevaluated 848 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 1302 times by 1 test
Evaluated by:
  • tst_qquicktextinput
848-1302
1112 m_validInput = state != InvalidInput;
executed 848 times by 5 tests: m_validInput = state != InvalidInput;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
848
1113 if (state != AcceptableInput) {
state != AcceptableInputDescription
TRUEevaluated 700 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 1450 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
700-1450
1114 if (m_acceptableInput) {
m_acceptableInputDescription
TRUEevaluated 520 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 180 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
180-520
1115 m_acceptableInput = false;-
1116 emit q->acceptableInputChanged();-
1117 }
executed 520 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
520
1118 } else if (!m_acceptableInput) {
executed 700 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
!m_acceptableInputDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1436 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
14-1436
1119 m_acceptableInput = true;-
1120 emit q->acceptableInputChanged();-
1121 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
14
1122}
executed 2150 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
2150
1123-
1124/*!-
1125 \qmlproperty string QtQuick::TextInput::inputMask-
1126-
1127 Allows you to set an input mask on the TextInput, restricting the allowable-
1128 text inputs. See QLineEdit::inputMask for further details, as the exact-
1129 same mask strings are used by TextInput.-
1130-
1131 \sa acceptableInput, validator-
1132*/-
1133QString QQuickTextInput::inputMask() const-
1134{-
1135 Q_D(const QQuickTextInput);-
1136 return d->inputMask();
executed 22 times by 1 test: return d->inputMask();
Executed by:
  • tst_qquicktextinput
22
1137}-
1138-
1139void QQuickTextInput::setInputMask(const QString &im)-
1140{-
1141 Q_D(QQuickTextInput);-
1142 if (d->inputMask() == im)
d->inputMask() == imDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 256 times by 1 test
Evaluated by:
  • tst_qquicktextinput
88-256
1143 return;
executed 88 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
88
1144-
1145 d->setInputMask(im);-
1146 emit inputMaskChanged(d->inputMask());-
1147}
executed 256 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
256
1148-
1149/*!-
1150 \qmlproperty bool QtQuick::TextInput::acceptableInput-
1151-
1152 This property is always true unless a validator or input mask has been set.-
1153 If a validator or input mask has been set, this property will only be true-
1154 if the current text is acceptable to the validator or input mask as a final-
1155 string (not as an intermediate string).-
1156*/-
1157bool QQuickTextInput::hasAcceptableInput() const-
1158{-
1159 Q_D(const QQuickTextInput);-
1160 return d->m_acceptableInput;
executed 230 times by 1 test: return d->m_acceptableInput;
Executed by:
  • tst_qquicktextinput
230
1161}-
1162-
1163/*!-
1164 \qmlsignal QtQuick::TextInput::accepted()-
1165-
1166 This signal is emitted when the Return or Enter key is pressed.-
1167 Note that if there is a \l validator or \l inputMask set on the text-
1168 input, the signal will only be emitted if the input is in an acceptable-
1169 state.-
1170-
1171 The corresponding handler is \c onAccepted.-
1172*/-
1173-
1174/*!-
1175 \qmlsignal QtQuick::TextInput::editingFinished()-
1176 \since 5.2-
1177-
1178 This signal is emitted when the Return or Enter key is pressed or-
1179 the text input loses focus. Note that if there is a validator or-
1180 inputMask set on the text input and enter/return is pressed, this-
1181 signal will only be emitted if the input follows-
1182 the inputMask and the validator returns an acceptable state.-
1183-
1184 The corresponding handler is \c onEditingFinished.-
1185*/-
1186-
1187/*!-
1188 \qmlsignal QtQuick::TextInput::textEdited()-
1189 \since 5.9-
1190-
1191 This signal is emitted whenever the text is edited. Unlike \c textChanged(),-
1192 this signal is not emitted when the text is changed programmatically, for example,-
1193 by changing the value of the \c text property or by calling \c clear().-
1194-
1195 The corresponding handler is \c onTextEdited.-
1196*/-
1197-
1198#if QT_CONFIG(im)-
1199Qt::InputMethodHints QQuickTextInputPrivate::effectiveInputMethodHints() const-
1200{-
1201 Qt::InputMethodHints hints = inputMethodHints;-
1202 if (m_echoMode == QQuickTextInput::Password || m_echoMode == QQuickTextInput::NoEcho)
m_echoMode == ...nput::PasswordDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 384 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
m_echoMode == ...tInput::NoEchoDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 382 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
2-384
1203 hints |= Qt::ImhHiddenText;
executed 14 times by 1 test: hints |= Qt::ImhHiddenText;
Executed by:
  • tst_qquicktextinput
14
1204 else if (m_echoMode == QQuickTextInput::PasswordEchoOnEdit)
m_echoMode == ...wordEchoOnEditDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 378 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
4-378
1205 hints &= ~Qt::ImhHiddenText;
executed 4 times by 1 test: hints &= ~Qt::ImhHiddenText;
Executed by:
  • tst_qquicktextinput
4
1206 if (m_echoMode != QQuickTextInput::Normal)
m_echoMode != ...tInput::NormalDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 378 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
18-378
1207 hints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
executed 18 times by 1 test: hints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
Executed by:
  • tst_qquicktextinput
18
1208 return hints;
executed 396 times by 3 tests: return hints;
Executed by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
396
1209}-
1210#endif-
1211-
1212/*!-
1213 \qmlproperty enumeration QtQuick::TextInput::echoMode-
1214-
1215 Specifies how the text should be displayed in the TextInput.-
1216 \list-
1217 \li TextInput.Normal - Displays the text as it is. (Default)-
1218 \li TextInput.Password - Displays platform-dependent password mask-
1219 characters instead of the actual characters.-
1220 \li TextInput.NoEcho - Displays nothing.-
1221 \li TextInput.PasswordEchoOnEdit - Displays characters as they are entered-
1222 while editing, otherwise identical to \c TextInput.Password.-
1223 \endlist-
1224*/-
1225QQuickTextInput::EchoMode QQuickTextInput::echoMode() const-
1226{-
1227 Q_D(const QQuickTextInput);-
1228 return QQuickTextInput::EchoMode(d->m_echoMode);
executed 112 times by 1 test: return QQuickTextInput::EchoMode(d->m_echoMode);
Executed by:
  • tst_qquicktextinput
112
1229}-
1230-
1231void QQuickTextInput::setEchoMode(QQuickTextInput::EchoMode echo)-
1232{-
1233 Q_D(QQuickTextInput);-
1234 if (echoMode() == echo)
echoMode() == echoDescription
TRUEevaluated 54 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquicktextinput
28-54
1235 return;
executed 54 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
54
1236 d->cancelPasswordEchoTimer();-
1237 d->m_echoMode = echo;-
1238 d->m_passwordEchoEditing = false;-
1239#if QT_CONFIG(im)-
1240 updateInputMethod(Qt::ImHints);-
1241#endif-
1242 d->updateDisplayText();-
1243 updateCursorRectangle();-
1244-
1245 emit echoModeChanged(echoMode());-
1246}
executed 28 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
28
1247-
1248/*!-
1249 \qmlproperty enumeration QtQuick::TextInput::inputMethodHints-
1250-
1251 Provides hints to the input method about the expected content of the text input and how it-
1252 should operate.-
1253-
1254 The value is a bit-wise combination of flags, or Qt.ImhNone if no hints are set.-
1255-
1256 Flags that alter behaviour are:-
1257-
1258 \list-
1259 \li Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords.-
1260 This is automatically set when setting echoMode to \c TextInput.Password.-
1261 \li Qt.ImhSensitiveData - Typed text should not be stored by the active input method-
1262 in any persistent storage like predictive user dictionary.-
1263 \li Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case-
1264 when a sentence ends.-
1265 \li Qt.ImhPreferNumbers - Numbers are preferred (but not required).-
1266 \li Qt.ImhPreferUppercase - Upper case letters are preferred (but not required).-
1267 \li Qt.ImhPreferLowercase - Lower case letters are preferred (but not required).-
1268 \li Qt.ImhNoPredictiveText - Do not use predictive text (i.e. dictionary lookup) while typing.-
1269-
1270 \li Qt.ImhDate - The text editor functions as a date field.-
1271 \li Qt.ImhTime - The text editor functions as a time field.-
1272 \li Qt.ImhMultiLine - The text editor doesn't close software input keyboard when Return or Enter key is pressed (since QtQuick 2.4).-
1273 \endlist-
1274-
1275 Flags that restrict input (exclusive flags) are:-
1276-
1277 \list-
1278 \li Qt.ImhDigitsOnly - Only digits are allowed.-
1279 \li Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign.-
1280 \li Qt.ImhUppercaseOnly - Only upper case letter input is allowed.-
1281 \li Qt.ImhLowercaseOnly - Only lower case letter input is allowed.-
1282 \li Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed.-
1283 \li Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed.-
1284 \li Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed.-
1285 \endlist-
1286-
1287 Masks:-
1288-
1289 \list-
1290 \li Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used.-
1291 \endlist-
1292*/-
1293-
1294Qt::InputMethodHints QQuickTextInput::inputMethodHints() const-
1295{-
1296#if !QT_CONFIG(im)-
1297 return Qt::ImhNone;-
1298#else-
1299 Q_D(const QQuickTextInput);-
1300 return d->inputMethodHints;
executed 14 times by 1 test: return d->inputMethodHints;
Executed by:
  • tst_qquicktextinput
14
1301#endif // im-
1302}-
1303-
1304void QQuickTextInput::setInputMethodHints(Qt::InputMethodHints hints)-
1305{-
1306#if !QT_CONFIG(im)-
1307 Q_UNUSED(hints);-
1308#else-
1309 Q_D(QQuickTextInput);-
1310-
1311 if (hints == d->inputMethodHints)
hints == d->inputMethodHintsDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4
1312 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
4
1313-
1314 d->inputMethodHints = hints;-
1315 updateInputMethod(Qt::ImHints);-
1316 emit inputMethodHintsChanged();-
1317#endif // im-
1318}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
4
1319-
1320/*!-
1321 \qmlproperty Component QtQuick::TextInput::cursorDelegate-
1322 The delegate for the cursor in the TextInput.-
1323-
1324 If you set a cursorDelegate for a TextInput, this delegate will be used for-
1325 drawing the cursor instead of the standard cursor. An instance of the-
1326 delegate will be created and managed by the TextInput when a cursor is-
1327 needed, and the x property of the delegate instance will be set so as-
1328 to be one pixel before the top left of the current character.-
1329-
1330 Note that the root item of the delegate component must be a QQuickItem or-
1331 QQuickItem derived item.-
1332*/-
1333QQmlComponent* QQuickTextInput::cursorDelegate() const-
1334{-
1335 Q_D(const QQuickTextInput);-
1336 return d->cursorComponent;
never executed: return d->cursorComponent;
0
1337}-
1338-
1339void QQuickTextInput::setCursorDelegate(QQmlComponent* c)-
1340{-
1341 Q_D(QQuickTextInput);-
1342 QQuickTextUtil::setCursorDelegate(d, c);-
1343}
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
24
1344-
1345void QQuickTextInput::createCursor()-
1346{-
1347 Q_D(QQuickTextInput);-
1348 d->cursorPending = true;-
1349 QQuickTextUtil::createCursor(d);-
1350}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
2
1351-
1352/*!-
1353 \qmlmethod rect QtQuick::TextInput::positionToRectangle(int pos)-
1354-
1355 This function takes a character position and returns the rectangle that the-
1356 cursor would occupy, if it was placed at that character position.-
1357-
1358 This is similar to setting the cursorPosition, and then querying the cursor-
1359 rectangle, but the cursorPosition is not changed.-
1360*/-
1361QRectF QQuickTextInput::positionToRectangle(int pos) const-
1362{-
1363 Q_D(const QQuickTextInput);-
1364 if (d->m_echoMode == NoEcho)
d->m_echoMode == NoEchoDescription
TRUEnever evaluated
FALSEevaluated 420 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-420
1365 pos = 0;
never executed: pos = 0;
0
1366#if QT_CONFIG(im)-
1367 else if (pos > d->m_cursor)
pos > d->m_cursorDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 394 times by 1 test
Evaluated by:
  • tst_qquicktextinput
26-394
1368 pos += d->preeditAreaText().length();
executed 26 times by 1 test: pos += d->preeditAreaText().length();
Executed by:
  • tst_qquicktextinput
26
1369#endif-
1370 QTextLine l = d->m_textLayout.lineForTextPosition(pos);-
1371 if (!l.isValid())
!l.isValid()Description
TRUEnever evaluated
FALSEevaluated 420 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-420
1372 return QRectF();
never executed: return QRectF();
0
1373 qreal x = l.cursorToX(pos) - d->hscroll;-
1374 qreal y = l.y() - d->vscroll;-
1375 qreal w = 1;-
1376 if (d->overwriteMode) {
d->overwriteModeDescription
TRUEnever evaluated
FALSEevaluated 420 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-420
1377 if (pos < text().length())
pos < text().length()Description
TRUEnever evaluated
FALSEnever evaluated
0
1378 w = l.cursorToX(pos + 1) - x;
never executed: w = l.cursorToX(pos + 1) - x;
0
1379 else-
1380 w = QFontMetrics(font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
never executed: w = QFontMetrics(font()).width(QLatin1Char(' '));
0
1381 }-
1382 return QRectF(x, y, w, l.height());
executed 420 times by 1 test: return QRectF(x, y, w, l.height());
Executed by:
  • tst_qquicktextinput
420
1383}-
1384-
1385/*!-
1386 \qmlmethod int QtQuick::TextInput::positionAt(real x, real y, CursorPosition position = CursorBetweenCharacters)-
1387-
1388 This function returns the character position at-
1389 x and y pixels from the top left of the textInput. Position 0 is before the-
1390 first character, position 1 is after the first character but before the second,-
1391 and so on until position text.length, which is after all characters.-
1392-
1393 This means that for all x values before the first character this function returns 0,-
1394 and for all x values after the last character this function returns text.length. If-
1395 the y value is above the text the position will be that of the nearest character on-
1396 the first line and if it is below the text the position of the nearest character-
1397 on the last line will be returned.-
1398-
1399 The cursor position type specifies how the cursor position should be resolved.-
1400-
1401 \list-
1402 \li TextInput.CursorBetweenCharacters - Returns the position between characters that is nearest x.-
1403 \li TextInput.CursorOnCharacter - Returns the position before the character that is nearest x.-
1404 \endlist-
1405*/-
1406-
1407void QQuickTextInput::positionAt(QQmlV4Function *args) const-
1408{-
1409 Q_D(const QQuickTextInput);-
1410-
1411 qreal x = 0;-
1412 qreal y = 0;-
1413 QTextLine::CursorPosition position = QTextLine::CursorBetweenCharacters;-
1414-
1415 if (args->length() < 1)
args->length() < 1Description
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-38
1416 return;
never executed: return;
0
1417-
1418 int i = 0;-
1419 QV4::Scope scope(args->v4engine());-
1420 QV4::ScopedValue arg(scope, (*args)[0]);-
1421 x = arg->toNumber();-
1422-
1423 if (++i < args->length()) {
++i < args->length()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquicktextinput
16-22
1424 arg = (*args)[i];-
1425 y = arg->toNumber();-
1426 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
16
1427-
1428 if (++i < args->length()) {
++i < args->length()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquicktextinput
8-30
1429 arg = (*args)[i];-
1430 position = QTextLine::CursorPosition(arg->toInt32());-
1431 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
8
1432-
1433 int pos = d->positionAt(x, y, position);-
1434 const int cursor = d->m_cursor;-
1435 if (pos > cursor) {
pos > cursorDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquicktextinput
14-24
1436#if QT_CONFIG(im)-
1437 const int preeditLength = d->preeditAreaText().length();-
1438 pos = pos > cursor + preeditLength
pos > cursor + preeditLengthDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-10
1439 ? pos - preeditLength-
1440 : cursor;-
1441#else-
1442 pos = cursor;-
1443#endif-
1444 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
14
1445 args->setReturnValue(QV4::Encode(pos));-
1446}
executed 38 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
38
1447-
1448int QQuickTextInputPrivate::positionAt(qreal x, qreal y, QTextLine::CursorPosition position) const-
1449{-
1450 Q_Q(const QQuickTextInput);-
1451 x += hscroll - q->leftPadding();-
1452 y += vscroll - q->topPadding();-
1453 QTextLine line = m_textLayout.lineAt(0);-
1454 for (int i = 1; i < m_textLayout.lineCount(); ++i) {
i < m_textLayout.lineCount()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 150 times by 1 test
Evaluated by:
  • tst_qquicktextinput
12-150
1455 QTextLine nextLine = m_textLayout.lineAt(i);-
1456-
1457 if (y < (line.rect().bottom() + nextLine.y()) / 2)
y < (line.rect...tLine.y()) / 2Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-8
1458 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qquicktextinput
8
1459 line = nextLine;-
1460 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
4
1461 return line.isValid() ? line.xToCursor(x, position) : 0;
executed 158 times by 1 test: return line.isValid() ? line.xToCursor(x, position) : 0;
Executed by:
  • tst_qquicktextinput
158
1462}-
1463-
1464/*!-
1465 \qmlproperty bool QtQuick::TextInput::overwriteMode-
1466 \since 5.8-
1467-
1468 Whether text entered by the user will overwrite existing text.-
1469-
1470 As with many text editors, the text editor widget can be configured-
1471 to insert or overwrite existing text with new text entered by the user.-
1472-
1473 If this property is \c true, existing text is overwritten, character-for-character-
1474 by new text; otherwise, text is inserted at the cursor position, displacing-
1475 existing text.-
1476-
1477 By default, this property is \c false (new text does not overwrite existing text).-
1478*/-
1479bool QQuickTextInput::overwriteMode() const-
1480{-
1481 Q_D(const QQuickTextInput);-
1482 return d->overwriteMode;
executed 6 times by 1 test: return d->overwriteMode;
Executed by:
  • tst_qquicktextinput
6
1483}-
1484-
1485void QQuickTextInput::setOverwriteMode(bool overwrite)-
1486{-
1487 Q_D(QQuickTextInput);-
1488 if (d->overwriteMode == overwrite)
d->overwriteMode == overwriteDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-6
1489 return;
never executed: return;
0
1490 d->overwriteMode = overwrite;-
1491 emit overwriteModeChanged(overwrite);-
1492}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
6
1493-
1494void QQuickTextInput::keyPressEvent(QKeyEvent* ev)-
1495{-
1496 Q_D(QQuickTextInput);-
1497 // Don't allow MacOSX up/down support, and we don't allow a completer.-
1498 bool ignore = (ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) && ev->modifiers() == Qt::NoModifier;
ev->key() == Qt::Key_UpDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1988 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
ev->key() == Qt::Key_DownDescription
TRUEnever evaluated
FALSEevaluated 1988 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
ev->modifiers(...Qt::NoModifierDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-1988
1499 if (!ignore && (d->lastSelectionStart == d->lastSelectionEnd) && (ev->key() == Qt::Key_Right || ev->key() == Qt::Key_Left)) {
!ignoreDescription
TRUEevaluated 1988 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
(d->lastSelect...tSelectionEnd)Description
TRUEevaluated 1920 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_qquicktextinput
ev->key() == Qt::Key_RightDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1880 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
ev->key() == Qt::Key_LeftDescription
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1834 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
2-1988
1500 // Ignore when moving off the end unless there is a selection,-
1501 // because then moving will do something (deselect).-
1502 int cursorPosition = d->m_cursor;-
1503 if (cursorPosition == 0)
cursorPosition == 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 70 times by 1 test
Evaluated by:
  • tst_qquicktextinput
16-70
1504 ignore = ev->key() == (d->layoutDirection() == Qt::LeftToRight ? Qt::Key_Left : Qt::Key_Right);
executed 16 times by 1 test: ignore = ev->key() == (d->layoutDirection() == Qt::LeftToRight ? Qt::Key_Left : Qt::Key_Right);
Executed by:
  • tst_qquicktextinput
d->layoutDirec...t::LeftToRightDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-16
1505 if (!ignore && cursorPosition == d->m_text.length())
!ignoreDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
cursorPosition..._text.length()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquicktextinput
6-80
1506 ignore = ev->key() == (d->layoutDirection() == Qt::LeftToRight ? Qt::Key_Right : Qt::Key_Left);
executed 14 times by 1 test: ignore = ev->key() == (d->layoutDirection() == Qt::LeftToRight ? Qt::Key_Right : Qt::Key_Left);
Executed by:
  • tst_qquicktextinput
d->layoutDirec...t::LeftToRightDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-14
1507 }
executed 86 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
86
1508 if (ignore) {
ignoreDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1976 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
14-1976
1509 ev->ignore();-
1510 } else {
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
14
1511 d->processKeyEvent(ev);-
1512 }
executed 1976 times by 2 tests: end of block
Executed by:
  • tst_qquickitem2
  • tst_qquicktextinput
1976
1513 if (!ev->isAccepted())
!ev->isAccepted()Description
TRUEevaluated 226 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 1764 times by 1 test
Evaluated by:
  • tst_qquicktextinput
226-1764
1514 QQuickImplicitSizeItem::keyPressEvent(ev);
executed 226 times by 2 tests: QQuickImplicitSizeItem::keyPressEvent(ev);
Executed by:
  • tst_qquickitem2
  • tst_qquicktextinput
226
1515}
executed 1990 times by 2 tests: end of block
Executed by:
  • tst_qquickitem2
  • tst_qquicktextinput
1990
1516-
1517#if QT_CONFIG(im)-
1518void QQuickTextInput::inputMethodEvent(QInputMethodEvent *ev)-
1519{-
1520 Q_D(QQuickTextInput);-
1521 const bool wasComposing = d->hasImState;-
1522 if (d->m_readOnly) {
d->m_readOnlyDescription
TRUEnever evaluated
FALSEevaluated 348 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-348
1523 ev->ignore();-
1524 } else {
never executed: end of block
0
1525 d->processInputMethodEvent(ev);-
1526 }
executed 348 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
348
1527 if (!ev->isAccepted())
!ev->isAccepted()Description
TRUEnever evaluated
FALSEevaluated 348 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-348
1528 QQuickImplicitSizeItem::inputMethodEvent(ev);
never executed: QQuickImplicitSizeItem::inputMethodEvent(ev);
0
1529-
1530 if (wasComposing != d->hasImState)
wasComposing != d->hasImStateDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 304 times by 1 test
Evaluated by:
  • tst_qquicktextinput
44-304
1531 emit inputMethodComposingChanged();
executed 44 times by 1 test: inputMethodComposingChanged();
Executed by:
  • tst_qquicktextinput
44
1532}
executed 348 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
348
1533#endif-
1534-
1535void QQuickTextInput::mouseDoubleClickEvent(QMouseEvent *event)-
1536{-
1537 Q_D(QQuickTextInput);-
1538-
1539 if (d->selectByMouse && event->button() == Qt::LeftButton) {
d->selectByMouseDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
event->button(...Qt::LeftButtonDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-6
1540#if QT_CONFIG(im)-
1541 d->commitPreedit();-
1542#endif-
1543 int cursor = d->positionAt(event->localPos());-
1544 d->selectWordAtPos(cursor);-
1545 event->setAccepted(true);-
1546 if (!d->hasPendingTripleClick()) {
!d->hasPendingTripleClick()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-4
1547 d->tripleClickStartPoint = event->localPos();-
1548 d->tripleClickTimer.start();-
1549 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
2
1550 } else {
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
6
1551 if (d->sendMouseEventToInputContext(event))
d->sendMouseEv...Context(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1552 return;
never executed: return;
0
1553 QQuickImplicitSizeItem::mouseDoubleClickEvent(event);-
1554 }
never executed: end of block
0
1555}-
1556-
1557void QQuickTextInput::mousePressEvent(QMouseEvent *event)-
1558{-
1559 Q_D(QQuickTextInput);-
1560-
1561 d->pressPos = event->localPos();-
1562-
1563 if (d->sendMouseEventToInputContext(event))
d->sendMouseEv...Context(event)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 84 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-84
1564 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
2
1565-
1566 if (d->selectByMouse) {
d->selectByMouseDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
16-68
1567 setKeepMouseGrab(false);-
1568 d->selectPressed = true;-
1569 QPointF distanceVector = d->pressPos - d->tripleClickStartPoint;-
1570 if (d->hasPendingTripleClick()
d->hasPendingTripleClick()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquicktextinput
12-56
1571 && distanceVector.manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) {
distanceVector...DragDistance()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-10
1572 event->setAccepted(true);-
1573 selectAll();-
1574 return;
executed 10 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
10
1575 }-
1576 }
executed 58 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
58
1577-
1578 bool mark = (event->modifiers() & Qt::ShiftModifier) && d->selectByMouse;
d->selectByMouseDescription
TRUEnever evaluated
FALSEnever evaluated
0
1579 int cursor = d->positionAt(event->localPos());-
1580 d->moveCursor(cursor, mark);-
1581-
1582 if (d->focusOnPress && !qGuiApp->styleHints()->setFocusOnTouchRelease())
d->focusOnPressDescription
TRUEevaluated 64 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
!(static_cast<...TouchRelease()Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-64
1583 ensureActiveFocus();
executed 64 times by 1 test: ensureActiveFocus();
Executed by:
  • tst_qquicktextinput
64
1584-
1585 event->setAccepted(true);-
1586}
executed 74 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
74
1587-
1588void QQuickTextInput::mouseMoveEvent(QMouseEvent *event)-
1589{-
1590 Q_D(QQuickTextInput);-
1591-
1592 if (d->selectPressed) {
d->selectPressedDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-36
1593 if (qAbs(int(event->localPos().x() - d->pressPos.x())) > QGuiApplication::styleHints()->startDragDistance())
qAbs(int(event...DragDistance()Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-36
1594 setKeepMouseGrab(true);
executed 36 times by 1 test: setKeepMouseGrab(true);
Executed by:
  • tst_qquicktextinput
36
1595-
1596#if QT_CONFIG(im)-
1597 if (d->composeMode()) {
d->composeMode()Description
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-36
1598 // start selection-
1599 int startPos = d->positionAt(d->pressPos);-
1600 int currentPos = d->positionAt(event->localPos());-
1601 if (startPos != currentPos)
startPos != currentPosDescription
TRUEnever evaluated
FALSEnever evaluated
0
1602 d->setSelection(startPos, currentPos - startPos);
never executed: d->setSelection(startPos, currentPos - startPos);
0
1603 } else
never executed: end of block
0
1604#endif-
1605 {-
1606 moveCursorSelection(d->positionAt(event->localPos()), d->mouseSelectionMode);-
1607 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
36
1608 event->setAccepted(true);-
1609 } else {
executed 36 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
36
1610 QQuickImplicitSizeItem::mouseMoveEvent(event);-
1611 }
never executed: end of block
0
1612}-
1613-
1614void QQuickTextInput::mouseReleaseEvent(QMouseEvent *event)-
1615{-
1616 Q_D(QQuickTextInput);-
1617 if (d->sendMouseEventToInputContext(event))
d->sendMouseEv...Context(event)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 84 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-84
1618 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktextinput
2
1619 if (d->selectPressed) {
d->selectPressedDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
16-68
1620 d->selectPressed = false;-
1621 setKeepMouseGrab(false);-
1622 }
executed 68 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
68
1623#if QT_CONFIG(clipboard)-
1624 if (QGuiApplication::clipboard()->supportsSelection()) {
QGuiApplicatio...rtsSelection()Description
TRUEevaluated 84 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-84
1625 if (event->button() == Qt::LeftButton) {
event->button(...Qt::LeftButtonDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-82
1626 d->copy(QClipboard::Selection);-
1627 } else if (!d->m_readOnly && event->button() == Qt::MidButton) {
executed 82 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
!d->m_readOnlyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
event->button(... Qt::MidButtonDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-82
1628 d->deselect();-
1629 d->insert(QGuiApplication::clipboard()->text(QClipboard::Selection));-
1630 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
2
1631 }
executed 84 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
84
1632#endif-
1633-
1634 if (d->focusOnPress && qGuiApp->styleHints()->setFocusOnTouchRelease())
d->focusOnPressDescription
TRUEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
(static_cast<Q...TouchRelease()Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-74
1635 ensureActiveFocus();
never executed: ensureActiveFocus();
0
1636-
1637 if (!event->isAccepted())
!event->isAccepted()Description
TRUEnever evaluated
FALSEevaluated 84 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-84
1638 QQuickImplicitSizeItem::mouseReleaseEvent(event);
never executed: QQuickImplicitSizeItem::mouseReleaseEvent(event);
0
1639}
executed 84 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
84
1640-
1641bool QQuickTextInputPrivate::sendMouseEventToInputContext(QMouseEvent *event)-
1642{-
1643#if QT_CONFIG(im)-
1644 if (composeMode()) {
composeMode()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 168 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-168
1645 int tmp_cursor = positionAt(event->localPos());-
1646 int mousePos = tmp_cursor - m_cursor;-
1647 if (mousePos >= 0 && mousePos <= m_textLayout.preeditAreaText().length()) {
mousePos >= 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
mousePos <= m_...ext().length()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-4
1648 if (event->type() == QEvent::MouseButtonRelease) {
event->type() ...eButtonReleaseDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2
1649 QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, mousePos);-
1650 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
2
1651 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_qquicktextinput
4
1652 }-
1653 }
never executed: end of block
0
1654#else-
1655 Q_UNUSED(event);-
1656#endif-
1657-
1658 return false;
executed 168 times by 1 test: return false;
Executed by:
  • tst_qquicktextinput
168
1659}-
1660-
1661void QQuickTextInput::mouseUngrabEvent()-
1662{-
1663 Q_D(QQuickTextInput);-
1664 d->selectPressed = false;-
1665 setKeepMouseGrab(false);-
1666}
executed 86 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
86
1667-
1668bool QQuickTextInput::event(QEvent* ev)-
1669{-
1670#if QT_CONFIG(shortcut)-
1671 Q_D(QQuickTextInput);-
1672 if (ev->type() == QEvent::ShortcutOverride) {
ev->type() == ...ortcutOverrideDescription
TRUEevaluated 1176 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 7113 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
1176-7113
1673 if (d->m_readOnly)
d->m_readOnlyDescription
TRUEnever evaluated
FALSEevaluated 1176 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-1176
1674 return false;
never executed: return false;
0
1675 QKeyEvent* ke = static_cast<QKeyEvent*>(ev);-
1676 if (ke == QKeySequence::Copy
ke == QKeySequence::CopyDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1166 times by 1 test
Evaluated by:
  • tst_qquicktextinput
10-1166
1677 || ke == QKeySequence::Paste
ke == QKeySequence::PasteDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1162 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-1162
1678 || ke == QKeySequence::Cut
ke == QKeySequence::CutDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1160 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-1160
1679 || ke == QKeySequence::Redo
ke == QKeySequence::RedoDescription
TRUEnever evaluated
FALSEevaluated 1160 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-1160
1680 || ke == QKeySequence::Undo
ke == QKeySequence::UndoDescription
TRUEnever evaluated
FALSEevaluated 1160 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-1160
1681 || ke == QKeySequence::MoveToNextWord
ke == QKeySequ...MoveToNextWordDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1152 times by 1 test
Evaluated by:
  • tst_qquicktextinput
8-1152
1682 || ke == QKeySequence::MoveToPreviousWord
ke == QKeySequ...ToPreviousWordDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1144 times by 1 test
Evaluated by:
  • tst_qquicktextinput
8-1144
1683 || ke == QKeySequence::MoveToStartOfDocument
ke == QKeySequ...tartOfDocumentDescription
TRUEnever evaluated
FALSEevaluated 1144 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-1144
1684 || ke == QKeySequence::MoveToEndOfDocument
ke == QKeySequ...oEndOfDocumentDescription
TRUEnever evaluated
FALSEevaluated 1144 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-1144
1685 || ke == QKeySequence::SelectNextWord
ke == QKeySequ...SelectNextWordDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1142 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-1142
1686 || ke == QKeySequence::SelectPreviousWord
ke == QKeySequ...ctPreviousWordDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1140 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-1140
1687 || ke == QKeySequence::SelectStartOfLine
ke == QKeySequ...ectStartOfLineDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1138 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-1138
1688 || ke == QKeySequence::SelectEndOfLine
ke == QKeySequ...electEndOfLineDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1136 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-1136
1689 || ke == QKeySequence::SelectStartOfBlock
ke == QKeySequ...ctStartOfBlockDescription
TRUEnever evaluated
FALSEevaluated 1136 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-1136
1690 || ke == QKeySequence::SelectEndOfBlock
ke == QKeySequ...lectEndOfBlockDescription
TRUEnever evaluated
FALSEevaluated 1136 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-1136
1691 || ke == QKeySequence::SelectStartOfDocument
ke == QKeySequ...tartOfDocumentDescription
TRUEnever evaluated
FALSEevaluated 1136 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-1136
1692 || ke == QKeySequence::SelectAll
ke == QKeySequence::SelectAllDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1132 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-1132
1693 || ke == QKeySequence::SelectEndOfDocument
ke == QKeySequ...tEndOfDocumentDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1130 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-1130
1694 || ke == QKeySequence::DeleteCompleteLine) {
ke == QKeySequ...teCompleteLineDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 1128 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-1128
1695 ke->accept();-
1696 return true;
executed 48 times by 1 test: return true;
Executed by:
  • tst_qquicktextinput
48
1697 } else if (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier
ke->modifiers(...Qt::NoModifierDescription
TRUEevaluated 1046 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquicktextinput
ke->modifiers(...:ShiftModifierDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquicktextinput
26-1046
1698 || ke->modifiers() == Qt::KeypadModifier) {
ke->modifiers(...KeypadModifierDescription
TRUEnever evaluated
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-56
1699 if (ke->key() < Qt::Key_Escape) {
ke->key() < Qt::Key_EscapeDescription
TRUEevaluated 976 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquicktextinput
96-976
1700 ke->accept();-
1701 return true;
executed 976 times by 1 test: return true;
Executed by:
  • tst_qquicktextinput
976
1702 } else {-
1703 switch (ke->key()) {-
1704 case Qt::Key_Delete:
executed 14 times by 1 test: case Qt::Key_Delete:
Executed by:
  • tst_qquicktextinput
14
1705 case Qt::Key_Home:
executed 2 times by 1 test: case Qt::Key_Home:
Executed by:
  • tst_qquicktextinput
2
1706 case Qt::Key_End:
never executed: case Qt::Key_End:
0
1707 case Qt::Key_Backspace:
executed 36 times by 1 test: case Qt::Key_Backspace:
Executed by:
  • tst_qquicktextinput
36
1708 case Qt::Key_Left:
executed 10 times by 1 test: case Qt::Key_Left:
Executed by:
  • tst_qquicktextinput
10
1709 case Qt::Key_Right:
executed 6 times by 1 test: case Qt::Key_Right:
Executed by:
  • tst_qquicktextinput
6
1710 ke->accept();-
1711 return true;
executed 68 times by 1 test: return true;
Executed by:
  • tst_qquicktextinput
68
1712 default:
executed 28 times by 1 test: default:
Executed by:
  • tst_qquicktextinput
28
1713 break;
executed 28 times by 1 test: break;
Executed by:
  • tst_qquicktextinput
28
1714 }-
1715 }-
1716 }-
1717 }
executed 84 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
84
1718#endif-
1719-
1720 return QQuickImplicitSizeItem::event(ev);
executed 7197 times by 5 tests: return QQuickImplicitSizeItem::event(ev);
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
7197
1721}-
1722-
1723void QQuickTextInput::geometryChanged(const QRectF &newGeometry,-
1724 const QRectF &oldGeometry)-
1725{-
1726 Q_D(QQuickTextInput);-
1727 if (!d->inLayout) {
!d->inLayoutDescription
TRUEevaluated 3019 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
6-3019
1728 if (newGeometry.width() != oldGeometry.width())
newGeometry.wi...ometry.width()Description
TRUEevaluated 2686 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 333 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
333-2686
1729 d->updateLayout();
executed 2686 times by 5 tests: d->updateLayout();
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
2686
1730 else if (newGeometry.height() != oldGeometry.height() && d->vAlign != QQuickTextInput::AlignTop)
newGeometry.he...metry.height()Description
TRUEevaluated 282 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 51 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
d->vAlign != Q...nput::AlignTopDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 262 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
20-282
1731 d->updateBaselineOffset();
executed 20 times by 1 test: d->updateBaselineOffset();
Executed by:
  • tst_qquicktextinput
20
1732 updateCursorRectangle();-
1733 }
executed 3019 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
3019
1734 QQuickImplicitSizeItem::geometryChanged(newGeometry, oldGeometry);-
1735}
executed 3025 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
3025
1736-
1737void QQuickTextInputPrivate::ensureVisible(int position, int preeditCursor, int preeditLength)-
1738{-
1739 Q_Q(QQuickTextInput);-
1740 QTextLine textLine = m_textLayout.lineForTextPosition(position + preeditCursor);-
1741 const qreal width = qMax<qreal>(0, q->width() - q->leftPadding() - q->rightPadding());-
1742 qreal cix = 0;-
1743 qreal widthUsed = 0;-
1744 if (textLine.isValid()) {
textLine.isValid()Description
TRUEevaluated 8395 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 10 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem2
  • tst_qquicktextinput
10-8395
1745 cix = textLine.cursorToX(position + preeditLength);-
1746 const qreal cursorWidth = cix >= 0 ? cix : width - cix;
cix >= 0Description
TRUEevaluated 8331 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 64 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
64-8331
1747 widthUsed = qMax(textLine.naturalTextWidth(), cursorWidth);-
1748 }
executed 8395 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
8395
1749 int previousScroll = hscroll;-
1750-
1751 if (widthUsed <= width) {
widthUsed <= widthDescription
TRUEevaluated 8091 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 314 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
314-8091
1752 hscroll = 0;-
1753 } else {
executed 8091 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
8091
1754 Q_ASSERT(textLine.isValid());-
1755 if (cix - hscroll >= width) {
cix - hscroll >= widthDescription
TRUEevaluated 138 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 176 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
138-176
1756 // text doesn't fit, cursor is to the right of br (scroll right)-
1757 hscroll = cix - width;-
1758 } else if (cix - hscroll < 0 && hscroll < widthUsed) {
executed 138 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
cix - hscroll < 0Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 104 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
hscroll < widthUsedDescription
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-138
1759 // text doesn't fit, cursor is to the left of br (scroll left)-
1760 hscroll = cix;-
1761 } else if (widthUsed - hscroll < width) {
executed 70 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
widthUsed - hscroll < widthDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 96 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
10-96
1762 // text doesn't fit, text document is to the left of br; align-
1763 // right-
1764 hscroll = widthUsed - width;-
1765 } else if (width - hscroll > widthUsed) {
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
width - hscroll > widthUsedDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
8-88
1766 // text doesn't fit, text document is to the right of br; align-
1767 // left-
1768 hscroll = width - widthUsed;-
1769 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
8
1770#if QT_CONFIG(im)-
1771 if (preeditLength > 0) {
preeditLength > 0Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 288 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
26-288
1772 // check to ensure long pre-edit text doesn't push the cursor-
1773 // off to the left-
1774 cix = textLine.cursorToX(position + qMax(0, preeditCursor - 1));-
1775 if (cix < hscroll)
cix < hscrollDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
10-16
1776 hscroll = cix;
executed 10 times by 1 test: hscroll = cix;
Executed by:
  • tst_qquicktextinput
10
1777 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
26
1778#endif-
1779 }
executed 314 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktextinput
314
1780 if (previousScroll != hscroll)
previousScroll != hscrollDescription
TRUEevaluated 208 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 8197 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
208-8197
1781 textLayoutDirty = true;
executed 208 times by 2 tests: textLayoutDirty = true;
Executed by:
  • tst_examples
  • tst_qquicktextinput
208
1782}
executed 8405 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
8405
1783-
1784void QQuickTextInputPrivate::updateHorizontalScroll()-
1785{-
1786 if (autoScroll && m_echoMode != QQuickTextInput::NoEcho) {
autoScrollDescription
TRUEevaluated 8411 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 122 times by 1 test
Evaluated by:
  • tst_qquicktextinput
m_echoMode != ...tInput::NoEchoDescription
TRUEevaluated 8401 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquicktextinput
10-8411
1787#if QT_CONFIG(im)-
1788 const int preeditLength = m_textLayout.preeditAreaText().length();-
1789 ensureVisible(m_cursor, m_preeditCursor, preeditLength);-
1790#else-
1791 ensureVisible(m_cursor);-
1792#endif-
1793 } else {
executed 8401 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
8401
1794 hscroll = 0;-
1795 }
executed 132 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
132
1796}-
1797-
1798void QQuickTextInputPrivate::updateVerticalScroll()-
1799{-
1800 Q_Q(QQuickTextInput);-
1801#if QT_CONFIG(im)-
1802 const int preeditLength = m_textLayout.preeditAreaText().length();-
1803#endif-
1804 const qreal height = qMax<qreal>(0, q->height() - q->topPadding() - q->bottomPadding());-
1805 qreal heightUsed = contentSize.height();-
1806 qreal previousScroll = vscroll;-
1807-
1808 if (!autoScroll || heightUsed <= height) {
!autoScrollDescription
TRUEevaluated 122 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 8411 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
heightUsed <= heightDescription
TRUEevaluated 8153 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
FALSEevaluated 258 times by 1 test
Evaluated by:
  • tst_qquicktextinput
122-8411
1809 // text fits in br; use vscroll for alignment-
1810 vscroll = -QQuickTextUtil::alignedY(-
1811 heightUsed, height, vAlign & ~(Qt::AlignAbsolute|Qt::AlignHorizontal_Mask));-
1812 } else {
executed 8275 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
8275
1813#if QT_CONFIG(im)-
1814 QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + preeditLength);-
1815#else-
1816 QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor);-
1817#endif-
1818 QRectF r = currentLine.isValid() ? currentLine.rect() : QRectF();
currentLine.isValid()Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-258
1819 qreal top = r.top();-
1820 int bottom = r.bottom();-
1821-
1822 if (bottom - vscroll >= height) {
bottom - vscroll >= heightDescription
TRUEevaluated 162 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 96 times by 1 test
Evaluated by:
  • tst_qquicktextinput
96-162
1823 // text doesn't fit, cursor is to the below the br (scroll down)-
1824 vscroll = bottom - height;-
1825 } else if (top - vscroll < 0 && vscroll < heightUsed) {
executed 162 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
top - vscroll < 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquicktextinput
vscroll < heightUsedDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
0-162
1826 // text doesn't fit, cursor is above br (scroll up)-
1827 vscroll = top;-
1828 } else if (heightUsed - vscroll < height) {
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
heightUsed - vscroll < heightDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquicktextinput
6-74
1829 // text doesn't fit, text document is to the left of br; align-
1830 // right-
1831 vscroll = heightUsed - height;-
1832 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
6
1833#if QT_CONFIG(im)-
1834 if (preeditLength > 0) {
preeditLength > 0Description
TRUEnever evaluated
FALSEevaluated 258 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-258
1835 // check to ensure long pre-edit text doesn't push the cursor-
1836 // off the top-
1837 currentLine = m_textLayout.lineForTextPosition(m_cursor + qMax(0, m_preeditCursor - 1));-
1838 top = currentLine.isValid() ? currentLine.rect().top() : 0;
currentLine.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1839 if (top < vscroll)
top < vscrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
1840 vscroll = top;
never executed: vscroll = top;
0
1841 }
never executed: end of block
0
1842#endif-
1843 }
executed 258 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
258
1844 if (previousScroll != vscroll)
previousScroll != vscrollDescription
TRUEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 8459 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
74-8459
1845 textLayoutDirty = true;
executed 74 times by 1 test: textLayoutDirty = true;
Executed by:
  • tst_qquicktextinput
74
1846}
executed 8533 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextedit
  • tst_qquicktextinput
8533
1847-
1848void QQuickTextInput::triggerPreprocess()-
1849{-
1850 Q_D(QQuickTextInput);-
1851 if (d->updateType == QQuickTextInputPrivate::UpdateNone)
d->updateType ...te::UpdateNoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1852 d->updateType = QQuickTextInputPrivate::UpdateOnlyPreprocess;
never executed: d->updateType = QQuickTextInputPrivate::UpdateOnlyPreprocess;
0
1853 polish();-
1854 update();-
1855}
never executed: end of block
0
1856-
1857void QQuickTextInput::updatePolish()-
1858{-
1859 invalidateFontCaches();-
1860}
executed 302 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
302
1861-
1862void QQuickTextInput::invalidateFontCaches()-
1863{-
1864 Q_D(QQuickTextInput);-
1865-
1866 if (d->m_textLayout.engine() != nullptr)
d->m_textLayou...e() != nullptrDescription
TRUEevaluated 599 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEnever evaluated
0-599
1867 d->m_textLayout.engine()->resetFontEngineCache();
executed 599 times by 4 tests: d->m_textLayout.engine()->resetFontEngineCache();
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
599
1868}
executed 599 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
599
1869-
1870void QQuickTextInput::ensureActiveFocus()-
1871{-
1872 bool hadActiveFocus = hasActiveFocus();-
1873 forceActiveFocus();-
1874#if QT_CONFIG(im)-
1875 Q_D(QQuickTextInput);-
1876 // re-open input panel on press if already focused-
1877 if (hasActiveFocus() && hadActiveFocus && !d->m_readOnly)
hasActiveFocus()Description
TRUEevaluated 62 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
hadActiveFocusDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquicktextinput
!d->m_readOnlyDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquicktextinput
2-62
1878 qGuiApp->inputMethod()->show();
executed 36 times by 1 test: (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->show();
Executed by:
  • tst_qquicktextinput
36
1879#else-
1880 Q_UNUSED(hadActiveFocus);-
1881#endif-
1882}
executed 64 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
64
1883-
1884QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)-
1885{-
1886 Q_UNUSED(data);-
1887 Q_D(QQuickTextInput);-
1888-
1889 if (d->updateType != QQuickTextInputPrivate::UpdatePaintNode && oldNode != nullptr) {
d->updateType ...pdatePaintNodeDescription
TRUEnever evaluated
FALSEevaluated 297 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
oldNode != nullptrDescription
TRUEnever evaluated
FALSEnever evaluated
0-297
1890 // Update done in preprocess() in the nodes-
1891 d->updateType = QQuickTextInputPrivate::UpdateNone;-
1892 return oldNode;
never executed: return oldNode;
0
1893 }-
1894-
1895 d->updateType = QQuickTextInputPrivate::UpdateNone;-
1896-
1897 QQuickTextNode *node = static_cast<QQuickTextNode *>(oldNode);-
1898 if (node == nullptr)
node == nullptrDescription
TRUEevaluated 162 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 135 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
135-162
1899 node = new QQuickTextNode(this);
executed 162 times by 4 tests: node = new QQuickTextNode(this);
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
162
1900 d->textNode = node;-
1901-
1902 const bool showCursor = !isReadOnly() && d->cursorItem == nullptr && d->cursorVisible && d->m_blinkStatus;
!isReadOnly()Description
TRUEevaluated 267 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
d->cursorItem == nullptrDescription
TRUEevaluated 236 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 31 times by 1 test
Evaluated by:
  • tst_qquicktextinput
d->cursorVisibleDescription
TRUEevaluated 69 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 167 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
d->m_blinkStatusDescription
TRUEevaluated 66 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qquicktextinput
3-267
1903-
1904 if (!d->textLayoutDirty && oldNode != nullptr) {
!d->textLayoutDirtyDescription
TRUEevaluated 86 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 211 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
oldNode != nullptrDescription
TRUEevaluated 86 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEnever evaluated
0-211
1905 if (showCursor)
showCursorDescription
TRUEevaluated 26 times by 3 tests
Evaluated by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 60 times by 2 tests
Evaluated by:
  • tst_qquickitem2
  • tst_qquicktextinput
26-60
1906 node->setCursor(cursorRectangle(), d->color);
executed 26 times by 3 tests: node->setCursor(cursorRectangle(), d->color);
Executed by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
26
1907 else-
1908 node->clearCursor();
executed 60 times by 2 tests: node->clearCursor();
Executed by:
  • tst_qquickitem2
  • tst_qquicktextinput
60
1909 } else {-
1910 node->setUseNativeRenderer(d->renderType == NativeRendering);-
1911 node->deleteContent();-
1912 node->setMatrix(QMatrix4x4());-
1913-
1914 QPointF offset(leftPadding(), topPadding());-
1915 if (d->autoScroll && d->m_textLayout.lineCount() > 0) {
d->autoScrollDescription
TRUEevaluated 209 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
d->m_textLayou...ineCount() > 0Description
TRUEevaluated 209 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEnever evaluated
0-209
1916 QFontMetricsF fm(d->font);-
1917 // the y offset is there to keep the baseline constant in case we have script changes in the text.-
1918 offset += -QPointF(d->hscroll, d->vscroll + d->m_textLayout.lineAt(0).ascent() - fm.ascent());-
1919 } else {
executed 209 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
209
1920 offset += -QPointF(d->hscroll, d->vscroll);-
1921 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
2
1922-
1923 if (!d->m_textLayout.text().isEmpty()
!d->m_textLayo...xt().isEmpty()Description
TRUEevaluated 145 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
FALSEevaluated 66 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
66-145
1924#if QT_CONFIG(im)-
1925 || !d->m_textLayout.preeditAreaText().isEmpty()
!d->m_textLayo...xt().isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 64 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
2-64
1926#endif-
1927 ) {-
1928 node->addTextLayout(offset, &d->m_textLayout, d->color,-
1929 QQuickText::Normal, QColor(), QColor(),-
1930 d->selectionColor, d->selectedTextColor,-
1931 d->selectionStart(),-
1932 d->selectionEnd() - 1); // selectionEnd() returns first char after-
1933 // selection-
1934 }
executed 147 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
147
1935-
1936 if (showCursor)
showCursorDescription
TRUEevaluated 40 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktextinput
FALSEevaluated 171 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
40-171
1937 node->setCursor(cursorRectangle(), d->color);
executed 40 times by 2 tests: node->setCursor(cursorRectangle(), d->color);
Executed by:
  • tst_examples
  • tst_qquicktextinput
40
1938-
1939 d->textLayoutDirty = false;-
1940 }
executed 211 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
211
1941-
1942 invalidateFontCaches();-
1943-
1944 return node;
executed 297 times by 4 tests: return node;
Executed by:
  • tst_examples
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
297
1945}-
1946-
1947#if QT_CONFIG(im)-
1948QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property) const-
1949{-
1950 return inputMethodQuery(property, QVariant());
executed 1279 times by 3 tests: return inputMethodQuery(property, QVariant());
Executed by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
1279
1951}-
1952-
1953QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const-
1954{-
1955 Q_D(const QQuickTextInput);-
1956 switch (property) {-
1957 case Qt::ImEnabled:
executed 531 times by 3 tests: case Qt::ImEnabled:
Executed by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
531
1958 return QVariant((bool)(flags() & ItemAcceptsInputMethod));
executed 531 times by 3 tests: return QVariant((bool)(flags() & ItemAcceptsInputMethod));
Executed by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
531
1959 case Qt::ImHints:
executed 396 times by 3 tests: case Qt::ImHints:
Executed by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
396
1960 return QVariant((int) d->effectiveInputMethodHints());
executed 396 times by 3 tests: return QVariant((int) d->effectiveInputMethodHints());
Executed by:
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktextinput
396
1961 case Qt::ImCursorRectangle:
executed 344 times by 1 test: case Qt::ImCursorRectangle:
Executed by:
  • tst_qquicktextinput
344
1962 return cursorRectangle();
executed 344 times by 1 test: return cursorRectangle();
Executed by:
  • tst_qquicktextinput
344
1963 case Qt::ImAnchorRectangle:
never executed: case Qt::ImAnchorRectangle:
0
1964 return d->anchorRectangle();
never executed: return d->anchorRectangle();
0
1965 case Qt::ImFont:
never executed: case Qt::ImFont:
0
1966 return font();
never executed: return font();
0
1967 case Qt::ImCursorPosition: {
never executed: case Qt::ImCursorPosition:
0
1968 const QPointF pt = argument.toPointF();-
1969 if (!pt.isNull())
!pt.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1970 return QVariant(d->positionAt(pt));
never executed: return QVariant(d->positionAt(pt));
0
1971 return QVariant(d->m_cursor);
never executed: return QVariant(d->m_cursor);
0
1972 }-
1973 case Qt::ImSurroundingText:
executed 8 times by 1 test: case Qt::ImSurroundingText:
Executed by:
  • tst_qquicktextinput
8
1974 if (d->m_echoMode == PasswordEchoOnEdit && !d->m_passwordEchoEditing) {
d->m_echoMode ...wordEchoOnEditDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEnever evaluated
!d->m_passwordEchoEditingDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
0-8
1975 return QVariant(displayText());
executed 4 times by 1 test: return QVariant(displayText());
Executed by:
  • tst_qquicktextinput
4
1976 } else {-
1977 return QVariant(d->realText());
executed 4 times by 1 test: return QVariant(d->realText());
Executed by:
  • tst_qquicktextinput
4
1978 }-
1979 case Qt::ImCurrentSelection:
never executed: case Qt::ImCurrentSelection:
0
1980 return QVariant(selectedText());
never executed: return QVariant(selectedText());
0
1981 case Qt::ImMaximumTextLength:
never executed: case Qt::ImMaximumTextLength:
0
1982 return QVariant(maxLength());
never executed: return QVariant(maxLength());
0
1983 case Qt::ImAnchorPosition:
never executed: case Qt::ImAnchorPosition:
0
1984 if (d->selectionStart() == d->selectionEnd())
d->selectionSt...selectionEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
1985 return QVariant(d->m_cursor);
never executed: return QVariant(d->m_cursor);
0
1986 else if (d->selectionStart() == d->m_cursor)
d->selectionSt...== d->m_cursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1987 return QVariant(d->selectionEnd());
never executed: return QVariant(d->selectionEnd());
0
1988 else-
1989 return QVariant(d->selectionStart());
never executed: return QVariant(d->selectionStart());
0
1990 case Qt::ImAbsolutePosition:
never executed: case Qt::ImAbsolutePosition:
0
1991 return QVariant(d->m_cursor);
never executed: return QVariant(d->m_cursor);
0
1992 case Qt::ImTextAfterCursor:
never executed: case Qt::ImTextAfterCursor:
0
1993 if (argument.isValid())
argument.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1994 return QVariant(d->m_text.mid(d->m_cursor, argument.toInt()));
never executed: return QVariant(d->m_text.mid(d->m_cursor, argument.toInt()));
0
1995 return QVariant(d->m_text.mid(d->m_cursor));
never executed: return QVariant(d->m_text.mid(d->m_cursor));
0
1996 case Qt::ImTextBeforeCursor:
never executed: case Qt::ImTextBeforeCursor:
0
1997 if (argument.isValid())
argument.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1998 return QVariant(d->m_text.leftRef(d->m_cursor).right(argument.toInt()).toString());
never executed: return QVariant(d->m_text.leftRef(d->m_cursor).right(argument.toInt()).toString());
0
1999 return QVariant(d->m_text.left(d->m_cursor));
never executed: return QVariant(d->m_text.left(d->m_cursor));
0
2000 default:
never executed: default:
0
2001 return QQuickItem::inputMethodQuery(property);
never executed: return QQuickItem::inputMethodQuery(property);
0
2002 }-
2003}-
2004#endif // im-
2005-
2006/*!-
2007 \qmlmethod QtQuick::TextInput::deselect()-
2008-
2009 Removes active text selection.-
2010*/-
2011void QQuickTextInput::deselect()-
2012{-
2013 Q_D(QQuickTextInput);-
2014 d->deselect();-
2015}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
4
2016-
2017/*!-
2018 \qmlmethod QtQuick::TextInput::selectAll()-
2019-
2020 Causes all text to be selected.-
2021*/-
2022void QQuickTextInput::selectAll()-
2023{-
2024 Q_D(QQuickTextInput);-
2025 d->setSelection(0, text().length());-
2026}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquicktextinput
20
2027-
2028/*!-
2029 \qmlmethod QtQuick::TextInput::isRightToLeft(int start, int end)-
2030-
2031 Returns true if the natural reading direction of the editor text-
2032 found between positions \a start and \a end is right to left.-
2033*/-
2034bool QQuickTextInput::isRightToLeft(int start, int end)-
2035{-
2036 if (start > end) {
start > endDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquicktextinput
FALSEevaluated 164 times by 1 test
Evaluated by:
  • tst_qquicktextinput
4-164
2037 qmlWarning(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";-
2038 return false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_qquicktextinput
4
2039 } else {-
2040 return text().midRef(start, end - start).isRightToLeft();
executed 164 times by 1 test: return text().midRef(start, end - start).isRightToLeft();
Executed by:
  • tst_qquicktextinput
164
2041 }-
2042}-
2043-
2044#if QT_CONFIG(clipboard)-
2045/*!-
2046 \qmlmethod QtQuick::TextInput::cut()-
2047-
2048 Moves the currently selected text to the system clipboard.-
2049-
2050 \note If the echo mode is set to a mode other than Normal then cut-
2051 will not work. This is to prevent using cut as a method of bypassing-
2052 password features of the line control.-