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-
501-
502void QLabel::contextMenuEvent(QContextMenuEvent *ev)-
503{-
504 QLabelPrivate * const d = d_func();-
505 if (!d->isTextLabel
!d->isTextLabelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
506 ev->ignore();-
507 return;
never executed: return;
0
508 }-
509 QMenu *menu = d->createStandardContextMenu(ev->pos());-
510 if (!menu
!menuDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
511 ev->ignore();-
512 return;
never executed: return;
0
513 }-
514 ev->accept();-
515 menu->setAttribute(Qt::WA_DeleteOnClose);-
516 menu->popup(ev->globalPos());-
517}
never executed: end of block
0
518-
519-
520-
521-
522-
523void QLabel::focusInEvent(QFocusEvent *ev)-
524{-
525 QLabelPrivate * const d = d_func();-
526 if (d->isTextLabel
d->isTextLabelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
527 d->ensureTextControl();-
528 d->sendControlEvent(ev);-
529 }
never executed: end of block
0
530 QFrame::focusInEvent(ev);-
531}
never executed: end of block
0
532-
533-
534-
535-
536void QLabel::focusOutEvent(QFocusEvent *ev)-
537{-
538 QLabelPrivate * const d = d_func();-
539 if (d->control
d->controlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
540 d->sendControlEvent(ev);-
541 QTextCursor cursor = d->control->textCursor();-
542 Qt::FocusReason reason = ev->reason();-
543 if (reason != Qt::ActiveWindowFocusReason
reason != Qt::...dowFocusReasonDescription
TRUEnever evaluated
FALSEnever evaluated
0
544 && reason != Qt::PopupFocusReason
reason != Qt::PopupFocusReasonDescription
TRUEnever evaluated
FALSEnever evaluated
0
545 && cursor.hasSelection()
cursor.hasSelection()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
546 cursor.clearSelection();-
547 d->control->setTextCursor(cursor);-
548 }
never executed: end of block
0
549 }
never executed: end of block
0
550-
551 QFrame::focusOutEvent(ev);-
552}
never executed: end of block
0
553-
554-
555-
556bool QLabel::focusNextPrevChild(bool next)-
557{-
558 QLabelPrivate * const d = d_func();-
559 if (d->control
d->controlDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->control->setFocusToNextOrPreviousAnchor(next)
d->control->se...usAnchor(next)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
560 return
never executed: return true;
true;
never executed: return true;
0
561 return
never executed: return QFrame::focusNextPrevChild(next);
QFrame::focusNextPrevChild(next);
never executed: return QFrame::focusNextPrevChild(next);
0
562}-
563-
564-
565-
566void QLabel::keyPressEvent(QKeyEvent *ev)-
567{-
568 QLabelPrivate * const d = d_func();-
569 d->sendControlEvent(ev);-
570}
never executed: end of block
0
571-
572-
573-
574bool QLabel::event(QEvent *e)-
575{-
576 QLabelPrivate * const d = d_func();-
577 QEvent::Type type = e->type();-
578-
579-
580 if (type == QEvent::Shortcut
type == QEvent::ShortcutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
581 QShortcutEvent *se = static_cast<QShortcutEvent *>(e);-
582 if (se->shortcutId() == d->shortcutId
se->shortcutId... d->shortcutIdDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
583 QWidget * w = d->buddy;-
584 QAbstractButton *button = qobject_cast<QAbstractButton *>(w);-
585 if (w->focusPolicy() != Qt::NoFocus
w->focusPolicy...!= Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
586 w->setFocus(Qt::ShortcutFocusReason);
never executed: w->setFocus(Qt::ShortcutFocusReason);
0
587 if (button
buttonDescription
TRUEnever evaluated
FALSEnever evaluated
&& !se->isAmbiguous()
!se->isAmbiguous()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
588 button->animateClick();
never executed: button->animateClick();
0
589 else-
590 window()->setAttribute(Qt::WA_KeyboardFocusChange);
never executed: window()->setAttribute(Qt::WA_KeyboardFocusChange);
0
591 return
never executed: return true;
true;
never executed: return true;
0
592 }-
593 }
never executed: end of block
else
0
594-
595 if (type == QEvent::Resize
type == QEvent::ResizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
596 if (d->control
d->controlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
597 d->textLayoutDirty = true;
never executed: d->textLayoutDirty = true;
0
598 }
never executed: end of block
else if (e->type() == QEvent::StyleChange
e->type() == Q...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
599-
600-
601-
602 ) {-
603 d->setLayoutItemMargins(QStyle::SE_LabelLayoutItem);-
604 d->updateLabel();-
605 }
never executed: end of block
0
606-
607 return
never executed: return QFrame::event(e);
QFrame::event(e);
never executed: return QFrame::event(e);
0
608}-
609-
610-
611-
612void QLabel::paintEvent(QPaintEvent *)-
613{-
614 QLabelPrivate * const d = d_func();-
615 QStyle *style = QWidget::style();-
616 QPainter painter(this);-
617 drawFrame(&painter);-
618 QRect cr = contentsRect();-
619 cr.adjust(d->margin, d->margin, -d->margin, -d->margin);-
620 int align = QStyle::visualAlignment(d->isTextLabel ? d->textDirection()-
621 : layoutDirection(), QFlag(d->align));-
622-
623-
624 if (d->movie
d->movieDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
625 if (d->scaledcontents
d->scaledcontentsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
626 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
627 else-
628 style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap());
never executed: style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap());
0
629 }-
630 else-
631-
632 if (d->isTextLabel
d->isTextLabelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
633 QRectF lr = d->layoutRect().toAlignedRect();-
634 QStyleOption opt;-
635 opt.initFrom(this);-
636-
637 if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style)
QStyleSheetSty...Style*>(style)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
638 cssStyle->styleSheetPalette(this, &opt, &opt.palette);-
639 }
never executed: end of block
0
640-
641 if (d->control
d->controlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
642-
643 const bool underline = (bool)style->styleHint(QStyle::SH_UnderlineShortcut, 0, this, 0);-
644 if (d->shortcutId != 0
d->shortcutId != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
645 && underline != d->shortcutCursor.charFormat().fontUnderline()
underline != d...ontUnderline()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
646 QTextCharFormat fmt;-
647 fmt.setFontUnderline(underline);-
648 d->shortcutCursor.mergeCharFormat(fmt);-
649 }
never executed: end of block
0
650-
651 d->ensureTextLayouted();-
652-
653 QAbstractTextDocumentLayout::PaintContext context;-
654-
655 context.palette = opt.palette;-
656-
657 if (foregroundRole() != QPalette::Text
foregroundRole...QPalette::TextDescription
TRUEnever evaluated
FALSEnever evaluated
&& isEnabled()
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
658 context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));
never executed: context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));
0
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 }
never executed: end of block
else {
0
667 int flags = align | (d->textDirection() == Qt::LeftToRight ? Qt::TextForceLeftToRight-
668 : Qt::TextForceRightToLeft);-
669 if (d->hasShortcut
d->hasShortcutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
670 flags |= Qt::TextShowMnemonic;-
671 if (!style->styleHint(QStyle::SH_UnderlineShortcut, &opt, this)
!style->styleH...t, &opt, this)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
672 flags |= Qt::TextHideMnemonic;
never executed: flags |= Qt::TextHideMnemonic;
0
673 }
never executed: end of block
0
674 style->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), d->text, foregroundRole());-
675 }
never executed: end of block
0
676 } else-
677-
678 if (d->picture
d->pictureDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
679 QRect br = d->picture->boundingRect();-
680 int rw = br.width();-
681 int rh = br.height();-
682 if (d->scaledcontents
d->scaledcontentsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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 }
never executed: end of block
else {
0
689 int xo = 0;-
690 int yo = 0;-
691 if (align & Qt::AlignVCenter
align & Qt::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
692 yo = (cr.height()-rh)/2;
never executed: yo = (cr.height()-rh)/2;
0
693 else if (align & Qt::AlignBottom
align & Qt::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
694 yo = cr.height()-rh;
never executed: yo = cr.height()-rh;
0
695 if (align & Qt::AlignRight
align & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
696 xo = cr.width()-rw;
never executed: xo = cr.width()-rw;
0
697 else if (align & Qt::AlignHCenter
align & Qt::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
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: end of block
0
701 } else-
702-
703 if (d->pixmap
d->pixmapDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->pixmap->isNull()
!d->pixmap->isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
704 QPixmap pix;-
705 if (d->scaledcontents
d->scaledcontentsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
706 QSize scaledSize = cr.size() * devicePixelRatioF();-
707 if (!d->scaledpixmap
!d->scaledpixmapDescription
TRUEnever evaluated
FALSEnever evaluated
|| d->scaledpixmap->size() != scaledSize
d->scaledpixma... != scaledSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
708 if (!d->cachedimage
!d->cachedimageDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
709 d->cachedimage = new QImage(d->pixmap->toImage());
never executed: d->cachedimage = new QImage(d->pixmap->toImage());
0
710 delete d->scaledpixmap;-
711 QImage scaledImage =-
712 d->cachedimage->scaled(scaledSize,-
713 Qt::IgnoreAspectRatio, Qt::SmoothTransformation);-
714 d->scaledpixmap = new QPixmap(QPixmap::fromImage(scaledImage));-
715 d->scaledpixmap->setDevicePixelRatio(devicePixelRatioF());-
716 }
never executed: end of block
0
717 pix = *d->scaledpixmap;-
718 }
never executed: end of block
else
0
719 pix = *d->pixmap;
never executed: pix = *d->pixmap;
0
720 QStyleOption opt;-
721 opt.initFrom(this);-
722 if (!isEnabled()
!isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
723 pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt);
never executed: pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt);
0
724 style->drawItemPixmap(&painter, cr, align, pix);-
725 }
never executed: end of block
0
726}
never executed: end of block
0
727-
728-
729-
730-
731-
732-
733void QLabelPrivate::updateLabel()-
734{-
735 QLabel * const q = q_func();-
736 valid_hints = false;-
737-
738 if (isTextLabel
isTextLabelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
739 QSizePolicy policy = q->sizePolicy();-
740 const bool wrap = align & Qt::TextWordWrap;-
741 policy.setHeightForWidth(wrap);-
742 if (policy != q->sizePolicy()
policy != q->sizePolicy()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
743 q->setSizePolicy(policy);
never executed: q->setSizePolicy(policy);
0
744 textLayoutDirty = true;-
745 }
never executed: end of block
0
746 q->updateGeometry();-
747 q->update(q->contentsRect());-
748}
never executed: end of block
0
749void QLabel::setBuddy(QWidget *buddy)-
750{-
751 QLabelPrivate * const d = d_func();-
752 d->buddy = buddy;-
753 if (d->isTextLabel
d->isTextLabelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
754 if (d->shortcutId
d->shortcutIdDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
755 releaseShortcut(d->shortcutId);
never executed: releaseShortcut(d->shortcutId);
0
756 d->shortcutId = 0;-
757 d->textDirty = true;-
758 if (buddy
buddyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
759 d->updateShortcut();
never executed: d->updateShortcut();
0
760 d->updateLabel();-
761 }
never executed: end of block
0
762}
never executed: end of block
0
763QWidget * QLabel::buddy() const-
764{-
765 const QLabelPrivate * const d = d_func();-
766 return
never executed: return d->buddy;
d->buddy;
never executed: return d->buddy;
0
767}-
768-
769void QLabelPrivate::updateShortcut()-
770{-
771 QLabel * const q = q_func();-
772 ((!(shortcutId == 0)) ? qt_assert("shortcutId == 0",__FILE__,1202) : qt_noop());-
773-
774-
775-
776-
777 hasShortcut = false;-
778-
779 if (!text.contains(QLatin1Char('&'))
!text.contains...tin1Char('&'))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
780 return;
never executed: return;
0
781 hasShortcut = true;-
782 shortcutId = q->grabShortcut(QKeySequence::mnemonic(text));-
783}
never executed: end of block
0
784-
785-
786-
787-
788void QLabelPrivate::_q_movieUpdated(const QRect& rect)-
789{-
790 QLabel * const q = q_func();-
791 if (movie
movieDescription
TRUEnever evaluated
FALSEnever evaluated
&& movie->isValid()
movie->isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
792 QRect r;-
793 if (scaledcontents
scaledcontentsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
794 QRect cr = q->contentsRect();-
795 QRect pixmapRect(cr.topLeft(), movie->currentPixmap().size());-
796 if (pixmapRect.isEmpty()
pixmapRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
797 return;
never executed: return;
0
798 r.setRect(cr.left(), cr.top(),-
799 (rect.width() * cr.width()) / pixmapRect.width(),-
800 (rect.height() * cr.height()) / pixmapRect.height());-
801 }
never executed: end of block
else {
0
802 r = q->style()->itemPixmapRect(q->contentsRect(), align, movie->currentPixmap());-
803 r.translate(rect.x(), rect.y());-
804 r.setWidth(qMin(r.width(), rect.width()));-
805 r.setHeight(qMin(r.height(), rect.height()));-
806 }
never executed: end of block
0
807 q->update(r);-
808 }
never executed: end of block
0
809}
never executed: end of block
0
810-
811void QLabelPrivate::_q_movieResized(const QSize& size)-
812{-
813 QLabel * const q = q_func();-
814 q->update();-
815 valid_hints = false;-
816 _q_movieUpdated(QRect(QPoint(0,0), size));-
817 q->updateGeometry();-
818}
never executed: end of block
0
819void QLabel::setMovie(QMovie *movie)-
820{-
821 QLabelPrivate * const d = d_func();-
822 d->clearContents();-
823-
824 if (!movie
!movieDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
825 return;
never executed: return;
0
826-
827 d->movie = movie;-
828 connect(movie, qFlagLocation("2""resized(QSize)" "\0" __FILE__ ":" "1268"), this, qFlagLocation("1""_q_movieResized(QSize)" "\0" __FILE__ ":" "1268"));-
829 connect(movie, qFlagLocation("2""updated(QRect)" "\0" __FILE__ ":" "1269"), this, qFlagLocation("1""_q_movieUpdated(QRect)" "\0" __FILE__ ":" "1269"));-
830-
831-
832-
833 if (movie->state() != QMovie::Running
movie->state()...Movie::RunningDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
834 d->updateLabel();
never executed: d->updateLabel();
0
835}
never executed: end of block
0
836void QLabelPrivate::clearContents()-
837{-
838 delete control;-
839 control = 0;-
840 isTextLabel = false;-
841 hasShortcut = false;-
842-
843-
844 delete picture;-
845 picture = 0;-
846-
847 delete scaledpixmap;-
848 scaledpixmap = 0;-
849 delete cachedimage;-
850 cachedimage = 0;-
851 delete pixmap;-
852 pixmap = 0;-
853-
854 text.clear();-
855 QLabel * const q = q_func();-
856-
857 if (shortcutId
shortcutIdDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
858 q->releaseShortcut(shortcutId);
never executed: q->releaseShortcut(shortcutId);
0
859 shortcutId = 0;-
860-
861-
862 if (movie
movieDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
863 QObject::disconnect(movie, qFlagLocation("2""resized(QSize)" "\0" __FILE__ ":" "1312"), q, qFlagLocation("1""_q_movieResized(QSize)" "\0" __FILE__ ":" "1312"));-
864 QObject::disconnect(movie, qFlagLocation("2""updated(QRect)" "\0" __FILE__ ":" "1313"), q, qFlagLocation("1""_q_movieUpdated(QRect)" "\0" __FILE__ ":" "1313"));-
865 }
never executed: end of block
0
866 movie = 0;-
867-
868-
869 if (onAnchor
onAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
870 if (validCursor
validCursorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
871 q->setCursor(cursor);
never executed: q->setCursor(cursor);
0
872 else-
873 q->unsetCursor();
never executed: q->unsetCursor();
0
874 }-
875 validCursor = false;-
876 onAnchor = false;-
877-
878}
never executed: end of block
0
879QMovie *QLabel::movie() const-
880{-
881 const QLabelPrivate * const d = d_func();-
882 return
never executed: return d->movie;
d->movie;
never executed: return d->movie;
0
883}-
884Qt::TextFormat QLabel::textFormat() const-
885{-
886 const QLabelPrivate * const d = d_func();-
887 return
never executed: return d->textformat;
d->textformat;
never executed: return d->textformat;
0
888}-
889-
890void QLabel::setTextFormat(Qt::TextFormat format)-
891{-
892 QLabelPrivate * const d = d_func();-
893 if (format != d->textformat
format != d->textformatDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
894 d->textformat = format;-
895 QString t = d->text;-
896 if (!t.isNull()
!t.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
897 d->text.clear();-
898 setText(t);-
899 }
never executed: end of block
0
900 }
never executed: end of block
0
901}
never executed: end of block
0
902-
903-
904-
905-
906void QLabel::changeEvent(QEvent *ev)-
907{-
908 QLabelPrivate * const d = d_func();-
909 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
910 if (d->isTextLabel
d->isTextLabelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
911 if (d->control
d->controlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
912 d->control->document()->setDefaultFont(font());
never executed: d->control->document()->setDefaultFont(font());
0
913 d->updateLabel();-
914 }
never executed: end of block
0
915 }
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
916 d->control->setPalette(palette());-
917 }
never executed: end of block
else if (ev->type() == QEvent::ContentsRectChange
ev->type() == ...entsRectChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
918 d->updateLabel();-
919 }
never executed: end of block
0
920 QFrame::changeEvent(ev);-
921}
never executed: end of block
0
922bool QLabel::hasScaledContents() const-
923{-
924 const QLabelPrivate * const d = d_func();-
925 return
never executed: return d->scaledcontents;
d->scaledcontents;
never executed: return d->scaledcontents;
0
926}-
927-
928void QLabel::setScaledContents(bool enable)-
929{-
930 QLabelPrivate * const d = d_func();-
931 if ((
(bool)d->scale...ents == enableDescription
TRUEnever evaluated
FALSEnever evaluated
bool)d->scaledcontents == enable
(bool)d->scale...ents == enableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
932 return;
never executed: return;
0
933 d->scaledcontents = enable;-
934 if (!enable
!enableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
935 delete d->scaledpixmap;-
936 d->scaledpixmap = 0;-
937 delete d->cachedimage;-
938 d->cachedimage = 0;-
939 }
never executed: end of block
0
940 update(contentsRect());-
941}
never executed: end of block
0
942-
943Qt::LayoutDirection QLabelPrivate::textDirection() const-
944{-
945 if (control
controlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
946 QTextOption opt = control->document()->defaultTextOption();-
947 return
never executed: return opt.textDirection();
opt.textDirection();
never executed: return opt.textDirection();
0
948 }-
949-
950 return
never executed: return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
never executed: return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
0
951}-
952-
953-
954-
955QRect QLabelPrivate::documentRect() const-
956{-
957 const QLabel * const q = q_func();-
958 ((!(isTextLabel)) ? qt_assert_x("documentRect", "document rect called for label that is not a text label!",__FILE__,1444) : qt_noop());-
959 QRect cr = q->contentsRect();-
960 cr.adjust(margin, margin, -margin, -margin);-
961 const int align = QStyle::visualAlignment(isTextLabel ? textDirection()-
962 : q->layoutDirection(), QFlag(this->align));-
963 int m = indent;-
964 if (m < 0
m < 0Description
TRUEnever evaluated
FALSEnever evaluated
&& q->frameWidth()
q->frameWidth()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
965 m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
never executed: m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
0
966 if (m > 0
m > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
967 if (align & Qt::AlignLeft
align & Qt::AlignLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
968 cr.setLeft(cr.left() + m);
never executed: cr.setLeft(cr.left() + m);
0
969 if (align & Qt::AlignRight
align & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
970 cr.setRight(cr.right() - m);
never executed: cr.setRight(cr.right() - m);
0
971 if (align & Qt::AlignTop
align & Qt::AlignTopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
972 cr.setTop(cr.top() + m);
never executed: cr.setTop(cr.top() + m);
0
973 if (align & Qt::AlignBottom
align & Qt::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
974 cr.setBottom(cr.bottom() - m);
never executed: cr.setBottom(cr.bottom() - m);
0
975 }
never executed: end of block
0
976 return
never executed: return cr;
cr;
never executed: return cr;
0
977}-
978-
979void QLabelPrivate::ensureTextPopulated() const-
980{-
981 if (!textDirty
!textDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
982 return;
never executed: return;
0
983 if (control
controlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
984 QTextDocument *doc = control->document();-
985 if (textDirty
textDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
986-
987 if (isRichText
isRichTextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
988 doc->setHtml(text);
never executed: doc->setHtml(text);
0
989 else-
990 doc->setPlainText(text);
never executed: doc->setPlainText(text);
0
991-
992-
993-
994 doc->setUndoRedoEnabled(false);-
995-
996-
997 if (hasShortcut
hasShortcutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
998-
999 int from = 0;-
1000 bool found = false;-
1001 QTextCursor cursor;-
1002 while (!(cursor = control->document()->find((QLatin1String("&")), from)).isNull()
!(cursor = con...rom)).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1003 cursor.deleteChar();-
1004 cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);-
1005 from = cursor.position();-
1006 if (!found
!foundDescription
TRUEnever evaluated
FALSEnever evaluated
&& cursor.selectedText() != QLatin1String("&")
cursor.selecte...in1String("&")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1007 found = true;-
1008 shortcutCursor = cursor;-
1009 }
never executed: end of block
0
1010 }
never executed: end of block
0
1011 }
never executed: end of block
0
1012-
1013 }
never executed: end of block
0
1014 }
never executed: end of block
0
1015 textDirty = false;-
1016}
never executed: end of block
0
1017-
1018void QLabelPrivate::ensureTextLayouted() const-
1019{-
1020 if (!textLayoutDirty
!textLayoutDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1021 return;
never executed: return;
0
1022 ensureTextPopulated();-
1023 if (control
controlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1024 QTextDocument *doc = control->document();-
1025 QTextOption opt = doc->defaultTextOption();-
1026-
1027 opt.setAlignment(QFlag(this->align));-
1028-
1029 if (this->align & Qt::TextWordWrap
this->align & Qt::TextWordWrapDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1030 opt.setWrapMode(QTextOption::WordWrap);
never executed: opt.setWrapMode(QTextOption::WordWrap);
0
1031 else-
1032 opt.setWrapMode(QTextOption::ManualWrap);
never executed: opt.setWrapMode(QTextOption::ManualWrap);
0
1033-
1034 doc->setDefaultTextOption(opt);-
1035-
1036 QTextFrameFormat fmt = doc->rootFrame()->frameFormat();-
1037 fmt.setMargin(0);-
1038 doc->rootFrame()->setFrameFormat(fmt);-
1039 doc->setTextWidth(documentRect().width());-
1040 }
never executed: end of block
0
1041 textLayoutDirty = false;-
1042}
never executed: end of block
0
1043-
1044void QLabelPrivate::ensureTextControl() const-
1045{-
1046 const QLabel * const q = q_func();-
1047 if (!isTextLabel
!isTextLabelDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1048 return;
never executed: return;
0
1049 if (!control
!controlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1050 control = new QWidgetTextControl(const_cast<QLabel *>(q));-
1051 control->document()->setUndoRedoEnabled(false);-
1052 control->document()->setDefaultFont(q->font());-
1053 control->setTextInteractionFlags(textInteractionFlags);-
1054 control->setOpenExternalLinks(openExternalLinks);-
1055 control->setPalette(q->palette());-
1056 control->setFocus(q->hasFocus());-
1057 QObject::connect(control, qFlagLocation("2""updateRequest(QRectF)" "\0" __FILE__ ":" "1543"),-
1058 q, qFlagLocation("1""update()" "\0" __FILE__ ":" "1544"));-
1059 QObject::connect(control, qFlagLocation("2""linkHovered(QString)" "\0" __FILE__ ":" "1545"),-
1060 q, qFlagLocation("1""_q_linkHovered(QString)" "\0" __FILE__ ":" "1546"));-
1061 QObject::connect(control, qFlagLocation("2""linkActivated(QString)" "\0" __FILE__ ":" "1547"),-
1062 q, qFlagLocation("2""linkActivated(QString)" "\0" __FILE__ ":" "1548"));-
1063 textLayoutDirty = true;-
1064 textDirty = true;-
1065 }
never executed: end of block
0
1066}
never executed: end of block
0
1067-
1068void QLabelPrivate::sendControlEvent(QEvent *e)-
1069{-
1070 QLabel * const q = q_func();-
1071 if (!isTextLabel
!isTextLabelDescription
TRUEnever evaluated
FALSEnever evaluated
|| !control
!controlDescription
TRUEnever evaluated
FALSEnever evaluated
|| textInteractionFlags == Qt::NoTextInteraction
textInteractio...extInteractionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1072 e->ignore();-
1073 return;
never executed: return;
0
1074 }-
1075 control->processEvent(e, -layoutRect().topLeft(), q);-
1076}
never executed: end of block
0
1077-
1078void QLabelPrivate::_q_linkHovered(const QString &anchor)-
1079{-
1080 QLabel * const q = q_func();-
1081-
1082 if (anchor.isEmpty()
anchor.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1083 if (validCursor
validCursorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1084 q->setCursor(cursor);
never executed: q->setCursor(cursor);
0
1085 else-
1086 q->unsetCursor();
never executed: q->unsetCursor();
0
1087 onAnchor = false;-
1088 }
never executed: end of block
else if (!onAnchor
!onAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1089 validCursor = q->testAttribute(Qt::WA_SetCursor);-
1090 if (validCursor
validCursorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1091 cursor = q->cursor();-
1092 }
never executed: end of block
0
1093 q->setCursor(Qt::PointingHandCursor);-
1094 onAnchor = true;-
1095 }
never executed: end of block
0
1096-
1097 q->linkHovered(anchor);-
1098}
never executed: end of block
0
1099-
1100-
1101-
1102-
1103QRectF QLabelPrivate::layoutRect() const-
1104{-
1105 QRectF cr = documentRect();-
1106 if (!control
!controlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1107 return
never executed: return cr;
cr;
never executed: return cr;
0
1108 ensureTextLayouted();-
1109-
1110 qreal rh = control->document()->documentLayout()->documentSize().height();-
1111 qreal yo = 0;-
1112 if (align & Qt::AlignVCenter
align & Qt::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1113 yo = qMax((cr.height()-rh)/2, qreal(0));
never executed: yo = qMax((cr.height()-rh)/2, qreal(0));
0
1114 else if (align & Qt::AlignBottom
align & Qt::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1115 yo = qMax(cr.height()-rh, qreal(0));
never executed: yo = qMax(cr.height()-rh, qreal(0));
0
1116 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
1117}-
1118-
1119-
1120QPoint QLabelPrivate::layoutPoint(const QPoint& p) const-
1121{-
1122 QRect lr = layoutRect().toRect();-
1123 return
never executed: return p - lr.topLeft();
p - lr.topLeft();
never executed: return p - lr.topLeft();
0
1124}-
1125-
1126-
1127QMenu *QLabelPrivate::createStandardContextMenu(const QPoint &pos)-
1128{-
1129 QString linkToCopy;-
1130 QPoint p;-
1131 if (control
controlDescription
TRUEnever evaluated
FALSEnever evaluated
&& isRichText
isRichTextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1132 p = layoutPoint(pos);-
1133 linkToCopy = control->document()->documentLayout()->anchorAt(p);-
1134 }
never executed: end of block
0
1135-
1136 if (linkToCopy.isEmpty()
linkToCopy.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& !control
!controlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1137 return
never executed: return 0;
0;
never executed: return 0;
0
1138-
1139 return
never executed: return control->createStandardContextMenu(p, q_func());
control->createStandardContextMenu(p, q_func());
never executed: return control->createStandardContextMenu(p, q_func());
0
1140}-
1141-
1142-
Switch to Source codePreprocessed file

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