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