widgets/qlabel.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6const QPicture *QLabel::picture() const -
7{ -
8 const QLabelPrivate * const d = d_func(); -
9 return d->picture;
executed: return d->picture;
Execution Count:2
2
10} -
11QLabel::QLabel(QWidget *parent, Qt::WindowFlags f) -
12 : QFrame(*new QLabelPrivate(), parent, f) -
13{ -
14 QLabelPrivate * const d = d_func(); -
15 d->init(); -
16}
executed: }
Execution Count:892
892
17QLabel::QLabel(const QString &text, QWidget *parent, Qt::WindowFlags f) -
18 : QFrame(*new QLabelPrivate(), parent, f) -
19{ -
20 QLabelPrivate * const d = d_func(); -
21 d->init(); -
22 setText(text); -
23}
executed: }
Execution Count:161
161
24 -
25 -
26 -
27 -
28 -
29 -
30 -
31QLabel::~QLabel() -
32{ -
33 QLabelPrivate * const d = d_func(); -
34 d->clearContents(); -
35}
executed: }
Execution Count:1039
1039
36 -
37void QLabelPrivate::init() -
38{ -
39 QLabel * const q = q_func(); -
40 -
41 valid_hints = false; -
42 margin = 0; -
43 -
44 movie = 0; -
45 -
46 -
47 shortcutId = 0; -
48 -
49 pixmap = 0; -
50 scaledpixmap = 0; -
51 cachedimage = 0; -
52 -
53 picture = 0; -
54 -
55 align = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextExpandTabs; -
56 indent = -1; -
57 scaledcontents = false; -
58 textLayoutDirty = false; -
59 textDirty = false; -
60 textformat = Qt::AutoText; -
61 control = 0; -
62 textInteractionFlags = Qt::LinksAccessibleByMouse; -
63 isRichText = false; -
64 isTextLabel = false; -
65 -
66 q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, -
67 QSizePolicy::Label)); -
68 -
69 -
70 validCursor = false; -
71 onAnchor = false; -
72 -
73 -
74 openExternalLinks = false; -
75 -
76 setLayoutItemMargins(QStyle::SE_LabelLayoutItem); -
77}
executed: }
Execution Count:1053
1053
78void QLabel::setText(const QString &text) -
79{ -
80 QLabelPrivate * const d = d_func(); -
81 if (d->text == text)
evaluated: d->text == text
TRUEFALSE
yes
Evaluation Count:698
yes
Evaluation Count:1011
698-1011
82 return;
executed: return;
Execution Count:698
698
83 -
84 QWidgetTextControl *oldControl = d->control; -
85 d->control = 0; -
86 -
87 d->clearContents(); -
88 d->text = text; -
89 d->isTextLabel = true; -
90 d->textDirty = true; -
91 d->isRichText = d->textformat == Qt::RichText
evaluated: d->textformat == Qt::RichText
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1008
3-1008
92 || (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
93 -
94 d->control = oldControl; -
95 -
96 if (d->needTextControl()) {
evaluated: d->needTextControl()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1000
11-1000
97 d->ensureTextControl(); -
98 } else {
executed: }
Execution Count:11
11
99 delete d->control; -
100 d->control = 0; -
101 }
executed: }
Execution Count:1000
1000
102 -
103 if (d->isRichText) {
evaluated: d->isRichText
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1000
11-1000
104 setMouseTracking(true); -
105 } else {
executed: }
Execution Count:11
11
106 -
107 }
executed: }
Execution Count:1000
1000
108 -
109 -
110 if (d->buddy)
evaluated: d->buddy
TRUEFALSE
yes
Evaluation Count:256
yes
Evaluation Count:755
256-755
111 d->updateShortcut();
executed: d->updateShortcut();
Execution Count:256
256
112 -
113 -
114 d->updateLabel(); -
115 -
116 -
117 if (accessibleName().isEmpty()) {
partially evaluated: accessibleName().isEmpty()
TRUEFALSE
yes
Evaluation Count:1011
no
Evaluation Count:0
0-1011
118 QAccessibleEvent event(this, QAccessible::NameChanged); -
119 QAccessible::updateAccessibility(&event); -
120 }
executed: }
Execution Count:1011
1011
121 -
122}
executed: }
Execution Count:1011
1011
123 -
124QString QLabel::text() const -
125{ -
126 const QLabelPrivate * const d = d_func(); -
127 return d->text;
executed: return d->text;
Execution Count:60
60
128} -
129 -
130 -
131 -
132 -
133 -
134void QLabel::clear() -
135{ -
136 QLabelPrivate * const d = d_func(); -
137 d->clearContents(); -
138 d->updateLabel(); -
139}
executed: }
Execution Count:1
1
140void QLabel::setPixmap(const QPixmap &pixmap) -
141{ -
142 QLabelPrivate * const d = d_func(); -
143 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
144 d->clearContents(); -
145 d->pixmap = new QPixmap(pixmap); -
146 }
executed: }
Execution Count:60
60
147 -
148 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
149 d->pixmap->setMask(*((QBitmap *)d->pixmap));
never executed: d->pixmap->setMask(*((QBitmap *)d->pixmap));
0
150 -
151 d->updateLabel(); -
152}
executed: }
Execution Count:105
105
153 -
154const QPixmap *QLabel::pixmap() const -
155{ -
156 const QLabelPrivate * const d = d_func(); -
157 return d->pixmap;
executed: return d->pixmap;
Execution Count:34
34
158} -
159void QLabel::setPicture(const QPicture &picture) -
160{ -
161 QLabelPrivate * const d = d_func(); -
162 d->clearContents(); -
163 d->picture = new QPicture(picture); -
164 -
165 d->updateLabel(); -
166}
executed: }
Execution Count:1
1
167void QLabel::setNum(int num) -
168{ -
169 QString str; -
170 str.setNum(num); -
171 setText(str); -
172}
executed: }
Execution Count:1
1
173void QLabel::setNum(double num) -
174{ -
175 QString str; -
176 str.setNum(num); -
177 setText(str); -
178}
executed: }
Execution Count:1
1
179void QLabel::setAlignment(Qt::Alignment alignment) -
180{ -
181 QLabelPrivate * const d = d_func(); -
182 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
183 return;
executed: return;
Execution Count:83
83
184 d->align = (d->align & ~(Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask)) -
185 | (alignment & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask)); -
186 -
187 d->updateLabel(); -
188}
executed: }
Execution Count:69
69
189 -
190 -
191Qt::Alignment QLabel::alignment() const -
192{ -
193 const QLabelPrivate * const d = d_func(); -
194 return QFlag(d->align & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask));
never executed: return QFlag(d->align & (Qt::AlignVertical_Mask|Qt::AlignHorizontal_Mask));
0
195} -
196void QLabel::setWordWrap(bool on) -
197{ -
198 QLabelPrivate * const d = d_func(); -
199 if (on)
evaluated: on
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:133
31-133
200 d->align |= Qt::TextWordWrap;
executed: d->align |= Qt::TextWordWrap;
Execution Count:31
31
201 else -
202 d->align &= ~Qt::TextWordWrap;
executed: d->align &= ~Qt::TextWordWrap;
Execution Count:133
133
203 -
204 d->updateLabel(); -
205}
executed: }
Execution Count:164
164
206 -
207bool QLabel::wordWrap() const -
208{ -
209 const QLabelPrivate * const d = d_func(); -
210 return d->align & Qt::TextWordWrap;
executed: return d->align & Qt::TextWordWrap;
Execution Count:9
9
211} -
212void QLabel::setIndent(int indent) -
213{ -
214 QLabelPrivate * const d = d_func(); -
215 d->indent = indent; -
216 d->updateLabel(); -
217}
executed: }
Execution Count:131
131
218 -
219int QLabel::indent() const -
220{ -
221 const QLabelPrivate * const d = d_func(); -
222 return d->indent;
never executed: return d->indent;
0
223} -
224int QLabel::margin() const -
225{ -
226 const QLabelPrivate * const d = d_func(); -
227 return d->margin;
never executed: return d->margin;
0
228} -
229 -
230void QLabel::setMargin(int margin) -
231{ -
232 QLabelPrivate * const d = d_func(); -
233 if (d->margin == margin)
evaluated: d->margin == margin
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:11
2-11
234 return;
executed: return;
Execution Count:2
2
235 d->margin = margin; -
236 d->updateLabel(); -
237}
executed: }
Execution Count:11
11
238 -
239 -
240 -
241 -
242 -
243QSize QLabelPrivate::sizeForWidth(int w) const -
244{ -
245 const QLabel * const q = q_func(); -
246 if(q->minimumWidth() > 0)
evaluated: q->minimumWidth() > 0
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:3127
69-3127
247 w = qMax(w, q->minimumWidth());
executed: w = qMax(w, q->minimumWidth());
Execution Count:69
69
248 QSize contentsMargin(leftmargin + rightmargin, topmargin + bottommargin); -
249 -
250 QRect br; -
251 -
252 int hextra = 2 * margin; -
253 int vextra = hextra; -
254 QFontMetrics fm = q->fontMetrics(); -
255 -
256 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
257 br = pixmap->rect(); -
258 br.setSize(br.size() / pixmap->devicePixelRatio()); -
259 -
260 } else if (picture && !picture->isNull()) {
evaluated: picture
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3112
partially evaluated: !picture->isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
executed: }
Execution Count:83
0-3112
261 br = picture->boundingRect(); -
262 -
263 -
264 } else if (movie && !movie->currentPixmap().isNull()) {
evaluated: movie
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3110
evaluated: !movie->currentPixmap().isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
never executed: }
0-3110
265 br = movie->currentPixmap().rect(); -
266 -
267 } else if (isTextLabel) {
evaluated: isTextLabel
TRUEFALSE
yes
Evaluation Count:2982
yes
Evaluation Count:129
executed: }
Execution Count:2
2-2982
268 int align = QStyle::visualAlignment(textDirection(), QFlag(this->align)); -
269 -
270 int m = indent; -
271 -
272 if (m < 0 && q->frameWidth())
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
273 m = fm.width(QLatin1Char('x')) - margin*2;
executed: m = fm.width(QLatin1Char('x')) - margin*2;
Execution Count:9
9
274 if (m > 0) {
evaluated: m > 0
TRUEFALSE
yes
Evaluation Count:512
yes
Evaluation Count:2470
512-2470
275 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
276 hextra += m;
executed: hextra += m;
Execution Count:512
512
277 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
278 vextra += m;
executed: vextra += m;
Execution Count:31
31
279 }
executed: }
Execution Count:512
512
280 -
281 if (control) {
evaluated: control
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:2880
102-2880
282 ensureTextLayouted(); -
283 const qreal oldTextWidth = control->textWidth(); -
284 -
285 if (align & Qt::TextWordWrap) {
evaluated: align & Qt::TextWordWrap
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:45
45-57
286 if (w >= 0) {
evaluated: w >= 0
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:7
7-50
287 w = qMax(w-hextra-contentsMargin.width(), 0); -
288 control->setTextWidth(w); -
289 } else {
executed: }
Execution Count:50
50
290 control->adjustSize(); -
291 }
executed: }
Execution Count:7
7
292 } else { -
293 control->setTextWidth(-1); -
294 }
executed: }
Execution Count:45
45
295 -
296 QSizeF controlSize = control->size(); -
297 br = QRect(QPoint(0, 0), QSize(qCeil(controlSize.width()), qCeil(controlSize.height()))); -
298 -
299 -
300 control->setTextWidth(oldTextWidth); -
301 } else {
executed: }
Execution Count:102
102
302 -
303 -
304 int flags = align & ~(Qt::AlignVCenter | Qt::AlignHCenter); -
305 if (hasShortcut) {
evaluated: hasShortcut
TRUEFALSE
yes
Evaluation Count:657
yes
Evaluation Count:2223
657-2223
306 flags |= Qt::TextShowMnemonic; -
307 QStyleOption opt; -
308 opt.initFrom(q); -
309 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
310 flags |= Qt::TextHideMnemonic;
never executed: flags |= Qt::TextHideMnemonic;
0
311 }
executed: }
Execution Count:657
657
312 -
313 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
314 if (tryWidth)
evaluated: tryWidth
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:2800
80-2800
315 w = qMin(fm.averageCharWidth() * 80, q->maximumSize().width());
executed: w = qMin(fm.averageCharWidth() * 80, q->maximumSize().width());
Execution Count:80
80
316 else if (w < 0)
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:819
yes
Evaluation Count:1981
819-1981
317 w = 2000;
executed: w = 2000;
Execution Count:819
819
318 w -= (hextra + contentsMargin.width()); -
319 br = fm.boundingRect(0, 0, w ,2000, flags, text); -
320 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
321 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
322 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
323 br = fm.boundingRect(0, 0, w/4, 2000, flags, text);
never executed: br = fm.boundingRect(0, 0, w/4, 2000, flags, text);
0
324 }
executed: }
Execution Count:2880
2880
325 } else { -
326 br = QRect(QPoint(0, 0), QSize(fm.averageCharWidth(), fm.lineSpacing())); -
327 }
executed: }
Execution Count:129
129
328 -
329 const QSize contentsSize(br.width() + hextra, br.height() + vextra); -
330 return (contentsSize + contentsMargin).expandedTo(q->minimumSize());
executed: return (contentsSize + contentsMargin).expandedTo(q->minimumSize());
Execution Count:3196
3196
331} -
332 -
333 -
334 -
335 -
336 -
337 -
338int QLabel::heightForWidth(int w) const -
339{ -
340 const QLabelPrivate * const d = d_func(); -
341 if (d->isTextLabel)
partially evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:189
no
Evaluation Count:0
0-189
342 return d->sizeForWidth(w).height();
executed: return d->sizeForWidth(w).height();
Execution Count:189
189
343 return QWidget::heightForWidth(w);
never executed: return QWidget::heightForWidth(w);
0
344} -
345bool QLabel::openExternalLinks() const -
346{ -
347 const QLabelPrivate * const d = d_func(); -
348 return d->openExternalLinks;
never executed: return d->openExternalLinks;
0
349} -
350 -
351void QLabel::setOpenExternalLinks(bool open) -
352{ -
353 QLabelPrivate * const d = d_func(); -
354 d->openExternalLinks = open; -
355 if (d->control)
partially evaluated: d->control
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
356 d->control->setOpenExternalLinks(open);
never executed: d->control->setOpenExternalLinks(open);
0
357}
executed: }
Execution Count:43
43
358void QLabel::setTextInteractionFlags(Qt::TextInteractionFlags flags) -
359{ -
360 QLabelPrivate * const d = d_func(); -
361 if (d->textInteractionFlags == flags)
evaluated: d->textInteractionFlags == flags
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:19
19-45
362 return;
executed: return;
Execution Count:45
45
363 d->textInteractionFlags = flags; -
364 if (flags & Qt::LinksAccessibleByKeyboard)
evaluated: flags & Qt::LinksAccessibleByKeyboard
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
365 setFocusPolicy(Qt::StrongFocus);
executed: setFocusPolicy(Qt::StrongFocus);
Execution Count:1
1
366 else if (flags & (Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse))
evaluated: flags & (Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:4
4-14
367 setFocusPolicy(Qt::ClickFocus);
executed: setFocusPolicy(Qt::ClickFocus);
Execution Count:14
14
368 else -
369 setFocusPolicy(Qt::NoFocus);
executed: setFocusPolicy(Qt::NoFocus);
Execution Count:4
4
370 -
371 if (d->needTextControl()) {
evaluated: d->needTextControl()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2
2-17
372 d->ensureTextControl(); -
373 } else {
executed: }
Execution Count:17
17
374 delete d->control; -
375 d->control = 0; -
376 }
executed: }
Execution Count:2
2
377 -
378 if (d->control)
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2
2-17
379 d->control->setTextInteractionFlags(d->textInteractionFlags);
executed: d->control->setTextInteractionFlags(d->textInteractionFlags);
Execution Count:17
17
380}
executed: }
Execution Count:19
19
381 -
382Qt::TextInteractionFlags QLabel::textInteractionFlags() const -
383{ -
384 const QLabelPrivate * const d = d_func(); -
385 return d->textInteractionFlags;
never executed: return d->textInteractionFlags;
0
386} -
387void QLabel::setSelection(int start, int length) -
388{ -
389 QLabelPrivate * const d = d_func(); -
390 if (d->control) {
partially evaluated: d->control
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
391 d->ensureTextPopulated(); -
392 QTextCursor cursor = d->control->textCursor(); -
393 cursor.setPosition(start); -
394 cursor.setPosition(start + length, QTextCursor::KeepAnchor); -
395 d->control->setTextCursor(cursor); -
396 }
executed: }
Execution Count:2
2
397}
executed: }
Execution Count:2
2
398bool QLabel::hasSelectedText() const -
399{ -
400 const QLabelPrivate * const d = d_func(); -
401 if (d->control)
partially evaluated: d->control
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
402 return d->control->textCursor().hasSelection();
executed: return d->control->textCursor().hasSelection();
Execution Count:3
3
403 return false;
never executed: return false;
0
404} -
405QString QLabel::selectedText() const -
406{ -
407 const QLabelPrivate * const d = d_func(); -
408 if (d->control)
partially evaluated: d->control
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
409 return d->control->textCursor().selectedText();
executed: return d->control->textCursor().selectedText();
Execution Count:3
3
410 return QString();
never executed: return QString();
0
411} -
412int QLabel::selectionStart() const -
413{ -
414 const QLabelPrivate * const d = d_func(); -
415 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
416 return d->control->textCursor().selectionStart();
executed: return d->control->textCursor().selectionStart();
Execution Count:2
2
417 return -1;
executed: return -1;
Execution Count:1
1
418} -
419 -
420 -
421 -
422QSize QLabel::sizeHint() const -
423{ -
424 const QLabelPrivate * const d = d_func(); -
425 if (!d->valid_hints)
evaluated: !d->valid_hints
TRUEFALSE
yes
Evaluation Count:1105
yes
Evaluation Count:401
401-1105
426 (void) QLabel::minimumSizeHint();
executed: (void) QLabel::minimumSizeHint();
Execution Count:1105
1105
427 return d->sh;
executed: return d->sh;
Execution Count:1506
1506
428} -
429 -
430 -
431 -
432 -
433QSize QLabel::minimumSizeHint() const -
434{ -
435 const QLabelPrivate * const d = d_func(); -
436 if (d->valid_hints) {
evaluated: d->valid_hints
TRUEFALSE
yes
Evaluation Count:1352
yes
Evaluation Count:1133
1133-1352
437 if (d->sizePolicy == sizePolicy())
evaluated: d->sizePolicy == sizePolicy()
TRUEFALSE
yes
Evaluation Count:1340
yes
Evaluation Count:12
12-1340
438 return d->msh;
executed: return d->msh;
Execution Count:1340
1340
439 }
executed: }
Execution Count:12
12
440 -
441 ensurePolished(); -
442 d->valid_hints = true; -
443 d->sh = d->sizeForWidth(-1); -
444 QSize msh(-1, -1); -
445 -
446 if (!d->isTextLabel) {
evaluated: !d->isTextLabel
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:931
214-931
447 msh = d->sh; -
448 } else {
executed: }
Execution Count:214
214
449 msh.rheight() = d->sizeForWidth(((1<<24)-1)).height(); -
450 msh.rwidth() = d->sizeForWidth(0).width(); -
451 if (d->sh.height() < msh.height())
partially evaluated: d->sh.height() < msh.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:931
0-931
452 msh.rheight() = d->sh.height();
never executed: msh.rheight() = d->sh.height();
0
453 }
executed: }
Execution Count:931
931
454 d->msh = msh; -
455 d->sizePolicy = sizePolicy(); -
456 return msh;
executed: return msh;
Execution Count:1145
1145
457} -
458 -
459 -
460 -
461void QLabel::mousePressEvent(QMouseEvent *ev) -
462{ -
463 QLabelPrivate * const d = d_func(); -
464 d->sendControlEvent(ev); -
465}
executed: }
Execution Count:10
10
466 -
467 -
468 -
469void QLabel::mouseMoveEvent(QMouseEvent *ev) -
470{ -
471 QLabelPrivate * const d = d_func(); -
472 d->sendControlEvent(ev); -
473}
executed: }
Execution Count:1
1
474 -
475 -
476 -
477void QLabel::mouseReleaseEvent(QMouseEvent *ev) -
478{ -
479 QLabelPrivate * const d = d_func(); -
480 d->sendControlEvent(ev); -
481}
executed: }
Execution Count:1
1
482 -
483 -
484 -
485void QLabel::contextMenuEvent(QContextMenuEvent *ev) -
486{ -
487 -
488 -
489 -
490 QLabelPrivate * const d = d_func(); -
491 if (!d->isTextLabel) {
partially evaluated: !d->isTextLabel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
492 ev->ignore(); -
493 return;
never executed: return;
0
494 } -
495 QMenu *menu = d->createStandardContextMenu(ev->pos()); -
496 if (!menu) {
partially evaluated: !menu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
497 ev->ignore(); -
498 return;
never executed: return;
0
499 } -
500 ev->accept(); -
501 menu->setAttribute(Qt::WA_DeleteOnClose); -
502 menu->popup(ev->globalPos()); -
503 -
504}
executed: }
Execution Count:1
1
505 -
506 -
507 -
508 -
509void QLabel::focusInEvent(QFocusEvent *ev) -
510{ -
511 QLabelPrivate * const d = d_func(); -
512 if (d->isTextLabel) {
evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
513 d->ensureTextControl(); -
514 d->sendControlEvent(ev); -
515 }
executed: }
Execution Count:2
2
516 QFrame::focusInEvent(ev); -
517}
executed: }
Execution Count:3
3
518 -
519 -
520 -
521 -
522void QLabel::focusOutEvent(QFocusEvent *ev) -
523{ -
524 QLabelPrivate * const d = d_func(); -
525 if (d->control) {
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
526 d->sendControlEvent(ev); -
527 QTextCursor cursor = d->control->textCursor(); -
528 Qt::FocusReason reason = ev->reason(); -
529 if (reason != Qt::ActiveWindowFocusReason
partially evaluated: reason != Qt::ActiveWindowFocusReason
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
530 && reason != Qt::PopupFocusReason
evaluated: reason != Qt::PopupFocusReason
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
531 && cursor.hasSelection()) {
partially evaluated: cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
532 cursor.clearSelection(); -
533 d->control->setTextCursor(cursor); -
534 }
never executed: }
0
535 }
executed: }
Execution Count:2
2
536 -
537 QFrame::focusOutEvent(ev); -
538}
executed: }
Execution Count:3
3
539 -
540 -
541 -
542bool QLabel::focusNextPrevChild(bool next) -
543{ -
544 QLabelPrivate * const d = d_func(); -
545 if (d->control && d->control->setFocusToNextOrPreviousAnchor(next))
never evaluated: d->control
never evaluated: d->control->setFocusToNextOrPreviousAnchor(next)
0
546 return true;
never executed: return true;
0
547 return QFrame::focusNextPrevChild(next);
never executed: return QFrame::focusNextPrevChild(next);
0
548} -
549 -
550 -
551 -
552void QLabel::keyPressEvent(QKeyEvent *ev) -
553{ -
554 QLabelPrivate * const d = d_func(); -
555 d->sendControlEvent(ev); -
556}
executed: }
Execution Count:1
1
557 -
558 -
559 -
560bool QLabel::event(QEvent *e) -
561{ -
562 QLabelPrivate * const d = d_func(); -
563 QEvent::Type type = e->type(); -
564 -
565 -
566 if (type == QEvent::Shortcut) {
evaluated: type == QEvent::Shortcut
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:7755
2-7755
567 QShortcutEvent *se = static_cast<QShortcutEvent *>(e); -
568 if (se->shortcutId() == d->shortcutId) {
partially evaluated: se->shortcutId() == d->shortcutId
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
569 QWidget * w = d->buddy; -
570 QAbstractButton *button = qobject_cast<QAbstractButton *>(w); -
571 if (w->focusPolicy() != Qt::NoFocus)
partially evaluated: w->focusPolicy() != Qt::NoFocus
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
572 w->setFocus(Qt::ShortcutFocusReason);
executed: w->setFocus(Qt::ShortcutFocusReason);
Execution Count:2
2
573 if (button && !se->isAmbiguous())
partially evaluated: button
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: !se->isAmbiguous()
0-2
574 button->animateClick();
never executed: button->animateClick();
0
575 else -
576 window()->setAttribute(Qt::WA_KeyboardFocusChange);
executed: window()->setAttribute(Qt::WA_KeyboardFocusChange);
Execution Count:2
2
577 return true;
executed: return true;
Execution Count:2
2
578 } -
579 } else
never executed: }
0
580 -
581 if (type == QEvent::Resize) {
evaluated: type == QEvent::Resize
TRUEFALSE
yes
Evaluation Count:641
yes
Evaluation Count:7114
641-7114
582 if (d->control)
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:617
24-617
583 d->textLayoutDirty = true;
executed: d->textLayoutDirty = true;
Execution Count:24
24
584 } 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
585 -
586 -
587 -
588 ) { -
589 d->setLayoutItemMargins(QStyle::SE_LabelLayoutItem); -
590 d->updateLabel(); -
591 }
executed: }
Execution Count:131
131
592 -
593 return QFrame::event(e);
executed: return QFrame::event(e);
Execution Count:7755
7755
594} -
595 -
596 -
597 -
598void QLabel::paintEvent(QPaintEvent *) -
599{ -
600 QLabelPrivate * const d = d_func(); -
601 QStyle *style = QWidget::style(); -
602 QPainter painter(this); -
603 drawFrame(&painter); -
604 QRect cr = contentsRect(); -
605 cr.adjust(d->margin, d->margin, -d->margin, -d->margin); -
606 int align = QStyle::visualAlignment(d->isTextLabel ? d->textDirection() -
607 : layoutDirection(), QFlag(d->align)); -
608 -
609 -
610 if (d->movie) {
evaluated: d->movie
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:586
129-586
611 if (d->scaledcontents)
partially evaluated: d->scaledcontents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:129
0-129
612 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
613 else -
614 style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap());
executed: style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap());
Execution Count:129
129
615 } -
616 else -
617 -
618 if (d->isTextLabel) {
evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:478
yes
Evaluation Count:108
108-478
619 QRectF lr = d->layoutRect().toAlignedRect(); -
620 QStyleOption opt; -
621 opt.initFrom(this); -
622 -
623 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
624 cssStyle->styleSheetPalette(this, &opt, &opt.palette); -
625 }
never executed: }
0
626 -
627 if (d->control) {
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:455
23-455
628 -
629 const bool underline = (bool)style->styleHint(QStyle::SH_UnderlineShortcut, 0, this, 0); -
630 if (d->shortcutId != 0
evaluated: d->shortcutId != 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:15
8-15
631 && underline != d->shortcutCursor.charFormat().fontUnderline()) {
evaluated: underline != d->shortcutCursor.charFormat().fontUnderline()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
632 QTextCharFormat fmt; -
633 fmt.setFontUnderline(underline); -
634 d->shortcutCursor.mergeCharFormat(fmt); -
635 }
executed: }
Execution Count:4
4
636 -
637 d->ensureTextLayouted(); -
638 -
639 QAbstractTextDocumentLayout::PaintContext context; -
640 if (!isEnabled() && !d->control &&
partially evaluated: !isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
never evaluated: !d->control
0-23
641 -
642 -
643 style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)) {
never evaluated: style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)
0
644 context.palette = opt.palette; -
645 context.palette.setColor(QPalette::Text, context.palette.light().color()); -
646 painter.save(); -
647 painter.translate(lr.x() + 1, lr.y() + 1); -
648 painter.setClipRect(lr.translated(-lr.x() - 1, -lr.y() - 1)); -
649 QAbstractTextDocumentLayout *layout = d->control->document()->documentLayout(); -
650 layout->draw(&painter, context); -
651 painter.restore(); -
652 }
never executed: }
0
653 -
654 -
655 context.palette = opt.palette; -
656 -
657 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
658 context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));
executed: context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));
Execution Count:20
20
659 -
660 painter.save(); -
661 painter.translate(lr.topLeft()); -
662 painter.setClipRect(lr.translated(-lr.x(), -lr.y())); -
663 d->control->setPalette(context.palette); -
664 d->control->drawContents(&painter, QRectF(), this); -
665 painter.restore(); -
666 } else {
executed: }
Execution Count:23
23
667 int flags = align | (d->textDirection() == Qt::LeftToRight ? Qt::TextForceLeftToRight -
668 : Qt::TextForceRightToLeft); -
669 if (d->hasShortcut) {
evaluated: d->hasShortcut
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:397
58-397
670 flags |= Qt::TextShowMnemonic; -
671 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
672 flags |= Qt::TextHideMnemonic;
never executed: flags |= Qt::TextHideMnemonic;
0
673 }
executed: }
Execution Count:58
58
674 style->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), d->text, foregroundRole()); -
675 }
executed: }
Execution Count:455
455
676 } else -
677 -
678 if (d->picture) {
partially evaluated: d->picture
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:108
0-108
679 QRect br = d->picture->boundingRect(); -
680 int rw = br.width(); -
681 int rh = br.height(); -
682 if (d->scaledcontents) {
never evaluated: d->scaledcontents
0
683 painter.save(); -
684 painter.translate(cr.x(), cr.y()); -
685 painter.scale((double)cr.width()/rw, (double)cr.height()/rh); -
686 painter.drawPicture(-br.x(), -br.y(), *d->picture); -
687 painter.restore(); -
688 } else {
never executed: }
0
689 int xo = 0; -
690 int yo = 0; -
691 if (align & Qt::AlignVCenter)
never evaluated: align & Qt::AlignVCenter
0
692 yo = (cr.height()-rh)/2;
never executed: yo = (cr.height()-rh)/2;
0
693 else if (align & Qt::AlignBottom)
never evaluated: align & Qt::AlignBottom
0
694 yo = cr.height()-rh;
never executed: yo = cr.height()-rh;
0
695 if (align & Qt::AlignRight)
never evaluated: align & Qt::AlignRight
0
696 xo = cr.width()-rw;
never executed: xo = cr.width()-rw;
0
697 else if (align & Qt::AlignHCenter)
never evaluated: align & Qt::AlignHCenter
0
698 xo = (cr.width()-rw)/2;
never executed: xo = (cr.width()-rw)/2;
0
699 painter.drawPicture(cr.x()+xo-br.x(), cr.y()+yo-br.y(), *d->picture); -
700 }
never executed: }
0
701 } else -
702 -
703 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
704 QPixmap pix; -
705 if (d->scaledcontents) {
partially evaluated: d->scaledcontents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
706 if (!d->scaledpixmap || d->scaledpixmap->size() != cr.size()) {
never evaluated: !d->scaledpixmap
never evaluated: d->scaledpixmap->size() != cr.size()
0
707 if (!d->cachedimage)
never evaluated: !d->cachedimage
0
708 d->cachedimage = new QImage(d->pixmap->toImage());
never executed: d->cachedimage = new QImage(d->pixmap->toImage());
0
709 delete d->scaledpixmap; -
710 d->scaledpixmap = new QPixmap(QPixmap::fromImage(d->cachedimage->scaled(cr.size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation))); -
711 }
never executed: }
0
712 pix = *d->scaledpixmap; -
713 } else
never executed: }
0
714 pix = *d->pixmap;
executed: pix = *d->pixmap;
Execution Count:46
46
715 QStyleOption opt; -
716 opt.initFrom(this); -
717 if (!isEnabled())
partially evaluated: !isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
718 pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt);
never executed: pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt);
0
719 style->drawItemPixmap(&painter, cr, align, pix); -
720 }
executed: }
Execution Count:46
46
721} -
722 -
723 -
724 -
725 -
726 -
727 -
728void QLabelPrivate::updateLabel() -
729{ -
730 QLabel * const q = q_func(); -
731 valid_hints = false; -
732 -
733 if (isTextLabel) {
evaluated: isTextLabel
TRUEFALSE
yes
Evaluation Count:1438
yes
Evaluation Count:375
375-1438
734 QSizePolicy policy = q->sizePolicy(); -
735 const bool wrap = align & Qt::TextWordWrap; -
736 policy.setHeightForWidth(wrap); -
737 if (policy != q->sizePolicy())
evaluated: policy != q->sizePolicy()
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:1390
48-1390
738 q->setSizePolicy(policy);
executed: q->setSizePolicy(policy);
Execution Count:48
48
739 textLayoutDirty = true; -
740 }
executed: }
Execution Count:1438
1438
741 q->updateGeometry(); -
742 q->update(q->contentsRect()); -
743}
executed: }
Execution Count:1813
1813
744void QLabel::setBuddy(QWidget *buddy) -
745{ -
746 QLabelPrivate * const d = d_func(); -
747 d->buddy = buddy; -
748 if (d->isTextLabel) {
evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:304
30-304
749 if (d->shortcutId)
partially evaluated: d->shortcutId
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
750 releaseShortcut(d->shortcutId);
never executed: releaseShortcut(d->shortcutId);
0
751 d->shortcutId = 0; -
752 d->textDirty = true; -
753 if (buddy)
evaluated: buddy
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:8
8-22
754 d->updateShortcut();
executed: d->updateShortcut();
Execution Count:22
22
755 d->updateLabel(); -
756 }
executed: }
Execution Count:30
30
757}
executed: }
Execution Count:334
334
758QWidget * QLabel::buddy() const -
759{ -
760 const QLabelPrivate * const d = d_func(); -
761 return d->buddy;
executed: return d->buddy;
Execution Count:17
17
762} -
763 -
764void QLabelPrivate::updateShortcut() -
765{ -
766 QLabel * const q = q_func(); -
767 qt_noop(); -
768 -
769 -
770 -
771 -
772 hasShortcut = false; -
773 -
774 if (!text.contains(QLatin1Char('&')))
evaluated: !text.contains(QLatin1Char('&'))
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:253
25-253
775 return;
executed: return;
Execution Count:25
25
776 hasShortcut = true; -
777 shortcutId = q->grabShortcut(QKeySequence::mnemonic(text)); -
778}
executed: }
Execution Count:253
253
779 -
780 -
781 -
782 -
783void QLabelPrivate::_q_movieUpdated(const QRect& rect) -
784{ -
785 QLabel * const q = q_func(); -
786 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
787 QRect r; -
788 if (scaledcontents) {
partially evaluated: scaledcontents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
789 QRect cr = q->contentsRect(); -
790 QRect pixmapRect(cr.topLeft(), movie->currentPixmap().size()); -
791 if (pixmapRect.isEmpty())
never evaluated: pixmapRect.isEmpty()
0
792 return;
never executed: return;
0
793 r.setRect(cr.left(), cr.top(), -
794 (rect.width() * cr.width()) / pixmapRect.width(), -
795 (rect.height() * cr.height()) / pixmapRect.height()); -
796 } else {
never executed: }
0
797 r = q->style()->itemPixmapRect(q->contentsRect(), align, movie->currentPixmap()); -
798 r.translate(rect.x(), rect.y()); -
799 r.setWidth(qMin(r.width(), rect.width())); -
800 r.setHeight(qMin(r.height(), rect.height())); -
801 }
executed: }
Execution Count:130
130
802 q->update(r); -
803 }
executed: }
Execution Count:130
130
804}
executed: }
Execution Count:130
130
805 -
806void QLabelPrivate::_q_movieResized(const QSize& size) -
807{ -
808 QLabel * const q = q_func(); -
809 q->update(); -
810 valid_hints = false; -
811 _q_movieUpdated(QRect(QPoint(0,0), size)); -
812 q->updateGeometry(); -
813}
executed: }
Execution Count:3
3
814void QLabel::setMovie(QMovie *movie) -
815{ -
816 QLabelPrivate * const d = d_func(); -
817 d->clearContents(); -
818 -
819 if (!movie)
evaluated: !movie
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
820 return;
executed: return;
Execution Count:1
1
821 -
822 d->movie = movie; -
823 connect(movie, "2""resized(QSize)", this, "1""_q_movieResized(QSize)"); -
824 connect(movie, "2""updated(QRect)", this, "1""_q_movieUpdated(QRect)"); -
825 -
826 -
827 -
828 if (movie->state() != QMovie::Running)
evaluated: movie->state() != QMovie::Running
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
829 d->updateLabel();
executed: d->updateLabel();
Execution Count:4
4
830}
executed: }
Execution Count:6
6
831void QLabelPrivate::clearContents() -
832{ -
833 delete control; -
834 control = 0; -
835 isTextLabel = false; -
836 hasShortcut = false; -
837 -
838 -
839 delete picture; -
840 picture = 0; -
841 -
842 delete scaledpixmap; -
843 scaledpixmap = 0; -
844 delete cachedimage; -
845 cachedimage = 0; -
846 delete pixmap; -
847 pixmap = 0; -
848 -
849 text.clear(); -
850 QLabel * const q = q_func(); -
851 -
852 if (shortcutId)
evaluated: shortcutId
TRUEFALSE
yes
Evaluation Count:245
yes
Evaluation Count:1874
245-1874
853 q->releaseShortcut(shortcutId);
executed: q->releaseShortcut(shortcutId);
Execution Count:245
245
854 shortcutId = 0; -
855 -
856 -
857 if (movie) {
evaluated: movie
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2114
5-2114
858 QObject::disconnect(movie, "2""resized(QSize)", q, "1""_q_movieResized(QSize)"); -
859 QObject::disconnect(movie, "2""updated(QRect)", q, "1""_q_movieUpdated(QRect)"); -
860 }
executed: }
Execution Count:5
5
861 movie = 0; -
862 -
863 -
864 if (onAnchor) {
partially evaluated: onAnchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2119
0-2119
865 if (validCursor)
never evaluated: validCursor
0
866 q->setCursor(cursor);
never executed: q->setCursor(cursor);
0
867 else -
868 q->unsetCursor();
never executed: q->unsetCursor();
0
869 } -
870 validCursor = false; -
871 onAnchor = false; -
872 -
873}
executed: }
Execution Count:2119
2119
874QMovie *QLabel::movie() const -
875{ -
876 const QLabelPrivate * const d = d_func(); -
877 return d->movie;
executed: return d->movie;
Execution Count:4
4
878} -
879Qt::TextFormat QLabel::textFormat() const -
880{ -
881 const QLabelPrivate * const d = d_func(); -
882 return d->textformat;
executed: return d->textformat;
Execution Count:73
73
883} -
884 -
885void QLabel::setTextFormat(Qt::TextFormat format) -
886{ -
887 QLabelPrivate * const d = d_func(); -
888 if (format != d->textformat) {
evaluated: format != d->textformat
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:144
14-144
889 d->textformat = format; -
890 QString t = d->text; -
891 if (!t.isNull()) {
partially evaluated: !t.isNull()
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
892 d->text.clear(); -
893 setText(t); -
894 }
executed: }
Execution Count:14
14
895 }
executed: }
Execution Count:14
14
896}
executed: }
Execution Count:158
158
897 -
898 -
899 -
900 -
901void QLabel::changeEvent(QEvent *ev) -
902{ -
903 QLabelPrivate * const d = d_func(); -
904 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
905 if (d->isTextLabel) {
evaluated: d->isTextLabel
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:14
14-28
906 if (d->control)
evaluated: d->control
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:27
1-27
907 d->control->document()->setDefaultFont(font());
executed: d->control->document()->setDefaultFont(font());
Execution Count:1
1
908 d->updateLabel(); -
909 }
executed: }
Execution Count:28
28
910 } 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
911 d->control->setPalette(palette()); -
912 } else if (ev->type() == QEvent::ContentsRectChange) {
never executed: }
evaluated: ev->type() == QEvent::ContentsRectChange
TRUEFALSE
yes
Evaluation Count:127
yes
Evaluation Count:517
0-517
913 d->updateLabel(); -
914 }
executed: }
Execution Count:127
127
915 QFrame::changeEvent(ev); -
916}
executed: }
Execution Count:686
686
917bool QLabel::hasScaledContents() const -
918{ -
919 const QLabelPrivate * const d = d_func(); -
920 return d->scaledcontents;
never executed: return d->scaledcontents;
0
921} -
922 -
923void QLabel::setScaledContents(bool enable) -
924{ -
925 QLabelPrivate * const d = d_func(); -
926 if ((bool)d->scaledcontents == enable)
partially evaluated: (bool)d->scaledcontents == enable
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
0-42
927 return;
executed: return;
Execution Count:42
42
928 d->scaledcontents = enable; -
929 if (!enable) {
never evaluated: !enable
0
930 delete d->scaledpixmap; -
931 d->scaledpixmap = 0; -
932 delete d->cachedimage; -
933 d->cachedimage = 0; -
934 }
never executed: }
0
935 update(contentsRect()); -
936}
never executed: }
0
937 -
938Qt::LayoutDirection QLabelPrivate::textDirection() const -
939{ -
940 if (control) {
evaluated: control
TRUEFALSE
yes
Evaluation Count:200
yes
Evaluation Count:4245
200-4245
941 QTextOption opt = control->document()->defaultTextOption(); -
942 return opt.textDirection();
executed: return opt.textDirection();
Execution Count:200
200
943 } -
944 -
945 return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
executed: return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
Execution Count:4245
4245
946} -
947 -
948 -
949 -
950QRect QLabelPrivate::documentRect() const -
951{ -
952 const QLabel * const q = q_func(); -
953 qt_noop(); -
954 QRect cr = q->contentsRect(); -
955 cr.adjust(margin, margin, -margin, -margin); -
956 const int align = QStyle::visualAlignment(isTextLabel ? textDirection() -
957 : q->layoutDirection(), QFlag(this->align)); -
958 int m = indent; -
959 if (m < 0 && q->frameWidth())
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
960 m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
executed: m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
Execution Count:194
194
961 if (m > 0) {
evaluated: m > 0
TRUEFALSE
yes
Evaluation Count:291
yes
Evaluation Count:239
239-291
962 if (align & Qt::AlignLeft)
partially evaluated: align & Qt::AlignLeft
TRUEFALSE
yes
Evaluation Count:291
no
Evaluation Count:0
0-291
963 cr.setLeft(cr.left() + m);
executed: cr.setLeft(cr.left() + m);
Execution Count:291
291
964 if (align & Qt::AlignRight)
partially evaluated: align & Qt::AlignRight
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:291
0-291
965 cr.setRight(cr.right() - m);
never executed: cr.setRight(cr.right() - m);
0
966 if (align & Qt::AlignTop)
evaluated: align & Qt::AlignTop
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:281
10-281
967 cr.setTop(cr.top() + m);
executed: cr.setTop(cr.top() + m);
Execution Count:10
10
968 if (align & Qt::AlignBottom)
partially evaluated: align & Qt::AlignBottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:291
0-291
969 cr.setBottom(cr.bottom() - m);
never executed: cr.setBottom(cr.bottom() - m);
0
970 }
executed: }
Execution Count:291
291
971 return cr;
executed: return cr;
Execution Count:530
530
972} -
973 -
974void QLabelPrivate::ensureTextPopulated() const -
975{ -
976 if (!textDirty)
evaluated: !textDirty
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:18
18-23
977 return;
executed: return;
Execution Count:23
23
978 if (control) {
partially evaluated: control
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
979 QTextDocument *doc = control->document(); -
980 if (textDirty) {
partially evaluated: textDirty
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
981 -
982 if (isRichText)
evaluated: isRichText
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:11
7-11
983 doc->setHtml(text);
executed: doc->setHtml(text);
Execution Count:7
7
984 else -
985 doc->setPlainText(text);
executed: doc->setPlainText(text);
Execution Count:11
11
986 -
987 -
988 -
989 doc->setUndoRedoEnabled(false); -
990 -
991 -
992 if (hasShortcut) {
evaluated: hasShortcut
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:12
6-12
993 -
994 int from = 0; -
995 bool found = false; -
996 QTextCursor cursor; -
997 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
998 cursor.deleteChar(); -
999 cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); -
1000 from = cursor.position(); -
1001 if (!found && cursor.selectedText() != QLatin1String("&")) {
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
1002 found = true; -
1003 shortcutCursor = cursor; -
1004 }
executed: }
Execution Count:5
5
1005 }
executed: }
Execution Count:9
9
1006 }
executed: }
Execution Count:6
6
1007 -
1008 }
executed: }
Execution Count:18
18
1009 }
executed: }
Execution Count:18
18
1010 textDirty = false; -
1011}
executed: }
Execution Count:18
18
1012 -
1013void QLabelPrivate::ensureTextLayouted() const -
1014{ -
1015 if (!textLayoutDirty)
evaluated: !textLayoutDirty
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:39
39-122
1016 return;
executed: return;
Execution Count:122
122
1017 ensureTextPopulated(); -
1018 if (control) {
partially evaluated: control
TRUEFALSE
yes
Evaluation Count:39
no
Evaluation Count:0
0-39
1019 QTextDocument *doc = control->document(); -
1020 QTextOption opt = doc->defaultTextOption(); -
1021 -
1022 opt.setAlignment(QFlag(this->align)); -
1023 -
1024 if (this->align & Qt::TextWordWrap)
evaluated: this->align & Qt::TextWordWrap
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:26
13-26
1025 opt.setWrapMode(QTextOption::WordWrap);
executed: opt.setWrapMode(QTextOption::WordWrap);
Execution Count:13
13
1026 else -
1027 opt.setWrapMode(QTextOption::ManualWrap);
executed: opt.setWrapMode(QTextOption::ManualWrap);
Execution Count:26
26
1028 -
1029 doc->setDefaultTextOption(opt); -
1030 -
1031 QTextFrameFormat fmt = doc->rootFrame()->frameFormat(); -
1032 fmt.setMargin(0); -
1033 doc->rootFrame()->setFrameFormat(fmt); -
1034 doc->setTextWidth(documentRect().width()); -
1035 }
executed: }
Execution Count:39
39
1036 textLayoutDirty = false; -
1037}
executed: }
Execution Count:39
39
1038 -
1039void QLabelPrivate::ensureTextControl() const -
1040{ -
1041 const QLabel * const q = q_func(); -
1042 if (!isTextLabel)
partially evaluated: !isTextLabel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
1043 return;
never executed: return;
0
1044 if (!control) {
evaluated: !control
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:7
7-23
1045 control = new QWidgetTextControl(const_cast<QLabel *>(q)); -
1046 control->document()->setUndoRedoEnabled(false); -
1047 control->document()->setDefaultFont(q->font()); -
1048 control->setTextInteractionFlags(textInteractionFlags); -
1049 control->setOpenExternalLinks(openExternalLinks); -
1050 control->setPalette(q->palette()); -
1051 control->setFocus(q->hasFocus()); -
1052 QObject::connect(control, "2""updateRequest(QRectF)", -
1053 q, "1""update()"); -
1054 QObject::connect(control, "2""linkHovered(QString)", -
1055 q, "1""_q_linkHovered(QString)"); -
1056 QObject::connect(control, "2""linkActivated(QString)", -
1057 q, "2""linkActivated(QString)"); -
1058 textLayoutDirty = true; -
1059 textDirty = true; -
1060 }
executed: }
Execution Count:23
23
1061}
executed: }
Execution Count:30
30
1062 -
1063void QLabelPrivate::sendControlEvent(QEvent *e) -
1064{ -
1065 QLabel * const q = q_func(); -
1066 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
1067 e->ignore(); -
1068 return;
executed: return;
Execution Count:4
4
1069 } -
1070 control->processEvent(e, -layoutRect().topLeft(), q); -
1071}
executed: }
Execution Count:13
13
1072 -
1073void QLabelPrivate::_q_linkHovered(const QString &anchor) -
1074{ -
1075 QLabel * const q = q_func(); -
1076 -
1077 if (anchor.isEmpty()) {
never evaluated: anchor.isEmpty()
0
1078 if (validCursor)
never evaluated: validCursor
0
1079 q->setCursor(cursor);
never executed: q->setCursor(cursor);
0
1080 else -
1081 q->unsetCursor();
never executed: q->unsetCursor();
0
1082 onAnchor = false; -
1083 } else if (!onAnchor) {
never executed: }
never evaluated: !onAnchor
0
1084 validCursor = q->testAttribute(Qt::WA_SetCursor); -
1085 if (validCursor) {
never evaluated: validCursor
0
1086 cursor = q->cursor(); -
1087 }
never executed: }
0
1088 q->setCursor(Qt::PointingHandCursor); -
1089 onAnchor = true; -
1090 }
never executed: }
0
1091 -
1092 q->linkHovered(anchor); -
1093}
never executed: }
0
1094 -
1095 -
1096 -
1097 -
1098QRectF QLabelPrivate::layoutRect() const -
1099{ -
1100 QRectF cr = documentRect(); -
1101 if (!control)
evaluated: !control
TRUEFALSE
yes
Evaluation Count:455
yes
Evaluation Count:36
36-455
1102 return cr;
executed: return cr;
Execution Count:455
455
1103 ensureTextLayouted(); -
1104 -
1105 qreal rh = control->document()->documentLayout()->documentSize().height(); -
1106 qreal yo = 0; -
1107 if (align & Qt::AlignVCenter)
evaluated: align & Qt::AlignVCenter
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:6
6-30
1108 yo = qMax((cr.height()-rh)/2, qreal(0));
executed: yo = qMax((cr.height()-rh)/2, qreal(0));
Execution Count:30
30
1109 else if (align & Qt::AlignBottom)
partially evaluated: align & Qt::AlignBottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1110 yo = qMax(cr.height()-rh, qreal(0));
never executed: yo = qMax(cr.height()-rh, qreal(0));
0
1111 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
1112} -
1113 -
1114 -
1115QPoint QLabelPrivate::layoutPoint(const QPoint& p) const -
1116{ -
1117 QRect lr = layoutRect().toRect(); -
1118 return p - lr.topLeft();
never executed: return p - lr.topLeft();
0
1119} -
1120 -
1121 -
1122QMenu *QLabelPrivate::createStandardContextMenu(const QPoint &pos) -
1123{ -
1124 QString linkToCopy; -
1125 QPoint p; -
1126 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
1127 p = layoutPoint(pos); -
1128 linkToCopy = control->document()->documentLayout()->anchorAt(p); -
1129 }
never executed: }
0
1130 -
1131 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
1132 return 0;
never executed: return 0;
0
1133 -
1134 return control->createStandardContextMenu(p, q_func());
executed: return control->createStandardContextMenu(p, q_func());
Execution Count:1
1
1135} -
1136 -
1137 -
1138 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial