qlabel.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9