widgets/qlabel.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui 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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qpainter.h" -
43#include "qevent.h" -
44#include "qdrawutil.h" -
45#include "qapplication.h" -
46#include "qabstractbutton.h" -
47#include "qstyle.h" -
48#include "qstyleoption.h" -
49#include <limits.h> -
50#include "qaction.h" -
51#include "qclipboard.h" -
52#include <qdebug.h> -
53#include <qurl.h> -
54#include "qlabel_p.h" -
55#include "private/qstylesheetstyle_p.h" -
56#include <qmath.h> -
57 -
58#ifndef QT_NO_ACCESSIBILITY -
59#include <qaccessible.h> -
60#endif -
61 -
62QT_BEGIN_NAMESPACE -
63 -
64/*! -
65 \class QLabel -
66 \brief The QLabel widget provides a text or image display. -
67 -
68 \ingroup basicwidgets -
69 \inmodule QtWidgets -
70 -
71 QLabel is used for displaying text or an image. No user -
72 interaction functionality is provided. The visual appearance of -
73 the label can be configured in various ways, and it can be used -
74 for specifying a focus mnemonic key for another widget. -
75 -
76 A QLabel can contain any of the following content types: -
77 -
78 \table -
79 \header \li Content \li Setting -
80 \row \li Plain text -
81 \li Pass a QString to setText(). -
82 \row \li Rich text -
83 \li Pass a QString that contains rich text to setText(). -
84 \row \li A pixmap -
85 \li Pass a QPixmap to setPixmap(). -
86 \row \li A movie -
87 \li Pass a QMovie to setMovie(). -
88 \row \li A number -
89 \li Pass an \e int or a \e double to setNum(), which converts -
90 the number to plain text. -
91 \row \li Nothing -
92 \li The same as an empty plain text. This is the default. Set -
93 by clear(). -
94 \endtable -
95 -
96 \warning When passing a QString to the constructor or calling setText(), -
97 make sure to sanitize your input, as QLabel tries to guess whether it -
98 displays the text as plain text or as rich text, a subset of HTML 4 -
99 markup. You may want to call -
100 setTextFormat() explicitly, e.g. in case you expect the text to be in -
101 plain format but cannot control the text source (for instance when -
102 displaying data loaded from the Web). -
103 -
104 When the content is changed using any of these functions, any -
105 previous content is cleared. -
106 -
107 By default, labels display \l{alignment}{left-aligned, vertically-centered} -
108 text and images, where any tabs in the text to be displayed are -
109 \l{Qt::TextExpandTabs}{automatically expanded}. However, the look -
110 of a QLabel can be adjusted and fine-tuned in several ways. -
111 -
112 The positioning of the content within the QLabel widget area can -
113 be tuned with setAlignment() and setIndent(). Text content can -
114 also wrap lines along word boundaries with setWordWrap(). For -
115 example, this code sets up a sunken panel with a two-line text in -
116 the bottom right corner (both lines being flush with the right -
117 side of the label): -
118 -
119 \snippet code/src_gui_widgets_qlabel.cpp 0 -
120 -
121 The properties and functions QLabel inherits from QFrame can also -
122 be used to specify the widget frame to be used for any given label. -
123 -
124 A QLabel is often used as a label for an interactive widget. For -
125 this use QLabel provides a useful mechanism for adding an -
126 mnemonic (see QKeySequence) that will set the keyboard focus to -
127 the other widget (called the QLabel's "buddy"). For example: -
128 -
129 \snippet code/src_gui_widgets_qlabel.cpp 1 -
130 -
131 In this example, keyboard focus is transferred to the label's -
132 buddy (the QLineEdit) when the user presses Alt+P. If the buddy -
133 was a button (inheriting from QAbstractButton), triggering the -
134 mnemonic would emulate a button click. -
135 -
136 \table 100% -
137 \row -
138 \li \inlineimage macintosh-label.png Screenshot of a Macintosh style label -
139 \li A label shown in the \l{Macintosh Style Widget Gallery}{Macintosh widget style}. -
140 \row -
141 \li \inlineimage fusion-label.png Screenshot of a Fusion style label -
142 \li A label shown in the \l{Fusion Style Widget Gallery}{Fusion widget style}. -
143 \row -
144 \li \inlineimage windowsvista-label.png Screenshot of a Windows Vista style label -
145 \li A label shown in the \l{Windows Vista Style Widget Gallery}{Windows Vista widget style}. -
146 \endtable -
147 -
148 \sa QLineEdit, QTextEdit, QPixmap, QMovie, -
149 {fowler}{GUI Design Handbook: Label} -
150*/ -
151 -
152#ifndef QT_NO_PICTURE -
153/*! -
154 Returns the label's picture or 0 if the label doesn't have a -
155 picture. -
156*/ -
157 -
158const QPicture *QLabel::picture() const -
159{ -
160 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
161 return d->picture;
executed: return d->picture;
Execution Count:2
2
162} -
163#endif -
164 -
165 -
166/*! -
167 Constructs an empty label. -
168 -
169 The \a parent and widget flag \a f, arguments are passed -
170 to the QFrame constructor. -
171 -
172 \sa setAlignment(), setFrameStyle(), setIndent() -
173*/ -
174QLabel::QLabel(QWidget *parent, Qt::WindowFlags f) -
175 : QFrame(*new QLabelPrivate(), parent, f) -
176{ -
177 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
178 d->init();
executed (the execution status of this line is deduced): d->init();
-
179}
executed: }
Execution Count:892
892
180 -
181/*! -
182 Constructs a label that displays the text, \a text. -
183 -
184 The \a parent and widget flag \a f, arguments are passed -
185 to the QFrame constructor. -
186 -
187 \sa setText(), setAlignment(), setFrameStyle(), setIndent() -
188*/ -
189QLabel::QLabel(const QString &text, QWidget *parent, Qt::WindowFlags f) -
190 : QFrame(*new QLabelPrivate(), parent, f) -
191{ -
192 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
193 d->init();
executed (the execution status of this line is deduced): d->init();
-
194 setText(text);
executed (the execution status of this line is deduced): setText(text);
-
195}
executed: }
Execution Count:161
161
196 -
197 -
198 -
199/*! -
200 Destroys the label. -
201*/ -
202 -
203QLabel::~QLabel() -
204{ -
205 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
206 d->clearContents();
executed (the execution status of this line is deduced): d->clearContents();
-
207}
executed: }
Execution Count:1039
1039
208 -
209void QLabelPrivate::init() -
210{ -
211 Q_Q(QLabel);
executed (the execution status of this line is deduced): QLabel * const q = q_func();
-
212 -
213 valid_hints = false;
executed (the execution status of this line is deduced): valid_hints = false;
-
214 margin = 0;
executed (the execution status of this line is deduced): margin = 0;
-
215#ifndef QT_NO_MOVIE -
216 movie = 0;
executed (the execution status of this line is deduced): movie = 0;
-
217#endif -
218#ifndef QT_NO_SHORTCUT -
219 shortcutId = 0;
executed (the execution status of this line is deduced): shortcutId = 0;
-
220#endif -
221 pixmap = 0;
executed (the execution status of this line is deduced): pixmap = 0;
-
222 scaledpixmap = 0;
executed (the execution status of this line is deduced): scaledpixmap = 0;
-
223 cachedimage = 0;
executed (the execution status of this line is deduced): cachedimage = 0;
-
224#ifndef QT_NO_PICTURE -
225 picture = 0;
executed (the execution status of this line is deduced): picture = 0;
-
226#endif -
227 align = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextExpandTabs;
executed (the execution status of this line is deduced): align = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextExpandTabs;
-
228 indent = -1;
executed (the execution status of this line is deduced): indent = -1;
-
229 scaledcontents = false;
executed (the execution status of this line is deduced): scaledcontents = false;
-
230 textLayoutDirty = false;
executed (the execution status of this line is deduced): textLayoutDirty = false;
-
231 textDirty = false;
executed (the execution status of this line is deduced): textDirty = false;
-
232 textformat = Qt::AutoText;
executed (the execution status of this line is deduced): textformat = Qt::AutoText;
-
233 control = 0;
executed (the execution status of this line is deduced): control = 0;
-
234 textInteractionFlags = Qt::LinksAccessibleByMouse;
executed (the execution status of this line is deduced): textInteractionFlags = Qt::LinksAccessibleByMouse;
-
235 isRichText = false;
executed (the execution status of this line is deduced): isRichText = false;
-
236 isTextLabel = false;
executed (the execution status of this line is deduced): isTextLabel = false;
-
237 -
238 q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred,
executed (the execution status of this line is deduced): q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred,
-
239 QSizePolicy::Label));
executed (the execution status of this line is deduced): QSizePolicy::Label));
-
240 -
241#ifndef QT_NO_CURSOR -
242 validCursor = false;
executed (the execution status of this line is deduced): validCursor = false;
-
243 onAnchor = false;
executed (the execution status of this line is deduced): onAnchor = false;
-
244#endif -
245 -
246 openExternalLinks = false;
executed (the execution status of this line is deduced): openExternalLinks = false;
-
247 -
248 setLayoutItemMargins(QStyle::SE_LabelLayoutItem);
executed (the execution status of this line is deduced): setLayoutItemMargins(QStyle::SE_LabelLayoutItem);
-
249}
executed: }
Execution Count:1053
1053
250 -
251 -
252/*! -
253 \property QLabel::text -
254 \brief the label's text -
255 -
256 If no text has been set this will return an empty string. Setting -
257 the text clears any previous content. -
258 -
259 The text will be interpreted either as plain text or as rich -
260 text, depending on the text format setting; see setTextFormat(). -
261 The default setting is Qt::AutoText; i.e. QLabel will try to -
262 auto-detect the format of the text set. -
263 See \l {Supported HTML Subset} for the definition of rich text. -
264 -
265 If a buddy has been set, the buddy mnemonic key is updated -
266 from the new text. -
267 -
268 Note that QLabel is well-suited to display small rich text -
269 documents, such as small documents that get their document -
270 specific settings (font, text color, link color) from the label's -
271 palette and font properties. For large documents, use QTextEdit -
272 in read-only mode instead. QTextEdit can also provide a scroll bar -
273 when necessary. -
274 -
275 \note This function enables mouse tracking if \a text contains rich -
276 text. -
277 -
278 \sa setTextFormat(), setBuddy(), alignment -
279*/ -
280 -
281void QLabel::setText(const QString &text) -
282{ -
283 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
284 if (d->text == text)
evaluated: d->text == text
TRUEFALSE
yes
Evaluation Count:698
yes
Evaluation Count:1011
698-1011
285 return;
executed: return;
Execution Count:698
698
286 -
287 QWidgetTextControl *oldControl = d->control;
executed (the execution status of this line is deduced): QWidgetTextControl *oldControl = d->control;
-
288 d->control = 0;
executed (the execution status of this line is deduced): d->control = 0;
-
289 -
290 d->clearContents();
executed (the execution status of this line is deduced): d->clearContents();
-
291 d->text = text;
executed (the execution status of this line is deduced): d->text = text;
-
292 d->isTextLabel = true;
executed (the execution status of this line is deduced): d->isTextLabel = true;
-
293 d->textDirty = true;
executed (the execution status of this line is deduced): d->textDirty = true;
-
294 d->isRichText = d->textformat == Qt::RichText
evaluated: d->textformat == Qt::RichText
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1008
3-1008
295 || (d->textformat == Qt::AutoText && Qt::mightBeRichText(d->text));
evaluated: d->textformat == Qt::AutoText
TRUEFALSE
yes
Evaluation Count:998
yes
Evaluation Count:10
evaluated: Qt::mightBeRichText(d->text)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:990
8-998
296 -
297 d->control = oldControl;
executed (the execution status of this line is deduced): d->control = oldControl;
-
298 -
299 if (d->needTextControl()) {
evaluated: d->needTextControl()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1000
11-1000
300 d->ensureTextControl();
executed (the execution status of this line is deduced): d->ensureTextControl();
-
301 } else {
executed: }
Execution Count:11
11
302 delete d->control;
executed (the execution status of this line is deduced): delete d->control;
-
303 d->control = 0;
executed (the execution status of this line is deduced): d->control = 0;
-
304 }
executed: }
Execution Count:1000
1000
305 -
306 if (d->isRichText) {
evaluated: d->isRichText
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1000
11-1000
307 setMouseTracking(true);
executed (the execution status of this line is deduced): setMouseTracking(true);
-
308 } else {
executed: }
Execution Count:11
11
309 // Note: mouse tracking not disabled intentionally -
310 }
executed: }
Execution Count:1000
1000
311 -
312#ifndef QT_NO_SHORTCUT -
313 if (d->buddy)
evaluated: d->buddy
TRUEFALSE
yes
Evaluation Count:256
yes
Evaluation Count:755
256-755
314 d->updateShortcut();
executed: d->updateShortcut();
Execution Count:256
256
315#endif -
316 -
317 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
318 -
319#ifndef QT_NO_ACCESSIBILITY -
320 if (accessibleName().isEmpty()) {
partially evaluated: accessibleName().isEmpty()
TRUEFALSE
yes
Evaluation Count:1011
no
Evaluation Count:0
0-1011
321 QAccessibleEvent event(this, QAccessible::NameChanged);
executed (the execution status of this line is deduced): QAccessibleEvent event(this, QAccessible::NameChanged);
-
322 QAccessible::updateAccessibility(&event);
executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event);
-
323 }
executed: }
Execution Count:1011
1011
324#endif -
325}
executed: }
Execution Count:1011
1011
326 -
327QString QLabel::text() const -
328{ -
329 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
330 return d->text;
executed: return d->text;
Execution Count:60
60
331} -
332 -
333/*! -
334 Clears any label contents. -
335*/ -
336 -
337void QLabel::clear() -
338{ -
339 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
340 d->clearContents();
executed (the execution status of this line is deduced): d->clearContents();
-
341 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
342}
executed: }
Execution Count:1
1
343 -
344/*! -
345 \property QLabel::pixmap -
346 \brief the label's pixmap -
347 -
348 If no pixmap has been set this will return 0. -
349 -
350 Setting the pixmap clears any previous content. The buddy -
351 shortcut, if any, is disabled. -
352*/ -
353void QLabel::setPixmap(const QPixmap &pixmap) -
354{ -
355 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
356 if (!d->pixmap || d->pixmap->cacheKey() != pixmap.cacheKey()) {
evaluated: !d->pixmap
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:51
evaluated: d->pixmap->cacheKey() != pixmap.cacheKey()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:45
6-54
357 d->clearContents();
executed (the execution status of this line is deduced): d->clearContents();
-
358 d->pixmap = new QPixmap(pixmap);
executed (the execution status of this line is deduced): d->pixmap = new QPixmap(pixmap);
-
359 }
executed: }
Execution Count:60
60
360 -
361 if (d->pixmap->depth() == 1 && !d->pixmap->mask())
partially evaluated: d->pixmap->depth() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:105
never evaluated: !d->pixmap->mask()
0-105
362 d->pixmap->setMask(*((QBitmap *)d->pixmap));
never executed: d->pixmap->setMask(*((QBitmap *)d->pixmap));
0
363 -
364 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
365}
executed: }
Execution Count:105
105
366 -
367const QPixmap *QLabel::pixmap() const -
368{ -
369 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
370 return d->pixmap;
executed: return d->pixmap;
Execution Count:34
34
371} -
372 -
373#ifndef QT_NO_PICTURE -
374/*! -
375 Sets the label contents to \a picture. Any previous content is -
376 cleared. -
377 -
378 The buddy shortcut, if any, is disabled. -
379 -
380 \sa picture(), setBuddy() -
381*/ -
382 -
383void QLabel::setPicture(const QPicture &picture) -
384{ -
385 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
386 d->clearContents();
executed (the execution status of this line is deduced): d->clearContents();
-
387 d->picture = new QPicture(picture);
executed (the execution status of this line is deduced): d->picture = new QPicture(picture);
-
388 -
389 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
390}
executed: }
Execution Count:1
1
391#endif // QT_NO_PICTURE -
392 -
393/*! -
394 Sets the label contents to plain text containing the textual -
395 representation of integer \a num. Any previous content is cleared. -
396 Does nothing if the integer's string representation is the same as -
397 the current contents of the label. -
398 -
399 The buddy shortcut, if any, is disabled. -
400 -
401 \sa setText(), QString::setNum(), setBuddy() -
402*/ -
403 -
404void QLabel::setNum(int num) -
405{ -
406 QString str;
executed (the execution status of this line is deduced): QString str;
-
407 str.setNum(num);
executed (the execution status of this line is deduced): str.setNum(num);
-
408 setText(str);
executed (the execution status of this line is deduced): setText(str);
-
409}
executed: }
Execution Count:1
1
410 -
411/*! -
412 \overload -
413 -
414 Sets the label contents to plain text containing the textual -
415 representation of double \a num. Any previous content is cleared. -
416 Does nothing if the double's string representation is the same as -
417 the current contents of the label. -
418 -
419 The buddy shortcut, if any, is disabled. -
420 -
421 \sa setText(), QString::setNum(), setBuddy() -
422*/ -
423 -
424void QLabel::setNum(double num) -
425{ -
426 QString str;
executed (the execution status of this line is deduced): QString str;
-
427 str.setNum(num);
executed (the execution status of this line is deduced): str.setNum(num);
-
428 setText(str);
executed (the execution status of this line is deduced): setText(str);
-
429}
executed: }
Execution Count:1
1
430 -
431/*! -
432 \property QLabel::alignment -
433 \brief the alignment of the label's contents -
434 -
435 By default, the contents of the label are left-aligned and vertically-centered. -
436 -
437 \sa text -
438*/ -
439 -
440void QLabel::setAlignment(Qt::Alignment alignment) -
441{ -
442 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
443 if (alignment == (d->align & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask)))
evaluated: alignment == (d->align & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask))
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:69
69-83
444 return;
executed: return;
Execution Count:83
83
445 d->align = (d->align & ~(Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask))
executed (the execution status of this line is deduced): d->align = (d->align & ~(Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask))
-
446 | (alignment & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask));
executed (the execution status of this line is deduced): | (alignment & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask));
-
447 -
448 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
449}
executed: }
Execution Count:69
69
450 -
451 -
452Qt::Alignment QLabel::alignment() const -
453{ -
454 Q_D(const QLabel);
never executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
455 return QFlag(d->align & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask));
never executed: return QFlag(d->align & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask));
0
456} -
457 -
458 -
459/*! -
460 \property QLabel::wordWrap -
461 \brief the label's word-wrapping policy -
462 -
463 If this property is true then label text is wrapped where -
464 necessary at word-breaks; otherwise it is not wrapped at all. -
465 -
466 By default, word wrap is disabled. -
467 -
468 \sa text -
469*/ -
470void QLabel::setWordWrap(bool on) -
471{ -
472 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
473 if (on)
evaluated: on
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:133
31-133
474 d->align |= Qt::TextWordWrap;
executed: d->align |= Qt::TextWordWrap;
Execution Count:31
31
475 else -
476 d->align &= ~Qt::TextWordWrap;
executed: d->align &= ~Qt::TextWordWrap;
Execution Count:133
133
477 -
478 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
479}
executed: }
Execution Count:164
164
480 -
481bool QLabel::wordWrap() const -
482{ -
483 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
484 return d->align & Qt::TextWordWrap;
executed: return d->align & Qt::TextWordWrap;
Execution Count:9
9
485} -
486 -
487/*! -
488 \property QLabel::indent -
489 \brief the label's text indent in pixels -
490 -
491 If a label displays text, the indent applies to the left edge if -
492 alignment() is Qt::AlignLeft, to the right edge if alignment() is -
493 Qt::AlignRight, to the top edge if alignment() is Qt::AlignTop, and -
494 to the bottom edge if alignment() is Qt::AlignBottom. -
495 -
496 If indent is negative, or if no indent has been set, the label -
497 computes the effective indent as follows: If frameWidth() is 0, -
498 the effective indent becomes 0. If frameWidth() is greater than 0, -
499 the effective indent becomes half the width of the "x" character -
500 of the widget's current font(). -
501 -
502 By default, the indent is -1, meaning that an effective indent is -
503 calculating in the manner described above. -
504 -
505 \sa alignment, margin, frameWidth(), font() -
506*/ -
507 -
508void QLabel::setIndent(int indent) -
509{ -
510 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
511 d->indent = indent;
executed (the execution status of this line is deduced): d->indent = indent;
-
512 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
513}
executed: }
Execution Count:131
131
514 -
515int QLabel::indent() const -
516{ -
517 Q_D(const QLabel);
never executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
518 return d->indent;
never executed: return d->indent;
0
519} -
520 -
521 -
522/*! -
523 \property QLabel::margin -
524 \brief the width of the margin -
525 -
526 The margin is the distance between the innermost pixel of the -
527 frame and the outermost pixel of contents. -
528 -
529 The default margin is 0. -
530 -
531 \sa indent -
532*/ -
533int QLabel::margin() const -
534{ -
535 Q_D(const QLabel);
never executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
536 return d->margin;
never executed: return d->margin;
0
537} -
538 -
539void QLabel::setMargin(int margin) -
540{ -
541 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
542 if (d->margin == margin)
evaluated: d->margin == margin
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:11
2-11
543 return;
executed: return;
Execution Count:2
2
544 d->margin = margin;
executed (the execution status of this line is deduced): d->margin = margin;
-
545 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
546}
executed: }
Execution Count:11
11
547 -
548/*! -
549 Returns the size that will be used if the width of the label is \a -
550 w. If \a w is -1, the sizeHint() is returned. If \a w is 0 minimumSizeHint() is returned -
551*/ -
552QSize QLabelPrivate::sizeForWidth(int w) const -
553{ -
554 Q_Q(const QLabel);
executed (the execution status of this line is deduced): const QLabel * const q = q_func();
-
555 if(q->minimumWidth() > 0)
evaluated: q->minimumWidth() > 0
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:3127
69-3127
556 w = qMax(w, q->minimumWidth());
executed: w = qMax(w, q->minimumWidth());
Execution Count:69
69
557 QSize contentsMargin(leftmargin + rightmargin, topmargin + bottommargin);
executed (the execution status of this line is deduced): QSize contentsMargin(leftmargin + rightmargin, topmargin + bottommargin);
-
558 -
559 QRect br;
executed (the execution status of this line is deduced): QRect br;
-
560 -
561 int hextra = 2 * margin;
executed (the execution status of this line is deduced): int hextra = 2 * margin;
-
562 int vextra = hextra;
executed (the execution status of this line is deduced): int vextra = hextra;
-
563 QFontMetrics fm = q->fontMetrics();
executed (the execution status of this line is deduced): QFontMetrics fm = q->fontMetrics();
-
564 -
565 if (pixmap && !pixmap->isNull()) {
evaluated: pixmap
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:3105
evaluated: !pixmap->isNull()
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:8
8-3105
566 br = pixmap->rect();
executed (the execution status of this line is deduced): br = pixmap->rect();
-
567 br.setSize(br.size() / pixmap->devicePixelRatio());
executed (the execution status of this line is deduced): br.setSize(br.size() / pixmap->devicePixelRatio());
-
568#ifndef QT_NO_PICTURE -
569 } else if (picture && !picture->isNull()) {
executed: }
Execution Count:83
evaluated: picture
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3112
partially evaluated: !picture->isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-3112
570 br = picture->boundingRect();
never executed (the execution status of this line is deduced): br = picture->boundingRect();
-
571#endif -
572#ifndef QT_NO_MOVIE -
573 } else if (movie && !movie->currentPixmap().isNull()) {
never executed: }
evaluated: movie
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3110
evaluated: !movie->currentPixmap().isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
0-3110
574 br = movie->currentPixmap().rect();
executed (the execution status of this line is deduced): br = movie->currentPixmap().rect();
-
575#endif -
576 } else if (isTextLabel) {
executed: }
Execution Count:2
evaluated: isTextLabel
TRUEFALSE
yes
Evaluation Count:2982
yes
Evaluation Count:129
2-2982
577 int align = QStyle::visualAlignment(textDirection(), QFlag(this->align));
executed (the execution status of this line is deduced): int align = QStyle::visualAlignment(textDirection(), QFlag(this->align));
-
578 // Add indentation -
579 int m = indent;
executed (the execution status of this line is deduced): int m = indent;
-
580 -
581 if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
evaluated: m < 0
TRUEFALSE
yes
Evaluation Count:2473
yes
Evaluation Count:509
evaluated: q->frameWidth()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2464
9-2473
582 m = fm.width(QLatin1Char('x')) - margin*2;
executed: m = fm.width(QLatin1Char('x')) - margin*2;
Execution Count:9
9
583 if (m > 0) {
evaluated: m > 0
TRUEFALSE
yes
Evaluation Count:512
yes
Evaluation Count:2470
512-2470
584 if ((align & Qt::AlignLeft) || (align & Qt::AlignRight))
partially evaluated: (align & Qt::AlignLeft)
TRUEFALSE
yes
Evaluation Count:512
no
Evaluation Count:0
never evaluated: (align & Qt::AlignRight)
0-512
585 hextra += m;
executed: hextra += m;
Execution Count:512
512
586 if ((align & Qt::AlignTop) || (align & Qt::AlignBottom))
evaluated: (align & Qt::AlignTop)
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:481
partially evaluated: (align & Qt::AlignBottom)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:481
0-481
587 vextra += m;
executed: vextra += m;
Execution Count:31
31
588 }
executed: }
Execution Count:512
512
589 -
590 if (control) {
evaluated: control
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:2880
102-2880
591 ensureTextLayouted();
executed (the execution status of this line is deduced): ensureTextLayouted();
-
592 const qreal oldTextWidth = control->textWidth();
executed (the execution status of this line is deduced): const qreal oldTextWidth = control->textWidth();
-
593 // Calculate the length of document if w is the width -
594 if (align & Qt::TextWordWrap) {
evaluated: align & Qt::TextWordWrap
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:45
45-57
595 if (w >= 0) {
evaluated: w >= 0
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:7
7-50
596 w = qMax(w-hextra-contentsMargin.width(), 0); // strip margin and indent
executed (the execution status of this line is deduced): w = qMax(w-hextra-contentsMargin.width(), 0);
-
597 control->setTextWidth(w);
executed (the execution status of this line is deduced): control->setTextWidth(w);
-
598 } else {
executed: }
Execution Count:50
50
599 control->adjustSize();
executed (the execution status of this line is deduced): control->adjustSize();
-
600 }
executed: }
Execution Count:7
7
601 } else { -
602 control->setTextWidth(-1);
executed (the execution status of this line is deduced): control->setTextWidth(-1);
-
603 }
executed: }
Execution Count:45
45
604 -
605 QSizeF controlSize = control->size();
executed (the execution status of this line is deduced): QSizeF controlSize = control->size();
-
606 br = QRect(QPoint(0, 0), QSize(qCeil(controlSize.width()), qCeil(controlSize.height())));
executed (the execution status of this line is deduced): br = QRect(QPoint(0, 0), QSize(qCeil(controlSize.width()), qCeil(controlSize.height())));
-
607 -
608 // restore state -
609 control->setTextWidth(oldTextWidth);
executed (the execution status of this line is deduced): control->setTextWidth(oldTextWidth);
-
610 } else {
executed: }
Execution Count:102
102
611 // Turn off center alignment in order to avoid rounding errors for centering, -
612 // since centering involves a division by 2. At the end, all we want is the size. -
613 int flags = align & ~(Qt::AlignVCenter | Qt::AlignHCenter);
executed (the execution status of this line is deduced): int flags = align & ~(Qt::AlignVCenter | Qt::AlignHCenter);
-
614 if (hasShortcut) {
evaluated: hasShortcut
TRUEFALSE
yes
Evaluation Count:657
yes
Evaluation Count:2223
657-2223
615 flags |= Qt::TextShowMnemonic;
executed (the execution status of this line is deduced): flags |= Qt::TextShowMnemonic;
-
616 QStyleOption opt;
executed (the execution status of this line is deduced): QStyleOption opt;
-
617 opt.initFrom(q);
executed (the execution status of this line is deduced): opt.initFrom(q);
-
618 if (!q->style()->styleHint(QStyle::SH_UnderlineShortcut, &opt, q))
partially evaluated: !q->style()->styleHint(QStyle::SH_UnderlineShortcut, &opt, q)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:657
0-657
619 flags |= Qt::TextHideMnemonic;
never executed: flags |= Qt::TextHideMnemonic;
0
620 }
executed: }
Execution Count:657
657
621 -
622 bool tryWidth = (w < 0) && (align & Qt::TextWordWrap);
evaluated: (w < 0)
TRUEFALSE
yes
Evaluation Count:899
yes
Evaluation Count:1981
evaluated: (align & Qt::TextWordWrap)
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:819
80-1981
623 if (tryWidth)
evaluated: tryWidth
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:2800
80-2800
624 w = qMin(fm.averageCharWidth() * 80, q->maximumSize().width());
executed: w = qMin(fm.averageCharWidth() * 80, q->maximumSize().width());
Execution Count:80
80
625 else if (w < 0)
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:819
yes
Evaluation Count:1981
819-1981
626 w = 2000;
executed: w = 2000;
Execution Count:819
819
627 w -= (hextra + contentsMargin.width());
executed (the execution status of this line is deduced): w -= (hextra + contentsMargin.width());
-
628 br = fm.boundingRect(0, 0, w ,2000, flags, text);
executed (the execution status of this line is deduced): br = fm.boundingRect(0, 0, w ,2000, flags, text);
-
629 if (tryWidth && br.height() < 4*fm.lineSpacing() && br.width() > w/2)
evaluated: tryWidth
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:2800
evaluated: br.height() < 4*fm.lineSpacing()
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:7
evaluated: br.width() > w/2
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:69
4-2800
630 br = fm.boundingRect(0, 0, w/2, 2000, flags, text);
executed: br = fm.boundingRect(0, 0, w/2, 2000, flags, text);
Execution Count:4
4
631 if (tryWidth && br.height() < 2*fm.lineSpacing() && br.width() > w/4)
evaluated: tryWidth
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:2800
evaluated: br.height() < 2*fm.lineSpacing()
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:34
partially evaluated: br.width() > w/4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-2800
632 br = fm.boundingRect(0, 0, w/4, 2000, flags, text);
never executed: br = fm.boundingRect(0, 0, w/4, 2000, flags, text);
0
633 }
executed: }
Execution Count:2880
2880
634 } else { -
635 br = QRect(QPoint(0, 0), QSize(fm.averageCharWidth(), fm.lineSpacing()));
executed (the execution status of this line is deduced): br = QRect(QPoint(0, 0), QSize(fm.averageCharWidth(), fm.lineSpacing()));
-
636 }
executed: }
Execution Count:129
129
637 -
638 const QSize contentsSize(br.width() + hextra, br.height() + vextra);
executed (the execution status of this line is deduced): const QSize contentsSize(br.width() + hextra, br.height() + vextra);
-
639 return (contentsSize + contentsMargin).expandedTo(q->minimumSize());
executed: return (contentsSize + contentsMargin).expandedTo(q->minimumSize());
Execution Count:3196
3196
640} -
641 -
642 -
643/*! -
644 \reimp -
645*/ -
646 -
647int QLabel::heightForWidth(int w) const -
648{ -
649 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
650 if (d->isTextLabel)
partially evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:189
no
Evaluation Count:0
0-189
651 return d->sizeForWidth(w).height();
executed: return d->sizeForWidth(w).height();
Execution Count:189
189
652 return QWidget::heightForWidth(w);
never executed: return QWidget::heightForWidth(w);
0
653} -
654 -
655/*! -
656 \property QLabel::openExternalLinks -
657 \since 4.2 -
658 -
659 Specifies whether QLabel should automatically open links using -
660 QDesktopServices::openUrl() instead of emitting the -
661 linkActivated() signal. -
662 -
663 \b{Note:} The textInteractionFlags set on the label need to include -
664 either LinksAccessibleByMouse or LinksAccessibleByKeyboard. -
665 -
666 The default value is false. -
667 -
668 \sa textInteractionFlags() -
669*/ -
670bool QLabel::openExternalLinks() const -
671{ -
672 Q_D(const QLabel);
never executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
673 return d->openExternalLinks;
never executed: return d->openExternalLinks;
0
674} -
675 -
676void QLabel::setOpenExternalLinks(bool open) -
677{ -
678 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
679 d->openExternalLinks = open;
executed (the execution status of this line is deduced): d->openExternalLinks = open;
-
680 if (d->control)
partially evaluated: d->control
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
681 d->control->setOpenExternalLinks(open);
never executed: d->control->setOpenExternalLinks(open);
0
682}
executed: }
Execution Count:43
43
683 -
684/*! -
685 \property QLabel::textInteractionFlags -
686 \since 4.2 -
687 -
688 Specifies how the label should interact with user input if it displays text. -
689 -
690 If the flags contain Qt::LinksAccessibleByKeyboard the focus policy is also -
691 automatically set to Qt::StrongFocus. If Qt::TextSelectableByKeyboard is set -
692 then the focus policy is set to Qt::ClickFocus. -
693 -
694 The default value is Qt::LinksAccessibleByMouse. -
695*/ -
696void QLabel::setTextInteractionFlags(Qt::TextInteractionFlags flags) -
697{ -
698 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
699 if (d->textInteractionFlags == flags)
evaluated: d->textInteractionFlags == flags
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:19
19-45
700 return;
executed: return;
Execution Count:45
45
701 d->textInteractionFlags = flags;
executed (the execution status of this line is deduced): d->textInteractionFlags = flags;
-
702 if (flags & Qt::LinksAccessibleByKeyboard)
evaluated: flags & Qt::LinksAccessibleByKeyboard
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
703 setFocusPolicy(Qt::StrongFocus);
executed: setFocusPolicy(Qt::StrongFocus);
Execution Count:1
1
704 else if (flags & (Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse))
evaluated: flags & (Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:4
4-14
705 setFocusPolicy(Qt::ClickFocus);
executed: setFocusPolicy(Qt::ClickFocus);
Execution Count:14
14
706 else -
707 setFocusPolicy(Qt::NoFocus);
executed: setFocusPolicy(Qt::NoFocus);
Execution Count:4
4
708 -
709 if (d->needTextControl()) {
evaluated: d->needTextControl()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2
2-17
710 d->ensureTextControl();
executed (the execution status of this line is deduced): d->ensureTextControl();
-
711 } else {
executed: }
Execution Count:17
17
712 delete d->control;
executed (the execution status of this line is deduced): delete d->control;
-
713 d->control = 0;
executed (the execution status of this line is deduced): d->control = 0;
-
714 }
executed: }
Execution Count:2
2
715 -
716 if (d->control)
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2
2-17
717 d->control->setTextInteractionFlags(d->textInteractionFlags);
executed: d->control->setTextInteractionFlags(d->textInteractionFlags);
Execution Count:17
17
718}
executed: }
Execution Count:19
19
719 -
720Qt::TextInteractionFlags QLabel::textInteractionFlags() const -
721{ -
722 Q_D(const QLabel);
never executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
723 return d->textInteractionFlags;
never executed: return d->textInteractionFlags;
0
724} -
725 -
726/*! -
727 Selects text from position \a start and for \a length characters. -
728 -
729 \sa selectedText() -
730 -
731 \b{Note:} The textInteractionFlags set on the label need to include -
732 either TextSelectableByMouse or TextSelectableByKeyboard. -
733 -
734 \since 4.7 -
735*/ -
736void QLabel::setSelection(int start, int length) -
737{ -
738 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
739 if (d->control) {
partially evaluated: d->control
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
740 d->ensureTextPopulated();
executed (the execution status of this line is deduced): d->ensureTextPopulated();
-
741 QTextCursor cursor = d->control->textCursor();
executed (the execution status of this line is deduced): QTextCursor cursor = d->control->textCursor();
-
742 cursor.setPosition(start);
executed (the execution status of this line is deduced): cursor.setPosition(start);
-
743 cursor.setPosition(start + length, QTextCursor::KeepAnchor);
executed (the execution status of this line is deduced): cursor.setPosition(start + length, QTextCursor::KeepAnchor);
-
744 d->control->setTextCursor(cursor);
executed (the execution status of this line is deduced): d->control->setTextCursor(cursor);
-
745 }
executed: }
Execution Count:2
2
746}
executed: }
Execution Count:2
2
747 -
748/*! -
749 \property QLabel::hasSelectedText -
750 \brief whether there is any text selected -
751 -
752 hasSelectedText() returns true if some or all of the text has been -
753 selected by the user; otherwise returns false. -
754 -
755 By default, this property is false. -
756 -
757 \sa selectedText() -
758 -
759 \b{Note:} The textInteractionFlags set on the label need to include -
760 either TextSelectableByMouse or TextSelectableByKeyboard. -
761 -
762 \since 4.7 -
763*/ -
764bool QLabel::hasSelectedText() const -
765{ -
766 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
767 if (d->control)
partially evaluated: d->control
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
768 return d->control->textCursor().hasSelection();
executed: return d->control->textCursor().hasSelection();
Execution Count:3
3
769 return false;
never executed: return false;
0
770} -
771 -
772/*! -
773 \property QLabel::selectedText -
774 \brief the selected text -
775 -
776 If there is no selected text this property's value is -
777 an empty string. -
778 -
779 By default, this property contains an empty string. -
780 -
781 \sa hasSelectedText() -
782 -
783 \b{Note:} The textInteractionFlags set on the label need to include -
784 either TextSelectableByMouse or TextSelectableByKeyboard. -
785 -
786 \since 4.7 -
787*/ -
788QString QLabel::selectedText() const -
789{ -
790 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
791 if (d->control)
partially evaluated: d->control
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
792 return d->control->textCursor().selectedText();
executed: return d->control->textCursor().selectedText();
Execution Count:3
3
793 return QString();
never executed: return QString();
0
794} -
795 -
796/*! -
797 selectionStart() returns the index of the first selected character in the -
798 label or -1 if no text is selected. -
799 -
800 \sa selectedText() -
801 -
802 \b{Note:} The textInteractionFlags set on the label need to include -
803 either TextSelectableByMouse or TextSelectableByKeyboard. -
804 -
805 \since 4.7 -
806*/ -
807int QLabel::selectionStart() const -
808{ -
809 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
810 if (d->control && d->control->textCursor().hasSelection())
partially evaluated: d->control
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
evaluated: d->control->textCursor().hasSelection()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
0-3
811 return d->control->textCursor().selectionStart();
executed: return d->control->textCursor().selectionStart();
Execution Count:2
2
812 return -1;
executed: return -1;
Execution Count:1
1
813} -
814 -
815/*!\reimp -
816*/ -
817QSize QLabel::sizeHint() const -
818{ -
819 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
820 if (!d->valid_hints)
evaluated: !d->valid_hints
TRUEFALSE
yes
Evaluation Count:1105
yes
Evaluation Count:401
401-1105
821 (void) QLabel::minimumSizeHint();
executed: (void) QLabel::minimumSizeHint();
Execution Count:1105
1105
822 return d->sh;
executed: return d->sh;
Execution Count:1506
1506
823} -
824 -
825/*! -
826 \reimp -
827*/ -
828QSize QLabel::minimumSizeHint() const -
829{ -
830 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
831 if (d->valid_hints) {
evaluated: d->valid_hints
TRUEFALSE
yes
Evaluation Count:1352
yes
Evaluation Count:1133
1133-1352
832 if (d->sizePolicy == sizePolicy())
evaluated: d->sizePolicy == sizePolicy()
TRUEFALSE
yes
Evaluation Count:1340
yes
Evaluation Count:12
12-1340
833 return d->msh;
executed: return d->msh;
Execution Count:1340
1340
834 }
executed: }
Execution Count:12
12
835 -
836 ensurePolished();
executed (the execution status of this line is deduced): ensurePolished();
-
837 d->valid_hints = true;
executed (the execution status of this line is deduced): d->valid_hints = true;
-
838 d->sh = d->sizeForWidth(-1); // wrap ? golden ratio : min doc size
executed (the execution status of this line is deduced): d->sh = d->sizeForWidth(-1);
-
839 QSize msh(-1, -1);
executed (the execution status of this line is deduced): QSize msh(-1, -1);
-
840 -
841 if (!d->isTextLabel) {
evaluated: !d->isTextLabel
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:931
214-931
842 msh = d->sh;
executed (the execution status of this line is deduced): msh = d->sh;
-
843 } else {
executed: }
Execution Count:214
214
844 msh.rheight() = d->sizeForWidth(QWIDGETSIZE_MAX).height(); // height for one line
executed (the execution status of this line is deduced): msh.rheight() = d->sizeForWidth(((1<<24)-1)).height();
-
845 msh.rwidth() = d->sizeForWidth(0).width(); // wrap ? size of biggest word : min doc size
executed (the execution status of this line is deduced): msh.rwidth() = d->sizeForWidth(0).width();
-
846 if (d->sh.height() < msh.height())
partially evaluated: d->sh.height() < msh.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:931
0-931
847 msh.rheight() = d->sh.height();
never executed: msh.rheight() = d->sh.height();
0
848 }
executed: }
Execution Count:931
931
849 d->msh = msh;
executed (the execution status of this line is deduced): d->msh = msh;
-
850 d->sizePolicy = sizePolicy();
executed (the execution status of this line is deduced): d->sizePolicy = sizePolicy();
-
851 return msh;
executed: return msh;
Execution Count:1145
1145
852} -
853 -
854/*!\reimp -
855*/ -
856void QLabel::mousePressEvent(QMouseEvent *ev) -
857{ -
858 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
859 d->sendControlEvent(ev);
executed (the execution status of this line is deduced): d->sendControlEvent(ev);
-
860}
executed: }
Execution Count:10
10
861 -
862/*!\reimp -
863*/ -
864void QLabel::mouseMoveEvent(QMouseEvent *ev) -
865{ -
866 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
867 d->sendControlEvent(ev);
executed (the execution status of this line is deduced): d->sendControlEvent(ev);
-
868}
executed: }
Execution Count:1
1
869 -
870/*!\reimp -
871*/ -
872void QLabel::mouseReleaseEvent(QMouseEvent *ev) -
873{ -
874 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
875 d->sendControlEvent(ev);
executed (the execution status of this line is deduced): d->sendControlEvent(ev);
-
876}
executed: }
Execution Count:1
1
877 -
878/*!\reimp -
879*/ -
880void QLabel::contextMenuEvent(QContextMenuEvent *ev) -
881{ -
882#ifdef QT_NO_CONTEXTMENU -
883 Q_UNUSED(ev); -
884#else -
885 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
886 if (!d->isTextLabel) {
partially evaluated: !d->isTextLabel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
887 ev->ignore();
never executed (the execution status of this line is deduced): ev->ignore();
-
888 return;
never executed: return;
0
889 } -
890 QMenu *menu = d->createStandardContextMenu(ev->pos());
executed (the execution status of this line is deduced): QMenu *menu = d->createStandardContextMenu(ev->pos());
-
891 if (!menu) {
partially evaluated: !menu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
892 ev->ignore();
never executed (the execution status of this line is deduced): ev->ignore();
-
893 return;
never executed: return;
0
894 } -
895 ev->accept();
executed (the execution status of this line is deduced): ev->accept();
-
896 menu->setAttribute(Qt::WA_DeleteOnClose);
executed (the execution status of this line is deduced): menu->setAttribute(Qt::WA_DeleteOnClose);
-
897 menu->popup(ev->globalPos());
executed (the execution status of this line is deduced): menu->popup(ev->globalPos());
-
898#endif -
899}
executed: }
Execution Count:1
1
900 -
901/*! -
902 \reimp -
903*/ -
904void QLabel::focusInEvent(QFocusEvent *ev) -
905{ -
906 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
907 if (d->isTextLabel) {
evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
908 d->ensureTextControl();
executed (the execution status of this line is deduced): d->ensureTextControl();
-
909 d->sendControlEvent(ev);
executed (the execution status of this line is deduced): d->sendControlEvent(ev);
-
910 }
executed: }
Execution Count:2
2
911 QFrame::focusInEvent(ev);
executed (the execution status of this line is deduced): QFrame::focusInEvent(ev);
-
912}
executed: }
Execution Count:3
3
913 -
914/*! -
915 \reimp -
916*/ -
917void QLabel::focusOutEvent(QFocusEvent *ev) -
918{ -
919 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
920 if (d->control) {
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
921 d->sendControlEvent(ev);
executed (the execution status of this line is deduced): d->sendControlEvent(ev);
-
922 QTextCursor cursor = d->control->textCursor();
executed (the execution status of this line is deduced): QTextCursor cursor = d->control->textCursor();
-
923 Qt::FocusReason reason = ev->reason();
executed (the execution status of this line is deduced): Qt::FocusReason reason = ev->reason();
-
924 if (reason != Qt::ActiveWindowFocusReason
partially evaluated: reason != Qt::ActiveWindowFocusReason
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
925 && reason != Qt::PopupFocusReason
evaluated: reason != Qt::PopupFocusReason
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
926 && cursor.hasSelection()) {
partially evaluated: cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
927 cursor.clearSelection();
never executed (the execution status of this line is deduced): cursor.clearSelection();
-
928 d->control->setTextCursor(cursor);
never executed (the execution status of this line is deduced): d->control->setTextCursor(cursor);
-
929 }
never executed: }
0
930 }
executed: }
Execution Count:2
2
931 -
932 QFrame::focusOutEvent(ev);
executed (the execution status of this line is deduced): QFrame::focusOutEvent(ev);
-
933}
executed: }
Execution Count:3
3
934 -
935/*!\reimp -
936*/ -
937bool QLabel::focusNextPrevChild(bool next) -
938{ -
939 Q_D(QLabel);
never executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
940 if (d->control && d->control->setFocusToNextOrPreviousAnchor(next))
never evaluated: d->control
never evaluated: d->control->setFocusToNextOrPreviousAnchor(next)
0
941 return true;
never executed: return true;
0
942 return QFrame::focusNextPrevChild(next);
never executed: return QFrame::focusNextPrevChild(next);
0
943} -
944 -
945/*!\reimp -
946*/ -
947void QLabel::keyPressEvent(QKeyEvent *ev) -
948{ -
949 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
950 d->sendControlEvent(ev);
executed (the execution status of this line is deduced): d->sendControlEvent(ev);
-
951}
executed: }
Execution Count:1
1
952 -
953/*!\reimp -
954*/ -
955bool QLabel::event(QEvent *e) -
956{ -
957 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
958 QEvent::Type type = e->type();
executed (the execution status of this line is deduced): QEvent::Type type = e->type();
-
959 -
960#ifndef QT_NO_SHORTCUT -
961 if (type == QEvent::Shortcut) {
evaluated: type == QEvent::Shortcut
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:7755
2-7755
962 QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
executed (the execution status of this line is deduced): QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
-
963 if (se->shortcutId() == d->shortcutId) {
partially evaluated: se->shortcutId() == d->shortcutId
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
964 QWidget * w = d->buddy;
executed (the execution status of this line is deduced): QWidget * w = d->buddy;
-
965 QAbstractButton *button = qobject_cast<QAbstractButton *>(w);
executed (the execution status of this line is deduced): QAbstractButton *button = qobject_cast<QAbstractButton *>(w);
-
966 if (w->focusPolicy() != Qt::NoFocus)
partially evaluated: w->focusPolicy() != Qt::NoFocus
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
967 w->setFocus(Qt::ShortcutFocusReason);
executed: w->setFocus(Qt::ShortcutFocusReason);
Execution Count:2
2
968 if (button && !se->isAmbiguous())
partially evaluated: button
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: !se->isAmbiguous()
0-2
969 button->animateClick();
never executed: button->animateClick();
0
970 else -
971 window()->setAttribute(Qt::WA_KeyboardFocusChange);
executed: window()->setAttribute(Qt::WA_KeyboardFocusChange);
Execution Count:2
2
972 return true;
executed: return true;
Execution Count:2
2
973 } -
974 } else
never executed: }
0
975#endif -
976 if (type == QEvent::Resize) {
evaluated: type == QEvent::Resize
TRUEFALSE
yes
Evaluation Count:641
yes
Evaluation Count:7114
641-7114
977 if (d->control)
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:617
24-617
978 d->textLayoutDirty = true;
executed: d->textLayoutDirty = true;
Execution Count:24
24
979 } else if (e->type() == QEvent::StyleChange
executed: }
Execution Count:641
evaluated: e->type() == QEvent::StyleChange
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:6983
131-6983
980#ifdef Q_OS_MAC -
981 || e->type() == QEvent::MacSizeChange -
982#endif -
983 ) { -
984 d->setLayoutItemMargins(QStyle::SE_LabelLayoutItem);
executed (the execution status of this line is deduced): d->setLayoutItemMargins(QStyle::SE_LabelLayoutItem);
-
985 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
986 }
executed: }
Execution Count:131
131
987 -
988 return QFrame::event(e);
executed: return QFrame::event(e);
Execution Count:7755
7755
989} -
990 -
991/*!\reimp -
992*/ -
993void QLabel::paintEvent(QPaintEvent *) -
994{ -
995 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
996 QStyle *style = QWidget::style();
executed (the execution status of this line is deduced): QStyle *style = QWidget::style();
-
997 QPainter painter(this);
executed (the execution status of this line is deduced): QPainter painter(this);
-
998 drawFrame(&painter);
executed (the execution status of this line is deduced): drawFrame(&painter);
-
999 QRect cr = contentsRect();
executed (the execution status of this line is deduced): QRect cr = contentsRect();
-
1000 cr.adjust(d->margin, d->margin, -d->margin, -d->margin);
executed (the execution status of this line is deduced): cr.adjust(d->margin, d->margin, -d->margin, -d->margin);
-
1001 int align = QStyle::visualAlignment(d->isTextLabel ? d->textDirection()
executed (the execution status of this line is deduced): int align = QStyle::visualAlignment(d->isTextLabel ? d->textDirection()
-
1002 : layoutDirection(), QFlag(d->align));
executed (the execution status of this line is deduced): : layoutDirection(), QFlag(d->align));
-
1003 -
1004#ifndef QT_NO_MOVIE -
1005 if (d->movie) {
evaluated: d->movie
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:586
129-586
1006 if (d->scaledcontents)
partially evaluated: d->scaledcontents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:129
0-129
1007 style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap().scaled(cr.size()));
never executed: style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap().scaled(cr.size()));
0
1008 else -
1009 style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap());
executed: style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap());
Execution Count:129
129
1010 } -
1011 else -
1012#endif -
1013 if (d->isTextLabel) {
evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:478
yes
Evaluation Count:108
108-478
1014 QRectF lr = d->layoutRect().toAlignedRect();
executed (the execution status of this line is deduced): QRectF lr = d->layoutRect().toAlignedRect();
-
1015 QStyleOption opt;
executed (the execution status of this line is deduced): QStyleOption opt;
-
1016 opt.initFrom(this);
executed (the execution status of this line is deduced): opt.initFrom(this);
-
1017#ifndef QT_NO_STYLE_STYLESHEET -
1018 if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style)) {
partially evaluated: QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:478
0-478
1019 cssStyle->styleSheetPalette(this, &opt, &opt.palette);
never executed (the execution status of this line is deduced): cssStyle->styleSheetPalette(this, &opt, &opt.palette);
-
1020 }
never executed: }
0
1021#endif -
1022 if (d->control) {
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:455
23-455
1023#ifndef QT_NO_SHORTCUT -
1024 const bool underline = (bool)style->styleHint(QStyle::SH_UnderlineShortcut, 0, this, 0);
executed (the execution status of this line is deduced): const bool underline = (bool)style->styleHint(QStyle::SH_UnderlineShortcut, 0, this, 0);
-
1025 if (d->shortcutId != 0
evaluated: d->shortcutId != 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:15
8-15
1026 && underline != d->shortcutCursor.charFormat().fontUnderline()) {
evaluated: underline != d->shortcutCursor.charFormat().fontUnderline()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
1027 QTextCharFormat fmt;
executed (the execution status of this line is deduced): QTextCharFormat fmt;
-
1028 fmt.setFontUnderline(underline);
executed (the execution status of this line is deduced): fmt.setFontUnderline(underline);
-
1029 d->shortcutCursor.mergeCharFormat(fmt);
executed (the execution status of this line is deduced): d->shortcutCursor.mergeCharFormat(fmt);
-
1030 }
executed: }
Execution Count:4
4
1031#endif -
1032 d->ensureTextLayouted();
executed (the execution status of this line is deduced): d->ensureTextLayouted();
-
1033 -
1034 QAbstractTextDocumentLayout::PaintContext context;
executed (the execution status of this line is deduced): QAbstractTextDocumentLayout::PaintContext context;
-
1035 if (!isEnabled() && !d->control &&
partially evaluated: !isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
never evaluated: !d->control
0-23
1036 // We cannot support etched for rich text controls because custom
executed (the execution status of this line is deduced):
-
1037 // colors and links will override the light palette
executed (the execution status of this line is deduced):
-
1038 style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)) {
never evaluated: style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)
0
1039 context.palette = opt.palette;
never executed (the execution status of this line is deduced): context.palette = opt.palette;
-
1040 context.palette.setColor(QPalette::Text, context.palette.light().color());
never executed (the execution status of this line is deduced): context.palette.setColor(QPalette::Text, context.palette.light().color());
-
1041 painter.save();
never executed (the execution status of this line is deduced): painter.save();
-
1042 painter.translate(lr.x() + 1, lr.y() + 1);
never executed (the execution status of this line is deduced): painter.translate(lr.x() + 1, lr.y() + 1);
-
1043 painter.setClipRect(lr.translated(-lr.x() - 1, -lr.y() - 1));
never executed (the execution status of this line is deduced): painter.setClipRect(lr.translated(-lr.x() - 1, -lr.y() - 1));
-
1044 QAbstractTextDocumentLayout *layout = d->control->document()->documentLayout();
never executed (the execution status of this line is deduced): QAbstractTextDocumentLayout *layout = d->control->document()->documentLayout();
-
1045 layout->draw(&painter, context);
never executed (the execution status of this line is deduced): layout->draw(&painter, context);
-
1046 painter.restore();
never executed (the execution status of this line is deduced): painter.restore();
-
1047 }
never executed: }
0
1048 -
1049 // Adjust the palette -
1050 context.palette = opt.palette;
executed (the execution status of this line is deduced): context.palette = opt.palette;
-
1051 -
1052 if (foregroundRole() != QPalette::Text && isEnabled())
evaluated: foregroundRole() != QPalette::Text
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:3
partially evaluated: isEnabled()
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-20
1053 context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));
executed: context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));
Execution Count:20
20
1054 -
1055 painter.save();
executed (the execution status of this line is deduced): painter.save();
-
1056 painter.translate(lr.topLeft());
executed (the execution status of this line is deduced): painter.translate(lr.topLeft());
-
1057 painter.setClipRect(lr.translated(-lr.x(), -lr.y()));
executed (the execution status of this line is deduced): painter.setClipRect(lr.translated(-lr.x(), -lr.y()));
-
1058 d->control->setPalette(context.palette);
executed (the execution status of this line is deduced): d->control->setPalette(context.palette);
-
1059 d->control->drawContents(&painter, QRectF(), this);
executed (the execution status of this line is deduced): d->control->drawContents(&painter, QRectF(), this);
-
1060 painter.restore();
executed (the execution status of this line is deduced): painter.restore();
-
1061 } else {
executed: }
Execution Count:23
23
1062 int flags = align | (d->textDirection() == Qt::LeftToRight ? Qt::TextForceLeftToRight
executed (the execution status of this line is deduced): int flags = align | (d->textDirection() == Qt::LeftToRight ? Qt::TextForceLeftToRight
-
1063 : Qt::TextForceRightToLeft);
executed (the execution status of this line is deduced): : Qt::TextForceRightToLeft);
-
1064 if (d->hasShortcut) {
evaluated: d->hasShortcut
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:397
58-397
1065 flags |= Qt::TextShowMnemonic;
executed (the execution status of this line is deduced): flags |= Qt::TextShowMnemonic;
-
1066 if (!style->styleHint(QStyle::SH_UnderlineShortcut, &opt, this))
partially evaluated: !style->styleHint(QStyle::SH_UnderlineShortcut, &opt, this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:58
0-58
1067 flags |= Qt::TextHideMnemonic;
never executed: flags |= Qt::TextHideMnemonic;
0
1068 }
executed: }
Execution Count:58
58
1069 style->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), d->text, foregroundRole());
executed (the execution status of this line is deduced): style->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), d->text, foregroundRole());
-
1070 }
executed: }
Execution Count:455
455
1071 } else -
1072#ifndef QT_NO_PICTURE -
1073 if (d->picture) {
partially evaluated: d->picture
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:108
0-108
1074 QRect br = d->picture->boundingRect();
never executed (the execution status of this line is deduced): QRect br = d->picture->boundingRect();
-
1075 int rw = br.width();
never executed (the execution status of this line is deduced): int rw = br.width();
-
1076 int rh = br.height();
never executed (the execution status of this line is deduced): int rh = br.height();
-
1077 if (d->scaledcontents) {
never evaluated: d->scaledcontents
0
1078 painter.save();
never executed (the execution status of this line is deduced): painter.save();
-
1079 painter.translate(cr.x(), cr.y());
never executed (the execution status of this line is deduced): painter.translate(cr.x(), cr.y());
-
1080 painter.scale((double)cr.width()/rw, (double)cr.height()/rh);
never executed (the execution status of this line is deduced): painter.scale((double)cr.width()/rw, (double)cr.height()/rh);
-
1081 painter.drawPicture(-br.x(), -br.y(), *d->picture);
never executed (the execution status of this line is deduced): painter.drawPicture(-br.x(), -br.y(), *d->picture);
-
1082 painter.restore();
never executed (the execution status of this line is deduced): painter.restore();
-
1083 } else {
never executed: }
0
1084 int xo = 0;
never executed (the execution status of this line is deduced): int xo = 0;
-
1085 int yo = 0;
never executed (the execution status of this line is deduced): int yo = 0;
-
1086 if (align & Qt::AlignVCenter)
never evaluated: align & Qt::AlignVCenter
0
1087 yo = (cr.height()-rh)/2;
never executed: yo = (cr.height()-rh)/2;
0
1088 else if (align & Qt::AlignBottom)
never evaluated: align & Qt::AlignBottom
0
1089 yo = cr.height()-rh;
never executed: yo = cr.height()-rh;
0
1090 if (align & Qt::AlignRight)
never evaluated: align & Qt::AlignRight
0
1091 xo = cr.width()-rw;
never executed: xo = cr.width()-rw;
0
1092 else if (align & Qt::AlignHCenter)
never evaluated: align & Qt::AlignHCenter
0
1093 xo = (cr.width()-rw)/2;
never executed: xo = (cr.width()-rw)/2;
0
1094 painter.drawPicture(cr.x()+xo-br.x(), cr.y()+yo-br.y(), *d->picture);
never executed (the execution status of this line is deduced): painter.drawPicture(cr.x()+xo-br.x(), cr.y()+yo-br.y(), *d->picture);
-
1095 }
never executed: }
0
1096 } else -
1097#endif -
1098 if (d->pixmap && !d->pixmap->isNull()) {
evaluated: d->pixmap
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:55
evaluated: !d->pixmap->isNull()
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:7
7-55
1099 QPixmap pix;
executed (the execution status of this line is deduced): QPixmap pix;
-
1100 if (d->scaledcontents) {
partially evaluated: d->scaledcontents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
1101 if (!d->scaledpixmap || d->scaledpixmap->size() != cr.size()) {
never evaluated: !d->scaledpixmap
never evaluated: d->scaledpixmap->size() != cr.size()
0
1102 if (!d->cachedimage)
never evaluated: !d->cachedimage
0
1103 d->cachedimage = new QImage(d->pixmap->toImage());
never executed: d->cachedimage = new QImage(d->pixmap->toImage());
0
1104 delete d->scaledpixmap;
never executed (the execution status of this line is deduced): delete d->scaledpixmap;
-
1105 d->scaledpixmap = new QPixmap(QPixmap::fromImage(d->cachedimage->scaled(cr.size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)));
never executed (the execution status of this line is deduced): d->scaledpixmap = new QPixmap(QPixmap::fromImage(d->cachedimage->scaled(cr.size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)));
-
1106 }
never executed: }
0
1107 pix = *d->scaledpixmap;
never executed (the execution status of this line is deduced): pix = *d->scaledpixmap;
-
1108 } else
never executed: }
0
1109 pix = *d->pixmap;
executed: pix = *d->pixmap;
Execution Count:46
46
1110 QStyleOption opt;
executed (the execution status of this line is deduced): QStyleOption opt;
-
1111 opt.initFrom(this);
executed (the execution status of this line is deduced): opt.initFrom(this);
-
1112 if (!isEnabled())
partially evaluated: !isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
1113 pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt);
never executed: pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt);
0
1114 style->drawItemPixmap(&painter, cr, align, pix);
executed (the execution status of this line is deduced): style->drawItemPixmap(&painter, cr, align, pix);
-
1115 }
executed: }
Execution Count:46
46
1116} -
1117 -
1118 -
1119/*! -
1120 Updates the label, but not the frame. -
1121*/ -
1122 -
1123void QLabelPrivate::updateLabel() -
1124{ -
1125 Q_Q(QLabel);
executed (the execution status of this line is deduced): QLabel * const q = q_func();
-
1126 valid_hints = false;
executed (the execution status of this line is deduced): valid_hints = false;
-
1127 -
1128 if (isTextLabel) {
evaluated: isTextLabel
TRUEFALSE
yes
Evaluation Count:1438
yes
Evaluation Count:375
375-1438
1129 QSizePolicy policy = q->sizePolicy();
executed (the execution status of this line is deduced): QSizePolicy policy = q->sizePolicy();
-
1130 const bool wrap = align & Qt::TextWordWrap;
executed (the execution status of this line is deduced): const bool wrap = align & Qt::TextWordWrap;
-
1131 policy.setHeightForWidth(wrap);
executed (the execution status of this line is deduced): policy.setHeightForWidth(wrap);
-
1132 if (policy != q->sizePolicy()) // ### should be replaced by WA_WState_OwnSizePolicy idiom
evaluated: policy != q->sizePolicy()
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:1390
48-1390
1133 q->setSizePolicy(policy);
executed: q->setSizePolicy(policy);
Execution Count:48
48
1134 textLayoutDirty = true;
executed (the execution status of this line is deduced): textLayoutDirty = true;
-
1135 }
executed: }
Execution Count:1438
1438
1136 q->updateGeometry();
executed (the execution status of this line is deduced): q->updateGeometry();
-
1137 q->update(q->contentsRect());
executed (the execution status of this line is deduced): q->update(q->contentsRect());
-
1138}
executed: }
Execution Count:1813
1813
1139 -
1140#ifndef QT_NO_SHORTCUT -
1141/*! -
1142 Sets this label's buddy to \a buddy. -
1143 -
1144 When the user presses the shortcut key indicated by this label, -
1145 the keyboard focus is transferred to the label's buddy widget. -
1146 -
1147 The buddy mechanism is only available for QLabels that contain -
1148 text in which one character is prefixed with an ampersand, '&'. -
1149 This character is set as the shortcut key. See the \l -
1150 QKeySequence::mnemonic() documentation for details (to display an -
1151 actual ampersand, use '&&'). -
1152 -
1153 In a dialog, you might create two data entry widgets and a label -
1154 for each, and set up the geometry layout so each label is just to -
1155 the left of its data entry widget (its "buddy"), for example: -
1156 \snippet code/src_gui_widgets_qlabel.cpp 2 -
1157 -
1158 With the code above, the focus jumps to the Name field when the -
1159 user presses Alt+N, and to the Phone field when the user presses -
1160 Alt+P. -
1161 -
1162 To unset a previously set buddy, call this function with \a buddy -
1163 set to 0. -
1164 -
1165 \sa buddy(), setText(), QShortcut, setAlignment() -
1166*/ -
1167 -
1168void QLabel::setBuddy(QWidget *buddy) -
1169{ -
1170 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
1171 d->buddy = buddy;
executed (the execution status of this line is deduced): d->buddy = buddy;
-
1172 if (d->isTextLabel) {
evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:304
30-304
1173 if (d->shortcutId)
partially evaluated: d->shortcutId
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
1174 releaseShortcut(d->shortcutId);
never executed: releaseShortcut(d->shortcutId);
0
1175 d->shortcutId = 0;
executed (the execution status of this line is deduced): d->shortcutId = 0;
-
1176 d->textDirty = true;
executed (the execution status of this line is deduced): d->textDirty = true;
-
1177 if (buddy)
evaluated: buddy
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:8
8-22
1178 d->updateShortcut(); // grab new shortcut
executed: d->updateShortcut();
Execution Count:22
22
1179 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
1180 }
executed: }
Execution Count:30
30
1181}
executed: }
Execution Count:334
334
1182 -
1183 -
1184/*! -
1185 Returns this label's buddy, or 0 if no buddy is currently set. -
1186 -
1187 \sa setBuddy() -
1188*/ -
1189 -
1190QWidget * QLabel::buddy() const -
1191{ -
1192 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
1193 return d->buddy;
executed: return d->buddy;
Execution Count:17
17
1194} -
1195 -
1196void QLabelPrivate::updateShortcut() -
1197{ -
1198 Q_Q(QLabel);
executed (the execution status of this line is deduced): QLabel * const q = q_func();
-
1199 Q_ASSERT(shortcutId == 0);
executed (the execution status of this line is deduced): qt_noop();
-
1200 // Introduce an extra boolean to indicate the presence of a shortcut in the -
1201 // text. We cannot use the shortcutId itself because on the mac mnemonics are -
1202 // off by default, so QKeySequence::mnemonic always returns an empty sequence. -
1203 // But then we do want to hide the ampersands, so we can't use shortcutId. -
1204 hasShortcut = false;
executed (the execution status of this line is deduced): hasShortcut = false;
-
1205 -
1206 if (!text.contains(QLatin1Char('&')))
evaluated: !text.contains(QLatin1Char('&'))
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:253
25-253
1207 return;
executed: return;
Execution Count:25
25
1208 hasShortcut = true;
executed (the execution status of this line is deduced): hasShortcut = true;
-
1209 shortcutId = q->grabShortcut(QKeySequence::mnemonic(text));
executed (the execution status of this line is deduced): shortcutId = q->grabShortcut(QKeySequence::mnemonic(text));
-
1210}
executed: }
Execution Count:253
253
1211 -
1212#endif // QT_NO_SHORTCUT -
1213 -
1214#ifndef QT_NO_MOVIE -
1215void QLabelPrivate::_q_movieUpdated(const QRect& rect) -
1216{ -
1217 Q_Q(QLabel);
executed (the execution status of this line is deduced): QLabel * const q = q_func();
-
1218 if (movie && movie->isValid()) {
partially evaluated: movie
TRUEFALSE
yes
Evaluation Count:130
no
Evaluation Count:0
partially evaluated: movie->isValid()
TRUEFALSE
yes
Evaluation Count:130
no
Evaluation Count:0
0-130
1219 QRect r;
executed (the execution status of this line is deduced): QRect r;
-
1220 if (scaledcontents) {
partially evaluated: scaledcontents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
1221 QRect cr = q->contentsRect();
never executed (the execution status of this line is deduced): QRect cr = q->contentsRect();
-
1222 QRect pixmapRect(cr.topLeft(), movie->currentPixmap().size());
never executed (the execution status of this line is deduced): QRect pixmapRect(cr.topLeft(), movie->currentPixmap().size());
-
1223 if (pixmapRect.isEmpty())
never evaluated: pixmapRect.isEmpty()
0
1224 return;
never executed: return;
0
1225 r.setRect(cr.left(), cr.top(),
never executed (the execution status of this line is deduced): r.setRect(cr.left(), cr.top(),
-
1226 (rect.width() * cr.width()) / pixmapRect.width(),
never executed (the execution status of this line is deduced): (rect.width() * cr.width()) / pixmapRect.width(),
-
1227 (rect.height() * cr.height()) / pixmapRect.height());
never executed (the execution status of this line is deduced): (rect.height() * cr.height()) / pixmapRect.height());
-
1228 } else {
never executed: }
0
1229 r = q->style()->itemPixmapRect(q->contentsRect(), align, movie->currentPixmap());
executed (the execution status of this line is deduced): r = q->style()->itemPixmapRect(q->contentsRect(), align, movie->currentPixmap());
-
1230 r.translate(rect.x(), rect.y());
executed (the execution status of this line is deduced): r.translate(rect.x(), rect.y());
-
1231 r.setWidth(qMin(r.width(), rect.width()));
executed (the execution status of this line is deduced): r.setWidth(qMin(r.width(), rect.width()));
-
1232 r.setHeight(qMin(r.height(), rect.height()));
executed (the execution status of this line is deduced): r.setHeight(qMin(r.height(), rect.height()));
-
1233 }
executed: }
Execution Count:130
130
1234 q->update(r);
executed (the execution status of this line is deduced): q->update(r);
-
1235 }
executed: }
Execution Count:130
130
1236}
executed: }
Execution Count:130
130
1237 -
1238void QLabelPrivate::_q_movieResized(const QSize& size) -
1239{ -
1240 Q_Q(QLabel);
executed (the execution status of this line is deduced): QLabel * const q = q_func();
-
1241 q->update(); //we need to refresh the whole background in case the new size is smaler
executed (the execution status of this line is deduced): q->update();
-
1242 valid_hints = false;
executed (the execution status of this line is deduced): valid_hints = false;
-
1243 _q_movieUpdated(QRect(QPoint(0,0), size));
executed (the execution status of this line is deduced): _q_movieUpdated(QRect(QPoint(0,0), size));
-
1244 q->updateGeometry();
executed (the execution status of this line is deduced): q->updateGeometry();
-
1245}
executed: }
Execution Count:3
3
1246 -
1247/*! -
1248 Sets the label contents to \a movie. Any previous content is -
1249 cleared. The label does NOT take ownership of the movie. -
1250 -
1251 The buddy shortcut, if any, is disabled. -
1252 -
1253 \sa movie(), setBuddy() -
1254*/ -
1255 -
1256void QLabel::setMovie(QMovie *movie) -
1257{ -
1258 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
1259 d->clearContents();
executed (the execution status of this line is deduced): d->clearContents();
-
1260 -
1261 if (!movie)
evaluated: !movie
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
1262 return;
executed: return;
Execution Count:1
1
1263 -
1264 d->movie = movie;
executed (the execution status of this line is deduced): d->movie = movie;
-
1265 connect(movie, SIGNAL(resized(QSize)), this, SLOT(_q_movieResized(QSize)));
executed (the execution status of this line is deduced): connect(movie, "2""resized(QSize)", this, "1""_q_movieResized(QSize)");
-
1266 connect(movie, SIGNAL(updated(QRect)), this, SLOT(_q_movieUpdated(QRect)));
executed (the execution status of this line is deduced): connect(movie, "2""updated(QRect)", this, "1""_q_movieUpdated(QRect)");
-
1267 -
1268 // Assume that if the movie is running, -
1269 // resize/update signals will come soon enough -
1270 if (movie->state() != QMovie::Running)
evaluated: movie->state() != QMovie::Running
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
1271 d->updateLabel();
executed: d->updateLabel();
Execution Count:4
4
1272}
executed: }
Execution Count:6
6
1273 -
1274#endif // QT_NO_MOVIE -
1275 -
1276/*! -
1277 \internal -
1278 -
1279 Clears any contents, without updating/repainting the label. -
1280*/ -
1281 -
1282void QLabelPrivate::clearContents() -
1283{ -
1284 delete control;
executed (the execution status of this line is deduced): delete control;
-
1285 control = 0;
executed (the execution status of this line is deduced): control = 0;
-
1286 isTextLabel = false;
executed (the execution status of this line is deduced): isTextLabel = false;
-
1287 hasShortcut = false;
executed (the execution status of this line is deduced): hasShortcut = false;
-
1288 -
1289#ifndef QT_NO_PICTURE -
1290 delete picture;
executed (the execution status of this line is deduced): delete picture;
-
1291 picture = 0;
executed (the execution status of this line is deduced): picture = 0;
-
1292#endif -
1293 delete scaledpixmap;
executed (the execution status of this line is deduced): delete scaledpixmap;
-
1294 scaledpixmap = 0;
executed (the execution status of this line is deduced): scaledpixmap = 0;
-
1295 delete cachedimage;
executed (the execution status of this line is deduced): delete cachedimage;
-
1296 cachedimage = 0;
executed (the execution status of this line is deduced): cachedimage = 0;
-
1297 delete pixmap;
executed (the execution status of this line is deduced): delete pixmap;
-
1298 pixmap = 0;
executed (the execution status of this line is deduced): pixmap = 0;
-
1299 -
1300 text.clear();
executed (the execution status of this line is deduced): text.clear();
-
1301 Q_Q(QLabel);
executed (the execution status of this line is deduced): QLabel * const q = q_func();
-
1302#ifndef QT_NO_SHORTCUT -
1303 if (shortcutId)
evaluated: shortcutId
TRUEFALSE
yes
Evaluation Count:245
yes
Evaluation Count:1874
245-1874
1304 q->releaseShortcut(shortcutId);
executed: q->releaseShortcut(shortcutId);
Execution Count:245
245
1305 shortcutId = 0;
executed (the execution status of this line is deduced): shortcutId = 0;
-
1306#endif -
1307#ifndef QT_NO_MOVIE -
1308 if (movie) {
evaluated: movie
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2114
5-2114
1309 QObject::disconnect(movie, SIGNAL(resized(QSize)), q, SLOT(_q_movieResized(QSize)));
executed (the execution status of this line is deduced): QObject::disconnect(movie, "2""resized(QSize)", q, "1""_q_movieResized(QSize)");
-
1310 QObject::disconnect(movie, SIGNAL(updated(QRect)), q, SLOT(_q_movieUpdated(QRect)));
executed (the execution status of this line is deduced): QObject::disconnect(movie, "2""updated(QRect)", q, "1""_q_movieUpdated(QRect)");
-
1311 }
executed: }
Execution Count:5
5
1312 movie = 0;
executed (the execution status of this line is deduced): movie = 0;
-
1313#endif -
1314#ifndef QT_NO_CURSOR -
1315 if (onAnchor) {
partially evaluated: onAnchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2119
0-2119
1316 if (validCursor)
never evaluated: validCursor
0
1317 q->setCursor(cursor);
never executed: q->setCursor(cursor);
0
1318 else -
1319 q->unsetCursor();
never executed: q->unsetCursor();
0
1320 } -
1321 validCursor = false;
executed (the execution status of this line is deduced): validCursor = false;
-
1322 onAnchor = false;
executed (the execution status of this line is deduced): onAnchor = false;
-
1323#endif -
1324}
executed: }
Execution Count:2119
2119
1325 -
1326 -
1327#ifndef QT_NO_MOVIE -
1328 -
1329/*! -
1330 Returns a pointer to the label's movie, or 0 if no movie has been -
1331 set. -
1332 -
1333 \sa setMovie() -
1334*/ -
1335 -
1336QMovie *QLabel::movie() const -
1337{ -
1338 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
1339 return d->movie;
executed: return d->movie;
Execution Count:4
4
1340} -
1341 -
1342#endif // QT_NO_MOVIE -
1343 -
1344/*! -
1345 \property QLabel::textFormat -
1346 \brief the label's text format -
1347 -
1348 See the Qt::TextFormat enum for an explanation of the possible -
1349 options. -
1350 -
1351 The default format is Qt::AutoText. -
1352 -
1353 \sa text() -
1354*/ -
1355 -
1356Qt::TextFormat QLabel::textFormat() const -
1357{ -
1358 Q_D(const QLabel);
executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
1359 return d->textformat;
executed: return d->textformat;
Execution Count:73
73
1360} -
1361 -
1362void QLabel::setTextFormat(Qt::TextFormat format) -
1363{ -
1364 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
1365 if (format != d->textformat) {
evaluated: format != d->textformat
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:144
14-144
1366 d->textformat = format;
executed (the execution status of this line is deduced): d->textformat = format;
-
1367 QString t = d->text;
executed (the execution status of this line is deduced): QString t = d->text;
-
1368 if (!t.isNull()) {
partially evaluated: !t.isNull()
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
1369 d->text.clear();
executed (the execution status of this line is deduced): d->text.clear();
-
1370 setText(t);
executed (the execution status of this line is deduced): setText(t);
-
1371 }
executed: }
Execution Count:14
14
1372 }
executed: }
Execution Count:14
14
1373}
executed: }
Execution Count:158
158
1374 -
1375/*! -
1376 \reimp -
1377*/ -
1378void QLabel::changeEvent(QEvent *ev) -
1379{ -
1380 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
1381 if(ev->type() == QEvent::FontChange || ev->type() == QEvent::ApplicationFontChange) {
evaluated: ev->type() == QEvent::FontChange
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:644
partially evaluated: ev->type() == QEvent::ApplicationFontChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:644
0-644
1382 if (d->isTextLabel) {
evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:14
14-28
1383 if (d->control)
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:27
1-27
1384 d->control->document()->setDefaultFont(font());
executed: d->control->document()->setDefaultFont(font());
Execution Count:1
1
1385 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
1386 }
executed: }
Execution Count:28
28
1387 } else if (ev->type() == QEvent::PaletteChange && d->control) {
executed: }
Execution Count:42
evaluated: ev->type() == QEvent::PaletteChange
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:594
partially evaluated: d->control
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-594
1388 d->control->setPalette(palette());
never executed (the execution status of this line is deduced): d->control->setPalette(palette());
-
1389 } else if (ev->type() == QEvent::ContentsRectChange) {
never executed: }
evaluated: ev->type() == QEvent::ContentsRectChange
TRUEFALSE
yes
Evaluation Count:127
yes
Evaluation Count:517
0-517
1390 d->updateLabel();
executed (the execution status of this line is deduced): d->updateLabel();
-
1391 }
executed: }
Execution Count:127
127
1392 QFrame::changeEvent(ev);
executed (the execution status of this line is deduced): QFrame::changeEvent(ev);
-
1393}
executed: }
Execution Count:686
686
1394 -
1395/*! -
1396 \property QLabel::scaledContents -
1397 \brief whether the label will scale its contents to fill all -
1398 available space. -
1399 -
1400 When enabled and the label shows a pixmap, it will scale the -
1401 pixmap to fill the available space. -
1402 -
1403 This property's default is false. -
1404*/ -
1405bool QLabel::hasScaledContents() const -
1406{ -
1407 Q_D(const QLabel);
never executed (the execution status of this line is deduced): const QLabelPrivate * const d = d_func();
-
1408 return d->scaledcontents;
never executed: return d->scaledcontents;
0
1409} -
1410 -
1411void QLabel::setScaledContents(bool enable) -
1412{ -
1413 Q_D(QLabel);
executed (the execution status of this line is deduced): QLabelPrivate * const d = d_func();
-
1414 if ((bool)d->scaledcontents == enable)
partially evaluated: (bool)d->scaledcontents == enable
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
0-42
1415 return;
executed: return;
Execution Count:42
42
1416 d->scaledcontents = enable;
never executed (the execution status of this line is deduced): d->scaledcontents = enable;
-
1417 if (!enable) {
never evaluated: !enable
0
1418 delete d->scaledpixmap;
never executed (the execution status of this line is deduced): delete d->scaledpixmap;
-
1419 d->scaledpixmap = 0;
never executed (the execution status of this line is deduced): d->scaledpixmap = 0;
-
1420 delete d->cachedimage;
never executed (the execution status of this line is deduced): delete d->cachedimage;
-
1421 d->cachedimage = 0;
never executed (the execution status of this line is deduced): d->cachedimage = 0;
-
1422 }
never executed: }
0
1423 update(contentsRect());
never executed (the execution status of this line is deduced): update(contentsRect());
-
1424}
never executed: }
0
1425 -
1426Qt::LayoutDirection QLabelPrivate::textDirection() const -
1427{ -
1428 if (control) {
evaluated: control
TRUEFALSE
yes
Evaluation Count:200
yes
Evaluation Count:4245
200-4245
1429 QTextOption opt = control->document()->defaultTextOption();
executed (the execution status of this line is deduced): QTextOption opt = control->document()->defaultTextOption();
-
1430 return opt.textDirection();
executed: return opt.textDirection();
Execution Count:200
200
1431 } -
1432 -
1433 return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
executed: return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
Execution Count:4245
4245
1434} -
1435 -
1436 -
1437// Returns the rect that is available for us to draw the document -
1438QRect QLabelPrivate::documentRect() const -
1439{ -
1440 Q_Q(const QLabel);
executed (the execution status of this line is deduced): const QLabel * const q = q_func();
-
1441 Q_ASSERT_X(isTextLabel, "documentRect", "document rect called for label that is not a text label!");
executed (the execution status of this line is deduced): qt_noop();
-
1442 QRect cr = q->contentsRect();
executed (the execution status of this line is deduced): QRect cr = q->contentsRect();
-
1443 cr.adjust(margin, margin, -margin, -margin);
executed (the execution status of this line is deduced): cr.adjust(margin, margin, -margin, -margin);
-
1444 const int align = QStyle::visualAlignment(isTextLabel ? textDirection()
executed (the execution status of this line is deduced): const int align = QStyle::visualAlignment(isTextLabel ? textDirection()
-
1445 : q->layoutDirection(), QFlag(this->align));
executed (the execution status of this line is deduced): : q->layoutDirection(), QFlag(this->align));
-
1446 int m = indent;
executed (the execution status of this line is deduced): int m = indent;
-
1447 if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
evaluated: m < 0
TRUEFALSE
yes
Evaluation Count:432
yes
Evaluation Count:98
evaluated: q->frameWidth()
TRUEFALSE
yes
Evaluation Count:194
yes
Evaluation Count:238
98-432
1448 m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
executed: m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
Execution Count:194
194
1449 if (m > 0) {
evaluated: m > 0
TRUEFALSE
yes
Evaluation Count:291
yes
Evaluation Count:239
239-291
1450 if (align & Qt::AlignLeft)
partially evaluated: align & Qt::AlignLeft
TRUEFALSE
yes
Evaluation Count:291
no
Evaluation Count:0
0-291
1451 cr.setLeft(cr.left() + m);
executed: cr.setLeft(cr.left() + m);
Execution Count:291
291
1452 if (align & Qt::AlignRight)
partially evaluated: align & Qt::AlignRight
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:291
0-291
1453 cr.setRight(cr.right() - m);
never executed: cr.setRight(cr.right() - m);
0
1454 if (align & Qt::AlignTop)
evaluated: align & Qt::AlignTop
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:281
10-281
1455 cr.setTop(cr.top() + m);
executed: cr.setTop(cr.top() + m);
Execution Count:10
10
1456 if (align & Qt::AlignBottom)
partially evaluated: align & Qt::AlignBottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:291
0-291
1457 cr.setBottom(cr.bottom() - m);
never executed: cr.setBottom(cr.bottom() - m);
0
1458 }
executed: }
Execution Count:291
291
1459 return cr;
executed: return cr;
Execution Count:530
530
1460} -
1461 -
1462void QLabelPrivate::ensureTextPopulated() const -
1463{ -
1464 if (!textDirty)
evaluated: !textDirty
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:18
18-23
1465 return;
executed: return;
Execution Count:23
23
1466 if (control) {
partially evaluated: control
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
1467 QTextDocument *doc = control->document();
executed (the execution status of this line is deduced): QTextDocument *doc = control->document();
-
1468 if (textDirty) {
partially evaluated: textDirty
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
1469#ifndef QT_NO_TEXTHTMLPARSER -
1470 if (isRichText)
evaluated: isRichText
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:11
7-11
1471 doc->setHtml(text);
executed: doc->setHtml(text);
Execution Count:7
7
1472 else -
1473 doc->setPlainText(text);
executed: doc->setPlainText(text);
Execution Count:11
11
1474#else -
1475 doc->setPlainText(text); -
1476#endif -
1477 doc->setUndoRedoEnabled(false);
executed (the execution status of this line is deduced): doc->setUndoRedoEnabled(false);
-
1478 -
1479#ifndef QT_NO_SHORTCUT -
1480 if (hasShortcut) {
evaluated: hasShortcut
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:12
6-12
1481 // Underline the first character that follows an ampersand (and remove the others ampersands) -
1482 int from = 0;
executed (the execution status of this line is deduced): int from = 0;
-
1483 bool found = false;
executed (the execution status of this line is deduced): bool found = false;
-
1484 QTextCursor cursor;
executed (the execution status of this line is deduced): QTextCursor cursor;
-
1485 while (!(cursor = control->document()->find((QLatin1String("&")), from)).isNull()) {
evaluated: !(cursor = control->document()->find((QLatin1String("&")), from)).isNull()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:6
6-9
1486 cursor.deleteChar(); // remove the ampersand
executed (the execution status of this line is deduced): cursor.deleteChar();
-
1487 cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
executed (the execution status of this line is deduced): cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
-
1488 from = cursor.position();
executed (the execution status of this line is deduced): from = cursor.position();
-
1489 if (!found && cursor.selectedText() != QLatin1String("&")) { //not a second &
evaluated: !found
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1
evaluated: cursor.selectedText() != QLatin1String("&")
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3
1-8
1490 found = true;
executed (the execution status of this line is deduced): found = true;
-
1491 shortcutCursor = cursor;
executed (the execution status of this line is deduced): shortcutCursor = cursor;
-
1492 }
executed: }
Execution Count:5
5
1493 }
executed: }
Execution Count:9
9
1494 }
executed: }
Execution Count:6
6
1495#endif -
1496 }
executed: }
Execution Count:18
18
1497 }
executed: }
Execution Count:18
18
1498 textDirty = false;
executed (the execution status of this line is deduced): textDirty = false;
-
1499}
executed: }
Execution Count:18
18
1500 -
1501void QLabelPrivate::ensureTextLayouted() const -
1502{ -
1503 if (!textLayoutDirty)
evaluated: !textLayoutDirty
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:39
39-122
1504 return;
executed: return;
Execution Count:122
122
1505 ensureTextPopulated();
executed (the execution status of this line is deduced): ensureTextPopulated();
-
1506 if (control) {
partially evaluated: control
TRUEFALSE
yes
Evaluation Count:39
no
Evaluation Count:0
0-39
1507 QTextDocument *doc = control->document();
executed (the execution status of this line is deduced): QTextDocument *doc = control->document();
-
1508 QTextOption opt = doc->defaultTextOption();
executed (the execution status of this line is deduced): QTextOption opt = doc->defaultTextOption();
-
1509 -
1510 opt.setAlignment(QFlag(this->align));
executed (the execution status of this line is deduced): opt.setAlignment(QFlag(this->align));
-
1511 -
1512 if (this->align & Qt::TextWordWrap)
evaluated: this->align & Qt::TextWordWrap
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:26
13-26
1513 opt.setWrapMode(QTextOption::WordWrap);
executed: opt.setWrapMode(QTextOption::WordWrap);
Execution Count:13
13
1514 else -
1515 opt.setWrapMode(QTextOption::ManualWrap);
executed: opt.setWrapMode(QTextOption::ManualWrap);
Execution Count:26
26
1516 -
1517 doc->setDefaultTextOption(opt);
executed (the execution status of this line is deduced): doc->setDefaultTextOption(opt);
-
1518 -
1519 QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
executed (the execution status of this line is deduced): QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
-
1520 fmt.setMargin(0);
executed (the execution status of this line is deduced): fmt.setMargin(0);
-
1521 doc->rootFrame()->setFrameFormat(fmt);
executed (the execution status of this line is deduced): doc->rootFrame()->setFrameFormat(fmt);
-
1522 doc->setTextWidth(documentRect().width());
executed (the execution status of this line is deduced): doc->setTextWidth(documentRect().width());
-
1523 }
executed: }
Execution Count:39
39
1524 textLayoutDirty = false;
executed (the execution status of this line is deduced): textLayoutDirty = false;
-
1525}
executed: }
Execution Count:39
39
1526 -
1527void QLabelPrivate::ensureTextControl() const -
1528{ -
1529 Q_Q(const QLabel);
executed (the execution status of this line is deduced): const QLabel * const q = q_func();
-
1530 if (!isTextLabel)
partially evaluated: !isTextLabel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
1531 return;
never executed: return;
0
1532 if (!control) {
evaluated: !control
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:7
7-23
1533 control = new QWidgetTextControl(const_cast<QLabel *>(q));
executed (the execution status of this line is deduced): control = new QWidgetTextControl(const_cast<QLabel *>(q));
-
1534 control->document()->setUndoRedoEnabled(false);
executed (the execution status of this line is deduced): control->document()->setUndoRedoEnabled(false);
-
1535 control->document()->setDefaultFont(q->font());
executed (the execution status of this line is deduced): control->document()->setDefaultFont(q->font());
-
1536 control->setTextInteractionFlags(textInteractionFlags);
executed (the execution status of this line is deduced): control->setTextInteractionFlags(textInteractionFlags);
-
1537 control->setOpenExternalLinks(openExternalLinks);
executed (the execution status of this line is deduced): control->setOpenExternalLinks(openExternalLinks);
-
1538 control->setPalette(q->palette());
executed (the execution status of this line is deduced): control->setPalette(q->palette());
-
1539 control->setFocus(q->hasFocus());
executed (the execution status of this line is deduced): control->setFocus(q->hasFocus());
-
1540 QObject::connect(control, SIGNAL(updateRequest(QRectF)),
executed (the execution status of this line is deduced): QObject::connect(control, "2""updateRequest(QRectF)",
-
1541 q, SLOT(update()));
executed (the execution status of this line is deduced): q, "1""update()");
-
1542 QObject::connect(control, SIGNAL(linkHovered(QString)),
executed (the execution status of this line is deduced): QObject::connect(control, "2""linkHovered(QString)",
-
1543 q, SLOT(_q_linkHovered(QString)));
executed (the execution status of this line is deduced): q, "1""_q_linkHovered(QString)");
-
1544 QObject::connect(control, SIGNAL(linkActivated(QString)),
executed (the execution status of this line is deduced): QObject::connect(control, "2""linkActivated(QString)",
-
1545 q, SIGNAL(linkActivated(QString)));
executed (the execution status of this line is deduced): q, "2""linkActivated(QString)");
-
1546 textLayoutDirty = true;
executed (the execution status of this line is deduced): textLayoutDirty = true;
-
1547 textDirty = true;
executed (the execution status of this line is deduced): textDirty = true;
-
1548 }
executed: }
Execution Count:23
23
1549}
executed: }
Execution Count:30
30
1550 -
1551void QLabelPrivate::sendControlEvent(QEvent *e) -
1552{ -
1553 Q_Q(QLabel);
executed (the execution status of this line is deduced): QLabel * const q = q_func();
-
1554 if (!isTextLabel || !control || textInteractionFlags == Qt::NoTextInteraction) {
partially evaluated: !isTextLabel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
evaluated: !control
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:14
evaluated: textInteractionFlags == Qt::NoTextInteraction
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
0-17
1555 e->ignore();
executed (the execution status of this line is deduced): e->ignore();
-
1556 return;
executed: return;
Execution Count:4
4
1557 } -
1558 control->processEvent(e, -layoutRect().topLeft(), q);
executed (the execution status of this line is deduced): control->processEvent(e, -layoutRect().topLeft(), q);
-
1559}
executed: }
Execution Count:13
13
1560 -
1561void QLabelPrivate::_q_linkHovered(const QString &anchor) -
1562{ -
1563 Q_Q(QLabel);
never executed (the execution status of this line is deduced): QLabel * const q = q_func();
-
1564#ifndef QT_NO_CURSOR -
1565 if (anchor.isEmpty()) { // restore cursor
never evaluated: anchor.isEmpty()
0
1566 if (validCursor)
never evaluated: validCursor
0
1567 q->setCursor(cursor);
never executed: q->setCursor(cursor);
0
1568 else -
1569 q->unsetCursor();
never executed: q->unsetCursor();
0
1570 onAnchor = false;
never executed (the execution status of this line is deduced): onAnchor = false;
-
1571 } else if (!onAnchor) {
never executed: }
never evaluated: !onAnchor
0
1572 validCursor = q->testAttribute(Qt::WA_SetCursor);
never executed (the execution status of this line is deduced): validCursor = q->testAttribute(Qt::WA_SetCursor);
-
1573 if (validCursor) {
never evaluated: validCursor
0
1574 cursor = q->cursor();
never executed (the execution status of this line is deduced): cursor = q->cursor();
-
1575 }
never executed: }
0
1576 q->setCursor(Qt::PointingHandCursor);
never executed (the execution status of this line is deduced): q->setCursor(Qt::PointingHandCursor);
-
1577 onAnchor = true;
never executed (the execution status of this line is deduced): onAnchor = true;
-
1578 }
never executed: }
0
1579#endif -
1580 emit q->linkHovered(anchor);
never executed (the execution status of this line is deduced): q->linkHovered(anchor);
-
1581}
never executed: }
0
1582 -
1583// Return the layout rect - this is the rect that is given to the layout painting code -
1584// This may be different from the document rect since vertical alignment is not -
1585// done by the text layout code -
1586QRectF QLabelPrivate::layoutRect() const -
1587{ -
1588 QRectF cr = documentRect();
executed (the execution status of this line is deduced): QRectF cr = documentRect();
-
1589 if (!control)
evaluated: !control
TRUEFALSE
yes
Evaluation Count:455
yes
Evaluation Count:36
36-455
1590 return cr;
executed: return cr;
Execution Count:455
455
1591 ensureTextLayouted();
executed (the execution status of this line is deduced): ensureTextLayouted();
-
1592 // Caculate y position manually -
1593 qreal rh = control->document()->documentLayout()->documentSize().height();
executed (the execution status of this line is deduced): qreal rh = control->document()->documentLayout()->documentSize().height();
-
1594 qreal yo = 0;
executed (the execution status of this line is deduced): qreal yo = 0;
-
1595 if (align & Qt::AlignVCenter)
evaluated: align & Qt::AlignVCenter
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:6
6-30
1596 yo = qMax((cr.height()-rh)/2, qreal(0));
executed: yo = qMax((cr.height()-rh)/2, qreal(0));
Execution Count:30
30
1597 else if (align & Qt::AlignBottom)
partially evaluated: align & Qt::AlignBottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1598 yo = qMax(cr.height()-rh, qreal(0));
never executed: yo = qMax(cr.height()-rh, qreal(0));
0
1599 return QRectF(cr.x(), yo + cr.y(), cr.width(), cr.height());
executed: return QRectF(cr.x(), yo + cr.y(), cr.width(), cr.height());
Execution Count:36
36
1600} -
1601 -
1602// Returns the point in the document rect adjusted with p -
1603QPoint QLabelPrivate::layoutPoint(const QPoint& p) const -
1604{ -
1605 QRect lr = layoutRect().toRect();
never executed (the execution status of this line is deduced): QRect lr = layoutRect().toRect();
-
1606 return p - lr.topLeft();
never executed: return p - lr.topLeft();
0
1607} -
1608 -
1609#ifndef QT_NO_CONTEXTMENU -
1610QMenu *QLabelPrivate::createStandardContextMenu(const QPoint &pos) -
1611{ -
1612 QString linkToCopy;
executed (the execution status of this line is deduced): QString linkToCopy;
-
1613 QPoint p;
executed (the execution status of this line is deduced): QPoint p;
-
1614 if (control && isRichText) {
partially evaluated: control
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: isRichText
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1615 p = layoutPoint(pos);
never executed (the execution status of this line is deduced): p = layoutPoint(pos);
-
1616 linkToCopy = control->document()->documentLayout()->anchorAt(p);
never executed (the execution status of this line is deduced): linkToCopy = control->document()->documentLayout()->anchorAt(p);
-
1617 }
never executed: }
0
1618 -
1619 if (linkToCopy.isEmpty() && !control)
partially evaluated: linkToCopy.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !control
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1620 return 0;
never executed: return 0;
0
1621 -
1622 return control->createStandardContextMenu(p, q_func());
executed: return control->createStandardContextMenu(p, q_func());
Execution Count:1
1
1623} -
1624#endif -
1625 -
1626/*! -
1627 \fn void QLabel::linkHovered(const QString &link) -
1628 \since 4.2 -
1629 -
1630 This signal is emitted when the user hovers over a link. The URL -
1631 referred to by the anchor is passed in \a link. -
1632 -
1633 \sa linkActivated() -
1634*/ -
1635 -
1636 -
1637/*! -
1638 \fn void QLabel::linkActivated(const QString &link) -
1639 \since 4.2 -
1640 -
1641 This signal is emitted when the user clicks a link. The URL -
1642 referred to by the anchor is passed in \a link. -
1643 -
1644 \sa linkHovered() -
1645*/ -
1646 -
1647QT_END_NAMESPACE -
1648 -
1649#include "moc_qlabel.cpp" -
1650 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial