qprogressbar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qprogressbar.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qprogressbar.h"-
41#ifndef QT_NO_PROGRESSBAR-
42#include <qlocale.h>-
43#include <qevent.h>-
44#include <qpainter.h>-
45#include <qstylepainter.h>-
46#include <qstyleoption.h>-
47#include <private/qwidget_p.h>-
48#ifndef QT_NO_ACCESSIBILITY-
49#include <qaccessible.h>-
50#endif-
51#include <limits.h>-
52-
53QT_BEGIN_NAMESPACE-
54-
55class QProgressBarPrivate : public QWidgetPrivate-
56{-
57 Q_DECLARE_PUBLIC(QProgressBar)-
58-
59public:-
60 QProgressBarPrivate();-
61-
62 void init();-
63 void initDefaultFormat();-
64 inline void resetLayoutItemMargins();-
65-
66 int minimum;-
67 int maximum;-
68 int value;-
69 Qt::Alignment alignment;-
70 uint textVisible : 1;-
71 uint defaultFormat: 1;-
72 int lastPaintedValue;-
73 Qt::Orientation orientation;-
74 bool invertedAppearance;-
75 QProgressBar::Direction textDirection;-
76 QString format;-
77 inline int bound(int val) const { return qMax(minimum-1, qMin(maximum, val)); }
never executed: return qMax(minimum-1, qMin(maximum, val));
0
78 bool repaintRequired() const;-
79};-
80-
81QProgressBarPrivate::QProgressBarPrivate()-
82 : minimum(0), maximum(100), value(-1), alignment(Qt::AlignLeft), textVisible(true),-
83 defaultFormat(true), lastPaintedValue(-1), orientation(Qt::Horizontal), invertedAppearance(false),-
84 textDirection(QProgressBar::TopToBottom)-
85{-
86 initDefaultFormat();-
87}
never executed: end of block
0
88-
89void QProgressBarPrivate::initDefaultFormat()-
90{-
91 if (defaultFormat)
defaultFormatDescription
TRUEnever evaluated
FALSEnever evaluated
0
92 format = QLatin1String("%p") + locale.percent();
never executed: format = QLatin1String("%p") + locale.percent();
0
93}
never executed: end of block
0
94-
95void QProgressBarPrivate::init()-
96{-
97 Q_Q(QProgressBar);-
98 QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed);-
99 if (orientation == Qt::Vertical)
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
100 sp.transpose();
never executed: sp.transpose();
0
101 q->setSizePolicy(sp);-
102 q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);-
103 resetLayoutItemMargins();-
104}
never executed: end of block
0
105-
106void QProgressBarPrivate::resetLayoutItemMargins()-
107{-
108 Q_Q(QProgressBar);-
109 QStyleOptionProgressBar option;-
110 q->initStyleOption(&option);-
111 setLayoutItemMargins(QStyle::SE_ProgressBarLayoutItem, &option);-
112}
never executed: end of block
0
113-
114/*!-
115 Initialize \a option with the values from this QProgressBar. This method is useful-
116 for subclasses when they need a QStyleOptionProgressBar,-
117 but don't want to fill in all the information themselves.-
118-
119 \sa QStyleOption::initFrom()-
120*/-
121void QProgressBar::initStyleOption(QStyleOptionProgressBar *option) const-
122{-
123 if (!option)
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
0
124 return;
never executed: return;
0
125 Q_D(const QProgressBar);-
126 option->initFrom(this);-
127-
128 if (d->orientation == Qt::Horizontal)
d->orientation...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
129 option->state |= QStyle::State_Horizontal;
never executed: option->state |= QStyle::State_Horizontal;
0
130 option->minimum = d->minimum;-
131 option->maximum = d->maximum;-
132 option->progress = d->value;-
133 option->textAlignment = d->alignment;-
134 option->textVisible = d->textVisible;-
135 option->text = text();-
136 option->orientation = d->orientation; // ### Qt 6: remove this member from QStyleOptionProgressBar-
137 option->invertedAppearance = d->invertedAppearance;-
138 option->bottomToTop = d->textDirection == QProgressBar::BottomToTop;-
139}
never executed: end of block
0
140-
141bool QProgressBarPrivate::repaintRequired() const-
142{-
143 Q_Q(const QProgressBar);-
144 if (value == lastPaintedValue)
value == lastPaintedValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
145 return false;
never executed: return false;
0
146-
147 int valueDifference = qAbs(value - lastPaintedValue);-
148-
149 // Check if the text needs to be repainted-
150 if (value == minimum || value == maximum)
value == minimumDescription
TRUEnever evaluated
FALSEnever evaluated
value == maximumDescription
TRUEnever evaluated
FALSEnever evaluated
0
151 return true;
never executed: return true;
0
152 if (textVisible) {
textVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
153 if ((format.contains(QLatin1String("%v"))))
(format.contai...String("%v")))Description
TRUEnever evaluated
FALSEnever evaluated
0
154 return true;
never executed: return true;
0
155 if ((format.contains(QLatin1String("%p"))
format.contain...1String("%p"))Description
TRUEnever evaluated
FALSEnever evaluated
0
156 && valueDifference >= qAbs((maximum - minimum) / 100)))
valueDifferenc...inimum) / 100)Description
TRUEnever evaluated
FALSEnever evaluated
0
157 return true;
never executed: return true;
0
158 }
never executed: end of block
0
159-
160 // Check if the bar needs to be repainted-
161 QStyleOptionProgressBar opt;-
162 q->initStyleOption(&opt);-
163 int cw = q->style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, q);-
164 QRect groove = q->style()->subElementRect(QStyle::SE_ProgressBarGroove, &opt, q);-
165 // This expression is basically-
166 // (valueDifference / (maximum - minimum) > cw / groove.width())-
167 // transformed to avoid integer division.-
168 int grooveBlock = (q->orientation() == Qt::Horizontal) ? groove.width() : groove.height();
(q->orientatio...t::Horizontal)Description
TRUEnever evaluated
FALSEnever evaluated
0
169 return (valueDifference * grooveBlock > cw * (maximum - minimum));
never executed: return (valueDifference * grooveBlock > cw * (maximum - minimum));
0
170}-
171-
172/*!-
173 \class QProgressBar-
174 \brief The QProgressBar widget provides a horizontal or vertical progress bar.-
175-
176 \ingroup basicwidgets-
177 \inmodule QtWidgets-
178-
179 A progress bar is used to give the user an indication of the-
180 progress of an operation and to reassure them that the application-
181 is still running.-
182-
183 The progress bar uses the concept of \e steps. You set it up by-
184 specifying the minimum and maximum possible step values, and it-
185 will display the percentage of steps that have been completed-
186 when you later give it the current step value. The percentage is-
187 calculated by dividing the progress (value() - minimum()) divided-
188 by maximum() - minimum().-
189-
190 You can specify the minimum and maximum number of steps with-
191 setMinimum() and setMaximum. The current number of steps is set-
192 with setValue(). The progress bar can be rewound to the-
193 beginning with reset().-
194-
195 If minimum and maximum both are set to 0, the bar shows a busy-
196 indicator instead of a percentage of steps. This is useful, for-
197 example, when using QNetworkAccessManager to download items when-
198 they are unable to determine the size of the item being downloaded.-
199-
200 \table-
201 \row \li \inlineimage macintosh-progressbar.png Screenshot of a Macintosh style progress bar-
202 \li A progress bar shown in the Macintosh widget style.-
203 \row \li \inlineimage windowsvista-progressbar.png Screenshot of a Windows Vista style progress bar-
204 \li A progress bar shown in the Windows Vista widget style.-
205 \row \li \inlineimage fusion-progressbar.png Screenshot of a Fusion style progress bar-
206 \li A progress bar shown in the Fusion widget style.-
207 \endtable-
208-
209 \sa QProgressDialog, {fowler}{GUI Design Handbook: Progress Indicator}-
210*/-
211-
212/*!-
213 \since 4.1-
214 \enum QProgressBar::Direction-
215 \brief Specifies the reading direction of the \l text for vertical progress bars.-
216-
217 \value TopToBottom The text is rotated 90 degrees clockwise.-
218 \value BottomToTop The text is rotated 90 degrees counter-clockwise.-
219-
220 Note that whether or not the text is drawn is dependent on the style.-
221 Currently CleanLooks and Plastique draw the text. Mac, Windows-
222 and WindowsXP style do not.-
223-
224 \sa textDirection-
225*/-
226-
227/*!-
228 \fn void QProgressBar::valueChanged(int value)-
229-
230 This signal is emitted when the value shown in the progress bar changes.-
231 \a value is the new value shown by the progress bar.-
232*/-
233-
234/*!-
235 Constructs a progress bar with the given \a parent.-
236-
237 By default, the minimum step value is set to 0, and the maximum to 100.-
238-
239 \sa setRange()-
240*/-
241-
242QProgressBar::QProgressBar(QWidget *parent)-
243 : QWidget(*(new QProgressBarPrivate), parent, 0)-
244{-
245 d_func()->init();-
246}
never executed: end of block
0
247-
248/*!-
249 Destructor.-
250*/-
251QProgressBar::~QProgressBar()-
252{-
253}-
254-
255/*!-
256 Reset the progress bar. The progress bar "rewinds" and shows no-
257 progress.-
258*/-
259-
260void QProgressBar::reset()-
261{-
262 Q_D(QProgressBar);-
263 d->value = d->minimum - 1;-
264 if (d->minimum == INT_MIN)
d->minimum == ...147483647 - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
265 d->value = INT_MIN;
never executed: d->value = (-2147483647 - 1);
0
266 repaint();-
267}
never executed: end of block
0
268-
269/*!-
270 \property QProgressBar::minimum-
271 \brief the progress bar's minimum value-
272-
273 When setting this property, the \l maximum is adjusted if-
274 necessary to ensure that the range remains valid. If the-
275 current value falls outside the new range, the progress bar is reset-
276 with reset().-
277*/-
278void QProgressBar::setMinimum(int minimum)-
279{-
280 setRange(minimum, qMax(d_func()->maximum, minimum));-
281}
never executed: end of block
0
282-
283int QProgressBar::minimum() const-
284{-
285 return d_func()->minimum;
never executed: return d_func()->minimum;
0
286}-
287-
288-
289/*!-
290 \property QProgressBar::maximum-
291 \brief the progress bar's maximum value-
292-
293 When setting this property, the \l minimum is adjusted if-
294 necessary to ensure that the range remains valid. If the-
295 current value falls outside the new range, the progress bar is reset-
296 with reset().-
297*/-
298-
299void QProgressBar::setMaximum(int maximum)-
300{-
301 setRange(qMin(d_func()->minimum, maximum), maximum);-
302}
never executed: end of block
0
303-
304int QProgressBar::maximum() const-
305{-
306 return d_func()->maximum;
never executed: return d_func()->maximum;
0
307}-
308-
309/*!-
310 \property QProgressBar::value-
311 \brief the progress bar's current value-
312-
313 Attempting to change the current value to one outside-
314 the minimum-maximum range has no effect on the current value.-
315*/-
316void QProgressBar::setValue(int value)-
317{-
318 Q_D(QProgressBar);-
319 if (d->value == value
d->value == valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
320 || ((value > d->maximum || value < d->minimum)
value > d->maximumDescription
TRUEnever evaluated
FALSEnever evaluated
value < d->minimumDescription
TRUEnever evaluated
FALSEnever evaluated
0
321 && (d->maximum != 0 || d->minimum != 0)))
d->maximum != 0Description
TRUEnever evaluated
FALSEnever evaluated
d->minimum != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
322 return;
never executed: return;
0
323 d->value = value;-
324 emit valueChanged(value);-
325#ifndef QT_NO_ACCESSIBILITY-
326 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
327 QAccessibleValueChangeEvent event(this, value);-
328 QAccessible::updateAccessibility(&event);-
329 }
never executed: end of block
0
330#endif-
331 if (d->repaintRequired())
d->repaintRequired()Description
TRUEnever evaluated
FALSEnever evaluated
0
332 repaint();
never executed: repaint();
0
333}
never executed: end of block
0
334-
335int QProgressBar::value() const-
336{-
337 return d_func()->value;
never executed: return d_func()->value;
0
338}-
339-
340/*!-
341 Sets the progress bar's minimum and maximum values to \a minimum and-
342 \a maximum respectively.-
343-
344 If \a maximum is smaller than \a minimum, \a minimum becomes the only-
345 legal value.-
346-
347 If the current value falls outside the new range, the progress bar is reset-
348 with reset().-
349-
350 The QProgressBar can be set to undetermined state by using setRange(0, 0).-
351-
352 \sa minimum, maximum-
353*/-
354void QProgressBar::setRange(int minimum, int maximum)-
355{-
356 Q_D(QProgressBar);-
357 if (minimum != d->minimum || maximum != d->maximum) {
minimum != d->minimumDescription
TRUEnever evaluated
FALSEnever evaluated
maximum != d->maximumDescription
TRUEnever evaluated
FALSEnever evaluated
0
358 d->minimum = minimum;-
359 d->maximum = qMax(minimum, maximum);-
360-
361 if (d->value < (d->minimum - 1) || d->value > d->maximum)
d->value < (d->minimum - 1)Description
TRUEnever evaluated
FALSEnever evaluated
d->value > d->maximumDescription
TRUEnever evaluated
FALSEnever evaluated
0
362 reset();
never executed: reset();
0
363 else-
364 update();
never executed: update();
0
365 }-
366}
never executed: end of block
0
367-
368/*!-
369 \property QProgressBar::textVisible-
370 \brief whether the current completed percentage should be displayed-
371-
372 This property may be ignored by the style (e.g., QMacStyle never draws the text).-
373-
374 \sa textDirection-
375*/-
376void QProgressBar::setTextVisible(bool visible)-
377{-
378 Q_D(QProgressBar);-
379 if (d->textVisible != visible) {
d->textVisible != visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
380 d->textVisible = visible;-
381 repaint();-
382 }
never executed: end of block
0
383}
never executed: end of block
0
384-
385bool QProgressBar::isTextVisible() const-
386{-
387 return d_func()->textVisible;
never executed: return d_func()->textVisible;
0
388}-
389-
390/*!-
391 \property QProgressBar::alignment-
392 \brief the alignment of the progress bar-
393*/-
394void QProgressBar::setAlignment(Qt::Alignment alignment)-
395{-
396 if (d_func()->alignment != alignment) {
d_func()->alig...t != alignmentDescription
TRUEnever evaluated
FALSEnever evaluated
0
397 d_func()->alignment = alignment;-
398 repaint();-
399 }
never executed: end of block
0
400}
never executed: end of block
0
401-
402Qt::Alignment QProgressBar::alignment() const-
403{-
404 return d_func()->alignment;
never executed: return d_func()->alignment;
0
405}-
406-
407/*!-
408 \reimp-
409*/-
410void QProgressBar::paintEvent(QPaintEvent *)-
411{-
412 QStylePainter paint(this);-
413 QStyleOptionProgressBar opt;-
414 initStyleOption(&opt);-
415 paint.drawControl(QStyle::CE_ProgressBar, opt);-
416 d_func()->lastPaintedValue = d_func()->value;-
417}
never executed: end of block
0
418-
419/*!-
420 \reimp-
421*/-
422QSize QProgressBar::sizeHint() const-
423{-
424 ensurePolished();-
425 QFontMetrics fm = fontMetrics();-
426 QStyleOptionProgressBar opt;-
427 initStyleOption(&opt);-
428 int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this);-
429 QSize size = QSize(qMax(9, cw) * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8);-
430 if (opt.orientation == Qt::Vertical)
opt.orientatio...= Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
431 size = size.transposed();
never executed: size = size.transposed();
0
432 return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this);
never executed: return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this);
0
433}-
434-
435/*!-
436 \reimp-
437*/-
438QSize QProgressBar::minimumSizeHint() const-
439{-
440 QSize size;-
441 if (orientation() == Qt::Horizontal)
orientation() ...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
442 size = QSize(sizeHint().width(), fontMetrics().height() + 2);
never executed: size = QSize(sizeHint().width(), fontMetrics().height() + 2);
0
443 else-
444 size = QSize(fontMetrics().height() + 2, sizeHint().height());
never executed: size = QSize(fontMetrics().height() + 2, sizeHint().height());
0
445 return size;
never executed: return size;
0
446}-
447-
448/*!-
449 \property QProgressBar::text-
450 \brief the descriptive text shown with the progress bar-
451-
452 The text returned is the same as the text displayed in the center-
453 (or in some styles, to the left) of the progress bar.-
454-
455 The progress shown in the text may be smaller than the minimum value,-
456 indicating that the progress bar is in the "reset" state before any-
457 progress is set.-
458-
459 In the default implementation, the text either contains a percentage-
460 value that indicates the progress so far, or it is blank because the-
461 progress bar is in the reset state.-
462*/-
463QString QProgressBar::text() const-
464{-
465 Q_D(const QProgressBar);-
466 if ((d->maximum == 0 && d->minimum == 0) || d->value < d->minimum
d->maximum == 0Description
TRUEnever evaluated
FALSEnever evaluated
d->minimum == 0Description
TRUEnever evaluated
FALSEnever evaluated
d->value < d->minimumDescription
TRUEnever evaluated
FALSEnever evaluated
0
467 || (d->value == INT_MIN && d->minimum == INT_MIN))
d->value == (-2147483647 - 1)Description
TRUEnever evaluated
FALSEnever evaluated
d->minimum == ...147483647 - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
468 return QString();
never executed: return QString();
0
469-
470 qint64 totalSteps = qint64(d->maximum) - d->minimum;-
471-
472 QString result = d->format;-
473 QLocale locale = d->locale; // Omit group separators for compatibility with previous versions that were non-localized.-
474 locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator);-
475 result.replace(QLatin1String("%m"), locale.toString(totalSteps));-
476 result.replace(QLatin1String("%v"), locale.toString(d->value));-
477-
478 // If max and min are equal and we get this far, it means that the-
479 // progress bar has one step and that we are on that step. Return-
480 // 100% here in order to avoid division by zero further down.-
481 if (totalSteps == 0) {
totalSteps == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
482 result.replace(QLatin1String("%p"), locale.toString(int(100)));-
483 return result;
never executed: return result;
0
484 }-
485-
486 int progress = (qreal(d->value) - d->minimum) * 100.0 / totalSteps;-
487 result.replace(QLatin1String("%p"), locale.toString(progress));-
488 return result;
never executed: return result;
0
489}-
490-
491/*!-
492 \since 4.1-
493 \property QProgressBar::orientation-
494 \brief the orientation of the progress bar-
495-
496 The orientation must be \l Qt::Horizontal (the default) or \l-
497 Qt::Vertical.-
498-
499 \sa invertedAppearance, textDirection-
500*/-
501-
502void QProgressBar::setOrientation(Qt::Orientation orientation)-
503{-
504 Q_D(QProgressBar);-
505 if (d->orientation == orientation)
d->orientation == orientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
506 return;
never executed: return;
0
507 d->orientation = orientation;-
508 if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
!testAttribute...OwnSizePolicy)Description
TRUEnever evaluated
FALSEnever evaluated
0
509 QSizePolicy sp = sizePolicy();-
510 sp.transpose();-
511 setSizePolicy(sp);-
512 setAttribute(Qt::WA_WState_OwnSizePolicy, false);-
513 }
never executed: end of block
0
514 d->resetLayoutItemMargins();-
515 update();-
516 updateGeometry();-
517}
never executed: end of block
0
518-
519Qt::Orientation QProgressBar::orientation() const-
520{-
521 Q_D(const QProgressBar);-
522 return d->orientation;
never executed: return d->orientation;
0
523}-
524-
525/*!-
526 \since 4.1-
527 \property QProgressBar::invertedAppearance-
528 \brief whether or not a progress bar shows its progress inverted-
529-
530 If this property is \c true, the progress bar grows in the other-
531 direction (e.g. from right to left). By default, the progress bar-
532 is not inverted.-
533-
534 \sa orientation, layoutDirection-
535*/-
536-
537void QProgressBar::setInvertedAppearance(bool invert)-
538{-
539 Q_D(QProgressBar);-
540 d->invertedAppearance = invert;-
541 update();-
542}
never executed: end of block
0
543-
544bool QProgressBar::invertedAppearance() const-
545{-
546 Q_D(const QProgressBar);-
547 return d->invertedAppearance;
never executed: return d->invertedAppearance;
0
548}-
549-
550/*!-
551 \since 4.1-
552 \property QProgressBar::textDirection-
553 \brief the reading direction of the \l text for vertical progress bars-
554-
555 This property has no impact on horizontal progress bars.-
556 By default, the reading direction is QProgressBar::TopToBottom.-
557-
558 \sa orientation, textVisible-
559*/-
560void QProgressBar::setTextDirection(QProgressBar::Direction textDirection)-
561{-
562 Q_D(QProgressBar);-
563 d->textDirection = textDirection;-
564 update();-
565}
never executed: end of block
0
566-
567QProgressBar::Direction QProgressBar::textDirection() const-
568{-
569 Q_D(const QProgressBar);-
570 return d->textDirection;
never executed: return d->textDirection;
0
571}-
572-
573/*! \reimp */-
574bool QProgressBar::event(QEvent *e)-
575{-
576 Q_D(QProgressBar);-
577 switch (e->type()) {-
578 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
579#ifdef Q_OS_MAC-
580 case QEvent::MacSizeChange:-
581#endif-
582 d->resetLayoutItemMargins();-
583 break;
never executed: break;
0
584 case QEvent::LocaleChange:
never executed: case QEvent::LocaleChange:
0
585 d->initDefaultFormat();-
586 break;
never executed: break;
0
587 default:
never executed: default:
0
588 break;
never executed: break;
0
589 }-
590 return QWidget::event(e);
never executed: return QWidget::event(e);
0
591}-
592-
593/*!-
594 \since 4.2-
595 \property QProgressBar::format-
596 \brief the string used to generate the current text-
597-
598 %p - is replaced by the percentage completed.-
599 %v - is replaced by the current value.-
600 %m - is replaced by the total number of steps.-
601-
602 The default value is "%p%".-
603-
604 \sa text()-
605*/-
606void QProgressBar::setFormat(const QString &format)-
607{-
608 Q_D(QProgressBar);-
609 if (d->format == format)
d->format == formatDescription
TRUEnever evaluated
FALSEnever evaluated
0
610 return;
never executed: return;
0
611 d->format = format;-
612 d->defaultFormat = false;-
613 update();-
614}
never executed: end of block
0
615-
616void QProgressBar::resetFormat()-
617{-
618 Q_D(QProgressBar);-
619 d->defaultFormat = true;-
620 d->initDefaultFormat();-
621 update();-
622}
never executed: end of block
0
623-
624QString QProgressBar::format() const-
625{-
626 Q_D(const QProgressBar);-
627 return d->format;
never executed: return d->format;
0
628}-
629-
630QT_END_NAMESPACE-
631-
632#include "moc_qprogressbar.cpp"-
633-
634#endif // QT_NO_PROGRESSBAR-
Source codeSwitch to Preprocessed file

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