Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicktext.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 "qquicktext_p.h" | - | ||||||||||||||||||||||||
41 | #include "qquicktext_p_p.h" | - | ||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | #include <QtQuick/private/qsgcontext_p.h> | - | ||||||||||||||||||||||||
44 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||||||||
45 | #include <private/qsgadaptationlayer_p.h> | - | ||||||||||||||||||||||||
46 | #include "qquicktextnode_p.h" | - | ||||||||||||||||||||||||
47 | #include "qquickimage_p_p.h" | - | ||||||||||||||||||||||||
48 | #include "qquicktextutil_p.h" | - | ||||||||||||||||||||||||
49 | #include "qquicktextdocument_p.h" | - | ||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||
51 | #include <QtQuick/private/qsgtexture_p.h> | - | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||||||||
54 | #include <QtGui/qevent.h> | - | ||||||||||||||||||||||||
55 | #include <QtGui/qabstracttextdocumentlayout.h> | - | ||||||||||||||||||||||||
56 | #include <QtGui/qpainter.h> | - | ||||||||||||||||||||||||
57 | #include <QtGui/qtextdocument.h> | - | ||||||||||||||||||||||||
58 | #include <QtGui/qtextobject.h> | - | ||||||||||||||||||||||||
59 | #include <QtGui/qtextcursor.h> | - | ||||||||||||||||||||||||
60 | #include <QtGui/qguiapplication.h> | - | ||||||||||||||||||||||||
61 | #include <QtGui/qinputmethod.h> | - | ||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | #include <private/qtextengine_p.h> | - | ||||||||||||||||||||||||
64 | #include <private/qquickstyledtext_p.h> | - | ||||||||||||||||||||||||
65 | #include <QtQuick/private/qquickpixmapcache_p.h> | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | #include <qmath.h> | - | ||||||||||||||||||||||||
68 | #include <limits.h> | - | ||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE) | - | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | const QChar QQuickTextPrivate::elideChar = QChar(0x2026); | - | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | QQuickTextPrivate::QQuickTextPrivate() | - | ||||||||||||||||||||||||
77 | : fontInfo(font), elideLayout(nullptr), textLine(nullptr), lineWidth(0) | - | ||||||||||||||||||||||||
78 | , color(0xFF000000), linkColor(0xFF0000FF), styleColor(0xFF000000) | - | ||||||||||||||||||||||||
79 | , lineCount(1), multilengthEos(-1) | - | ||||||||||||||||||||||||
80 | , elideMode(QQuickText::ElideNone), hAlign(QQuickText::AlignLeft), vAlign(QQuickText::AlignTop) | - | ||||||||||||||||||||||||
81 | , format(QQuickText::AutoText), wrapMode(QQuickText::NoWrap) | - | ||||||||||||||||||||||||
82 | , style(QQuickText::Normal) | - | ||||||||||||||||||||||||
83 | , renderType(QQuickTextUtil::textRenderType<QQuickText>()) | - | ||||||||||||||||||||||||
84 | , updateType(UpdatePaintNode) | - | ||||||||||||||||||||||||
85 | , maximumLineCountValid(false), updateOnComponentComplete(true), richText(false) | - | ||||||||||||||||||||||||
86 | , styledText(false), widthExceeded(false), heightExceeded(false), internalWidthUpdate(false) | - | ||||||||||||||||||||||||
87 | , requireImplicitSize(false), implicitWidthValid(false), implicitHeightValid(false) | - | ||||||||||||||||||||||||
88 | , truncated(false), hAlignImplicit(true), rightToLeftText(false) | - | ||||||||||||||||||||||||
89 | , layoutTextElided(false), textHasChanged(true), needToUpdateLayout(false), formatModifiesFontSize(false) | - | ||||||||||||||||||||||||
90 | , polishSize(false) | - | ||||||||||||||||||||||||
91 | , updateSizeRecursionGuard(false) | - | ||||||||||||||||||||||||
92 | { | - | ||||||||||||||||||||||||
93 | implicitAntialiasing = true; | - | ||||||||||||||||||||||||
94 | } executed 264678 times by 35 tests: end of block Executed by:
| 264678 | ||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||
96 | QQuickTextPrivate::ExtraData::ExtraData() | - | ||||||||||||||||||||||||
97 | : padding(0) | - | ||||||||||||||||||||||||
98 | , topPadding(0) | - | ||||||||||||||||||||||||
99 | , leftPadding(0) | - | ||||||||||||||||||||||||
100 | , rightPadding(0) | - | ||||||||||||||||||||||||
101 | , bottomPadding(0) | - | ||||||||||||||||||||||||
102 | , explicitTopPadding(false) | - | ||||||||||||||||||||||||
103 | , explicitLeftPadding(false) | - | ||||||||||||||||||||||||
104 | , explicitRightPadding(false) | - | ||||||||||||||||||||||||
105 | , explicitBottomPadding(false) | - | ||||||||||||||||||||||||
106 | , lineHeight(1.0) | - | ||||||||||||||||||||||||
107 | , doc(nullptr) | - | ||||||||||||||||||||||||
108 | , minimumPixelSize(12) | - | ||||||||||||||||||||||||
109 | , minimumPointSize(12) | - | ||||||||||||||||||||||||
110 | , nbActiveDownloads(0) | - | ||||||||||||||||||||||||
111 | , maximumLineCount(INT_MAX) | - | ||||||||||||||||||||||||
112 | , lineHeightValid(false) | - | ||||||||||||||||||||||||
113 | , lineHeightMode(QQuickText::ProportionalHeight) | - | ||||||||||||||||||||||||
114 | , fontSizeMode(QQuickText::FixedSize) | - | ||||||||||||||||||||||||
115 | { | - | ||||||||||||||||||||||||
116 | } executed 330 times by 2 tests: end of block Executed by:
| 330 | ||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||
118 | void QQuickTextPrivate::init() | - | ||||||||||||||||||||||||
119 | { | - | ||||||||||||||||||||||||
120 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
121 | q->setAcceptedMouseButtons(Qt::LeftButton); | - | ||||||||||||||||||||||||
122 | q->setFlag(QQuickItem::ItemHasContents); | - | ||||||||||||||||||||||||
123 | } executed 264678 times by 35 tests: end of block Executed by:
| 264678 | ||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | QQuickTextPrivate::~QQuickTextPrivate() | - | ||||||||||||||||||||||||
126 | { | - | ||||||||||||||||||||||||
127 | delete elideLayout; | - | ||||||||||||||||||||||||
128 | delete textLine; textLine = nullptr; | - | ||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | if (extra.isAllocated()) {
| 328-264286 | ||||||||||||||||||||||||
131 | qDeleteAll(extra->imgTags); | - | ||||||||||||||||||||||||
132 | extra->imgTags.clear(); | - | ||||||||||||||||||||||||
133 | } executed 328 times by 2 tests: end of block Executed by:
| 328 | ||||||||||||||||||||||||
134 | } executed 264614 times by 33 tests: end of block Executed by:
| 264614 | ||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||
136 | qreal QQuickTextPrivate::getImplicitWidth() const | - | ||||||||||||||||||||||||
137 | { | - | ||||||||||||||||||||||||
138 | if (!requireImplicitSize) {
| 148-1012 | ||||||||||||||||||||||||
139 | // We don't calculate implicitWidth unless it is required. | - | ||||||||||||||||||||||||
140 | // We need to force a size update now to ensure implicitWidth is calculated | - | ||||||||||||||||||||||||
141 | QQuickTextPrivate *me = const_cast<QQuickTextPrivate*>(this); | - | ||||||||||||||||||||||||
142 | me->requireImplicitSize = true; | - | ||||||||||||||||||||||||
143 | me->updateSize(); | - | ||||||||||||||||||||||||
144 | } executed 148 times by 5 tests: end of block Executed by:
| 148 | ||||||||||||||||||||||||
145 | return implicitWidth; executed 1160 times by 6 tests: return implicitWidth; Executed by:
| 1160 | ||||||||||||||||||||||||
146 | } | - | ||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||
148 | qreal QQuickTextPrivate::getImplicitHeight() const | - | ||||||||||||||||||||||||
149 | { | - | ||||||||||||||||||||||||
150 | if (!requireImplicitSize) {
| 190-750 | ||||||||||||||||||||||||
151 | QQuickTextPrivate *me = const_cast<QQuickTextPrivate*>(this); | - | ||||||||||||||||||||||||
152 | me->requireImplicitSize = true; | - | ||||||||||||||||||||||||
153 | me->updateSize(); | - | ||||||||||||||||||||||||
154 | } executed 190 times by 3 tests: end of block Executed by:
| 190 | ||||||||||||||||||||||||
155 | return implicitHeight; executed 940 times by 5 tests: return implicitHeight; Executed by:
| 940 | ||||||||||||||||||||||||
156 | } | - | ||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||
158 | qreal QQuickTextPrivate::availableWidth() const | - | ||||||||||||||||||||||||
159 | { | - | ||||||||||||||||||||||||
160 | Q_Q(const QQuickText); | - | ||||||||||||||||||||||||
161 | return q->width() - q->leftPadding() - q->rightPadding(); executed 1097384 times by 33 tests: return q->width() - q->leftPadding() - q->rightPadding(); Executed by:
| 1097384 | ||||||||||||||||||||||||
162 | } | - | ||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||
164 | qreal QQuickTextPrivate::availableHeight() const | - | ||||||||||||||||||||||||
165 | { | - | ||||||||||||||||||||||||
166 | Q_Q(const QQuickText); | - | ||||||||||||||||||||||||
167 | return q->height() - q->topPadding() - q->bottomPadding(); executed 1100576 times by 33 tests: return q->height() - q->topPadding() - q->bottomPadding(); Executed by:
| 1100576 | ||||||||||||||||||||||||
168 | } | - | ||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||
170 | void QQuickTextPrivate::setTopPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
171 | { | - | ||||||||||||||||||||||||
172 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
173 | qreal oldPadding = q->topPadding(); | - | ||||||||||||||||||||||||
174 | if (!reset || extra.isAllocated()) {
| 0-32 | ||||||||||||||||||||||||
175 | extra.value().topPadding = value; | - | ||||||||||||||||||||||||
176 | extra.value().explicitTopPadding = !reset; | - | ||||||||||||||||||||||||
177 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
178 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-32 | ||||||||||||||||||||||||
179 | updateSize(); | - | ||||||||||||||||||||||||
180 | emit q->topPaddingChanged(); | - | ||||||||||||||||||||||||
181 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
182 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||
184 | void QQuickTextPrivate::setLeftPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
185 | { | - | ||||||||||||||||||||||||
186 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
187 | qreal oldPadding = q->leftPadding(); | - | ||||||||||||||||||||||||
188 | if (!reset || extra.isAllocated()) {
| 0-4 | ||||||||||||||||||||||||
189 | extra.value().leftPadding = value; | - | ||||||||||||||||||||||||
190 | extra.value().explicitLeftPadding = !reset; | - | ||||||||||||||||||||||||
191 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
192 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-4 | ||||||||||||||||||||||||
193 | updateSize(); | - | ||||||||||||||||||||||||
194 | emit q->leftPaddingChanged(); | - | ||||||||||||||||||||||||
195 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
196 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | void QQuickTextPrivate::setRightPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
199 | { | - | ||||||||||||||||||||||||
200 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
201 | qreal oldPadding = q->rightPadding(); | - | ||||||||||||||||||||||||
202 | if (!reset || extra.isAllocated()) {
| 0-4 | ||||||||||||||||||||||||
203 | extra.value().rightPadding = value; | - | ||||||||||||||||||||||||
204 | extra.value().explicitRightPadding = !reset; | - | ||||||||||||||||||||||||
205 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
206 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-4 | ||||||||||||||||||||||||
207 | updateSize(); | - | ||||||||||||||||||||||||
208 | emit q->rightPaddingChanged(); | - | ||||||||||||||||||||||||
209 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
210 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
211 | - | |||||||||||||||||||||||||
212 | void QQuickTextPrivate::setBottomPadding(qreal value, bool reset) | - | ||||||||||||||||||||||||
213 | { | - | ||||||||||||||||||||||||
214 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
215 | qreal oldPadding = q->bottomPadding(); | - | ||||||||||||||||||||||||
216 | if (!reset || extra.isAllocated()) {
| 0-32 | ||||||||||||||||||||||||
217 | extra.value().bottomPadding = value; | - | ||||||||||||||||||||||||
218 | extra.value().explicitBottomPadding = !reset; | - | ||||||||||||||||||||||||
219 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
220 | if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
| 0-32 | ||||||||||||||||||||||||
221 | updateSize(); | - | ||||||||||||||||||||||||
222 | emit q->bottomPaddingChanged(); | - | ||||||||||||||||||||||||
223 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
224 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||
226 | /*! | - | ||||||||||||||||||||||||
227 | \qmlproperty bool QtQuick::Text::antialiasing | - | ||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||
229 | Used to decide if the Text should use antialiasing or not. Only Text | - | ||||||||||||||||||||||||
230 | with renderType of Text.NativeRendering can disable antialiasing. | - | ||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||
232 | The default is true. | - | ||||||||||||||||||||||||
233 | */ | - | ||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||
235 | void QQuickText::q_updateLayout() | - | ||||||||||||||||||||||||
236 | { | - | ||||||||||||||||||||||||
237 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
238 | d->updateLayout(); | - | ||||||||||||||||||||||||
239 | } never executed: end of block | 0 | ||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||
241 | void QQuickTextPrivate::updateLayout() | - | ||||||||||||||||||||||||
242 | { | - | ||||||||||||||||||||||||
243 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
244 | if (!q->isComponentComplete()) {
| 254122-472713 | ||||||||||||||||||||||||
245 | updateOnComponentComplete = true; | - | ||||||||||||||||||||||||
246 | return; executed 254122 times by 33 tests: return; Executed by:
| 254122 | ||||||||||||||||||||||||
247 | } | - | ||||||||||||||||||||||||
248 | updateOnComponentComplete = false; | - | ||||||||||||||||||||||||
249 | layoutTextElided = false; | - | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | if (extra.isAllocated())
| 840-471873 | ||||||||||||||||||||||||
252 | extra->visibleImgTags.clear(); executed 840 times by 2 tests: extra->visibleImgTags.clear(); Executed by:
| 840 | ||||||||||||||||||||||||
253 | needToUpdateLayout = false; | - | ||||||||||||||||||||||||
254 | - | |||||||||||||||||||||||||
255 | // Setup instance of QTextLayout for all cases other than richtext | - | ||||||||||||||||||||||||
256 | if (!richText) {
| 284-472429 | ||||||||||||||||||||||||
257 | if (textHasChanged) {
| 1618-470811 | ||||||||||||||||||||||||
258 | if (styledText && !text.isEmpty()) {
| 4-468819 | ||||||||||||||||||||||||
259 | layout.setFont(font); | - | ||||||||||||||||||||||||
260 | // needs temporary bool because formatModifiesFontSize is in a bit-field | - | ||||||||||||||||||||||||
261 | bool fontSizeModified = false; | - | ||||||||||||||||||||||||
262 | QList<QQuickStyledTextImgTag*> someImgTags = extra.isAllocated() ? extra->imgTags : QList<QQuickStyledTextImgTag*>();
| 58-1930 | ||||||||||||||||||||||||
263 | QQuickStyledText::parse(text, layout, someImgTags, q->baseUrl(), qmlContext(q), !maximumLineCountValid, &fontSizeModified); | - | ||||||||||||||||||||||||
264 | if (someImgTags.size() || extra.isAllocated())
| 22-1908 | ||||||||||||||||||||||||
265 | extra.value().imgTags = someImgTags; executed 102 times by 2 tests: extra.value().imgTags = someImgTags; Executed by:
| 102 | ||||||||||||||||||||||||
266 | formatModifiesFontSize = fontSizeModified; | - | ||||||||||||||||||||||||
267 | multilengthEos = -1; | - | ||||||||||||||||||||||||
268 | } else { executed 1988 times by 6 tests: end of block Executed by:
| 1988 | ||||||||||||||||||||||||
269 | QString tmp = text; | - | ||||||||||||||||||||||||
270 | multilengthEos = tmp.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||||||||||||||
271 | if (multilengthEos != -1)
| 12-468811 | ||||||||||||||||||||||||
272 | tmp = tmp.mid(0, multilengthEos); executed 12 times by 1 test: tmp = tmp.mid(0, multilengthEos); Executed by:
| 12 | ||||||||||||||||||||||||
273 | tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); | - | ||||||||||||||||||||||||
274 | layout.setText(tmp); | - | ||||||||||||||||||||||||
275 | } executed 468823 times by 35 tests: end of block Executed by:
| 468823 | ||||||||||||||||||||||||
276 | textHasChanged = false; | - | ||||||||||||||||||||||||
277 | } executed 470811 times by 35 tests: end of block Executed by:
| 470811 | ||||||||||||||||||||||||
278 | } else if (extra.isAllocated() && extra->lineHeightValid) { executed 472429 times by 35 tests: end of block Executed by:
| 0-472429 | ||||||||||||||||||||||||
279 | ensureDoc(); | - | ||||||||||||||||||||||||
280 | QTextBlockFormat::LineHeightTypes type; | - | ||||||||||||||||||||||||
281 | type = lineHeightMode() == QQuickText::FixedHeight ? QTextBlockFormat::FixedHeight : QTextBlockFormat::ProportionalHeight;
| 0 | ||||||||||||||||||||||||
282 | QTextBlockFormat blockFormat; | - | ||||||||||||||||||||||||
283 | blockFormat.setLineHeight((lineHeightMode() == QQuickText::FixedHeight ? lineHeight() : lineHeight() * 100), type); | - | ||||||||||||||||||||||||
284 | for (QTextBlock it = extra->doc->begin(); it != extra->doc->end(); it = it.next()) {
| 0 | ||||||||||||||||||||||||
285 | QTextCursor cursor(it); | - | ||||||||||||||||||||||||
286 | cursor.mergeBlockFormat(blockFormat); | - | ||||||||||||||||||||||||
287 | } never executed: end of block | 0 | ||||||||||||||||||||||||
288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||
290 | updateSize(); | - | ||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | if (needToUpdateLayout) {
| 2-472711 | ||||||||||||||||||||||||
293 | needToUpdateLayout = false; | - | ||||||||||||||||||||||||
294 | textHasChanged = true; | - | ||||||||||||||||||||||||
295 | updateLayout(); | - | ||||||||||||||||||||||||
296 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
297 | - | |||||||||||||||||||||||||
298 | q->polish(); | - | ||||||||||||||||||||||||
299 | } executed 472713 times by 35 tests: end of block Executed by:
| 472713 | ||||||||||||||||||||||||
300 | - | |||||||||||||||||||||||||
301 | void QQuickText::imageDownloadFinished() | - | ||||||||||||||||||||||||
302 | { | - | ||||||||||||||||||||||||
303 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
304 | - | |||||||||||||||||||||||||
305 | (d->extra->nbActiveDownloads)--; | - | ||||||||||||||||||||||||
306 | - | |||||||||||||||||||||||||
307 | // when all the remote images have been downloaded, | - | ||||||||||||||||||||||||
308 | // if one of the sizes was not specified at parsing time | - | ||||||||||||||||||||||||
309 | // we use the implicit size from pixmapcache and re-layout. | - | ||||||||||||||||||||||||
310 | - | |||||||||||||||||||||||||
311 | if (d->extra.isAllocated() && d->extra->nbActiveDownloads == 0) {
| 0-10 | ||||||||||||||||||||||||
312 | bool needToUpdateLayout = false; | - | ||||||||||||||||||||||||
313 | for (QQuickStyledTextImgTag *img : qAsConst(d->extra->visibleImgTags)) { | - | ||||||||||||||||||||||||
314 | if (!img->size.isValid()) {
| 2-8 | ||||||||||||||||||||||||
315 | img->size = img->pix->implicitSize(); | - | ||||||||||||||||||||||||
316 | needToUpdateLayout = true; | - | ||||||||||||||||||||||||
317 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
318 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
319 | - | |||||||||||||||||||||||||
320 | if (needToUpdateLayout) {
| 2-8 | ||||||||||||||||||||||||
321 | d->textHasChanged = true; | - | ||||||||||||||||||||||||
322 | d->updateLayout(); | - | ||||||||||||||||||||||||
323 | } else { executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
324 | d->updateType = QQuickTextPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
325 | update(); | - | ||||||||||||||||||||||||
326 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
327 | } | - | ||||||||||||||||||||||||
328 | } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | void QQuickTextPrivate::updateBaseline(qreal baseline, qreal dy) | - | ||||||||||||||||||||||||
331 | { | - | ||||||||||||||||||||||||
332 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | qreal yoff = 0; | - | ||||||||||||||||||||||||
335 | - | |||||||||||||||||||||||||
336 | if (q->heightValid()) {
| 3660-469367 | ||||||||||||||||||||||||
337 | if (vAlign == QQuickText::AlignBottom)
| 90-3570 | ||||||||||||||||||||||||
338 | yoff = dy; executed 90 times by 1 test: yoff = dy; Executed by:
| 90 | ||||||||||||||||||||||||
339 | else if (vAlign == QQuickText::AlignVCenter)
| 409-3161 | ||||||||||||||||||||||||
340 | yoff = dy/2; executed 409 times by 4 tests: yoff = dy/2; Executed by:
| 409 | ||||||||||||||||||||||||
341 | } executed 3660 times by 11 tests: end of block Executed by:
| 3660 | ||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||
343 | q->setBaselineOffset(baseline + yoff + q->topPadding()); | - | ||||||||||||||||||||||||
344 | } executed 473027 times by 35 tests: end of block Executed by:
| 473027 | ||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | void QQuickTextPrivate::updateSize() | - | ||||||||||||||||||||||||
347 | { | - | ||||||||||||||||||||||||
348 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
349 | - | |||||||||||||||||||||||||
350 | if (!q->isComponentComplete()) {
| 366-473027 | ||||||||||||||||||||||||
351 | updateOnComponentComplete = true; | - | ||||||||||||||||||||||||
352 | return; executed 366 times by 4 tests: return; Executed by:
| 366 | ||||||||||||||||||||||||
353 | } | - | ||||||||||||||||||||||||
354 | - | |||||||||||||||||||||||||
355 | if (!requireImplicitSize) {
| 526-472501 | ||||||||||||||||||||||||
356 | implicitWidthChanged(); | - | ||||||||||||||||||||||||
357 | implicitHeightChanged(); | - | ||||||||||||||||||||||||
358 | // if the implicitWidth is used, then updateSize() has already been called (recursively) | - | ||||||||||||||||||||||||
359 | if (requireImplicitSize)
| 0-472501 | ||||||||||||||||||||||||
360 | return; never executed: return; | 0 | ||||||||||||||||||||||||
361 | } executed 472501 times by 35 tests: end of block Executed by:
| 472501 | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | qreal hPadding = q->leftPadding() + q->rightPadding(); | - | ||||||||||||||||||||||||
364 | qreal vPadding = q->topPadding() + q->bottomPadding(); | - | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | if (text.isEmpty() && !isLineLaidOutConnected() && fontSizeMode() == QQuickText::FixedSize) {
| 8-424342 | ||||||||||||||||||||||||
367 | // How much more expensive is it to just do a full layout on an empty string here? | - | ||||||||||||||||||||||||
368 | // There may be subtle differences in the height and baseline calculations between | - | ||||||||||||||||||||||||
369 | // QTextLayout and QFontMetrics and the number of variables that can affect the size | - | ||||||||||||||||||||||||
370 | // and position of a line is increasing. | - | ||||||||||||||||||||||||
371 | QFontMetricsF fm(font); | - | ||||||||||||||||||||||||
372 | qreal fontHeight = qCeil(fm.height()); // QScriptLine and therefore QTextLine rounds up | - | ||||||||||||||||||||||||
373 | if (!richText) { // line height, so we will as well.
| 44-48625 | ||||||||||||||||||||||||
374 | fontHeight = lineHeightMode() == QQuickText::FixedHeight
| 16-48609 | ||||||||||||||||||||||||
375 | ? lineHeight() | - | ||||||||||||||||||||||||
376 | : fontHeight * lineHeight(); | - | ||||||||||||||||||||||||
377 | } executed 48625 times by 18 tests: end of block Executed by:
| 48625 | ||||||||||||||||||||||||
378 | updateBaseline(fm.ascent(), q->height() - fontHeight - vPadding); | - | ||||||||||||||||||||||||
379 | q->setImplicitSize(hPadding, fontHeight + vPadding); | - | ||||||||||||||||||||||||
380 | layedOutTextRect = QRectF(0, 0, 0, fontHeight); | - | ||||||||||||||||||||||||
381 | advance = QSizeF(); | - | ||||||||||||||||||||||||
382 | emit q->contentSizeChanged(); | - | ||||||||||||||||||||||||
383 | updateType = UpdatePaintNode; | - | ||||||||||||||||||||||||
384 | q->update(); | - | ||||||||||||||||||||||||
385 | return; executed 48669 times by 18 tests: return; Executed by:
| 48669 | ||||||||||||||||||||||||
386 | } | - | ||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | QSizeF size(0, 0); | - | ||||||||||||||||||||||||
389 | QSizeF previousSize = layedOutTextRect.size(); | - | ||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | //setup instance of QTextLayout for all cases other than richtext | - | ||||||||||||||||||||||||
392 | if (!richText) {
| 296-424062 | ||||||||||||||||||||||||
393 | qreal baseline = 0; | - | ||||||||||||||||||||||||
394 | QRectF textRect = setupTextLayout(&baseline); | - | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | if (internalWidthUpdate) // probably the result of a binding loop, but by letting it
| 0-424062 | ||||||||||||||||||||||||
397 | return; // get this far we'll get a warning to that effect if it is. never executed: return; | 0 | ||||||||||||||||||||||||
398 | - | |||||||||||||||||||||||||
399 | layedOutTextRect = textRect; | - | ||||||||||||||||||||||||
400 | size = textRect.size(); | - | ||||||||||||||||||||||||
401 | updateBaseline(baseline, q->height() - size.height() - vPadding); | - | ||||||||||||||||||||||||
402 | } else { executed 424062 times by 33 tests: end of block Executed by:
| 424062 | ||||||||||||||||||||||||
403 | widthExceeded = true; // always relayout rich text on width changes.. | - | ||||||||||||||||||||||||
404 | heightExceeded = false; // rich text layout isn't affected by height changes. | - | ||||||||||||||||||||||||
405 | ensureDoc(); | - | ||||||||||||||||||||||||
406 | extra->doc->setDefaultFont(font); | - | ||||||||||||||||||||||||
407 | QQuickText::HAlignment horizontalAlignment = q->effectiveHAlign(); | - | ||||||||||||||||||||||||
408 | if (rightToLeftText) {
| 56-240 | ||||||||||||||||||||||||
409 | if (horizontalAlignment == QQuickText::AlignLeft)
| 2-54 | ||||||||||||||||||||||||
410 | horizontalAlignment = QQuickText::AlignRight; executed 2 times by 1 test: horizontalAlignment = QQuickText::AlignRight; Executed by:
| 2 | ||||||||||||||||||||||||
411 | else if (horizontalAlignment == QQuickText::AlignRight)
| 0-54 | ||||||||||||||||||||||||
412 | horizontalAlignment = QQuickText::AlignLeft; executed 54 times by 2 tests: horizontalAlignment = QQuickText::AlignLeft; Executed by:
| 54 | ||||||||||||||||||||||||
413 | } executed 56 times by 2 tests: end of block Executed by:
| 56 | ||||||||||||||||||||||||
414 | QTextOption option; | - | ||||||||||||||||||||||||
415 | option.setAlignment((Qt::Alignment)int(horizontalAlignment | vAlign)); | - | ||||||||||||||||||||||||
416 | option.setWrapMode(QTextOption::WrapMode(wrapMode)); | - | ||||||||||||||||||||||||
417 | option.setUseDesignMetrics(renderType != QQuickText::NativeRendering); | - | ||||||||||||||||||||||||
418 | extra->doc->setDefaultTextOption(option); | - | ||||||||||||||||||||||||
419 | qreal naturalWidth = 0; | - | ||||||||||||||||||||||||
420 | if (requireImplicitSize && q->widthValid()) {
| 6-264 | ||||||||||||||||||||||||
421 | extra->doc->setTextWidth(-1); | - | ||||||||||||||||||||||||
422 | naturalWidth = extra->doc->idealWidth(); | - | ||||||||||||||||||||||||
423 | const bool wasInLayout = internalWidthUpdate; | - | ||||||||||||||||||||||||
424 | internalWidthUpdate = true; | - | ||||||||||||||||||||||||
425 | q->setImplicitWidth(naturalWidth + hPadding); | - | ||||||||||||||||||||||||
426 | internalWidthUpdate = wasInLayout; | - | ||||||||||||||||||||||||
427 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
428 | if (internalWidthUpdate)
| 0-296 | ||||||||||||||||||||||||
429 | return; never executed: return; | 0 | ||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||
431 | extra->doc->setPageSize(QSizeF()); | - | ||||||||||||||||||||||||
432 | if (q->widthValid() && (wrapMode != QQuickText::NoWrap || extra->doc->idealWidth() < availableWidth()))
| 14-186 | ||||||||||||||||||||||||
433 | extra->doc->setTextWidth(availableWidth()); executed 172 times by 2 tests: extra->doc->setTextWidth(availableWidth()); Executed by:
| 172 | ||||||||||||||||||||||||
434 | else | - | ||||||||||||||||||||||||
435 | extra->doc->setTextWidth(extra->doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) executed 124 times by 2 tests: extra->doc->setTextWidth(extra->doc->idealWidth()); Executed by:
| 124 | ||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | QSizeF dsize = extra->doc->size(); | - | ||||||||||||||||||||||||
438 | layedOutTextRect = QRectF(QPointF(0,0), dsize); | - | ||||||||||||||||||||||||
439 | size = QSizeF(extra->doc->idealWidth(),dsize.height()); | - | ||||||||||||||||||||||||
440 | - | |||||||||||||||||||||||||
441 | QFontMetricsF fm(font); | - | ||||||||||||||||||||||||
442 | updateBaseline(fm.ascent(), q->height() - size.height() - vPadding); | - | ||||||||||||||||||||||||
443 | - | |||||||||||||||||||||||||
444 | //### need to confirm cost of always setting these for richText | - | ||||||||||||||||||||||||
445 | internalWidthUpdate = true; | - | ||||||||||||||||||||||||
446 | qreal oldWidth = q->width(); | - | ||||||||||||||||||||||||
447 | qreal iWidth = -1; | - | ||||||||||||||||||||||||
448 | if (!q->widthValid())
| 110-186 | ||||||||||||||||||||||||
449 | iWidth = size.width(); executed 110 times by 2 tests: iWidth = size.width(); Executed by:
| 110 | ||||||||||||||||||||||||
450 | if (iWidth > -1)
| 110-186 | ||||||||||||||||||||||||
451 | q->setImplicitSize(iWidth + hPadding, size.height() + vPadding); executed 110 times by 2 tests: q->setImplicitSize(iWidth + hPadding, size.height() + vPadding); Executed by:
| 110 | ||||||||||||||||||||||||
452 | internalWidthUpdate = false; | - | ||||||||||||||||||||||||
453 | - | |||||||||||||||||||||||||
454 | // If the implicit width update caused a recursive change of the width, | - | ||||||||||||||||||||||||
455 | // we will have skipped integral parts of the layout due to the | - | ||||||||||||||||||||||||
456 | // internalWidthUpdate recursion guard. To make sure everything is up | - | ||||||||||||||||||||||||
457 | // to date, we need to run a second pass over the layout when updateSize() | - | ||||||||||||||||||||||||
458 | // is done. | - | ||||||||||||||||||||||||
459 | if (!qFuzzyCompare(q->width(), oldWidth) && !updateSizeRecursionGuard) {
| 0-242 | ||||||||||||||||||||||||
460 | updateSizeRecursionGuard = true; | - | ||||||||||||||||||||||||
461 | updateSize(); | - | ||||||||||||||||||||||||
462 | updateSizeRecursionGuard = false; | - | ||||||||||||||||||||||||
463 | } else { executed 54 times by 2 tests: end of block Executed by:
| 54 | ||||||||||||||||||||||||
464 | if (iWidth == -1)
| 56-186 | ||||||||||||||||||||||||
465 | q->setImplicitHeight(size.height() + vPadding); executed 186 times by 2 tests: q->setImplicitHeight(size.height() + vPadding); Executed by:
| 186 | ||||||||||||||||||||||||
466 | - | |||||||||||||||||||||||||
467 | QTextBlock firstBlock = extra->doc->firstBlock(); | - | ||||||||||||||||||||||||
468 | while (firstBlock.layout()->lineCount() == 0)
| 0-242 | ||||||||||||||||||||||||
469 | firstBlock = firstBlock.next(); never executed: firstBlock = firstBlock.next(); | 0 | ||||||||||||||||||||||||
470 | - | |||||||||||||||||||||||||
471 | QTextBlock lastBlock = extra->doc->lastBlock(); | - | ||||||||||||||||||||||||
472 | while (lastBlock.layout()->lineCount() == 0)
| 0-242 | ||||||||||||||||||||||||
473 | lastBlock = lastBlock.previous(); never executed: lastBlock = lastBlock.previous(); | 0 | ||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||
475 | if (firstBlock.lineCount() > 0 && lastBlock.lineCount() > 0) {
| 0-242 | ||||||||||||||||||||||||
476 | QTextLine firstLine = firstBlock.layout()->lineAt(0); | - | ||||||||||||||||||||||||
477 | QTextLine lastLine = lastBlock.layout()->lineAt(lastBlock.layout()->lineCount() - 1); | - | ||||||||||||||||||||||||
478 | advance = QSizeF(lastLine.horizontalAdvance(), | - | ||||||||||||||||||||||||
479 | (lastLine.y() + lastBlock.layout()->position().y()) - (firstLine.y() + firstBlock.layout()->position().y())); | - | ||||||||||||||||||||||||
480 | } else { executed 242 times by 2 tests: end of block Executed by:
| 242 | ||||||||||||||||||||||||
481 | advance = QSizeF(); | - | ||||||||||||||||||||||||
482 | } never executed: end of block | 0 | ||||||||||||||||||||||||
483 | } | - | ||||||||||||||||||||||||
484 | } | - | ||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | if (layedOutTextRect.size() != previousSize)
| 72195-352163 | ||||||||||||||||||||||||
488 | emit q->contentSizeChanged(); executed 352163 times by 33 tests: q->contentSizeChanged(); Executed by:
| 352163 | ||||||||||||||||||||||||
489 | updateType = UpdatePaintNode; | - | ||||||||||||||||||||||||
490 | q->update(); | - | ||||||||||||||||||||||||
491 | } executed 424358 times by 33 tests: end of block Executed by:
| 424358 | ||||||||||||||||||||||||
492 | - | |||||||||||||||||||||||||
493 | QQuickTextLine::QQuickTextLine() | - | ||||||||||||||||||||||||
494 | : QObject(), m_line(nullptr), m_height(0), m_lineOffset(0) | - | ||||||||||||||||||||||||
495 | { | - | ||||||||||||||||||||||||
496 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
497 | - | |||||||||||||||||||||||||
498 | void QQuickTextLine::setLine(QTextLine *line) | - | ||||||||||||||||||||||||
499 | { | - | ||||||||||||||||||||||||
500 | m_line = line; | - | ||||||||||||||||||||||||
501 | } executed 336 times by 1 test: end of block Executed by:
| 336 | ||||||||||||||||||||||||
502 | - | |||||||||||||||||||||||||
503 | void QQuickTextLine::setLineOffset(int offset) | - | ||||||||||||||||||||||||
504 | { | - | ||||||||||||||||||||||||
505 | m_lineOffset = offset; | - | ||||||||||||||||||||||||
506 | } executed 336 times by 1 test: end of block Executed by:
| 336 | ||||||||||||||||||||||||
507 | - | |||||||||||||||||||||||||
508 | int QQuickTextLine::number() const | - | ||||||||||||||||||||||||
509 | { | - | ||||||||||||||||||||||||
510 | if (m_line)
| 0-448 | ||||||||||||||||||||||||
511 | return m_line->lineNumber() + m_lineOffset; executed 448 times by 1 test: return m_line->lineNumber() + m_lineOffset; Executed by:
| 448 | ||||||||||||||||||||||||
512 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
513 | } | - | ||||||||||||||||||||||||
514 | - | |||||||||||||||||||||||||
515 | qreal QQuickTextLine::width() const | - | ||||||||||||||||||||||||
516 | { | - | ||||||||||||||||||||||||
517 | if (m_line)
| 0-30 | ||||||||||||||||||||||||
518 | return m_line->width(); executed 30 times by 1 test: return m_line->width(); Executed by:
| 30 | ||||||||||||||||||||||||
519 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
520 | } | - | ||||||||||||||||||||||||
521 | - | |||||||||||||||||||||||||
522 | void QQuickTextLine::setWidth(qreal width) | - | ||||||||||||||||||||||||
523 | { | - | ||||||||||||||||||||||||
524 | if (m_line)
| 0-646 | ||||||||||||||||||||||||
525 | m_line->setLineWidth(width); executed 646 times by 1 test: m_line->setLineWidth(width); Executed by:
| 646 | ||||||||||||||||||||||||
526 | } executed 646 times by 1 test: end of block Executed by:
| 646 | ||||||||||||||||||||||||
527 | - | |||||||||||||||||||||||||
528 | qreal QQuickTextLine::height() const | - | ||||||||||||||||||||||||
529 | { | - | ||||||||||||||||||||||||
530 | if (m_height)
| 0-556 | ||||||||||||||||||||||||
531 | return m_height; never executed: return m_height; | 0 | ||||||||||||||||||||||||
532 | if (m_line)
| 0-556 | ||||||||||||||||||||||||
533 | return m_line->height(); executed 556 times by 1 test: return m_line->height(); Executed by:
| 556 | ||||||||||||||||||||||||
534 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
535 | } | - | ||||||||||||||||||||||||
536 | - | |||||||||||||||||||||||||
537 | void QQuickTextLine::setHeight(qreal height) | - | ||||||||||||||||||||||||
538 | { | - | ||||||||||||||||||||||||
539 | if (m_line)
| 0-336 | ||||||||||||||||||||||||
540 | m_line->setPosition(QPointF(m_line->x(), m_line->y() - m_line->height() + height)); executed 336 times by 1 test: m_line->setPosition(QPointF(m_line->x(), m_line->y() - m_line->height() + height)); Executed by:
| 336 | ||||||||||||||||||||||||
541 | m_height = height; | - | ||||||||||||||||||||||||
542 | } executed 336 times by 1 test: end of block Executed by:
| 336 | ||||||||||||||||||||||||
543 | - | |||||||||||||||||||||||||
544 | qreal QQuickTextLine::x() const | - | ||||||||||||||||||||||||
545 | { | - | ||||||||||||||||||||||||
546 | if (m_line)
| 0 | ||||||||||||||||||||||||
547 | return m_line->x(); never executed: return m_line->x(); | 0 | ||||||||||||||||||||||||
548 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
549 | } | - | ||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||
551 | void QQuickTextLine::setX(qreal x) | - | ||||||||||||||||||||||||
552 | { | - | ||||||||||||||||||||||||
553 | if (m_line)
| 0-214 | ||||||||||||||||||||||||
554 | m_line->setPosition(QPointF(x, m_line->y())); executed 214 times by 1 test: m_line->setPosition(QPointF(x, m_line->y())); Executed by:
| 214 | ||||||||||||||||||||||||
555 | } executed 214 times by 1 test: end of block Executed by:
| 214 | ||||||||||||||||||||||||
556 | - | |||||||||||||||||||||||||
557 | qreal QQuickTextLine::y() const | - | ||||||||||||||||||||||||
558 | { | - | ||||||||||||||||||||||||
559 | if (m_line)
| 0-466 | ||||||||||||||||||||||||
560 | return m_line->y(); executed 466 times by 1 test: return m_line->y(); Executed by:
| 466 | ||||||||||||||||||||||||
561 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
562 | } | - | ||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | void QQuickTextLine::setY(qreal y) | - | ||||||||||||||||||||||||
565 | { | - | ||||||||||||||||||||||||
566 | if (m_line)
| 0-574 | ||||||||||||||||||||||||
567 | m_line->setPosition(QPointF(m_line->x(), y)); executed 574 times by 1 test: m_line->setPosition(QPointF(m_line->x(), y)); Executed by:
| 574 | ||||||||||||||||||||||||
568 | } executed 574 times by 1 test: end of block Executed by:
| 574 | ||||||||||||||||||||||||
569 | - | |||||||||||||||||||||||||
570 | bool QQuickTextPrivate::isLineLaidOutConnected() | - | ||||||||||||||||||||||||
571 | { | - | ||||||||||||||||||||||||
572 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
573 | IS_SIGNAL_CONNECTED(q, QQuickText, lineLaidOut, (QQuickTextLine *)); executed 473487 times by 35 tests: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); Executed by:
| 473487 | ||||||||||||||||||||||||
574 | } | - | ||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height, int lineOffset) | - | ||||||||||||||||||||||||
577 | { | - | ||||||||||||||||||||||||
578 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
579 | - | |||||||||||||||||||||||||
580 | if (!textLine)
| 10-326 | ||||||||||||||||||||||||
581 | textLine = new QQuickTextLine; executed 10 times by 1 test: textLine = new QQuickTextLine; Executed by:
| 10 | ||||||||||||||||||||||||
582 | textLine->setLine(&line); | - | ||||||||||||||||||||||||
583 | textLine->setY(height); | - | ||||||||||||||||||||||||
584 | textLine->setHeight(0); | - | ||||||||||||||||||||||||
585 | textLine->setLineOffset(lineOffset); | - | ||||||||||||||||||||||||
586 | - | |||||||||||||||||||||||||
587 | // use the text item's width by default if it has one and wrap is on or text must be aligned | - | ||||||||||||||||||||||||
588 | if (q->widthValid() && (q->wrapMode() != QQuickText::NoWrap ||
| 2-222 | ||||||||||||||||||||||||
589 | q->effectiveHAlign() != QQuickText::AlignLeft))
| 0-2 | ||||||||||||||||||||||||
590 | textLine->setWidth(availableWidth()); executed 222 times by 1 test: textLine->setWidth(availableWidth()); Executed by:
| 222 | ||||||||||||||||||||||||
591 | else | - | ||||||||||||||||||||||||
592 | textLine->setWidth(INT_MAX); executed 114 times by 1 test: textLine->setWidth(0x7fffffff); Executed by:
| 114 | ||||||||||||||||||||||||
593 | if (lineHeight() != 1.0)
| 0-336 | ||||||||||||||||||||||||
594 | textLine->setHeight((lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight()); never executed: textLine->setHeight((lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight()); | 0 | ||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||
596 | emit q->lineLaidOut(textLine); | - | ||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||
598 | height += textLine->height(); | - | ||||||||||||||||||||||||
599 | } executed 336 times by 1 test: end of block Executed by:
| 336 | ||||||||||||||||||||||||
600 | - | |||||||||||||||||||||||||
601 | void QQuickTextPrivate::elideFormats( | - | ||||||||||||||||||||||||
602 | const int start, const int length, int offset, QVector<QTextLayout::FormatRange> *elidedFormats) | - | ||||||||||||||||||||||||
603 | { | - | ||||||||||||||||||||||||
604 | const int end = start + length; | - | ||||||||||||||||||||||||
605 | const QVector<QTextLayout::FormatRange> formats = layout.formats(); | - | ||||||||||||||||||||||||
606 | for (int i = 0; i < formats.count(); ++i) {
| 28-76 | ||||||||||||||||||||||||
607 | QTextLayout::FormatRange format = formats.at(i); | - | ||||||||||||||||||||||||
608 | const int formatLength = qMin(format.start + format.length, end) - qMax(format.start, start); | - | ||||||||||||||||||||||||
609 | if (formatLength > 0) {
| 36-40 | ||||||||||||||||||||||||
610 | format.start = qMax(offset, format.start - start + offset); | - | ||||||||||||||||||||||||
611 | format.length = formatLength; | - | ||||||||||||||||||||||||
612 | elidedFormats->append(format); | - | ||||||||||||||||||||||||
613 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
614 | } executed 76 times by 1 test: end of block Executed by:
| 76 | ||||||||||||||||||||||||
615 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||||||||
616 | - | |||||||||||||||||||||||||
617 | QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine) const | - | ||||||||||||||||||||||||
618 | { | - | ||||||||||||||||||||||||
619 | if (nextLine) {
| 124-226 | ||||||||||||||||||||||||
620 | return layout.engine()->elidedText( executed 226 times by 1 test: return layout.engine()->elidedText( Qt::TextElideMode(elideMode), QFixed::fromReal(lineWidth), 0, line.textStart(), line.textLength() + nextLine->textLength()); Executed by:
| 226 | ||||||||||||||||||||||||
621 | Qt::TextElideMode(elideMode), executed 226 times by 1 test: return layout.engine()->elidedText( Qt::TextElideMode(elideMode), QFixed::fromReal(lineWidth), 0, line.textStart(), line.textLength() + nextLine->textLength()); Executed by:
| 226 | ||||||||||||||||||||||||
622 | QFixed::fromReal(lineWidth), executed 226 times by 1 test: return layout.engine()->elidedText( Qt::TextElideMode(elideMode), QFixed::fromReal(lineWidth), 0, line.textStart(), line.textLength() + nextLine->textLength()); Executed by:
| 226 | ||||||||||||||||||||||||
623 | 0, executed 226 times by 1 test: return layout.engine()->elidedText( Qt::TextElideMode(elideMode), QFixed::fromReal(lineWidth), 0, line.textStart(), line.textLength() + nextLine->textLength()); Executed by:
| 226 | ||||||||||||||||||||||||
624 | line.textStart(), executed 226 times by 1 test: return layout.engine()->elidedText( Qt::TextElideMode(elideMode), QFixed::fromReal(lineWidth), 0, line.textStart(), line.textLength() + nextLine->textLength()); Executed by:
| 226 | ||||||||||||||||||||||||
625 | line.textLength() + nextLine->textLength()); executed 226 times by 1 test: return layout.engine()->elidedText( Qt::TextElideMode(elideMode), QFixed::fromReal(lineWidth), 0, line.textStart(), line.textLength() + nextLine->textLength()); Executed by:
| 226 | ||||||||||||||||||||||||
626 | } else { | - | ||||||||||||||||||||||||
627 | QString elideText = layout.text().mid(line.textStart(), line.textLength()); | - | ||||||||||||||||||||||||
628 | if (!styledText) {
| 54-70 | ||||||||||||||||||||||||
629 | // QFontMetrics won't help eliding styled text. | - | ||||||||||||||||||||||||
630 | elideText[elideText.length() - 1] = elideChar; | - | ||||||||||||||||||||||||
631 | // Appending the elide character may push the line over the maximum width | - | ||||||||||||||||||||||||
632 | // in which case the elided text will need to be elided. | - | ||||||||||||||||||||||||
633 | QFontMetricsF metrics(layout.font()); | - | ||||||||||||||||||||||||
634 | if (metrics.width(elideChar) + line.naturalTextWidth() >= lineWidth)
| 18-52 | ||||||||||||||||||||||||
635 | elideText = metrics.elidedText(elideText, Qt::TextElideMode(elideMode), lineWidth); executed 52 times by 1 test: elideText = metrics.elidedText(elideText, Qt::TextElideMode(elideMode), lineWidth); Executed by:
| 52 | ||||||||||||||||||||||||
636 | } executed 70 times by 1 test: end of block Executed by:
| 70 | ||||||||||||||||||||||||
637 | return elideText; executed 124 times by 1 test: return elideText; Executed by:
| 124 | ||||||||||||||||||||||||
638 | } | - | ||||||||||||||||||||||||
639 | } | - | ||||||||||||||||||||||||
640 | - | |||||||||||||||||||||||||
641 | void QQuickTextPrivate::clearFormats() | - | ||||||||||||||||||||||||
642 | { | - | ||||||||||||||||||||||||
643 | layout.clearFormats(); | - | ||||||||||||||||||||||||
644 | if (elideLayout)
| 22-205041 | ||||||||||||||||||||||||
645 | elideLayout->clearFormats(); executed 22 times by 1 test: elideLayout->clearFormats(); Executed by:
| 22 | ||||||||||||||||||||||||
646 | } executed 205063 times by 18 tests: end of block Executed by:
| 205063 | ||||||||||||||||||||||||
647 | - | |||||||||||||||||||||||||
648 | /*! | - | ||||||||||||||||||||||||
649 | Lays out the QQuickTextPrivate::layout QTextLayout in the constraints of the QQuickText. | - | ||||||||||||||||||||||||
650 | - | |||||||||||||||||||||||||
651 | Returns the size of the final text. This can be used to position the text vertically (the text is | - | ||||||||||||||||||||||||
652 | already absolutely positioned horizontally). | - | ||||||||||||||||||||||||
653 | */ | - | ||||||||||||||||||||||||
654 | - | |||||||||||||||||||||||||
655 | QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) | - | ||||||||||||||||||||||||
656 | { | - | ||||||||||||||||||||||||
657 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
658 | - | |||||||||||||||||||||||||
659 | bool singlelineElide = elideMode != QQuickText::ElideNone && q->widthValid();
| 30-423704 | ||||||||||||||||||||||||
660 | bool multilineElide = elideMode == QQuickText::ElideRight
| 292-423770 | ||||||||||||||||||||||||
661 | && q->widthValid()
| 30-262 | ||||||||||||||||||||||||
662 | && (q->heightValid() || maximumLineCountValid);
| 22-198 | ||||||||||||||||||||||||
663 | - | |||||||||||||||||||||||||
664 | if ((!requireImplicitSize || (implicitWidthValid && implicitHeightValid))
| 2-423582 | ||||||||||||||||||||||||
665 | && ((singlelineElide && availableWidth() <= 0.)
| 6-423440 | ||||||||||||||||||||||||
666 | || (multilineElide && q->heightValid() && availableHeight() <= 0.))) {
| 8-423532 | ||||||||||||||||||||||||
667 | // we are elided and we have a zero width or height | - | ||||||||||||||||||||||||
668 | widthExceeded = q->widthValid() && availableWidth() <= 0.;
| 0-14 | ||||||||||||||||||||||||
669 | heightExceeded = q->heightValid() && availableHeight() <= 0.;
| 2-12 | ||||||||||||||||||||||||
670 | - | |||||||||||||||||||||||||
671 | if (!truncated) {
| 4-10 | ||||||||||||||||||||||||
672 | truncated = true; | - | ||||||||||||||||||||||||
673 | emit q->truncatedChanged(); | - | ||||||||||||||||||||||||
674 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
675 | if (lineCount) {
| 4-10 | ||||||||||||||||||||||||
676 | lineCount = 0; | - | ||||||||||||||||||||||||
677 | emit q->lineCountChanged(); | - | ||||||||||||||||||||||||
678 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
679 | - | |||||||||||||||||||||||||
680 | if (qFuzzyIsNull(q->width())) {
| 4-10 | ||||||||||||||||||||||||
681 | layout.setText(QString()); | - | ||||||||||||||||||||||||
682 | textHasChanged = true; | - | ||||||||||||||||||||||||
683 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
684 | - | |||||||||||||||||||||||||
685 | QFontMetricsF fm(font); | - | ||||||||||||||||||||||||
686 | qreal height = (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : qCeil(fm.height()) * lineHeight();
| 0-14 | ||||||||||||||||||||||||
687 | *baseline = fm.ascent(); | - | ||||||||||||||||||||||||
688 | return QRectF(0, 0, 0, height); executed 14 times by 1 test: return QRectF(0, 0, 0, height); Executed by:
| 14 | ||||||||||||||||||||||||
689 | } | - | ||||||||||||||||||||||||
690 | - | |||||||||||||||||||||||||
691 | bool shouldUseDesignMetrics = renderType != QQuickText::NativeRendering; | - | ||||||||||||||||||||||||
692 | if (extra.isAllocated())
| 670-423378 | ||||||||||||||||||||||||
693 | extra->visibleImgTags.clear(); executed 670 times by 2 tests: extra->visibleImgTags.clear(); Executed by:
| 670 | ||||||||||||||||||||||||
694 | layout.setCacheEnabled(true); | - | ||||||||||||||||||||||||
695 | QTextOption textOption = layout.textOption(); | - | ||||||||||||||||||||||||
696 | if (textOption.alignment() != q->effectiveHAlign()
| 479-423569 | ||||||||||||||||||||||||
697 | || textOption.wrapMode() != QTextOption::WrapMode(wrapMode)
| 207391-216178 | ||||||||||||||||||||||||
698 | || textOption.useDesignMetrics() != shouldUseDesignMetrics) {
| 84-207307 | ||||||||||||||||||||||||
699 | textOption.setAlignment(Qt::Alignment(q->effectiveHAlign())); | - | ||||||||||||||||||||||||
700 | textOption.setWrapMode(QTextOption::WrapMode(wrapMode)); | - | ||||||||||||||||||||||||
701 | textOption.setUseDesignMetrics(shouldUseDesignMetrics); | - | ||||||||||||||||||||||||
702 | layout.setTextOption(textOption); | - | ||||||||||||||||||||||||
703 | } executed 216741 times by 33 tests: end of block Executed by:
| 216741 | ||||||||||||||||||||||||
704 | if (layout.font() != font)
| 38097-385951 | ||||||||||||||||||||||||
705 | layout.setFont(font); executed 38097 times by 13 tests: layout.setFont(font); Executed by:
| 38097 | ||||||||||||||||||||||||
706 | - | |||||||||||||||||||||||||
707 | lineWidth = (q->widthValid() || implicitWidthValid) && q->width() > 0
| 78-420702 | ||||||||||||||||||||||||
708 | ? q->width() | - | ||||||||||||||||||||||||
709 | : FLT_MAX; | - | ||||||||||||||||||||||||
710 | qreal maxHeight = q->heightValid() ? availableHeight() : FLT_MAX;
| 3452-420596 | ||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||
712 | const bool customLayout = isLineLaidOutConnected(); | - | ||||||||||||||||||||||||
713 | const bool wasTruncated = truncated; | - | ||||||||||||||||||||||||
714 | - | |||||||||||||||||||||||||
715 | bool canWrap = wrapMode != QQuickText::NoWrap && q->widthValid();
| 24-423402 | ||||||||||||||||||||||||
716 | - | |||||||||||||||||||||||||
717 | bool horizontalFit = fontSizeMode() & QQuickText::HorizontalFit && q->widthValid();
| 0-423850 | ||||||||||||||||||||||||
718 | bool verticalFit = fontSizeMode() & QQuickText::VerticalFit
| 178-423870 | ||||||||||||||||||||||||
719 | && (q->heightValid() || (maximumLineCountValid && canWrap));
| 0-178 | ||||||||||||||||||||||||
720 | - | |||||||||||||||||||||||||
721 | const bool pixelSize = font.pixelSize() != -1; | - | ||||||||||||||||||||||||
722 | QString layoutText = layout.text(); | - | ||||||||||||||||||||||||
723 | - | |||||||||||||||||||||||||
724 | int largeFont = pixelSize ? font.pixelSize() : font.pointSize();
| 92078-331970 | ||||||||||||||||||||||||
725 | int smallFont = fontSizeMode() != QQuickText::FixedSize
| 286-423762 | ||||||||||||||||||||||||
726 | ? qMin(pixelSize ? minimumPixelSize() : minimumPointSize(), largeFont) | - | ||||||||||||||||||||||||
727 | : largeFont; | - | ||||||||||||||||||||||||
728 | int scaledFontSize = largeFont; | - | ||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||
730 | bool widthChanged = false; | - | ||||||||||||||||||||||||
731 | widthExceeded = availableWidth() <= 0 && (singlelineElide || canWrap || horizontalFit);
| 0-215258 | ||||||||||||||||||||||||
732 | heightExceeded = availableHeight() <= 0 && (multilineElide || verticalFit);
| 0-214642 | ||||||||||||||||||||||||
733 | - | |||||||||||||||||||||||||
734 | QRectF br; | - | ||||||||||||||||||||||||
735 | - | |||||||||||||||||||||||||
736 | QFont scaledFont = font; | - | ||||||||||||||||||||||||
737 | - | |||||||||||||||||||||||||
738 | int visibleCount = 0; | - | ||||||||||||||||||||||||
739 | bool elide; | - | ||||||||||||||||||||||||
740 | qreal height = 0; | - | ||||||||||||||||||||||||
741 | QString elideText; | - | ||||||||||||||||||||||||
742 | bool once = true; | - | ||||||||||||||||||||||||
743 | int elideStart = 0; | - | ||||||||||||||||||||||||
744 | int elideEnd = 0; | - | ||||||||||||||||||||||||
745 | - | |||||||||||||||||||||||||
746 | int eos = multilengthEos; | - | ||||||||||||||||||||||||
747 | - | |||||||||||||||||||||||||
748 | // Repeated layouts with reduced font sizes or abbreviated strings may be required if the text | - | ||||||||||||||||||||||||
749 | // doesn't fit within the item dimensions, or a binding to implicitWidth/Height changes | - | ||||||||||||||||||||||||
750 | // the item dimensions. | - | ||||||||||||||||||||||||
751 | for (;;) { | - | ||||||||||||||||||||||||
752 | if (!once) {
| 1992-424048 | ||||||||||||||||||||||||
753 | if (pixelSize)
| 208-1784 | ||||||||||||||||||||||||
754 | scaledFont.setPixelSize(scaledFontSize); executed 1784 times by 2 tests: scaledFont.setPixelSize(scaledFontSize); Executed by:
| 1784 | ||||||||||||||||||||||||
755 | else | - | ||||||||||||||||||||||||
756 | scaledFont.setPointSize(scaledFontSize); executed 208 times by 3 tests: scaledFont.setPointSize(scaledFontSize); Executed by:
| 208 | ||||||||||||||||||||||||
757 | if (layout.font() != scaledFont)
| 168-1824 | ||||||||||||||||||||||||
758 | layout.setFont(scaledFont); executed 1824 times by 1 test: layout.setFont(scaledFont); Executed by:
| 1824 | ||||||||||||||||||||||||
759 | } executed 1992 times by 3 tests: end of block Executed by:
| 1992 | ||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||
761 | layout.beginLayout(); | - | ||||||||||||||||||||||||
762 | - | |||||||||||||||||||||||||
763 | bool wrapped = false; | - | ||||||||||||||||||||||||
764 | bool truncateHeight = false; | - | ||||||||||||||||||||||||
765 | truncated = false; | - | ||||||||||||||||||||||||
766 | elide = false; | - | ||||||||||||||||||||||||
767 | int unwrappedLineCount = 1; | - | ||||||||||||||||||||||||
768 | int maxLineCount = maximumLineCount(); | - | ||||||||||||||||||||||||
769 | height = 0; | - | ||||||||||||||||||||||||
770 | qreal naturalHeight = 0; | - | ||||||||||||||||||||||||
771 | qreal previousHeight = 0; | - | ||||||||||||||||||||||||
772 | br = QRectF(); | - | ||||||||||||||||||||||||
773 | - | |||||||||||||||||||||||||
774 | QRectF unelidedRect; | - | ||||||||||||||||||||||||
775 | QTextLine line = layout.createLine(); | - | ||||||||||||||||||||||||
776 | for (visibleCount = 1; ; ++visibleCount) { | - | ||||||||||||||||||||||||
777 | if (customLayout) {
| 336-432692 | ||||||||||||||||||||||||
778 | setupCustomLineGeometry(line, naturalHeight); | - | ||||||||||||||||||||||||
779 | } else { executed 336 times by 1 test: end of block Executed by:
| 336 | ||||||||||||||||||||||||
780 | setLineGeometry(line, lineWidth, naturalHeight); | - | ||||||||||||||||||||||||
781 | } executed 432692 times by 33 tests: end of block Executed by:
| 432692 | ||||||||||||||||||||||||
782 | - | |||||||||||||||||||||||||
783 | unelidedRect = br.united(line.naturalTextRect()); | - | ||||||||||||||||||||||||
784 | - | |||||||||||||||||||||||||
785 | // Elide the previous line if the accumulated height of the text exceeds the height | - | ||||||||||||||||||||||||
786 | // of the element. | - | ||||||||||||||||||||||||
787 | if (multilineElide && naturalHeight > maxHeight && visibleCount > 1) {
| 168-431648 | ||||||||||||||||||||||||
788 | elide = true; | - | ||||||||||||||||||||||||
789 | heightExceeded = true; | - | ||||||||||||||||||||||||
790 | if (eos != -1) // There's an abbreviated string available, skip the rest as it's
| 10-332 | ||||||||||||||||||||||||
791 | break; // all going to be discarded. executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
792 | - | |||||||||||||||||||||||||
793 | truncated = true; | - | ||||||||||||||||||||||||
794 | truncateHeight = true; | - | ||||||||||||||||||||||||
795 | - | |||||||||||||||||||||||||
796 | visibleCount -= 1; | - | ||||||||||||||||||||||||
797 | - | |||||||||||||||||||||||||
798 | QTextLine previousLine = layout.lineAt(visibleCount - 1); | - | ||||||||||||||||||||||||
799 | elideText = layoutText.at(line.textStart() - 1) != QChar::LineSeparator
| 124-208 | ||||||||||||||||||||||||
800 | ? elidedText(line.width(), previousLine, &line) | - | ||||||||||||||||||||||||
801 | : elidedText(line.width(), previousLine); | - | ||||||||||||||||||||||||
802 | elideStart = previousLine.textStart(); | - | ||||||||||||||||||||||||
803 | // elideEnd isn't required for right eliding. | - | ||||||||||||||||||||||||
804 | - | |||||||||||||||||||||||||
805 | height = previousHeight; | - | ||||||||||||||||||||||||
806 | break; executed 332 times by 1 test: break; Executed by:
| 332 | ||||||||||||||||||||||||
807 | } | - | ||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||
809 | const QTextLine previousLine = line; | - | ||||||||||||||||||||||||
810 | line = layout.createLine(); | - | ||||||||||||||||||||||||
811 | if (!line.isValid()) {
| 7170-425516 | ||||||||||||||||||||||||
812 | if (singlelineElide && visibleCount == 1 && previousLine.naturalTextWidth() > previousLine.width()) {
| 170-424722 | ||||||||||||||||||||||||
813 | // Elide a single previousLine of text if its width exceeds the element width. | - | ||||||||||||||||||||||||
814 | elide = true; | - | ||||||||||||||||||||||||
815 | widthExceeded = true; | - | ||||||||||||||||||||||||
816 | if (eos != -1) // There's an abbreviated string available.
| 10-290 | ||||||||||||||||||||||||
817 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
818 | - | |||||||||||||||||||||||||
819 | truncated = true; | - | ||||||||||||||||||||||||
820 | elideText = layout.engine()->elidedText( | - | ||||||||||||||||||||||||
821 | Qt::TextElideMode(elideMode), | - | ||||||||||||||||||||||||
822 | QFixed::fromReal(previousLine.width()), | - | ||||||||||||||||||||||||
823 | 0, | - | ||||||||||||||||||||||||
824 | previousLine.textStart(), | - | ||||||||||||||||||||||||
825 | previousLine.textLength()); | - | ||||||||||||||||||||||||
826 | elideStart = previousLine.textStart(); | - | ||||||||||||||||||||||||
827 | elideEnd = elideStart + previousLine.textLength(); | - | ||||||||||||||||||||||||
828 | } else { executed 290 times by 1 test: end of block Executed by:
| 290 | ||||||||||||||||||||||||
829 | br = unelidedRect; | - | ||||||||||||||||||||||||
830 | height = naturalHeight; | - | ||||||||||||||||||||||||
831 | } executed 425216 times by 33 tests: end of block Executed by:
| 425216 | ||||||||||||||||||||||||
832 | break; executed 425506 times by 33 tests: break; Executed by:
| 425506 | ||||||||||||||||||||||||
833 | } else { | - | ||||||||||||||||||||||||
834 | const bool wrappedLine = layoutText.at(line.textStart() - 1) != QChar::LineSeparator; | - | ||||||||||||||||||||||||
835 | wrapped |= wrappedLine; | - | ||||||||||||||||||||||||
836 | - | |||||||||||||||||||||||||
837 | if (!wrappedLine)
| 3106-4064 | ||||||||||||||||||||||||
838 | ++unwrappedLineCount; executed 4064 times by 5 tests: ++unwrappedLineCount; Executed by:
| 4064 | ||||||||||||||||||||||||
839 | - | |||||||||||||||||||||||||
840 | // Stop if the maximum number of lines has been reached and elide the last line | - | ||||||||||||||||||||||||
841 | // if enabled. | - | ||||||||||||||||||||||||
842 | if (visibleCount == maxLineCount) {
| 182-6988 | ||||||||||||||||||||||||
843 | truncated = true; | - | ||||||||||||||||||||||||
844 | heightExceeded |= wrapped; | - | ||||||||||||||||||||||||
845 | - | |||||||||||||||||||||||||
846 | if (multilineElide) {
| 18-164 | ||||||||||||||||||||||||
847 | elide = true; | - | ||||||||||||||||||||||||
848 | if (eos != -1) // There's an abbreviated string available
| 0-18 | ||||||||||||||||||||||||
849 | break; never executed: break; | 0 | ||||||||||||||||||||||||
850 | elideText = wrappedLine
| 0-18 | ||||||||||||||||||||||||
851 | ? elidedText(previousLine.width(), previousLine, &line) | - | ||||||||||||||||||||||||
852 | : elidedText(previousLine.width(), previousLine); | - | ||||||||||||||||||||||||
853 | elideStart = previousLine.textStart(); | - | ||||||||||||||||||||||||
854 | // elideEnd isn't required for right eliding. | - | ||||||||||||||||||||||||
855 | } else { executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
856 | br = unelidedRect; | - | ||||||||||||||||||||||||
857 | height = naturalHeight; | - | ||||||||||||||||||||||||
858 | } executed 164 times by 1 test: end of block Executed by:
| 164 | ||||||||||||||||||||||||
859 | break; executed 182 times by 1 test: break; Executed by:
| 182 | ||||||||||||||||||||||||
860 | } | - | ||||||||||||||||||||||||
861 | } executed 6988 times by 6 tests: end of block Executed by:
| 6988 | ||||||||||||||||||||||||
862 | br = unelidedRect; | - | ||||||||||||||||||||||||
863 | previousHeight = height; | - | ||||||||||||||||||||||||
864 | height = naturalHeight; | - | ||||||||||||||||||||||||
865 | } executed 6988 times by 6 tests: end of block Executed by:
| 6988 | ||||||||||||||||||||||||
866 | widthExceeded |= wrapped; | - | ||||||||||||||||||||||||
867 | - | |||||||||||||||||||||||||
868 | // Save the implicit size of the text on the first layout only. | - | ||||||||||||||||||||||||
869 | if (once) {
| 1992-424048 | ||||||||||||||||||||||||
870 | once = false; | - | ||||||||||||||||||||||||
871 | - | |||||||||||||||||||||||||
872 | // If implicit sizes are required layout any additional lines up to the maximum line | - | ||||||||||||||||||||||||
873 | // count. | - | ||||||||||||||||||||||||
874 | if ((requireImplicitSize) && line.isValid() && unwrappedLineCount < maxLineCount) {
| 0-423572 | ||||||||||||||||||||||||
875 | // Layout the remainder of the wrapped lines up to maxLineCount to get the implicit | - | ||||||||||||||||||||||||
876 | // height. | - | ||||||||||||||||||||||||
877 | for (int lineCount = layout.lineCount(); lineCount < maxLineCount; ++lineCount) {
| 18-248 | ||||||||||||||||||||||||
878 | line = layout.createLine(); | - | ||||||||||||||||||||||||
879 | if (!line.isValid())
| 12-236 | ||||||||||||||||||||||||
880 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||||||||||||||
881 | if (layoutText.at(line.textStart() - 1) == QChar::LineSeparator)
| 58-178 | ||||||||||||||||||||||||
882 | ++unwrappedLineCount; executed 58 times by 1 test: ++unwrappedLineCount; Executed by:
| 58 | ||||||||||||||||||||||||
883 | setLineGeometry(line, lineWidth, naturalHeight); | - | ||||||||||||||||||||||||
884 | } executed 236 times by 1 test: end of block Executed by:
| 236 | ||||||||||||||||||||||||
885 | - | |||||||||||||||||||||||||
886 | // Create the remainder of the unwrapped lines up to maxLineCount to get the | - | ||||||||||||||||||||||||
887 | // implicit width. | - | ||||||||||||||||||||||||
888 | const int eol = line.isValid()
| 12-18 | ||||||||||||||||||||||||
889 | ? line.textStart() + line.textLength() | - | ||||||||||||||||||||||||
890 | : layoutText.length(); | - | ||||||||||||||||||||||||
891 | if (eol < layoutText.length() && layoutText.at(eol) != QChar::LineSeparator)
| 0-16 | ||||||||||||||||||||||||
892 | line = layout.createLine(); executed 16 times by 1 test: line = layout.createLine(); Executed by:
| 16 | ||||||||||||||||||||||||
893 | for (; line.isValid() && unwrappedLineCount <= maxLineCount; ++unwrappedLineCount)
| 0-30 | ||||||||||||||||||||||||
894 | line = layout.createLine(); executed 2 times by 1 test: line = layout.createLine(); Executed by:
| 2 | ||||||||||||||||||||||||
895 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
896 | layout.endLayout(); | - | ||||||||||||||||||||||||
897 | - | |||||||||||||||||||||||||
898 | const qreal naturalWidth = layout.maximumWidth(); | - | ||||||||||||||||||||||||
899 | - | |||||||||||||||||||||||||
900 | bool wasInLayout = internalWidthUpdate; | - | ||||||||||||||||||||||||
901 | internalWidthUpdate = true; | - | ||||||||||||||||||||||||
902 | q->setImplicitSize(naturalWidth + q->leftPadding() + q->rightPadding(), naturalHeight + q->topPadding() + q->bottomPadding()); | - | ||||||||||||||||||||||||
903 | internalWidthUpdate = wasInLayout; | - | ||||||||||||||||||||||||
904 | - | |||||||||||||||||||||||||
905 | // Update any variables that are dependent on the validity of the width or height. | - | ||||||||||||||||||||||||
906 | singlelineElide = elideMode != QQuickText::ElideNone && q->widthValid();
| 24-423704 | ||||||||||||||||||||||||
907 | multilineElide = elideMode == QQuickText::ElideRight
| 278-423770 | ||||||||||||||||||||||||
908 | && q->widthValid()
| 24-254 | ||||||||||||||||||||||||
909 | && (q->heightValid() || maximumLineCountValid);
| 22-186 | ||||||||||||||||||||||||
910 | canWrap = wrapMode != QQuickText::NoWrap && q->widthValid();
| 24-423402 | ||||||||||||||||||||||||
911 | - | |||||||||||||||||||||||||
912 | horizontalFit = fontSizeMode() & QQuickText::HorizontalFit && q->widthValid();
| 0-423850 | ||||||||||||||||||||||||
913 | verticalFit = fontSizeMode() & QQuickText::VerticalFit
| 178-423870 | ||||||||||||||||||||||||
914 | && (q->heightValid() || (maximumLineCountValid && canWrap));
| 0-178 | ||||||||||||||||||||||||
915 | - | |||||||||||||||||||||||||
916 | const qreal oldWidth = lineWidth; | - | ||||||||||||||||||||||||
917 | const qreal oldHeight = maxHeight; | - | ||||||||||||||||||||||||
918 | - | |||||||||||||||||||||||||
919 | const qreal availWidth = availableWidth(); | - | ||||||||||||||||||||||||
920 | const qreal availHeight = availableHeight(); | - | ||||||||||||||||||||||||
921 | - | |||||||||||||||||||||||||
922 | lineWidth = q->widthValid() && availWidth > 0 ? availWidth : naturalWidth;
| 58-420696 | ||||||||||||||||||||||||
923 | maxHeight = q->heightValid() ? availHeight : FLT_MAX;
| 3452-420596 | ||||||||||||||||||||||||
924 | - | |||||||||||||||||||||||||
925 | // If the width of the item has changed and it's possible the result of wrapping, | - | ||||||||||||||||||||||||
926 | // eliding, scaling has changed, or the text is not left aligned do another layout. | - | ||||||||||||||||||||||||
927 | if ((!qFuzzyCompare(lineWidth, oldWidth) || (widthExceeded && lineWidth > oldWidth))
| 0-420794 | ||||||||||||||||||||||||
928 | && (singlelineElide || multilineElide || canWrap || horizontalFit
| 0-420760 | ||||||||||||||||||||||||
929 | || q->effectiveHAlign() != QQuickText::AlignLeft)) {
| 64-420648 | ||||||||||||||||||||||||
930 | widthChanged = true; | - | ||||||||||||||||||||||||
931 | widthExceeded = lineWidth >= qMin(oldWidth, naturalWidth); | - | ||||||||||||||||||||||||
932 | heightExceeded = false; | - | ||||||||||||||||||||||||
933 | continue; executed 146 times by 3 tests: continue; Executed by:
| 146 | ||||||||||||||||||||||||
934 | } | - | ||||||||||||||||||||||||
935 | - | |||||||||||||||||||||||||
936 | // If the height of the item has changed and it's possible the result of eliding, | - | ||||||||||||||||||||||||
937 | // line count truncation or scaling has changed, do another layout. | - | ||||||||||||||||||||||||
938 | if ((maxHeight < qMin(oldHeight, naturalHeight) || (heightExceeded && maxHeight > oldHeight))
| 0-423902 | ||||||||||||||||||||||||
939 | && (multilineElide || (canWrap && maximumLineCountValid))) {
| 0-2 | ||||||||||||||||||||||||
940 | widthExceeded = false; | - | ||||||||||||||||||||||||
941 | heightExceeded = false; | - | ||||||||||||||||||||||||
942 | continue; executed 2 times by 1 test: continue; Executed by:
| 2 | ||||||||||||||||||||||||
943 | } | - | ||||||||||||||||||||||||
944 | - | |||||||||||||||||||||||||
945 | // If the horizontal alignment is not left and the width was not valid we need to relayout | - | ||||||||||||||||||||||||
946 | // now that we know the maximum line width. | - | ||||||||||||||||||||||||
947 | if (!q->widthValid() && !implicitWidthValid && unwrappedLineCount > 1 && q->effectiveHAlign() != QQuickText::AlignLeft) {
| 0-420658 | ||||||||||||||||||||||||
948 | widthExceeded = false; | - | ||||||||||||||||||||||||
949 | heightExceeded = false; | - | ||||||||||||||||||||||||
950 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
951 | } | - | ||||||||||||||||||||||||
952 | } else if (widthChanged) { executed 423900 times by 33 tests: end of block Executed by:
| 146-423900 | ||||||||||||||||||||||||
953 | widthChanged = false; | - | ||||||||||||||||||||||||
954 | if (line.isValid()) {
| 6-140 | ||||||||||||||||||||||||
955 | for (int lineCount = layout.lineCount(); lineCount < maxLineCount; ++lineCount) {
| 2-190 | ||||||||||||||||||||||||
956 | line = layout.createLine(); | - | ||||||||||||||||||||||||
957 | if (!line.isValid())
| 4-186 | ||||||||||||||||||||||||
958 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
959 | setLineGeometry(line, lineWidth, naturalHeight); | - | ||||||||||||||||||||||||
960 | } executed 186 times by 1 test: end of block Executed by:
| 186 | ||||||||||||||||||||||||
961 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
962 | layout.endLayout(); | - | ||||||||||||||||||||||||
963 | - | |||||||||||||||||||||||||
964 | bool wasInLayout = internalWidthUpdate; | - | ||||||||||||||||||||||||
965 | internalWidthUpdate = true; | - | ||||||||||||||||||||||||
966 | q->setImplicitHeight(naturalHeight + q->topPadding() + q->bottomPadding()); | - | ||||||||||||||||||||||||
967 | internalWidthUpdate = wasInLayout; | - | ||||||||||||||||||||||||
968 | - | |||||||||||||||||||||||||
969 | multilineElide = elideMode == QQuickText::ElideRight
| 34-112 | ||||||||||||||||||||||||
970 | && q->widthValid()
| 0-34 | ||||||||||||||||||||||||
971 | && (q->heightValid() || maximumLineCountValid);
| 4-18 | ||||||||||||||||||||||||
972 | verticalFit = fontSizeMode() & QQuickText::VerticalFit
| 0-146 | ||||||||||||||||||||||||
973 | && (q->heightValid() || (maximumLineCountValid && canWrap));
| 0 | ||||||||||||||||||||||||
974 | - | |||||||||||||||||||||||||
975 | const qreal oldHeight = maxHeight; | - | ||||||||||||||||||||||||
976 | maxHeight = q->heightValid() ? availableHeight() : FLT_MAX;
| 56-90 | ||||||||||||||||||||||||
977 | // If the height of the item has changed and it's possible the result of eliding, | - | ||||||||||||||||||||||||
978 | // line count truncation or scaling has changed, do another layout. | - | ||||||||||||||||||||||||
979 | if ((maxHeight < qMin(oldHeight, naturalHeight) || (heightExceeded && maxHeight > oldHeight))
| 0-146 | ||||||||||||||||||||||||
980 | && (multilineElide || (canWrap && maximumLineCountValid))) {
| 0 | ||||||||||||||||||||||||
981 | widthExceeded = false; | - | ||||||||||||||||||||||||
982 | heightExceeded = false; | - | ||||||||||||||||||||||||
983 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
984 | } | - | ||||||||||||||||||||||||
985 | } else { executed 146 times by 3 tests: end of block Executed by:
| 146 | ||||||||||||||||||||||||
986 | layout.endLayout(); | - | ||||||||||||||||||||||||
987 | } executed 1846 times by 1 test: end of block Executed by:
| 1846 | ||||||||||||||||||||||||
988 | - | |||||||||||||||||||||||||
989 | // If the next needs to be elided and there's an abbreviated string available | - | ||||||||||||||||||||||||
990 | // go back and do another layout with the abbreviated string. | - | ||||||||||||||||||||||||
991 | if (eos != -1 && elide) {
| 8-425864 | ||||||||||||||||||||||||
992 | int start = eos + 1; | - | ||||||||||||||||||||||||
993 | eos = text.indexOf(QLatin1Char('\x9c'), start); | - | ||||||||||||||||||||||||
994 | layoutText = text.mid(start, eos != -1 ? eos - start : -1); | - | ||||||||||||||||||||||||
995 | layoutText.replace(QLatin1Char('\n'), QChar::LineSeparator); | - | ||||||||||||||||||||||||
996 | layout.setText(layoutText); | - | ||||||||||||||||||||||||
997 | textHasChanged = true; | - | ||||||||||||||||||||||||
998 | continue; executed 20 times by 1 test: continue; Executed by:
| 20 | ||||||||||||||||||||||||
999 | } | - | ||||||||||||||||||||||||
1000 | - | |||||||||||||||||||||||||
1001 | br.moveTop(0); | - | ||||||||||||||||||||||||
1002 | - | |||||||||||||||||||||||||
1003 | // Find the advance of the text layout | - | ||||||||||||||||||||||||
1004 | if (layout.lineCount() > 0) {
| 0-425872 | ||||||||||||||||||||||||
1005 | QTextLine firstLine = layout.lineAt(0); | - | ||||||||||||||||||||||||
1006 | QTextLine lastLine = layout.lineAt(layout.lineCount() - 1); | - | ||||||||||||||||||||||||
1007 | advance = QSizeF(lastLine.horizontalAdvance(), | - | ||||||||||||||||||||||||
1008 | lastLine.y() - firstLine.y()); | - | ||||||||||||||||||||||||
1009 | } else { executed 425872 times by 33 tests: end of block Executed by:
| 425872 | ||||||||||||||||||||||||
1010 | advance = QSizeF(); | - | ||||||||||||||||||||||||
1011 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1012 | - | |||||||||||||||||||||||||
1013 | if (!horizontalFit && !verticalFit)
| 626-424388 | ||||||||||||||||||||||||
1014 | break; executed 423762 times by 33 tests: break; Executed by:
| 423762 | ||||||||||||||||||||||||
1015 | - | |||||||||||||||||||||||||
1016 | // Try and find a font size that better fits the dimensions of the element. | - | ||||||||||||||||||||||||
1017 | if (horizontalFit) {
| 626-1484 | ||||||||||||||||||||||||
1018 | if (unelidedRect.width() > lineWidth || (!verticalFit && wrapped)) {
| 228-1082 | ||||||||||||||||||||||||
1019 | widthExceeded = true; | - | ||||||||||||||||||||||||
1020 | largeFont = scaledFontSize - 1; | - | ||||||||||||||||||||||||
1021 | if (smallFont > largeFont)
| 0-630 | ||||||||||||||||||||||||
1022 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1023 | scaledFontSize = (smallFont + largeFont) / 2; | - | ||||||||||||||||||||||||
1024 | if (pixelSize)
| 36-594 | ||||||||||||||||||||||||
1025 | scaledFont.setPixelSize(scaledFontSize); executed 594 times by 1 test: scaledFont.setPixelSize(scaledFontSize); Executed by:
| 594 | ||||||||||||||||||||||||
1026 | else | - | ||||||||||||||||||||||||
1027 | scaledFont.setPointSize(scaledFontSize); executed 36 times by 1 test: scaledFont.setPointSize(scaledFontSize); Executed by:
| 36 | ||||||||||||||||||||||||
1028 | continue; executed 630 times by 1 test: continue; Executed by:
| 630 | ||||||||||||||||||||||||
1029 | } else if (!verticalFit) {
| 358-496 | ||||||||||||||||||||||||
1030 | smallFont = scaledFontSize; | - | ||||||||||||||||||||||||
1031 | if (smallFont == largeFont)
| 108-250 | ||||||||||||||||||||||||
1032 | break; executed 108 times by 1 test: break; Executed by:
| 108 | ||||||||||||||||||||||||
1033 | scaledFontSize = (smallFont + largeFont + 1) / 2; | - | ||||||||||||||||||||||||
1034 | } executed 250 times by 1 test: end of block Executed by:
| 250 | ||||||||||||||||||||||||
1035 | } executed 746 times by 1 test: end of block Executed by:
| 746 | ||||||||||||||||||||||||
1036 | - | |||||||||||||||||||||||||
1037 | if (verticalFit) {
| 250-1122 | ||||||||||||||||||||||||
1038 | if (truncateHeight || unelidedRect.height() > maxHeight) {
| 150-972 | ||||||||||||||||||||||||
1039 | heightExceeded = true; | - | ||||||||||||||||||||||||
1040 | largeFont = scaledFontSize - 1; | - | ||||||||||||||||||||||||
1041 | if (smallFont > largeFont)
| 0-574 | ||||||||||||||||||||||||
1042 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1043 | scaledFontSize = (smallFont + largeFont) / 2; | - | ||||||||||||||||||||||||
1044 | - | |||||||||||||||||||||||||
1045 | } else { executed 574 times by 1 test: end of block Executed by:
| 574 | ||||||||||||||||||||||||
1046 | smallFont = scaledFontSize; | - | ||||||||||||||||||||||||
1047 | if (smallFont == largeFont)
| 178-370 | ||||||||||||||||||||||||
1048 | break; executed 178 times by 1 test: break; Executed by:
| 178 | ||||||||||||||||||||||||
1049 | scaledFontSize = (smallFont + largeFont + 1) / 2; | - | ||||||||||||||||||||||||
1050 | } executed 370 times by 1 test: end of block Executed by:
| 370 | ||||||||||||||||||||||||
1051 | } | - | ||||||||||||||||||||||||
1052 | } executed 1194 times by 1 test: end of block Executed by:
| 1194 | ||||||||||||||||||||||||
1053 | - | |||||||||||||||||||||||||
1054 | implicitWidthValid = true; | - | ||||||||||||||||||||||||
1055 | implicitHeightValid = true; | - | ||||||||||||||||||||||||
1056 | - | |||||||||||||||||||||||||
1057 | QFontInfo scaledFontInfo(scaledFont); | - | ||||||||||||||||||||||||
1058 | if (fontInfo.weight() != scaledFontInfo.weight()
| 216-423832 | ||||||||||||||||||||||||
1059 | || fontInfo.pixelSize() != scaledFontInfo.pixelSize()
| 4530-419302 | ||||||||||||||||||||||||
1060 | || fontInfo.italic() != scaledFontInfo.italic()
| 8-419294 | ||||||||||||||||||||||||
1061 | || !qFuzzyCompare(fontInfo.pointSizeF(), scaledFontInfo.pointSizeF())
| 0-419294 | ||||||||||||||||||||||||
1062 | || fontInfo.family() != scaledFontInfo.family()
| 10-419284 | ||||||||||||||||||||||||
1063 | || fontInfo.styleName() != scaledFontInfo.styleName()) {
| 0-419284 | ||||||||||||||||||||||||
1064 | fontInfo = scaledFontInfo; | - | ||||||||||||||||||||||||
1065 | emit q->fontInfoChanged(); | - | ||||||||||||||||||||||||
1066 | } executed 4764 times by 13 tests: end of block Executed by:
| 4764 | ||||||||||||||||||||||||
1067 | - | |||||||||||||||||||||||||
1068 | if (eos != multilengthEos)
| 12-424036 | ||||||||||||||||||||||||
1069 | truncated = true; executed 12 times by 1 test: truncated = true; Executed by:
| 12 | ||||||||||||||||||||||||
1070 | - | |||||||||||||||||||||||||
1071 | assignedFont = QFontInfo(font).family(); | - | ||||||||||||||||||||||||
1072 | - | |||||||||||||||||||||||||
1073 | if (elide) {
| 140-423908 | ||||||||||||||||||||||||
1074 | if (!elideLayout) {
| 46-94 | ||||||||||||||||||||||||
1075 | elideLayout = new QTextLayout; | - | ||||||||||||||||||||||||
1076 | elideLayout->setCacheEnabled(true); | - | ||||||||||||||||||||||||
1077 | } executed 94 times by 1 test: end of block Executed by:
| 94 | ||||||||||||||||||||||||
1078 | QTextEngine *engine = layout.engine(); | - | ||||||||||||||||||||||||
1079 | if (engine && engine->hasFormats()) {
| 0-140 | ||||||||||||||||||||||||
1080 | QVector<QTextLayout::FormatRange> formats; | - | ||||||||||||||||||||||||
1081 | switch (elideMode) { | - | ||||||||||||||||||||||||
1082 | case QQuickText::ElideRight: executed 14 times by 1 test: case QQuickText::ElideRight: Executed by:
| 14 | ||||||||||||||||||||||||
1083 | elideFormats(elideStart, elideText.length() - 1, 0, &formats); | - | ||||||||||||||||||||||||
1084 | break; executed 14 times by 1 test: break; Executed by:
| 14 | ||||||||||||||||||||||||
1085 | case QQuickText::ElideLeft: executed 6 times by 1 test: case QQuickText::ElideLeft: Executed by:
| 6 | ||||||||||||||||||||||||
1086 | elideFormats(elideEnd - elideText.length() + 1, elideText.length() - 1, 1, &formats); | - | ||||||||||||||||||||||||
1087 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
1088 | case QQuickText::ElideMiddle: { executed 4 times by 1 test: case QQuickText::ElideMiddle: Executed by:
| 4 | ||||||||||||||||||||||||
1089 | const int index = elideText.indexOf(elideChar); | - | ||||||||||||||||||||||||
1090 | if (index != -1) {
| 0-4 | ||||||||||||||||||||||||
1091 | elideFormats(elideStart, index, 0, &formats); | - | ||||||||||||||||||||||||
1092 | elideFormats( | - | ||||||||||||||||||||||||
1093 | elideEnd - elideText.length() + index + 1, | - | ||||||||||||||||||||||||
1094 | elideText.length() - index - 1, | - | ||||||||||||||||||||||||
1095 | index + 1, | - | ||||||||||||||||||||||||
1096 | &formats); | - | ||||||||||||||||||||||||
1097 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1098 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
1099 | } | - | ||||||||||||||||||||||||
1100 | default: never executed: default: | 0 | ||||||||||||||||||||||||
1101 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1102 | } | - | ||||||||||||||||||||||||
1103 | elideLayout->setFormats(formats); | - | ||||||||||||||||||||||||
1104 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
1105 | - | |||||||||||||||||||||||||
1106 | elideLayout->setFont(layout.font()); | - | ||||||||||||||||||||||||
1107 | elideLayout->setTextOption(layout.textOption()); | - | ||||||||||||||||||||||||
1108 | elideLayout->setText(elideText); | - | ||||||||||||||||||||||||
1109 | elideLayout->beginLayout(); | - | ||||||||||||||||||||||||
1110 | - | |||||||||||||||||||||||||
1111 | QTextLine elidedLine = elideLayout->createLine(); | - | ||||||||||||||||||||||||
1112 | elidedLine.setPosition(QPointF(0, height)); | - | ||||||||||||||||||||||||
1113 | if (customLayout) {
| 0-140 | ||||||||||||||||||||||||
1114 | setupCustomLineGeometry(elidedLine, height, visibleCount - 1); | - | ||||||||||||||||||||||||
1115 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1116 | setLineGeometry(elidedLine, lineWidth, height); | - | ||||||||||||||||||||||||
1117 | } executed 140 times by 1 test: end of block Executed by:
| 140 | ||||||||||||||||||||||||
1118 | elideLayout->endLayout(); | - | ||||||||||||||||||||||||
1119 | - | |||||||||||||||||||||||||
1120 | br = br.united(elidedLine.naturalTextRect()); | - | ||||||||||||||||||||||||
1121 | - | |||||||||||||||||||||||||
1122 | if (visibleCount == 1)
| 38-102 | ||||||||||||||||||||||||
1123 | layout.clearLayout(); executed 102 times by 1 test: layout.clearLayout(); Executed by:
| 102 | ||||||||||||||||||||||||
1124 | } else { executed 140 times by 1 test: end of block Executed by:
| 140 | ||||||||||||||||||||||||
1125 | delete elideLayout; | - | ||||||||||||||||||||||||
1126 | elideLayout = nullptr; | - | ||||||||||||||||||||||||
1127 | } executed 423908 times by 33 tests: end of block Executed by:
| 423908 | ||||||||||||||||||||||||
1128 | - | |||||||||||||||||||||||||
1129 | QTextLine firstLine = visibleCount == 1 && elideLayout
| 102-422000 | ||||||||||||||||||||||||
1130 | ? elideLayout->lineAt(0) | - | ||||||||||||||||||||||||
1131 | : layout.lineAt(0); | - | ||||||||||||||||||||||||
1132 | Q_ASSERT(firstLine.isValid()); | - | ||||||||||||||||||||||||
1133 | *baseline = firstLine.y() + firstLine.ascent(); | - | ||||||||||||||||||||||||
1134 | - | |||||||||||||||||||||||||
1135 | if (!customLayout)
| 28-424020 | ||||||||||||||||||||||||
1136 | br.setHeight(height); executed 424020 times by 33 tests: br.setHeight(height); Executed by:
| 424020 | ||||||||||||||||||||||||
1137 | - | |||||||||||||||||||||||||
1138 | //Update the number of visible lines | - | ||||||||||||||||||||||||
1139 | if (lineCount != visibleCount) {
| 844-423204 | ||||||||||||||||||||||||
1140 | lineCount = visibleCount; | - | ||||||||||||||||||||||||
1141 | emit q->lineCountChanged(); | - | ||||||||||||||||||||||||
1142 | } executed 844 times by 6 tests: end of block Executed by:
| 844 | ||||||||||||||||||||||||
1143 | - | |||||||||||||||||||||||||
1144 | if (truncated != wasTruncated)
| 170-423878 | ||||||||||||||||||||||||
1145 | emit q->truncatedChanged(); executed 170 times by 1 test: q->truncatedChanged(); Executed by:
| 170 | ||||||||||||||||||||||||
1146 | - | |||||||||||||||||||||||||
1147 | return br; executed 424048 times by 33 tests: return br; Executed by:
| 424048 | ||||||||||||||||||||||||
1148 | } | - | ||||||||||||||||||||||||
1149 | - | |||||||||||||||||||||||||
1150 | void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height) | - | ||||||||||||||||||||||||
1151 | { | - | ||||||||||||||||||||||||
1152 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
1153 | line.setLineWidth(lineWidth); | - | ||||||||||||||||||||||||
1154 | - | |||||||||||||||||||||||||
1155 | if (extra.isAllocated() && extra->imgTags.isEmpty()) {
| 138-428438 | ||||||||||||||||||||||||
1156 | line.setPosition(QPointF(line.position().x(), height)); | - | ||||||||||||||||||||||||
1157 | height += (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight();
| 92-4586 | ||||||||||||||||||||||||
1158 | return; executed 4678 times by 1 test: return; Executed by:
| 4678 | ||||||||||||||||||||||||
1159 | } | - | ||||||||||||||||||||||||
1160 | - | |||||||||||||||||||||||||
1161 | qreal textTop = 0; | - | ||||||||||||||||||||||||
1162 | qreal textHeight = line.height(); | - | ||||||||||||||||||||||||
1163 | qreal totalLineHeight = textHeight; | - | ||||||||||||||||||||||||
1164 | - | |||||||||||||||||||||||||
1165 | QList<QQuickStyledTextImgTag *> imagesInLine; | - | ||||||||||||||||||||||||
1166 | - | |||||||||||||||||||||||||
1167 | if (extra.isAllocated()) {
| 138-428438 | ||||||||||||||||||||||||
1168 | for (QQuickStyledTextImgTag *image : qAsConst(extra->imgTags)) { | - | ||||||||||||||||||||||||
1169 | if (image->position >= line.textStart() &&
| 58-112 | ||||||||||||||||||||||||
1170 | image->position < line.textStart() + line.textLength()) {
| 16-96 | ||||||||||||||||||||||||
1171 | - | |||||||||||||||||||||||||
1172 | if (!image->pix) {
| 40-56 | ||||||||||||||||||||||||
1173 | QUrl url = q->baseUrl().resolved(image->url); | - | ||||||||||||||||||||||||
1174 | image->pix = new QQuickPixmap(qmlEngine(q), url, image->size); | - | ||||||||||||||||||||||||
1175 | if (image->pix->isLoading()) {
| 10-30 | ||||||||||||||||||||||||
1176 | image->pix->connectFinished(q, SLOT(imageDownloadFinished())); | - | ||||||||||||||||||||||||
1177 | if (!extra.isAllocated() || !extra->nbActiveDownloads)
| 0-10 | ||||||||||||||||||||||||
1178 | extra.value().nbActiveDownloads = 0; executed 10 times by 2 tests: extra.value().nbActiveDownloads = 0; Executed by:
| 10 | ||||||||||||||||||||||||
1179 | extra->nbActiveDownloads++; | - | ||||||||||||||||||||||||
1180 | } else if (image->pix->isReady()) { executed 10 times by 2 tests: end of block Executed by:
| 2-28 | ||||||||||||||||||||||||
1181 | if (!image->size.isValid()) {
| 2-26 | ||||||||||||||||||||||||
1182 | image->size = image->pix->implicitSize(); | - | ||||||||||||||||||||||||
1183 | // if the size of the image was not explicitly set, we need to | - | ||||||||||||||||||||||||
1184 | // call updateLayout() once again. | - | ||||||||||||||||||||||||
1185 | needToUpdateLayout = true; | - | ||||||||||||||||||||||||
1186 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1187 | } else if (image->pix->isError()) { executed 28 times by 2 tests: end of block Executed by:
| 0-28 | ||||||||||||||||||||||||
1188 | qmlWarning(q) << image->pix->error(); | - | ||||||||||||||||||||||||
1189 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1190 | } executed 40 times by 2 tests: end of block Executed by:
| 40 | ||||||||||||||||||||||||
1191 | - | |||||||||||||||||||||||||
1192 | qreal ih = qreal(image->size.height()); | - | ||||||||||||||||||||||||
1193 | if (image->align == QQuickStyledTextImgTag::Top)
| 8-88 | ||||||||||||||||||||||||
1194 | image->pos.setY(0); executed 8 times by 2 tests: image->pos.setY(0); Executed by:
| 8 | ||||||||||||||||||||||||
1195 | else if (image->align == QQuickStyledTextImgTag::Middle)
| 18-70 | ||||||||||||||||||||||||
1196 | image->pos.setY((textHeight / 2.0) - (ih / 2.0)); executed 18 times by 2 tests: image->pos.setY((textHeight / 2.0) - (ih / 2.0)); Executed by:
| 18 | ||||||||||||||||||||||||
1197 | else | - | ||||||||||||||||||||||||
1198 | image->pos.setY(textHeight - ih); executed 70 times by 2 tests: image->pos.setY(textHeight - ih); Executed by:
| 70 | ||||||||||||||||||||||||
1199 | imagesInLine << image; | - | ||||||||||||||||||||||||
1200 | textTop = qMax(textTop, qAbs(image->pos.y())); | - | ||||||||||||||||||||||||
1201 | } executed 96 times by 2 tests: end of block Executed by:
| 96 | ||||||||||||||||||||||||
1202 | } executed 170 times by 2 tests: end of block Executed by:
| 170 | ||||||||||||||||||||||||
1203 | } executed 138 times by 2 tests: end of block Executed by:
| 138 | ||||||||||||||||||||||||
1204 | - | |||||||||||||||||||||||||
1205 | for (QQuickStyledTextImgTag *image : qAsConst(imagesInLine)) { | - | ||||||||||||||||||||||||
1206 | totalLineHeight = qMax(totalLineHeight, textTop + image->pos.y() + image->size.height()); | - | ||||||||||||||||||||||||
1207 | const int leadX = line.cursorToX(image->position); | - | ||||||||||||||||||||||||
1208 | const int trailX = line.cursorToX(image->position, QTextLine::Trailing); | - | ||||||||||||||||||||||||
1209 | const bool rtl = trailX < leadX; | - | ||||||||||||||||||||||||
1210 | image->pos.setX(leadX + (rtl ? (-image->offset - image->size.width()) : image->offset)); | - | ||||||||||||||||||||||||
1211 | image->pos.setY(image->pos.y() + height + textTop); | - | ||||||||||||||||||||||||
1212 | extra->visibleImgTags << image; | - | ||||||||||||||||||||||||
1213 | } executed 96 times by 2 tests: end of block Executed by:
| 96 | ||||||||||||||||||||||||
1214 | - | |||||||||||||||||||||||||
1215 | line.setPosition(QPointF(line.position().x(), height + textTop)); | - | ||||||||||||||||||||||||
1216 | height += (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : totalLineHeight * lineHeight();
| 0-428576 | ||||||||||||||||||||||||
1217 | } executed 428576 times by 33 tests: end of block Executed by:
| 428576 | ||||||||||||||||||||||||
1218 | - | |||||||||||||||||||||||||
1219 | /*! | - | ||||||||||||||||||||||||
1220 | Returns the y offset when aligning text with a non-1.0 lineHeight | - | ||||||||||||||||||||||||
1221 | */ | - | ||||||||||||||||||||||||
1222 | int QQuickTextPrivate::lineHeightOffset() const | - | ||||||||||||||||||||||||
1223 | { | - | ||||||||||||||||||||||||
1224 | QFontMetricsF fm(font); | - | ||||||||||||||||||||||||
1225 | qreal fontHeight = qCeil(fm.height()); // QScriptLine and therefore QTextLine rounds up | - | ||||||||||||||||||||||||
1226 | return lineHeightMode() == QQuickText::FixedHeight ? fontHeight - lineHeight() executed 249006 times by 21 tests: return lineHeightMode() == QQuickText::FixedHeight ? fontHeight - lineHeight() : (1.0 - lineHeight()) * fontHeight; Executed by:
| 249006 | ||||||||||||||||||||||||
1227 | : (1.0 - lineHeight()) * fontHeight; executed 249006 times by 21 tests: return lineHeightMode() == QQuickText::FixedHeight ? fontHeight - lineHeight() : (1.0 - lineHeight()) * fontHeight; Executed by:
| 249006 | ||||||||||||||||||||||||
1228 | } | - | ||||||||||||||||||||||||
1229 | - | |||||||||||||||||||||||||
1230 | /*! | - | ||||||||||||||||||||||||
1231 | Ensures the QQuickTextPrivate::doc variable is set to a valid text document | - | ||||||||||||||||||||||||
1232 | */ | - | ||||||||||||||||||||||||
1233 | void QQuickTextPrivate::ensureDoc() | - | ||||||||||||||||||||||||
1234 | { | - | ||||||||||||||||||||||||
1235 | if (!extra.isAllocated() || !extra->doc) {
| 12-438 | ||||||||||||||||||||||||
1236 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
1237 | extra.value().doc = new QQuickTextDocumentWithImageResources(q); | - | ||||||||||||||||||||||||
1238 | extra->doc->setPageSize(QSizeF(0, 0)); | - | ||||||||||||||||||||||||
1239 | extra->doc->setDocumentMargin(0); | - | ||||||||||||||||||||||||
1240 | extra->doc->setBaseUrl(q->baseUrl()); | - | ||||||||||||||||||||||||
1241 | qmlobject_connect(extra->doc, QQuickTextDocumentWithImageResources, SIGNAL(imagesLoaded()), executed 4 times by 2 tests: end of block Executed by:
executed 4 times by 2 tests: methodIdx = QQuickText::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickText::staticMetaObject.indexOfSignal(method+1);
| 0-146 | ||||||||||||||||||||||||
1242 | q, QQuickText, SLOT(q_updateLayout())); | - | ||||||||||||||||||||||||
1243 | } executed 150 times by 2 tests: end of block Executed by:
| 150 | ||||||||||||||||||||||||
1244 | } executed 576 times by 2 tests: end of block Executed by:
| 576 | ||||||||||||||||||||||||
1245 | - | |||||||||||||||||||||||||
1246 | /*! | - | ||||||||||||||||||||||||
1247 | \qmltype Text | - | ||||||||||||||||||||||||
1248 | \instantiates QQuickText | - | ||||||||||||||||||||||||
1249 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
1250 | \ingroup qtquick-visual | - | ||||||||||||||||||||||||
1251 | \inherits Item | - | ||||||||||||||||||||||||
1252 | \brief Specifies how to add formatted text to a scene. | - | ||||||||||||||||||||||||
1253 | - | |||||||||||||||||||||||||
1254 | Text items can display both plain and rich text. For example, red text with | - | ||||||||||||||||||||||||
1255 | a specific font and size can be defined like this: | - | ||||||||||||||||||||||||
1256 | - | |||||||||||||||||||||||||
1257 | \qml | - | ||||||||||||||||||||||||
1258 | Text { | - | ||||||||||||||||||||||||
1259 | text: "Hello World!" | - | ||||||||||||||||||||||||
1260 | font.family: "Helvetica" | - | ||||||||||||||||||||||||
1261 | font.pointSize: 24 | - | ||||||||||||||||||||||||
1262 | color: "red" | - | ||||||||||||||||||||||||
1263 | } | - | ||||||||||||||||||||||||
1264 | \endqml | - | ||||||||||||||||||||||||
1265 | - | |||||||||||||||||||||||||
1266 | Rich text is defined using HTML-style markup: | - | ||||||||||||||||||||||||
1267 | - | |||||||||||||||||||||||||
1268 | \qml | - | ||||||||||||||||||||||||
1269 | Text { | - | ||||||||||||||||||||||||
1270 | text: "<b>Hello</b> <i>World!</i>" | - | ||||||||||||||||||||||||
1271 | } | - | ||||||||||||||||||||||||
1272 | \endqml | - | ||||||||||||||||||||||||
1273 | - | |||||||||||||||||||||||||
1274 | \image declarative-text.png | - | ||||||||||||||||||||||||
1275 | - | |||||||||||||||||||||||||
1276 | If height and width are not explicitly set, Text will attempt to determine how | - | ||||||||||||||||||||||||
1277 | much room is needed and set it accordingly. Unless \l wrapMode is set, it will always | - | ||||||||||||||||||||||||
1278 | prefer width to height (all text will be placed on a single line). | - | ||||||||||||||||||||||||
1279 | - | |||||||||||||||||||||||||
1280 | The \l elide property can alternatively be used to fit a single line of | - | ||||||||||||||||||||||||
1281 | plain text to a set width. | - | ||||||||||||||||||||||||
1282 | - | |||||||||||||||||||||||||
1283 | Note that the \l{Supported HTML Subset} is limited. Also, if the text contains | - | ||||||||||||||||||||||||
1284 | HTML img tags that load remote images, the text is reloaded. | - | ||||||||||||||||||||||||
1285 | - | |||||||||||||||||||||||||
1286 | Text provides read-only text. For editable text, see \l TextEdit. | - | ||||||||||||||||||||||||
1287 | - | |||||||||||||||||||||||||
1288 | \sa {Qt Quick Examples - Text#Fonts}{Fonts example} | - | ||||||||||||||||||||||||
1289 | */ | - | ||||||||||||||||||||||||
1290 | QQuickText::QQuickText(QQuickItem *parent) | - | ||||||||||||||||||||||||
1291 | : QQuickImplicitSizeItem(*(new QQuickTextPrivate), parent) | - | ||||||||||||||||||||||||
1292 | { | - | ||||||||||||||||||||||||
1293 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1294 | d->init(); | - | ||||||||||||||||||||||||
1295 | } executed 264678 times by 35 tests: end of block Executed by:
| 264678 | ||||||||||||||||||||||||
1296 | - | |||||||||||||||||||||||||
1297 | QQuickText::QQuickText(QQuickTextPrivate &dd, QQuickItem *parent) | - | ||||||||||||||||||||||||
1298 | : QQuickImplicitSizeItem(dd, parent) | - | ||||||||||||||||||||||||
1299 | { | - | ||||||||||||||||||||||||
1300 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1301 | d->init(); | - | ||||||||||||||||||||||||
1302 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1303 | - | |||||||||||||||||||||||||
1304 | QQuickText::~QQuickText() | - | ||||||||||||||||||||||||
1305 | { | - | ||||||||||||||||||||||||
1306 | } | - | ||||||||||||||||||||||||
1307 | - | |||||||||||||||||||||||||
1308 | /*! | - | ||||||||||||||||||||||||
1309 | \qmlproperty bool QtQuick::Text::clip | - | ||||||||||||||||||||||||
1310 | This property holds whether the text is clipped. | - | ||||||||||||||||||||||||
1311 | - | |||||||||||||||||||||||||
1312 | Note that if the text does not fit in the bounding rectangle it will be abruptly chopped. | - | ||||||||||||||||||||||||
1313 | - | |||||||||||||||||||||||||
1314 | If you want to display potentially long text in a limited space, you probably want to use \c elide instead. | - | ||||||||||||||||||||||||
1315 | */ | - | ||||||||||||||||||||||||
1316 | - | |||||||||||||||||||||||||
1317 | /*! | - | ||||||||||||||||||||||||
1318 | \qmlsignal QtQuick::Text::lineLaidOut(object line) | - | ||||||||||||||||||||||||
1319 | - | |||||||||||||||||||||||||
1320 | This signal is emitted for each line of text that is laid out during the layout | - | ||||||||||||||||||||||||
1321 | process. The specified \a line object provides more details about the line that | - | ||||||||||||||||||||||||
1322 | is currently being laid out. | - | ||||||||||||||||||||||||
1323 | - | |||||||||||||||||||||||||
1324 | This gives the opportunity to position and resize a line as it is being laid out. | - | ||||||||||||||||||||||||
1325 | It can for example be used to create columns or lay out text around objects. | - | ||||||||||||||||||||||||
1326 | - | |||||||||||||||||||||||||
1327 | The properties of the specified \a line object are: | - | ||||||||||||||||||||||||
1328 | \list | - | ||||||||||||||||||||||||
1329 | \li number (read-only) | - | ||||||||||||||||||||||||
1330 | \li x | - | ||||||||||||||||||||||||
1331 | \li y | - | ||||||||||||||||||||||||
1332 | \li width | - | ||||||||||||||||||||||||
1333 | \li height | - | ||||||||||||||||||||||||
1334 | \endlist | - | ||||||||||||||||||||||||
1335 | - | |||||||||||||||||||||||||
1336 | For example, this will move the first 5 lines of a Text item by 100 pixels to the right: | - | ||||||||||||||||||||||||
1337 | \code | - | ||||||||||||||||||||||||
1338 | onLineLaidOut: { | - | ||||||||||||||||||||||||
1339 | if (line.number < 5) { | - | ||||||||||||||||||||||||
1340 | line.x = line.x + 100 | - | ||||||||||||||||||||||||
1341 | line.width = line.width - 100 | - | ||||||||||||||||||||||||
1342 | } | - | ||||||||||||||||||||||||
1343 | } | - | ||||||||||||||||||||||||
1344 | \endcode | - | ||||||||||||||||||||||||
1345 | - | |||||||||||||||||||||||||
1346 | The corresponding handler is \c onLineLaidOut. | - | ||||||||||||||||||||||||
1347 | */ | - | ||||||||||||||||||||||||
1348 | - | |||||||||||||||||||||||||
1349 | /*! | - | ||||||||||||||||||||||||
1350 | \qmlsignal QtQuick::Text::linkActivated(string link) | - | ||||||||||||||||||||||||
1351 | - | |||||||||||||||||||||||||
1352 | This signal is emitted when the user clicks on a link embedded in the text. | - | ||||||||||||||||||||||||
1353 | The link must be in rich text or HTML format and the | - | ||||||||||||||||||||||||
1354 | \a link string provides access to the particular link. | - | ||||||||||||||||||||||||
1355 | - | |||||||||||||||||||||||||
1356 | \snippet qml/text/onLinkActivated.qml 0 | - | ||||||||||||||||||||||||
1357 | - | |||||||||||||||||||||||||
1358 | The example code will display the text | - | ||||||||||||||||||||||||
1359 | "See the \l{http://qt-project.org}{Qt Project website}." | - | ||||||||||||||||||||||||
1360 | - | |||||||||||||||||||||||||
1361 | Clicking on the highlighted link will output | - | ||||||||||||||||||||||||
1362 | \tt{http://qt-project.org link activated} to the console. | - | ||||||||||||||||||||||||
1363 | - | |||||||||||||||||||||||||
1364 | The corresponding handler is \c onLinkActivated. | - | ||||||||||||||||||||||||
1365 | */ | - | ||||||||||||||||||||||||
1366 | - | |||||||||||||||||||||||||
1367 | /*! | - | ||||||||||||||||||||||||
1368 | \qmlproperty string QtQuick::Text::font.family | - | ||||||||||||||||||||||||
1369 | - | |||||||||||||||||||||||||
1370 | Sets the family name of the font. | - | ||||||||||||||||||||||||
1371 | - | |||||||||||||||||||||||||
1372 | The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". | - | ||||||||||||||||||||||||
1373 | If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. | - | ||||||||||||||||||||||||
1374 | If the family isn't available a family will be set using the font matching algorithm. | - | ||||||||||||||||||||||||
1375 | */ | - | ||||||||||||||||||||||||
1376 | - | |||||||||||||||||||||||||
1377 | /*! | - | ||||||||||||||||||||||||
1378 | \qmlproperty string QtQuick::Text::font.styleName | - | ||||||||||||||||||||||||
1379 | \since 5.6 | - | ||||||||||||||||||||||||
1380 | - | |||||||||||||||||||||||||
1381 | Sets the style name of the font. | - | ||||||||||||||||||||||||
1382 | - | |||||||||||||||||||||||||
1383 | The style name is case insensitive. If set, the font will be matched against style name instead | - | ||||||||||||||||||||||||
1384 | of the font properties \l font.weight, \l font.bold and \l font.italic. | - | ||||||||||||||||||||||||
1385 | */ | - | ||||||||||||||||||||||||
1386 | - | |||||||||||||||||||||||||
1387 | /*! | - | ||||||||||||||||||||||||
1388 | \qmlproperty bool QtQuick::Text::font.bold | - | ||||||||||||||||||||||||
1389 | - | |||||||||||||||||||||||||
1390 | Sets whether the font weight is bold. | - | ||||||||||||||||||||||||
1391 | */ | - | ||||||||||||||||||||||||
1392 | - | |||||||||||||||||||||||||
1393 | /*! | - | ||||||||||||||||||||||||
1394 | \qmlproperty enumeration QtQuick::Text::font.weight | - | ||||||||||||||||||||||||
1395 | - | |||||||||||||||||||||||||
1396 | Sets the font's weight. | - | ||||||||||||||||||||||||
1397 | - | |||||||||||||||||||||||||
1398 | The weight can be one of: | - | ||||||||||||||||||||||||
1399 | \list | - | ||||||||||||||||||||||||
1400 | \li Font.Thin | - | ||||||||||||||||||||||||
1401 | \li Font.Light | - | ||||||||||||||||||||||||
1402 | \li Font.ExtraLight | - | ||||||||||||||||||||||||
1403 | \li Font.Normal - the default | - | ||||||||||||||||||||||||
1404 | \li Font.Medium | - | ||||||||||||||||||||||||
1405 | \li Font.DemiBold | - | ||||||||||||||||||||||||
1406 | \li Font.Bold | - | ||||||||||||||||||||||||
1407 | \li Font.ExtraBold | - | ||||||||||||||||||||||||
1408 | \li Font.Black | - | ||||||||||||||||||||||||
1409 | \endlist | - | ||||||||||||||||||||||||
1410 | - | |||||||||||||||||||||||||
1411 | \qml | - | ||||||||||||||||||||||||
1412 | Text { text: "Hello"; font.weight: Font.DemiBold } | - | ||||||||||||||||||||||||
1413 | \endqml | - | ||||||||||||||||||||||||
1414 | */ | - | ||||||||||||||||||||||||
1415 | - | |||||||||||||||||||||||||
1416 | /*! | - | ||||||||||||||||||||||||
1417 | \qmlproperty bool QtQuick::Text::font.italic | - | ||||||||||||||||||||||||
1418 | - | |||||||||||||||||||||||||
1419 | Sets whether the font has an italic style. | - | ||||||||||||||||||||||||
1420 | */ | - | ||||||||||||||||||||||||
1421 | - | |||||||||||||||||||||||||
1422 | /*! | - | ||||||||||||||||||||||||
1423 | \qmlproperty bool QtQuick::Text::font.underline | - | ||||||||||||||||||||||||
1424 | - | |||||||||||||||||||||||||
1425 | Sets whether the text is underlined. | - | ||||||||||||||||||||||||
1426 | */ | - | ||||||||||||||||||||||||
1427 | - | |||||||||||||||||||||||||
1428 | /*! | - | ||||||||||||||||||||||||
1429 | \qmlproperty bool QtQuick::Text::font.strikeout | - | ||||||||||||||||||||||||
1430 | - | |||||||||||||||||||||||||
1431 | Sets whether the font has a strikeout style. | - | ||||||||||||||||||||||||
1432 | */ | - | ||||||||||||||||||||||||
1433 | - | |||||||||||||||||||||||||
1434 | /*! | - | ||||||||||||||||||||||||
1435 | \qmlproperty real QtQuick::Text::font.pointSize | - | ||||||||||||||||||||||||
1436 | - | |||||||||||||||||||||||||
1437 | Sets the font size in points. The point size must be greater than zero. | - | ||||||||||||||||||||||||
1438 | */ | - | ||||||||||||||||||||||||
1439 | - | |||||||||||||||||||||||||
1440 | /*! | - | ||||||||||||||||||||||||
1441 | \qmlproperty int QtQuick::Text::font.pixelSize | - | ||||||||||||||||||||||||
1442 | - | |||||||||||||||||||||||||
1443 | Sets the font size in pixels. | - | ||||||||||||||||||||||||
1444 | - | |||||||||||||||||||||||||
1445 | Using this function makes the font device dependent. | - | ||||||||||||||||||||||||
1446 | Use \c pointSize to set the size of the font in a device independent manner. | - | ||||||||||||||||||||||||
1447 | */ | - | ||||||||||||||||||||||||
1448 | - | |||||||||||||||||||||||||
1449 | /*! | - | ||||||||||||||||||||||||
1450 | \qmlproperty real QtQuick::Text::font.letterSpacing | - | ||||||||||||||||||||||||
1451 | - | |||||||||||||||||||||||||
1452 | Sets the letter spacing for the font. | - | ||||||||||||||||||||||||
1453 | - | |||||||||||||||||||||||||
1454 | Letter spacing changes the default spacing between individual letters in the font. | - | ||||||||||||||||||||||||
1455 | A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. | - | ||||||||||||||||||||||||
1456 | */ | - | ||||||||||||||||||||||||
1457 | - | |||||||||||||||||||||||||
1458 | /*! | - | ||||||||||||||||||||||||
1459 | \qmlproperty real QtQuick::Text::font.wordSpacing | - | ||||||||||||||||||||||||
1460 | - | |||||||||||||||||||||||||
1461 | Sets the word spacing for the font. | - | ||||||||||||||||||||||||
1462 | - | |||||||||||||||||||||||||
1463 | Word spacing changes the default spacing between individual words. | - | ||||||||||||||||||||||||
1464 | A positive value increases the word spacing by a corresponding amount of pixels, | - | ||||||||||||||||||||||||
1465 | while a negative value decreases the inter-word spacing accordingly. | - | ||||||||||||||||||||||||
1466 | */ | - | ||||||||||||||||||||||||
1467 | - | |||||||||||||||||||||||||
1468 | /*! | - | ||||||||||||||||||||||||
1469 | \qmlproperty enumeration QtQuick::Text::font.capitalization | - | ||||||||||||||||||||||||
1470 | - | |||||||||||||||||||||||||
1471 | Sets the capitalization for the text. | - | ||||||||||||||||||||||||
1472 | - | |||||||||||||||||||||||||
1473 | \list | - | ||||||||||||||||||||||||
1474 | \li Font.MixedCase - This is the normal text rendering option where no capitalization change is applied. | - | ||||||||||||||||||||||||
1475 | \li Font.AllUppercase - This alters the text to be rendered in all uppercase type. | - | ||||||||||||||||||||||||
1476 | \li Font.AllLowercase - This alters the text to be rendered in all lowercase type. | - | ||||||||||||||||||||||||
1477 | \li Font.SmallCaps - This alters the text to be rendered in small-caps type. | - | ||||||||||||||||||||||||
1478 | \li Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character. | - | ||||||||||||||||||||||||
1479 | \endlist | - | ||||||||||||||||||||||||
1480 | - | |||||||||||||||||||||||||
1481 | \qml | - | ||||||||||||||||||||||||
1482 | Text { text: "Hello"; font.capitalization: Font.AllLowercase } | - | ||||||||||||||||||||||||
1483 | \endqml | - | ||||||||||||||||||||||||
1484 | */ | - | ||||||||||||||||||||||||
1485 | - | |||||||||||||||||||||||||
1486 | /*! | - | ||||||||||||||||||||||||
1487 | \qmlproperty enumeration QtQuick::Text::font.hintingPreference | - | ||||||||||||||||||||||||
1488 | \since 5.8 | - | ||||||||||||||||||||||||
1489 | - | |||||||||||||||||||||||||
1490 | Sets the preferred hinting on the text. This is a hint to the underlying text rendering system | - | ||||||||||||||||||||||||
1491 | to use a certain level of hinting, and has varying support across platforms. See the table in | - | ||||||||||||||||||||||||
1492 | the documentation for QFont::HintingPreference for more details. | - | ||||||||||||||||||||||||
1493 | - | |||||||||||||||||||||||||
1494 | \note This property only has an effect when used together with render type Text.NativeRendering. | - | ||||||||||||||||||||||||
1495 | - | |||||||||||||||||||||||||
1496 | \list | - | ||||||||||||||||||||||||
1497 | \value Font.PreferDefaultHinting - Use the default hinting level for the target platform. | - | ||||||||||||||||||||||||
1498 | \value Font.PreferNoHinting - If possible, render text without hinting the outlines | - | ||||||||||||||||||||||||
1499 | of the glyphs. The text layout will be typographically accurate, using the same metrics | - | ||||||||||||||||||||||||
1500 | as are used e.g. when printing. | - | ||||||||||||||||||||||||
1501 | \value Font.PreferVerticalHinting - If possible, render text with no horizontal hinting, | - | ||||||||||||||||||||||||
1502 | but align glyphs to the pixel grid in the vertical direction. The text will appear | - | ||||||||||||||||||||||||
1503 | crisper on displays where the density is too low to give an accurate rendering | - | ||||||||||||||||||||||||
1504 | of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's | - | ||||||||||||||||||||||||
1505 | layout will be scalable to higher density devices (such as printers) without impacting | - | ||||||||||||||||||||||||
1506 | details such as line breaks. | - | ||||||||||||||||||||||||
1507 | \value Font.PreferFullHinting - If possible, render text with hinting in both horizontal and | - | ||||||||||||||||||||||||
1508 | vertical directions. The text will be altered to optimize legibility on the target | - | ||||||||||||||||||||||||
1509 | device, but since the metrics will depend on the target size of the text, the positions | - | ||||||||||||||||||||||||
1510 | of glyphs, line breaks, and other typographical detail will not scale, meaning that a | - | ||||||||||||||||||||||||
1511 | text layout may look different on devices with different pixel densities. | - | ||||||||||||||||||||||||
1512 | \endlist | - | ||||||||||||||||||||||||
1513 | - | |||||||||||||||||||||||||
1514 | \qml | - | ||||||||||||||||||||||||
1515 | Text { text: "Hello"; renderType: Text.NativeRendering; font.hintingPreference: Font.PreferVerticalHinting } | - | ||||||||||||||||||||||||
1516 | \endqml | - | ||||||||||||||||||||||||
1517 | */ | - | ||||||||||||||||||||||||
1518 | - | |||||||||||||||||||||||||
1519 | /*! | - | ||||||||||||||||||||||||
1520 | \qmlproperty bool QtQuick::Text::font.kerning | - | ||||||||||||||||||||||||
1521 | \since 5.10 | - | ||||||||||||||||||||||||
1522 | - | |||||||||||||||||||||||||
1523 | Enables or disables the kerning OpenType feature when shaping the text. Disabling this may | - | ||||||||||||||||||||||||
1524 | improve performance when creating or changing the text, at the expense of some cosmetic | - | ||||||||||||||||||||||||
1525 | features. The default value is true. | - | ||||||||||||||||||||||||
1526 | - | |||||||||||||||||||||||||
1527 | \qml | - | ||||||||||||||||||||||||
1528 | Text { text: "OATS FLAVOUR WAY"; font.kerning: false } | - | ||||||||||||||||||||||||
1529 | \endqml | - | ||||||||||||||||||||||||
1530 | */ | - | ||||||||||||||||||||||||
1531 | - | |||||||||||||||||||||||||
1532 | /*! | - | ||||||||||||||||||||||||
1533 | \qmlproperty bool QtQuick::Text::font.preferShaping | - | ||||||||||||||||||||||||
1534 | \since 5.10 | - | ||||||||||||||||||||||||
1535 | - | |||||||||||||||||||||||||
1536 | Sometimes, a font will apply complex rules to a set of characters in order to | - | ||||||||||||||||||||||||
1537 | display them correctly. In some writing systems, such as Brahmic scripts, this is | - | ||||||||||||||||||||||||
1538 | required in order for the text to be legible, but in e.g. Latin script, it is merely | - | ||||||||||||||||||||||||
1539 | a cosmetic feature. Setting the \c preferShaping property to false will disable all | - | ||||||||||||||||||||||||
1540 | such features when they are not required, which will improve performance in most cases. | - | ||||||||||||||||||||||||
1541 | - | |||||||||||||||||||||||||
1542 | The default value is true. | - | ||||||||||||||||||||||||
1543 | - | |||||||||||||||||||||||||
1544 | \qml | - | ||||||||||||||||||||||||
1545 | Text { text: "Some text"; font.preferShaping: false } | - | ||||||||||||||||||||||||
1546 | \endqml | - | ||||||||||||||||||||||||
1547 | */ | - | ||||||||||||||||||||||||
1548 | QFont QQuickText::font() const | - | ||||||||||||||||||||||||
1549 | { | - | ||||||||||||||||||||||||
1550 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1551 | return d->sourceFont; executed 40231 times by 18 tests: return d->sourceFont; Executed by:
| 40231 | ||||||||||||||||||||||||
1552 | } | - | ||||||||||||||||||||||||
1553 | - | |||||||||||||||||||||||||
1554 | void QQuickText::setFont(const QFont &font) | - | ||||||||||||||||||||||||
1555 | { | - | ||||||||||||||||||||||||
1556 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1557 | if (d->sourceFont == font)
| 360-39386 | ||||||||||||||||||||||||
1558 | return; executed 360 times by 7 tests: return; Executed by:
| 360 | ||||||||||||||||||||||||
1559 | - | |||||||||||||||||||||||||
1560 | d->sourceFont = font; | - | ||||||||||||||||||||||||
1561 | QFont oldFont = d->font; | - | ||||||||||||||||||||||||
1562 | d->font = font; | - | ||||||||||||||||||||||||
1563 | - | |||||||||||||||||||||||||
1564 | if (!antialiasing())
| 0-39386 | ||||||||||||||||||||||||
1565 | d->font.setStyleStrategy(QFont::NoAntialias); never executed: d->font.setStyleStrategy(QFont::NoAntialias); | 0 | ||||||||||||||||||||||||
1566 | - | |||||||||||||||||||||||||
1567 | if (d->font.pointSizeF() != -1) {
| 2515-36871 | ||||||||||||||||||||||||
1568 | // 0.5pt resolution | - | ||||||||||||||||||||||||
1569 | qreal size = qRound(d->font.pointSizeF()*2.0); | - | ||||||||||||||||||||||||
1570 | d->font.setPointSizeF(size/2.0); | - | ||||||||||||||||||||||||
1571 | } executed 2515 times by 15 tests: end of block Executed by:
| 2515 | ||||||||||||||||||||||||
1572 | - | |||||||||||||||||||||||||
1573 | if (oldFont != d->font) {
| 1-39385 | ||||||||||||||||||||||||
1574 | // if the format changes the size of the text | - | ||||||||||||||||||||||||
1575 | // with headings or <font> tag, we need to re-parse | - | ||||||||||||||||||||||||
1576 | if (d->formatModifiesFontSize)
| 1196-38189 | ||||||||||||||||||||||||
1577 | d->textHasChanged = true; executed 1196 times by 1 test: d->textHasChanged = true; Executed by:
| 1196 | ||||||||||||||||||||||||
1578 | d->implicitWidthValid = false; | - | ||||||||||||||||||||||||
1579 | d->implicitHeightValid = false; | - | ||||||||||||||||||||||||
1580 | d->updateLayout(); | - | ||||||||||||||||||||||||
1581 | } executed 39385 times by 18 tests: end of block Executed by:
| 39385 | ||||||||||||||||||||||||
1582 | - | |||||||||||||||||||||||||
1583 | emit fontChanged(d->sourceFont); | - | ||||||||||||||||||||||||
1584 | } executed 39386 times by 18 tests: end of block Executed by:
| 39386 | ||||||||||||||||||||||||
1585 | - | |||||||||||||||||||||||||
1586 | void QQuickText::itemChange(ItemChange change, const ItemChangeData &value) | - | ||||||||||||||||||||||||
1587 | { | - | ||||||||||||||||||||||||
1588 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1589 | Q_UNUSED(value); | - | ||||||||||||||||||||||||
1590 | switch (change) { | - | ||||||||||||||||||||||||
1591 | case ItemAntialiasingHasChanged: executed 2 times by 1 test: case ItemAntialiasingHasChanged: Executed by:
| 2 | ||||||||||||||||||||||||
1592 | if (!antialiasing())
| 0-2 | ||||||||||||||||||||||||
1593 | d->font.setStyleStrategy(QFont::NoAntialias); executed 2 times by 1 test: d->font.setStyleStrategy(QFont::NoAntialias); Executed by:
| 2 | ||||||||||||||||||||||||
1594 | else | - | ||||||||||||||||||||||||
1595 | d->font.setStyleStrategy(QFont::PreferAntialias); never executed: d->font.setStyleStrategy(QFont::PreferAntialias); | 0 | ||||||||||||||||||||||||
1596 | d->implicitWidthValid = false; | - | ||||||||||||||||||||||||
1597 | d->implicitHeightValid = false; | - | ||||||||||||||||||||||||
1598 | d->updateLayout(); | - | ||||||||||||||||||||||||
1599 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
1600 | - | |||||||||||||||||||||||||
1601 | case ItemDevicePixelRatioHasChanged: never executed: case ItemDevicePixelRatioHasChanged: | 0 | ||||||||||||||||||||||||
1602 | if (d->renderType == NativeRendering) {
| 0 | ||||||||||||||||||||||||
1603 | // Native rendering optimizes for a given pixel grid, so its results must not be scaled. | - | ||||||||||||||||||||||||
1604 | // Text layout code respects the current device pixel ratio automatically, we only need | - | ||||||||||||||||||||||||
1605 | // to rerun layout after the ratio changed. | - | ||||||||||||||||||||||||
1606 | // Changes of implicit size should be minimal; they are hard to avoid. | - | ||||||||||||||||||||||||
1607 | d->implicitWidthValid = false; | - | ||||||||||||||||||||||||
1608 | d->implicitHeightValid = false; | - | ||||||||||||||||||||||||
1609 | d->updateLayout(); | - | ||||||||||||||||||||||||
1610 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1611 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1612 | - | |||||||||||||||||||||||||
1613 | default: executed 1054500 times by 32 tests: default: Executed by:
| 1054500 | ||||||||||||||||||||||||
1614 | break; executed 1054500 times by 32 tests: break; Executed by:
| 1054500 | ||||||||||||||||||||||||
1615 | } | - | ||||||||||||||||||||||||
1616 | QQuickItem::itemChange(change, value); | - | ||||||||||||||||||||||||
1617 | } executed 1054502 times by 32 tests: end of block Executed by:
| 1054502 | ||||||||||||||||||||||||
1618 | - | |||||||||||||||||||||||||
1619 | /*! | - | ||||||||||||||||||||||||
1620 | \qmlproperty string QtQuick::Text::text | - | ||||||||||||||||||||||||
1621 | - | |||||||||||||||||||||||||
1622 | The text to display. Text supports both plain and rich text strings. | - | ||||||||||||||||||||||||
1623 | - | |||||||||||||||||||||||||
1624 | The item will try to automatically determine whether the text should | - | ||||||||||||||||||||||||
1625 | be treated as styled text. This determination is made using Qt::mightBeRichText(). | - | ||||||||||||||||||||||||
1626 | */ | - | ||||||||||||||||||||||||
1627 | QString QQuickText::text() const | - | ||||||||||||||||||||||||
1628 | { | - | ||||||||||||||||||||||||
1629 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1630 | return d->text; executed 170280 times by 18 tests: return d->text; Executed by:
| 170280 | ||||||||||||||||||||||||
1631 | } | - | ||||||||||||||||||||||||
1632 | - | |||||||||||||||||||||||||
1633 | void QQuickText::setText(const QString &n) | - | ||||||||||||||||||||||||
1634 | { | - | ||||||||||||||||||||||||
1635 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1636 | if (d->text == n)
| 88385-421506 | ||||||||||||||||||||||||
1637 | return; executed 88385 times by 12 tests: return; Executed by:
| 88385 | ||||||||||||||||||||||||
1638 | - | |||||||||||||||||||||||||
1639 | d->richText = d->format == RichText; | - | ||||||||||||||||||||||||
1640 | d->styledText = d->format == StyledText || (d->format == AutoText && Qt::mightBeRichText(n));
| 50-421456 | ||||||||||||||||||||||||
1641 | d->text = n; | - | ||||||||||||||||||||||||
1642 | if (isComponentComplete()) {
| 205093-216413 | ||||||||||||||||||||||||
1643 | if (d->richText) {
| 46-205047 | ||||||||||||||||||||||||
1644 | d->ensureDoc(); | - | ||||||||||||||||||||||||
1645 | d->extra->doc->setText(n); | - | ||||||||||||||||||||||||
1646 | d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft(); | - | ||||||||||||||||||||||||
1647 | } else { executed 46 times by 1 test: end of block Executed by:
| 46 | ||||||||||||||||||||||||
1648 | d->clearFormats(); | - | ||||||||||||||||||||||||
1649 | d->rightToLeftText = d->text.isRightToLeft(); | - | ||||||||||||||||||||||||
1650 | } executed 205047 times by 18 tests: end of block Executed by:
| 205047 | ||||||||||||||||||||||||
1651 | d->determineHorizontalAlignment(); | - | ||||||||||||||||||||||||
1652 | } executed 205093 times by 18 tests: end of block Executed by:
| 205093 | ||||||||||||||||||||||||
1653 | d->textHasChanged = true; | - | ||||||||||||||||||||||||
1654 | d->implicitWidthValid = false; | - | ||||||||||||||||||||||||
1655 | d->implicitHeightValid = false; | - | ||||||||||||||||||||||||
1656 | - | |||||||||||||||||||||||||
1657 | if (d->extra.isAllocated()) {
| 264-421242 | ||||||||||||||||||||||||
1658 | qDeleteAll(d->extra->imgTags); | - | ||||||||||||||||||||||||
1659 | d->extra->imgTags.clear(); | - | ||||||||||||||||||||||||
1660 | } executed 264 times by 1 test: end of block Executed by:
| 264 | ||||||||||||||||||||||||
1661 | d->updateLayout(); | - | ||||||||||||||||||||||||
1662 | setAcceptHoverEvents(d->richText || d->styledText); | - | ||||||||||||||||||||||||
1663 | emit textChanged(d->text); | - | ||||||||||||||||||||||||
1664 | } executed 421506 times by 33 tests: end of block Executed by:
| 421506 | ||||||||||||||||||||||||
1665 | - | |||||||||||||||||||||||||
1666 | /*! | - | ||||||||||||||||||||||||
1667 | \qmlproperty color QtQuick::Text::color | - | ||||||||||||||||||||||||
1668 | - | |||||||||||||||||||||||||
1669 | The text color. | - | ||||||||||||||||||||||||
1670 | - | |||||||||||||||||||||||||
1671 | An example of green text defined using hexadecimal notation: | - | ||||||||||||||||||||||||
1672 | \qml | - | ||||||||||||||||||||||||
1673 | Text { | - | ||||||||||||||||||||||||
1674 | color: "#00FF00" | - | ||||||||||||||||||||||||
1675 | text: "green text" | - | ||||||||||||||||||||||||
1676 | } | - | ||||||||||||||||||||||||
1677 | \endqml | - | ||||||||||||||||||||||||
1678 | - | |||||||||||||||||||||||||
1679 | An example of steel blue text defined using an SVG color name: | - | ||||||||||||||||||||||||
1680 | \qml | - | ||||||||||||||||||||||||
1681 | Text { | - | ||||||||||||||||||||||||
1682 | color: "steelblue" | - | ||||||||||||||||||||||||
1683 | text: "blue text" | - | ||||||||||||||||||||||||
1684 | } | - | ||||||||||||||||||||||||
1685 | \endqml | - | ||||||||||||||||||||||||
1686 | */ | - | ||||||||||||||||||||||||
1687 | QColor QQuickText::color() const | - | ||||||||||||||||||||||||
1688 | { | - | ||||||||||||||||||||||||
1689 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1690 | return QColor::fromRgba(d->color); executed 432 times by 2 tests: return QColor::fromRgba(d->color); Executed by:
| 432 | ||||||||||||||||||||||||
1691 | } | - | ||||||||||||||||||||||||
1692 | - | |||||||||||||||||||||||||
1693 | void QQuickText::setColor(const QColor &color) | - | ||||||||||||||||||||||||
1694 | { | - | ||||||||||||||||||||||||
1695 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1696 | QRgb rgb = color.rgba(); | - | ||||||||||||||||||||||||
1697 | if (d->color == rgb)
| 174-1870 | ||||||||||||||||||||||||
1698 | return; executed 174 times by 5 tests: return; Executed by:
| 174 | ||||||||||||||||||||||||
1699 | - | |||||||||||||||||||||||||
1700 | d->color = rgb; | - | ||||||||||||||||||||||||
1701 | if (isComponentComplete()) {
| 60-1810 | ||||||||||||||||||||||||
1702 | d->updateType = QQuickTextPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
1703 | update(); | - | ||||||||||||||||||||||||
1704 | } executed 60 times by 3 tests: end of block Executed by:
| 60 | ||||||||||||||||||||||||
1705 | emit colorChanged(); | - | ||||||||||||||||||||||||
1706 | } executed 1870 times by 9 tests: end of block Executed by:
| 1870 | ||||||||||||||||||||||||
1707 | - | |||||||||||||||||||||||||
1708 | /*! | - | ||||||||||||||||||||||||
1709 | \qmlproperty color QtQuick::Text::linkColor | - | ||||||||||||||||||||||||
1710 | - | |||||||||||||||||||||||||
1711 | The color of links in the text. | - | ||||||||||||||||||||||||
1712 | - | |||||||||||||||||||||||||
1713 | This property works with the StyledText \l textFormat, but not with RichText. | - | ||||||||||||||||||||||||
1714 | Link color in RichText can be specified by including CSS style tags in the | - | ||||||||||||||||||||||||
1715 | text. | - | ||||||||||||||||||||||||
1716 | */ | - | ||||||||||||||||||||||||
1717 | - | |||||||||||||||||||||||||
1718 | QColor QQuickText::linkColor() const | - | ||||||||||||||||||||||||
1719 | { | - | ||||||||||||||||||||||||
1720 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1721 | return QColor::fromRgba(d->linkColor); executed 430 times by 2 tests: return QColor::fromRgba(d->linkColor); Executed by:
| 430 | ||||||||||||||||||||||||
1722 | } | - | ||||||||||||||||||||||||
1723 | - | |||||||||||||||||||||||||
1724 | void QQuickText::setLinkColor(const QColor &color) | - | ||||||||||||||||||||||||
1725 | { | - | ||||||||||||||||||||||||
1726 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1727 | QRgb rgb = color.rgba(); | - | ||||||||||||||||||||||||
1728 | if (d->linkColor == rgb)
| 26-364 | ||||||||||||||||||||||||
1729 | return; executed 26 times by 1 test: return; Executed by:
| 26 | ||||||||||||||||||||||||
1730 | - | |||||||||||||||||||||||||
1731 | d->linkColor = rgb; | - | ||||||||||||||||||||||||
1732 | if (isComponentComplete()) {
| 50-314 | ||||||||||||||||||||||||
1733 | d->updateType = QQuickTextPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
1734 | update(); | - | ||||||||||||||||||||||||
1735 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||||||||
1736 | emit linkColorChanged(); | - | ||||||||||||||||||||||||
1737 | } executed 364 times by 1 test: end of block Executed by:
| 364 | ||||||||||||||||||||||||
1738 | - | |||||||||||||||||||||||||
1739 | /*! | - | ||||||||||||||||||||||||
1740 | \qmlproperty enumeration QtQuick::Text::style | - | ||||||||||||||||||||||||
1741 | - | |||||||||||||||||||||||||
1742 | Set an additional text style. | - | ||||||||||||||||||||||||
1743 | - | |||||||||||||||||||||||||
1744 | Supported text styles are: | - | ||||||||||||||||||||||||
1745 | \list | - | ||||||||||||||||||||||||
1746 | \li Text.Normal - the default | - | ||||||||||||||||||||||||
1747 | \li Text.Outline | - | ||||||||||||||||||||||||
1748 | \li Text.Raised | - | ||||||||||||||||||||||||
1749 | \li Text.Sunken | - | ||||||||||||||||||||||||
1750 | \endlist | - | ||||||||||||||||||||||||
1751 | - | |||||||||||||||||||||||||
1752 | \qml | - | ||||||||||||||||||||||||
1753 | Row { | - | ||||||||||||||||||||||||
1754 | Text { font.pointSize: 24; text: "Normal" } | - | ||||||||||||||||||||||||
1755 | Text { font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" } | - | ||||||||||||||||||||||||
1756 | Text { font.pointSize: 24; text: "Outline";style: Text.Outline; styleColor: "red" } | - | ||||||||||||||||||||||||
1757 | Text { font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" } | - | ||||||||||||||||||||||||
1758 | } | - | ||||||||||||||||||||||||
1759 | \endqml | - | ||||||||||||||||||||||||
1760 | - | |||||||||||||||||||||||||
1761 | \image declarative-textstyle.png | - | ||||||||||||||||||||||||
1762 | */ | - | ||||||||||||||||||||||||
1763 | QQuickText::TextStyle QQuickText::style() const | - | ||||||||||||||||||||||||
1764 | { | - | ||||||||||||||||||||||||
1765 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1766 | return d->style; executed 24 times by 2 tests: return d->style; Executed by:
| 24 | ||||||||||||||||||||||||
1767 | } | - | ||||||||||||||||||||||||
1768 | - | |||||||||||||||||||||||||
1769 | void QQuickText::setStyle(QQuickText::TextStyle style) | - | ||||||||||||||||||||||||
1770 | { | - | ||||||||||||||||||||||||
1771 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1772 | if (d->style == style)
| 2-80 | ||||||||||||||||||||||||
1773 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||||||||
1774 | - | |||||||||||||||||||||||||
1775 | d->style = style; | - | ||||||||||||||||||||||||
1776 | if (isComponentComplete()) {
| 4-76 | ||||||||||||||||||||||||
1777 | d->updateType = QQuickTextPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
1778 | update(); | - | ||||||||||||||||||||||||
1779 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1780 | emit styleChanged(d->style); | - | ||||||||||||||||||||||||
1781 | } executed 80 times by 3 tests: end of block Executed by:
| 80 | ||||||||||||||||||||||||
1782 | - | |||||||||||||||||||||||||
1783 | /*! | - | ||||||||||||||||||||||||
1784 | \qmlproperty color QtQuick::Text::styleColor | - | ||||||||||||||||||||||||
1785 | - | |||||||||||||||||||||||||
1786 | Defines the secondary color used by text styles. | - | ||||||||||||||||||||||||
1787 | - | |||||||||||||||||||||||||
1788 | \c styleColor is used as the outline color for outlined text, and as the | - | ||||||||||||||||||||||||
1789 | shadow color for raised or sunken text. If no style has been set, it is not | - | ||||||||||||||||||||||||
1790 | used at all. | - | ||||||||||||||||||||||||
1791 | - | |||||||||||||||||||||||||
1792 | \qml | - | ||||||||||||||||||||||||
1793 | Text { font.pointSize: 18; text: "hello"; style: Text.Raised; styleColor: "gray" } | - | ||||||||||||||||||||||||
1794 | \endqml | - | ||||||||||||||||||||||||
1795 | - | |||||||||||||||||||||||||
1796 | \sa style | - | ||||||||||||||||||||||||
1797 | */ | - | ||||||||||||||||||||||||
1798 | QColor QQuickText::styleColor() const | - | ||||||||||||||||||||||||
1799 | { | - | ||||||||||||||||||||||||
1800 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1801 | return QColor::fromRgba(d->styleColor); executed 390 times by 2 tests: return QColor::fromRgba(d->styleColor); Executed by:
| 390 | ||||||||||||||||||||||||
1802 | } | - | ||||||||||||||||||||||||
1803 | - | |||||||||||||||||||||||||
1804 | void QQuickText::setStyleColor(const QColor &color) | - | ||||||||||||||||||||||||
1805 | { | - | ||||||||||||||||||||||||
1806 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1807 | QRgb rgb = color.rgba(); | - | ||||||||||||||||||||||||
1808 | if (d->styleColor == rgb)
| 64-332 | ||||||||||||||||||||||||
1809 | return; executed 64 times by 3 tests: return; Executed by:
| 64 | ||||||||||||||||||||||||
1810 | - | |||||||||||||||||||||||||
1811 | d->styleColor = rgb; | - | ||||||||||||||||||||||||
1812 | if (isComponentComplete()) {
| 2-330 | ||||||||||||||||||||||||
1813 | d->updateType = QQuickTextPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
1814 | update(); | - | ||||||||||||||||||||||||
1815 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1816 | emit styleColorChanged(); | - | ||||||||||||||||||||||||
1817 | } executed 332 times by 2 tests: end of block Executed by:
| 332 | ||||||||||||||||||||||||
1818 | - | |||||||||||||||||||||||||
1819 | /*! | - | ||||||||||||||||||||||||
1820 | \qmlproperty enumeration QtQuick::Text::horizontalAlignment | - | ||||||||||||||||||||||||
1821 | \qmlproperty enumeration QtQuick::Text::verticalAlignment | - | ||||||||||||||||||||||||
1822 | \qmlproperty enumeration QtQuick::Text::effectiveHorizontalAlignment | - | ||||||||||||||||||||||||
1823 | - | |||||||||||||||||||||||||
1824 | Sets the horizontal and vertical alignment of the text within the Text items | - | ||||||||||||||||||||||||
1825 | width and height. By default, the text is vertically aligned to the top. Horizontal | - | ||||||||||||||||||||||||
1826 | alignment follows the natural alignment of the text, for example text that is read | - | ||||||||||||||||||||||||
1827 | from left to right will be aligned to the left. | - | ||||||||||||||||||||||||
1828 | - | |||||||||||||||||||||||||
1829 | The valid values for \c horizontalAlignment are \c Text.AlignLeft, \c Text.AlignRight, \c Text.AlignHCenter and | - | ||||||||||||||||||||||||
1830 | \c Text.AlignJustify. The valid values for \c verticalAlignment are \c Text.AlignTop, \c Text.AlignBottom | - | ||||||||||||||||||||||||
1831 | and \c Text.AlignVCenter. | - | ||||||||||||||||||||||||
1832 | - | |||||||||||||||||||||||||
1833 | Note that for a single line of text, the size of the text is the area of the text. In this common case, | - | ||||||||||||||||||||||||
1834 | all alignments are equivalent. If you want the text to be, say, centered in its parent, then you will | - | ||||||||||||||||||||||||
1835 | need to either modify the Item::anchors, or set horizontalAlignment to Text.AlignHCenter and bind the width to | - | ||||||||||||||||||||||||
1836 | that of the parent. | - | ||||||||||||||||||||||||
1837 | - | |||||||||||||||||||||||||
1838 | When using the attached property LayoutMirroring::enabled to mirror application | - | ||||||||||||||||||||||||
1839 | layouts, the horizontal alignment of text will also be mirrored. However, the property | - | ||||||||||||||||||||||||
1840 | \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment | - | ||||||||||||||||||||||||
1841 | of Text, use the read-only property \c effectiveHorizontalAlignment. | - | ||||||||||||||||||||||||
1842 | */ | - | ||||||||||||||||||||||||
1843 | QQuickText::HAlignment QQuickText::hAlign() const | - | ||||||||||||||||||||||||
1844 | { | - | ||||||||||||||||||||||||
1845 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1846 | return d->hAlign; executed 164 times by 3 tests: return d->hAlign; Executed by:
| 164 | ||||||||||||||||||||||||
1847 | } | - | ||||||||||||||||||||||||
1848 | - | |||||||||||||||||||||||||
1849 | void QQuickText::setHAlign(HAlignment align) | - | ||||||||||||||||||||||||
1850 | { | - | ||||||||||||||||||||||||
1851 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1852 | bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror;
| 2-481 | ||||||||||||||||||||||||
1853 | d->hAlignImplicit = false; | - | ||||||||||||||||||||||||
1854 | if (d->setHAlign(align, forceAlign) && isComponentComplete())
| 46-477 | ||||||||||||||||||||||||
1855 | d->updateLayout(); executed 48 times by 2 tests: d->updateLayout(); Executed by:
| 48 | ||||||||||||||||||||||||
1856 | } executed 523 times by 5 tests: end of block Executed by:
| 523 | ||||||||||||||||||||||||
1857 | - | |||||||||||||||||||||||||
1858 | void QQuickText::resetHAlign() | - | ||||||||||||||||||||||||
1859 | { | - | ||||||||||||||||||||||||
1860 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1861 | d->hAlignImplicit = true; | - | ||||||||||||||||||||||||
1862 | if (isComponentComplete() && d->determineHorizontalAlignment())
| 2-56 | ||||||||||||||||||||||||
1863 | d->updateLayout(); executed 4 times by 1 test: d->updateLayout(); Executed by:
| 4 | ||||||||||||||||||||||||
1864 | } executed 62 times by 2 tests: end of block Executed by:
| 62 | ||||||||||||||||||||||||
1865 | - | |||||||||||||||||||||||||
1866 | QQuickText::HAlignment QQuickText::effectiveHAlign() const | - | ||||||||||||||||||||||||
1867 | { | - | ||||||||||||||||||||||||
1868 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1869 | QQuickText::HAlignment effectiveAlignment = d->hAlign; | - | ||||||||||||||||||||||||
1870 | if (!d->hAlignImplicit && d->effectiveLayoutMirror) {
| 174-1311756 | ||||||||||||||||||||||||
1871 | switch (d->hAlign) { | - | ||||||||||||||||||||||||
1872 | case QQuickText::AlignLeft: executed 122 times by 2 tests: case QQuickText::AlignLeft: Executed by:
| 122 | ||||||||||||||||||||||||
1873 | effectiveAlignment = QQuickText::AlignRight; | - | ||||||||||||||||||||||||
1874 | break; executed 122 times by 2 tests: break; Executed by:
| 122 | ||||||||||||||||||||||||
1875 | case QQuickText::AlignRight: executed 52 times by 1 test: case QQuickText::AlignRight: Executed by:
| 52 | ||||||||||||||||||||||||
1876 | effectiveAlignment = QQuickText::AlignLeft; | - | ||||||||||||||||||||||||
1877 | break; executed 52 times by 1 test: break; Executed by:
| 52 | ||||||||||||||||||||||||
1878 | default: never executed: default: | 0 | ||||||||||||||||||||||||
1879 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1880 | } | - | ||||||||||||||||||||||||
1881 | } | - | ||||||||||||||||||||||||
1882 | return effectiveAlignment; executed 1314785 times by 33 tests: return effectiveAlignment; Executed by:
| 1314785 | ||||||||||||||||||||||||
1883 | } | - | ||||||||||||||||||||||||
1884 | - | |||||||||||||||||||||||||
1885 | bool QQuickTextPrivate::setHAlign(QQuickText::HAlignment alignment, bool forceAlign) | - | ||||||||||||||||||||||||
1886 | { | - | ||||||||||||||||||||||||
1887 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
1888 | if (hAlign != alignment || forceAlign) {
| 2-469304 | ||||||||||||||||||||||||
1889 | QQuickText::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); | - | ||||||||||||||||||||||||
1890 | hAlign = alignment; | - | ||||||||||||||||||||||||
1891 | - | |||||||||||||||||||||||||
1892 | emit q->horizontalAlignmentChanged(hAlign); | - | ||||||||||||||||||||||||
1893 | if (oldEffectiveHAlign != q->effectiveHAlign())
| 2-511 | ||||||||||||||||||||||||
1894 | emit q->effectiveHorizontalAlignmentChanged(); executed 511 times by 5 tests: q->effectiveHorizontalAlignmentChanged(); Executed by:
| 511 | ||||||||||||||||||||||||
1895 | return true; executed 513 times by 5 tests: return true; Executed by:
| 513 | ||||||||||||||||||||||||
1896 | } | - | ||||||||||||||||||||||||
1897 | return false; executed 469302 times by 34 tests: return false; Executed by:
| 469302 | ||||||||||||||||||||||||
1898 | } | - | ||||||||||||||||||||||||
1899 | - | |||||||||||||||||||||||||
1900 | bool QQuickTextPrivate::determineHorizontalAlignment() | - | ||||||||||||||||||||||||
1901 | { | - | ||||||||||||||||||||||||
1902 | if (hAlignImplicit) {
| 503-469292 | ||||||||||||||||||||||||
1903 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
1904 | bool alignToRight = text.isEmpty() ? QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft : rightToLeftText;
| 48613-420679 | ||||||||||||||||||||||||
1905 | #else | - | ||||||||||||||||||||||||
1906 | bool alignToRight = rightToLeftText; | - | ||||||||||||||||||||||||
1907 | #endif | - | ||||||||||||||||||||||||
1908 | return setHAlign(alignToRight ? QQuickText::AlignRight : QQuickText::AlignLeft); executed 469292 times by 34 tests: return setHAlign(alignToRight ? QQuickText::AlignRight : QQuickText::AlignLeft); Executed by:
| 469292 | ||||||||||||||||||||||||
1909 | } | - | ||||||||||||||||||||||||
1910 | return false; executed 503 times by 5 tests: return false; Executed by:
| 503 | ||||||||||||||||||||||||
1911 | } | - | ||||||||||||||||||||||||
1912 | - | |||||||||||||||||||||||||
1913 | void QQuickTextPrivate::mirrorChange() | - | ||||||||||||||||||||||||
1914 | { | - | ||||||||||||||||||||||||
1915 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
1916 | if (q->isComponentComplete()) {
| 14-20 | ||||||||||||||||||||||||
1917 | if (!hAlignImplicit && (hAlign == QQuickText::AlignRight || hAlign == QQuickText::AlignLeft)) {
| 0-8 | ||||||||||||||||||||||||
1918 | updateLayout(); | - | ||||||||||||||||||||||||
1919 | emit q->effectiveHorizontalAlignmentChanged(); | - | ||||||||||||||||||||||||
1920 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1921 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||||||||
1922 | } executed 34 times by 3 tests: end of block Executed by:
| 34 | ||||||||||||||||||||||||
1923 | - | |||||||||||||||||||||||||
1924 | QQuickText::VAlignment QQuickText::vAlign() const | - | ||||||||||||||||||||||||
1925 | { | - | ||||||||||||||||||||||||
1926 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1927 | return d->vAlign; executed 40 times by 2 tests: return d->vAlign; Executed by:
| 40 | ||||||||||||||||||||||||
1928 | } | - | ||||||||||||||||||||||||
1929 | - | |||||||||||||||||||||||||
1930 | void QQuickText::setVAlign(VAlignment align) | - | ||||||||||||||||||||||||
1931 | { | - | ||||||||||||||||||||||||
1932 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1933 | if (d->vAlign == align)
| 20-435 | ||||||||||||||||||||||||
1934 | return; executed 20 times by 1 test: return; Executed by:
| 20 | ||||||||||||||||||||||||
1935 | - | |||||||||||||||||||||||||
1936 | d->vAlign = align; | - | ||||||||||||||||||||||||
1937 | - | |||||||||||||||||||||||||
1938 | if (isComponentComplete())
| 6-429 | ||||||||||||||||||||||||
1939 | d->updateLayout(); executed 6 times by 1 test: d->updateLayout(); Executed by:
| 6 | ||||||||||||||||||||||||
1940 | - | |||||||||||||||||||||||||
1941 | emit verticalAlignmentChanged(align); | - | ||||||||||||||||||||||||
1942 | } executed 435 times by 4 tests: end of block Executed by:
| 435 | ||||||||||||||||||||||||
1943 | - | |||||||||||||||||||||||||
1944 | /*! | - | ||||||||||||||||||||||||
1945 | \qmlproperty enumeration QtQuick::Text::wrapMode | - | ||||||||||||||||||||||||
1946 | - | |||||||||||||||||||||||||
1947 | Set this property to wrap the text to the Text item's width. The text will only | - | ||||||||||||||||||||||||
1948 | wrap if an explicit width has been set. wrapMode can be one of: | - | ||||||||||||||||||||||||
1949 | - | |||||||||||||||||||||||||
1950 | \list | - | ||||||||||||||||||||||||
1951 | \li Text.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then \l contentWidth will exceed a set width. | - | ||||||||||||||||||||||||
1952 | \li Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, \l contentWidth will exceed a set width. | - | ||||||||||||||||||||||||
1953 | \li Text.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word. | - | ||||||||||||||||||||||||
1954 | \li Text.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. | - | ||||||||||||||||||||||||
1955 | \endlist | - | ||||||||||||||||||||||||
1956 | */ | - | ||||||||||||||||||||||||
1957 | QQuickText::WrapMode QQuickText::wrapMode() const | - | ||||||||||||||||||||||||
1958 | { | - | ||||||||||||||||||||||||
1959 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1960 | return d->wrapMode; executed 246 times by 2 tests: return d->wrapMode; Executed by:
| 246 | ||||||||||||||||||||||||
1961 | } | - | ||||||||||||||||||||||||
1962 | - | |||||||||||||||||||||||||
1963 | void QQuickText::setWrapMode(WrapMode mode) | - | ||||||||||||||||||||||||
1964 | { | - | ||||||||||||||||||||||||
1965 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
1966 | if (mode == d->wrapMode)
| 34-380 | ||||||||||||||||||||||||
1967 | return; executed 34 times by 1 test: return; Executed by:
| 34 | ||||||||||||||||||||||||
1968 | - | |||||||||||||||||||||||||
1969 | d->wrapMode = mode; | - | ||||||||||||||||||||||||
1970 | d->updateLayout(); | - | ||||||||||||||||||||||||
1971 | - | |||||||||||||||||||||||||
1972 | emit wrapModeChanged(); | - | ||||||||||||||||||||||||
1973 | } executed 380 times by 3 tests: end of block Executed by:
| 380 | ||||||||||||||||||||||||
1974 | - | |||||||||||||||||||||||||
1975 | /*! | - | ||||||||||||||||||||||||
1976 | \qmlproperty int QtQuick::Text::lineCount | - | ||||||||||||||||||||||||
1977 | - | |||||||||||||||||||||||||
1978 | Returns the number of lines visible in the text item. | - | ||||||||||||||||||||||||
1979 | - | |||||||||||||||||||||||||
1980 | This property is not supported for rich text. | - | ||||||||||||||||||||||||
1981 | - | |||||||||||||||||||||||||
1982 | \sa maximumLineCount | - | ||||||||||||||||||||||||
1983 | */ | - | ||||||||||||||||||||||||
1984 | int QQuickText::lineCount() const | - | ||||||||||||||||||||||||
1985 | { | - | ||||||||||||||||||||||||
1986 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
1987 | return d->lineCount; executed 76 times by 2 tests: return d->lineCount; Executed by:
| 76 | ||||||||||||||||||||||||
1988 | } | - | ||||||||||||||||||||||||
1989 | - | |||||||||||||||||||||||||
1990 | /*! | - | ||||||||||||||||||||||||
1991 | \qmlproperty bool QtQuick::Text::truncated | - | ||||||||||||||||||||||||
1992 | - | |||||||||||||||||||||||||
1993 | Returns true if the text has been truncated due to \l maximumLineCount | - | ||||||||||||||||||||||||
1994 | or \l elide. | - | ||||||||||||||||||||||||
1995 | - | |||||||||||||||||||||||||
1996 | This property is not supported for rich text. | - | ||||||||||||||||||||||||
1997 | - | |||||||||||||||||||||||||
1998 | \sa maximumLineCount, elide | - | ||||||||||||||||||||||||
1999 | */ | - | ||||||||||||||||||||||||
2000 | bool QQuickText::truncated() const | - | ||||||||||||||||||||||||
2001 | { | - | ||||||||||||||||||||||||
2002 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2003 | return d->truncated; executed 172 times by 2 tests: return d->truncated; Executed by:
| 172 | ||||||||||||||||||||||||
2004 | } | - | ||||||||||||||||||||||||
2005 | - | |||||||||||||||||||||||||
2006 | /*! | - | ||||||||||||||||||||||||
2007 | \qmlproperty int QtQuick::Text::maximumLineCount | - | ||||||||||||||||||||||||
2008 | - | |||||||||||||||||||||||||
2009 | Set this property to limit the number of lines that the text item will show. | - | ||||||||||||||||||||||||
2010 | If elide is set to Text.ElideRight, the text will be elided appropriately. | - | ||||||||||||||||||||||||
2011 | By default, this is the value of the largest possible integer. | - | ||||||||||||||||||||||||
2012 | - | |||||||||||||||||||||||||
2013 | This property is not supported for rich text. | - | ||||||||||||||||||||||||
2014 | - | |||||||||||||||||||||||||
2015 | \sa lineCount, elide | - | ||||||||||||||||||||||||
2016 | */ | - | ||||||||||||||||||||||||
2017 | int QQuickText::maximumLineCount() const | - | ||||||||||||||||||||||||
2018 | { | - | ||||||||||||||||||||||||
2019 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2020 | return d->maximumLineCount(); executed 24 times by 2 tests: return d->maximumLineCount(); Executed by:
| 24 | ||||||||||||||||||||||||
2021 | } | - | ||||||||||||||||||||||||
2022 | - | |||||||||||||||||||||||||
2023 | void QQuickText::setMaximumLineCount(int lines) | - | ||||||||||||||||||||||||
2024 | { | - | ||||||||||||||||||||||||
2025 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2026 | - | |||||||||||||||||||||||||
2027 | d->maximumLineCountValid = lines==INT_MAX ? false : true;
| 8-58 | ||||||||||||||||||||||||
2028 | if (d->maximumLineCount() != lines) {
| 2-64 | ||||||||||||||||||||||||
2029 | d->extra.value().maximumLineCount = lines; | - | ||||||||||||||||||||||||
2030 | d->implicitHeightValid = false; | - | ||||||||||||||||||||||||
2031 | d->updateLayout(); | - | ||||||||||||||||||||||||
2032 | emit maximumLineCountChanged(); | - | ||||||||||||||||||||||||
2033 | } executed 64 times by 1 test: end of block Executed by:
| 64 | ||||||||||||||||||||||||
2034 | } executed 66 times by 1 test: end of block Executed by:
| 66 | ||||||||||||||||||||||||
2035 | - | |||||||||||||||||||||||||
2036 | void QQuickText::resetMaximumLineCount() | - | ||||||||||||||||||||||||
2037 | { | - | ||||||||||||||||||||||||
2038 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2039 | setMaximumLineCount(INT_MAX); | - | ||||||||||||||||||||||||
2040 | if (d->truncated != false) {
| 0-8 | ||||||||||||||||||||||||
2041 | d->truncated = false; | - | ||||||||||||||||||||||||
2042 | emit truncatedChanged(); | - | ||||||||||||||||||||||||
2043 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2044 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
2045 | - | |||||||||||||||||||||||||
2046 | /*! | - | ||||||||||||||||||||||||
2047 | \qmlproperty enumeration QtQuick::Text::textFormat | - | ||||||||||||||||||||||||
2048 | - | |||||||||||||||||||||||||
2049 | The way the text property should be displayed. | - | ||||||||||||||||||||||||
2050 | - | |||||||||||||||||||||||||
2051 | Supported text formats are: | - | ||||||||||||||||||||||||
2052 | - | |||||||||||||||||||||||||
2053 | \list | - | ||||||||||||||||||||||||
2054 | \li Text.AutoText (default) | - | ||||||||||||||||||||||||
2055 | \li Text.PlainText | - | ||||||||||||||||||||||||
2056 | \li Text.StyledText | - | ||||||||||||||||||||||||
2057 | \li Text.RichText | - | ||||||||||||||||||||||||
2058 | \endlist | - | ||||||||||||||||||||||||
2059 | - | |||||||||||||||||||||||||
2060 | If the text format is \c Text.AutoText the Text item | - | ||||||||||||||||||||||||
2061 | will automatically determine whether the text should be treated as | - | ||||||||||||||||||||||||
2062 | styled text. This determination is made using Qt::mightBeRichText() | - | ||||||||||||||||||||||||
2063 | which uses a fast and therefore simple heuristic. It mainly checks | - | ||||||||||||||||||||||||
2064 | whether there is something that looks like a tag before the first | - | ||||||||||||||||||||||||
2065 | line break. Although the result may be correct for common cases, | - | ||||||||||||||||||||||||
2066 | there is no guarantee. | - | ||||||||||||||||||||||||
2067 | - | |||||||||||||||||||||||||
2068 | Text.StyledText is an optimized format supporting some basic text | - | ||||||||||||||||||||||||
2069 | styling markup, in the style of HTML 3.2: | - | ||||||||||||||||||||||||
2070 | - | |||||||||||||||||||||||||
2071 | \code | - | ||||||||||||||||||||||||
2072 | <b></b> - bold | - | ||||||||||||||||||||||||
2073 | <strong></strong> - bold | - | ||||||||||||||||||||||||
2074 | <i></i> - italic | - | ||||||||||||||||||||||||
2075 | <br> - new line | - | ||||||||||||||||||||||||
2076 | <p> - paragraph | - | ||||||||||||||||||||||||
2077 | <u> - underlined text | - | ||||||||||||||||||||||||
2078 | <font color="color_name" size="1-7"></font> | - | ||||||||||||||||||||||||
2079 | <h1> to <h6> - headers | - | ||||||||||||||||||||||||
2080 | <a href=""> - anchor | - | ||||||||||||||||||||||||
2081 | <img src="" align="top,middle,bottom" width="" height=""> - inline images | - | ||||||||||||||||||||||||
2082 | <ol type="">, <ul type=""> and <li> - ordered and unordered lists | - | ||||||||||||||||||||||||
2083 | <pre></pre> - preformatted | - | ||||||||||||||||||||||||
2084 | > < & | - | ||||||||||||||||||||||||
2085 | \endcode | - | ||||||||||||||||||||||||
2086 | - | |||||||||||||||||||||||||
2087 | \c Text.StyledText parser is strict, requiring tags to be correctly nested. | - | ||||||||||||||||||||||||
2088 | - | |||||||||||||||||||||||||
2089 | \table | - | ||||||||||||||||||||||||
2090 | \row | - | ||||||||||||||||||||||||
2091 | \li | - | ||||||||||||||||||||||||
2092 | \qml | - | ||||||||||||||||||||||||
2093 | Column { | - | ||||||||||||||||||||||||
2094 | Text { | - | ||||||||||||||||||||||||
2095 | font.pointSize: 24 | - | ||||||||||||||||||||||||
2096 | text: "<b>Hello</b> <i>World!</i>" | - | ||||||||||||||||||||||||
2097 | } | - | ||||||||||||||||||||||||
2098 | Text { | - | ||||||||||||||||||||||||
2099 | font.pointSize: 24 | - | ||||||||||||||||||||||||
2100 | textFormat: Text.RichText | - | ||||||||||||||||||||||||
2101 | text: "<b>Hello</b> <i>World!</i>" | - | ||||||||||||||||||||||||
2102 | } | - | ||||||||||||||||||||||||
2103 | Text { | - | ||||||||||||||||||||||||
2104 | font.pointSize: 24 | - | ||||||||||||||||||||||||
2105 | textFormat: Text.PlainText | - | ||||||||||||||||||||||||
2106 | text: "<b>Hello</b> <i>World!</i>" | - | ||||||||||||||||||||||||
2107 | } | - | ||||||||||||||||||||||||
2108 | } | - | ||||||||||||||||||||||||
2109 | \endqml | - | ||||||||||||||||||||||||
2110 | \li \image declarative-textformat.png | - | ||||||||||||||||||||||||
2111 | \endtable | - | ||||||||||||||||||||||||
2112 | - | |||||||||||||||||||||||||
2113 | Text.RichText supports a larger subset of HTML 4, as described on the | - | ||||||||||||||||||||||||
2114 | \l {Supported HTML Subset} page. You should prefer using Text.PlainText | - | ||||||||||||||||||||||||
2115 | or Text.StyledText instead, as they offer better performance. | - | ||||||||||||||||||||||||
2116 | */ | - | ||||||||||||||||||||||||
2117 | QQuickText::TextFormat QQuickText::textFormat() const | - | ||||||||||||||||||||||||
2118 | { | - | ||||||||||||||||||||||||
2119 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2120 | return d->format; executed 38 times by 2 tests: return d->format; Executed by:
| 38 | ||||||||||||||||||||||||
2121 | } | - | ||||||||||||||||||||||||
2122 | - | |||||||||||||||||||||||||
2123 | void QQuickText::setTextFormat(TextFormat format) | - | ||||||||||||||||||||||||
2124 | { | - | ||||||||||||||||||||||||
2125 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2126 | if (format == d->format)
| 4-256 | ||||||||||||||||||||||||
2127 | return; executed 4 times by 2 tests: return; Executed by:
| 4 | ||||||||||||||||||||||||
2128 | d->format = format; | - | ||||||||||||||||||||||||
2129 | bool wasRich = d->richText; | - | ||||||||||||||||||||||||
2130 | d->richText = format == RichText; | - | ||||||||||||||||||||||||
2131 | d->styledText = format == StyledText || (format == AutoText && Qt::mightBeRichText(d->text));
| 2-198 | ||||||||||||||||||||||||
2132 | - | |||||||||||||||||||||||||
2133 | if (isComponentComplete()) {
| 18-238 | ||||||||||||||||||||||||
2134 | if (!wasRich && d->richText) {
| 2-16 | ||||||||||||||||||||||||
2135 | d->ensureDoc(); | - | ||||||||||||||||||||||||
2136 | d->extra->doc->setText(d->text); | - | ||||||||||||||||||||||||
2137 | d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft(); | - | ||||||||||||||||||||||||
2138 | } else { executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2139 | d->clearFormats(); | - | ||||||||||||||||||||||||
2140 | d->rightToLeftText = d->text.isRightToLeft(); | - | ||||||||||||||||||||||||
2141 | d->textHasChanged = true; | - | ||||||||||||||||||||||||
2142 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
2143 | d->determineHorizontalAlignment(); | - | ||||||||||||||||||||||||
2144 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
2145 | d->updateLayout(); | - | ||||||||||||||||||||||||
2146 | setAcceptHoverEvents(d->richText || d->styledText); | - | ||||||||||||||||||||||||
2147 | setAcceptedMouseButtons(d->richText || d->styledText ? Qt::LeftButton : Qt::NoButton); | - | ||||||||||||||||||||||||
2148 | - | |||||||||||||||||||||||||
2149 | emit textFormatChanged(d->format); | - | ||||||||||||||||||||||||
2150 | } executed 256 times by 3 tests: end of block Executed by:
| 256 | ||||||||||||||||||||||||
2151 | - | |||||||||||||||||||||||||
2152 | /*! | - | ||||||||||||||||||||||||
2153 | \qmlproperty enumeration QtQuick::Text::elide | - | ||||||||||||||||||||||||
2154 | - | |||||||||||||||||||||||||
2155 | Set this property to elide parts of the text fit to the Text item's width. | - | ||||||||||||||||||||||||
2156 | The text will only elide if an explicit width has been set. | - | ||||||||||||||||||||||||
2157 | - | |||||||||||||||||||||||||
2158 | This property cannot be used with rich text. | - | ||||||||||||||||||||||||
2159 | - | |||||||||||||||||||||||||
2160 | Eliding can be: | - | ||||||||||||||||||||||||
2161 | \list | - | ||||||||||||||||||||||||
2162 | \li Text.ElideNone - the default | - | ||||||||||||||||||||||||
2163 | \li Text.ElideLeft | - | ||||||||||||||||||||||||
2164 | \li Text.ElideMiddle | - | ||||||||||||||||||||||||
2165 | \li Text.ElideRight | - | ||||||||||||||||||||||||
2166 | \endlist | - | ||||||||||||||||||||||||
2167 | - | |||||||||||||||||||||||||
2168 | If this property is set to Text.ElideRight, it can be used with \l {wrapMode}{wrapped} | - | ||||||||||||||||||||||||
2169 | text. The text will only elide if \c maximumLineCount, or \c height has been set. | - | ||||||||||||||||||||||||
2170 | If both \c maximumLineCount and \c height are set, \c maximumLineCount will | - | ||||||||||||||||||||||||
2171 | apply unless the lines do not fit in the height allowed. | - | ||||||||||||||||||||||||
2172 | - | |||||||||||||||||||||||||
2173 | If the text is a multi-length string, and the mode is not \c Text.ElideNone, | - | ||||||||||||||||||||||||
2174 | the first string that fits will be used, otherwise the last will be elided. | - | ||||||||||||||||||||||||
2175 | - | |||||||||||||||||||||||||
2176 | Multi-length strings are ordered from longest to shortest, separated by the | - | ||||||||||||||||||||||||
2177 | Unicode "String Terminator" character \c U009C (write this in QML with \c{"\u009C"} or \c{"\x9C"}). | - | ||||||||||||||||||||||||
2178 | */ | - | ||||||||||||||||||||||||
2179 | QQuickText::TextElideMode QQuickText::elideMode() const | - | ||||||||||||||||||||||||
2180 | { | - | ||||||||||||||||||||||||
2181 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2182 | return d->elideMode; executed 56 times by 2 tests: return d->elideMode; Executed by:
| 56 | ||||||||||||||||||||||||
2183 | } | - | ||||||||||||||||||||||||
2184 | - | |||||||||||||||||||||||||
2185 | void QQuickText::setElideMode(QQuickText::TextElideMode mode) | - | ||||||||||||||||||||||||
2186 | { | - | ||||||||||||||||||||||||
2187 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2188 | if (mode == d->elideMode)
| 42-320 | ||||||||||||||||||||||||
2189 | return; executed 42 times by 1 test: return; Executed by:
| 42 | ||||||||||||||||||||||||
2190 | - | |||||||||||||||||||||||||
2191 | d->elideMode = mode; | - | ||||||||||||||||||||||||
2192 | d->updateLayout(); | - | ||||||||||||||||||||||||
2193 | - | |||||||||||||||||||||||||
2194 | emit elideModeChanged(mode); | - | ||||||||||||||||||||||||
2195 | } executed 320 times by 2 tests: end of block Executed by:
| 320 | ||||||||||||||||||||||||
2196 | - | |||||||||||||||||||||||||
2197 | /*! | - | ||||||||||||||||||||||||
2198 | \qmlproperty url QtQuick::Text::baseUrl | - | ||||||||||||||||||||||||
2199 | - | |||||||||||||||||||||||||
2200 | This property specifies a base URL which is used to resolve relative URLs | - | ||||||||||||||||||||||||
2201 | within the text. | - | ||||||||||||||||||||||||
2202 | - | |||||||||||||||||||||||||
2203 | Urls are resolved to be within the same directory as the target of the base | - | ||||||||||||||||||||||||
2204 | URL meaning any portion of the path after the last '/' will be ignored. | - | ||||||||||||||||||||||||
2205 | - | |||||||||||||||||||||||||
2206 | \table | - | ||||||||||||||||||||||||
2207 | \header \li Base URL \li Relative URL \li Resolved URL | - | ||||||||||||||||||||||||
2208 | \row \li http://qt-project.org/ \li images/logo.png \li http://qt-project.org/images/logo.png | - | ||||||||||||||||||||||||
2209 | \row \li http://qt-project.org/index.html \li images/logo.png \li http://qt-project.org/images/logo.png | - | ||||||||||||||||||||||||
2210 | \row \li http://qt-project.org/content \li images/logo.png \li http://qt-project.org/content/images/logo.png | - | ||||||||||||||||||||||||
2211 | \row \li http://qt-project.org/content/ \li images/logo.png \li http://qt-project.org/content/images/logo.png | - | ||||||||||||||||||||||||
2212 | \row \li http://qt-project.org/content/index.html \li images/logo.png \li http://qt-project.org/content/images/logo.png | - | ||||||||||||||||||||||||
2213 | \row \li http://qt-project.org/content/index.html \li ../images/logo.png \li http://qt-project.org/images/logo.png | - | ||||||||||||||||||||||||
2214 | \row \li http://qt-project.org/content/index.html \li /images/logo.png \li http://qt-project.org/images/logo.png | - | ||||||||||||||||||||||||
2215 | \endtable | - | ||||||||||||||||||||||||
2216 | - | |||||||||||||||||||||||||
2217 | The default value is the url of the QML file instantiating the Text item. | - | ||||||||||||||||||||||||
2218 | */ | - | ||||||||||||||||||||||||
2219 | - | |||||||||||||||||||||||||
2220 | QUrl QQuickText::baseUrl() const | - | ||||||||||||||||||||||||
2221 | { | - | ||||||||||||||||||||||||
2222 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2223 | if (!d->extra.isAllocated() || d->extra->baseUrl.isEmpty()) {
| 38-1970 | ||||||||||||||||||||||||
2224 | if (QQmlContext *context = qmlContext(this))
| 0-2186 | ||||||||||||||||||||||||
2225 | return context->baseUrl(); executed 2186 times by 7 tests: return context->baseUrl(); Executed by:
| 2186 | ||||||||||||||||||||||||
2226 | else | - | ||||||||||||||||||||||||
2227 | return QUrl(); never executed: return QUrl(); | 0 | ||||||||||||||||||||||||
2228 | } else { | - | ||||||||||||||||||||||||
2229 | return d->extra->baseUrl; executed 38 times by 1 test: return d->extra->baseUrl; Executed by:
| 38 | ||||||||||||||||||||||||
2230 | } | - | ||||||||||||||||||||||||
2231 | } | - | ||||||||||||||||||||||||
2232 | - | |||||||||||||||||||||||||
2233 | void QQuickText::setBaseUrl(const QUrl &url) | - | ||||||||||||||||||||||||
2234 | { | - | ||||||||||||||||||||||||
2235 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2236 | if (baseUrl() != url) {
| 2-20 | ||||||||||||||||||||||||
2237 | d->extra.value().baseUrl = url; | - | ||||||||||||||||||||||||
2238 | - | |||||||||||||||||||||||||
2239 | if (d->richText) {
| 0-20 | ||||||||||||||||||||||||
2240 | d->ensureDoc(); | - | ||||||||||||||||||||||||
2241 | d->extra->doc->setBaseUrl(url); | - | ||||||||||||||||||||||||
2242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2243 | if (d->styledText) {
| 0-20 | ||||||||||||||||||||||||
2244 | d->textHasChanged = true; | - | ||||||||||||||||||||||||
2245 | if (d->extra.isAllocated()) {
| 0 | ||||||||||||||||||||||||
2246 | qDeleteAll(d->extra->imgTags); | - | ||||||||||||||||||||||||
2247 | d->extra->imgTags.clear(); | - | ||||||||||||||||||||||||
2248 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2249 | d->updateLayout(); | - | ||||||||||||||||||||||||
2250 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2251 | emit baseUrlChanged(); | - | ||||||||||||||||||||||||
2252 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
2253 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
2254 | - | |||||||||||||||||||||||||
2255 | void QQuickText::resetBaseUrl() | - | ||||||||||||||||||||||||
2256 | { | - | ||||||||||||||||||||||||
2257 | if (QQmlContext *context = qmlContext(this))
| 0-2 | ||||||||||||||||||||||||
2258 | setBaseUrl(context->baseUrl()); executed 2 times by 1 test: setBaseUrl(context->baseUrl()); Executed by:
| 2 | ||||||||||||||||||||||||
2259 | else | - | ||||||||||||||||||||||||
2260 | setBaseUrl(QUrl()); never executed: setBaseUrl(QUrl()); | 0 | ||||||||||||||||||||||||
2261 | } | - | ||||||||||||||||||||||||
2262 | - | |||||||||||||||||||||||||
2263 | /*! \internal */ | - | ||||||||||||||||||||||||
2264 | QRectF QQuickText::boundingRect() const | - | ||||||||||||||||||||||||
2265 | { | - | ||||||||||||||||||||||||
2266 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2267 | - | |||||||||||||||||||||||||
2268 | QRectF rect = d->layedOutTextRect; | - | ||||||||||||||||||||||||
2269 | rect.moveLeft(QQuickTextUtil::alignedX(rect.width(), width(), effectiveHAlign())); | - | ||||||||||||||||||||||||
2270 | rect.moveTop(QQuickTextUtil::alignedY(rect.height() + d->lineHeightOffset(), height(), d->vAlign)); | - | ||||||||||||||||||||||||
2271 | - | |||||||||||||||||||||||||
2272 | if (d->style != Normal)
| 2-222 | ||||||||||||||||||||||||
2273 | rect.adjust(-1, 0, 1, 2); executed 2 times by 1 test: rect.adjust(-1, 0, 1, 2); Executed by:
| 2 | ||||||||||||||||||||||||
2274 | // Could include font max left/right bearings to either side of rectangle. | - | ||||||||||||||||||||||||
2275 | - | |||||||||||||||||||||||||
2276 | return rect; executed 224 times by 1 test: return rect; Executed by:
| 224 | ||||||||||||||||||||||||
2277 | } | - | ||||||||||||||||||||||||
2278 | - | |||||||||||||||||||||||||
2279 | QRectF QQuickText::clipRect() const | - | ||||||||||||||||||||||||
2280 | { | - | ||||||||||||||||||||||||
2281 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2282 | - | |||||||||||||||||||||||||
2283 | QRectF rect = QQuickImplicitSizeItem::clipRect(); | - | ||||||||||||||||||||||||
2284 | if (d->style != Normal)
| 8-38 | ||||||||||||||||||||||||
2285 | rect.adjust(-1, 0, 1, 2); executed 8 times by 1 test: rect.adjust(-1, 0, 1, 2); Executed by:
| 8 | ||||||||||||||||||||||||
2286 | return rect; executed 46 times by 2 tests: return rect; Executed by:
| 46 | ||||||||||||||||||||||||
2287 | } | - | ||||||||||||||||||||||||
2288 | - | |||||||||||||||||||||||||
2289 | /*! \internal */ | - | ||||||||||||||||||||||||
2290 | void QQuickText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | - | ||||||||||||||||||||||||
2291 | { | - | ||||||||||||||||||||||||
2292 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2293 | if (d->text.isEmpty()) {
| 215255-386322 | ||||||||||||||||||||||||
2294 | QQuickItem::geometryChanged(newGeometry, oldGeometry); | - | ||||||||||||||||||||||||
2295 | return; executed 215255 times by 20 tests: return; Executed by:
| 215255 | ||||||||||||||||||||||||
2296 | } | - | ||||||||||||||||||||||||
2297 | - | |||||||||||||||||||||||||
2298 | bool widthChanged = newGeometry.width() != oldGeometry.width(); | - | ||||||||||||||||||||||||
2299 | bool heightChanged = newGeometry.height() != oldGeometry.height(); | - | ||||||||||||||||||||||||
2300 | bool wrapped = d->wrapMode != QQuickText::NoWrap; | - | ||||||||||||||||||||||||
2301 | bool elide = d->elideMode != QQuickText::ElideNone; | - | ||||||||||||||||||||||||
2302 | bool scaleFont = d->fontSizeMode() != QQuickText::FixedSize && (widthValid() || heightValid());
| 0-386310 | ||||||||||||||||||||||||
2303 | bool verticalScale = (d->fontSizeMode() & QQuickText::VerticalFit) && heightValid();
| 0-386318 | ||||||||||||||||||||||||
2304 | - | |||||||||||||||||||||||||
2305 | bool widthMaximum = newGeometry.width() >= oldGeometry.width() && !d->widthExceeded;
| 612-354949 | ||||||||||||||||||||||||
2306 | bool heightMaximum = newGeometry.height() >= oldGeometry.height() && !d->heightExceeded;
| 76-386136 | ||||||||||||||||||||||||
2307 | - | |||||||||||||||||||||||||
2308 | bool verticalPositionChanged = heightChanged && d->vAlign != AlignTop;
| 268-218262 | ||||||||||||||||||||||||
2309 | - | |||||||||||||||||||||||||
2310 | if ((!widthChanged && !heightChanged) || d->internalWidthUpdate)
| 798-351153 | ||||||||||||||||||||||||
2311 | goto geomChangeDone; executed 384592 times by 32 tests: goto geomChangeDone; Executed by:
| 384592 | ||||||||||||||||||||||||
2312 | - | |||||||||||||||||||||||||
2313 | if ((effectiveHAlign() != QQuickText::AlignLeft && widthChanged) || verticalPositionChanged) {
| 18-1426 | ||||||||||||||||||||||||
2314 | // If the width has changed and we're not left aligned do an update so the text is | - | ||||||||||||||||||||||||
2315 | // repositioned even if a full layout isn't required. And the same for vertical. | - | ||||||||||||||||||||||||
2316 | d->updateType = QQuickTextPrivate::UpdatePaintNode; | - | ||||||||||||||||||||||||
2317 | update(); | - | ||||||||||||||||||||||||
2318 | } executed 304 times by 5 tests: end of block Executed by:
| 304 | ||||||||||||||||||||||||
2319 | - | |||||||||||||||||||||||||
2320 | if (!wrapped && !elide && !scaleFont && !verticalPositionChanged)
| 4-1142 | ||||||||||||||||||||||||
2321 | goto geomChangeDone; // left aligned unwrapped text without eliding never needs relayout executed 838 times by 8 tests: goto geomChangeDone; Executed by:
| 838 | ||||||||||||||||||||||||
2322 | - | |||||||||||||||||||||||||
2323 | if (elide // eliding and dimensions were and remain invalid;
| 108-784 | ||||||||||||||||||||||||
2324 | && ((widthValid() && oldGeometry.width() <= 0 && newGeometry.width() <= 0)
| 2-92 | ||||||||||||||||||||||||
2325 | || (heightValid() && oldGeometry.height() <= 0 && newGeometry.height() <= 0))) {
| 2-82 | ||||||||||||||||||||||||
2326 | goto geomChangeDone; executed 4 times by 1 test: goto geomChangeDone; Executed by:
| 4 | ||||||||||||||||||||||||
2327 | } | - | ||||||||||||||||||||||||
2328 | - | |||||||||||||||||||||||||
2329 | if (widthMaximum && heightMaximum && !d->isLineLaidOutConnected() && !verticalPositionChanged) // Size is sufficient and growing.
| 2-628 | ||||||||||||||||||||||||
2330 | goto geomChangeDone; executed 376 times by 3 tests: goto geomChangeDone; Executed by:
| 376 | ||||||||||||||||||||||||
2331 | - | |||||||||||||||||||||||||
2332 | if (!(widthChanged || widthMaximum) && !d->isLineLaidOutConnected()) { // only height has changed
| 2-372 | ||||||||||||||||||||||||
2333 | if (newGeometry.height() > oldGeometry.height()) {
| 30-96 | ||||||||||||||||||||||||
2334 | if (!d->heightExceeded && !qFuzzyIsNull(oldGeometry.height())) {
| 10-74 | ||||||||||||||||||||||||
2335 | // Height is adequate and growing, and it wasn't 0 previously. | - | ||||||||||||||||||||||||
2336 | goto geomChangeDone; executed 10 times by 1 test: goto geomChangeDone; Executed by:
| 10 | ||||||||||||||||||||||||
2337 | } | - | ||||||||||||||||||||||||
2338 | if (d->lineCount == d->maximumLineCount()) // Reached maximum line and height is growing.
| 16-70 | ||||||||||||||||||||||||
2339 | goto geomChangeDone; executed 16 times by 1 test: goto geomChangeDone; Executed by:
| 16 | ||||||||||||||||||||||||
2340 | } else if (newGeometry.height() < oldGeometry.height()) { executed 70 times by 2 tests: end of block Executed by:
| 0-70 | ||||||||||||||||||||||||
2341 | if (d->lineCount < 2 && !verticalScale && newGeometry.height() > 0) // A single line won't be truncated until the text is 0 height.
| 0-22 | ||||||||||||||||||||||||
2342 | goto geomChangeDone; executed 8 times by 1 test: goto geomChangeDone; Executed by:
| 8 | ||||||||||||||||||||||||
2343 | - | |||||||||||||||||||||||||
2344 | if (!verticalScale // no scaling, no eliding, and either unwrapped, or no maximum line count.
| 0-22 | ||||||||||||||||||||||||
2345 | && d->elideMode != QQuickText::ElideRight
| 8-14 | ||||||||||||||||||||||||
2346 | && !(d->maximumLineCountValid && d->widthExceeded)) {
| 0-4 | ||||||||||||||||||||||||
2347 | goto geomChangeDone; executed 4 times by 1 test: goto geomChangeDone; Executed by:
| 4 | ||||||||||||||||||||||||
2348 | } | - | ||||||||||||||||||||||||
2349 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
2350 | } else if (!heightChanged && widthMaximum) { executed 88 times by 2 tests: end of block Executed by:
| 2-258 | ||||||||||||||||||||||||
2351 | goto geomChangeDone; executed 2 times by 1 test: goto geomChangeDone; Executed by:
| 2 | ||||||||||||||||||||||||
2352 | } | - | ||||||||||||||||||||||||
2353 | - | |||||||||||||||||||||||||
2354 | if (d->updateOnComponentComplete || d->textHasChanged) {
| 86-272 | ||||||||||||||||||||||||
2355 | // We need to re-elide | - | ||||||||||||||||||||||||
2356 | d->updateLayout(); | - | ||||||||||||||||||||||||
2357 | } else { executed 358 times by 3 tests: end of block Executed by:
| 358 | ||||||||||||||||||||||||
2358 | // We just need to re-layout | - | ||||||||||||||||||||||||
2359 | d->updateSize(); | - | ||||||||||||||||||||||||
2360 | } executed 114 times by 3 tests: end of block Executed by:
| 114 | ||||||||||||||||||||||||
2361 | - | |||||||||||||||||||||||||
2362 | geomChangeDone: code before this statement executed 472 times by 4 tests: geomChangeDone: Executed by:
| 472 | ||||||||||||||||||||||||
2363 | QQuickItem::geometryChanged(newGeometry, oldGeometry); | - | ||||||||||||||||||||||||
2364 | } executed 386322 times by 33 tests: end of block Executed by:
| 386322 | ||||||||||||||||||||||||
2365 | - | |||||||||||||||||||||||||
2366 | void QQuickText::triggerPreprocess() | - | ||||||||||||||||||||||||
2367 | { | - | ||||||||||||||||||||||||
2368 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2369 | if (d->updateType == QQuickTextPrivate::UpdateNone)
| 0 | ||||||||||||||||||||||||
2370 | d->updateType = QQuickTextPrivate::UpdatePreprocess; never executed: d->updateType = QQuickTextPrivate::UpdatePreprocess; | 0 | ||||||||||||||||||||||||
2371 | update(); | - | ||||||||||||||||||||||||
2372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2373 | - | |||||||||||||||||||||||||
2374 | QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) | - | ||||||||||||||||||||||||
2375 | { | - | ||||||||||||||||||||||||
2376 | Q_UNUSED(data); | - | ||||||||||||||||||||||||
2377 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2378 | - | |||||||||||||||||||||||||
2379 | if (d->text.isEmpty()) {
| 38737-248380 | ||||||||||||||||||||||||
2380 | delete oldNode; | - | ||||||||||||||||||||||||
2381 | return nullptr; executed 38737 times by 5 tests: return nullptr; Executed by:
| 38737 | ||||||||||||||||||||||||
2382 | } | - | ||||||||||||||||||||||||
2383 | - | |||||||||||||||||||||||||
2384 | if (d->updateType != QQuickTextPrivate::UpdatePaintNode && oldNode != nullptr) {
| 0-248380 | ||||||||||||||||||||||||
2385 | // Update done in preprocess() in the nodes | - | ||||||||||||||||||||||||
2386 | d->updateType = QQuickTextPrivate::UpdateNone; | - | ||||||||||||||||||||||||
2387 | return oldNode; never executed: return oldNode; | 0 | ||||||||||||||||||||||||
2388 | } | - | ||||||||||||||||||||||||
2389 | - | |||||||||||||||||||||||||
2390 | d->updateType = QQuickTextPrivate::UpdateNone; | - | ||||||||||||||||||||||||
2391 | - | |||||||||||||||||||||||||
2392 | const qreal dy = QQuickTextUtil::alignedY(d->layedOutTextRect.height() + d->lineHeightOffset(), d->availableHeight(), d->vAlign) + topPadding(); | - | ||||||||||||||||||||||||
2393 | - | |||||||||||||||||||||||||
2394 | QQuickTextNode *node = nullptr; | - | ||||||||||||||||||||||||
2395 | if (!oldNode)
| 74395-173985 | ||||||||||||||||||||||||
2396 | node = new QQuickTextNode(this); executed 173985 times by 21 tests: node = new QQuickTextNode(this); Executed by:
| 173985 | ||||||||||||||||||||||||
2397 | else | - | ||||||||||||||||||||||||
2398 | node = static_cast<QQuickTextNode *>(oldNode); executed 74395 times by 9 tests: node = static_cast<QQuickTextNode *>(oldNode); Executed by:
| 74395 | ||||||||||||||||||||||||
2399 | - | |||||||||||||||||||||||||
2400 | node->setUseNativeRenderer(d->renderType == NativeRendering); | - | ||||||||||||||||||||||||
2401 | node->deleteContent(); | - | ||||||||||||||||||||||||
2402 | node->setMatrix(QMatrix4x4()); | - | ||||||||||||||||||||||||
2403 | - | |||||||||||||||||||||||||
2404 | const QColor color = QColor::fromRgba(d->color); | - | ||||||||||||||||||||||||
2405 | const QColor styleColor = QColor::fromRgba(d->styleColor); | - | ||||||||||||||||||||||||
2406 | const QColor linkColor = QColor::fromRgba(d->linkColor); | - | ||||||||||||||||||||||||
2407 | - | |||||||||||||||||||||||||
2408 | if (d->richText) {
| 84-248296 | ||||||||||||||||||||||||
2409 | const qreal dx = QQuickTextUtil::alignedX(d->layedOutTextRect.width(), d->availableWidth(), effectiveHAlign()) + leftPadding(); | - | ||||||||||||||||||||||||
2410 | d->ensureDoc(); | - | ||||||||||||||||||||||||
2411 | node->addTextDocument(QPointF(dx, dy), d->extra->doc, color, d->style, styleColor, linkColor); | - | ||||||||||||||||||||||||
2412 | } else if (d->layedOutTextRect.width() > 0) { executed 84 times by 2 tests: end of block Executed by:
| 0-248296 | ||||||||||||||||||||||||
2413 | const qreal dx = QQuickTextUtil::alignedX(d->lineWidth, d->availableWidth(), effectiveHAlign()) + leftPadding(); | - | ||||||||||||||||||||||||
2414 | int unelidedLineCount = d->lineCount; | - | ||||||||||||||||||||||||
2415 | if (d->elideLayout)
| 24-248272 | ||||||||||||||||||||||||
2416 | unelidedLineCount -= 1; executed 24 times by 1 test: unelidedLineCount -= 1; Executed by:
| 24 | ||||||||||||||||||||||||
2417 | if (unelidedLineCount > 0) {
| 24-248272 | ||||||||||||||||||||||||
2418 | node->addTextLayout( | - | ||||||||||||||||||||||||
2419 | QPointF(dx, dy), | - | ||||||||||||||||||||||||
2420 | &d->layout, | - | ||||||||||||||||||||||||
2421 | color, d->style, styleColor, linkColor, | - | ||||||||||||||||||||||||
2422 | QColor(), QColor(), -1, -1, | - | ||||||||||||||||||||||||
2423 | 0, unelidedLineCount); | - | ||||||||||||||||||||||||
2424 | } executed 248272 times by 21 tests: end of block Executed by:
| 248272 | ||||||||||||||||||||||||
2425 | if (d->elideLayout)
| 24-248272 | ||||||||||||||||||||||||
2426 | node->addTextLayout(QPointF(dx, dy), d->elideLayout, color, d->style, styleColor, linkColor); executed 24 times by 1 test: node->addTextLayout(QPointF(dx, dy), d->elideLayout, color, d->style, styleColor, linkColor); Executed by:
| 24 | ||||||||||||||||||||||||
2427 | - | |||||||||||||||||||||||||
2428 | if (d->extra.isAllocated()) {
| 308-247988 | ||||||||||||||||||||||||
2429 | for (QQuickStyledTextImgTag *img : qAsConst(d->extra->visibleImgTags)) { | - | ||||||||||||||||||||||||
2430 | QQuickPixmap *pix = img->pix; | - | ||||||||||||||||||||||||
2431 | if (pix && pix->isReady())
| 0-30 | ||||||||||||||||||||||||
2432 | node->addImage(QRectF(img->pos.x() + dx, img->pos.y() + dy, pix->width(), pix->height()), pix->image()); executed 26 times by 1 test: node->addImage(QRectF(img->pos.x() + dx, img->pos.y() + dy, pix->width(), pix->height()), pix->image()); Executed by:
| 26 | ||||||||||||||||||||||||
2433 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
2434 | } executed 308 times by 2 tests: end of block Executed by:
| 308 | ||||||||||||||||||||||||
2435 | } executed 248296 times by 21 tests: end of block Executed by:
| 248296 | ||||||||||||||||||||||||
2436 | - | |||||||||||||||||||||||||
2437 | // The font caches have now been initialized on the render thread, so they have to be | - | ||||||||||||||||||||||||
2438 | // invalidated before we can use them from the main thread again. | - | ||||||||||||||||||||||||
2439 | invalidateFontCaches(); | - | ||||||||||||||||||||||||
2440 | - | |||||||||||||||||||||||||
2441 | return node; executed 248380 times by 21 tests: return node; Executed by:
| 248380 | ||||||||||||||||||||||||
2442 | } | - | ||||||||||||||||||||||||
2443 | - | |||||||||||||||||||||||||
2444 | void QQuickText::updatePolish() | - | ||||||||||||||||||||||||
2445 | { | - | ||||||||||||||||||||||||
2446 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2447 | // If the fonts used for rendering are different from the ones used in the GUI thread, | - | ||||||||||||||||||||||||
2448 | // it means we will get warnings and corrupted text. If this case is detected, we need | - | ||||||||||||||||||||||||
2449 | // to update the text layout before creating the scenegraph nodes. | - | ||||||||||||||||||||||||
2450 | if (!d->assignedFont.isEmpty() && QFontInfo(d->font).family() != d->assignedFont)
| 0-253536 | ||||||||||||||||||||||||
2451 | d->polishSize = true; never executed: d->polishSize = true; | 0 | ||||||||||||||||||||||||
2452 | - | |||||||||||||||||||||||||
2453 | if (d->polishSize) {
| 88-292535 | ||||||||||||||||||||||||
2454 | d->updateSize(); | - | ||||||||||||||||||||||||
2455 | d->polishSize = false; | - | ||||||||||||||||||||||||
2456 | } executed 88 times by 1 test: end of block Executed by:
| 88 | ||||||||||||||||||||||||
2457 | invalidateFontCaches(); | - | ||||||||||||||||||||||||
2458 | } executed 292623 times by 21 tests: end of block Executed by:
| 292623 | ||||||||||||||||||||||||
2459 | - | |||||||||||||||||||||||||
2460 | /*! | - | ||||||||||||||||||||||||
2461 | \qmlproperty real QtQuick::Text::contentWidth | - | ||||||||||||||||||||||||
2462 | - | |||||||||||||||||||||||||
2463 | Returns the width of the text, including width past the width | - | ||||||||||||||||||||||||
2464 | which is covered due to insufficient wrapping if WrapMode is set. | - | ||||||||||||||||||||||||
2465 | */ | - | ||||||||||||||||||||||||
2466 | qreal QQuickText::contentWidth() const | - | ||||||||||||||||||||||||
2467 | { | - | ||||||||||||||||||||||||
2468 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2469 | return d->layedOutTextRect.width(); executed 434 times by 2 tests: return d->layedOutTextRect.width(); Executed by:
| 434 | ||||||||||||||||||||||||
2470 | } | - | ||||||||||||||||||||||||
2471 | - | |||||||||||||||||||||||||
2472 | /*! | - | ||||||||||||||||||||||||
2473 | \qmlproperty real QtQuick::Text::contentHeight | - | ||||||||||||||||||||||||
2474 | - | |||||||||||||||||||||||||
2475 | Returns the height of the text, including height past the height | - | ||||||||||||||||||||||||
2476 | which is covered due to there being more text than fits in the set height. | - | ||||||||||||||||||||||||
2477 | */ | - | ||||||||||||||||||||||||
2478 | qreal QQuickText::contentHeight() const | - | ||||||||||||||||||||||||
2479 | { | - | ||||||||||||||||||||||||
2480 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2481 | return d->layedOutTextRect.height(); executed 410 times by 2 tests: return d->layedOutTextRect.height(); Executed by:
| 410 | ||||||||||||||||||||||||
2482 | } | - | ||||||||||||||||||||||||
2483 | - | |||||||||||||||||||||||||
2484 | /*! | - | ||||||||||||||||||||||||
2485 | \qmlproperty real QtQuick::Text::lineHeight | - | ||||||||||||||||||||||||
2486 | - | |||||||||||||||||||||||||
2487 | Sets the line height for the text. | - | ||||||||||||||||||||||||
2488 | The value can be in pixels or a multiplier depending on lineHeightMode. | - | ||||||||||||||||||||||||
2489 | - | |||||||||||||||||||||||||
2490 | The default value is a multiplier of 1.0. | - | ||||||||||||||||||||||||
2491 | The line height must be a positive value. | - | ||||||||||||||||||||||||
2492 | */ | - | ||||||||||||||||||||||||
2493 | qreal QQuickText::lineHeight() const | - | ||||||||||||||||||||||||
2494 | { | - | ||||||||||||||||||||||||
2495 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2496 | return d->lineHeight(); executed 18 times by 2 tests: return d->lineHeight(); Executed by:
| 18 | ||||||||||||||||||||||||
2497 | } | - | ||||||||||||||||||||||||
2498 | - | |||||||||||||||||||||||||
2499 | void QQuickText::setLineHeight(qreal lineHeight) | - | ||||||||||||||||||||||||
2500 | { | - | ||||||||||||||||||||||||
2501 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2502 | - | |||||||||||||||||||||||||
2503 | if ((d->lineHeight() == lineHeight) || (lineHeight < 0.0))
| 0-30 | ||||||||||||||||||||||||
2504 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2505 | - | |||||||||||||||||||||||||
2506 | d->extra.value().lineHeightValid = true; | - | ||||||||||||||||||||||||
2507 | d->extra.value().lineHeight = lineHeight; | - | ||||||||||||||||||||||||
2508 | d->implicitHeightValid = false; | - | ||||||||||||||||||||||||
2509 | d->updateLayout(); | - | ||||||||||||||||||||||||
2510 | emit lineHeightChanged(lineHeight); | - | ||||||||||||||||||||||||
2511 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
2512 | - | |||||||||||||||||||||||||
2513 | /*! | - | ||||||||||||||||||||||||
2514 | \qmlproperty enumeration QtQuick::Text::lineHeightMode | - | ||||||||||||||||||||||||
2515 | - | |||||||||||||||||||||||||
2516 | This property determines how the line height is specified. | - | ||||||||||||||||||||||||
2517 | The possible values are: | - | ||||||||||||||||||||||||
2518 | - | |||||||||||||||||||||||||
2519 | \list | - | ||||||||||||||||||||||||
2520 | \li Text.ProportionalHeight (default) - this sets the spacing proportional to the | - | ||||||||||||||||||||||||
2521 | line (as a multiplier). For example, set to 2 for double spacing. | - | ||||||||||||||||||||||||
2522 | \li Text.FixedHeight - this sets the line height to a fixed line height (in pixels). | - | ||||||||||||||||||||||||
2523 | \endlist | - | ||||||||||||||||||||||||
2524 | */ | - | ||||||||||||||||||||||||
2525 | QQuickText::LineHeightMode QQuickText::lineHeightMode() const | - | ||||||||||||||||||||||||
2526 | { | - | ||||||||||||||||||||||||
2527 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2528 | return d->lineHeightMode(); executed 18 times by 2 tests: return d->lineHeightMode(); Executed by:
| 18 | ||||||||||||||||||||||||
2529 | } | - | ||||||||||||||||||||||||
2530 | - | |||||||||||||||||||||||||
2531 | void QQuickText::setLineHeightMode(LineHeightMode mode) | - | ||||||||||||||||||||||||
2532 | { | - | ||||||||||||||||||||||||
2533 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2534 | if (mode == d->lineHeightMode())
| 8-14 | ||||||||||||||||||||||||
2535 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||||||||
2536 | - | |||||||||||||||||||||||||
2537 | d->implicitHeightValid = false; | - | ||||||||||||||||||||||||
2538 | d->extra.value().lineHeightValid = true; | - | ||||||||||||||||||||||||
2539 | d->extra.value().lineHeightMode = mode; | - | ||||||||||||||||||||||||
2540 | d->updateLayout(); | - | ||||||||||||||||||||||||
2541 | - | |||||||||||||||||||||||||
2542 | emit lineHeightModeChanged(mode); | - | ||||||||||||||||||||||||
2543 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
2544 | - | |||||||||||||||||||||||||
2545 | /*! | - | ||||||||||||||||||||||||
2546 | \qmlproperty enumeration QtQuick::Text::fontSizeMode | - | ||||||||||||||||||||||||
2547 | - | |||||||||||||||||||||||||
2548 | This property specifies how the font size of the displayed text is determined. | - | ||||||||||||||||||||||||
2549 | The possible values are: | - | ||||||||||||||||||||||||
2550 | - | |||||||||||||||||||||||||
2551 | \list | - | ||||||||||||||||||||||||
2552 | \li Text.FixedSize (default) - The size specified by \l font.pixelSize | - | ||||||||||||||||||||||||
2553 | or \l font.pointSize is used. | - | ||||||||||||||||||||||||
2554 | \li Text.HorizontalFit - The largest size up to the size specified that fits | - | ||||||||||||||||||||||||
2555 | within the width of the item without wrapping is used. | - | ||||||||||||||||||||||||
2556 | \li Text.VerticalFit - The largest size up to the size specified that fits | - | ||||||||||||||||||||||||
2557 | the height of the item is used. | - | ||||||||||||||||||||||||
2558 | \li Text.Fit - The largest size up to the size specified that fits within the | - | ||||||||||||||||||||||||
2559 | width and height of the item is used. | - | ||||||||||||||||||||||||
2560 | \endlist | - | ||||||||||||||||||||||||
2561 | - | |||||||||||||||||||||||||
2562 | The font size of fitted text has a minimum bound specified by the | - | ||||||||||||||||||||||||
2563 | minimumPointSize or minimumPixelSize property and maximum bound specified | - | ||||||||||||||||||||||||
2564 | by either the \l font.pointSize or \l font.pixelSize properties. | - | ||||||||||||||||||||||||
2565 | - | |||||||||||||||||||||||||
2566 | \qml | - | ||||||||||||||||||||||||
2567 | Text { text: "Hello"; fontSizeMode: Text.Fit; minimumPixelSize: 10; font.pixelSize: 72 } | - | ||||||||||||||||||||||||
2568 | \endqml | - | ||||||||||||||||||||||||
2569 | - | |||||||||||||||||||||||||
2570 | If the text does not fit within the item bounds with the minimum font size | - | ||||||||||||||||||||||||
2571 | the text will be elided as per the \l elide property. | - | ||||||||||||||||||||||||
2572 | */ | - | ||||||||||||||||||||||||
2573 | - | |||||||||||||||||||||||||
2574 | QQuickText::FontSizeMode QQuickText::fontSizeMode() const | - | ||||||||||||||||||||||||
2575 | { | - | ||||||||||||||||||||||||
2576 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2577 | return d->fontSizeMode(); executed 16 times by 1 test: return d->fontSizeMode(); Executed by:
| 16 | ||||||||||||||||||||||||
2578 | } | - | ||||||||||||||||||||||||
2579 | - | |||||||||||||||||||||||||
2580 | void QQuickText::setFontSizeMode(FontSizeMode mode) | - | ||||||||||||||||||||||||
2581 | { | - | ||||||||||||||||||||||||
2582 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2583 | if (d->fontSizeMode() == mode)
| 0-94 | ||||||||||||||||||||||||
2584 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2585 | - | |||||||||||||||||||||||||
2586 | d->polishSize = true; | - | ||||||||||||||||||||||||
2587 | polish(); | - | ||||||||||||||||||||||||
2588 | - | |||||||||||||||||||||||||
2589 | d->extra.value().fontSizeMode = mode; | - | ||||||||||||||||||||||||
2590 | emit fontSizeModeChanged(); | - | ||||||||||||||||||||||||
2591 | } executed 94 times by 1 test: end of block Executed by:
| 94 | ||||||||||||||||||||||||
2592 | - | |||||||||||||||||||||||||
2593 | /*! | - | ||||||||||||||||||||||||
2594 | \qmlproperty int QtQuick::Text::minimumPixelSize | - | ||||||||||||||||||||||||
2595 | - | |||||||||||||||||||||||||
2596 | This property specifies the minimum font pixel size of text scaled by the | - | ||||||||||||||||||||||||
2597 | fontSizeMode property. | - | ||||||||||||||||||||||||
2598 | - | |||||||||||||||||||||||||
2599 | If the fontSizeMode is Text.FixedSize or the \l font.pixelSize is -1 this | - | ||||||||||||||||||||||||
2600 | property is ignored. | - | ||||||||||||||||||||||||
2601 | */ | - | ||||||||||||||||||||||||
2602 | - | |||||||||||||||||||||||||
2603 | int QQuickText::minimumPixelSize() const | - | ||||||||||||||||||||||||
2604 | { | - | ||||||||||||||||||||||||
2605 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2606 | return d->minimumPixelSize(); executed 16 times by 1 test: return d->minimumPixelSize(); Executed by:
| 16 | ||||||||||||||||||||||||
2607 | } | - | ||||||||||||||||||||||||
2608 | - | |||||||||||||||||||||||||
2609 | void QQuickText::setMinimumPixelSize(int size) | - | ||||||||||||||||||||||||
2610 | { | - | ||||||||||||||||||||||||
2611 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2612 | if (d->minimumPixelSize() == size)
| 0-8 | ||||||||||||||||||||||||
2613 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2614 | - | |||||||||||||||||||||||||
2615 | if (d->fontSizeMode() != FixedSize && (widthValid() || heightValid())) {
| 0-8 | ||||||||||||||||||||||||
2616 | d->polishSize = true; | - | ||||||||||||||||||||||||
2617 | polish(); | - | ||||||||||||||||||||||||
2618 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2619 | d->extra.value().minimumPixelSize = size; | - | ||||||||||||||||||||||||
2620 | emit minimumPixelSizeChanged(); | - | ||||||||||||||||||||||||
2621 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
2622 | - | |||||||||||||||||||||||||
2623 | /*! | - | ||||||||||||||||||||||||
2624 | \qmlproperty int QtQuick::Text::minimumPointSize | - | ||||||||||||||||||||||||
2625 | - | |||||||||||||||||||||||||
2626 | This property specifies the minimum font point \l size of text scaled by | - | ||||||||||||||||||||||||
2627 | the fontSizeMode property. | - | ||||||||||||||||||||||||
2628 | - | |||||||||||||||||||||||||
2629 | If the fontSizeMode is Text.FixedSize or the \l font.pointSize is -1 this | - | ||||||||||||||||||||||||
2630 | property is ignored. | - | ||||||||||||||||||||||||
2631 | */ | - | ||||||||||||||||||||||||
2632 | - | |||||||||||||||||||||||||
2633 | int QQuickText::minimumPointSize() const | - | ||||||||||||||||||||||||
2634 | { | - | ||||||||||||||||||||||||
2635 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2636 | return d->minimumPointSize(); executed 16 times by 1 test: return d->minimumPointSize(); Executed by:
| 16 | ||||||||||||||||||||||||
2637 | } | - | ||||||||||||||||||||||||
2638 | - | |||||||||||||||||||||||||
2639 | void QQuickText::setMinimumPointSize(int size) | - | ||||||||||||||||||||||||
2640 | { | - | ||||||||||||||||||||||||
2641 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2642 | if (d->minimumPointSize() == size)
| 0-12 | ||||||||||||||||||||||||
2643 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2644 | - | |||||||||||||||||||||||||
2645 | if (d->fontSizeMode() != FixedSize && (widthValid() || heightValid())) {
| 0-8 | ||||||||||||||||||||||||
2646 | d->polishSize = true; | - | ||||||||||||||||||||||||
2647 | polish(); | - | ||||||||||||||||||||||||
2648 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2649 | d->extra.value().minimumPointSize = size; | - | ||||||||||||||||||||||||
2650 | emit minimumPointSizeChanged(); | - | ||||||||||||||||||||||||
2651 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
2652 | - | |||||||||||||||||||||||||
2653 | /*! | - | ||||||||||||||||||||||||
2654 | Returns the number of resources (images) that are being loaded asynchronously. | - | ||||||||||||||||||||||||
2655 | */ | - | ||||||||||||||||||||||||
2656 | int QQuickText::resourcesLoading() const | - | ||||||||||||||||||||||||
2657 | { | - | ||||||||||||||||||||||||
2658 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2659 | if (d->richText && d->extra.isAllocated() && d->extra->doc)
| 0-24 | ||||||||||||||||||||||||
2660 | return d->extra->doc->resourcesLoading(); executed 24 times by 1 test: return d->extra->doc->resourcesLoading(); Executed by:
| 24 | ||||||||||||||||||||||||
2661 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2662 | } | - | ||||||||||||||||||||||||
2663 | - | |||||||||||||||||||||||||
2664 | /*! \internal */ | - | ||||||||||||||||||||||||
2665 | void QQuickText::componentComplete() | - | ||||||||||||||||||||||||
2666 | { | - | ||||||||||||||||||||||||
2667 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2668 | if (d->updateOnComponentComplete) {
| 0-264678 | ||||||||||||||||||||||||
2669 | if (d->richText) {
| 148-264530 | ||||||||||||||||||||||||
2670 | d->ensureDoc(); | - | ||||||||||||||||||||||||
2671 | d->extra->doc->setText(d->text); | - | ||||||||||||||||||||||||
2672 | d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft(); | - | ||||||||||||||||||||||||
2673 | } else { executed 148 times by 2 tests: end of block Executed by:
| 148 | ||||||||||||||||||||||||
2674 | d->rightToLeftText = d->text.isRightToLeft(); | - | ||||||||||||||||||||||||
2675 | } executed 264530 times by 35 tests: end of block Executed by:
| 264530 | ||||||||||||||||||||||||
2676 | d->determineHorizontalAlignment(); | - | ||||||||||||||||||||||||
2677 | } executed 264678 times by 35 tests: end of block Executed by:
| 264678 | ||||||||||||||||||||||||
2678 | QQuickItem::componentComplete(); | - | ||||||||||||||||||||||||
2679 | if (d->updateOnComponentComplete)
| 238-264440 | ||||||||||||||||||||||||
2680 | d->updateLayout(); executed 264440 times by 35 tests: d->updateLayout(); Executed by:
| 264440 | ||||||||||||||||||||||||
2681 | } executed 264678 times by 35 tests: end of block Executed by:
| 264678 | ||||||||||||||||||||||||
2682 | - | |||||||||||||||||||||||||
2683 | QString QQuickTextPrivate::anchorAt(const QTextLayout *layout, const QPointF &mousePos) | - | ||||||||||||||||||||||||
2684 | { | - | ||||||||||||||||||||||||
2685 | for (int i = 0; i < layout->lineCount(); ++i) {
| 62-300 | ||||||||||||||||||||||||
2686 | QTextLine line = layout->lineAt(i); | - | ||||||||||||||||||||||||
2687 | if (line.naturalTextRect().contains(mousePos)) {
| 98-202 | ||||||||||||||||||||||||
2688 | int charPos = line.xToCursor(mousePos.x(), QTextLine::CursorOnCharacter); | - | ||||||||||||||||||||||||
2689 | const auto formats = layout->formats(); | - | ||||||||||||||||||||||||
2690 | for (const QTextLayout::FormatRange &formatRange : formats) { | - | ||||||||||||||||||||||||
2691 | if (formatRange.format.isAnchor()
| 0-278 | ||||||||||||||||||||||||
2692 | && charPos >= formatRange.start
| 22-256 | ||||||||||||||||||||||||
2693 | && charPos < formatRange.start + formatRange.length) {
| 76-180 | ||||||||||||||||||||||||
2694 | return formatRange.format.anchorHref(); executed 180 times by 1 test: return formatRange.format.anchorHref(); Executed by:
| 180 | ||||||||||||||||||||||||
2695 | } | - | ||||||||||||||||||||||||
2696 | } executed 98 times by 1 test: end of block Executed by:
| 98 | ||||||||||||||||||||||||
2697 | break; executed 22 times by 1 test: break; Executed by:
| 22 | ||||||||||||||||||||||||
2698 | } | - | ||||||||||||||||||||||||
2699 | } executed 98 times by 1 test: end of block Executed by:
| 98 | ||||||||||||||||||||||||
2700 | return QString(); executed 84 times by 1 test: return QString(); Executed by:
| 84 | ||||||||||||||||||||||||
2701 | } | - | ||||||||||||||||||||||||
2702 | - | |||||||||||||||||||||||||
2703 | QString QQuickTextPrivate::anchorAt(const QPointF &mousePos) const | - | ||||||||||||||||||||||||
2704 | { | - | ||||||||||||||||||||||||
2705 | Q_Q(const QQuickText); | - | ||||||||||||||||||||||||
2706 | QPointF translatedMousePos = mousePos; | - | ||||||||||||||||||||||||
2707 | translatedMousePos.rx() -= q->leftPadding(); | - | ||||||||||||||||||||||||
2708 | translatedMousePos.ry() -= q->topPadding() + QQuickTextUtil::alignedY(layedOutTextRect.height() + lineHeightOffset(), availableHeight(), vAlign); | - | ||||||||||||||||||||||||
2709 | if (styledText) {
| 162-240 | ||||||||||||||||||||||||
2710 | QString link = anchorAt(&layout, translatedMousePos); | - | ||||||||||||||||||||||||
2711 | if (link.isEmpty() && elideLayout)
| 24-160 | ||||||||||||||||||||||||
2712 | link = anchorAt(elideLayout, translatedMousePos); executed 24 times by 1 test: link = anchorAt(elideLayout, translatedMousePos); Executed by:
| 24 | ||||||||||||||||||||||||
2713 | return link; executed 240 times by 1 test: return link; Executed by:
| 240 | ||||||||||||||||||||||||
2714 | } else if (richText && extra.isAllocated() && extra->doc) {
| 0-162 | ||||||||||||||||||||||||
2715 | translatedMousePos.rx() -= QQuickTextUtil::alignedX(layedOutTextRect.width(), availableWidth(), q->effectiveHAlign()); | - | ||||||||||||||||||||||||
2716 | return extra->doc->documentLayout()->anchorAt(translatedMousePos); executed 162 times by 1 test: return extra->doc->documentLayout()->anchorAt(translatedMousePos); Executed by:
| 162 | ||||||||||||||||||||||||
2717 | } | - | ||||||||||||||||||||||||
2718 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
2719 | } | - | ||||||||||||||||||||||||
2720 | - | |||||||||||||||||||||||||
2721 | bool QQuickTextPrivate::isLinkActivatedConnected() | - | ||||||||||||||||||||||||
2722 | { | - | ||||||||||||||||||||||||
2723 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
2724 | IS_SIGNAL_CONNECTED(q, QQuickText, linkActivated, (const QString &)); executed 360 times by 6 tests: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); Executed by:
| 360 | ||||||||||||||||||||||||
2725 | } | - | ||||||||||||||||||||||||
2726 | - | |||||||||||||||||||||||||
2727 | /*! \internal */ | - | ||||||||||||||||||||||||
2728 | void QQuickText::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
2729 | { | - | ||||||||||||||||||||||||
2730 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2731 | - | |||||||||||||||||||||||||
2732 | QString link; | - | ||||||||||||||||||||||||
2733 | if (d->isLinkActivatedConnected())
| 64-230 | ||||||||||||||||||||||||
2734 | link = d->anchorAt(event->localPos()); executed 64 times by 1 test: link = d->anchorAt(event->localPos()); Executed by:
| 64 | ||||||||||||||||||||||||
2735 | - | |||||||||||||||||||||||||
2736 | if (link.isEmpty()) {
| 58-236 | ||||||||||||||||||||||||
2737 | event->setAccepted(false); | - | ||||||||||||||||||||||||
2738 | } else { executed 236 times by 5 tests: end of block Executed by:
| 236 | ||||||||||||||||||||||||
2739 | d->extra.value().activeLink = link; | - | ||||||||||||||||||||||||
2740 | } executed 58 times by 1 test: end of block Executed by:
| 58 | ||||||||||||||||||||||||
2741 | - | |||||||||||||||||||||||||
2742 | // ### may malfunction if two of the same links are clicked & dragged onto each other) | - | ||||||||||||||||||||||||
2743 | - | |||||||||||||||||||||||||
2744 | if (!event->isAccepted())
| 58-236 | ||||||||||||||||||||||||
2745 | QQuickItem::mousePressEvent(event); executed 236 times by 5 tests: QQuickItem::mousePressEvent(event); Executed by:
| 236 | ||||||||||||||||||||||||
2746 | } executed 294 times by 5 tests: end of block Executed by:
| 294 | ||||||||||||||||||||||||
2747 | - | |||||||||||||||||||||||||
2748 | - | |||||||||||||||||||||||||
2749 | /*! \internal */ | - | ||||||||||||||||||||||||
2750 | void QQuickText::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
2751 | { | - | ||||||||||||||||||||||||
2752 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2753 | - | |||||||||||||||||||||||||
2754 | // ### confirm the link, and send a signal out | - | ||||||||||||||||||||||||
2755 | - | |||||||||||||||||||||||||
2756 | QString link; | - | ||||||||||||||||||||||||
2757 | if (d->isLinkActivatedConnected())
| 2-64 | ||||||||||||||||||||||||
2758 | link = d->anchorAt(event->localPos()); executed 64 times by 1 test: link = d->anchorAt(event->localPos()); Executed by:
| 64 | ||||||||||||||||||||||||
2759 | - | |||||||||||||||||||||||||
2760 | if (!link.isEmpty() && d->extra.isAllocated() && d->extra->activeLink == link)
| 0-58 | ||||||||||||||||||||||||
2761 | emit linkActivated(d->extra->activeLink); executed 48 times by 1 test: linkActivated(d->extra->activeLink); Executed by:
| 48 | ||||||||||||||||||||||||
2762 | else | - | ||||||||||||||||||||||||
2763 | event->setAccepted(false); executed 18 times by 2 tests: event->setAccepted(false); Executed by:
| 18 | ||||||||||||||||||||||||
2764 | - | |||||||||||||||||||||||||
2765 | if (!event->isAccepted())
| 18-48 | ||||||||||||||||||||||||
2766 | QQuickItem::mouseReleaseEvent(event); executed 18 times by 2 tests: QQuickItem::mouseReleaseEvent(event); Executed by:
| 18 | ||||||||||||||||||||||||
2767 | } executed 66 times by 2 tests: end of block Executed by:
| 66 | ||||||||||||||||||||||||
2768 | - | |||||||||||||||||||||||||
2769 | bool QQuickTextPrivate::isLinkHoveredConnected() | - | ||||||||||||||||||||||||
2770 | { | - | ||||||||||||||||||||||||
2771 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
2772 | IS_SIGNAL_CONNECTED(q, QQuickText, linkHovered, (const QString &)); executed 354 times by 2 tests: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); Executed by:
| 354 | ||||||||||||||||||||||||
2773 | } | - | ||||||||||||||||||||||||
2774 | - | |||||||||||||||||||||||||
2775 | /*! | - | ||||||||||||||||||||||||
2776 | \qmlsignal QtQuick::Text::linkHovered(string link) | - | ||||||||||||||||||||||||
2777 | \since 5.2 | - | ||||||||||||||||||||||||
2778 | - | |||||||||||||||||||||||||
2779 | This signal is emitted when the user hovers a link embedded in the | - | ||||||||||||||||||||||||
2780 | text. The link must be in rich text or HTML format and the \a link | - | ||||||||||||||||||||||||
2781 | string provides access to the particular link. | - | ||||||||||||||||||||||||
2782 | - | |||||||||||||||||||||||||
2783 | The corresponding handler is \c onLinkHovered. | - | ||||||||||||||||||||||||
2784 | - | |||||||||||||||||||||||||
2785 | \sa hoveredLink, linkAt() | - | ||||||||||||||||||||||||
2786 | */ | - | ||||||||||||||||||||||||
2787 | - | |||||||||||||||||||||||||
2788 | /*! | - | ||||||||||||||||||||||||
2789 | \qmlproperty string QtQuick::Text::hoveredLink | - | ||||||||||||||||||||||||
2790 | \since 5.2 | - | ||||||||||||||||||||||||
2791 | - | |||||||||||||||||||||||||
2792 | This property contains the link string when the user hovers a link | - | ||||||||||||||||||||||||
2793 | embedded in the text. The link must be in rich text or HTML format | - | ||||||||||||||||||||||||
2794 | and the \a hoveredLink string provides access to the particular link. | - | ||||||||||||||||||||||||
2795 | - | |||||||||||||||||||||||||
2796 | \sa linkHovered, linkAt() | - | ||||||||||||||||||||||||
2797 | */ | - | ||||||||||||||||||||||||
2798 | - | |||||||||||||||||||||||||
2799 | QString QQuickText::hoveredLink() const | - | ||||||||||||||||||||||||
2800 | { | - | ||||||||||||||||||||||||
2801 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2802 | if (const_cast<QQuickTextPrivate *>(d)->isLinkHoveredConnected()) {
| 16-192 | ||||||||||||||||||||||||
2803 | if (d->extra.isAllocated())
| 8-184 | ||||||||||||||||||||||||
2804 | return d->extra->hoveredLink; executed 184 times by 1 test: return d->extra->hoveredLink; Executed by:
| 184 | ||||||||||||||||||||||||
2805 | } else { executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
2806 | #if QT_CONFIG(cursor) | - | ||||||||||||||||||||||||
2807 | if (QQuickWindow *wnd = window()) {
| 0-16 | ||||||||||||||||||||||||
2808 | QPointF pos = QCursor::pos(wnd->screen()) - wnd->position() - mapToScene(QPointF(0, 0)); | - | ||||||||||||||||||||||||
2809 | return d->anchorAt(pos); never executed: return d->anchorAt(pos); | 0 | ||||||||||||||||||||||||
2810 | } | - | ||||||||||||||||||||||||
2811 | #endif // cursor | - | ||||||||||||||||||||||||
2812 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
2813 | return QString(); executed 24 times by 2 tests: return QString(); Executed by:
| 24 | ||||||||||||||||||||||||
2814 | } | - | ||||||||||||||||||||||||
2815 | - | |||||||||||||||||||||||||
2816 | void QQuickTextPrivate::processHoverEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
2817 | { | - | ||||||||||||||||||||||||
2818 | Q_Q(QQuickText); | - | ||||||||||||||||||||||||
2819 | qCDebug(DBG_HOVER_TRACE) << q; never executed: QMessageLogger(__FILE__, 2819, __PRETTY_FUNCTION__, DBG_HOVER_TRACE().categoryName()).debug() << q;
| 0-146 | ||||||||||||||||||||||||
2820 | QString link; | - | ||||||||||||||||||||||||
2821 | if (isLinkHoveredConnected()) {
| 0-146 | ||||||||||||||||||||||||
2822 | if (event->type() != QEvent::HoverLeave)
| 64-82 | ||||||||||||||||||||||||
2823 | link = anchorAt(event->posF()); executed 82 times by 1 test: link = anchorAt(event->posF()); Executed by:
| 82 | ||||||||||||||||||||||||
2824 | - | |||||||||||||||||||||||||
2825 | if ((!extra.isAllocated() && !link.isEmpty()) || (extra.isAllocated() && extra->hoveredLink != link)) {
| 6-104 | ||||||||||||||||||||||||
2826 | extra.value().hoveredLink = link; | - | ||||||||||||||||||||||||
2827 | emit q->linkHovered(extra->hoveredLink); | - | ||||||||||||||||||||||||
2828 | } executed 128 times by 1 test: end of block Executed by:
| 128 | ||||||||||||||||||||||||
2829 | } executed 146 times by 1 test: end of block Executed by:
| 146 | ||||||||||||||||||||||||
2830 | event->setAccepted(!link.isEmpty()); | - | ||||||||||||||||||||||||
2831 | } executed 146 times by 1 test: end of block Executed by:
| 146 | ||||||||||||||||||||||||
2832 | - | |||||||||||||||||||||||||
2833 | void QQuickText::hoverEnterEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
2834 | { | - | ||||||||||||||||||||||||
2835 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2836 | d->processHoverEvent(event); | - | ||||||||||||||||||||||||
2837 | } executed 64 times by 1 test: end of block Executed by:
| 64 | ||||||||||||||||||||||||
2838 | - | |||||||||||||||||||||||||
2839 | void QQuickText::hoverMoveEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
2840 | { | - | ||||||||||||||||||||||||
2841 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2842 | d->processHoverEvent(event); | - | ||||||||||||||||||||||||
2843 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
2844 | - | |||||||||||||||||||||||||
2845 | void QQuickText::hoverLeaveEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||
2846 | { | - | ||||||||||||||||||||||||
2847 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2848 | d->processHoverEvent(event); | - | ||||||||||||||||||||||||
2849 | } executed 64 times by 1 test: end of block Executed by:
| 64 | ||||||||||||||||||||||||
2850 | - | |||||||||||||||||||||||||
2851 | /*! | - | ||||||||||||||||||||||||
2852 | \qmlproperty enumeration QtQuick::Text::renderType | - | ||||||||||||||||||||||||
2853 | - | |||||||||||||||||||||||||
2854 | Override the default rendering type for this component. | - | ||||||||||||||||||||||||
2855 | - | |||||||||||||||||||||||||
2856 | Supported render types are: | - | ||||||||||||||||||||||||
2857 | \list | - | ||||||||||||||||||||||||
2858 | \li Text.QtRendering | - | ||||||||||||||||||||||||
2859 | \li Text.NativeRendering | - | ||||||||||||||||||||||||
2860 | \endlist | - | ||||||||||||||||||||||||
2861 | - | |||||||||||||||||||||||||
2862 | Select Text.NativeRendering if you prefer text to look native on the target platform and do | - | ||||||||||||||||||||||||
2863 | not require advanced features such as transformation of the text. Using such features in | - | ||||||||||||||||||||||||
2864 | combination with the NativeRendering render type will lend poor and sometimes pixelated | - | ||||||||||||||||||||||||
2865 | results. | - | ||||||||||||||||||||||||
2866 | - | |||||||||||||||||||||||||
2867 | The default rendering type is determined by \l QQuickWindow::textRenderType(). | - | ||||||||||||||||||||||||
2868 | */ | - | ||||||||||||||||||||||||
2869 | QQuickText::RenderType QQuickText::renderType() const | - | ||||||||||||||||||||||||
2870 | { | - | ||||||||||||||||||||||||
2871 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2872 | return d->renderType; executed 22 times by 2 tests: return d->renderType; Executed by:
| 22 | ||||||||||||||||||||||||
2873 | } | - | ||||||||||||||||||||||||
2874 | - | |||||||||||||||||||||||||
2875 | void QQuickText::setRenderType(QQuickText::RenderType renderType) | - | ||||||||||||||||||||||||
2876 | { | - | ||||||||||||||||||||||||
2877 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2878 | if (d->renderType == renderType)
| 4-76 | ||||||||||||||||||||||||
2879 | return; executed 4 times by 2 tests: return; Executed by:
| 4 | ||||||||||||||||||||||||
2880 | - | |||||||||||||||||||||||||
2881 | d->renderType = renderType; | - | ||||||||||||||||||||||||
2882 | emit renderTypeChanged(); | - | ||||||||||||||||||||||||
2883 | - | |||||||||||||||||||||||||
2884 | if (isComponentComplete())
| 4-72 | ||||||||||||||||||||||||
2885 | d->updateLayout(); executed 4 times by 1 test: d->updateLayout(); Executed by:
| 4 | ||||||||||||||||||||||||
2886 | } executed 76 times by 2 tests: end of block Executed by:
| 76 | ||||||||||||||||||||||||
2887 | - | |||||||||||||||||||||||||
2888 | /*! | - | ||||||||||||||||||||||||
2889 | \qmlmethod QtQuick::Text::doLayout() | - | ||||||||||||||||||||||||
2890 | \deprecated | - | ||||||||||||||||||||||||
2891 | - | |||||||||||||||||||||||||
2892 | Use \l forceLayout() instead. | - | ||||||||||||||||||||||||
2893 | */ | - | ||||||||||||||||||||||||
2894 | void QQuickText::doLayout() | - | ||||||||||||||||||||||||
2895 | { | - | ||||||||||||||||||||||||
2896 | forceLayout(); | - | ||||||||||||||||||||||||
2897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2898 | - | |||||||||||||||||||||||||
2899 | /*! | - | ||||||||||||||||||||||||
2900 | \qmlmethod QtQuick::Text::forceLayout() | - | ||||||||||||||||||||||||
2901 | \since 5.9 | - | ||||||||||||||||||||||||
2902 | - | |||||||||||||||||||||||||
2903 | Triggers a re-layout of the displayed text. | - | ||||||||||||||||||||||||
2904 | */ | - | ||||||||||||||||||||||||
2905 | void QQuickText::forceLayout() | - | ||||||||||||||||||||||||
2906 | { | - | ||||||||||||||||||||||||
2907 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2908 | d->updateSize(); | - | ||||||||||||||||||||||||
2909 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2910 | - | |||||||||||||||||||||||||
2911 | /*! | - | ||||||||||||||||||||||||
2912 | \qmlmethod QtQuick::Text::linkAt(real x, real y) | - | ||||||||||||||||||||||||
2913 | \since 5.3 | - | ||||||||||||||||||||||||
2914 | - | |||||||||||||||||||||||||
2915 | Returns the link string at point \a x, \a y in content coordinates, | - | ||||||||||||||||||||||||
2916 | or an empty string if no link exists at that point. | - | ||||||||||||||||||||||||
2917 | - | |||||||||||||||||||||||||
2918 | \sa hoveredLink | - | ||||||||||||||||||||||||
2919 | */ | - | ||||||||||||||||||||||||
2920 | QString QQuickText::linkAt(qreal x, qreal y) const | - | ||||||||||||||||||||||||
2921 | { | - | ||||||||||||||||||||||||
2922 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2923 | return d->anchorAt(QPointF(x, y)); executed 192 times by 1 test: return d->anchorAt(QPointF(x, y)); Executed by:
| 192 | ||||||||||||||||||||||||
2924 | } | - | ||||||||||||||||||||||||
2925 | - | |||||||||||||||||||||||||
2926 | /*! | - | ||||||||||||||||||||||||
2927 | * \internal | - | ||||||||||||||||||||||||
2928 | * | - | ||||||||||||||||||||||||
2929 | * Invalidates font caches owned by the text objects owned by the element | - | ||||||||||||||||||||||||
2930 | * to work around the fact that text objects cannot be used from multiple threads. | - | ||||||||||||||||||||||||
2931 | */ | - | ||||||||||||||||||||||||
2932 | void QQuickText::invalidateFontCaches() | - | ||||||||||||||||||||||||
2933 | { | - | ||||||||||||||||||||||||
2934 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2935 | - | |||||||||||||||||||||||||
2936 | if (d->richText && d->extra.isAllocated() && d->extra->doc != nullptr) {
| 0-540829 | ||||||||||||||||||||||||
2937 | QTextBlock block; | - | ||||||||||||||||||||||||
2938 | for (block = d->extra->doc->firstBlock(); block.isValid(); block = block.next()) {
| 174-222 | ||||||||||||||||||||||||
2939 | if (block.layout() != nullptr && block.layout()->engine() != nullptr)
| 0-222 | ||||||||||||||||||||||||
2940 | block.layout()->engine()->resetFontEngineCache(); executed 222 times by 2 tests: block.layout()->engine()->resetFontEngineCache(); Executed by:
| 222 | ||||||||||||||||||||||||
2941 | } executed 222 times by 2 tests: end of block Executed by:
| 222 | ||||||||||||||||||||||||
2942 | } else { executed 174 times by 2 tests: end of block Executed by:
| 174 | ||||||||||||||||||||||||
2943 | if (d->layout.engine() != nullptr)
| 0-540829 | ||||||||||||||||||||||||
2944 | d->layout.engine()->resetFontEngineCache(); executed 540829 times by 21 tests: d->layout.engine()->resetFontEngineCache(); Executed by:
| 540829 | ||||||||||||||||||||||||
2945 | } executed 540829 times by 21 tests: end of block Executed by:
| 540829 | ||||||||||||||||||||||||
2946 | } | - | ||||||||||||||||||||||||
2947 | - | |||||||||||||||||||||||||
2948 | /*! | - | ||||||||||||||||||||||||
2949 | \since 5.6 | - | ||||||||||||||||||||||||
2950 | \qmlproperty real QtQuick::Text::padding | - | ||||||||||||||||||||||||
2951 | \qmlproperty real QtQuick::Text::topPadding | - | ||||||||||||||||||||||||
2952 | \qmlproperty real QtQuick::Text::leftPadding | - | ||||||||||||||||||||||||
2953 | \qmlproperty real QtQuick::Text::bottomPadding | - | ||||||||||||||||||||||||
2954 | \qmlproperty real QtQuick::Text::rightPadding | - | ||||||||||||||||||||||||
2955 | - | |||||||||||||||||||||||||
2956 | These properties hold the padding around the content. This space is reserved | - | ||||||||||||||||||||||||
2957 | in addition to the contentWidth and contentHeight. | - | ||||||||||||||||||||||||
2958 | */ | - | ||||||||||||||||||||||||
2959 | qreal QQuickText::padding() const | - | ||||||||||||||||||||||||
2960 | { | - | ||||||||||||||||||||||||
2961 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2962 | return d->padding(); executed 18 times by 2 tests: return d->padding(); Executed by:
| 18 | ||||||||||||||||||||||||
2963 | } | - | ||||||||||||||||||||||||
2964 | - | |||||||||||||||||||||||||
2965 | void QQuickText::setPadding(qreal padding) | - | ||||||||||||||||||||||||
2966 | { | - | ||||||||||||||||||||||||
2967 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
2968 | if (qFuzzyCompare(d->padding(), padding))
| 0-4 | ||||||||||||||||||||||||
2969 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2970 | - | |||||||||||||||||||||||||
2971 | d->extra.value().padding = padding; | - | ||||||||||||||||||||||||
2972 | d->updateSize(); | - | ||||||||||||||||||||||||
2973 | emit paddingChanged(); | - | ||||||||||||||||||||||||
2974 | if (!d->extra.isAllocated() || !d->extra->explicitTopPadding)
| 0-4 | ||||||||||||||||||||||||
2975 | emit topPaddingChanged(); executed 2 times by 1 test: topPaddingChanged(); Executed by:
| 2 | ||||||||||||||||||||||||
2976 | if (!d->extra.isAllocated() || !d->extra->explicitLeftPadding)
| 0-4 | ||||||||||||||||||||||||
2977 | emit leftPaddingChanged(); executed 2 times by 1 test: leftPaddingChanged(); Executed by:
| 2 | ||||||||||||||||||||||||
2978 | if (!d->extra.isAllocated() || !d->extra->explicitRightPadding)
| 0-4 | ||||||||||||||||||||||||
2979 | emit rightPaddingChanged(); executed 2 times by 1 test: rightPaddingChanged(); Executed by:
| 2 | ||||||||||||||||||||||||
2980 | if (!d->extra.isAllocated() || !d->extra->explicitBottomPadding)
| 0-4 | ||||||||||||||||||||||||
2981 | emit bottomPaddingChanged(); executed 2 times by 1 test: bottomPaddingChanged(); Executed by:
| 2 | ||||||||||||||||||||||||
2982 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2983 | - | |||||||||||||||||||||||||
2984 | void QQuickText::resetPadding() | - | ||||||||||||||||||||||||
2985 | { | - | ||||||||||||||||||||||||
2986 | setPadding(0); | - | ||||||||||||||||||||||||
2987 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2988 | - | |||||||||||||||||||||||||
2989 | qreal QQuickText::topPadding() const | - | ||||||||||||||||||||||||
2990 | { | - | ||||||||||||||||||||||||
2991 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
2992 | if (d->extra.isAllocated() && d->extra->explicitTopPadding)
| 896-2713358 | ||||||||||||||||||||||||
2993 | return d->extra->topPadding; executed 896 times by 1 test: return d->extra->topPadding; Executed by:
| 896 | ||||||||||||||||||||||||
2994 | return d->padding(); executed 2718982 times by 35 tests: return d->padding(); Executed by:
| 2718982 | ||||||||||||||||||||||||
2995 | } | - | ||||||||||||||||||||||||
2996 | - | |||||||||||||||||||||||||
2997 | void QQuickText::setTopPadding(qreal padding) | - | ||||||||||||||||||||||||
2998 | { | - | ||||||||||||||||||||||||
2999 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
3000 | d->setTopPadding(padding); | - | ||||||||||||||||||||||||
3001 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
3002 | - | |||||||||||||||||||||||||
3003 | void QQuickText::resetTopPadding() | - | ||||||||||||||||||||||||
3004 | { | - | ||||||||||||||||||||||||
3005 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
3006 | d->setTopPadding(0, true); | - | ||||||||||||||||||||||||
3007 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3008 | - | |||||||||||||||||||||||||
3009 | qreal QQuickText::leftPadding() const | - | ||||||||||||||||||||||||
3010 | { | - | ||||||||||||||||||||||||
3011 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
3012 | if (d->extra.isAllocated() && d->extra->explicitLeftPadding)
| 132-2238461 | ||||||||||||||||||||||||
3013 | return d->extra->leftPadding; executed 132 times by 1 test: return d->extra->leftPadding; Executed by:
| 132 | ||||||||||||||||||||||||
3014 | return d->padding(); executed 2243153 times by 35 tests: return d->padding(); Executed by:
| 2243153 | ||||||||||||||||||||||||
3015 | } | - | ||||||||||||||||||||||||
3016 | - | |||||||||||||||||||||||||
3017 | void QQuickText::setLeftPadding(qreal padding) | - | ||||||||||||||||||||||||
3018 | { | - | ||||||||||||||||||||||||
3019 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
3020 | d->setLeftPadding(padding); | - | ||||||||||||||||||||||||
3021 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3022 | - | |||||||||||||||||||||||||
3023 | void QQuickText::resetLeftPadding() | - | ||||||||||||||||||||||||
3024 | { | - | ||||||||||||||||||||||||
3025 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
3026 | d->setLeftPadding(0, true); | - | ||||||||||||||||||||||||
3027 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3028 | - | |||||||||||||||||||||||||
3029 | qreal QQuickText::rightPadding() const | - | ||||||||||||||||||||||||
3030 | { | - | ||||||||||||||||||||||||
3031 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
3032 | if (d->extra.isAllocated() && d->extra->explicitRightPadding)
| 138-1990419 | ||||||||||||||||||||||||
3033 | return d->extra->rightPadding; executed 138 times by 1 test: return d->extra->rightPadding; Executed by:
| 138 | ||||||||||||||||||||||||
3034 | return d->padding(); executed 1994365 times by 35 tests: return d->padding(); Executed by:
| 1994365 | ||||||||||||||||||||||||
3035 | } | - | ||||||||||||||||||||||||
3036 | - | |||||||||||||||||||||||||
3037 | void QQuickText::setRightPadding(qreal padding) | - | ||||||||||||||||||||||||
3038 | { | - | ||||||||||||||||||||||||
3039 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
3040 | d->setRightPadding(padding); | - | ||||||||||||||||||||||||
3041 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3042 | - | |||||||||||||||||||||||||
3043 | void QQuickText::resetRightPadding() | - | ||||||||||||||||||||||||
3044 | { | - | ||||||||||||||||||||||||
3045 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
3046 | d->setRightPadding(0, true); | - | ||||||||||||||||||||||||
3047 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3048 | - | |||||||||||||||||||||||||
3049 | qreal QQuickText::bottomPadding() const | - | ||||||||||||||||||||||||
3050 | { | - | ||||||||||||||||||||||||
3051 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
3052 | if (d->extra.isAllocated() && d->extra->explicitBottomPadding)
| 694-1993371 | ||||||||||||||||||||||||
3053 | return d->extra->bottomPadding; executed 694 times by 1 test: return d->extra->bottomPadding; Executed by:
| 694 | ||||||||||||||||||||||||
3054 | return d->padding(); executed 1997255 times by 35 tests: return d->padding(); Executed by:
| 1997255 | ||||||||||||||||||||||||
3055 | } | - | ||||||||||||||||||||||||
3056 | - | |||||||||||||||||||||||||
3057 | void QQuickText::setBottomPadding(qreal padding) | - | ||||||||||||||||||||||||
3058 | { | - | ||||||||||||||||||||||||
3059 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
3060 | d->setBottomPadding(padding); | - | ||||||||||||||||||||||||
3061 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
3062 | - | |||||||||||||||||||||||||
3063 | void QQuickText::resetBottomPadding() | - | ||||||||||||||||||||||||
3064 | { | - | ||||||||||||||||||||||||
3065 | Q_D(QQuickText); | - | ||||||||||||||||||||||||
3066 | d->setBottomPadding(0, true); | - | ||||||||||||||||||||||||
3067 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3068 | - | |||||||||||||||||||||||||
3069 | /*! | - | ||||||||||||||||||||||||
3070 | \qmlproperty string QtQuick::Text::fontInfo.family | - | ||||||||||||||||||||||||
3071 | \since 5.9 | - | ||||||||||||||||||||||||
3072 | - | |||||||||||||||||||||||||
3073 | The family name of the font that has been resolved for the current font | - | ||||||||||||||||||||||||
3074 | and fontSizeMode. | - | ||||||||||||||||||||||||
3075 | */ | - | ||||||||||||||||||||||||
3076 | - | |||||||||||||||||||||||||
3077 | /*! | - | ||||||||||||||||||||||||
3078 | \qmlproperty string QtQuick::Text::fontInfo.styleName | - | ||||||||||||||||||||||||
3079 | \since 5.9 | - | ||||||||||||||||||||||||
3080 | - | |||||||||||||||||||||||||
3081 | The style name of the font info that has been resolved for the current font | - | ||||||||||||||||||||||||
3082 | and fontSizeMode. | - | ||||||||||||||||||||||||
3083 | */ | - | ||||||||||||||||||||||||
3084 | - | |||||||||||||||||||||||||
3085 | /*! | - | ||||||||||||||||||||||||
3086 | \qmlproperty bool QtQuick::Text::fontInfo.bold | - | ||||||||||||||||||||||||
3087 | \since 5.9 | - | ||||||||||||||||||||||||
3088 | - | |||||||||||||||||||||||||
3089 | The bold state of the font info that has been resolved for the current font | - | ||||||||||||||||||||||||
3090 | and fontSizeMode. This is true if the weight of the resolved font is bold or higher. | - | ||||||||||||||||||||||||
3091 | */ | - | ||||||||||||||||||||||||
3092 | - | |||||||||||||||||||||||||
3093 | /*! | - | ||||||||||||||||||||||||
3094 | \qmlproperty int QtQuick::Text::fontInfo.weight | - | ||||||||||||||||||||||||
3095 | \since 5.9 | - | ||||||||||||||||||||||||
3096 | - | |||||||||||||||||||||||||
3097 | The weight of the font info that has been resolved for the current font | - | ||||||||||||||||||||||||
3098 | and fontSizeMode. | - | ||||||||||||||||||||||||
3099 | */ | - | ||||||||||||||||||||||||
3100 | - | |||||||||||||||||||||||||
3101 | /*! | - | ||||||||||||||||||||||||
3102 | \qmlproperty bool QtQuick::Text::fontInfo.italic | - | ||||||||||||||||||||||||
3103 | \since 5.9 | - | ||||||||||||||||||||||||
3104 | - | |||||||||||||||||||||||||
3105 | The italic state of the font info that has been resolved for the current font | - | ||||||||||||||||||||||||
3106 | and fontSizeMode. | - | ||||||||||||||||||||||||
3107 | */ | - | ||||||||||||||||||||||||
3108 | - | |||||||||||||||||||||||||
3109 | /*! | - | ||||||||||||||||||||||||
3110 | \qmlproperty real QtQuick::Text::fontInfo.pointSize | - | ||||||||||||||||||||||||
3111 | \since 5.9 | - | ||||||||||||||||||||||||
3112 | - | |||||||||||||||||||||||||
3113 | The pointSize of the font info that has been resolved for the current font | - | ||||||||||||||||||||||||
3114 | and fontSizeMode. | - | ||||||||||||||||||||||||
3115 | */ | - | ||||||||||||||||||||||||
3116 | - | |||||||||||||||||||||||||
3117 | /*! | - | ||||||||||||||||||||||||
3118 | \qmlproperty string QtQuick::Text::fontInfo.pixelSize | - | ||||||||||||||||||||||||
3119 | \since 5.9 | - | ||||||||||||||||||||||||
3120 | - | |||||||||||||||||||||||||
3121 | The pixel size of the font info that has been resolved for the current font | - | ||||||||||||||||||||||||
3122 | and fontSizeMode. | - | ||||||||||||||||||||||||
3123 | */ | - | ||||||||||||||||||||||||
3124 | QJSValue QQuickText::fontInfo() const | - | ||||||||||||||||||||||||
3125 | { | - | ||||||||||||||||||||||||
3126 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
3127 | - | |||||||||||||||||||||||||
3128 | QJSEngine *engine = qjsEngine(this); | - | ||||||||||||||||||||||||
3129 | if (!engine) {
| 0-8 | ||||||||||||||||||||||||
3130 | qmlWarning(this) << "fontInfo: item has no JS engine"; | - | ||||||||||||||||||||||||
3131 | return QJSValue(); never executed: return QJSValue(); | 0 | ||||||||||||||||||||||||
3132 | } | - | ||||||||||||||||||||||||
3133 | - | |||||||||||||||||||||||||
3134 | QJSValue value = engine->newObject(); | - | ||||||||||||||||||||||||
3135 | value.setProperty(QStringLiteral("family"), d->fontInfo.family()); executed 8 times by 1 test: return qstring_literal_temp; Executed by:
| 8 | ||||||||||||||||||||||||
3136 | value.setProperty(QStringLiteral("styleName"), d->fontInfo.styleName()); executed 8 times by 1 test: return qstring_literal_temp; Executed by:
| 8 | ||||||||||||||||||||||||
3137 | value.setProperty(QStringLiteral("bold"), d->fontInfo.bold()); executed 8 times by 1 test: return qstring_literal_temp; Executed by:
| 8 | ||||||||||||||||||||||||
3138 | value.setProperty(QStringLiteral("weight"), d->fontInfo.weight()); executed 8 times by 1 test: return qstring_literal_temp; Executed by:
| 8 | ||||||||||||||||||||||||
3139 | value.setProperty(QStringLiteral("italic"), d->fontInfo.italic()); executed 8 times by 1 test: return qstring_literal_temp; Executed by:
| 8 | ||||||||||||||||||||||||
3140 | value.setProperty(QStringLiteral("pointSize"), d->fontInfo.pointSizeF()); executed 8 times by 1 test: return qstring_literal_temp; Executed by:
| 8 | ||||||||||||||||||||||||
3141 | value.setProperty(QStringLiteral("pixelSize"), d->fontInfo.pixelSize()); executed 8 times by 1 test: return qstring_literal_temp; Executed by:
| 8 | ||||||||||||||||||||||||
3142 | return value; executed 8 times by 1 test: return value; Executed by:
| 8 | ||||||||||||||||||||||||
3143 | } | - | ||||||||||||||||||||||||
3144 | - | |||||||||||||||||||||||||
3145 | /*! | - | ||||||||||||||||||||||||
3146 | \qmlproperty size QtQuick::Text::advance | - | ||||||||||||||||||||||||
3147 | \since 5.10 | - | ||||||||||||||||||||||||
3148 | - | |||||||||||||||||||||||||
3149 | The distance, in pixels, from the baseline origin of the first | - | ||||||||||||||||||||||||
3150 | character of the text item, to the baseline origin of the first | - | ||||||||||||||||||||||||
3151 | character in a text item occurring directly after this one | - | ||||||||||||||||||||||||
3152 | in a text flow. | - | ||||||||||||||||||||||||
3153 | - | |||||||||||||||||||||||||
3154 | Note that the advance can be negative if the text flows from | - | ||||||||||||||||||||||||
3155 | the right to the left. | - | ||||||||||||||||||||||||
3156 | */ | - | ||||||||||||||||||||||||
3157 | QSizeF QQuickText::advance() const | - | ||||||||||||||||||||||||
3158 | { | - | ||||||||||||||||||||||||
3159 | Q_D(const QQuickText); | - | ||||||||||||||||||||||||
3160 | return d->advance; executed 16 times by 1 test: return d->advance; Executed by:
| 16 | ||||||||||||||||||||||||
3161 | } | - | ||||||||||||||||||||||||
3162 | - | |||||||||||||||||||||||||
3163 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
3164 | - | |||||||||||||||||||||||||
3165 | #include "moc_qquicktext_p.cpp" | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |