Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicktextedit.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
24 | ** | - | ||||||||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
35 | ** | - | ||||||||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
37 | ** | - | ||||||||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | #include "qquicktextedit_p.h" | - | ||||||||||||||||||||||||
41 | #include "qquicktextedit_p_p.h" | - | ||||||||||||||||||||||||
42 | #include "qquicktextcontrol_p.h" | - | ||||||||||||||||||||||||
43 | #include "qquicktextdocument_p.h" | - | ||||||||||||||||||||||||
44 | #include "qquickevents_p_p.h" | - | ||||||||||||||||||||||||
45 | #include "qquickwindow.h" | - | ||||||||||||||||||||||||
46 | #include "qquicktextnode_p.h" | - | ||||||||||||||||||||||||
47 | #include "qquicktextnodeengine_p.h" | - | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | #include <QtCore/qmath.h> | - | ||||||||||||||||||||||||
50 | #include <QtGui/qguiapplication.h> | - | ||||||||||||||||||||||||
51 | #include <QtGui/qevent.h> | - | ||||||||||||||||||||||||
52 | #include <QtGui/qpainter.h> | - | ||||||||||||||||||||||||
53 | #include <QtGui/qtextobject.h> | - | ||||||||||||||||||||||||
54 | #include <QtGui/qtexttable.h> | - | ||||||||||||||||||||||||
55 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||||||||
56 | #include <QtQuick/qsgsimplerectnode.h> | - | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||||||||
59 | #include <private/qqmlproperty_p.h> | - | ||||||||||||||||||||||||
60 | #include <private/qtextengine_p.h> | - | ||||||||||||||||||||||||
61 | #include <private/qsgadaptationlayer_p.h> | - | ||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | #include "qquicktextdocument.h" | - | ||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||
65 | #include <algorithm> | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | /*! | - | ||||||||||||||||||||||||
70 | \qmltype TextEdit | - | ||||||||||||||||||||||||
71 | \instantiates QQuickTextEdit | - | ||||||||||||||||||||||||
72 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
73 | \ingroup qtquick-visual | - | ||||||||||||||||||||||||
74 | \ingroup qtquick-input | - | ||||||||||||||||||||||||
75 | \inherits Item | - | ||||||||||||||||||||||||
76 | \brief Displays multiple lines of editable formatted text. | - | ||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | The TextEdit item displays a block of editable, formatted text. | - | ||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | It can display both plain and rich text. For example: | - | ||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | \qml | - | ||||||||||||||||||||||||
83 | TextEdit { | - | ||||||||||||||||||||||||
84 | width: 240 | - | ||||||||||||||||||||||||
85 | text: "<b>Hello</b> <i>World!</i>" | - | ||||||||||||||||||||||||
86 | font.family: "Helvetica" | - | ||||||||||||||||||||||||
87 | font.pointSize: 20 | - | ||||||||||||||||||||||||
88 | color: "blue" | - | ||||||||||||||||||||||||
89 | focus: true | - | ||||||||||||||||||||||||
90 | } | - | ||||||||||||||||||||||||
91 | \endqml | - | ||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | \image declarative-textedit.gif | - | ||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||
95 | Setting \l {Item::focus}{focus} to \c true enables the TextEdit item to receive keyboard focus. | - | ||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific | - | ||||||||||||||||||||||||
98 | to a look-and-feel. For example, to add flickable scrolling that follows the cursor: | - | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | \snippet qml/texteditor.qml 0 | - | ||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||
102 | A particular look-and-feel might use smooth scrolling (eg. using SmoothedAnimation), might have a visible | - | ||||||||||||||||||||||||
103 | scrollbar, or a scrollbar that fades in to show location, etc. | - | ||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | Clipboard support is provided by the cut(), copy(), and paste() functions, and the selection can | - | ||||||||||||||||||||||||
106 | be handled in a traditional "mouse" mechanism by setting selectByMouse, or handled completely | - | ||||||||||||||||||||||||
107 | from QML by manipulating selectionStart and selectionEnd, or using selectAll() or selectWord(). | - | ||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | You can translate between cursor positions (characters from the start of the document) and pixel | - | ||||||||||||||||||||||||
110 | points using positionAt() and positionToRectangle(). | - | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | \sa Text, TextInput | - | ||||||||||||||||||||||||
113 | */ | - | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | /*! | - | ||||||||||||||||||||||||
116 | \qmlsignal QtQuick::TextEdit::linkActivated(string link) | - | ||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||
118 | This signal is emitted when the user clicks on a link embedded in the text. | - | ||||||||||||||||||||||||
119 | The link must be in rich text or HTML format and the | - | ||||||||||||||||||||||||
120 | \a link string provides access to the particular link. | - | ||||||||||||||||||||||||
121 | - | |||||||||||||||||||||||||
122 | The corresponding handler is \c onLinkActivated. | - | ||||||||||||||||||||||||
123 | */ | - | ||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | // This is a pretty arbitrary figure. The idea is that we don't want to break down the document | - | ||||||||||||||||||||||||
126 | // into text nodes corresponding to a text block each so that the glyph node grouping doesn't become pointless. | - | ||||||||||||||||||||||||
127 | static const int nodeBreakingSize = 300; | - | ||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | namespace { | - | ||||||||||||||||||||||||
130 | class ProtectedLayoutAccessor: public QAbstractTextDocumentLayout | - | ||||||||||||||||||||||||
131 | { | - | ||||||||||||||||||||||||
132 | public: | - | ||||||||||||||||||||||||
133 | inline QTextCharFormat formatAccessor(int pos) | - | ||||||||||||||||||||||||
134 | { | - | ||||||||||||||||||||||||
135 | return format(pos); never executed: return format(pos); | 0 | ||||||||||||||||||||||||
136 | } | - | ||||||||||||||||||||||||
137 | }; | - | ||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||
139 | class RootNode : public QSGTransformNode | - | ||||||||||||||||||||||||
140 | { | - | ||||||||||||||||||||||||
141 | public: | - | ||||||||||||||||||||||||
142 | RootNode() : cursorNode(nullptr), frameDecorationsNode(nullptr) | - | ||||||||||||||||||||||||
143 | { } executed 234 times by 4 tests: end of block Executed by:
| 234 | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | void resetFrameDecorations(QQuickTextNode* newNode) | - | ||||||||||||||||||||||||
146 | { | - | ||||||||||||||||||||||||
147 | if (frameDecorationsNode) {
| 58-234 | ||||||||||||||||||||||||
148 | removeChildNode(frameDecorationsNode); | - | ||||||||||||||||||||||||
149 | delete frameDecorationsNode; | - | ||||||||||||||||||||||||
150 | } executed 58 times by 1 test: end of block Executed by:
| 58 | ||||||||||||||||||||||||
151 | frameDecorationsNode = newNode; | - | ||||||||||||||||||||||||
152 | newNode->setFlag(QSGNode::OwnedByParent); | - | ||||||||||||||||||||||||
153 | } executed 292 times by 4 tests: end of block Executed by:
| 292 | ||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||
155 | void resetCursorNode(QSGInternalRectangleNode* newNode) | - | ||||||||||||||||||||||||
156 | { | - | ||||||||||||||||||||||||
157 | if (cursorNode)
| 12-324 | ||||||||||||||||||||||||
158 | removeChildNode(cursorNode); executed 12 times by 1 test: removeChildNode(cursorNode); Executed by:
| 12 | ||||||||||||||||||||||||
159 | delete cursorNode; | - | ||||||||||||||||||||||||
160 | cursorNode = newNode; | - | ||||||||||||||||||||||||
161 | if (cursorNode) {
| 140-196 | ||||||||||||||||||||||||
162 | appendChildNode(cursorNode); | - | ||||||||||||||||||||||||
163 | cursorNode->setFlag(QSGNode::OwnedByParent); | - | ||||||||||||||||||||||||
164 | } executed 140 times by 3 tests: end of block Executed by:
| 140 | ||||||||||||||||||||||||
165 | } executed 336 times by 4 tests: end of block Executed by:
| 336 | ||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||
167 | QSGInternalRectangleNode *cursorNode; | - | ||||||||||||||||||||||||
168 | QQuickTextNode* frameDecorationsNode; | - | ||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||
170 | }; | - | ||||||||||||||||||||||||
171 | } | - | ||||||||||||||||||||||||
172 | - | |||||||||||||||||||||||||
173 | QQuickTextEdit::QQuickTextEdit(QQuickItem *parent) | - | ||||||||||||||||||||||||
174 | : QQuickImplicitSizeItem(*(new QQuickTextEditPrivate), parent) | - | ||||||||||||||||||||||||
175 | { | - | ||||||||||||||||||||||||
176 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
177 | d->init(); | - | ||||||||||||||||||||||||
178 | } executed 1076 times by 6 tests: end of block Executed by:
| 1076 | ||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | QQuickTextEdit::QQuickTextEdit(QQuickTextEditPrivate &dd, QQuickItem *parent) | - | ||||||||||||||||||||||||
181 | : QQuickImplicitSizeItem(dd, parent) | - | ||||||||||||||||||||||||
182 | { | - | ||||||||||||||||||||||||
183 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
184 | d->init(); | - | ||||||||||||||||||||||||
185 | } never executed: end of block | 0 | ||||||||||||||||||||||||
186 | - | |||||||||||||||||||||||||
187 | QString QQuickTextEdit::text() const | - | ||||||||||||||||||||||||
188 | { | - | ||||||||||||||||||||||||
189 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
190 | if (!d->textCached && isComponentComplete()) {
| 168-1496 | ||||||||||||||||||||||||
191 | QQuickTextEditPrivate *d = const_cast<QQuickTextEditPrivate *>(d_func()); | - | ||||||||||||||||||||||||
192 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
193 | if (d->richText)
| 22-510 | ||||||||||||||||||||||||
194 | d->text = d->control->toHtml(); executed 22 times by 1 test: d->text = d->control->toHtml(); Executed by:
| 22 | ||||||||||||||||||||||||
195 | else | - | ||||||||||||||||||||||||
196 | #endif | - | ||||||||||||||||||||||||
197 | d->text = d->control->toPlainText(); executed 510 times by 2 tests: d->text = d->control->toPlainText(); Executed by:
| 510 | ||||||||||||||||||||||||
198 | d->textCached = true; | - | ||||||||||||||||||||||||
199 | } executed 532 times by 2 tests: end of block Executed by:
| 532 | ||||||||||||||||||||||||
200 | return d->text; executed 1664 times by 5 tests: return d->text; Executed by:
| 1664 | ||||||||||||||||||||||||
201 | } | - | ||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | /*! | - | ||||||||||||||||||||||||
204 | \qmlproperty string QtQuick::TextEdit::font.family | - | ||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | Sets the family name of the font. | - | ||||||||||||||||||||||||
207 | - | |||||||||||||||||||||||||
208 | The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". | - | ||||||||||||||||||||||||
209 | If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. | - | ||||||||||||||||||||||||
210 | If the family isn't available a family will be set using the font matching algorithm. | - | ||||||||||||||||||||||||
211 | */ | - | ||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||
213 | /*! | - | ||||||||||||||||||||||||
214 | \qmlproperty string QtQuick::TextEdit::font.styleName | - | ||||||||||||||||||||||||
215 | \since 5.6 | - | ||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||
217 | Sets the style name of the font. | - | ||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||
219 | The style name is case insensitive. If set, the font will be matched against style name instead | - | ||||||||||||||||||||||||
220 | of the font properties \l font.weight, \l font.bold and \l font.italic. | - | ||||||||||||||||||||||||
221 | */ | - | ||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||
224 | /*! | - | ||||||||||||||||||||||||
225 | \qmlproperty bool QtQuick::TextEdit::font.bold | - | ||||||||||||||||||||||||
226 | - | |||||||||||||||||||||||||
227 | Sets whether the font weight is bold. | - | ||||||||||||||||||||||||
228 | */ | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | /*! | - | ||||||||||||||||||||||||
231 | \qmlproperty enumeration QtQuick::TextEdit::font.weight | - | ||||||||||||||||||||||||
232 | - | |||||||||||||||||||||||||
233 | Sets the font's weight. | - | ||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||
235 | The weight can be one of: | - | ||||||||||||||||||||||||
236 | \list | - | ||||||||||||||||||||||||
237 | \li Font.Thin | - | ||||||||||||||||||||||||
238 | \li Font.Light | - | ||||||||||||||||||||||||
239 | \li Font.ExtraLight | - | ||||||||||||||||||||||||
240 | \li Font.Normal - the default | - | ||||||||||||||||||||||||
241 | \li Font.Medium | - | ||||||||||||||||||||||||
242 | \li Font.DemiBold | - | ||||||||||||||||||||||||
243 | \li Font.Bold | - | ||||||||||||||||||||||||
244 | \li Font.ExtraBold | - | ||||||||||||||||||||||||
245 | \li Font.Black | - | ||||||||||||||||||||||||
246 | \endlist | - | ||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | \qml | - | ||||||||||||||||||||||||
249 | TextEdit { text: "Hello"; font.weight: Font.DemiBold } | - | ||||||||||||||||||||||||
250 | \endqml | - | ||||||||||||||||||||||||
251 | */ | - | ||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||
253 | /*! | - | ||||||||||||||||||||||||
254 | \qmlproperty bool QtQuick::TextEdit::font.italic | - | ||||||||||||||||||||||||
255 | - | |||||||||||||||||||||||||
256 | Sets whether the font has an italic style. | - | ||||||||||||||||||||||||
257 | */ | - | ||||||||||||||||||||||||
258 | - | |||||||||||||||||||||||||
259 | /*! | - | ||||||||||||||||||||||||
260 | \qmlproperty bool QtQuick::TextEdit::font.underline | - | ||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | Sets whether the text is underlined. | - | ||||||||||||||||||||||||
263 | */ | - | ||||||||||||||||||||||||
264 | - | |||||||||||||||||||||||||
265 | /*! | - | ||||||||||||||||||||||||
266 | \qmlproperty bool QtQuick::TextEdit::font.strikeout | - | ||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||
268 | Sets whether the font has a strikeout style. | - | ||||||||||||||||||||||||
269 | */ | - | ||||||||||||||||||||||||
270 | - | |||||||||||||||||||||||||
271 | /*! | - | ||||||||||||||||||||||||
272 | \qmlproperty real QtQuick::TextEdit::font.pointSize | - | ||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | Sets the font size in points. The point size must be greater than zero. | - | ||||||||||||||||||||||||
275 | */ | - | ||||||||||||||||||||||||
276 | - | |||||||||||||||||||||||||
277 | /*! | - | ||||||||||||||||||||||||
278 | \qmlproperty int QtQuick::TextEdit::font.pixelSize | - | ||||||||||||||||||||||||
279 | - | |||||||||||||||||||||||||
280 | Sets the font size in pixels. | - | ||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | Using this function makes the font device dependent. Use | - | ||||||||||||||||||||||||
283 | \l{TextEdit::font.pointSize} to set the size of the font in a | - | ||||||||||||||||||||||||
284 | device independent manner. | - | ||||||||||||||||||||||||
285 | */ | - | ||||||||||||||||||||||||
286 | - | |||||||||||||||||||||||||
287 | /*! | - | ||||||||||||||||||||||||
288 | \qmlproperty real QtQuick::TextEdit::font.letterSpacing | - | ||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||
290 | Sets the letter spacing for the font. | - | ||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | Letter spacing changes the default spacing between individual letters in the font. | - | ||||||||||||||||||||||||
293 | A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. | - | ||||||||||||||||||||||||
294 | */ | - | ||||||||||||||||||||||||
295 | - | |||||||||||||||||||||||||
296 | /*! | - | ||||||||||||||||||||||||
297 | \qmlproperty real QtQuick::TextEdit::font.wordSpacing | - | ||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||
299 | Sets the word spacing for the font. | - | ||||||||||||||||||||||||
300 | - | |||||||||||||||||||||||||
301 | Word spacing changes the default spacing between individual words. | - | ||||||||||||||||||||||||
302 | A positive value increases the word spacing by a corresponding amount of pixels, | - | ||||||||||||||||||||||||
303 | while a negative value decreases the inter-word spacing accordingly. | - | ||||||||||||||||||||||||
304 | */ | - | ||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | /*! | - | ||||||||||||||||||||||||
307 | \qmlproperty enumeration QtQuick::TextEdit::font.capitalization | - | ||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | Sets the capitalization for the text. | - | ||||||||||||||||||||||||
310 | - | |||||||||||||||||||||||||
311 | \list | - | ||||||||||||||||||||||||
312 | \li Font.MixedCase - This is the normal text rendering option where no capitalization change is applied. | - | ||||||||||||||||||||||||
313 | \li Font.AllUppercase - This alters the text to be rendered in all uppercase type. | - | ||||||||||||||||||||||||
314 | \li Font.AllLowercase - This alters the text to be rendered in all lowercase type. | - | ||||||||||||||||||||||||
315 | \li Font.SmallCaps - This alters the text to be rendered in small-caps type. | - | ||||||||||||||||||||||||
316 | \li Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character. | - | ||||||||||||||||||||||||
317 | \endlist | - | ||||||||||||||||||||||||
318 | - | |||||||||||||||||||||||||
319 | \qml | - | ||||||||||||||||||||||||
320 | TextEdit { text: "Hello"; font.capitalization: Font.AllLowercase } | - | ||||||||||||||||||||||||
321 | \endqml | - | ||||||||||||||||||||||||
322 | */ | - | ||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | /*! | - | ||||||||||||||||||||||||
325 | \qmlproperty enumeration QtQuick::TextEdit::font.hintingPreference | - | ||||||||||||||||||||||||
326 | \since 5.8 | - | ||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||
328 | Sets the preferred hinting on the text. This is a hint to the underlying text rendering system | - | ||||||||||||||||||||||||
329 | to use a certain level of hinting, and has varying support across platforms. See the table in | - | ||||||||||||||||||||||||
330 | the documentation for QFont::HintingPreference for more details. | - | ||||||||||||||||||||||||
331 | - | |||||||||||||||||||||||||
332 | \note This property only has an effect when used together with render type TextEdit.NativeRendering. | - | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | \list | - | ||||||||||||||||||||||||
335 | \value Font.PreferDefaultHinting - Use the default hinting level for the target platform. | - | ||||||||||||||||||||||||
336 | \value Font.PreferNoHinting - If possible, render text without hinting the outlines | - | ||||||||||||||||||||||||
337 | of the glyphs. The text layout will be typographically accurate, using the same metrics | - | ||||||||||||||||||||||||
338 | as are used e.g. when printing. | - | ||||||||||||||||||||||||
339 | \value Font.PreferVerticalHinting - If possible, render text with no horizontal hinting, | - | ||||||||||||||||||||||||
340 | but align glyphs to the pixel grid in the vertical direction. The text will appear | - | ||||||||||||||||||||||||
341 | crisper on displays where the density is too low to give an accurate rendering | - | ||||||||||||||||||||||||
342 | of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's | - | ||||||||||||||||||||||||
343 | layout will be scalable to higher density devices (such as printers) without impacting | - | ||||||||||||||||||||||||
344 | details such as line breaks. | - | ||||||||||||||||||||||||
345 | \value Font.PreferFullHinting - If possible, render text with hinting in both horizontal and | - | ||||||||||||||||||||||||
346 | vertical directions. The text will be altered to optimize legibility on the target | - | ||||||||||||||||||||||||
347 | device, but since the metrics will depend on the target size of the text, the positions | - | ||||||||||||||||||||||||
348 | of glyphs, line breaks, and other typographical detail will not scale, meaning that a | - | ||||||||||||||||||||||||
349 | text layout may look different on devices with different pixel densities. | - | ||||||||||||||||||||||||
350 | \endlist | - | ||||||||||||||||||||||||
351 | - | |||||||||||||||||||||||||
352 | \qml | - | ||||||||||||||||||||||||
353 | TextEdit { text: "Hello"; renderType: TextEdit.NativeRendering; font.hintingPreference: Font.PreferVerticalHinting } | - | ||||||||||||||||||||||||
354 | \endqml | - | ||||||||||||||||||||||||
355 | */ | - | ||||||||||||||||||||||||
356 | - | |||||||||||||||||||||||||
357 | /*! | - | ||||||||||||||||||||||||
358 | \qmlproperty bool QtQuick::TextEdit::font.kerning | - | ||||||||||||||||||||||||
359 | \since 5.10 | - | ||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||
361 | Enables or disables the kerning OpenType feature when shaping the text. Disabling this may | - | ||||||||||||||||||||||||
362 | improve performance when creating or changing the text, at the expense of some cosmetic | - | ||||||||||||||||||||||||
363 | features. The default value is true. | - | ||||||||||||||||||||||||
364 | - | |||||||||||||||||||||||||
365 | \qml | - | ||||||||||||||||||||||||
366 | TextEdit { text: "OATS FLAVOUR WAY"; kerning: font.false } | - | ||||||||||||||||||||||||
367 | \endqml | - | ||||||||||||||||||||||||
368 | */ | - | ||||||||||||||||||||||||
369 | - | |||||||||||||||||||||||||
370 | /*! | - | ||||||||||||||||||||||||
371 | \qmlproperty bool QtQuick::TextEdit::font.preferShaping | - | ||||||||||||||||||||||||
372 | \since 5.10 | - | ||||||||||||||||||||||||
373 | - | |||||||||||||||||||||||||
374 | Sometimes, a font will apply complex rules to a set of characters in order to | - | ||||||||||||||||||||||||
375 | display them correctly. In some writing systems, such as Brahmic scripts, this is | - | ||||||||||||||||||||||||
376 | required in order for the text to be legible, but in e.g. Latin script, it is merely | - | ||||||||||||||||||||||||
377 | a cosmetic feature. Setting the \c preferShaping property to false will disable all | - | ||||||||||||||||||||||||
378 | such features when they are not required, which will improve performance in most cases. | - | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | The default value is true. | - | ||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | \qml | - | ||||||||||||||||||||||||
383 | TextEdit { text: "Some text"; font.preferShaping: false } | - | ||||||||||||||||||||||||
384 | \endqml | - | ||||||||||||||||||||||||
385 | */ | - | ||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||
387 | /*! | - | ||||||||||||||||||||||||
388 | \qmlproperty string QtQuick::TextEdit::text | - | ||||||||||||||||||||||||
389 | - | |||||||||||||||||||||||||
390 | The text to display. If the text format is AutoText the text edit will | - | ||||||||||||||||||||||||
391 | automatically determine whether the text should be treated as | - | ||||||||||||||||||||||||
392 | rich text. This determination is made using Qt::mightBeRichText(). | - | ||||||||||||||||||||||||
393 | - | |||||||||||||||||||||||||
394 | The text-property is mostly suitable for setting the initial content and | - | ||||||||||||||||||||||||
395 | handling modifications to relatively small text content. The append(), | - | ||||||||||||||||||||||||
396 | insert() and remove() methods provide more fine-grained control and | - | ||||||||||||||||||||||||
397 | remarkably better performance for modifying especially large rich text | - | ||||||||||||||||||||||||
398 | content. | - | ||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||
400 | \sa clear() | - | ||||||||||||||||||||||||
401 | */ | - | ||||||||||||||||||||||||
402 | void QQuickTextEdit::setText(const QString &text) | - | ||||||||||||||||||||||||
403 | { | - | ||||||||||||||||||||||||
404 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
405 | if (QQuickTextEdit::text() == text)
| 16-1052 | ||||||||||||||||||||||||
406 | return; executed 16 times by 3 tests: return; Executed by:
| 16 | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | d->document->clearResources(); | - | ||||||||||||||||||||||||
409 | d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text));
| 6-1010 | ||||||||||||||||||||||||
410 | if (!isComponentComplete()) {
| 152-900 | ||||||||||||||||||||||||
411 | d->text = text; | - | ||||||||||||||||||||||||
412 | } else if (d->richText) { executed 900 times by 4 tests: end of block Executed by:
| 10-900 | ||||||||||||||||||||||||
413 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
414 | d->control->setHtml(text); | - | ||||||||||||||||||||||||
415 | #else | - | ||||||||||||||||||||||||
416 | d->control->setPlainText(text); | - | ||||||||||||||||||||||||
417 | #endif | - | ||||||||||||||||||||||||
418 | } else { executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
419 | d->control->setPlainText(text); | - | ||||||||||||||||||||||||
420 | } executed 142 times by 2 tests: end of block Executed by:
| 142 | ||||||||||||||||||||||||
421 | } | - | ||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||
423 | /*! | - | ||||||||||||||||||||||||
424 | \qmlproperty string QtQuick::TextEdit::preeditText | - | ||||||||||||||||||||||||
425 | \readonly | - | ||||||||||||||||||||||||
426 | \since 5.7 | - | ||||||||||||||||||||||||
427 | - | |||||||||||||||||||||||||
428 | This property contains partial text input from an input method. | - | ||||||||||||||||||||||||
429 | */ | - | ||||||||||||||||||||||||
430 | QString QQuickTextEdit::preeditText() const | - | ||||||||||||||||||||||||
431 | { | - | ||||||||||||||||||||||||
432 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
433 | return d->control->preeditText(); executed 8 times by 1 test: return d->control->preeditText(); Executed by:
| 8 | ||||||||||||||||||||||||
434 | } | - | ||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | /*! | - | ||||||||||||||||||||||||
437 | \qmlproperty enumeration QtQuick::TextEdit::textFormat | - | ||||||||||||||||||||||||
438 | - | |||||||||||||||||||||||||
439 | The way the text property should be displayed. | - | ||||||||||||||||||||||||
440 | - | |||||||||||||||||||||||||
441 | \list | - | ||||||||||||||||||||||||
442 | \li TextEdit.AutoText | - | ||||||||||||||||||||||||
443 | \li TextEdit.PlainText | - | ||||||||||||||||||||||||
444 | \li TextEdit.RichText | - | ||||||||||||||||||||||||
445 | \endlist | - | ||||||||||||||||||||||||
446 | - | |||||||||||||||||||||||||
447 | The default is TextEdit.PlainText. If the text format is TextEdit.AutoText the text edit | - | ||||||||||||||||||||||||
448 | will automatically determine whether the text should be treated as | - | ||||||||||||||||||||||||
449 | rich text. This determination is made using Qt::mightBeRichText(). | - | ||||||||||||||||||||||||
450 | - | |||||||||||||||||||||||||
451 | \table | - | ||||||||||||||||||||||||
452 | \row | - | ||||||||||||||||||||||||
453 | \li | - | ||||||||||||||||||||||||
454 | \qml | - | ||||||||||||||||||||||||
455 | Column { | - | ||||||||||||||||||||||||
456 | TextEdit { | - | ||||||||||||||||||||||||
457 | font.pointSize: 24 | - | ||||||||||||||||||||||||
458 | text: "<b>Hello</b> <i>World!</i>" | - | ||||||||||||||||||||||||
459 | } | - | ||||||||||||||||||||||||
460 | TextEdit { | - | ||||||||||||||||||||||||
461 | font.pointSize: 24 | - | ||||||||||||||||||||||||
462 | textFormat: TextEdit.RichText | - | ||||||||||||||||||||||||
463 | text: "<b>Hello</b> <i>World!</i>" | - | ||||||||||||||||||||||||
464 | } | - | ||||||||||||||||||||||||
465 | TextEdit { | - | ||||||||||||||||||||||||
466 | font.pointSize: 24 | - | ||||||||||||||||||||||||
467 | textFormat: TextEdit.PlainText | - | ||||||||||||||||||||||||
468 | text: "<b>Hello</b> <i>World!</i>" | - | ||||||||||||||||||||||||
469 | } | - | ||||||||||||||||||||||||
470 | } | - | ||||||||||||||||||||||||
471 | \endqml | - | ||||||||||||||||||||||||
472 | \li \image declarative-textformat.png | - | ||||||||||||||||||||||||
473 | \endtable | - | ||||||||||||||||||||||||
474 | */ | - | ||||||||||||||||||||||||
475 | QQuickTextEdit::TextFormat QQuickTextEdit::textFormat() const | - | ||||||||||||||||||||||||
476 | { | - | ||||||||||||||||||||||||
477 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
478 | return d->format; executed 26 times by 1 test: return d->format; Executed by:
| 26 | ||||||||||||||||||||||||
479 | } | - | ||||||||||||||||||||||||
480 | - | |||||||||||||||||||||||||
481 | void QQuickTextEdit::setTextFormat(TextFormat format) | - | ||||||||||||||||||||||||
482 | { | - | ||||||||||||||||||||||||
483 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
484 | if (format == d->format)
| 116-136 | ||||||||||||||||||||||||
485 | return; executed 116 times by 1 test: return; Executed by:
| 116 | ||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | bool wasRich = d->richText; | - | ||||||||||||||||||||||||
488 | d->richText = format == RichText || (format == AutoText && (wasRich || Qt::mightBeRichText(text())));
| 0-78 | ||||||||||||||||||||||||
489 | - | |||||||||||||||||||||||||
490 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
491 | if (isComponentComplete()) {
| 24-112 | ||||||||||||||||||||||||
492 | if (wasRich && !d->richText) {
| 0-22 | ||||||||||||||||||||||||
493 | d->control->setPlainText(!d->textCached ? d->control->toHtml() : d->text); | - | ||||||||||||||||||||||||
494 | updateSize(); | - | ||||||||||||||||||||||||
495 | } else if (!wasRich && d->richText) { executed 2 times by 1 test: end of block Executed by:
| 0-22 | ||||||||||||||||||||||||
496 | d->control->setHtml(!d->textCached ? d->control->toPlainText() : d->text); | - | ||||||||||||||||||||||||
497 | updateSize(); | - | ||||||||||||||||||||||||
498 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
499 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
500 | #endif | - | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | d->format = format; | - | ||||||||||||||||||||||||
503 | d->control->setAcceptRichText(d->format != PlainText); | - | ||||||||||||||||||||||||
504 | emit textFormatChanged(d->format); | - | ||||||||||||||||||||||||
505 | } executed 136 times by 3 tests: end of block Executed by:
| 136 | ||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||
507 | /*! | - | ||||||||||||||||||||||||
508 | \qmlproperty enumeration QtQuick::TextEdit::renderType | - | ||||||||||||||||||||||||
509 | - | |||||||||||||||||||||||||
510 | Override the default rendering type for this component. | - | ||||||||||||||||||||||||
511 | - | |||||||||||||||||||||||||
512 | Supported render types are: | - | ||||||||||||||||||||||||
513 | \list | - | ||||||||||||||||||||||||
514 | \li Text.QtRendering | - | ||||||||||||||||||||||||
515 | \li Text.NativeRendering | - | ||||||||||||||||||||||||
516 | \endlist | - | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | Select Text.NativeRendering if you prefer text to look native on the target platform and do | - | ||||||||||||||||||||||||
519 | not require advanced features such as transformation of the text. Using such features in | - | ||||||||||||||||||||||||
520 | combination with the NativeRendering render type will lend poor and sometimes pixelated | - | ||||||||||||||||||||||||
521 | results. | - | ||||||||||||||||||||||||
522 | - | |||||||||||||||||||||||||
523 | The default rendering type is determined by \l QQuickWindow::textRenderType(). | - | ||||||||||||||||||||||||
524 | */ | - | ||||||||||||||||||||||||
525 | QQuickTextEdit::RenderType QQuickTextEdit::renderType() const | - | ||||||||||||||||||||||||
526 | { | - | ||||||||||||||||||||||||
527 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
528 | return d->renderType; executed 6 times by 1 test: return d->renderType; Executed by:
| 6 | ||||||||||||||||||||||||
529 | } | - | ||||||||||||||||||||||||
530 | - | |||||||||||||||||||||||||
531 | void QQuickTextEdit::setRenderType(QQuickTextEdit::RenderType renderType) | - | ||||||||||||||||||||||||
532 | { | - | ||||||||||||||||||||||||
533 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
534 | if (d->renderType == renderType)
| 2-4 | ||||||||||||||||||||||||
535 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
536 | - | |||||||||||||||||||||||||
537 | d->renderType = renderType; | - | ||||||||||||||||||||||||
538 | emit renderTypeChanged(); | - | ||||||||||||||||||||||||
539 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
540 | - | |||||||||||||||||||||||||
541 | if (isComponentComplete())
| 0-4 | ||||||||||||||||||||||||
542 | updateSize(); executed 4 times by 1 test: updateSize(); Executed by:
| 4 | ||||||||||||||||||||||||
543 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||
545 | QFont QQuickTextEdit::font() const | - | ||||||||||||||||||||||||
546 | { | - | ||||||||||||||||||||||||
547 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
548 | return d->sourceFont; executed 148 times by 3 tests: return d->sourceFont; Executed by:
| 148 | ||||||||||||||||||||||||
549 | } | - | ||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||
551 | void QQuickTextEdit::setFont(const QFont &font) | - | ||||||||||||||||||||||||
552 | { | - | ||||||||||||||||||||||||
553 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
554 | if (d->sourceFont == font)
| 28-76 | ||||||||||||||||||||||||
555 | return; executed 28 times by 1 test: return; Executed by:
| 28 | ||||||||||||||||||||||||
556 | - | |||||||||||||||||||||||||
557 | d->sourceFont = font; | - | ||||||||||||||||||||||||
558 | QFont oldFont = d->font; | - | ||||||||||||||||||||||||
559 | d->font = font; | - | ||||||||||||||||||||||||
560 | if (d->font.pointSizeF() != -1) {
| 14-62 | ||||||||||||||||||||||||
561 | // 0.5pt resolution | - | ||||||||||||||||||||||||
562 | qreal size = qRound(d->font.pointSizeF()*2.0); | - | ||||||||||||||||||||||||
563 | d->font.setPointSizeF(size/2.0); | - | ||||||||||||||||||||||||
564 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | if (oldFont != d->font) {
| 0-76 | ||||||||||||||||||||||||
567 | d->document->setDefaultFont(d->font); | - | ||||||||||||||||||||||||
568 | if (d->cursorItem) {
| 2-74 | ||||||||||||||||||||||||
569 | d->cursorItem->setHeight(QFontMetrics(d->font).height()); | - | ||||||||||||||||||||||||
570 | moveCursorDelegate(); | - | ||||||||||||||||||||||||
571 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
572 | updateSize(); | - | ||||||||||||||||||||||||
573 | updateWholeDocument(); | - | ||||||||||||||||||||||||
574 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
575 | updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle | Qt::ImFont); | - | ||||||||||||||||||||||||
576 | #endif | - | ||||||||||||||||||||||||
577 | } executed 76 times by 3 tests: end of block Executed by:
| 76 | ||||||||||||||||||||||||
578 | emit fontChanged(d->sourceFont); | - | ||||||||||||||||||||||||
579 | } executed 76 times by 3 tests: end of block Executed by:
| 76 | ||||||||||||||||||||||||
580 | - | |||||||||||||||||||||||||
581 | /*! | - | ||||||||||||||||||||||||
582 | \qmlproperty color QtQuick::TextEdit::color | - | ||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||
584 | The text color. | - | ||||||||||||||||||||||||
585 | - | |||||||||||||||||||||||||
586 | \qml | - | ||||||||||||||||||||||||
587 | // green text using hexadecimal notation | - | ||||||||||||||||||||||||
588 | TextEdit { color: "#00FF00" } | - | ||||||||||||||||||||||||
589 | \endqml | - | ||||||||||||||||||||||||
590 | - | |||||||||||||||||||||||||
591 | \qml | - | ||||||||||||||||||||||||
592 | // steelblue text using SVG color name | - | ||||||||||||||||||||||||
593 | TextEdit { color: "steelblue" } | - | ||||||||||||||||||||||||
594 | \endqml | - | ||||||||||||||||||||||||
595 | */ | - | ||||||||||||||||||||||||
596 | QColor QQuickTextEdit::color() const | - | ||||||||||||||||||||||||
597 | { | - | ||||||||||||||||||||||||
598 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
599 | return d->color; executed 32 times by 1 test: return d->color; Executed by:
| 32 | ||||||||||||||||||||||||
600 | } | - | ||||||||||||||||||||||||
601 | - | |||||||||||||||||||||||||
602 | void QQuickTextEdit::setColor(const QColor &color) | - | ||||||||||||||||||||||||
603 | { | - | ||||||||||||||||||||||||
604 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
605 | if (d->color == color)
| 4-32 | ||||||||||||||||||||||||
606 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
607 | - | |||||||||||||||||||||||||
608 | d->color = color; | - | ||||||||||||||||||||||||
609 | updateWholeDocument(); | - | ||||||||||||||||||||||||
610 | emit colorChanged(d->color); | - | ||||||||||||||||||||||||
611 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||||||||||||||
612 | - | |||||||||||||||||||||||||
613 | /*! | - | ||||||||||||||||||||||||
614 | \qmlproperty color QtQuick::TextEdit::selectionColor | - | ||||||||||||||||||||||||
615 | - | |||||||||||||||||||||||||
616 | The text highlight color, used behind selections. | - | ||||||||||||||||||||||||
617 | */ | - | ||||||||||||||||||||||||
618 | QColor QQuickTextEdit::selectionColor() const | - | ||||||||||||||||||||||||
619 | { | - | ||||||||||||||||||||||||
620 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
621 | return d->selectionColor; executed 30 times by 1 test: return d->selectionColor; Executed by:
| 30 | ||||||||||||||||||||||||
622 | } | - | ||||||||||||||||||||||||
623 | - | |||||||||||||||||||||||||
624 | void QQuickTextEdit::setSelectionColor(const QColor &color) | - | ||||||||||||||||||||||||
625 | { | - | ||||||||||||||||||||||||
626 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
627 | if (d->selectionColor == color)
| 2-28 | ||||||||||||||||||||||||
628 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||
630 | d->selectionColor = color; | - | ||||||||||||||||||||||||
631 | updateWholeDocument(); | - | ||||||||||||||||||||||||
632 | emit selectionColorChanged(d->selectionColor); | - | ||||||||||||||||||||||||
633 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||||||||
634 | - | |||||||||||||||||||||||||
635 | /*! | - | ||||||||||||||||||||||||
636 | \qmlproperty color QtQuick::TextEdit::selectedTextColor | - | ||||||||||||||||||||||||
637 | - | |||||||||||||||||||||||||
638 | The selected text color, used in selections. | - | ||||||||||||||||||||||||
639 | */ | - | ||||||||||||||||||||||||
640 | QColor QQuickTextEdit::selectedTextColor() const | - | ||||||||||||||||||||||||
641 | { | - | ||||||||||||||||||||||||
642 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
643 | return d->selectedTextColor; executed 30 times by 1 test: return d->selectedTextColor; Executed by:
| 30 | ||||||||||||||||||||||||
644 | } | - | ||||||||||||||||||||||||
645 | - | |||||||||||||||||||||||||
646 | void QQuickTextEdit::setSelectedTextColor(const QColor &color) | - | ||||||||||||||||||||||||
647 | { | - | ||||||||||||||||||||||||
648 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
649 | if (d->selectedTextColor == color)
| 4-26 | ||||||||||||||||||||||||
650 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
651 | - | |||||||||||||||||||||||||
652 | d->selectedTextColor = color; | - | ||||||||||||||||||||||||
653 | updateWholeDocument(); | - | ||||||||||||||||||||||||
654 | emit selectedTextColorChanged(d->selectedTextColor); | - | ||||||||||||||||||||||||
655 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
656 | - | |||||||||||||||||||||||||
657 | /*! | - | ||||||||||||||||||||||||
658 | \qmlproperty enumeration QtQuick::TextEdit::horizontalAlignment | - | ||||||||||||||||||||||||
659 | \qmlproperty enumeration QtQuick::TextEdit::verticalAlignment | - | ||||||||||||||||||||||||
660 | \qmlproperty enumeration QtQuick::TextEdit::effectiveHorizontalAlignment | - | ||||||||||||||||||||||||
661 | - | |||||||||||||||||||||||||
662 | Sets the horizontal and vertical alignment of the text within the TextEdit item's | - | ||||||||||||||||||||||||
663 | width and height. By default, the text alignment follows the natural alignment | - | ||||||||||||||||||||||||
664 | of the text, for example text that is read from left to right will be aligned to | - | ||||||||||||||||||||||||
665 | the left. | - | ||||||||||||||||||||||||
666 | - | |||||||||||||||||||||||||
667 | Valid values for \c horizontalAlignment are: | - | ||||||||||||||||||||||||
668 | \list | - | ||||||||||||||||||||||||
669 | \li TextEdit.AlignLeft (default) | - | ||||||||||||||||||||||||
670 | \li TextEdit.AlignRight | - | ||||||||||||||||||||||||
671 | \li TextEdit.AlignHCenter | - | ||||||||||||||||||||||||
672 | \li TextEdit.AlignJustify | - | ||||||||||||||||||||||||
673 | \endlist | - | ||||||||||||||||||||||||
674 | - | |||||||||||||||||||||||||
675 | Valid values for \c verticalAlignment are: | - | ||||||||||||||||||||||||
676 | \list | - | ||||||||||||||||||||||||
677 | \li TextEdit.AlignTop (default) | - | ||||||||||||||||||||||||
678 | \li TextEdit.AlignBottom | - | ||||||||||||||||||||||||
679 | \li TextEdit.AlignVCenter | - | ||||||||||||||||||||||||
680 | \endlist | - | ||||||||||||||||||||||||
681 | - | |||||||||||||||||||||||||
682 | When using the attached property LayoutMirroring::enabled to mirror application | - | ||||||||||||||||||||||||
683 | layouts, the horizontal alignment of text will also be mirrored. However, the property | - | ||||||||||||||||||||||||
684 | \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment | - | ||||||||||||||||||||||||
685 | of TextEdit, use the read-only property \c effectiveHorizontalAlignment. | - | ||||||||||||||||||||||||
686 | */ | - | ||||||||||||||||||||||||
687 | QQuickTextEdit::HAlignment QQuickTextEdit::hAlign() const | - | ||||||||||||||||||||||||
688 | { | - | ||||||||||||||||||||||||
689 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
690 | return d->hAlign; executed 122 times by 2 tests: return d->hAlign; Executed by:
| 122 | ||||||||||||||||||||||||
691 | } | - | ||||||||||||||||||||||||
692 | - | |||||||||||||||||||||||||
693 | void QQuickTextEdit::setHAlign(HAlignment align) | - | ||||||||||||||||||||||||
694 | { | - | ||||||||||||||||||||||||
695 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
696 | bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror;
| 2-66 | ||||||||||||||||||||||||
697 | d->hAlignImplicit = false; | - | ||||||||||||||||||||||||
698 | if (d->setHAlign(align, forceAlign) && isComponentComplete()) {
| 22-52 | ||||||||||||||||||||||||
699 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
700 | updateSize(); | - | ||||||||||||||||||||||||
701 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
702 | } executed 74 times by 1 test: end of block Executed by:
| 74 | ||||||||||||||||||||||||
703 | - | |||||||||||||||||||||||||
704 | void QQuickTextEdit::resetHAlign() | - | ||||||||||||||||||||||||
705 | { | - | ||||||||||||||||||||||||
706 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
707 | d->hAlignImplicit = true; | - | ||||||||||||||||||||||||
708 | if (d->determineHorizontalAlignment() && isComponentComplete()) {
| 0-32 | ||||||||||||||||||||||||
709 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
710 | updateSize(); | - | ||||||||||||||||||||||||
711 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
712 | } executed 36 times by 2 tests: end of block Executed by:
| 36 | ||||||||||||||||||||||||
713 | - | |||||||||||||||||||||||||
714 | QQuickTextEdit::HAlignment QQuickTextEdit::effectiveHAlign() const | - | ||||||||||||||||||||||||
715 | { | - | ||||||||||||||||||||||||
716 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
717 | QQuickTextEdit::HAlignment effectiveAlignment = d->hAlign; | - | ||||||||||||||||||||||||
718 | if (!d->hAlignImplicit && d->effectiveLayoutMirror) {
| 20-10458 | ||||||||||||||||||||||||
719 | switch (d->hAlign) { | - | ||||||||||||||||||||||||
720 | case QQuickTextEdit::AlignLeft: executed 8 times by 1 test: case QQuickTextEdit::AlignLeft: Executed by:
| 8 | ||||||||||||||||||||||||
721 | effectiveAlignment = QQuickTextEdit::AlignRight; | - | ||||||||||||||||||||||||
722 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||||||||||||||
723 | case QQuickTextEdit::AlignRight: executed 12 times by 1 test: case QQuickTextEdit::AlignRight: Executed by:
| 12 | ||||||||||||||||||||||||
724 | effectiveAlignment = QQuickTextEdit::AlignLeft; | - | ||||||||||||||||||||||||
725 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||||||||||||||
726 | default: never executed: default: | 0 | ||||||||||||||||||||||||
727 | break; never executed: break; | 0 | ||||||||||||||||||||||||
728 | } | - | ||||||||||||||||||||||||
729 | } | - | ||||||||||||||||||||||||
730 | return effectiveAlignment; executed 10826 times by 6 tests: return effectiveAlignment; Executed by:
| 10826 | ||||||||||||||||||||||||
731 | } | - | ||||||||||||||||||||||||
732 | - | |||||||||||||||||||||||||
733 | bool QQuickTextEditPrivate::setHAlign(QQuickTextEdit::HAlignment alignment, bool forceAlign) | - | ||||||||||||||||||||||||
734 | { | - | ||||||||||||||||||||||||
735 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
736 | if (hAlign != alignment || forceAlign) {
| 2-4226 | ||||||||||||||||||||||||
737 | QQuickTextEdit::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); | - | ||||||||||||||||||||||||
738 | hAlign = alignment; | - | ||||||||||||||||||||||||
739 | emit q->horizontalAlignmentChanged(alignment); | - | ||||||||||||||||||||||||
740 | if (oldEffectiveHAlign != q->effectiveHAlign())
| 2-94 | ||||||||||||||||||||||||
741 | emit q->effectiveHorizontalAlignmentChanged(); executed 94 times by 2 tests: q->effectiveHorizontalAlignmentChanged(); Executed by:
| 94 | ||||||||||||||||||||||||
742 | return true; executed 96 times by 2 tests: return true; Executed by:
| 96 | ||||||||||||||||||||||||
743 | } | - | ||||||||||||||||||||||||
744 | return false; executed 4224 times by 6 tests: return false; Executed by:
| 4224 | ||||||||||||||||||||||||
745 | } | - | ||||||||||||||||||||||||
746 | - | |||||||||||||||||||||||||
747 | - | |||||||||||||||||||||||||
748 | Qt::LayoutDirection QQuickTextEditPrivate::textDirection(const QString &text) const | - | ||||||||||||||||||||||||
749 | { | - | ||||||||||||||||||||||||
750 | const QChar *character = text.constData(); | - | ||||||||||||||||||||||||
751 | while (!character->isNull()) {
| 2692-3978 | ||||||||||||||||||||||||
752 | switch (character->direction()) { | - | ||||||||||||||||||||||||
753 | case QChar::DirL: executed 2448 times by 5 tests: case QChar::DirL: Executed by:
| 2448 | ||||||||||||||||||||||||
754 | return Qt::LeftToRight; executed 2448 times by 5 tests: return Qt::LeftToRight; Executed by:
| 2448 | ||||||||||||||||||||||||
755 | case QChar::DirR: never executed: case QChar::DirR: | 0 | ||||||||||||||||||||||||
756 | case QChar::DirAL: executed 24 times by 2 tests: case QChar::DirAL: Executed by:
| 24 | ||||||||||||||||||||||||
757 | case QChar::DirAN: never executed: case QChar::DirAN: | 0 | ||||||||||||||||||||||||
758 | return Qt::RightToLeft; executed 24 times by 2 tests: return Qt::RightToLeft; Executed by:
| 24 | ||||||||||||||||||||||||
759 | default: executed 1506 times by 2 tests: default: Executed by:
| 1506 | ||||||||||||||||||||||||
760 | break; executed 1506 times by 2 tests: break; Executed by:
| 1506 | ||||||||||||||||||||||||
761 | } | - | ||||||||||||||||||||||||
762 | character++; | - | ||||||||||||||||||||||||
763 | } executed 1506 times by 2 tests: end of block Executed by:
| 1506 | ||||||||||||||||||||||||
764 | return Qt::LayoutDirectionAuto; executed 2692 times by 6 tests: return Qt::LayoutDirectionAuto; Executed by:
| 2692 | ||||||||||||||||||||||||
765 | } | - | ||||||||||||||||||||||||
766 | - | |||||||||||||||||||||||||
767 | bool QQuickTextEditPrivate::determineHorizontalAlignment() | - | ||||||||||||||||||||||||
768 | { | - | ||||||||||||||||||||||||
769 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
770 | if (hAlignImplicit && q->isComponentComplete()) {
| 84-4342 | ||||||||||||||||||||||||
771 | Qt::LayoutDirection direction = contentDirection; | - | ||||||||||||||||||||||||
772 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
773 | if (direction == Qt::LayoutDirectionAuto) {
| 1374-2872 | ||||||||||||||||||||||||
774 | const QString preeditText = control->textCursor().block().layout()->preeditAreaText(); | - | ||||||||||||||||||||||||
775 | direction = textDirection(preeditText); | - | ||||||||||||||||||||||||
776 | } executed 1374 times by 6 tests: end of block Executed by:
| 1374 | ||||||||||||||||||||||||
777 | if (direction == Qt::LayoutDirectionAuto)
| 1352-2894 | ||||||||||||||||||||||||
778 | direction = qGuiApp->inputMethod()->inputDirection(); executed 1352 times by 6 tests: direction = (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->inputDirection(); Executed by:
| 1352 | ||||||||||||||||||||||||
779 | #endif | - | ||||||||||||||||||||||||
780 | - | |||||||||||||||||||||||||
781 | return setHAlign(direction == Qt::RightToLeft ? QQuickTextEdit::AlignRight : QQuickTextEdit::AlignLeft); executed 4246 times by 6 tests: return setHAlign(direction == Qt::RightToLeft ? QQuickTextEdit::AlignRight : QQuickTextEdit::AlignLeft); Executed by:
| 4246 | ||||||||||||||||||||||||
782 | } | - | ||||||||||||||||||||||||
783 | return false; executed 180 times by 2 tests: return false; Executed by:
| 180 | ||||||||||||||||||||||||
784 | } | - | ||||||||||||||||||||||||
785 | - | |||||||||||||||||||||||||
786 | void QQuickTextEditPrivate::mirrorChange() | - | ||||||||||||||||||||||||
787 | { | - | ||||||||||||||||||||||||
788 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
789 | if (q->isComponentComplete()) {
| 0-4 | ||||||||||||||||||||||||
790 | if (!hAlignImplicit && (hAlign == QQuickTextEdit::AlignRight || hAlign == QQuickTextEdit::AlignLeft)) {
| 0-2 | ||||||||||||||||||||||||
791 | updateDefaultTextOption(); | - | ||||||||||||||||||||||||
792 | q->updateSize(); | - | ||||||||||||||||||||||||
793 | emit q->effectiveHorizontalAlignmentChanged(); | - | ||||||||||||||||||||||||
794 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
795 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
796 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
797 | - | |||||||||||||||||||||||||
798 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
799 | Qt::InputMethodHints QQuickTextEditPrivate::effectiveInputMethodHints() const | - | ||||||||||||||||||||||||
800 | { | - | ||||||||||||||||||||||||
801 | return inputMethodHints | Qt::ImhMultiLine; executed 338 times by 3 tests: return inputMethodHints | Qt::ImhMultiLine; Executed by:
| 338 | ||||||||||||||||||||||||
802 | } | - | ||||||||||||||||||||||||
803 | #endif | - | ||||||||||||||||||||||||
804 | - | |||||||||||||||||||||||||
805 | void QQuickTextEditPrivate::setTopPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
806 | { | - | ||||||||||||||||||||||||
807 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
808 | qreal oldPadding = q->topPadding(); | - | ||||||||||||||||||||||||
809 | if (!reset || extra.isAllocated()) {
| 0-4 | ||||||||||||||||||||||||
810 | extra.value().topPadding = value; | - | ||||||||||||||||||||||||
811 | extra.value().explicitTopPadding = !reset; | - | ||||||||||||||||||||||||
812 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
813 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-4 | ||||||||||||||||||||||||
814 | q->updateSize(); | - | ||||||||||||||||||||||||
815 | emit q->topPaddingChanged(); | - | ||||||||||||||||||||||||
816 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
817 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
818 | - | |||||||||||||||||||||||||
819 | void QQuickTextEditPrivate::setLeftPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
820 | { | - | ||||||||||||||||||||||||
821 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
822 | qreal oldPadding = q->leftPadding(); | - | ||||||||||||||||||||||||
823 | if (!reset || extra.isAllocated()) {
| 0-4 | ||||||||||||||||||||||||
824 | extra.value().leftPadding = value; | - | ||||||||||||||||||||||||
825 | extra.value().explicitLeftPadding = !reset; | - | ||||||||||||||||||||||||
826 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
827 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-4 | ||||||||||||||||||||||||
828 | q->updateSize(); | - | ||||||||||||||||||||||||
829 | emit q->leftPaddingChanged(); | - | ||||||||||||||||||||||||
830 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
831 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
832 | - | |||||||||||||||||||||||||
833 | void QQuickTextEditPrivate::setRightPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
834 | { | - | ||||||||||||||||||||||||
835 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
836 | qreal oldPadding = q->rightPadding(); | - | ||||||||||||||||||||||||
837 | if (!reset || extra.isAllocated()) {
| 0-4 | ||||||||||||||||||||||||
838 | extra.value().rightPadding = value; | - | ||||||||||||||||||||||||
839 | extra.value().explicitRightPadding = !reset; | - | ||||||||||||||||||||||||
840 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
841 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-4 | ||||||||||||||||||||||||
842 | q->updateSize(); | - | ||||||||||||||||||||||||
843 | emit q->rightPaddingChanged(); | - | ||||||||||||||||||||||||
844 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
845 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
846 | - | |||||||||||||||||||||||||
847 | void QQuickTextEditPrivate::setBottomPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
848 | { | - | ||||||||||||||||||||||||
849 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
850 | qreal oldPadding = q->bottomPadding(); | - | ||||||||||||||||||||||||
851 | if (!reset || extra.isAllocated()) {
| 0-4 | ||||||||||||||||||||||||
852 | extra.value().bottomPadding = value; | - | ||||||||||||||||||||||||
853 | extra.value().explicitBottomPadding = !reset; | - | ||||||||||||||||||||||||
854 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
855 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-4 | ||||||||||||||||||||||||
856 | q->updateSize(); | - | ||||||||||||||||||||||||
857 | emit q->bottomPaddingChanged(); | - | ||||||||||||||||||||||||
858 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
859 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
860 | - | |||||||||||||||||||||||||
861 | bool QQuickTextEditPrivate::isImplicitResizeEnabled() const | - | ||||||||||||||||||||||||
862 | { | - | ||||||||||||||||||||||||
863 | return !extra.isAllocated() || extra->implicitResize; executed 5290 times by 6 tests: return !extra.isAllocated() || extra->implicitResize; Executed by:
| 5290 | ||||||||||||||||||||||||
864 | } | - | ||||||||||||||||||||||||
865 | - | |||||||||||||||||||||||||
866 | void QQuickTextEditPrivate::setImplicitResizeEnabled(bool enabled) | - | ||||||||||||||||||||||||
867 | { | - | ||||||||||||||||||||||||
868 | if (!enabled)
| 0 | ||||||||||||||||||||||||
869 | extra.value().implicitResize = false; never executed: extra.value().implicitResize = false; | 0 | ||||||||||||||||||||||||
870 | else if (extra.isAllocated())
| 0 | ||||||||||||||||||||||||
871 | extra->implicitResize = true; never executed: extra->implicitResize = true; | 0 | ||||||||||||||||||||||||
872 | } never executed: end of block | 0 | ||||||||||||||||||||||||
873 | - | |||||||||||||||||||||||||
874 | QQuickTextEdit::VAlignment QQuickTextEdit::vAlign() const | - | ||||||||||||||||||||||||
875 | { | - | ||||||||||||||||||||||||
876 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
877 | return d->vAlign; executed 42 times by 1 test: return d->vAlign; Executed by:
| 42 | ||||||||||||||||||||||||
878 | } | - | ||||||||||||||||||||||||
879 | - | |||||||||||||||||||||||||
880 | void QQuickTextEdit::setVAlign(QQuickTextEdit::VAlignment alignment) | - | ||||||||||||||||||||||||
881 | { | - | ||||||||||||||||||||||||
882 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
883 | if (alignment == d->vAlign)
| 20-42 | ||||||||||||||||||||||||
884 | return; executed 20 times by 1 test: return; Executed by:
| 20 | ||||||||||||||||||||||||
885 | d->vAlign = alignment; | - | ||||||||||||||||||||||||
886 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
887 | updateSize(); | - | ||||||||||||||||||||||||
888 | moveCursorDelegate(); | - | ||||||||||||||||||||||||
889 | emit verticalAlignmentChanged(d->vAlign); | - | ||||||||||||||||||||||||
890 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||
891 | /*! | - | ||||||||||||||||||||||||
892 | \qmlproperty enumeration QtQuick::TextEdit::wrapMode | - | ||||||||||||||||||||||||
893 | - | |||||||||||||||||||||||||
894 | Set this property to wrap the text to the TextEdit item's width. | - | ||||||||||||||||||||||||
895 | The text will only wrap if an explicit width has been set. | - | ||||||||||||||||||||||||
896 | - | |||||||||||||||||||||||||
897 | \list | - | ||||||||||||||||||||||||
898 | \li TextEdit.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width. | - | ||||||||||||||||||||||||
899 | \li TextEdit.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width. | - | ||||||||||||||||||||||||
900 | \li TextEdit.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word. | - | ||||||||||||||||||||||||
901 | \li TextEdit.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word. | - | ||||||||||||||||||||||||
902 | \endlist | - | ||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||
904 | The default is TextEdit.NoWrap. If you set a width, consider using TextEdit.Wrap. | - | ||||||||||||||||||||||||
905 | */ | - | ||||||||||||||||||||||||
906 | QQuickTextEdit::WrapMode QQuickTextEdit::wrapMode() const | - | ||||||||||||||||||||||||
907 | { | - | ||||||||||||||||||||||||
908 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
909 | return d->wrapMode; executed 6 times by 1 test: return d->wrapMode; Executed by:
| 6 | ||||||||||||||||||||||||
910 | } | - | ||||||||||||||||||||||||
911 | - | |||||||||||||||||||||||||
912 | void QQuickTextEdit::setWrapMode(WrapMode mode) | - | ||||||||||||||||||||||||
913 | { | - | ||||||||||||||||||||||||
914 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
915 | if (mode == d->wrapMode)
| 10-108 | ||||||||||||||||||||||||
916 | return; executed 10 times by 1 test: return; Executed by:
| 10 | ||||||||||||||||||||||||
917 | d->wrapMode = mode; | - | ||||||||||||||||||||||||
918 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
919 | updateSize(); | - | ||||||||||||||||||||||||
920 | emit wrapModeChanged(); | - | ||||||||||||||||||||||||
921 | } executed 108 times by 4 tests: end of block Executed by:
| 108 | ||||||||||||||||||||||||
922 | - | |||||||||||||||||||||||||
923 | /*! | - | ||||||||||||||||||||||||
924 | \qmlproperty int QtQuick::TextEdit::lineCount | - | ||||||||||||||||||||||||
925 | - | |||||||||||||||||||||||||
926 | Returns the total number of lines in the TextEdit item. | - | ||||||||||||||||||||||||
927 | */ | - | ||||||||||||||||||||||||
928 | int QQuickTextEdit::lineCount() const | - | ||||||||||||||||||||||||
929 | { | - | ||||||||||||||||||||||||
930 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
931 | return d->lineCount; executed 52 times by 1 test: return d->lineCount; Executed by:
| 52 | ||||||||||||||||||||||||
932 | } | - | ||||||||||||||||||||||||
933 | - | |||||||||||||||||||||||||
934 | /*! | - | ||||||||||||||||||||||||
935 | \qmlproperty int QtQuick::TextEdit::length | - | ||||||||||||||||||||||||
936 | - | |||||||||||||||||||||||||
937 | Returns the total number of plain text characters in the TextEdit item. | - | ||||||||||||||||||||||||
938 | - | |||||||||||||||||||||||||
939 | As this number doesn't include any formatting markup it may not be the same as the | - | ||||||||||||||||||||||||
940 | length of the string returned by the \l text property. | - | ||||||||||||||||||||||||
941 | - | |||||||||||||||||||||||||
942 | This property can be faster than querying the length the \l text property as it doesn't | - | ||||||||||||||||||||||||
943 | require any copying or conversion of the TextEdit's internal string data. | - | ||||||||||||||||||||||||
944 | */ | - | ||||||||||||||||||||||||
945 | - | |||||||||||||||||||||||||
946 | int QQuickTextEdit::length() const | - | ||||||||||||||||||||||||
947 | { | - | ||||||||||||||||||||||||
948 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
949 | // QTextDocument::characterCount() includes the terminating null character. | - | ||||||||||||||||||||||||
950 | return qMax(0, d->document->characterCount() - 1); executed 160 times by 1 test: return qMax(0, d->document->characterCount() - 1); Executed by:
| 160 | ||||||||||||||||||||||||
951 | } | - | ||||||||||||||||||||||||
952 | - | |||||||||||||||||||||||||
953 | /*! | - | ||||||||||||||||||||||||
954 | \qmlproperty real QtQuick::TextEdit::contentWidth | - | ||||||||||||||||||||||||
955 | - | |||||||||||||||||||||||||
956 | Returns the width of the text, including the width past the width | - | ||||||||||||||||||||||||
957 | which is covered due to insufficient wrapping if \l wrapMode is set. | - | ||||||||||||||||||||||||
958 | */ | - | ||||||||||||||||||||||||
959 | qreal QQuickTextEdit::contentWidth() const | - | ||||||||||||||||||||||||
960 | { | - | ||||||||||||||||||||||||
961 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
962 | return d->contentSize.width(); executed 24 times by 2 tests: return d->contentSize.width(); Executed by:
| 24 | ||||||||||||||||||||||||
963 | } | - | ||||||||||||||||||||||||
964 | - | |||||||||||||||||||||||||
965 | /*! | - | ||||||||||||||||||||||||
966 | \qmlproperty real QtQuick::TextEdit::contentHeight | - | ||||||||||||||||||||||||
967 | - | |||||||||||||||||||||||||
968 | Returns the height of the text, including the height past the height | - | ||||||||||||||||||||||||
969 | that is covered if the text does not fit within the set height. | - | ||||||||||||||||||||||||
970 | */ | - | ||||||||||||||||||||||||
971 | qreal QQuickTextEdit::contentHeight() const | - | ||||||||||||||||||||||||
972 | { | - | ||||||||||||||||||||||||
973 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
974 | return d->contentSize.height(); executed 22 times by 2 tests: return d->contentSize.height(); Executed by:
| 22 | ||||||||||||||||||||||||
975 | } | - | ||||||||||||||||||||||||
976 | - | |||||||||||||||||||||||||
977 | /*! | - | ||||||||||||||||||||||||
978 | \qmlproperty url QtQuick::TextEdit::baseUrl | - | ||||||||||||||||||||||||
979 | - | |||||||||||||||||||||||||
980 | This property specifies a base URL which is used to resolve relative URLs | - | ||||||||||||||||||||||||
981 | within the text. | - | ||||||||||||||||||||||||
982 | - | |||||||||||||||||||||||||
983 | The default value is the url of the QML file instantiating the TextEdit item. | - | ||||||||||||||||||||||||
984 | */ | - | ||||||||||||||||||||||||
985 | - | |||||||||||||||||||||||||
986 | QUrl QQuickTextEdit::baseUrl() const | - | ||||||||||||||||||||||||
987 | { | - | ||||||||||||||||||||||||
988 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
989 | if (d->baseUrl.isEmpty()) {
| 18-1060 | ||||||||||||||||||||||||
990 | if (QQmlContext *context = qmlContext(this))
| 2-1058 | ||||||||||||||||||||||||
991 | const_cast<QQuickTextEditPrivate *>(d)->baseUrl = context->baseUrl(); executed 1058 times by 6 tests: const_cast<QQuickTextEditPrivate *>(d)->baseUrl = context->baseUrl(); Executed by:
| 1058 | ||||||||||||||||||||||||
992 | } executed 1060 times by 6 tests: end of block Executed by:
| 1060 | ||||||||||||||||||||||||
993 | return d->baseUrl; executed 1078 times by 6 tests: return d->baseUrl; Executed by:
| 1078 | ||||||||||||||||||||||||
994 | } | - | ||||||||||||||||||||||||
995 | - | |||||||||||||||||||||||||
996 | void QQuickTextEdit::setBaseUrl(const QUrl &url) | - | ||||||||||||||||||||||||
997 | { | - | ||||||||||||||||||||||||
998 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
999 | if (baseUrl() != url) {
| 2-8 | ||||||||||||||||||||||||
1000 | d->baseUrl = url; | - | ||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||
1002 | d->document->setBaseUrl(url); | - | ||||||||||||||||||||||||
1003 | emit baseUrlChanged(); | - | ||||||||||||||||||||||||
1004 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1005 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
1006 | - | |||||||||||||||||||||||||
1007 | void QQuickTextEdit::resetBaseUrl() | - | ||||||||||||||||||||||||
1008 | { | - | ||||||||||||||||||||||||
1009 | if (QQmlContext *context = qmlContext(this))
| 0-2 | ||||||||||||||||||||||||
1010 | setBaseUrl(context->baseUrl()); executed 2 times by 1 test: setBaseUrl(context->baseUrl()); Executed by:
| 2 | ||||||||||||||||||||||||
1011 | else | - | ||||||||||||||||||||||||
1012 | setBaseUrl(QUrl()); never executed: setBaseUrl(QUrl()); | 0 | ||||||||||||||||||||||||
1013 | } | - | ||||||||||||||||||||||||
1014 | - | |||||||||||||||||||||||||
1015 | /*! | - | ||||||||||||||||||||||||
1016 | \qmlmethod rectangle QtQuick::TextEdit::positionToRectangle(position) | - | ||||||||||||||||||||||||
1017 | - | |||||||||||||||||||||||||
1018 | Returns the rectangle at the given \a position in the text. The x, y, | - | ||||||||||||||||||||||||
1019 | and height properties correspond to the cursor that would describe | - | ||||||||||||||||||||||||
1020 | that position. | - | ||||||||||||||||||||||||
1021 | */ | - | ||||||||||||||||||||||||
1022 | QRectF QQuickTextEdit::positionToRectangle(int pos) const | - | ||||||||||||||||||||||||
1023 | { | - | ||||||||||||||||||||||||
1024 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1025 | QTextCursor c(d->document); | - | ||||||||||||||||||||||||
1026 | c.setPosition(pos); | - | ||||||||||||||||||||||||
1027 | return d->control->cursorRect(c).translated(d->xoff, d->yoff); executed 340 times by 2 tests: return d->control->cursorRect(c).translated(d->xoff, d->yoff); Executed by:
| 340 | ||||||||||||||||||||||||
1028 | - | |||||||||||||||||||||||||
1029 | } | - | ||||||||||||||||||||||||
1030 | - | |||||||||||||||||||||||||
1031 | /*! | - | ||||||||||||||||||||||||
1032 | \qmlmethod int QtQuick::TextEdit::positionAt(int x, int y) | - | ||||||||||||||||||||||||
1033 | - | |||||||||||||||||||||||||
1034 | Returns the text position closest to pixel position (\a x, \a y). | - | ||||||||||||||||||||||||
1035 | - | |||||||||||||||||||||||||
1036 | Position 0 is before the first character, position 1 is after the first character | - | ||||||||||||||||||||||||
1037 | but before the second, and so on until position \l {text}.length, which is after all characters. | - | ||||||||||||||||||||||||
1038 | */ | - | ||||||||||||||||||||||||
1039 | int QQuickTextEdit::positionAt(qreal x, qreal y) const | - | ||||||||||||||||||||||||
1040 | { | - | ||||||||||||||||||||||||
1041 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1042 | x -= d->xoff; | - | ||||||||||||||||||||||||
1043 | y -= d->yoff; | - | ||||||||||||||||||||||||
1044 | - | |||||||||||||||||||||||||
1045 | int r = d->document->documentLayout()->hitTest(QPointF(x, y), Qt::FuzzyHit); | - | ||||||||||||||||||||||||
1046 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1047 | QTextCursor cursor = d->control->textCursor(); | - | ||||||||||||||||||||||||
1048 | if (r > cursor.position()) {
| 14-58 | ||||||||||||||||||||||||
1049 | // The cursor position includes positions within the preedit text, but only positions in the | - | ||||||||||||||||||||||||
1050 | // same text block are offset so it is possible to get a position that is either part of the | - | ||||||||||||||||||||||||
1051 | // preedit or the next text block. | - | ||||||||||||||||||||||||
1052 | QTextLayout *layout = cursor.block().layout(); | - | ||||||||||||||||||||||||
1053 | const int preeditLength = layout
| 0-58 | ||||||||||||||||||||||||
1054 | ? layout->preeditAreaText().length() | - | ||||||||||||||||||||||||
1055 | : 0; | - | ||||||||||||||||||||||||
1056 | if (preeditLength > 0
| 12-46 | ||||||||||||||||||||||||
1057 | && d->document->documentLayout()->blockBoundingRect(cursor.block()).contains(x, y)) {
| 12-34 | ||||||||||||||||||||||||
1058 | r = r > cursor.position() + preeditLength
| 12-22 | ||||||||||||||||||||||||
1059 | ? r - preeditLength | - | ||||||||||||||||||||||||
1060 | : cursor.position(); | - | ||||||||||||||||||||||||
1061 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
1062 | } executed 58 times by 1 test: end of block Executed by:
| 58 | ||||||||||||||||||||||||
1063 | #endif | - | ||||||||||||||||||||||||
1064 | return r; executed 72 times by 1 test: return r; Executed by:
| 72 | ||||||||||||||||||||||||
1065 | } | - | ||||||||||||||||||||||||
1066 | - | |||||||||||||||||||||||||
1067 | /*! | - | ||||||||||||||||||||||||
1068 | \qmlmethod QtQuick::TextEdit::moveCursorSelection(int position, SelectionMode mode = TextEdit.SelectCharacters) | - | ||||||||||||||||||||||||
1069 | - | |||||||||||||||||||||||||
1070 | Moves the cursor to \a position and updates the selection according to the optional \a mode | - | ||||||||||||||||||||||||
1071 | parameter. (To only move the cursor, set the \l cursorPosition property.) | - | ||||||||||||||||||||||||
1072 | - | |||||||||||||||||||||||||
1073 | When this method is called it additionally sets either the | - | ||||||||||||||||||||||||
1074 | selectionStart or the selectionEnd (whichever was at the previous cursor position) | - | ||||||||||||||||||||||||
1075 | to the specified position. This allows you to easily extend and contract the selected | - | ||||||||||||||||||||||||
1076 | text range. | - | ||||||||||||||||||||||||
1077 | - | |||||||||||||||||||||||||
1078 | The selection mode specifies whether the selection is updated on a per character or a per word | - | ||||||||||||||||||||||||
1079 | basis. If not specified the selection mode will default to TextEdit.SelectCharacters. | - | ||||||||||||||||||||||||
1080 | - | |||||||||||||||||||||||||
1081 | \list | - | ||||||||||||||||||||||||
1082 | \li TextEdit.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at | - | ||||||||||||||||||||||||
1083 | the previous cursor position) to the specified position. | - | ||||||||||||||||||||||||
1084 | \li TextEdit.SelectWords - Sets the selectionStart and selectionEnd to include all | - | ||||||||||||||||||||||||
1085 | words between the specified position and the previous cursor position. Words partially in the | - | ||||||||||||||||||||||||
1086 | range are included. | - | ||||||||||||||||||||||||
1087 | \endlist | - | ||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||
1089 | For example, take this sequence of calls: | - | ||||||||||||||||||||||||
1090 | - | |||||||||||||||||||||||||
1091 | \code | - | ||||||||||||||||||||||||
1092 | cursorPosition = 5 | - | ||||||||||||||||||||||||
1093 | moveCursorSelection(9, TextEdit.SelectCharacters) | - | ||||||||||||||||||||||||
1094 | moveCursorSelection(7, TextEdit.SelectCharacters) | - | ||||||||||||||||||||||||
1095 | \endcode | - | ||||||||||||||||||||||||
1096 | - | |||||||||||||||||||||||||
1097 | This moves the cursor to position 5, extend the selection end from 5 to 9 | - | ||||||||||||||||||||||||
1098 | and then retract the selection end from 9 to 7, leaving the text from position 5 to 7 | - | ||||||||||||||||||||||||
1099 | selected (the 6th and 7th characters). | - | ||||||||||||||||||||||||
1100 | - | |||||||||||||||||||||||||
1101 | The same sequence with TextEdit.SelectWords will extend the selection start to a word boundary | - | ||||||||||||||||||||||||
1102 | before or on position 5 and extend the selection end to a word boundary on or past position 9. | - | ||||||||||||||||||||||||
1103 | */ | - | ||||||||||||||||||||||||
1104 | void QQuickTextEdit::moveCursorSelection(int pos) | - | ||||||||||||||||||||||||
1105 | { | - | ||||||||||||||||||||||||
1106 | //Note that this is the same as setCursorPosition but with the KeepAnchor flag set | - | ||||||||||||||||||||||||
1107 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1108 | QTextCursor cursor = d->control->textCursor(); | - | ||||||||||||||||||||||||
1109 | if (cursor.position() == pos)
| 0-2 | ||||||||||||||||||||||||
1110 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1111 | cursor.setPosition(pos, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1112 | d->control->setTextCursor(cursor); | - | ||||||||||||||||||||||||
1113 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1114 | - | |||||||||||||||||||||||||
1115 | void QQuickTextEdit::moveCursorSelection(int pos, SelectionMode mode) | - | ||||||||||||||||||||||||
1116 | { | - | ||||||||||||||||||||||||
1117 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1118 | QTextCursor cursor = d->control->textCursor(); | - | ||||||||||||||||||||||||
1119 | if (cursor.position() == pos)
| 60-236 | ||||||||||||||||||||||||
1120 | return; executed 60 times by 1 test: return; Executed by:
| 60 | ||||||||||||||||||||||||
1121 | if (mode == SelectCharacters) {
| 40-196 | ||||||||||||||||||||||||
1122 | cursor.setPosition(pos, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1123 | } else if (cursor.anchor() < pos || (cursor.anchor() == pos && cursor.position() < pos)) { executed 40 times by 1 test: end of block Executed by:
| 2-100 | ||||||||||||||||||||||||
1124 | if (cursor.anchor() > cursor.position()) {
| 8-90 | ||||||||||||||||||||||||
1125 | cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1126 | cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1127 | if (cursor.position() == cursor.anchor())
| 2-6 | ||||||||||||||||||||||||
1128 | cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor); executed 2 times by 1 test: cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor); Executed by:
| 2 | ||||||||||||||||||||||||
1129 | else | - | ||||||||||||||||||||||||
1130 | cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); executed 6 times by 1 test: cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); Executed by:
| 6 | ||||||||||||||||||||||||
1131 | } else { | - | ||||||||||||||||||||||||
1132 | cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1133 | cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1134 | } executed 90 times by 1 test: end of block Executed by:
| 90 | ||||||||||||||||||||||||
1135 | - | |||||||||||||||||||||||||
1136 | cursor.setPosition(pos, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1137 | cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1138 | if (cursor.position() != pos)
| 42-56 | ||||||||||||||||||||||||
1139 | cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); executed 56 times by 1 test: cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); Executed by:
| 56 | ||||||||||||||||||||||||
1140 | } else if (cursor.anchor() > pos || (cursor.anchor() == pos && cursor.position() > pos)) { executed 98 times by 1 test: end of block Executed by:
| 0-98 | ||||||||||||||||||||||||
1141 | if (cursor.anchor() < cursor.position()) {
| 8-90 | ||||||||||||||||||||||||
1142 | cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1143 | cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1144 | } else { executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1145 | cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1146 | cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1147 | cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1148 | if (cursor.position() != cursor.anchor()) {
| 36-54 | ||||||||||||||||||||||||
1149 | cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1150 | cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1151 | } executed 54 times by 1 test: end of block Executed by:
| 54 | ||||||||||||||||||||||||
1152 | } executed 90 times by 1 test: end of block Executed by:
| 90 | ||||||||||||||||||||||||
1153 | - | |||||||||||||||||||||||||
1154 | cursor.setPosition(pos, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1155 | cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1156 | if (cursor.position() != pos) {
| 40-58 | ||||||||||||||||||||||||
1157 | cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1158 | cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1159 | } executed 58 times by 1 test: end of block Executed by:
| 58 | ||||||||||||||||||||||||
1160 | } executed 98 times by 1 test: end of block Executed by:
| 98 | ||||||||||||||||||||||||
1161 | d->control->setTextCursor(cursor); | - | ||||||||||||||||||||||||
1162 | } executed 236 times by 1 test: end of block Executed by:
| 236 | ||||||||||||||||||||||||
1163 | - | |||||||||||||||||||||||||
1164 | /*! | - | ||||||||||||||||||||||||
1165 | \qmlproperty bool QtQuick::TextEdit::cursorVisible | - | ||||||||||||||||||||||||
1166 | If true the text edit shows a cursor. | - | ||||||||||||||||||||||||
1167 | - | |||||||||||||||||||||||||
1168 | This property is set and unset when the text edit gets active focus, but it can also | - | ||||||||||||||||||||||||
1169 | be set directly (useful, for example, if a KeyProxy might forward keys to it). | - | ||||||||||||||||||||||||
1170 | */ | - | ||||||||||||||||||||||||
1171 | bool QQuickTextEdit::isCursorVisible() const | - | ||||||||||||||||||||||||
1172 | { | - | ||||||||||||||||||||||||
1173 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1174 | return d->cursorVisible; executed 108 times by 1 test: return d->cursorVisible; Executed by:
| 108 | ||||||||||||||||||||||||
1175 | } | - | ||||||||||||||||||||||||
1176 | - | |||||||||||||||||||||||||
1177 | void QQuickTextEdit::setCursorVisible(bool on) | - | ||||||||||||||||||||||||
1178 | { | - | ||||||||||||||||||||||||
1179 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1180 | if (d->cursorVisible == on)
| 342-482 | ||||||||||||||||||||||||
1181 | return; executed 342 times by 2 tests: return; Executed by:
| 342 | ||||||||||||||||||||||||
1182 | d->cursorVisible = on; | - | ||||||||||||||||||||||||
1183 | if (on && isComponentComplete())
| 32-370 | ||||||||||||||||||||||||
1184 | QQuickTextUtil::createCursor(d); executed 338 times by 3 tests: QQuickTextUtil::createCursor(d); Executed by:
| 338 | ||||||||||||||||||||||||
1185 | if (!on && !d->persistentSelection)
| 2-370 | ||||||||||||||||||||||||
1186 | d->control->setCursorIsFocusIndicator(true); executed 110 times by 3 tests: d->control->setCursorIsFocusIndicator(true); Executed by:
| 110 | ||||||||||||||||||||||||
1187 | d->control->setCursorVisible(on); | - | ||||||||||||||||||||||||
1188 | emit cursorVisibleChanged(d->cursorVisible); | - | ||||||||||||||||||||||||
1189 | } executed 482 times by 4 tests: end of block Executed by:
| 482 | ||||||||||||||||||||||||
1190 | - | |||||||||||||||||||||||||
1191 | /*! | - | ||||||||||||||||||||||||
1192 | \qmlproperty int QtQuick::TextEdit::cursorPosition | - | ||||||||||||||||||||||||
1193 | The position of the cursor in the TextEdit. | - | ||||||||||||||||||||||||
1194 | */ | - | ||||||||||||||||||||||||
1195 | int QQuickTextEdit::cursorPosition() const | - | ||||||||||||||||||||||||
1196 | { | - | ||||||||||||||||||||||||
1197 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1198 | return d->control->textCursor().position(); executed 326 times by 1 test: return d->control->textCursor().position(); Executed by:
| 326 | ||||||||||||||||||||||||
1199 | } | - | ||||||||||||||||||||||||
1200 | - | |||||||||||||||||||||||||
1201 | void QQuickTextEdit::setCursorPosition(int pos) | - | ||||||||||||||||||||||||
1202 | { | - | ||||||||||||||||||||||||
1203 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1204 | if (pos < 0 || pos >= d->document->characterCount()) // characterCount includes the terminating null.
| 2-670 | ||||||||||||||||||||||||
1205 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||||||||
1206 | QTextCursor cursor = d->control->textCursor(); | - | ||||||||||||||||||||||||
1207 | if (cursor.position() == pos && cursor.anchor() == pos)
| 56-520 | ||||||||||||||||||||||||
1208 | return; executed 88 times by 1 test: return; Executed by:
| 88 | ||||||||||||||||||||||||
1209 | cursor.setPosition(pos); | - | ||||||||||||||||||||||||
1210 | d->control->setTextCursor(cursor); | - | ||||||||||||||||||||||||
1211 | d->control->updateCursorRectangle(true); | - | ||||||||||||||||||||||||
1212 | } executed 576 times by 1 test: end of block Executed by:
| 576 | ||||||||||||||||||||||||
1213 | - | |||||||||||||||||||||||||
1214 | /*! | - | ||||||||||||||||||||||||
1215 | \qmlproperty Component QtQuick::TextEdit::cursorDelegate | - | ||||||||||||||||||||||||
1216 | The delegate for the cursor in the TextEdit. | - | ||||||||||||||||||||||||
1217 | - | |||||||||||||||||||||||||
1218 | If you set a cursorDelegate for a TextEdit, this delegate will be used for | - | ||||||||||||||||||||||||
1219 | drawing the cursor instead of the standard cursor. An instance of the | - | ||||||||||||||||||||||||
1220 | delegate will be created and managed by the text edit when a cursor is | - | ||||||||||||||||||||||||
1221 | needed, and the x and y properties of delegate instance will be set so as | - | ||||||||||||||||||||||||
1222 | to be one pixel before the top left of the current character. | - | ||||||||||||||||||||||||
1223 | - | |||||||||||||||||||||||||
1224 | Note that the root item of the delegate component must be a QQuickItem or | - | ||||||||||||||||||||||||
1225 | QQuickItem derived item. | - | ||||||||||||||||||||||||
1226 | */ | - | ||||||||||||||||||||||||
1227 | QQmlComponent* QQuickTextEdit::cursorDelegate() const | - | ||||||||||||||||||||||||
1228 | { | - | ||||||||||||||||||||||||
1229 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1230 | return d->cursorComponent; never executed: return d->cursorComponent; | 0 | ||||||||||||||||||||||||
1231 | } | - | ||||||||||||||||||||||||
1232 | - | |||||||||||||||||||||||||
1233 | void QQuickTextEdit::setCursorDelegate(QQmlComponent* c) | - | ||||||||||||||||||||||||
1234 | { | - | ||||||||||||||||||||||||
1235 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1236 | QQuickTextUtil::setCursorDelegate(d, c); | - | ||||||||||||||||||||||||
1237 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
1238 | - | |||||||||||||||||||||||||
1239 | void QQuickTextEdit::createCursor() | - | ||||||||||||||||||||||||
1240 | { | - | ||||||||||||||||||||||||
1241 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1242 | d->cursorPending = true; | - | ||||||||||||||||||||||||
1243 | QQuickTextUtil::createCursor(d); | - | ||||||||||||||||||||||||
1244 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1245 | - | |||||||||||||||||||||||||
1246 | /*! | - | ||||||||||||||||||||||||
1247 | \qmlproperty int QtQuick::TextEdit::selectionStart | - | ||||||||||||||||||||||||
1248 | - | |||||||||||||||||||||||||
1249 | The cursor position before the first character in the current selection. | - | ||||||||||||||||||||||||
1250 | - | |||||||||||||||||||||||||
1251 | This property is read-only. To change the selection, use select(start,end), | - | ||||||||||||||||||||||||
1252 | selectAll(), or selectWord(). | - | ||||||||||||||||||||||||
1253 | - | |||||||||||||||||||||||||
1254 | \sa selectionEnd, cursorPosition, selectedText | - | ||||||||||||||||||||||||
1255 | */ | - | ||||||||||||||||||||||||
1256 | int QQuickTextEdit::selectionStart() const | - | ||||||||||||||||||||||||
1257 | { | - | ||||||||||||||||||||||||
1258 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1259 | return d->control->textCursor().selectionStart(); executed 1062 times by 4 tests: return d->control->textCursor().selectionStart(); Executed by:
| 1062 | ||||||||||||||||||||||||
1260 | } | - | ||||||||||||||||||||||||
1261 | - | |||||||||||||||||||||||||
1262 | /*! | - | ||||||||||||||||||||||||
1263 | \qmlproperty int QtQuick::TextEdit::selectionEnd | - | ||||||||||||||||||||||||
1264 | - | |||||||||||||||||||||||||
1265 | The cursor position after the last character in the current selection. | - | ||||||||||||||||||||||||
1266 | - | |||||||||||||||||||||||||
1267 | This property is read-only. To change the selection, use select(start,end), | - | ||||||||||||||||||||||||
1268 | selectAll(), or selectWord(). | - | ||||||||||||||||||||||||
1269 | - | |||||||||||||||||||||||||
1270 | \sa selectionStart, cursorPosition, selectedText | - | ||||||||||||||||||||||||
1271 | */ | - | ||||||||||||||||||||||||
1272 | int QQuickTextEdit::selectionEnd() const | - | ||||||||||||||||||||||||
1273 | { | - | ||||||||||||||||||||||||
1274 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1275 | return d->control->textCursor().selectionEnd(); executed 1062 times by 4 tests: return d->control->textCursor().selectionEnd(); Executed by:
| 1062 | ||||||||||||||||||||||||
1276 | } | - | ||||||||||||||||||||||||
1277 | - | |||||||||||||||||||||||||
1278 | /*! | - | ||||||||||||||||||||||||
1279 | \qmlproperty string QtQuick::TextEdit::selectedText | - | ||||||||||||||||||||||||
1280 | - | |||||||||||||||||||||||||
1281 | This read-only property provides the text currently selected in the | - | ||||||||||||||||||||||||
1282 | text edit. | - | ||||||||||||||||||||||||
1283 | - | |||||||||||||||||||||||||
1284 | It is equivalent to the following snippet, but is faster and easier | - | ||||||||||||||||||||||||
1285 | to use. | - | ||||||||||||||||||||||||
1286 | \code | - | ||||||||||||||||||||||||
1287 | //myTextEdit is the id of the TextEdit | - | ||||||||||||||||||||||||
1288 | myTextEdit.text.toString().substring(myTextEdit.selectionStart, | - | ||||||||||||||||||||||||
1289 | myTextEdit.selectionEnd); | - | ||||||||||||||||||||||||
1290 | \endcode | - | ||||||||||||||||||||||||
1291 | */ | - | ||||||||||||||||||||||||
1292 | QString QQuickTextEdit::selectedText() const | - | ||||||||||||||||||||||||
1293 | { | - | ||||||||||||||||||||||||
1294 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1295 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
1296 | return d->richText executed 1516 times by 1 test: return d->richText ? d->control->textCursor().selectedText() : d->control->textCursor().selection().toPlainText(); Executed by:
| 1516 | ||||||||||||||||||||||||
1297 | ? d->control->textCursor().selectedText() executed 1516 times by 1 test: return d->richText ? d->control->textCursor().selectedText() : d->control->textCursor().selection().toPlainText(); Executed by:
| 1516 | ||||||||||||||||||||||||
1298 | : d->control->textCursor().selection().toPlainText(); executed 1516 times by 1 test: return d->richText ? d->control->textCursor().selectedText() : d->control->textCursor().selection().toPlainText(); Executed by:
| 1516 | ||||||||||||||||||||||||
1299 | #else | - | ||||||||||||||||||||||||
1300 | return d->control->textCursor().selection().toPlainText(); | - | ||||||||||||||||||||||||
1301 | #endif | - | ||||||||||||||||||||||||
1302 | } | - | ||||||||||||||||||||||||
1303 | - | |||||||||||||||||||||||||
1304 | /*! | - | ||||||||||||||||||||||||
1305 | \qmlproperty bool QtQuick::TextEdit::activeFocusOnPress | - | ||||||||||||||||||||||||
1306 | - | |||||||||||||||||||||||||
1307 | Whether the TextEdit should gain active focus on a mouse press. By default this is | - | ||||||||||||||||||||||||
1308 | set to true. | - | ||||||||||||||||||||||||
1309 | */ | - | ||||||||||||||||||||||||
1310 | bool QQuickTextEdit::focusOnPress() const | - | ||||||||||||||||||||||||
1311 | { | - | ||||||||||||||||||||||||
1312 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1313 | return d->focusOnPress; executed 10 times by 1 test: return d->focusOnPress; Executed by:
| 10 | ||||||||||||||||||||||||
1314 | } | - | ||||||||||||||||||||||||
1315 | - | |||||||||||||||||||||||||
1316 | void QQuickTextEdit::setFocusOnPress(bool on) | - | ||||||||||||||||||||||||
1317 | { | - | ||||||||||||||||||||||||
1318 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1319 | if (d->focusOnPress == on)
| 10-96 | ||||||||||||||||||||||||
1320 | return; executed 96 times by 1 test: return; Executed by:
| 96 | ||||||||||||||||||||||||
1321 | d->focusOnPress = on; | - | ||||||||||||||||||||||||
1322 | emit activeFocusOnPressChanged(d->focusOnPress); | - | ||||||||||||||||||||||||
1323 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
1324 | - | |||||||||||||||||||||||||
1325 | /*! | - | ||||||||||||||||||||||||
1326 | \qmlproperty bool QtQuick::TextEdit::persistentSelection | - | ||||||||||||||||||||||||
1327 | - | |||||||||||||||||||||||||
1328 | Whether the TextEdit should keep the selection visible when it loses active focus to another | - | ||||||||||||||||||||||||
1329 | item in the scene. By default this is set to false. | - | ||||||||||||||||||||||||
1330 | */ | - | ||||||||||||||||||||||||
1331 | bool QQuickTextEdit::persistentSelection() const | - | ||||||||||||||||||||||||
1332 | { | - | ||||||||||||||||||||||||
1333 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1334 | return d->persistentSelection; executed 6 times by 1 test: return d->persistentSelection; Executed by:
| 6 | ||||||||||||||||||||||||
1335 | } | - | ||||||||||||||||||||||||
1336 | - | |||||||||||||||||||||||||
1337 | void QQuickTextEdit::setPersistentSelection(bool on) | - | ||||||||||||||||||||||||
1338 | { | - | ||||||||||||||||||||||||
1339 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1340 | if (d->persistentSelection == on)
| 2 | ||||||||||||||||||||||||
1341 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
1342 | d->persistentSelection = on; | - | ||||||||||||||||||||||||
1343 | emit persistentSelectionChanged(d->persistentSelection); | - | ||||||||||||||||||||||||
1344 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1345 | - | |||||||||||||||||||||||||
1346 | /*! | - | ||||||||||||||||||||||||
1347 | \qmlproperty real QtQuick::TextEdit::textMargin | - | ||||||||||||||||||||||||
1348 | - | |||||||||||||||||||||||||
1349 | The margin, in pixels, around the text in the TextEdit. | - | ||||||||||||||||||||||||
1350 | */ | - | ||||||||||||||||||||||||
1351 | qreal QQuickTextEdit::textMargin() const | - | ||||||||||||||||||||||||
1352 | { | - | ||||||||||||||||||||||||
1353 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1354 | return d->textMargin; executed 70 times by 1 test: return d->textMargin; Executed by:
| 70 | ||||||||||||||||||||||||
1355 | } | - | ||||||||||||||||||||||||
1356 | - | |||||||||||||||||||||||||
1357 | void QQuickTextEdit::setTextMargin(qreal margin) | - | ||||||||||||||||||||||||
1358 | { | - | ||||||||||||||||||||||||
1359 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1360 | if (d->textMargin == margin)
| 2-68 | ||||||||||||||||||||||||
1361 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
1362 | d->textMargin = margin; | - | ||||||||||||||||||||||||
1363 | d->document->setDocumentMargin(d->textMargin); | - | ||||||||||||||||||||||||
1364 | emit textMarginChanged(d->textMargin); | - | ||||||||||||||||||||||||
1365 | } executed 68 times by 1 test: end of block Executed by:
| 68 | ||||||||||||||||||||||||
1366 | - | |||||||||||||||||||||||||
1367 | /*! | - | ||||||||||||||||||||||||
1368 | \qmlproperty enumeration QtQuick::TextEdit::inputMethodHints | - | ||||||||||||||||||||||||
1369 | - | |||||||||||||||||||||||||
1370 | Provides hints to the input method about the expected content of the text edit and how it | - | ||||||||||||||||||||||||
1371 | should operate. | - | ||||||||||||||||||||||||
1372 | - | |||||||||||||||||||||||||
1373 | The value is a bit-wise combination of flags or Qt.ImhNone if no hints are set. | - | ||||||||||||||||||||||||
1374 | - | |||||||||||||||||||||||||
1375 | Flags that alter behaviour are: | - | ||||||||||||||||||||||||
1376 | - | |||||||||||||||||||||||||
1377 | \list | - | ||||||||||||||||||||||||
1378 | \li Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords. | - | ||||||||||||||||||||||||
1379 | \li Qt.ImhSensitiveData - Typed text should not be stored by the active input method | - | ||||||||||||||||||||||||
1380 | in any persistent storage like predictive user dictionary. | - | ||||||||||||||||||||||||
1381 | \li Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case | - | ||||||||||||||||||||||||
1382 | when a sentence ends. | - | ||||||||||||||||||||||||
1383 | \li Qt.ImhPreferNumbers - Numbers are preferred (but not required). | - | ||||||||||||||||||||||||
1384 | \li Qt.ImhPreferUppercase - Upper case letters are preferred (but not required). | - | ||||||||||||||||||||||||
1385 | \li Qt.ImhPreferLowercase - Lower case letters are preferred (but not required). | - | ||||||||||||||||||||||||
1386 | \li Qt.ImhNoPredictiveText - Do not use predictive text (i.e. dictionary lookup) while typing. | - | ||||||||||||||||||||||||
1387 | - | |||||||||||||||||||||||||
1388 | \li Qt.ImhDate - The text editor functions as a date field. | - | ||||||||||||||||||||||||
1389 | \li Qt.ImhTime - The text editor functions as a time field. | - | ||||||||||||||||||||||||
1390 | \endlist | - | ||||||||||||||||||||||||
1391 | - | |||||||||||||||||||||||||
1392 | Flags that restrict input (exclusive flags) are: | - | ||||||||||||||||||||||||
1393 | - | |||||||||||||||||||||||||
1394 | \list | - | ||||||||||||||||||||||||
1395 | \li Qt.ImhDigitsOnly - Only digits are allowed. | - | ||||||||||||||||||||||||
1396 | \li Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign. | - | ||||||||||||||||||||||||
1397 | \li Qt.ImhUppercaseOnly - Only upper case letter input is allowed. | - | ||||||||||||||||||||||||
1398 | \li Qt.ImhLowercaseOnly - Only lower case letter input is allowed. | - | ||||||||||||||||||||||||
1399 | \li Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed. | - | ||||||||||||||||||||||||
1400 | \li Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed. | - | ||||||||||||||||||||||||
1401 | \li Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed. | - | ||||||||||||||||||||||||
1402 | \endlist | - | ||||||||||||||||||||||||
1403 | - | |||||||||||||||||||||||||
1404 | Masks: | - | ||||||||||||||||||||||||
1405 | - | |||||||||||||||||||||||||
1406 | \list | - | ||||||||||||||||||||||||
1407 | \li Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used. | - | ||||||||||||||||||||||||
1408 | \endlist | - | ||||||||||||||||||||||||
1409 | */ | - | ||||||||||||||||||||||||
1410 | - | |||||||||||||||||||||||||
1411 | Qt::InputMethodHints QQuickTextEdit::inputMethodHints() const | - | ||||||||||||||||||||||||
1412 | { | - | ||||||||||||||||||||||||
1413 | #if !QT_CONFIG(im) | - | ||||||||||||||||||||||||
1414 | return Qt::ImhNone; | - | ||||||||||||||||||||||||
1415 | #else | - | ||||||||||||||||||||||||
1416 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1417 | return d->inputMethodHints; executed 6 times by 1 test: return d->inputMethodHints; Executed by:
| 6 | ||||||||||||||||||||||||
1418 | #endif // im | - | ||||||||||||||||||||||||
1419 | } | - | ||||||||||||||||||||||||
1420 | - | |||||||||||||||||||||||||
1421 | void QQuickTextEdit::setInputMethodHints(Qt::InputMethodHints hints) | - | ||||||||||||||||||||||||
1422 | { | - | ||||||||||||||||||||||||
1423 | #if !QT_CONFIG(im) | - | ||||||||||||||||||||||||
1424 | Q_UNUSED(hints); | - | ||||||||||||||||||||||||
1425 | #else | - | ||||||||||||||||||||||||
1426 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1427 | - | |||||||||||||||||||||||||
1428 | if (hints == d->inputMethodHints)
| 2-4 | ||||||||||||||||||||||||
1429 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
1430 | - | |||||||||||||||||||||||||
1431 | d->inputMethodHints = hints; | - | ||||||||||||||||||||||||
1432 | updateInputMethod(Qt::ImHints); | - | ||||||||||||||||||||||||
1433 | emit inputMethodHintsChanged(); | - | ||||||||||||||||||||||||
1434 | #endif // im | - | ||||||||||||||||||||||||
1435 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1436 | - | |||||||||||||||||||||||||
1437 | void QQuickTextEdit::geometryChanged(const QRectF &newGeometry, | - | ||||||||||||||||||||||||
1438 | const QRectF &oldGeometry) | - | ||||||||||||||||||||||||
1439 | { | - | ||||||||||||||||||||||||
1440 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1441 | if (!d->inLayout && ((newGeometry.width() != oldGeometry.width() && widthValid())
| 14-4150 | ||||||||||||||||||||||||
1442 | || (newGeometry.height() != oldGeometry.height() && heightValid()))) {
| 78-2528 | ||||||||||||||||||||||||
1443 | updateSize(); | - | ||||||||||||||||||||||||
1444 | updateWholeDocument(); | - | ||||||||||||||||||||||||
1445 | moveCursorDelegate(); | - | ||||||||||||||||||||||||
1446 | } executed 248 times by 5 tests: end of block Executed by:
| 248 | ||||||||||||||||||||||||
1447 | QQuickImplicitSizeItem::geometryChanged(newGeometry, oldGeometry); | - | ||||||||||||||||||||||||
1448 | - | |||||||||||||||||||||||||
1449 | } executed 4164 times by 6 tests: end of block Executed by:
| 4164 | ||||||||||||||||||||||||
1450 | - | |||||||||||||||||||||||||
1451 | /*! | - | ||||||||||||||||||||||||
1452 | Ensures any delayed caching or data loading the class | - | ||||||||||||||||||||||||
1453 | needs to performed is complete. | - | ||||||||||||||||||||||||
1454 | */ | - | ||||||||||||||||||||||||
1455 | void QQuickTextEdit::componentComplete() | - | ||||||||||||||||||||||||
1456 | { | - | ||||||||||||||||||||||||
1457 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1458 | QQuickImplicitSizeItem::componentComplete(); | - | ||||||||||||||||||||||||
1459 | - | |||||||||||||||||||||||||
1460 | d->document->setBaseUrl(baseUrl()); | - | ||||||||||||||||||||||||
1461 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
1462 | if (d->richText)
| 76-984 | ||||||||||||||||||||||||
1463 | d->control->setHtml(d->text); executed 76 times by 3 tests: d->control->setHtml(d->text); Executed by:
| 76 | ||||||||||||||||||||||||
1464 | else | - | ||||||||||||||||||||||||
1465 | #endif | - | ||||||||||||||||||||||||
1466 | if (!d->text.isEmpty())
| 160-824 | ||||||||||||||||||||||||
1467 | d->control->setPlainText(d->text); executed 824 times by 4 tests: d->control->setPlainText(d->text); Executed by:
| 824 | ||||||||||||||||||||||||
1468 | - | |||||||||||||||||||||||||
1469 | if (d->dirty) {
| 246-814 | ||||||||||||||||||||||||
1470 | d->determineHorizontalAlignment(); | - | ||||||||||||||||||||||||
1471 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
1472 | updateSize(); | - | ||||||||||||||||||||||||
1473 | d->dirty = false; | - | ||||||||||||||||||||||||
1474 | } executed 246 times by 4 tests: end of block Executed by:
| 246 | ||||||||||||||||||||||||
1475 | if (d->cursorComponent && isCursorVisible())
| 4-1038 | ||||||||||||||||||||||||
1476 | QQuickTextUtil::createCursor(d); executed 4 times by 1 test: QQuickTextUtil::createCursor(d); Executed by:
| 4 | ||||||||||||||||||||||||
1477 | } executed 1060 times by 6 tests: end of block Executed by:
| 1060 | ||||||||||||||||||||||||
1478 | - | |||||||||||||||||||||||||
1479 | /*! | - | ||||||||||||||||||||||||
1480 | \qmlproperty bool QtQuick::TextEdit::selectByKeyboard | - | ||||||||||||||||||||||||
1481 | \since 5.1 | - | ||||||||||||||||||||||||
1482 | - | |||||||||||||||||||||||||
1483 | Defaults to true when the editor is editable, and false | - | ||||||||||||||||||||||||
1484 | when read-only. | - | ||||||||||||||||||||||||
1485 | - | |||||||||||||||||||||||||
1486 | If true, the user can use the keyboard to select text | - | ||||||||||||||||||||||||
1487 | even if the editor is read-only. If false, the user | - | ||||||||||||||||||||||||
1488 | cannot use the keyboard to select text even if the | - | ||||||||||||||||||||||||
1489 | editor is editable. | - | ||||||||||||||||||||||||
1490 | - | |||||||||||||||||||||||||
1491 | \sa readOnly | - | ||||||||||||||||||||||||
1492 | */ | - | ||||||||||||||||||||||||
1493 | bool QQuickTextEdit::selectByKeyboard() const | - | ||||||||||||||||||||||||
1494 | { | - | ||||||||||||||||||||||||
1495 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1496 | if (d->selectByKeyboardSet)
| 8-38 | ||||||||||||||||||||||||
1497 | return d->selectByKeyboard; executed 8 times by 1 test: return d->selectByKeyboard; Executed by:
| 8 | ||||||||||||||||||||||||
1498 | return !isReadOnly(); executed 38 times by 1 test: return !isReadOnly(); Executed by:
| 38 | ||||||||||||||||||||||||
1499 | } | - | ||||||||||||||||||||||||
1500 | - | |||||||||||||||||||||||||
1501 | void QQuickTextEdit::setSelectByKeyboard(bool on) | - | ||||||||||||||||||||||||
1502 | { | - | ||||||||||||||||||||||||
1503 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1504 | bool was = selectByKeyboard(); | - | ||||||||||||||||||||||||
1505 | if (!d->selectByKeyboardSet || was != on) {
| 0-34 | ||||||||||||||||||||||||
1506 | d->selectByKeyboardSet = true; | - | ||||||||||||||||||||||||
1507 | d->selectByKeyboard = on; | - | ||||||||||||||||||||||||
1508 | if (on)
| 18 | ||||||||||||||||||||||||
1509 | d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByKeyboard); executed 18 times by 1 test: d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByKeyboard); Executed by:
| 18 | ||||||||||||||||||||||||
1510 | else | - | ||||||||||||||||||||||||
1511 | d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByKeyboard); executed 18 times by 1 test: d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByKeyboard); Executed by:
| 18 | ||||||||||||||||||||||||
1512 | emit selectByKeyboardChanged(on); | - | ||||||||||||||||||||||||
1513 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
1514 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
1515 | - | |||||||||||||||||||||||||
1516 | /*! | - | ||||||||||||||||||||||||
1517 | \qmlproperty bool QtQuick::TextEdit::selectByMouse | - | ||||||||||||||||||||||||
1518 | - | |||||||||||||||||||||||||
1519 | Defaults to false. | - | ||||||||||||||||||||||||
1520 | - | |||||||||||||||||||||||||
1521 | If true, the user can use the mouse to select text in some | - | ||||||||||||||||||||||||
1522 | platform-specific way. Note that for some platforms this may | - | ||||||||||||||||||||||||
1523 | not be an appropriate interaction; it may conflict with how | - | ||||||||||||||||||||||||
1524 | the text needs to behave inside a Flickable, for example. | - | ||||||||||||||||||||||||
1525 | */ | - | ||||||||||||||||||||||||
1526 | bool QQuickTextEdit::selectByMouse() const | - | ||||||||||||||||||||||||
1527 | { | - | ||||||||||||||||||||||||
1528 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1529 | return d->selectByMouse; executed 6 times by 1 test: return d->selectByMouse; Executed by:
| 6 | ||||||||||||||||||||||||
1530 | } | - | ||||||||||||||||||||||||
1531 | - | |||||||||||||||||||||||||
1532 | void QQuickTextEdit::setSelectByMouse(bool on) | - | ||||||||||||||||||||||||
1533 | { | - | ||||||||||||||||||||||||
1534 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1535 | if (d->selectByMouse != on) {
| 8-114 | ||||||||||||||||||||||||
1536 | d->selectByMouse = on; | - | ||||||||||||||||||||||||
1537 | setKeepMouseGrab(on); | - | ||||||||||||||||||||||||
1538 | if (on)
| 2-112 | ||||||||||||||||||||||||
1539 | d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByMouse); executed 112 times by 2 tests: d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByMouse); Executed by:
| 112 | ||||||||||||||||||||||||
1540 | else | - | ||||||||||||||||||||||||
1541 | d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByMouse); executed 2 times by 1 test: d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByMouse); Executed by:
| 2 | ||||||||||||||||||||||||
1542 | emit selectByMouseChanged(on); | - | ||||||||||||||||||||||||
1543 | } executed 114 times by 2 tests: end of block Executed by:
| 114 | ||||||||||||||||||||||||
1544 | } executed 122 times by 2 tests: end of block Executed by:
| 122 | ||||||||||||||||||||||||
1545 | - | |||||||||||||||||||||||||
1546 | /*! | - | ||||||||||||||||||||||||
1547 | \qmlproperty enumeration QtQuick::TextEdit::mouseSelectionMode | - | ||||||||||||||||||||||||
1548 | - | |||||||||||||||||||||||||
1549 | Specifies how text should be selected using a mouse. | - | ||||||||||||||||||||||||
1550 | - | |||||||||||||||||||||||||
1551 | \list | - | ||||||||||||||||||||||||
1552 | \li TextEdit.SelectCharacters - The selection is updated with individual characters. (Default) | - | ||||||||||||||||||||||||
1553 | \li TextEdit.SelectWords - The selection is updated with whole words. | - | ||||||||||||||||||||||||
1554 | \endlist | - | ||||||||||||||||||||||||
1555 | - | |||||||||||||||||||||||||
1556 | This property only applies when \l selectByMouse is true. | - | ||||||||||||||||||||||||
1557 | */ | - | ||||||||||||||||||||||||
1558 | QQuickTextEdit::SelectionMode QQuickTextEdit::mouseSelectionMode() const | - | ||||||||||||||||||||||||
1559 | { | - | ||||||||||||||||||||||||
1560 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1561 | return d->mouseSelectionMode; executed 6 times by 1 test: return d->mouseSelectionMode; Executed by:
| 6 | ||||||||||||||||||||||||
1562 | } | - | ||||||||||||||||||||||||
1563 | - | |||||||||||||||||||||||||
1564 | void QQuickTextEdit::setMouseSelectionMode(SelectionMode mode) | - | ||||||||||||||||||||||||
1565 | { | - | ||||||||||||||||||||||||
1566 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1567 | if (d->mouseSelectionMode != mode) {
| 4-30 | ||||||||||||||||||||||||
1568 | d->mouseSelectionMode = mode; | - | ||||||||||||||||||||||||
1569 | d->control->setWordSelectionEnabled(mode == SelectWords); | - | ||||||||||||||||||||||||
1570 | emit mouseSelectionModeChanged(mode); | - | ||||||||||||||||||||||||
1571 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
1572 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
1573 | - | |||||||||||||||||||||||||
1574 | /*! | - | ||||||||||||||||||||||||
1575 | \qmlproperty bool QtQuick::TextEdit::readOnly | - | ||||||||||||||||||||||||
1576 | - | |||||||||||||||||||||||||
1577 | Whether the user can interact with the TextEdit item. If this | - | ||||||||||||||||||||||||
1578 | property is set to true the text cannot be edited by user interaction. | - | ||||||||||||||||||||||||
1579 | - | |||||||||||||||||||||||||
1580 | By default this property is false. | - | ||||||||||||||||||||||||
1581 | */ | - | ||||||||||||||||||||||||
1582 | void QQuickTextEdit::setReadOnly(bool r) | - | ||||||||||||||||||||||||
1583 | { | - | ||||||||||||||||||||||||
1584 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1585 | if (r == isReadOnly())
| 36-62 | ||||||||||||||||||||||||
1586 | return; executed 36 times by 3 tests: return; Executed by:
| 36 | ||||||||||||||||||||||||
1587 | - | |||||||||||||||||||||||||
1588 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1589 | setFlag(QQuickItem::ItemAcceptsInputMethod, !r); | - | ||||||||||||||||||||||||
1590 | #endif | - | ||||||||||||||||||||||||
1591 | Qt::TextInteractionFlags flags = Qt::LinksAccessibleByMouse; | - | ||||||||||||||||||||||||
1592 | if (d->selectByMouse)
| 12-50 | ||||||||||||||||||||||||
1593 | flags = flags | Qt::TextSelectableByMouse; executed 12 times by 1 test: flags = flags | Qt::TextSelectableByMouse; Executed by:
| 12 | ||||||||||||||||||||||||
1594 | if (d->selectByKeyboardSet && d->selectByKeyboard)
| 8-44 | ||||||||||||||||||||||||
1595 | flags = flags | Qt::TextSelectableByKeyboard; executed 10 times by 1 test: flags = flags | Qt::TextSelectableByKeyboard; Executed by:
| 10 | ||||||||||||||||||||||||
1596 | else if (!d->selectByKeyboardSet && !r)
| 8-44 | ||||||||||||||||||||||||
1597 | flags = flags | Qt::TextSelectableByKeyboard; executed 16 times by 1 test: flags = flags | Qt::TextSelectableByKeyboard; Executed by:
| 16 | ||||||||||||||||||||||||
1598 | if (!r)
| 18-44 | ||||||||||||||||||||||||
1599 | flags = flags | Qt::TextEditable; executed 18 times by 1 test: flags = flags | Qt::TextEditable; Executed by:
| 18 | ||||||||||||||||||||||||
1600 | d->control->setTextInteractionFlags(flags); | - | ||||||||||||||||||||||||
1601 | d->control->moveCursor(QTextCursor::End); | - | ||||||||||||||||||||||||
1602 | - | |||||||||||||||||||||||||
1603 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1604 | updateInputMethod(Qt::ImEnabled); | - | ||||||||||||||||||||||||
1605 | #endif | - | ||||||||||||||||||||||||
1606 | q_canPasteChanged(); | - | ||||||||||||||||||||||||
1607 | emit readOnlyChanged(r); | - | ||||||||||||||||||||||||
1608 | if (!d->selectByKeyboardSet)
| 18-44 | ||||||||||||||||||||||||
1609 | emit selectByKeyboardChanged(!r); executed 44 times by 2 tests: selectByKeyboardChanged(!r); Executed by:
| 44 | ||||||||||||||||||||||||
1610 | if (r) {
| 18-44 | ||||||||||||||||||||||||
1611 | setCursorVisible(false); | - | ||||||||||||||||||||||||
1612 | } else if (hasActiveFocus()) { executed 44 times by 2 tests: end of block Executed by:
| 6-44 | ||||||||||||||||||||||||
1613 | setCursorVisible(true); | - | ||||||||||||||||||||||||
1614 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
1615 | } executed 62 times by 2 tests: end of block Executed by:
| 62 | ||||||||||||||||||||||||
1616 | - | |||||||||||||||||||||||||
1617 | bool QQuickTextEdit::isReadOnly() const | - | ||||||||||||||||||||||||
1618 | { | - | ||||||||||||||||||||||||
1619 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1620 | return !(d->control->textInteractionFlags() & Qt::TextEditable); executed 1732 times by 4 tests: return !(d->control->textInteractionFlags() & Qt::TextEditable); Executed by:
| 1732 | ||||||||||||||||||||||||
1621 | } | - | ||||||||||||||||||||||||
1622 | - | |||||||||||||||||||||||||
1623 | /*! | - | ||||||||||||||||||||||||
1624 | \qmlproperty rectangle QtQuick::TextEdit::cursorRectangle | - | ||||||||||||||||||||||||
1625 | - | |||||||||||||||||||||||||
1626 | The rectangle where the standard text cursor is rendered | - | ||||||||||||||||||||||||
1627 | within the text edit. Read-only. | - | ||||||||||||||||||||||||
1628 | - | |||||||||||||||||||||||||
1629 | The position and height of a custom cursorDelegate are updated to follow the cursorRectangle | - | ||||||||||||||||||||||||
1630 | automatically when it changes. The width of the delegate is unaffected by changes in the | - | ||||||||||||||||||||||||
1631 | cursor rectangle. | - | ||||||||||||||||||||||||
1632 | */ | - | ||||||||||||||||||||||||
1633 | QRectF QQuickTextEdit::cursorRectangle() const | - | ||||||||||||||||||||||||
1634 | { | - | ||||||||||||||||||||||||
1635 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1636 | return d->control->cursorRect().translated(d->xoff, d->yoff); executed 2190 times by 2 tests: return d->control->cursorRect().translated(d->xoff, d->yoff); Executed by:
| 2190 | ||||||||||||||||||||||||
1637 | } | - | ||||||||||||||||||||||||
1638 | - | |||||||||||||||||||||||||
1639 | bool QQuickTextEdit::event(QEvent *event) | - | ||||||||||||||||||||||||
1640 | { | - | ||||||||||||||||||||||||
1641 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1642 | if (event->type() == QEvent::ShortcutOverride) {
| 660-7114 | ||||||||||||||||||||||||
1643 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | - | ||||||||||||||||||||||||
1644 | return event->isAccepted(); executed 660 times by 2 tests: return event->isAccepted(); Executed by:
| 660 | ||||||||||||||||||||||||
1645 | } | - | ||||||||||||||||||||||||
1646 | return QQuickImplicitSizeItem::event(event); executed 7114 times by 6 tests: return QQuickImplicitSizeItem::event(event); Executed by:
| 7114 | ||||||||||||||||||||||||
1647 | } | - | ||||||||||||||||||||||||
1648 | - | |||||||||||||||||||||||||
1649 | /*! | - | ||||||||||||||||||||||||
1650 | \qmlproperty bool QtQuick::TextEdit::overwriteMode | - | ||||||||||||||||||||||||
1651 | \since 5.8 | - | ||||||||||||||||||||||||
1652 | Whether text entered by the user will overwrite existing text. | - | ||||||||||||||||||||||||
1653 | - | |||||||||||||||||||||||||
1654 | As with many text editors, the text editor widget can be configured | - | ||||||||||||||||||||||||
1655 | to insert or overwrite existing text with new text entered by the user. | - | ||||||||||||||||||||||||
1656 | - | |||||||||||||||||||||||||
1657 | If this property is \c true, existing text is overwritten, character-for-character | - | ||||||||||||||||||||||||
1658 | by new text; otherwise, text is inserted at the cursor position, displacing | - | ||||||||||||||||||||||||
1659 | existing text. | - | ||||||||||||||||||||||||
1660 | - | |||||||||||||||||||||||||
1661 | By default, this property is \c false (new text does not overwrite existing text). | - | ||||||||||||||||||||||||
1662 | */ | - | ||||||||||||||||||||||||
1663 | bool QQuickTextEdit::overwriteMode() const | - | ||||||||||||||||||||||||
1664 | { | - | ||||||||||||||||||||||||
1665 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1666 | return d->control->overwriteMode(); executed 6 times by 1 test: return d->control->overwriteMode(); Executed by:
| 6 | ||||||||||||||||||||||||
1667 | } | - | ||||||||||||||||||||||||
1668 | - | |||||||||||||||||||||||||
1669 | void QQuickTextEdit::setOverwriteMode(bool overwrite) | - | ||||||||||||||||||||||||
1670 | { | - | ||||||||||||||||||||||||
1671 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1672 | d->control->setOverwriteMode(overwrite); | - | ||||||||||||||||||||||||
1673 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
1674 | - | |||||||||||||||||||||||||
1675 | /*! | - | ||||||||||||||||||||||||
1676 | \overload | - | ||||||||||||||||||||||||
1677 | Handles the given key \a event. | - | ||||||||||||||||||||||||
1678 | */ | - | ||||||||||||||||||||||||
1679 | void QQuickTextEdit::keyPressEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||
1680 | { | - | ||||||||||||||||||||||||
1681 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1682 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | - | ||||||||||||||||||||||||
1683 | if (!event->isAccepted())
| 222-806 | ||||||||||||||||||||||||
1684 | QQuickImplicitSizeItem::keyPressEvent(event); executed 222 times by 3 tests: QQuickImplicitSizeItem::keyPressEvent(event); Executed by:
| 222 | ||||||||||||||||||||||||
1685 | } executed 1028 times by 3 tests: end of block Executed by:
| 1028 | ||||||||||||||||||||||||
1686 | - | |||||||||||||||||||||||||
1687 | /*! | - | ||||||||||||||||||||||||
1688 | \overload | - | ||||||||||||||||||||||||
1689 | Handles the given key \a event. | - | ||||||||||||||||||||||||
1690 | */ | - | ||||||||||||||||||||||||
1691 | void QQuickTextEdit::keyReleaseEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||
1692 | { | - | ||||||||||||||||||||||||
1693 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1694 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | - | ||||||||||||||||||||||||
1695 | if (!event->isAccepted())
| 0-1012 | ||||||||||||||||||||||||
1696 | QQuickImplicitSizeItem::keyReleaseEvent(event); never executed: QQuickImplicitSizeItem::keyReleaseEvent(event); | 0 | ||||||||||||||||||||||||
1697 | } executed 1012 times by 2 tests: end of block Executed by:
| 1012 | ||||||||||||||||||||||||
1698 | - | |||||||||||||||||||||||||
1699 | /*! | - | ||||||||||||||||||||||||
1700 | \qmlmethod QtQuick::TextEdit::deselect() | - | ||||||||||||||||||||||||
1701 | - | |||||||||||||||||||||||||
1702 | Removes active text selection. | - | ||||||||||||||||||||||||
1703 | */ | - | ||||||||||||||||||||||||
1704 | void QQuickTextEdit::deselect() | - | ||||||||||||||||||||||||
1705 | { | - | ||||||||||||||||||||||||
1706 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1707 | QTextCursor c = d->control->textCursor(); | - | ||||||||||||||||||||||||
1708 | c.clearSelection(); | - | ||||||||||||||||||||||||
1709 | d->control->setTextCursor(c); | - | ||||||||||||||||||||||||
1710 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1711 | - | |||||||||||||||||||||||||
1712 | /*! | - | ||||||||||||||||||||||||
1713 | \qmlmethod QtQuick::TextEdit::selectAll() | - | ||||||||||||||||||||||||
1714 | - | |||||||||||||||||||||||||
1715 | Causes all text to be selected. | - | ||||||||||||||||||||||||
1716 | */ | - | ||||||||||||||||||||||||
1717 | void QQuickTextEdit::selectAll() | - | ||||||||||||||||||||||||
1718 | { | - | ||||||||||||||||||||||||
1719 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1720 | d->control->selectAll(); | - | ||||||||||||||||||||||||
1721 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
1722 | - | |||||||||||||||||||||||||
1723 | /*! | - | ||||||||||||||||||||||||
1724 | \qmlmethod QtQuick::TextEdit::selectWord() | - | ||||||||||||||||||||||||
1725 | - | |||||||||||||||||||||||||
1726 | Causes the word closest to the current cursor position to be selected. | - | ||||||||||||||||||||||||
1727 | */ | - | ||||||||||||||||||||||||
1728 | void QQuickTextEdit::selectWord() | - | ||||||||||||||||||||||||
1729 | { | - | ||||||||||||||||||||||||
1730 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1731 | QTextCursor c = d->control->textCursor(); | - | ||||||||||||||||||||||||
1732 | c.select(QTextCursor::WordUnderCursor); | - | ||||||||||||||||||||||||
1733 | d->control->setTextCursor(c); | - | ||||||||||||||||||||||||
1734 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1735 | - | |||||||||||||||||||||||||
1736 | /*! | - | ||||||||||||||||||||||||
1737 | \qmlmethod QtQuick::TextEdit::select(int start, int end) | - | ||||||||||||||||||||||||
1738 | - | |||||||||||||||||||||||||
1739 | Causes the text from \a start to \a end to be selected. | - | ||||||||||||||||||||||||
1740 | - | |||||||||||||||||||||||||
1741 | If either start or end is out of range, the selection is not changed. | - | ||||||||||||||||||||||||
1742 | - | |||||||||||||||||||||||||
1743 | After calling this, selectionStart will become the lesser | - | ||||||||||||||||||||||||
1744 | and selectionEnd will become the greater (regardless of the order passed | - | ||||||||||||||||||||||||
1745 | to this method). | - | ||||||||||||||||||||||||
1746 | - | |||||||||||||||||||||||||
1747 | \sa selectionStart, selectionEnd | - | ||||||||||||||||||||||||
1748 | */ | - | ||||||||||||||||||||||||
1749 | void QQuickTextEdit::select(int start, int end) | - | ||||||||||||||||||||||||
1750 | { | - | ||||||||||||||||||||||||
1751 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1752 | if (start < 0 || end < 0 || start >= d->document->characterCount() || end >= d->document->characterCount())
| 4-360 | ||||||||||||||||||||||||
1753 | return; executed 16 times by 1 test: return; Executed by:
| 16 | ||||||||||||||||||||||||
1754 | QTextCursor cursor = d->control->textCursor(); | - | ||||||||||||||||||||||||
1755 | cursor.beginEditBlock(); | - | ||||||||||||||||||||||||
1756 | cursor.setPosition(start, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1757 | cursor.setPosition(end, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1758 | cursor.endEditBlock(); | - | ||||||||||||||||||||||||
1759 | d->control->setTextCursor(cursor); | - | ||||||||||||||||||||||||
1760 | - | |||||||||||||||||||||||||
1761 | // QTBUG-11100 | - | ||||||||||||||||||||||||
1762 | updateSelection(); | - | ||||||||||||||||||||||||
1763 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1764 | updateInputMethod(); | - | ||||||||||||||||||||||||
1765 | #endif | - | ||||||||||||||||||||||||
1766 | } executed 348 times by 1 test: end of block Executed by:
| 348 | ||||||||||||||||||||||||
1767 | - | |||||||||||||||||||||||||
1768 | /*! | - | ||||||||||||||||||||||||
1769 | \qmlmethod QtQuick::TextEdit::isRightToLeft(int start, int end) | - | ||||||||||||||||||||||||
1770 | - | |||||||||||||||||||||||||
1771 | Returns true if the natural reading direction of the editor text | - | ||||||||||||||||||||||||
1772 | found between positions \a start and \a end is right to left. | - | ||||||||||||||||||||||||
1773 | */ | - | ||||||||||||||||||||||||
1774 | bool QQuickTextEdit::isRightToLeft(int start, int end) | - | ||||||||||||||||||||||||
1775 | { | - | ||||||||||||||||||||||||
1776 | if (start > end) {
| 4-164 | ||||||||||||||||||||||||
1777 | qmlWarning(this) << "isRightToLeft(start, end) called with the end property being smaller than the start."; | - | ||||||||||||||||||||||||
1778 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
1779 | } else { | - | ||||||||||||||||||||||||
1780 | return getText(start, end).isRightToLeft(); executed 164 times by 1 test: return getText(start, end).isRightToLeft(); Executed by:
| 164 | ||||||||||||||||||||||||
1781 | } | - | ||||||||||||||||||||||||
1782 | } | - | ||||||||||||||||||||||||
1783 | - | |||||||||||||||||||||||||
1784 | #if QT_CONFIG(clipboard) | - | ||||||||||||||||||||||||
1785 | /*! | - | ||||||||||||||||||||||||
1786 | \qmlmethod QtQuick::TextEdit::cut() | - | ||||||||||||||||||||||||
1787 | - | |||||||||||||||||||||||||
1788 | Moves the currently selected text to the system clipboard. | - | ||||||||||||||||||||||||
1789 | */ | - | ||||||||||||||||||||||||
1790 | void QQuickTextEdit::cut() | - | ||||||||||||||||||||||||
1791 | { | - | ||||||||||||||||||||||||
1792 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1793 | d->control->cut(); | - | ||||||||||||||||||||||||
1794 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
1795 | - | |||||||||||||||||||||||||
1796 | /*! | - | ||||||||||||||||||||||||
1797 | \qmlmethod QtQuick::TextEdit::copy() | - | ||||||||||||||||||||||||
1798 | - | |||||||||||||||||||||||||
1799 | Copies the currently selected text to the system clipboard. | - | ||||||||||||||||||||||||
1800 | */ | - | ||||||||||||||||||||||||
1801 | void QQuickTextEdit::copy() | - | ||||||||||||||||||||||||
1802 | { | - | ||||||||||||||||||||||||
1803 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1804 | d->control->copy(); | - | ||||||||||||||||||||||||
1805 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
1806 | - | |||||||||||||||||||||||||
1807 | /*! | - | ||||||||||||||||||||||||
1808 | \qmlmethod QtQuick::TextEdit::paste() | - | ||||||||||||||||||||||||
1809 | - | |||||||||||||||||||||||||
1810 | Replaces the currently selected text by the contents of the system clipboard. | - | ||||||||||||||||||||||||
1811 | */ | - | ||||||||||||||||||||||||
1812 | void QQuickTextEdit::paste() | - | ||||||||||||||||||||||||
1813 | { | - | ||||||||||||||||||||||||
1814 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1815 | d->control->paste(); | - | ||||||||||||||||||||||||
1816 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
1817 | #endif // clipboard | - | ||||||||||||||||||||||||
1818 | - | |||||||||||||||||||||||||
1819 | - | |||||||||||||||||||||||||
1820 | /*! | - | ||||||||||||||||||||||||
1821 | \qmlmethod QtQuick::TextEdit::undo() | - | ||||||||||||||||||||||||
1822 | - | |||||||||||||||||||||||||
1823 | Undoes the last operation if undo is \l {canUndo}{available}. Deselects any | - | ||||||||||||||||||||||||
1824 | current selection, and updates the selection start to the current cursor | - | ||||||||||||||||||||||||
1825 | position. | - | ||||||||||||||||||||||||
1826 | */ | - | ||||||||||||||||||||||||
1827 | - | |||||||||||||||||||||||||
1828 | void QQuickTextEdit::undo() | - | ||||||||||||||||||||||||
1829 | { | - | ||||||||||||||||||||||||
1830 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1831 | d->control->undo(); | - | ||||||||||||||||||||||||
1832 | } executed 108 times by 1 test: end of block Executed by:
| 108 | ||||||||||||||||||||||||
1833 | - | |||||||||||||||||||||||||
1834 | /*! | - | ||||||||||||||||||||||||
1835 | \qmlmethod QtQuick::TextEdit::redo() | - | ||||||||||||||||||||||||
1836 | - | |||||||||||||||||||||||||
1837 | Redoes the last operation if redo is \l {canRedo}{available}. | - | ||||||||||||||||||||||||
1838 | */ | - | ||||||||||||||||||||||||
1839 | - | |||||||||||||||||||||||||
1840 | void QQuickTextEdit::redo() | - | ||||||||||||||||||||||||
1841 | { | - | ||||||||||||||||||||||||
1842 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1843 | d->control->redo(); | - | ||||||||||||||||||||||||
1844 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1845 | - | |||||||||||||||||||||||||
1846 | /*! | - | ||||||||||||||||||||||||
1847 | \overload | - | ||||||||||||||||||||||||
1848 | Handles the given mouse \a event. | - | ||||||||||||||||||||||||
1849 | */ | - | ||||||||||||||||||||||||
1850 | void QQuickTextEdit::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1851 | { | - | ||||||||||||||||||||||||
1852 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1853 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | - | ||||||||||||||||||||||||
1854 | if (d->focusOnPress){
| 16-498 | ||||||||||||||||||||||||
1855 | bool hadActiveFocus = hasActiveFocus(); | - | ||||||||||||||||||||||||
1856 | forceActiveFocus(Qt::MouseFocusReason); | - | ||||||||||||||||||||||||
1857 | // re-open input panel on press if already focused | - | ||||||||||||||||||||||||
1858 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1859 | if (hasActiveFocus() && hadActiveFocus && !isReadOnly())
| 0-498 | ||||||||||||||||||||||||
1860 | qGuiApp->inputMethod()->show(); executed 462 times by 1 test: (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->show(); Executed by:
| 462 | ||||||||||||||||||||||||
1861 | #else | - | ||||||||||||||||||||||||
1862 | Q_UNUSED(hadActiveFocus); | - | ||||||||||||||||||||||||
1863 | #endif | - | ||||||||||||||||||||||||
1864 | } executed 498 times by 1 test: end of block Executed by:
| 498 | ||||||||||||||||||||||||
1865 | if (!event->isAccepted())
| 0-514 | ||||||||||||||||||||||||
1866 | QQuickImplicitSizeItem::mousePressEvent(event); never executed: QQuickImplicitSizeItem::mousePressEvent(event); | 0 | ||||||||||||||||||||||||
1867 | } executed 514 times by 1 test: end of block Executed by:
| 514 | ||||||||||||||||||||||||
1868 | - | |||||||||||||||||||||||||
1869 | /*! | - | ||||||||||||||||||||||||
1870 | \overload | - | ||||||||||||||||||||||||
1871 | Handles the given mouse \a event. | - | ||||||||||||||||||||||||
1872 | */ | - | ||||||||||||||||||||||||
1873 | void QQuickTextEdit::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1874 | { | - | ||||||||||||||||||||||||
1875 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1876 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | - | ||||||||||||||||||||||||
1877 | - | |||||||||||||||||||||||||
1878 | if (!event->isAccepted())
| 0-514 | ||||||||||||||||||||||||
1879 | QQuickImplicitSizeItem::mouseReleaseEvent(event); never executed: QQuickImplicitSizeItem::mouseReleaseEvent(event); | 0 | ||||||||||||||||||||||||
1880 | } executed 514 times by 1 test: end of block Executed by:
| 514 | ||||||||||||||||||||||||
1881 | - | |||||||||||||||||||||||||
1882 | /*! | - | ||||||||||||||||||||||||
1883 | \overload | - | ||||||||||||||||||||||||
1884 | Handles the given mouse \a event. | - | ||||||||||||||||||||||||
1885 | */ | - | ||||||||||||||||||||||||
1886 | void QQuickTextEdit::mouseDoubleClickEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1887 | { | - | ||||||||||||||||||||||||
1888 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1889 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | - | ||||||||||||||||||||||||
1890 | if (!event->isAccepted())
| 0-104 | ||||||||||||||||||||||||
1891 | QQuickImplicitSizeItem::mouseDoubleClickEvent(event); never executed: QQuickImplicitSizeItem::mouseDoubleClickEvent(event); | 0 | ||||||||||||||||||||||||
1892 | } executed 104 times by 1 test: end of block Executed by:
| 104 | ||||||||||||||||||||||||
1893 | - | |||||||||||||||||||||||||
1894 | /*! | - | ||||||||||||||||||||||||
1895 | \overload | - | ||||||||||||||||||||||||
1896 | Handles the given mouse \a event. | - | ||||||||||||||||||||||||
1897 | */ | - | ||||||||||||||||||||||||
1898 | void QQuickTextEdit::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1899 | { | - | ||||||||||||||||||||||||
1900 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1901 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | - | ||||||||||||||||||||||||
1902 | if (!event->isAccepted())
| 0-138 | ||||||||||||||||||||||||
1903 | QQuickImplicitSizeItem::mouseMoveEvent(event); never executed: QQuickImplicitSizeItem::mouseMoveEvent(event); | 0 | ||||||||||||||||||||||||
1904 | } executed 138 times by 1 test: end of block Executed by:
| 138 | ||||||||||||||||||||||||
1905 | - | |||||||||||||||||||||||||
1906 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1907 | /*! | - | ||||||||||||||||||||||||
1908 | \overload | - | ||||||||||||||||||||||||
1909 | Handles the given input method \a event. | - | ||||||||||||||||||||||||
1910 | */ | - | ||||||||||||||||||||||||
1911 | void QQuickTextEdit::inputMethodEvent(QInputMethodEvent *event) | - | ||||||||||||||||||||||||
1912 | { | - | ||||||||||||||||||||||||
1913 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1914 | const bool wasComposing = isInputMethodComposing(); | - | ||||||||||||||||||||||||
1915 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | - | ||||||||||||||||||||||||
1916 | setCursorVisible(d->control->cursorVisible()); | - | ||||||||||||||||||||||||
1917 | if (wasComposing != isInputMethodComposing())
| 50-274 | ||||||||||||||||||||||||
1918 | emit inputMethodComposingChanged(); executed 50 times by 1 test: inputMethodComposingChanged(); Executed by:
| 50 | ||||||||||||||||||||||||
1919 | } executed 324 times by 1 test: end of block Executed by:
| 324 | ||||||||||||||||||||||||
1920 | - | |||||||||||||||||||||||||
1921 | /*! | - | ||||||||||||||||||||||||
1922 | \overload | - | ||||||||||||||||||||||||
1923 | Returns the value of the given \a property and \a argument. | - | ||||||||||||||||||||||||
1924 | */ | - | ||||||||||||||||||||||||
1925 | QVariant QQuickTextEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const | - | ||||||||||||||||||||||||
1926 | { | - | ||||||||||||||||||||||||
1927 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
1928 | - | |||||||||||||||||||||||||
1929 | QVariant v; | - | ||||||||||||||||||||||||
1930 | switch (property) { | - | ||||||||||||||||||||||||
1931 | case Qt::ImEnabled: executed 544 times by 3 tests: case Qt::ImEnabled: Executed by:
| 544 | ||||||||||||||||||||||||
1932 | v = (bool)(flags() & ItemAcceptsInputMethod); | - | ||||||||||||||||||||||||
1933 | break; executed 544 times by 3 tests: break; Executed by:
| 544 | ||||||||||||||||||||||||
1934 | case Qt::ImHints: executed 338 times by 3 tests: case Qt::ImHints: Executed by:
| 338 | ||||||||||||||||||||||||
1935 | v = (int)d->effectiveInputMethodHints(); | - | ||||||||||||||||||||||||
1936 | break; executed 338 times by 3 tests: break; Executed by:
| 338 | ||||||||||||||||||||||||
1937 | case Qt::ImInputItemClipRectangle: never executed: case Qt::ImInputItemClipRectangle: | 0 | ||||||||||||||||||||||||
1938 | v = QQuickItem::inputMethodQuery(property); | - | ||||||||||||||||||||||||
1939 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1940 | default: executed 26 times by 1 test: default: Executed by:
| 26 | ||||||||||||||||||||||||
1941 | if (property == Qt::ImCursorPosition && !argument.isNull())
| 0-26 | ||||||||||||||||||||||||
1942 | argument = QVariant(argument.toPointF() - QPointF(d->xoff, d->yoff)); never executed: argument = QVariant(argument.toPointF() - QPointF(d->xoff, d->yoff)); | 0 | ||||||||||||||||||||||||
1943 | v = d->control->inputMethodQuery(property, argument); | - | ||||||||||||||||||||||||
1944 | if (property == Qt::ImCursorRectangle || property == Qt::ImAnchorRectangle)
| 0-26 | ||||||||||||||||||||||||
1945 | v = QVariant(v.toRectF().translated(d->xoff, d->yoff)); executed 26 times by 1 test: v = QVariant(v.toRectF().translated(d->xoff, d->yoff)); Executed by:
| 26 | ||||||||||||||||||||||||
1946 | break; executed 26 times by 1 test: break; Executed by:
| 26 | ||||||||||||||||||||||||
1947 | } | - | ||||||||||||||||||||||||
1948 | return v; executed 908 times by 3 tests: return v; Executed by:
| 908 | ||||||||||||||||||||||||
1949 | } | - | ||||||||||||||||||||||||
1950 | - | |||||||||||||||||||||||||
1951 | /*! | - | ||||||||||||||||||||||||
1952 | \overload | - | ||||||||||||||||||||||||
1953 | Returns the value of the given \a property. | - | ||||||||||||||||||||||||
1954 | */ | - | ||||||||||||||||||||||||
1955 | QVariant QQuickTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const | - | ||||||||||||||||||||||||
1956 | { | - | ||||||||||||||||||||||||
1957 | return inputMethodQuery(property, QVariant()); executed 908 times by 3 tests: return inputMethodQuery(property, QVariant()); Executed by:
| 908 | ||||||||||||||||||||||||
1958 | } | - | ||||||||||||||||||||||||
1959 | #endif // im | - | ||||||||||||||||||||||||
1960 | - | |||||||||||||||||||||||||
1961 | void QQuickTextEdit::triggerPreprocess() | - | ||||||||||||||||||||||||
1962 | { | - | ||||||||||||||||||||||||
1963 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1964 | if (d->updateType == QQuickTextEditPrivate::UpdateNone)
| 0 | ||||||||||||||||||||||||
1965 | d->updateType = QQuickTextEditPrivate::UpdateOnlyPreprocess; never executed: d->updateType = QQuickTextEditPrivate::UpdateOnlyPreprocess; | 0 | ||||||||||||||||||||||||
1966 | polish(); | - | ||||||||||||||||||||||||
1967 | update(); | - | ||||||||||||||||||||||||
1968 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1969 | - | |||||||||||||||||||||||||
1970 | typedef QQuickTextEditPrivate::Node TextNode; | - | ||||||||||||||||||||||||
1971 | using TextNodeIterator = QQuickTextEditPrivate::TextNodeIterator; | - | ||||||||||||||||||||||||
1972 | - | |||||||||||||||||||||||||
1973 | static inline bool operator<(const TextNode &n1, const TextNode &n2) | - | ||||||||||||||||||||||||
1974 | { | - | ||||||||||||||||||||||||
1975 | return n1.startPos() < n2.startPos(); executed 5896 times by 2 tests: return n1.startPos() < n2.startPos(); Executed by:
| 5896 | ||||||||||||||||||||||||
1976 | } | - | ||||||||||||||||||||||||
1977 | - | |||||||||||||||||||||||||
1978 | static inline void updateNodeTransform(QQuickTextNode* node, const QPointF &topLeft) | - | ||||||||||||||||||||||||
1979 | { | - | ||||||||||||||||||||||||
1980 | QMatrix4x4 transformMatrix; | - | ||||||||||||||||||||||||
1981 | transformMatrix.translate(topLeft.x(), topLeft.y()); | - | ||||||||||||||||||||||||
1982 | node->setMatrix(transformMatrix); | - | ||||||||||||||||||||||||
1983 | } executed 562 times by 4 tests: end of block Executed by:
| 562 | ||||||||||||||||||||||||
1984 | - | |||||||||||||||||||||||||
1985 | /*! | - | ||||||||||||||||||||||||
1986 | * \internal | - | ||||||||||||||||||||||||
1987 | * | - | ||||||||||||||||||||||||
1988 | * Invalidates font caches owned by the text objects owned by the element | - | ||||||||||||||||||||||||
1989 | * to work around the fact that text objects cannot be used from multiple threads. | - | ||||||||||||||||||||||||
1990 | */ | - | ||||||||||||||||||||||||
1991 | void QQuickTextEdit::invalidateFontCaches() | - | ||||||||||||||||||||||||
1992 | { | - | ||||||||||||||||||||||||
1993 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
1994 | if (d->document == nullptr)
| 0-842 | ||||||||||||||||||||||||
1995 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1996 | - | |||||||||||||||||||||||||
1997 | QTextBlock block; | - | ||||||||||||||||||||||||
1998 | for (block = d->document->firstBlock(); block.isValid(); block = block.next()) {
| 842-1826 | ||||||||||||||||||||||||
1999 | if (block.layout() != nullptr && block.layout()->engine() != nullptr)
| 0-1826 | ||||||||||||||||||||||||
2000 | block.layout()->engine()->resetFontEngineCache(); executed 1826 times by 4 tests: block.layout()->engine()->resetFontEngineCache(); Executed by:
| 1826 | ||||||||||||||||||||||||
2001 | } executed 1826 times by 4 tests: end of block Executed by:
| 1826 | ||||||||||||||||||||||||
2002 | } executed 842 times by 4 tests: end of block Executed by:
| 842 | ||||||||||||||||||||||||
2003 | - | |||||||||||||||||||||||||
2004 | inline void resetEngine(QQuickTextNodeEngine *engine, const QColor& textColor, const QColor& selectedTextColor, const QColor& selectionColor) | - | ||||||||||||||||||||||||
2005 | { | - | ||||||||||||||||||||||||
2006 | *engine = QQuickTextNodeEngine(); | - | ||||||||||||||||||||||||
2007 | engine->setTextColor(textColor); | - | ||||||||||||||||||||||||
2008 | engine->setSelectedTextColor(selectedTextColor); | - | ||||||||||||||||||||||||
2009 | engine->setSelectionColor(selectionColor); | - | ||||||||||||||||||||||||
2010 | } executed 854 times by 4 tests: end of block Executed by:
| 854 | ||||||||||||||||||||||||
2011 | - | |||||||||||||||||||||||||
2012 | QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) | - | ||||||||||||||||||||||||
2013 | { | - | ||||||||||||||||||||||||
2014 | Q_UNUSED(updatePaintNodeData); | - | ||||||||||||||||||||||||
2015 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2016 | - | |||||||||||||||||||||||||
2017 | if (d->updateType != QQuickTextEditPrivate::UpdatePaintNode && oldNode != nullptr) {
| 0-422 | ||||||||||||||||||||||||
2018 | // Update done in preprocess() in the nodes | - | ||||||||||||||||||||||||
2019 | d->updateType = QQuickTextEditPrivate::UpdateNone; | - | ||||||||||||||||||||||||
2020 | return oldNode; never executed: return oldNode; | 0 | ||||||||||||||||||||||||
2021 | } | - | ||||||||||||||||||||||||
2022 | - | |||||||||||||||||||||||||
2023 | d->updateType = QQuickTextEditPrivate::UpdateNone; | - | ||||||||||||||||||||||||
2024 | - | |||||||||||||||||||||||||
2025 | if (!oldNode) {
| 188-234 | ||||||||||||||||||||||||
2026 | // If we had any QQuickTextNode node references, they were deleted along with the root node | - | ||||||||||||||||||||||||
2027 | // But here we must delete the Node structures in textNodeMap | - | ||||||||||||||||||||||||
2028 | d->textNodeMap.clear(); | - | ||||||||||||||||||||||||
2029 | } executed 234 times by 4 tests: end of block Executed by:
| 234 | ||||||||||||||||||||||||
2030 | - | |||||||||||||||||||||||||
2031 | RootNode *rootNode = static_cast<RootNode *>(oldNode); | - | ||||||||||||||||||||||||
2032 | TextNodeIterator nodeIterator = d->textNodeMap.begin(); | - | ||||||||||||||||||||||||
2033 | while (nodeIterator != d->textNodeMap.end() && !nodeIterator->dirty())
| 58-364 | ||||||||||||||||||||||||
2034 | ++nodeIterator; executed 246 times by 2 tests: ++nodeIterator; Executed by:
| 246 | ||||||||||||||||||||||||
2035 | - | |||||||||||||||||||||||||
2036 | QQuickTextNodeEngine engine; | - | ||||||||||||||||||||||||
2037 | QQuickTextNodeEngine frameDecorationsEngine; | - | ||||||||||||||||||||||||
2038 | - | |||||||||||||||||||||||||
2039 | if (!oldNode || nodeIterator < d->textNodeMap.end()) {
| 58-234 | ||||||||||||||||||||||||
2040 | - | |||||||||||||||||||||||||
2041 | if (!oldNode)
| 58-234 | ||||||||||||||||||||||||
2042 | rootNode = new RootNode; executed 234 times by 4 tests: rootNode = new RootNode; Executed by:
| 234 | ||||||||||||||||||||||||
2043 | - | |||||||||||||||||||||||||
2044 | int firstDirtyPos = 0; | - | ||||||||||||||||||||||||
2045 | if (nodeIterator != d->textNodeMap.end()) {
| 58-234 | ||||||||||||||||||||||||
2046 | firstDirtyPos = nodeIterator->startPos(); | - | ||||||||||||||||||||||||
2047 | do { | - | ||||||||||||||||||||||||
2048 | rootNode->removeChildNode(nodeIterator->textNode()); | - | ||||||||||||||||||||||||
2049 | delete nodeIterator->textNode(); | - | ||||||||||||||||||||||||
2050 | nodeIterator = d->textNodeMap.erase(nodeIterator); | - | ||||||||||||||||||||||||
2051 | } while (nodeIterator != d->textNodeMap.end() && nodeIterator->dirty()); executed 70 times by 1 test: end of block Executed by:
| 12-70 | ||||||||||||||||||||||||
2052 | } executed 58 times by 1 test: end of block Executed by:
| 58 | ||||||||||||||||||||||||
2053 | - | |||||||||||||||||||||||||
2054 | // FIXME: the text decorations could probably be handled separately (only updated for affected textFrames) | - | ||||||||||||||||||||||||
2055 | rootNode->resetFrameDecorations(d->createTextNode()); | - | ||||||||||||||||||||||||
2056 | resetEngine(&frameDecorationsEngine, d->color, d->selectedTextColor, d->selectionColor); | - | ||||||||||||||||||||||||
2057 | - | |||||||||||||||||||||||||
2058 | QQuickTextNode *node = nullptr; | - | ||||||||||||||||||||||||
2059 | - | |||||||||||||||||||||||||
2060 | int currentNodeSize = 0; | - | ||||||||||||||||||||||||
2061 | int nodeStart = firstDirtyPos; | - | ||||||||||||||||||||||||
2062 | QPointF basePosition(d->xoff, d->yoff); | - | ||||||||||||||||||||||||
2063 | QMatrix4x4 basePositionMatrix; | - | ||||||||||||||||||||||||
2064 | basePositionMatrix.translate(basePosition.x(), basePosition.y()); | - | ||||||||||||||||||||||||
2065 | rootNode->setMatrix(basePositionMatrix); | - | ||||||||||||||||||||||||
2066 | - | |||||||||||||||||||||||||
2067 | QPointF nodeOffset; | - | ||||||||||||||||||||||||
2068 | const TextNode firstCleanNode = (nodeIterator != d->textNodeMap.end()) ? *nodeIterator
| 38-254 | ||||||||||||||||||||||||
2069 | : TextNode(); | - | ||||||||||||||||||||||||
2070 | - | |||||||||||||||||||||||||
2071 | QList<QTextFrame *> frames; | - | ||||||||||||||||||||||||
2072 | frames.append(d->document->rootFrame()); | - | ||||||||||||||||||||||||
2073 | - | |||||||||||||||||||||||||
2074 | while (!frames.isEmpty()) {
| 292 | ||||||||||||||||||||||||
2075 | QTextFrame *textFrame = frames.takeFirst(); | - | ||||||||||||||||||||||||
2076 | frames.append(textFrame->childFrames()); | - | ||||||||||||||||||||||||
2077 | frameDecorationsEngine.addFrameDecorations(d->document, textFrame); | - | ||||||||||||||||||||||||
2078 | - | |||||||||||||||||||||||||
2079 | if (textFrame->lastPosition() < firstDirtyPos
| 0-292 | ||||||||||||||||||||||||
2080 | || textFrame->firstPosition() >= firstCleanNode.startPos())
| 0-292 | ||||||||||||||||||||||||
2081 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2082 | node = d->createTextNode(); | - | ||||||||||||||||||||||||
2083 | resetEngine(&engine, d->color, d->selectedTextColor, d->selectionColor); | - | ||||||||||||||||||||||||
2084 | - | |||||||||||||||||||||||||
2085 | if (textFrame->firstPosition() > textFrame->lastPosition()
| 0-292 | ||||||||||||||||||||||||
2086 | && textFrame->frameFormat().position() != QTextFrameFormat::InFlow) {
| 0 | ||||||||||||||||||||||||
2087 | updateNodeTransform(node, d->document->documentLayout()->frameBoundingRect(textFrame).topLeft()); | - | ||||||||||||||||||||||||
2088 | const int pos = textFrame->firstPosition() - 1; | - | ||||||||||||||||||||||||
2089 | ProtectedLayoutAccessor *a = static_cast<ProtectedLayoutAccessor *>(d->document->documentLayout()); | - | ||||||||||||||||||||||||
2090 | QTextCharFormat format = a->formatAccessor(pos); | - | ||||||||||||||||||||||||
2091 | QTextBlock block = textFrame->firstCursorPosition().block(); | - | ||||||||||||||||||||||||
2092 | engine.setCurrentLine(block.layout()->lineForTextPosition(pos - block.position())); | - | ||||||||||||||||||||||||
2093 | engine.addTextObject(QPointF(0, 0), format, QQuickTextNodeEngine::Unselected, d->document, | - | ||||||||||||||||||||||||
2094 | pos, textFrame->frameFormat().position()); | - | ||||||||||||||||||||||||
2095 | nodeStart = pos; | - | ||||||||||||||||||||||||
2096 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
2097 | // Having nodes spanning across frame boundaries will break the current bookkeeping mechanism. We need to prevent that. | - | ||||||||||||||||||||||||
2098 | QList<int> frameBoundaries; | - | ||||||||||||||||||||||||
2099 | frameBoundaries.reserve(frames.size()); | - | ||||||||||||||||||||||||
2100 | for (QTextFrame *frame : qAsConst(frames)) | - | ||||||||||||||||||||||||
2101 | frameBoundaries.append(frame->firstPosition()); never executed: frameBoundaries.append(frame->firstPosition()); | 0 | ||||||||||||||||||||||||
2102 | std::sort(frameBoundaries.begin(), frameBoundaries.end()); | - | ||||||||||||||||||||||||
2103 | - | |||||||||||||||||||||||||
2104 | QTextFrame::iterator it = textFrame->begin(); | - | ||||||||||||||||||||||||
2105 | while (!it.atEnd()) {
| 0-570 | ||||||||||||||||||||||||
2106 | QTextBlock block = it.currentBlock(); | - | ||||||||||||||||||||||||
2107 | ++it; | - | ||||||||||||||||||||||||
2108 | if (block.position() < firstDirtyPos)
| 8-562 | ||||||||||||||||||||||||
2109 | continue; executed 8 times by 1 test: continue; Executed by:
| 8 | ||||||||||||||||||||||||
2110 | - | |||||||||||||||||||||||||
2111 | if (!engine.hasContents()) {
| 0-562 | ||||||||||||||||||||||||
2112 | nodeOffset = d->document->documentLayout()->blockBoundingRect(block).topLeft(); | - | ||||||||||||||||||||||||
2113 | updateNodeTransform(node, nodeOffset); | - | ||||||||||||||||||||||||
2114 | nodeStart = block.position(); | - | ||||||||||||||||||||||||
2115 | } executed 562 times by 4 tests: end of block Executed by:
| 562 | ||||||||||||||||||||||||
2116 | - | |||||||||||||||||||||||||
2117 | engine.addTextBlock(d->document, block, -nodeOffset, d->color, QColor(), selectionStart(), selectionEnd() - 1); | - | ||||||||||||||||||||||||
2118 | currentNodeSize += block.length(); | - | ||||||||||||||||||||||||
2119 | - | |||||||||||||||||||||||||
2120 | if ((it.atEnd()) || block.next().position() >= firstCleanNode.startPos())
| 38-308 | ||||||||||||||||||||||||
2121 | break; // last node that needed replacing or last block of the frame executed 292 times by 4 tests: break; Executed by:
| 292 | ||||||||||||||||||||||||
2122 | - | |||||||||||||||||||||||||
2123 | QList<int>::const_iterator lowerBound = std::lower_bound(frameBoundaries.constBegin(), frameBoundaries.constEnd(), block.next().position()); | - | ||||||||||||||||||||||||
2124 | if (currentNodeSize > nodeBreakingSize || lowerBound == frameBoundaries.constEnd() || *lowerBound > nodeStart) {
| 0-270 | ||||||||||||||||||||||||
2125 | currentNodeSize = 0; | - | ||||||||||||||||||||||||
2126 | d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart); | - | ||||||||||||||||||||||||
2127 | node = d->createTextNode(); | - | ||||||||||||||||||||||||
2128 | resetEngine(&engine, d->color, d->selectedTextColor, d->selectionColor); | - | ||||||||||||||||||||||||
2129 | nodeStart = block.next().position(); | - | ||||||||||||||||||||||||
2130 | } executed 270 times by 2 tests: end of block Executed by:
| 270 | ||||||||||||||||||||||||
2131 | } executed 270 times by 2 tests: end of block Executed by:
| 270 | ||||||||||||||||||||||||
2132 | } executed 292 times by 4 tests: end of block Executed by:
| 292 | ||||||||||||||||||||||||
2133 | d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart); | - | ||||||||||||||||||||||||
2134 | } executed 292 times by 4 tests: end of block Executed by:
| 292 | ||||||||||||||||||||||||
2135 | frameDecorationsEngine.addToSceneGraph(rootNode->frameDecorationsNode, QQuickText::Normal, QColor()); | - | ||||||||||||||||||||||||
2136 | // Now prepend the frame decorations since we want them rendered first, with the text nodes and cursor in front. | - | ||||||||||||||||||||||||
2137 | rootNode->prependChildNode(rootNode->frameDecorationsNode); | - | ||||||||||||||||||||||||
2138 | - | |||||||||||||||||||||||||
2139 | Q_ASSERT(nodeIterator == d->textNodeMap.end() | - | ||||||||||||||||||||||||
2140 | || (nodeIterator->textNode() == firstCleanNode.textNode() | - | ||||||||||||||||||||||||
2141 | && nodeIterator->startPos() == firstCleanNode.startPos())); | - | ||||||||||||||||||||||||
2142 | // Update the position of the subsequent text blocks. | - | ||||||||||||||||||||||||
2143 | if (firstCleanNode.textNode() != nullptr) {
| 38-254 | ||||||||||||||||||||||||
2144 | QPointF oldOffset = firstCleanNode.textNode()->matrix().map(QPointF(0,0)); | - | ||||||||||||||||||||||||
2145 | QPointF currentOffset = d->document->documentLayout()->blockBoundingRect( | - | ||||||||||||||||||||||||
2146 | d->document->findBlock(firstCleanNode.startPos())).topLeft(); | - | ||||||||||||||||||||||||
2147 | QPointF delta = currentOffset - oldOffset; | - | ||||||||||||||||||||||||
2148 | while (nodeIterator != d->textNodeMap.end()) {
| 38-106 | ||||||||||||||||||||||||
2149 | QMatrix4x4 transformMatrix = nodeIterator->textNode()->matrix(); | - | ||||||||||||||||||||||||
2150 | transformMatrix.translate(delta.x(), delta.y()); | - | ||||||||||||||||||||||||
2151 | nodeIterator->textNode()->setMatrix(transformMatrix); | - | ||||||||||||||||||||||||
2152 | ++nodeIterator; | - | ||||||||||||||||||||||||
2153 | } executed 106 times by 1 test: end of block Executed by:
| 106 | ||||||||||||||||||||||||
2154 | - | |||||||||||||||||||||||||
2155 | } executed 38 times by 1 test: end of block Executed by:
| 38 | ||||||||||||||||||||||||
2156 | - | |||||||||||||||||||||||||
2157 | // Since we iterate over blocks from different text frames that are potentially not sorted | - | ||||||||||||||||||||||||
2158 | // we need to ensure that our list of nodes is sorted again: | - | ||||||||||||||||||||||||
2159 | std::sort(d->textNodeMap.begin(), d->textNodeMap.end()); | - | ||||||||||||||||||||||||
2160 | } executed 292 times by 4 tests: end of block Executed by:
| 292 | ||||||||||||||||||||||||
2161 | - | |||||||||||||||||||||||||
2162 | if (d->cursorComponent == nullptr) {
| 86-336 | ||||||||||||||||||||||||
2163 | QSGInternalRectangleNode* cursor = nullptr; | - | ||||||||||||||||||||||||
2164 | if (!isReadOnly() && d->cursorVisible && d->control->cursorOn())
| 2-330 | ||||||||||||||||||||||||
2165 | cursor = d->sceneGraphContext()->createInternalRectangleNode(d->control->cursorRect(), d->color); executed 140 times by 3 tests: cursor = d->sceneGraphContext()->createInternalRectangleNode(d->control->cursorRect(), d->color); Executed by:
| 140 | ||||||||||||||||||||||||
2166 | rootNode->resetCursorNode(cursor); | - | ||||||||||||||||||||||||
2167 | } executed 336 times by 4 tests: end of block Executed by:
| 336 | ||||||||||||||||||||||||
2168 | - | |||||||||||||||||||||||||
2169 | invalidateFontCaches(); | - | ||||||||||||||||||||||||
2170 | - | |||||||||||||||||||||||||
2171 | return rootNode; executed 422 times by 4 tests: return rootNode; Executed by:
| 422 | ||||||||||||||||||||||||
2172 | } | - | ||||||||||||||||||||||||
2173 | - | |||||||||||||||||||||||||
2174 | void QQuickTextEdit::updatePolish() | - | ||||||||||||||||||||||||
2175 | { | - | ||||||||||||||||||||||||
2176 | invalidateFontCaches(); | - | ||||||||||||||||||||||||
2177 | } executed 420 times by 4 tests: end of block Executed by:
| 420 | ||||||||||||||||||||||||
2178 | - | |||||||||||||||||||||||||
2179 | /*! | - | ||||||||||||||||||||||||
2180 | \qmlproperty bool QtQuick::TextEdit::canPaste | - | ||||||||||||||||||||||||
2181 | - | |||||||||||||||||||||||||
2182 | Returns true if the TextEdit is writable and the content of the clipboard is | - | ||||||||||||||||||||||||
2183 | suitable for pasting into the TextEdit. | - | ||||||||||||||||||||||||
2184 | */ | - | ||||||||||||||||||||||||
2185 | bool QQuickTextEdit::canPaste() const | - | ||||||||||||||||||||||||
2186 | { | - | ||||||||||||||||||||||||
2187 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2188 | if (!d->canPasteValid) {
| 4-8 | ||||||||||||||||||||||||
2189 | const_cast<QQuickTextEditPrivate *>(d)->canPaste = d->control->canPaste(); | - | ||||||||||||||||||||||||
2190 | const_cast<QQuickTextEditPrivate *>(d)->canPasteValid = true; | - | ||||||||||||||||||||||||
2191 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2192 | return d->canPaste; executed 12 times by 1 test: return d->canPaste; Executed by:
| 12 | ||||||||||||||||||||||||
2193 | } | - | ||||||||||||||||||||||||
2194 | - | |||||||||||||||||||||||||
2195 | /*! | - | ||||||||||||||||||||||||
2196 | \qmlproperty bool QtQuick::TextEdit::canUndo | - | ||||||||||||||||||||||||
2197 | - | |||||||||||||||||||||||||
2198 | Returns true if the TextEdit is writable and there are previous operations | - | ||||||||||||||||||||||||
2199 | that can be undone. | - | ||||||||||||||||||||||||
2200 | */ | - | ||||||||||||||||||||||||
2201 | - | |||||||||||||||||||||||||
2202 | bool QQuickTextEdit::canUndo() const | - | ||||||||||||||||||||||||
2203 | { | - | ||||||||||||||||||||||||
2204 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2205 | return d->document->isUndoAvailable(); executed 98 times by 1 test: return d->document->isUndoAvailable(); Executed by:
| 98 | ||||||||||||||||||||||||
2206 | } | - | ||||||||||||||||||||||||
2207 | - | |||||||||||||||||||||||||
2208 | /*! | - | ||||||||||||||||||||||||
2209 | \qmlproperty bool QtQuick::TextEdit::canRedo | - | ||||||||||||||||||||||||
2210 | - | |||||||||||||||||||||||||
2211 | Returns true if the TextEdit is writable and there are \l {undo}{undone} | - | ||||||||||||||||||||||||
2212 | operations that can be redone. | - | ||||||||||||||||||||||||
2213 | */ | - | ||||||||||||||||||||||||
2214 | - | |||||||||||||||||||||||||
2215 | bool QQuickTextEdit::canRedo() const | - | ||||||||||||||||||||||||
2216 | { | - | ||||||||||||||||||||||||
2217 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2218 | return d->document->isRedoAvailable(); executed 28 times by 1 test: return d->document->isRedoAvailable(); Executed by:
| 28 | ||||||||||||||||||||||||
2219 | } | - | ||||||||||||||||||||||||
2220 | - | |||||||||||||||||||||||||
2221 | /*! | - | ||||||||||||||||||||||||
2222 | \qmlproperty bool QtQuick::TextEdit::inputMethodComposing | - | ||||||||||||||||||||||||
2223 | - | |||||||||||||||||||||||||
2224 | - | |||||||||||||||||||||||||
2225 | This property holds whether the TextEdit has partial text input from an | - | ||||||||||||||||||||||||
2226 | input method. | - | ||||||||||||||||||||||||
2227 | - | |||||||||||||||||||||||||
2228 | While it is composing an input method may rely on mouse or key events from | - | ||||||||||||||||||||||||
2229 | the TextEdit to edit or commit the partial text. This property can be used | - | ||||||||||||||||||||||||
2230 | to determine when to disable events handlers that may interfere with the | - | ||||||||||||||||||||||||
2231 | correct operation of an input method. | - | ||||||||||||||||||||||||
2232 | */ | - | ||||||||||||||||||||||||
2233 | bool QQuickTextEdit::isInputMethodComposing() const | - | ||||||||||||||||||||||||
2234 | { | - | ||||||||||||||||||||||||
2235 | #if !QT_CONFIG(im) | - | ||||||||||||||||||||||||
2236 | return false; | - | ||||||||||||||||||||||||
2237 | #else | - | ||||||||||||||||||||||||
2238 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2239 | return d->control->hasImState(); executed 672 times by 1 test: return d->control->hasImState(); Executed by:
| 672 | ||||||||||||||||||||||||
2240 | #endif // im | - | ||||||||||||||||||||||||
2241 | } | - | ||||||||||||||||||||||||
2242 | - | |||||||||||||||||||||||||
2243 | QQuickTextEditPrivate::ExtraData::ExtraData() | - | ||||||||||||||||||||||||
2244 | : padding(0) | - | ||||||||||||||||||||||||
2245 | , topPadding(0) | - | ||||||||||||||||||||||||
2246 | , leftPadding(0) | - | ||||||||||||||||||||||||
2247 | , rightPadding(0) | - | ||||||||||||||||||||||||
2248 | , bottomPadding(0) | - | ||||||||||||||||||||||||
2249 | , explicitTopPadding(false) | - | ||||||||||||||||||||||||
2250 | , explicitLeftPadding(false) | - | ||||||||||||||||||||||||
2251 | , explicitRightPadding(false) | - | ||||||||||||||||||||||||
2252 | , explicitBottomPadding(false) | - | ||||||||||||||||||||||||
2253 | , implicitResize(true) | - | ||||||||||||||||||||||||
2254 | { | - | ||||||||||||||||||||||||
2255 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2256 | - | |||||||||||||||||||||||||
2257 | void QQuickTextEditPrivate::init() | - | ||||||||||||||||||||||||
2258 | { | - | ||||||||||||||||||||||||
2259 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
2260 | - | |||||||||||||||||||||||||
2261 | #if QT_CONFIG(clipboard) | - | ||||||||||||||||||||||||
2262 | if (QGuiApplication::clipboard()->supportsSelection())
| 0-1076 | ||||||||||||||||||||||||
2263 | q->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton); executed 1076 times by 6 tests: q->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton); Executed by:
| 1076 | ||||||||||||||||||||||||
2264 | else | - | ||||||||||||||||||||||||
2265 | #endif | - | ||||||||||||||||||||||||
2266 | q->setAcceptedMouseButtons(Qt::LeftButton); never executed: q->setAcceptedMouseButtons(Qt::LeftButton); | 0 | ||||||||||||||||||||||||
2267 | - | |||||||||||||||||||||||||
2268 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
2269 | q->setFlag(QQuickItem::ItemAcceptsInputMethod); | - | ||||||||||||||||||||||||
2270 | #endif | - | ||||||||||||||||||||||||
2271 | q->setFlag(QQuickItem::ItemHasContents); | - | ||||||||||||||||||||||||
2272 | - | |||||||||||||||||||||||||
2273 | q->setAcceptHoverEvents(true); | - | ||||||||||||||||||||||||
2274 | - | |||||||||||||||||||||||||
2275 | document = new QQuickTextDocumentWithImageResources(q); | - | ||||||||||||||||||||||||
2276 | - | |||||||||||||||||||||||||
2277 | control = new QQuickTextControl(document, q); | - | ||||||||||||||||||||||||
2278 | control->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable); | - | ||||||||||||||||||||||||
2279 | control->setAcceptRichText(false); | - | ||||||||||||||||||||||||
2280 | control->setCursorIsFocusIndicator(true); | - | ||||||||||||||||||||||||
2281 | - | |||||||||||||||||||||||||
2282 | qmlobject_connect(control, QQuickTextControl, SIGNAL(updateCursorRequest()), q, QQuickTextEdit, SLOT(updateCursor())); executed 12 times by 6 tests: end of block Executed by:
executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1);
| 0-1064 | ||||||||||||||||||||||||
2283 | qmlobject_connect(control, QQuickTextControl, SIGNAL(selectionChanged()), q, QQuickTextEdit, SIGNAL(selectedTextChanged())); executed 12 times by 6 tests: end of block Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1064 | ||||||||||||||||||||||||
2284 | qmlobject_connect(control, QQuickTextControl, SIGNAL(selectionChanged()), q, QQuickTextEdit, SLOT(updateSelection())); executed 12 times by 6 tests: end of block Executed by:
executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1);
| 0-1064 | ||||||||||||||||||||||||
2285 | qmlobject_connect(control, QQuickTextControl, SIGNAL(cursorPositionChanged()), q, QQuickTextEdit, SLOT(updateSelection())); executed 12 times by 6 tests: end of block Executed by:
executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1);
| 0-1064 | ||||||||||||||||||||||||
2286 | qmlobject_connect(control, QQuickTextControl, SIGNAL(cursorPositionChanged()), q, QQuickTextEdit, SIGNAL(cursorPositionChanged())); executed 12 times by 6 tests: end of block Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1064 | ||||||||||||||||||||||||
2287 | qmlobject_connect(control, QQuickTextControl, SIGNAL(cursorRectangleChanged()), q, QQuickTextEdit, SLOT(moveCursorDelegate())); executed 12 times by 6 tests: end of block Executed by:
executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1);
| 0-1064 | ||||||||||||||||||||||||
2288 | qmlobject_connect(control, QQuickTextControl, SIGNAL(linkActivated(QString)), q, QQuickTextEdit, SIGNAL(linkActivated(QString))); executed 12 times by 6 tests: end of block Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1064 | ||||||||||||||||||||||||
2289 | qmlobject_connect(control, QQuickTextControl, SIGNAL(linkHovered(QString)), q, QQuickTextEdit, SIGNAL(linkHovered(QString))); executed 12 times by 6 tests: end of block Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1064 | ||||||||||||||||||||||||
2290 | qmlobject_connect(control, QQuickTextControl, SIGNAL(overwriteModeChanged(bool)), q, QQuickTextEdit, SIGNAL(overwriteModeChanged(bool))); executed 12 times by 6 tests: end of block Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1064 | ||||||||||||||||||||||||
2291 | qmlobject_connect(control, QQuickTextControl, SIGNAL(textChanged()), q, QQuickTextEdit, SLOT(q_textChanged())); executed 12 times by 6 tests: end of block Executed by:
executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1);
| 0-1064 | ||||||||||||||||||||||||
2292 | qmlobject_connect(control, QQuickTextControl, SIGNAL(preeditTextChanged()), q, QQuickTextEdit, SIGNAL(preeditTextChanged())); executed 12 times by 6 tests: end of block Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1064 | ||||||||||||||||||||||||
2293 | #if QT_CONFIG(clipboard) | - | ||||||||||||||||||||||||
2294 | qmlobject_connect(QGuiApplication::clipboard(), QClipboard, SIGNAL(dataChanged()), q, QQuickTextEdit, SLOT(q_canPasteChanged())); executed 12 times by 6 tests: end of block Executed by:
executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1);
| 0-1064 | ||||||||||||||||||||||||
2295 | #endif | - | ||||||||||||||||||||||||
2296 | qmlobject_connect(document, QQuickTextDocumentWithImageResources, SIGNAL(undoAvailable(bool)), q, QQuickTextEdit, SIGNAL(canUndoChanged())); executed 12 times by 6 tests: end of block Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1064 | ||||||||||||||||||||||||
2297 | qmlobject_connect(document, QQuickTextDocumentWithImageResources, SIGNAL(redoAvailable(bool)), q, QQuickTextEdit, SIGNAL(canRedoChanged())); executed 12 times by 6 tests: end of block Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1); Executed by:
| 0-1064 | ||||||||||||||||||||||||
2298 | qmlobject_connect(document, QQuickTextDocumentWithImageResources, SIGNAL(imagesLoaded()), q, QQuickTextEdit, SLOT(updateSize())); executed 12 times by 6 tests: end of block Executed by:
executed 12 times by 6 tests: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickTextEdit::staticMetaObject.indexOfSignal(method+1);
| 0-1064 | ||||||||||||||||||||||||
2299 | QObject::connect(document, &QQuickTextDocumentWithImageResources::contentsChange, q, &QQuickTextEdit::q_contentsChange); | - | ||||||||||||||||||||||||
2300 | QObject::connect(document->documentLayout(), &QAbstractTextDocumentLayout::updateBlock, q, &QQuickTextEdit::invalidateBlock); | - | ||||||||||||||||||||||||
2301 | - | |||||||||||||||||||||||||
2302 | document->setDefaultFont(font); | - | ||||||||||||||||||||||||
2303 | document->setDocumentMargin(textMargin); | - | ||||||||||||||||||||||||
2304 | document->setUndoRedoEnabled(false); // flush undo buffer. | - | ||||||||||||||||||||||||
2305 | document->setUndoRedoEnabled(true); | - | ||||||||||||||||||||||||
2306 | updateDefaultTextOption(); | - | ||||||||||||||||||||||||
2307 | q->updateSize(); | - | ||||||||||||||||||||||||
2308 | } executed 1076 times by 6 tests: end of block Executed by:
| 1076 | ||||||||||||||||||||||||
2309 | - | |||||||||||||||||||||||||
2310 | void QQuickTextEditPrivate::resetInputMethod() | - | ||||||||||||||||||||||||
2311 | { | - | ||||||||||||||||||||||||
2312 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
2313 | if (!q->isReadOnly() && q->hasActiveFocus() && qGuiApp)
| 0-6 | ||||||||||||||||||||||||
2314 | QGuiApplication::inputMethod()->reset(); executed 6 times by 1 test: QGuiApplication::inputMethod()->reset(); Executed by:
| 6 | ||||||||||||||||||||||||
2315 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
2316 | - | |||||||||||||||||||||||||
2317 | void QQuickTextEdit::q_textChanged() | - | ||||||||||||||||||||||||
2318 | { | - | ||||||||||||||||||||||||
2319 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2320 | d->textCached = false; | - | ||||||||||||||||||||||||
2321 | for (QTextBlock it = d->document->begin(); it != d->document->end(); it = it.next()) {
| 1340-3790 | ||||||||||||||||||||||||
2322 | d->contentDirection = d->textDirection(it.text()); | - | ||||||||||||||||||||||||
2323 | if (d->contentDirection != Qt::LayoutDirectionAuto)
| 1340-2450 | ||||||||||||||||||||||||
2324 | break; executed 2450 times by 5 tests: break; Executed by:
| 2450 | ||||||||||||||||||||||||
2325 | } executed 1340 times by 6 tests: end of block Executed by:
| 1340 | ||||||||||||||||||||||||
2326 | d->determineHorizontalAlignment(); | - | ||||||||||||||||||||||||
2327 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
2328 | updateSize(); | - | ||||||||||||||||||||||||
2329 | emit textChanged(); | - | ||||||||||||||||||||||||
2330 | } executed 3790 times by 6 tests: end of block Executed by:
| 3790 | ||||||||||||||||||||||||
2331 | - | |||||||||||||||||||||||||
2332 | void QQuickTextEdit::markDirtyNodesForRange(int start, int end, int charDelta) | - | ||||||||||||||||||||||||
2333 | { | - | ||||||||||||||||||||||||
2334 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2335 | if (start == end)
| 1144-6074 | ||||||||||||||||||||||||
2336 | return; executed 1144 times by 6 tests: return; Executed by:
| 1144 | ||||||||||||||||||||||||
2337 | - | |||||||||||||||||||||||||
2338 | TextNode dummyNode(start); | - | ||||||||||||||||||||||||
2339 | - | |||||||||||||||||||||||||
2340 | const TextNodeIterator textNodeMapBegin = d->textNodeMap.begin(); | - | ||||||||||||||||||||||||
2341 | const TextNodeIterator textNodeMapEnd = d->textNodeMap.end(); | - | ||||||||||||||||||||||||
2342 | - | |||||||||||||||||||||||||
2343 | TextNodeIterator it = std::lower_bound(textNodeMapBegin, textNodeMapEnd, dummyNode); | - | ||||||||||||||||||||||||
2344 | // qLowerBound gives us the first node past the start of the affected portion, rewind to the first node | - | ||||||||||||||||||||||||
2345 | // that starts at the last position before the edit position. (there might be several because of images) | - | ||||||||||||||||||||||||
2346 | if (it != textNodeMapBegin) {
| 520-5554 | ||||||||||||||||||||||||
2347 | --it; | - | ||||||||||||||||||||||||
2348 | TextNode otherDummy(it->startPos()); | - | ||||||||||||||||||||||||
2349 | it = std::lower_bound(textNodeMapBegin, textNodeMapEnd, otherDummy); | - | ||||||||||||||||||||||||
2350 | } executed 520 times by 1 test: end of block Executed by:
| 520 | ||||||||||||||||||||||||
2351 | - | |||||||||||||||||||||||||
2352 | // mark the affected nodes as dirty | - | ||||||||||||||||||||||||
2353 | while (it != textNodeMapEnd) {
| 3612-5160 | ||||||||||||||||||||||||
2354 | if (it->startPos() <= end)
| 920-2692 | ||||||||||||||||||||||||
2355 | it->setDirty(); executed 2692 times by 1 test: it->setDirty(); Executed by:
| 2692 | ||||||||||||||||||||||||
2356 | else if (charDelta)
| 6-914 | ||||||||||||||||||||||||
2357 | it->moveStartPos(charDelta); executed 6 times by 1 test: it->moveStartPos(charDelta); Executed by:
| 6 | ||||||||||||||||||||||||
2358 | else | - | ||||||||||||||||||||||||
2359 | return; executed 914 times by 1 test: return; Executed by:
| 914 | ||||||||||||||||||||||||
2360 | ++it; | - | ||||||||||||||||||||||||
2361 | } executed 2698 times by 1 test: end of block Executed by:
| 2698 | ||||||||||||||||||||||||
2362 | } executed 5160 times by 5 tests: end of block Executed by:
| 5160 | ||||||||||||||||||||||||
2363 | - | |||||||||||||||||||||||||
2364 | void QQuickTextEdit::q_contentsChange(int pos, int charsRemoved, int charsAdded) | - | ||||||||||||||||||||||||
2365 | { | - | ||||||||||||||||||||||||
2366 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2367 | - | |||||||||||||||||||||||||
2368 | const int editRange = pos + qMax(charsAdded, charsRemoved); | - | ||||||||||||||||||||||||
2369 | const int delta = charsAdded - charsRemoved; | - | ||||||||||||||||||||||||
2370 | - | |||||||||||||||||||||||||
2371 | markDirtyNodesForRange(pos, editRange, delta); | - | ||||||||||||||||||||||||
2372 | - | |||||||||||||||||||||||||
2373 | polish(); | - | ||||||||||||||||||||||||
2374 | if (isComponentComplete()) {
| 68-4442 | ||||||||||||||||||||||||
2375 | d->updateType = QQuickTextEditPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
2376 | update(); | - | ||||||||||||||||||||||||
2377 | } executed 4442 times by 6 tests: end of block Executed by:
| 4442 | ||||||||||||||||||||||||
2378 | } executed 4510 times by 6 tests: end of block Executed by:
| 4510 | ||||||||||||||||||||||||
2379 | - | |||||||||||||||||||||||||
2380 | void QQuickTextEdit::moveCursorDelegate() | - | ||||||||||||||||||||||||
2381 | { | - | ||||||||||||||||||||||||
2382 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2383 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
2384 | updateInputMethod(); | - | ||||||||||||||||||||||||
2385 | #endif | - | ||||||||||||||||||||||||
2386 | emit cursorRectangleChanged(); | - | ||||||||||||||||||||||||
2387 | if (!d->cursorItem)
| 1080-6228 | ||||||||||||||||||||||||
2388 | return; executed 6228 times by 6 tests: return; Executed by:
| 6228 | ||||||||||||||||||||||||
2389 | QRectF cursorRect = cursorRectangle(); | - | ||||||||||||||||||||||||
2390 | d->cursorItem->setX(cursorRect.x()); | - | ||||||||||||||||||||||||
2391 | d->cursorItem->setY(cursorRect.y()); | - | ||||||||||||||||||||||||
2392 | d->cursorItem->setHeight(cursorRect.height()); | - | ||||||||||||||||||||||||
2393 | } executed 1080 times by 1 test: end of block Executed by:
| 1080 | ||||||||||||||||||||||||
2394 | - | |||||||||||||||||||||||||
2395 | void QQuickTextEdit::updateSelection() | - | ||||||||||||||||||||||||
2396 | { | - | ||||||||||||||||||||||||
2397 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2398 | - | |||||||||||||||||||||||||
2399 | // No need for node updates when we go from an empty selection to another empty selection | - | ||||||||||||||||||||||||
2400 | if (d->control->textCursor().hasSelection() || d->hadSelection) {
| 222-2544 | ||||||||||||||||||||||||
2401 | markDirtyNodesForRange(qMin(d->lastSelectionStart, d->control->textCursor().selectionStart()), qMax(d->control->textCursor().selectionEnd(), d->lastSelectionEnd), 0); | - | ||||||||||||||||||||||||
2402 | polish(); | - | ||||||||||||||||||||||||
2403 | if (isComponentComplete()) {
| 0-2708 | ||||||||||||||||||||||||
2404 | d->updateType = QQuickTextEditPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
2405 | update(); | - | ||||||||||||||||||||||||
2406 | } executed 2708 times by 1 test: end of block Executed by:
| 2708 | ||||||||||||||||||||||||
2407 | } executed 2708 times by 1 test: end of block Executed by:
| 2708 | ||||||||||||||||||||||||
2408 | - | |||||||||||||||||||||||||
2409 | d->hadSelection = d->control->textCursor().hasSelection(); | - | ||||||||||||||||||||||||
2410 | - | |||||||||||||||||||||||||
2411 | if (d->lastSelectionStart != d->control->textCursor().selectionStart()) {
| 2494-2536 | ||||||||||||||||||||||||
2412 | d->lastSelectionStart = d->control->textCursor().selectionStart(); | - | ||||||||||||||||||||||||
2413 | emit selectionStartChanged(); | - | ||||||||||||||||||||||||
2414 | } executed 2494 times by 2 tests: end of block Executed by:
| 2494 | ||||||||||||||||||||||||
2415 | if (d->lastSelectionEnd != d->control->textCursor().selectionEnd()) {
| 2340-2690 | ||||||||||||||||||||||||
2416 | d->lastSelectionEnd = d->control->textCursor().selectionEnd(); | - | ||||||||||||||||||||||||
2417 | emit selectionEndChanged(); | - | ||||||||||||||||||||||||
2418 | } executed 2690 times by 2 tests: end of block Executed by:
| 2690 | ||||||||||||||||||||||||
2419 | } executed 5030 times by 2 tests: end of block Executed by:
| 5030 | ||||||||||||||||||||||||
2420 | - | |||||||||||||||||||||||||
2421 | QRectF QQuickTextEdit::boundingRect() const | - | ||||||||||||||||||||||||
2422 | { | - | ||||||||||||||||||||||||
2423 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2424 | QRectF r( | - | ||||||||||||||||||||||||
2425 | QQuickTextUtil::alignedX(d->contentSize.width(), width(), effectiveHAlign()), | - | ||||||||||||||||||||||||
2426 | d->yoff, | - | ||||||||||||||||||||||||
2427 | d->contentSize.width(), | - | ||||||||||||||||||||||||
2428 | d->contentSize.height()); | - | ||||||||||||||||||||||||
2429 | - | |||||||||||||||||||||||||
2430 | int cursorWidth = 1; | - | ||||||||||||||||||||||||
2431 | if (d->cursorItem)
| 32 | ||||||||||||||||||||||||
2432 | cursorWidth = 0; executed 32 times by 1 test: cursorWidth = 0; Executed by:
| 32 | ||||||||||||||||||||||||
2433 | else if (!d->document->isEmpty())
| 8-24 | ||||||||||||||||||||||||
2434 | cursorWidth += 3;// ### Need a better way of accounting for space between char and cursor executed 24 times by 1 test: cursorWidth += 3; Executed by:
| 24 | ||||||||||||||||||||||||
2435 | - | |||||||||||||||||||||||||
2436 | // Could include font max left/right bearings to either side of rectangle. | - | ||||||||||||||||||||||||
2437 | r.setRight(r.right() + cursorWidth); | - | ||||||||||||||||||||||||
2438 | - | |||||||||||||||||||||||||
2439 | return r; executed 64 times by 1 test: return r; Executed by:
| 64 | ||||||||||||||||||||||||
2440 | } | - | ||||||||||||||||||||||||
2441 | - | |||||||||||||||||||||||||
2442 | QRectF QQuickTextEdit::clipRect() const | - | ||||||||||||||||||||||||
2443 | { | - | ||||||||||||||||||||||||
2444 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2445 | QRectF r = QQuickImplicitSizeItem::clipRect(); | - | ||||||||||||||||||||||||
2446 | int cursorWidth = 1; | - | ||||||||||||||||||||||||
2447 | if (d->cursorItem)
| 32 | ||||||||||||||||||||||||
2448 | cursorWidth = d->cursorItem->width(); executed 32 times by 1 test: cursorWidth = d->cursorItem->width(); Executed by:
| 32 | ||||||||||||||||||||||||
2449 | if (!d->document->isEmpty())
| 8-56 | ||||||||||||||||||||||||
2450 | cursorWidth += 3;// ### Need a better way of accounting for space between char and cursor executed 56 times by 1 test: cursorWidth += 3; Executed by:
| 56 | ||||||||||||||||||||||||
2451 | - | |||||||||||||||||||||||||
2452 | // Could include font max left/right bearings to either side of rectangle. | - | ||||||||||||||||||||||||
2453 | - | |||||||||||||||||||||||||
2454 | r.setRight(r.right() + cursorWidth); | - | ||||||||||||||||||||||||
2455 | return r; executed 64 times by 1 test: return r; Executed by:
| 64 | ||||||||||||||||||||||||
2456 | } | - | ||||||||||||||||||||||||
2457 | - | |||||||||||||||||||||||||
2458 | qreal QQuickTextEditPrivate::getImplicitWidth() const | - | ||||||||||||||||||||||||
2459 | { | - | ||||||||||||||||||||||||
2460 | Q_Q(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2461 | if (!requireImplicitWidth) {
| 26-74 | ||||||||||||||||||||||||
2462 | // We don't calculate implicitWidth unless it is required. | - | ||||||||||||||||||||||||
2463 | // We need to force a size update now to ensure implicitWidth is calculated | - | ||||||||||||||||||||||||
2464 | const_cast<QQuickTextEditPrivate*>(this)->requireImplicitWidth = true; | - | ||||||||||||||||||||||||
2465 | const_cast<QQuickTextEdit*>(q)->updateSize(); | - | ||||||||||||||||||||||||
2466 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
2467 | return implicitWidth; executed 100 times by 1 test: return implicitWidth; Executed by:
| 100 | ||||||||||||||||||||||||
2468 | } | - | ||||||||||||||||||||||||
2469 | - | |||||||||||||||||||||||||
2470 | //### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't | - | ||||||||||||||||||||||||
2471 | // need to do all the calculations each time | - | ||||||||||||||||||||||||
2472 | void QQuickTextEdit::updateSize() | - | ||||||||||||||||||||||||
2473 | { | - | ||||||||||||||||||||||||
2474 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2475 | if (!isComponentComplete()) {
| 466-5230 | ||||||||||||||||||||||||
2476 | d->dirty = true; | - | ||||||||||||||||||||||||
2477 | return; executed 466 times by 4 tests: return; Executed by:
| 466 | ||||||||||||||||||||||||
2478 | } | - | ||||||||||||||||||||||||
2479 | - | |||||||||||||||||||||||||
2480 | qreal naturalWidth = d->implicitWidth - leftPadding() - rightPadding(); | - | ||||||||||||||||||||||||
2481 | - | |||||||||||||||||||||||||
2482 | qreal newWidth = d->document->idealWidth(); | - | ||||||||||||||||||||||||
2483 | // ### assumes that if the width is set, the text will fill to edges | - | ||||||||||||||||||||||||
2484 | // ### (unless wrap is false, then clipping will occur) | - | ||||||||||||||||||||||||
2485 | if (widthValid()) {
| 910-4320 | ||||||||||||||||||||||||
2486 | if (!d->requireImplicitWidth) {
| 60-850 | ||||||||||||||||||||||||
2487 | emit implicitWidthChanged(); | - | ||||||||||||||||||||||||
2488 | // if the implicitWidth is used, then updateSize() has already been called (recursively) | - | ||||||||||||||||||||||||
2489 | if (d->requireImplicitWidth)
| 0-850 | ||||||||||||||||||||||||
2490 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2491 | } executed 850 times by 5 tests: end of block Executed by:
| 850 | ||||||||||||||||||||||||
2492 | if (d->requireImplicitWidth) {
| 60-850 | ||||||||||||||||||||||||
2493 | d->document->setTextWidth(-1); | - | ||||||||||||||||||||||||
2494 | naturalWidth = d->document->idealWidth(); | - | ||||||||||||||||||||||||
2495 | - | |||||||||||||||||||||||||
2496 | const bool wasInLayout = d->inLayout; | - | ||||||||||||||||||||||||
2497 | d->inLayout = true; | - | ||||||||||||||||||||||||
2498 | if (d->isImplicitResizeEnabled())
| 0-60 | ||||||||||||||||||||||||
2499 | setImplicitWidth(naturalWidth + leftPadding() + rightPadding()); executed 60 times by 1 test: setImplicitWidth(naturalWidth + leftPadding() + rightPadding()); Executed by:
| 60 | ||||||||||||||||||||||||
2500 | d->inLayout = wasInLayout; | - | ||||||||||||||||||||||||
2501 | if (d->inLayout) // probably the result of a binding loop, but by letting it
| 0-60 | ||||||||||||||||||||||||
2502 | return; // get this far we'll get a warning to that effect. never executed: return; | 0 | ||||||||||||||||||||||||
2503 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||||||||||||||||||||
2504 | if (d->document->textWidth() != width()) {
| 226-684 | ||||||||||||||||||||||||
2505 | d->document->setTextWidth(width() - leftPadding() - rightPadding()); | - | ||||||||||||||||||||||||
2506 | newWidth = d->document->idealWidth(); | - | ||||||||||||||||||||||||
2507 | } executed 226 times by 5 tests: end of block Executed by:
| 226 | ||||||||||||||||||||||||
2508 | //### need to confirm cost of always setting these | - | ||||||||||||||||||||||||
2509 | } else if (d->wrapMode == NoWrap && d->document->textWidth() != newWidth) { executed 910 times by 5 tests: end of block Executed by:
| 2-4318 | ||||||||||||||||||||||||
2510 | d->document->setTextWidth(newWidth); // ### Text does not align if width is not set or the idealWidth exceeds the textWidth (QTextDoc bug) | - | ||||||||||||||||||||||||
2511 | } else { executed 3920 times by 6 tests: end of block Executed by:
| 3920 | ||||||||||||||||||||||||
2512 | d->document->setTextWidth(-1); | - | ||||||||||||||||||||||||
2513 | } executed 400 times by 1 test: end of block Executed by:
| 400 | ||||||||||||||||||||||||
2514 | - | |||||||||||||||||||||||||
2515 | QFontMetricsF fm(d->font); | - | ||||||||||||||||||||||||
2516 | qreal newHeight = d->document->isEmpty() ? qCeil(fm.height()) : d->document->size().height();
| 2302-2928 | ||||||||||||||||||||||||
2517 | - | |||||||||||||||||||||||||
2518 | if (d->isImplicitResizeEnabled()) {
| 0-5230 | ||||||||||||||||||||||||
2519 | // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. | - | ||||||||||||||||||||||||
2520 | if (!widthValid())
| 910-4320 | ||||||||||||||||||||||||
2521 | setImplicitSize(newWidth + leftPadding() + rightPadding(), newHeight + topPadding() + bottomPadding()); executed 4320 times by 6 tests: setImplicitSize(newWidth + leftPadding() + rightPadding(), newHeight + topPadding() + bottomPadding()); Executed by:
| 4320 | ||||||||||||||||||||||||
2522 | else | - | ||||||||||||||||||||||||
2523 | setImplicitHeight(newHeight + topPadding() + bottomPadding()); executed 910 times by 5 tests: setImplicitHeight(newHeight + topPadding() + bottomPadding()); Executed by:
| 910 | ||||||||||||||||||||||||
2524 | } | - | ||||||||||||||||||||||||
2525 | - | |||||||||||||||||||||||||
2526 | d->xoff = leftPadding() + qMax(qreal(0), QQuickTextUtil::alignedX(d->document->size().width(), width() - leftPadding() - rightPadding(), effectiveHAlign())); | - | ||||||||||||||||||||||||
2527 | d->yoff = topPadding() + QQuickTextUtil::alignedY(d->document->size().height(), height() - topPadding() - bottomPadding(), d->vAlign); | - | ||||||||||||||||||||||||
2528 | setBaselineOffset(fm.ascent() + d->yoff + d->textMargin); | - | ||||||||||||||||||||||||
2529 | - | |||||||||||||||||||||||||
2530 | QSizeF size(newWidth, newHeight); | - | ||||||||||||||||||||||||
2531 | if (d->contentSize != size) {
| 882-4348 | ||||||||||||||||||||||||
2532 | d->contentSize = size; | - | ||||||||||||||||||||||||
2533 | emit contentSizeChanged(); | - | ||||||||||||||||||||||||
2534 | updateTotalLines(); | - | ||||||||||||||||||||||||
2535 | } executed 4348 times by 6 tests: end of block Executed by:
| 4348 | ||||||||||||||||||||||||
2536 | } executed 5230 times by 6 tests: end of block Executed by:
| 5230 | ||||||||||||||||||||||||
2537 | - | |||||||||||||||||||||||||
2538 | void QQuickTextEdit::updateWholeDocument() | - | ||||||||||||||||||||||||
2539 | { | - | ||||||||||||||||||||||||
2540 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2541 | if (!d->textNodeMap.isEmpty()) {
| 4-406 | ||||||||||||||||||||||||
2542 | for (TextNode &node : d->textNodeMap) | - | ||||||||||||||||||||||||
2543 | node.setDirty(); executed 4 times by 1 test: node.setDirty(); Executed by:
| 4 | ||||||||||||||||||||||||
2544 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2545 | - | |||||||||||||||||||||||||
2546 | polish(); | - | ||||||||||||||||||||||||
2547 | if (isComponentComplete()) {
| 64-346 | ||||||||||||||||||||||||
2548 | d->updateType = QQuickTextEditPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
2549 | update(); | - | ||||||||||||||||||||||||
2550 | } executed 64 times by 3 tests: end of block Executed by:
| 64 | ||||||||||||||||||||||||
2551 | } executed 410 times by 5 tests: end of block Executed by:
| 410 | ||||||||||||||||||||||||
2552 | - | |||||||||||||||||||||||||
2553 | void QQuickTextEdit::invalidateBlock(const QTextBlock &block) | - | ||||||||||||||||||||||||
2554 | { | - | ||||||||||||||||||||||||
2555 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2556 | markDirtyNodesForRange(block.position(), block.position() + block.length(), 0); | - | ||||||||||||||||||||||||
2557 | - | |||||||||||||||||||||||||
2558 | polish(); | - | ||||||||||||||||||||||||
2559 | if (isComponentComplete()) {
| 0 | ||||||||||||||||||||||||
2560 | d->updateType = QQuickTextEditPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
2561 | update(); | - | ||||||||||||||||||||||||
2562 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2563 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2564 | - | |||||||||||||||||||||||||
2565 | void QQuickTextEdit::updateCursor() | - | ||||||||||||||||||||||||
2566 | { | - | ||||||||||||||||||||||||
2567 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2568 | polish(); | - | ||||||||||||||||||||||||
2569 | if (isComponentComplete()) {
| 40-4126 | ||||||||||||||||||||||||
2570 | d->updateType = QQuickTextEditPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
2571 | update(); | - | ||||||||||||||||||||||||
2572 | } executed 4126 times by 3 tests: end of block Executed by:
| 4126 | ||||||||||||||||||||||||
2573 | } executed 4166 times by 4 tests: end of block Executed by:
| 4166 | ||||||||||||||||||||||||
2574 | - | |||||||||||||||||||||||||
2575 | void QQuickTextEdit::q_updateAlignment() | - | ||||||||||||||||||||||||
2576 | { | - | ||||||||||||||||||||||||
2577 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2578 | if (d->determineHorizontalAlignment()) {
| 14-340 | ||||||||||||||||||||||||
2579 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
2580 | d->xoff = qMax(qreal(0), QQuickTextUtil::alignedX(d->document->size().width(), width(), effectiveHAlign())); | - | ||||||||||||||||||||||||
2581 | moveCursorDelegate(); | - | ||||||||||||||||||||||||
2582 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
2583 | } executed 354 times by 3 tests: end of block Executed by:
| 354 | ||||||||||||||||||||||||
2584 | - | |||||||||||||||||||||||||
2585 | void QQuickTextEdit::updateTotalLines() | - | ||||||||||||||||||||||||
2586 | { | - | ||||||||||||||||||||||||
2587 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2588 | - | |||||||||||||||||||||||||
2589 | int subLines = 0; | - | ||||||||||||||||||||||||
2590 | - | |||||||||||||||||||||||||
2591 | for (QTextBlock it = d->document->begin(); it != d->document->end(); it = it.next()) {
| 4348-4702 | ||||||||||||||||||||||||
2592 | QTextLayout *layout = it.layout(); | - | ||||||||||||||||||||||||
2593 | if (!layout)
| 0-4702 | ||||||||||||||||||||||||
2594 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2595 | subLines += layout->lineCount()-1; | - | ||||||||||||||||||||||||
2596 | } executed 4702 times by 6 tests: end of block Executed by:
| 4702 | ||||||||||||||||||||||||
2597 | - | |||||||||||||||||||||||||
2598 | int newTotalLines = d->document->lineCount() + subLines; | - | ||||||||||||||||||||||||
2599 | if (d->lineCount != newTotalLines) {
| 1300-3048 | ||||||||||||||||||||||||
2600 | d->lineCount = newTotalLines; | - | ||||||||||||||||||||||||
2601 | emit lineCountChanged(); | - | ||||||||||||||||||||||||
2602 | } executed 1300 times by 6 tests: end of block Executed by:
| 1300 | ||||||||||||||||||||||||
2603 | } executed 4348 times by 6 tests: end of block Executed by:
| 4348 | ||||||||||||||||||||||||
2604 | - | |||||||||||||||||||||||||
2605 | void QQuickTextEditPrivate::updateDefaultTextOption() | - | ||||||||||||||||||||||||
2606 | { | - | ||||||||||||||||||||||||
2607 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
2608 | QTextOption opt = document->defaultTextOption(); | - | ||||||||||||||||||||||||
2609 | const Qt::Alignment oldAlignment = opt.alignment(); | - | ||||||||||||||||||||||||
2610 | Qt::LayoutDirection oldTextDirection = opt.textDirection(); | - | ||||||||||||||||||||||||
2611 | - | |||||||||||||||||||||||||
2612 | QQuickTextEdit::HAlignment horizontalAlignment = q->effectiveHAlign(); | - | ||||||||||||||||||||||||
2613 | if (contentDirection == Qt::RightToLeft) {
| 54-5256 | ||||||||||||||||||||||||
2614 | if (horizontalAlignment == QQuickTextEdit::AlignLeft)
| 8-46 | ||||||||||||||||||||||||
2615 | horizontalAlignment = QQuickTextEdit::AlignRight; executed 8 times by 1 test: horizontalAlignment = QQuickTextEdit::AlignRight; Executed by:
| 8 | ||||||||||||||||||||||||
2616 | else if (horizontalAlignment == QQuickTextEdit::AlignRight)
| 2-44 | ||||||||||||||||||||||||
2617 | horizontalAlignment = QQuickTextEdit::AlignLeft; executed 44 times by 2 tests: horizontalAlignment = QQuickTextEdit::AlignLeft; Executed by:
| 44 | ||||||||||||||||||||||||
2618 | } executed 54 times by 2 tests: end of block Executed by:
| 54 | ||||||||||||||||||||||||
2619 | if (!hAlignImplicit)
| 116-5194 | ||||||||||||||||||||||||
2620 | opt.setAlignment((Qt::Alignment)(int)(horizontalAlignment | vAlign)); executed 116 times by 1 test: opt.setAlignment((Qt::Alignment)(int)(horizontalAlignment | vAlign)); Executed by:
| 116 | ||||||||||||||||||||||||
2621 | else | - | ||||||||||||||||||||||||
2622 | opt.setAlignment(Qt::Alignment(vAlign)); executed 5194 times by 6 tests: opt.setAlignment(Qt::Alignment(vAlign)); Executed by:
| 5194 | ||||||||||||||||||||||||
2623 | - | |||||||||||||||||||||||||
2624 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
2625 | if (contentDirection == Qt::LayoutDirectionAuto) {
| 2562-2748 | ||||||||||||||||||||||||
2626 | opt.setTextDirection(qGuiApp->inputMethod()->inputDirection()); | - | ||||||||||||||||||||||||
2627 | } else executed 2562 times by 6 tests: end of block Executed by:
| 2562 | ||||||||||||||||||||||||
2628 | #endif | - | ||||||||||||||||||||||||
2629 | { | - | ||||||||||||||||||||||||
2630 | opt.setTextDirection(contentDirection); | - | ||||||||||||||||||||||||
2631 | } executed 2748 times by 5 tests: end of block Executed by:
| 2748 | ||||||||||||||||||||||||
2632 | - | |||||||||||||||||||||||||
2633 | QTextOption::WrapMode oldWrapMode = opt.wrapMode(); | - | ||||||||||||||||||||||||
2634 | opt.setWrapMode(QTextOption::WrapMode(wrapMode)); | - | ||||||||||||||||||||||||
2635 | - | |||||||||||||||||||||||||
2636 | bool oldUseDesignMetrics = opt.useDesignMetrics(); | - | ||||||||||||||||||||||||
2637 | opt.setUseDesignMetrics(renderType != QQuickTextEdit::NativeRendering); | - | ||||||||||||||||||||||||
2638 | - | |||||||||||||||||||||||||
2639 | if (oldWrapMode != opt.wrapMode() || oldAlignment != opt.alignment()
| 116-4126 | ||||||||||||||||||||||||
2640 | || oldTextDirection != opt.textDirection()
| 36-3974 | ||||||||||||||||||||||||
2641 | || oldUseDesignMetrics != opt.useDesignMetrics()) {
| 4-3970 | ||||||||||||||||||||||||
2642 | document->setDefaultTextOption(opt); | - | ||||||||||||||||||||||||
2643 | } executed 1340 times by 6 tests: end of block Executed by:
| 1340 | ||||||||||||||||||||||||
2644 | } executed 5310 times by 6 tests: end of block Executed by:
| 5310 | ||||||||||||||||||||||||
2645 | - | |||||||||||||||||||||||||
2646 | void QQuickTextEdit::focusInEvent(QFocusEvent *event) | - | ||||||||||||||||||||||||
2647 | { | - | ||||||||||||||||||||||||
2648 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2649 | d->handleFocusEvent(event); | - | ||||||||||||||||||||||||
2650 | QQuickImplicitSizeItem::focusInEvent(event); | - | ||||||||||||||||||||||||
2651 | } executed 338 times by 3 tests: end of block Executed by:
| 338 | ||||||||||||||||||||||||
2652 | - | |||||||||||||||||||||||||
2653 | void QQuickTextEdit::focusOutEvent(QFocusEvent *event) | - | ||||||||||||||||||||||||
2654 | { | - | ||||||||||||||||||||||||
2655 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2656 | d->handleFocusEvent(event); | - | ||||||||||||||||||||||||
2657 | QQuickImplicitSizeItem::focusOutEvent(event); | - | ||||||||||||||||||||||||
2658 | } executed 94 times by 3 tests: end of block Executed by:
| 94 | ||||||||||||||||||||||||
2659 | - | |||||||||||||||||||||||||
2660 | void QQuickTextEditPrivate::handleFocusEvent(QFocusEvent *event) | - | ||||||||||||||||||||||||
2661 | { | - | ||||||||||||||||||||||||
2662 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
2663 | bool focus = event->type() == QEvent::FocusIn; | - | ||||||||||||||||||||||||
2664 | if (!q->isReadOnly())
| 28-404 | ||||||||||||||||||||||||
2665 | q->setCursorVisible(focus); executed 404 times by 3 tests: q->setCursorVisible(focus); Executed by:
| 404 | ||||||||||||||||||||||||
2666 | control->processEvent(event, QPointF(-xoff, -yoff)); | - | ||||||||||||||||||||||||
2667 | if (focus) {
| 94-338 | ||||||||||||||||||||||||
2668 | q->q_updateAlignment(); | - | ||||||||||||||||||||||||
2669 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
2670 | if (focusOnPress && !q->isReadOnly())
| 2-336 | ||||||||||||||||||||||||
2671 | qGuiApp->inputMethod()->show(); executed 314 times by 3 tests: (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->show(); Executed by:
| 314 | ||||||||||||||||||||||||
2672 | q->connect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), | - | ||||||||||||||||||||||||
2673 | q, SLOT(q_updateAlignment())); | - | ||||||||||||||||||||||||
2674 | #endif | - | ||||||||||||||||||||||||
2675 | } else { executed 338 times by 3 tests: end of block Executed by:
| 338 | ||||||||||||||||||||||||
2676 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
2677 | q->disconnect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), | - | ||||||||||||||||||||||||
2678 | q, SLOT(q_updateAlignment())); | - | ||||||||||||||||||||||||
2679 | #endif | - | ||||||||||||||||||||||||
2680 | emit q->editingFinished(); | - | ||||||||||||||||||||||||
2681 | } executed 94 times by 3 tests: end of block Executed by:
| 94 | ||||||||||||||||||||||||
2682 | } | - | ||||||||||||||||||||||||
2683 | - | |||||||||||||||||||||||||
2684 | void QQuickTextEditPrivate::addCurrentTextNodeToRoot(QQuickTextNodeEngine *engine, QSGTransformNode *root, QQuickTextNode *node, TextNodeIterator &it, int startPos) | - | ||||||||||||||||||||||||
2685 | { | - | ||||||||||||||||||||||||
2686 | engine->addToSceneGraph(node, QQuickText::Normal, QColor()); | - | ||||||||||||||||||||||||
2687 | it = textNodeMap.insert(it, TextNode(startPos, node)); | - | ||||||||||||||||||||||||
2688 | ++it; | - | ||||||||||||||||||||||||
2689 | root->appendChildNode(node); | - | ||||||||||||||||||||||||
2690 | } executed 562 times by 4 tests: end of block Executed by:
| 562 | ||||||||||||||||||||||||
2691 | - | |||||||||||||||||||||||||
2692 | QQuickTextNode *QQuickTextEditPrivate::createTextNode() | - | ||||||||||||||||||||||||
2693 | { | - | ||||||||||||||||||||||||
2694 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
2695 | QQuickTextNode* node = new QQuickTextNode(q); | - | ||||||||||||||||||||||||
2696 | node->setUseNativeRenderer(renderType == QQuickTextEdit::NativeRendering); | - | ||||||||||||||||||||||||
2697 | return node; executed 854 times by 4 tests: return node; Executed by:
| 854 | ||||||||||||||||||||||||
2698 | } | - | ||||||||||||||||||||||||
2699 | - | |||||||||||||||||||||||||
2700 | void QQuickTextEdit::q_canPasteChanged() | - | ||||||||||||||||||||||||
2701 | { | - | ||||||||||||||||||||||||
2702 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2703 | bool old = d->canPaste; | - | ||||||||||||||||||||||||
2704 | d->canPaste = d->control->canPaste(); | - | ||||||||||||||||||||||||
2705 | bool changed = old!=d->canPaste || !d->canPasteValid;
| 42-3282 | ||||||||||||||||||||||||
2706 | d->canPasteValid = true; | - | ||||||||||||||||||||||||
2707 | if (changed)
| 1788-3240 | ||||||||||||||||||||||||
2708 | emit canPasteChanged(); executed 1788 times by 2 tests: canPasteChanged(); Executed by:
| 1788 | ||||||||||||||||||||||||
2709 | } executed 5028 times by 2 tests: end of block Executed by:
| 5028 | ||||||||||||||||||||||||
2710 | - | |||||||||||||||||||||||||
2711 | /*! | - | ||||||||||||||||||||||||
2712 | \qmlmethod string QtQuick::TextEdit::getText(int start, int end) | - | ||||||||||||||||||||||||
2713 | - | |||||||||||||||||||||||||
2714 | Returns the section of text that is between the \a start and \a end positions. | - | ||||||||||||||||||||||||
2715 | - | |||||||||||||||||||||||||
2716 | The returned text does not include any rich text formatting. | - | ||||||||||||||||||||||||
2717 | */ | - | ||||||||||||||||||||||||
2718 | - | |||||||||||||||||||||||||
2719 | QString QQuickTextEdit::getText(int start, int end) const | - | ||||||||||||||||||||||||
2720 | { | - | ||||||||||||||||||||||||
2721 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2722 | start = qBound(0, start, d->document->characterCount() - 1); | - | ||||||||||||||||||||||||
2723 | end = qBound(0, end, d->document->characterCount() - 1); | - | ||||||||||||||||||||||||
2724 | QTextCursor cursor(d->document); | - | ||||||||||||||||||||||||
2725 | cursor.setPosition(start, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
2726 | cursor.setPosition(end, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
2727 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
2728 | return d->richText executed 208 times by 1 test: return d->richText ? cursor.selectedText() : cursor.selection().toPlainText(); Executed by:
| 208 | ||||||||||||||||||||||||
2729 | ? cursor.selectedText() executed 208 times by 1 test: return d->richText ? cursor.selectedText() : cursor.selection().toPlainText(); Executed by:
| 208 | ||||||||||||||||||||||||
2730 | : cursor.selection().toPlainText(); executed 208 times by 1 test: return d->richText ? cursor.selectedText() : cursor.selection().toPlainText(); Executed by:
| 208 | ||||||||||||||||||||||||
2731 | #else | - | ||||||||||||||||||||||||
2732 | return cursor.selection().toPlainText(); | - | ||||||||||||||||||||||||
2733 | #endif | - | ||||||||||||||||||||||||
2734 | } | - | ||||||||||||||||||||||||
2735 | - | |||||||||||||||||||||||||
2736 | /*! | - | ||||||||||||||||||||||||
2737 | \qmlmethod string QtQuick::TextEdit::getFormattedText(int start, int end) | - | ||||||||||||||||||||||||
2738 | - | |||||||||||||||||||||||||
2739 | Returns the section of text that is between the \a start and \a end positions. | - | ||||||||||||||||||||||||
2740 | - | |||||||||||||||||||||||||
2741 | The returned text will be formatted according the \l textFormat property. | - | ||||||||||||||||||||||||
2742 | */ | - | ||||||||||||||||||||||||
2743 | - | |||||||||||||||||||||||||
2744 | QString QQuickTextEdit::getFormattedText(int start, int end) const | - | ||||||||||||||||||||||||
2745 | { | - | ||||||||||||||||||||||||
2746 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2747 | - | |||||||||||||||||||||||||
2748 | start = qBound(0, start, d->document->characterCount() - 1); | - | ||||||||||||||||||||||||
2749 | end = qBound(0, end, d->document->characterCount() - 1); | - | ||||||||||||||||||||||||
2750 | - | |||||||||||||||||||||||||
2751 | QTextCursor cursor(d->document); | - | ||||||||||||||||||||||||
2752 | cursor.setPosition(start, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
2753 | cursor.setPosition(end, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
2754 | - | |||||||||||||||||||||||||
2755 | if (d->richText) {
| 8-16 | ||||||||||||||||||||||||
2756 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
2757 | return cursor.selection().toHtml(); executed 8 times by 1 test: return cursor.selection().toHtml(); Executed by:
| 8 | ||||||||||||||||||||||||
2758 | #else | - | ||||||||||||||||||||||||
2759 | return cursor.selection().toPlainText(); | - | ||||||||||||||||||||||||
2760 | #endif | - | ||||||||||||||||||||||||
2761 | } else { | - | ||||||||||||||||||||||||
2762 | return cursor.selection().toPlainText(); executed 16 times by 1 test: return cursor.selection().toPlainText(); Executed by:
| 16 | ||||||||||||||||||||||||
2763 | } | - | ||||||||||||||||||||||||
2764 | } | - | ||||||||||||||||||||||||
2765 | - | |||||||||||||||||||||||||
2766 | /*! | - | ||||||||||||||||||||||||
2767 | \qmlmethod QtQuick::TextEdit::insert(int position, string text) | - | ||||||||||||||||||||||||
2768 | - | |||||||||||||||||||||||||
2769 | Inserts \a text into the TextEdit at position. | - | ||||||||||||||||||||||||
2770 | */ | - | ||||||||||||||||||||||||
2771 | void QQuickTextEdit::insert(int position, const QString &text) | - | ||||||||||||||||||||||||
2772 | { | - | ||||||||||||||||||||||||
2773 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2774 | if (position < 0 || position >= d->document->characterCount())
| 2-34 | ||||||||||||||||||||||||
2775 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
2776 | QTextCursor cursor(d->document); | - | ||||||||||||||||||||||||
2777 | cursor.setPosition(position); | - | ||||||||||||||||||||||||
2778 | d->richText = d->richText || (d->format == AutoText && Qt::mightBeRichText(text));
| 0-30 | ||||||||||||||||||||||||
2779 | if (d->richText) {
| 4-28 | ||||||||||||||||||||||||
2780 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
2781 | cursor.insertHtml(text); | - | ||||||||||||||||||||||||
2782 | #else | - | ||||||||||||||||||||||||
2783 | cursor.insertText(text); | - | ||||||||||||||||||||||||
2784 | #endif | - | ||||||||||||||||||||||||
2785 | } else { executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2786 | cursor.insertText(text); | - | ||||||||||||||||||||||||
2787 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||||||||
2788 | d->control->updateCursorRectangle(false); | - | ||||||||||||||||||||||||
2789 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
2790 | - | |||||||||||||||||||||||||
2791 | /*! | - | ||||||||||||||||||||||||
2792 | \qmlmethod string QtQuick::TextEdit::remove(int start, int end) | - | ||||||||||||||||||||||||
2793 | - | |||||||||||||||||||||||||
2794 | Removes the section of text that is between the \a start and \a end positions from the TextEdit. | - | ||||||||||||||||||||||||
2795 | */ | - | ||||||||||||||||||||||||
2796 | - | |||||||||||||||||||||||||
2797 | void QQuickTextEdit::remove(int start, int end) | - | ||||||||||||||||||||||||
2798 | { | - | ||||||||||||||||||||||||
2799 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2800 | start = qBound(0, start, d->document->characterCount() - 1); | - | ||||||||||||||||||||||||
2801 | end = qBound(0, end, d->document->characterCount() - 1); | - | ||||||||||||||||||||||||
2802 | QTextCursor cursor(d->document); | - | ||||||||||||||||||||||||
2803 | cursor.setPosition(start, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
2804 | cursor.setPosition(end, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
2805 | cursor.removeSelectedText(); | - | ||||||||||||||||||||||||
2806 | d->control->updateCursorRectangle(false); | - | ||||||||||||||||||||||||
2807 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||
2808 | - | |||||||||||||||||||||||||
2809 | /*! | - | ||||||||||||||||||||||||
2810 | \qmlproperty TextDocument QtQuick::TextEdit::textDocument | - | ||||||||||||||||||||||||
2811 | \since 5.1 | - | ||||||||||||||||||||||||
2812 | - | |||||||||||||||||||||||||
2813 | Returns the QQuickTextDocument of this TextEdit. | - | ||||||||||||||||||||||||
2814 | It can be used to implement syntax highlighting using | - | ||||||||||||||||||||||||
2815 | \l QSyntaxHighlighter. | - | ||||||||||||||||||||||||
2816 | - | |||||||||||||||||||||||||
2817 | \sa QQuickTextDocument | - | ||||||||||||||||||||||||
2818 | */ | - | ||||||||||||||||||||||||
2819 | - | |||||||||||||||||||||||||
2820 | QQuickTextDocument *QQuickTextEdit::textDocument() | - | ||||||||||||||||||||||||
2821 | { | - | ||||||||||||||||||||||||
2822 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2823 | if (!d->quickDocument)
| 0-2 | ||||||||||||||||||||||||
2824 | d->quickDocument = new QQuickTextDocument(this); executed 2 times by 1 test: d->quickDocument = new QQuickTextDocument(this); Executed by:
| 2 | ||||||||||||||||||||||||
2825 | return d->quickDocument; executed 2 times by 1 test: return d->quickDocument; Executed by:
| 2 | ||||||||||||||||||||||||
2826 | } | - | ||||||||||||||||||||||||
2827 | - | |||||||||||||||||||||||||
2828 | bool QQuickTextEditPrivate::isLinkHoveredConnected() | - | ||||||||||||||||||||||||
2829 | { | - | ||||||||||||||||||||||||
2830 | Q_Q(QQuickTextEdit); | - | ||||||||||||||||||||||||
2831 | IS_SIGNAL_CONNECTED(q, QQuickTextEdit, linkHovered, (const QString &)); executed 442 times by 1 test: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); Executed by:
| 442 | ||||||||||||||||||||||||
2832 | } | - | ||||||||||||||||||||||||
2833 | - | |||||||||||||||||||||||||
2834 | /*! | - | ||||||||||||||||||||||||
2835 | \qmlsignal QtQuick::TextEdit::linkHovered(string link) | - | ||||||||||||||||||||||||
2836 | \since 5.2 | - | ||||||||||||||||||||||||
2837 | - | |||||||||||||||||||||||||
2838 | This signal is emitted when the user hovers a link embedded in the text. | - | ||||||||||||||||||||||||
2839 | The link must be in rich text or HTML format and the | - | ||||||||||||||||||||||||
2840 | \a link string provides access to the particular link. | - | ||||||||||||||||||||||||
2841 | - | |||||||||||||||||||||||||
2842 | The corresponding handler is \c onLinkHovered. | - | ||||||||||||||||||||||||
2843 | - | |||||||||||||||||||||||||
2844 | \sa hoveredLink, linkAt() | - | ||||||||||||||||||||||||
2845 | */ | - | ||||||||||||||||||||||||
2846 | - | |||||||||||||||||||||||||
2847 | /*! | - | ||||||||||||||||||||||||
2848 | \qmlsignal QtQuick::TextEdit::editingFinished() | - | ||||||||||||||||||||||||
2849 | \since 5.6 | - | ||||||||||||||||||||||||
2850 | - | |||||||||||||||||||||||||
2851 | This signal is emitted when the text edit loses focus. | - | ||||||||||||||||||||||||
2852 | - | |||||||||||||||||||||||||
2853 | The corresponding handler is \c onEditingFinished. | - | ||||||||||||||||||||||||
2854 | */ | - | ||||||||||||||||||||||||
2855 | - | |||||||||||||||||||||||||
2856 | /*! | - | ||||||||||||||||||||||||
2857 | \qmlproperty string QtQuick::TextEdit::hoveredLink | - | ||||||||||||||||||||||||
2858 | \since 5.2 | - | ||||||||||||||||||||||||
2859 | - | |||||||||||||||||||||||||
2860 | This property contains the link string when the user hovers a link | - | ||||||||||||||||||||||||
2861 | embedded in the text. The link must be in rich text or HTML format | - | ||||||||||||||||||||||||
2862 | and the link string provides access to the particular link. | - | ||||||||||||||||||||||||
2863 | - | |||||||||||||||||||||||||
2864 | \sa linkHovered, linkAt() | - | ||||||||||||||||||||||||
2865 | */ | - | ||||||||||||||||||||||||
2866 | - | |||||||||||||||||||||||||
2867 | QString QQuickTextEdit::hoveredLink() const | - | ||||||||||||||||||||||||
2868 | { | - | ||||||||||||||||||||||||
2869 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2870 | if (const_cast<QQuickTextEditPrivate *>(d)->isLinkHoveredConnected()) {
| 0-8 | ||||||||||||||||||||||||
2871 | return d->control->hoveredLink(); executed 8 times by 1 test: return d->control->hoveredLink(); Executed by:
| 8 | ||||||||||||||||||||||||
2872 | } else { | - | ||||||||||||||||||||||||
2873 | #if QT_CONFIG(cursor) | - | ||||||||||||||||||||||||
2874 | if (QQuickWindow *wnd = window()) {
| 0 | ||||||||||||||||||||||||
2875 | QPointF pos = QCursor::pos(wnd->screen()) - wnd->position() - mapToScene(QPointF(0, 0)); | - | ||||||||||||||||||||||||
2876 | return d->control->anchorAt(pos); never executed: return d->control->anchorAt(pos); | 0 | ||||||||||||||||||||||||
2877 | } | - | ||||||||||||||||||||||||
2878 | #endif // cursor | - | ||||||||||||||||||||||||
2879 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2880 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
2881 | } | - | ||||||||||||||||||||||||
2882 | - | |||||||||||||||||||||||||
2883 | void QQuickTextEdit::hoverEnterEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
2884 | { | - | ||||||||||||||||||||||||
2885 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2886 | if (d->isLinkHoveredConnected())
| 2-118 | ||||||||||||||||||||||||
2887 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); executed 2 times by 1 test: d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); Executed by:
| 2 | ||||||||||||||||||||||||
2888 | } executed 120 times by 1 test: end of block Executed by:
| 120 | ||||||||||||||||||||||||
2889 | - | |||||||||||||||||||||||||
2890 | void QQuickTextEdit::hoverMoveEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
2891 | { | - | ||||||||||||||||||||||||
2892 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2893 | if (d->isLinkHoveredConnected())
| 6-306 | ||||||||||||||||||||||||
2894 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); executed 6 times by 1 test: d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); Executed by:
| 6 | ||||||||||||||||||||||||
2895 | } executed 312 times by 1 test: end of block Executed by:
| 312 | ||||||||||||||||||||||||
2896 | - | |||||||||||||||||||||||||
2897 | void QQuickTextEdit::hoverLeaveEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
2898 | { | - | ||||||||||||||||||||||||
2899 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2900 | if (d->isLinkHoveredConnected())
| 0-2 | ||||||||||||||||||||||||
2901 | d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); never executed: d->control->processEvent(event, QPointF(-d->xoff, -d->yoff)); | 0 | ||||||||||||||||||||||||
2902 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2903 | - | |||||||||||||||||||||||||
2904 | /*! | - | ||||||||||||||||||||||||
2905 | \qmlmethod void QtQuick::TextEdit::append(string text) | - | ||||||||||||||||||||||||
2906 | \since 5.2 | - | ||||||||||||||||||||||||
2907 | - | |||||||||||||||||||||||||
2908 | Appends a new paragraph with \a text to the end of the TextEdit. | - | ||||||||||||||||||||||||
2909 | - | |||||||||||||||||||||||||
2910 | In order to append without inserting a new paragraph, | - | ||||||||||||||||||||||||
2911 | call \c myTextEdit.insert(myTextEdit.length, text) instead. | - | ||||||||||||||||||||||||
2912 | */ | - | ||||||||||||||||||||||||
2913 | void QQuickTextEdit::append(const QString &text) | - | ||||||||||||||||||||||||
2914 | { | - | ||||||||||||||||||||||||
2915 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2916 | QTextCursor cursor(d->document); | - | ||||||||||||||||||||||||
2917 | cursor.beginEditBlock(); | - | ||||||||||||||||||||||||
2918 | cursor.movePosition(QTextCursor::End); | - | ||||||||||||||||||||||||
2919 | - | |||||||||||||||||||||||||
2920 | if (!d->document->isEmpty())
| 0-20 | ||||||||||||||||||||||||
2921 | cursor.insertBlock(); executed 20 times by 1 test: cursor.insertBlock(); Executed by:
| 20 | ||||||||||||||||||||||||
2922 | - | |||||||||||||||||||||||||
2923 | #if QT_CONFIG(texthtmlparser) | - | ||||||||||||||||||||||||
2924 | if (d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text))) {
| 0-18 | ||||||||||||||||||||||||
2925 | cursor.insertHtml(text); | - | ||||||||||||||||||||||||
2926 | } else { executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2927 | cursor.insertText(text); | - | ||||||||||||||||||||||||
2928 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
2929 | #else | - | ||||||||||||||||||||||||
2930 | cursor.insertText(text); | - | ||||||||||||||||||||||||
2931 | #endif // texthtmlparser | - | ||||||||||||||||||||||||
2932 | - | |||||||||||||||||||||||||
2933 | cursor.endEditBlock(); | - | ||||||||||||||||||||||||
2934 | d->control->updateCursorRectangle(false); | - | ||||||||||||||||||||||||
2935 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
2936 | - | |||||||||||||||||||||||||
2937 | /*! | - | ||||||||||||||||||||||||
2938 | \qmlmethod QtQuick::TextEdit::linkAt(real x, real y) | - | ||||||||||||||||||||||||
2939 | \since 5.3 | - | ||||||||||||||||||||||||
2940 | - | |||||||||||||||||||||||||
2941 | Returns the link string at point \a x, \a y in content coordinates, | - | ||||||||||||||||||||||||
2942 | or an empty string if no link exists at that point. | - | ||||||||||||||||||||||||
2943 | - | |||||||||||||||||||||||||
2944 | \sa hoveredLink | - | ||||||||||||||||||||||||
2945 | */ | - | ||||||||||||||||||||||||
2946 | QString QQuickTextEdit::linkAt(qreal x, qreal y) const | - | ||||||||||||||||||||||||
2947 | { | - | ||||||||||||||||||||||||
2948 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2949 | return d->control->anchorAt(QPointF(x + topPadding(), y + leftPadding())); executed 8 times by 1 test: return d->control->anchorAt(QPointF(x + topPadding(), y + leftPadding())); Executed by:
| 8 | ||||||||||||||||||||||||
2950 | } | - | ||||||||||||||||||||||||
2951 | - | |||||||||||||||||||||||||
2952 | /*! | - | ||||||||||||||||||||||||
2953 | \since 5.6 | - | ||||||||||||||||||||||||
2954 | \qmlproperty real QtQuick::TextEdit::padding | - | ||||||||||||||||||||||||
2955 | \qmlproperty real QtQuick::TextEdit::topPadding | - | ||||||||||||||||||||||||
2956 | \qmlproperty real QtQuick::TextEdit::leftPadding | - | ||||||||||||||||||||||||
2957 | \qmlproperty real QtQuick::TextEdit::bottomPadding | - | ||||||||||||||||||||||||
2958 | \qmlproperty real QtQuick::TextEdit::rightPadding | - | ||||||||||||||||||||||||
2959 | - | |||||||||||||||||||||||||
2960 | These properties hold the padding around the content. This space is reserved | - | ||||||||||||||||||||||||
2961 | in addition to the contentWidth and contentHeight. | - | ||||||||||||||||||||||||
2962 | */ | - | ||||||||||||||||||||||||
2963 | qreal QQuickTextEdit::padding() const | - | ||||||||||||||||||||||||
2964 | { | - | ||||||||||||||||||||||||
2965 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
2966 | return d->padding(); executed 2 times by 1 test: return d->padding(); Executed by:
| 2 | ||||||||||||||||||||||||
2967 | } | - | ||||||||||||||||||||||||
2968 | - | |||||||||||||||||||||||||
2969 | void QQuickTextEdit::setPadding(qreal padding) | - | ||||||||||||||||||||||||
2970 | { | - | ||||||||||||||||||||||||
2971 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
2972 | if (qFuzzyCompare(d->padding(), padding))
| 0-4 | ||||||||||||||||||||||||
2973 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2974 | - | |||||||||||||||||||||||||
2975 | d->extra.value().padding = padding; | - | ||||||||||||||||||||||||
2976 | updateSize(); | - | ||||||||||||||||||||||||
2977 | if (isComponentComplete()) {
| 2 | ||||||||||||||||||||||||
2978 | d->updateType = QQuickTextEditPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
2979 | update(); | - | ||||||||||||||||||||||||
2980 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2981 | emit paddingChanged(); | - | ||||||||||||||||||||||||
2982 | if (!d->extra.isAllocated() || !d->extra->explicitTopPadding)
| 0-4 | ||||||||||||||||||||||||
2983 | emit topPaddingChanged(); executed 2 times by 1 test: topPaddingChanged(); Executed by:
| 2 | ||||||||||||||||||||||||
2984 | if (!d->extra.isAllocated() || !d->extra->explicitLeftPadding)
| 0-4 | ||||||||||||||||||||||||
2985 | emit leftPaddingChanged(); executed 2 times by 1 test: leftPaddingChanged(); Executed by:
| 2 | ||||||||||||||||||||||||
2986 | if (!d->extra.isAllocated() || !d->extra->explicitRightPadding)
| 0-4 | ||||||||||||||||||||||||
2987 | emit rightPaddingChanged(); executed 2 times by 1 test: rightPaddingChanged(); Executed by:
| 2 | ||||||||||||||||||||||||
2988 | if (!d->extra.isAllocated() || !d->extra->explicitBottomPadding)
| 0-4 | ||||||||||||||||||||||||
2989 | emit bottomPaddingChanged(); executed 2 times by 1 test: bottomPaddingChanged(); Executed by:
| 2 | ||||||||||||||||||||||||
2990 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2991 | - | |||||||||||||||||||||||||
2992 | void QQuickTextEdit::resetPadding() | - | ||||||||||||||||||||||||
2993 | { | - | ||||||||||||||||||||||||
2994 | setPadding(0); | - | ||||||||||||||||||||||||
2995 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2996 | - | |||||||||||||||||||||||||
2997 | qreal QQuickTextEdit::topPadding() const | - | ||||||||||||||||||||||||
2998 | { | - | ||||||||||||||||||||||||
2999 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
3000 | if (d->extra.isAllocated() && d->extra->explicitTopPadding)
| 36-15614 | ||||||||||||||||||||||||
3001 | return d->extra->topPadding; executed 72 times by 1 test: return d->extra->topPadding; Executed by:
| 72 | ||||||||||||||||||||||||
3002 | return d->padding(); executed 15650 times by 6 tests: return d->padding(); Executed by:
| 15650 | ||||||||||||||||||||||||
3003 | } | - | ||||||||||||||||||||||||
3004 | - | |||||||||||||||||||||||||
3005 | void QQuickTextEdit::setTopPadding(qreal padding) | - | ||||||||||||||||||||||||
3006 | { | - | ||||||||||||||||||||||||
3007 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3008 | d->setTopPadding(padding); | - | ||||||||||||||||||||||||
3009 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3010 | - | |||||||||||||||||||||||||
3011 | void QQuickTextEdit::resetTopPadding() | - | ||||||||||||||||||||||||
3012 | { | - | ||||||||||||||||||||||||
3013 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3014 | d->setTopPadding(0, true); | - | ||||||||||||||||||||||||
3015 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3016 | - | |||||||||||||||||||||||||
3017 | qreal QQuickTextEdit::leftPadding() const | - | ||||||||||||||||||||||||
3018 | { | - | ||||||||||||||||||||||||
3019 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
3020 | if (d->extra.isAllocated() && d->extra->explicitLeftPadding)
| 46-20168 | ||||||||||||||||||||||||
3021 | return d->extra->leftPadding; executed 114 times by 1 test: return d->extra->leftPadding; Executed by:
| 114 | ||||||||||||||||||||||||
3022 | return d->padding(); executed 20214 times by 6 tests: return d->padding(); Executed by:
| 20214 | ||||||||||||||||||||||||
3023 | } | - | ||||||||||||||||||||||||
3024 | - | |||||||||||||||||||||||||
3025 | void QQuickTextEdit::setLeftPadding(qreal padding) | - | ||||||||||||||||||||||||
3026 | { | - | ||||||||||||||||||||||||
3027 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3028 | d->setLeftPadding(padding); | - | ||||||||||||||||||||||||
3029 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3030 | - | |||||||||||||||||||||||||
3031 | void QQuickTextEdit::resetLeftPadding() | - | ||||||||||||||||||||||||
3032 | { | - | ||||||||||||||||||||||||
3033 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3034 | d->setLeftPadding(0, true); | - | ||||||||||||||||||||||||
3035 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3036 | - | |||||||||||||||||||||||||
3037 | qreal QQuickTextEdit::rightPadding() const | - | ||||||||||||||||||||||||
3038 | { | - | ||||||||||||||||||||||||
3039 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
3040 | if (d->extra.isAllocated() && d->extra->explicitRightPadding)
| 30-14958 | ||||||||||||||||||||||||
3041 | return d->extra->rightPadding; executed 102 times by 1 test: return d->extra->rightPadding; Executed by:
| 102 | ||||||||||||||||||||||||
3042 | return d->padding(); executed 14988 times by 6 tests: return d->padding(); Executed by:
| 14988 | ||||||||||||||||||||||||
3043 | } | - | ||||||||||||||||||||||||
3044 | - | |||||||||||||||||||||||||
3045 | void QQuickTextEdit::setRightPadding(qreal padding) | - | ||||||||||||||||||||||||
3046 | { | - | ||||||||||||||||||||||||
3047 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3048 | d->setRightPadding(padding); | - | ||||||||||||||||||||||||
3049 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3050 | - | |||||||||||||||||||||||||
3051 | void QQuickTextEdit::resetRightPadding() | - | ||||||||||||||||||||||||
3052 | { | - | ||||||||||||||||||||||||
3053 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3054 | d->setRightPadding(0, true); | - | ||||||||||||||||||||||||
3055 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3056 | - | |||||||||||||||||||||||||
3057 | qreal QQuickTextEdit::bottomPadding() const | - | ||||||||||||||||||||||||
3058 | { | - | ||||||||||||||||||||||||
3059 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
3060 | if (d->extra.isAllocated() && d->extra->explicitBottomPadding)
| 12-10406 | ||||||||||||||||||||||||
3061 | return d->extra->bottomPadding; executed 66 times by 1 test: return d->extra->bottomPadding; Executed by:
| 66 | ||||||||||||||||||||||||
3062 | return d->padding(); executed 10418 times by 6 tests: return d->padding(); Executed by:
| 10418 | ||||||||||||||||||||||||
3063 | } | - | ||||||||||||||||||||||||
3064 | - | |||||||||||||||||||||||||
3065 | void QQuickTextEdit::setBottomPadding(qreal padding) | - | ||||||||||||||||||||||||
3066 | { | - | ||||||||||||||||||||||||
3067 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3068 | d->setBottomPadding(padding); | - | ||||||||||||||||||||||||
3069 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3070 | - | |||||||||||||||||||||||||
3071 | void QQuickTextEdit::resetBottomPadding() | - | ||||||||||||||||||||||||
3072 | { | - | ||||||||||||||||||||||||
3073 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3074 | d->setBottomPadding(0, true); | - | ||||||||||||||||||||||||
3075 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3076 | - | |||||||||||||||||||||||||
3077 | /*! | - | ||||||||||||||||||||||||
3078 | \qmlproperty real QtQuick::TextEdit::tabStopDistance | - | ||||||||||||||||||||||||
3079 | \since 5.10 | - | ||||||||||||||||||||||||
3080 | - | |||||||||||||||||||||||||
3081 | The default distance, in device units, between tab stops. | - | ||||||||||||||||||||||||
3082 | - | |||||||||||||||||||||||||
3083 | \sa QTextOption::setTabStop() | - | ||||||||||||||||||||||||
3084 | */ | - | ||||||||||||||||||||||||
3085 | int QQuickTextEdit::tabStopDistance() const | - | ||||||||||||||||||||||||
3086 | { | - | ||||||||||||||||||||||||
3087 | Q_D(const QQuickTextEdit); | - | ||||||||||||||||||||||||
3088 | return d->document->defaultTextOption().tabStopDistance(); never executed: return d->document->defaultTextOption().tabStopDistance(); | 0 | ||||||||||||||||||||||||
3089 | } | - | ||||||||||||||||||||||||
3090 | - | |||||||||||||||||||||||||
3091 | void QQuickTextEdit::setTabStopDistance(qreal distance) | - | ||||||||||||||||||||||||
3092 | { | - | ||||||||||||||||||||||||
3093 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3094 | QTextOption textOptions = d->document->defaultTextOption(); | - | ||||||||||||||||||||||||
3095 | if (textOptions.tabStopDistance() == distance)
| 0 | ||||||||||||||||||||||||
3096 | return; never executed: return; | 0 | ||||||||||||||||||||||||
3097 | - | |||||||||||||||||||||||||
3098 | textOptions.setTabStopDistance(distance); | - | ||||||||||||||||||||||||
3099 | d->document->setDefaultTextOption(textOptions); | - | ||||||||||||||||||||||||
3100 | emit tabStopDistanceChanged(distance); | - | ||||||||||||||||||||||||
3101 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3102 | - | |||||||||||||||||||||||||
3103 | /*! | - | ||||||||||||||||||||||||
3104 | \qmlmethod QtQuick::TextEdit::clear() | - | ||||||||||||||||||||||||
3105 | \since 5.7 | - | ||||||||||||||||||||||||
3106 | - | |||||||||||||||||||||||||
3107 | Clears the contents of the text edit | - | ||||||||||||||||||||||||
3108 | and resets partial text input from an input method. | - | ||||||||||||||||||||||||
3109 | - | |||||||||||||||||||||||||
3110 | Use this method instead of setting the \l text property to an empty string. | - | ||||||||||||||||||||||||
3111 | - | |||||||||||||||||||||||||
3112 | \sa QInputMethod::reset() | - | ||||||||||||||||||||||||
3113 | */ | - | ||||||||||||||||||||||||
3114 | void QQuickTextEdit::clear() | - | ||||||||||||||||||||||||
3115 | { | - | ||||||||||||||||||||||||
3116 | Q_D(QQuickTextEdit); | - | ||||||||||||||||||||||||
3117 | d->resetInputMethod(); | - | ||||||||||||||||||||||||
3118 | d->control->clear(); | - | ||||||||||||||||||||||||
3119 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
3120 | - | |||||||||||||||||||||||||
3121 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
3122 | - | |||||||||||||||||||||||||
3123 | #include "moc_qquicktextedit_p.cpp" | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |