| 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 <private/qabstractspinbox_p.h> | - |
| 43 | #include <qspinbox.h> | - |
| 44 | | - |
| 45 | #ifndef QT_NO_SPINBOX | - |
| 46 | | - |
| 47 | #include <qlineedit.h> | - |
| 48 | #include <qlocale.h> | - |
| 49 | #include <qvalidator.h> | - |
| 50 | #include <qdebug.h> | - |
| 51 | | - |
| 52 | #include <math.h> | - |
| 53 | #include <float.h> | - |
| 54 | | - |
| 55 | QT_BEGIN_NAMESPACE | - |
| 56 | | - |
| 57 | //#define QSPINBOX_QSBDEBUG | - |
| 58 | #ifdef QSPINBOX_QSBDEBUG | - |
| 59 | # define QSBDEBUG qDebug | - |
| 60 | #else | - |
| 61 | # define QSBDEBUG if (false) qDebug | - |
| 62 | #endif | - |
| 63 | | - |
| 64 | class QSpinBoxPrivate : public QAbstractSpinBoxPrivate | - |
| 65 | { | - |
| 66 | Q_DECLARE_PUBLIC(QSpinBox) | - |
| 67 | public: | - |
| 68 | QSpinBoxPrivate(); | - |
| 69 | void emitSignals(EmitPolicy ep, const QVariant &); | - |
| 70 | | - |
| 71 | virtual QVariant valueFromText(const QString &n) const; | - |
| 72 | virtual QString textFromValue(const QVariant &n) const; | - |
| 73 | QVariant validateAndInterpret(QString &input, int &pos, | - |
| 74 | QValidator::State &state) const; | - |
| 75 | | - |
| 76 | inline void init() { | - |
| 77 | Q_Q(QSpinBox); executed (the execution status of this line is deduced): QSpinBox * const q = q_func(); | - |
| 78 | q->setInputMethodHints(Qt::ImhDigitsOnly); executed (the execution status of this line is deduced): q->setInputMethodHints(Qt::ImhDigitsOnly); | - |
| 79 | setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem); executed (the execution status of this line is deduced): setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem); | - |
| 80 | } executed: }Execution Count:148 | 148 |
| 81 | }; | - |
| 82 | | - |
| 83 | class QDoubleSpinBoxPrivate : public QAbstractSpinBoxPrivate | - |
| 84 | { | - |
| 85 | Q_DECLARE_PUBLIC(QDoubleSpinBox) | - |
| 86 | public: | - |
| 87 | QDoubleSpinBoxPrivate(); | - |
| 88 | void emitSignals(EmitPolicy ep, const QVariant &); | - |
| 89 | | - |
| 90 | virtual QVariant valueFromText(const QString &n) const; | - |
| 91 | virtual QString textFromValue(const QVariant &n) const; | - |
| 92 | QVariant validateAndInterpret(QString &input, int &pos, | - |
| 93 | QValidator::State &state) const; | - |
| 94 | double round(double input) const; | - |
| 95 | // variables | - |
| 96 | int decimals; | - |
| 97 | | - |
| 98 | inline void init() { | - |
| 99 | Q_Q(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBox * const q = q_func(); | - |
| 100 | q->setInputMethodHints(Qt::ImhFormattedNumbersOnly); executed (the execution status of this line is deduced): q->setInputMethodHints(Qt::ImhFormattedNumbersOnly); | - |
| 101 | } executed: }Execution Count:182 | 182 |
| 102 | | - |
| 103 | // When fiddling with the decimals property, we may lose precision in these properties. | - |
| 104 | double actualMin; | - |
| 105 | double actualMax; | - |
| 106 | }; | - |
| 107 | | - |
| 108 | | - |
| 109 | /*! | - |
| 110 | \class QSpinBox | - |
| 111 | \brief The QSpinBox class provides a spin box widget. | - |
| 112 | | - |
| 113 | \ingroup basicwidgets | - |
| 114 | \inmodule QtWidgets | - |
| 115 | | - |
| 116 | QSpinBox is designed to handle integers and discrete sets of | - |
| 117 | values (e.g., month names); use QDoubleSpinBox for floating point | - |
| 118 | values. | - |
| 119 | | - |
| 120 | QSpinBox allows the user to choose a value by clicking the up/down | - |
| 121 | buttons or pressing up/down on the keyboard to increase/decrease | - |
| 122 | the value currently displayed. The user can also type the value in | - |
| 123 | manually. The spin box supports integer values but can be extended to | - |
| 124 | use different strings with validate(), textFromValue() and valueFromText(). | - |
| 125 | | - |
| 126 | Every time the value changes QSpinBox emits two valueChanged() signals, | - |
| 127 | one providing an int and the other a QString. The QString overload | - |
| 128 | provides the value with both prefix() and suffix(). | - |
| 129 | The current value can be fetched with value() and set with setValue(). | - |
| 130 | | - |
| 131 | Clicking the up/down buttons or using the keyboard accelerator's | - |
| 132 | up and down arrows will increase or decrease the current value in | - |
| 133 | steps of size singleStep(). If you want to change this behaviour you | - |
| 134 | can reimplement the virtual function stepBy(). The minimum and | - |
| 135 | maximum value and the step size can be set using one of the | - |
| 136 | constructors, and can be changed later with setMinimum(), | - |
| 137 | setMaximum() and setSingleStep(). | - |
| 138 | | - |
| 139 | Most spin boxes are directional, but QSpinBox can also operate as | - |
| 140 | a circular spin box, i.e. if the range is 0-99 and the current | - |
| 141 | value is 99, clicking "up" will give 0 if wrapping() is set to | - |
| 142 | true. Use setWrapping() if you want circular behavior. | - |
| 143 | | - |
| 144 | The displayed value can be prepended and appended with arbitrary | - |
| 145 | strings indicating, for example, currency or the unit of | - |
| 146 | measurement. See setPrefix() and setSuffix(). The text in the spin | - |
| 147 | box is retrieved with text() (which includes any prefix() and | - |
| 148 | suffix()), or with cleanText() (which has no prefix(), no suffix() | - |
| 149 | and no leading or trailing whitespace). | - |
| 150 | | - |
| 151 | It is often desirable to give the user a special (often default) | - |
| 152 | choice in addition to the range of numeric values. See | - |
| 153 | setSpecialValueText() for how to do this with QSpinBox. | - |
| 154 | | - |
| 155 | \table 100% | - |
| 156 | \row \li \inlineimage windowsvista-spinbox.png Screenshot of a Windows Vista spin box | - |
| 157 | \li A spin box shown in the \l{Windows Vista Style Widget Gallery}{Windows Vista widget style}. | - |
| 158 | \row \li \inlineimage fusion-spinbox.png Screenshot of a Fusion spin box | - |
| 159 | \li A spin box shown in the \l{Fusion Style Widget Gallery}{Fusion widget style}. | - |
| 160 | \row \li \inlineimage macintosh-spinbox.png Screenshot of a Macintosh spin box | - |
| 161 | \li A spin box shown in the \l{Macintosh Style Widget Gallery}{Macintosh widget style}. | - |
| 162 | \endtable | - |
| 163 | | - |
| 164 | \section1 Subclassing QSpinBox | - |
| 165 | | - |
| 166 | If using prefix(), suffix(), and specialValueText() don't provide | - |
| 167 | enough control, you subclass QSpinBox and reimplement | - |
| 168 | valueFromText() and textFromValue(). For example, here's the code | - |
| 169 | for a custom spin box that allows the user to enter icon sizes | - |
| 170 | (e.g., "32 x 32"): | - |
| 171 | | - |
| 172 | \snippet widgets/icons/iconsizespinbox.cpp 1 | - |
| 173 | \codeline | - |
| 174 | \snippet widgets/icons/iconsizespinbox.cpp 2 | - |
| 175 | | - |
| 176 | See the \l{widgets/icons}{Icons} example for the full source | - |
| 177 | code. | - |
| 178 | | - |
| 179 | \sa QDoubleSpinBox, QDateTimeEdit, QSlider, {Spin Boxes Example} | - |
| 180 | */ | - |
| 181 | | - |
| 182 | /*! | - |
| 183 | \fn void QSpinBox::valueChanged(int i) | - |
| 184 | | - |
| 185 | This signal is emitted whenever the spin box's value is changed. | - |
| 186 | The new value's integer value is passed in \a i. | - |
| 187 | */ | - |
| 188 | | - |
| 189 | /*! | - |
| 190 | \fn void QSpinBox::valueChanged(const QString &text) | - |
| 191 | | - |
| 192 | \overload | - |
| 193 | | - |
| 194 | The new value is passed in \a text with prefix() and suffix(). | - |
| 195 | */ | - |
| 196 | | - |
| 197 | /*! | - |
| 198 | Constructs a spin box with 0 as minimum value and 99 as maximum value, a | - |
| 199 | step value of 1. The value is initially set to 0. It is parented to \a | - |
| 200 | parent. | - |
| 201 | | - |
| 202 | \sa setMinimum(), setMaximum(), setSingleStep() | - |
| 203 | */ | - |
| 204 | | - |
| 205 | QSpinBox::QSpinBox(QWidget *parent) | - |
| 206 | : QAbstractSpinBox(*new QSpinBoxPrivate, parent) | - |
| 207 | { | - |
| 208 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 209 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 210 | } executed: }Execution Count:148 | 148 |
| 211 | | - |
| 212 | /*! | - |
| 213 | Destructor. | - |
| 214 | */ | - |
| 215 | QSpinBox::~QSpinBox() {} | - |
| 216 | | - |
| 217 | /*! | - |
| 218 | \property QSpinBox::value | - |
| 219 | \brief the value of the spin box | - |
| 220 | | - |
| 221 | setValue() will emit valueChanged() if the new value is different | - |
| 222 | from the old one. The value property has a second notifier | - |
| 223 | signal which includes the spin box's prefix and suffix. | - |
| 224 | */ | - |
| 225 | | - |
| 226 | int QSpinBox::value() const | - |
| 227 | { | - |
| 228 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 229 | return d->value.toInt(); executed: return d->value.toInt();Execution Count:115 | 115 |
| 230 | } | - |
| 231 | | - |
| 232 | void QSpinBox::setValue(int value) | - |
| 233 | { | - |
| 234 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 235 | d->setValue(QVariant(value), EmitIfChanged); executed (the execution status of this line is deduced): d->setValue(QVariant(value), EmitIfChanged); | - |
| 236 | } executed: }Execution Count:787 | 787 |
| 237 | | - |
| 238 | /*! | - |
| 239 | \property QSpinBox::prefix | - |
| 240 | \brief the spin box's prefix | - |
| 241 | | - |
| 242 | The prefix is prepended to the start of the displayed value. | - |
| 243 | Typical use is to display a unit of measurement or a currency | - |
| 244 | symbol. For example: | - |
| 245 | | - |
| 246 | \snippet code/src_gui_widgets_qspinbox.cpp 0 | - |
| 247 | | - |
| 248 | To turn off the prefix display, set this property to an empty | - |
| 249 | string. The default is no prefix. The prefix is not displayed when | - |
| 250 | value() == minimum() and specialValueText() is set. | - |
| 251 | | - |
| 252 | If no prefix is set, prefix() returns an empty string. | - |
| 253 | | - |
| 254 | \sa suffix(), setSuffix(), specialValueText(), setSpecialValueText() | - |
| 255 | */ | - |
| 256 | | - |
| 257 | QString QSpinBox::prefix() const | - |
| 258 | { | - |
| 259 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 260 | return d->prefix; executed: return d->prefix;Execution Count:8 | 8 |
| 261 | } | - |
| 262 | | - |
| 263 | void QSpinBox::setPrefix(const QString &prefix) | - |
| 264 | { | - |
| 265 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 266 | | - |
| 267 | d->prefix = prefix; executed (the execution status of this line is deduced): d->prefix = prefix; | - |
| 268 | d->updateEdit(); executed (the execution status of this line is deduced): d->updateEdit(); | - |
| 269 | | - |
| 270 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 271 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 272 | } executed: }Execution Count:10 | 10 |
| 273 | | - |
| 274 | /*! | - |
| 275 | \property QSpinBox::suffix | - |
| 276 | \brief the suffix of the spin box | - |
| 277 | | - |
| 278 | The suffix is appended to the end of the displayed value. Typical | - |
| 279 | use is to display a unit of measurement or a currency symbol. For | - |
| 280 | example: | - |
| 281 | | - |
| 282 | \snippet code/src_gui_widgets_qspinbox.cpp 1 | - |
| 283 | | - |
| 284 | To turn off the suffix display, set this property to an empty | - |
| 285 | string. The default is no suffix. The suffix is not displayed for | - |
| 286 | the minimum() if specialValueText() is set. | - |
| 287 | | - |
| 288 | If no suffix is set, suffix() returns an empty string. | - |
| 289 | | - |
| 290 | \sa prefix(), setPrefix(), specialValueText(), setSpecialValueText() | - |
| 291 | */ | - |
| 292 | | - |
| 293 | QString QSpinBox::suffix() const | - |
| 294 | { | - |
| 295 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 296 | | - |
| 297 | return d->suffix; executed: return d->suffix;Execution Count:8 | 8 |
| 298 | } | - |
| 299 | | - |
| 300 | void QSpinBox::setSuffix(const QString &suffix) | - |
| 301 | { | - |
| 302 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 303 | | - |
| 304 | d->suffix = suffix; executed (the execution status of this line is deduced): d->suffix = suffix; | - |
| 305 | d->updateEdit(); executed (the execution status of this line is deduced): d->updateEdit(); | - |
| 306 | | - |
| 307 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 308 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 309 | } executed: }Execution Count:10 | 10 |
| 310 | | - |
| 311 | /*! | - |
| 312 | \property QSpinBox::cleanText | - |
| 313 | | - |
| 314 | \brief the text of the spin box excluding any prefix, suffix, | - |
| 315 | or leading or trailing whitespace. | - |
| 316 | | - |
| 317 | \sa text, QSpinBox::prefix, QSpinBox::suffix | - |
| 318 | */ | - |
| 319 | | - |
| 320 | QString QSpinBox::cleanText() const | - |
| 321 | { | - |
| 322 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 323 | | - |
| 324 | return d->stripped(d->edit->displayText()); executed: return d->stripped(d->edit->displayText());Execution Count:12 | 12 |
| 325 | } | - |
| 326 | | - |
| 327 | | - |
| 328 | /*! | - |
| 329 | \property QSpinBox::singleStep | - |
| 330 | \brief the step value | - |
| 331 | | - |
| 332 | When the user uses the arrows to change the spin box's value the | - |
| 333 | value will be incremented/decremented by the amount of the | - |
| 334 | singleStep. The default value is 1. Setting a singleStep value of | - |
| 335 | less than 0 does nothing. | - |
| 336 | */ | - |
| 337 | | - |
| 338 | int QSpinBox::singleStep() const | - |
| 339 | { | - |
| 340 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 341 | | - |
| 342 | return d->singleStep.toInt(); executed: return d->singleStep.toInt();Execution Count:7 | 7 |
| 343 | } | - |
| 344 | | - |
| 345 | void QSpinBox::setSingleStep(int value) | - |
| 346 | { | - |
| 347 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 348 | if (value >= 0) { evaluated: value >= 0| yes Evaluation Count:12 | yes Evaluation Count:1 |
| 1-12 |
| 349 | d->singleStep = QVariant(value); executed (the execution status of this line is deduced): d->singleStep = QVariant(value); | - |
| 350 | d->updateEdit(); executed (the execution status of this line is deduced): d->updateEdit(); | - |
| 351 | } executed: }Execution Count:12 | 12 |
| 352 | } executed: }Execution Count:13 | 13 |
| 353 | | - |
| 354 | /*! | - |
| 355 | \property QSpinBox::minimum | - |
| 356 | | - |
| 357 | \brief the minimum value of the spin box | - |
| 358 | | - |
| 359 | When setting this property the \l maximum is adjusted | - |
| 360 | if necessary to ensure that the range remains valid. | - |
| 361 | | - |
| 362 | The default minimum value is 0. | - |
| 363 | | - |
| 364 | \sa setRange(), specialValueText | - |
| 365 | */ | - |
| 366 | | - |
| 367 | int QSpinBox::minimum() const | - |
| 368 | { | - |
| 369 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 370 | | - |
| 371 | return d->minimum.toInt(); executed: return d->minimum.toInt();Execution Count:22 | 22 |
| 372 | } | - |
| 373 | | - |
| 374 | void QSpinBox::setMinimum(int minimum) | - |
| 375 | { | - |
| 376 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 377 | const QVariant m(minimum); executed (the execution status of this line is deduced): const QVariant m(minimum); | - |
| 378 | d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); executed (the execution status of this line is deduced): d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); | - |
| 379 | } executed: }Execution Count:83 | 83 |
| 380 | | - |
| 381 | /*! | - |
| 382 | \property QSpinBox::maximum | - |
| 383 | | - |
| 384 | \brief the maximum value of the spin box | - |
| 385 | | - |
| 386 | When setting this property the minimum is adjusted | - |
| 387 | if necessary, to ensure that the range remains valid. | - |
| 388 | | - |
| 389 | The default maximum value is 99. | - |
| 390 | | - |
| 391 | \sa setRange(), specialValueText | - |
| 392 | | - |
| 393 | */ | - |
| 394 | | - |
| 395 | int QSpinBox::maximum() const | - |
| 396 | { | - |
| 397 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 398 | | - |
| 399 | return d->maximum.toInt(); executed: return d->maximum.toInt();Execution Count:23 | 23 |
| 400 | } | - |
| 401 | | - |
| 402 | void QSpinBox::setMaximum(int maximum) | - |
| 403 | { | - |
| 404 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 405 | const QVariant m(maximum); executed (the execution status of this line is deduced): const QVariant m(maximum); | - |
| 406 | d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); executed (the execution status of this line is deduced): d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); | - |
| 407 | } executed: }Execution Count:81 | 81 |
| 408 | | - |
| 409 | /*! | - |
| 410 | Convenience function to set the \a minimum, and \a maximum values | - |
| 411 | with a single function call. | - |
| 412 | | - |
| 413 | \snippet code/src_gui_widgets_qspinbox.cpp 2 | - |
| 414 | is equivalent to: | - |
| 415 | \snippet code/src_gui_widgets_qspinbox.cpp 3 | - |
| 416 | | - |
| 417 | \sa minimum, maximum | - |
| 418 | */ | - |
| 419 | | - |
| 420 | void QSpinBox::setRange(int minimum, int maximum) | - |
| 421 | { | - |
| 422 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 423 | d->setRange(QVariant(minimum), QVariant(maximum)); executed (the execution status of this line is deduced): d->setRange(QVariant(minimum), QVariant(maximum)); | - |
| 424 | } executed: }Execution Count:58 | 58 |
| 425 | | - |
| 426 | /*! | - |
| 427 | This virtual function is used by the spin box whenever it needs to | - |
| 428 | display the given \a value. The default implementation returns a | - |
| 429 | string containing \a value printed in the standard way using | - |
| 430 | QWidget::locale().toString(), but with the thousand separator | - |
| 431 | removed. Reimplementations may return anything. (See the example | - |
| 432 | in the detailed description.) | - |
| 433 | | - |
| 434 | Note: QSpinBox does not call this function for specialValueText() | - |
| 435 | and that neither prefix() nor suffix() should be included in the | - |
| 436 | return value. | - |
| 437 | | - |
| 438 | If you reimplement this, you may also need to reimplement | - |
| 439 | valueFromText() and validate() | - |
| 440 | | - |
| 441 | \sa valueFromText(), validate(), QLocale::groupSeparator() | - |
| 442 | */ | - |
| 443 | | - |
| 444 | QString QSpinBox::textFromValue(int value) const | - |
| 445 | { | - |
| 446 | QString str = locale().toString(value); executed (the execution status of this line is deduced): QString str = locale().toString(value); | - |
| 447 | if (qAbs(value) >= 1000 || value == INT_MIN) { evaluated: qAbs(value) >= 1000| yes Evaluation Count:654 | yes Evaluation Count:537 |
evaluated: value == (-2147483647 - 1)| yes Evaluation Count:8 | yes Evaluation Count:529 |
| 8-654 |
| 448 | str.remove(locale().groupSeparator()); executed (the execution status of this line is deduced): str.remove(locale().groupSeparator()); | - |
| 449 | } executed: }Execution Count:662 | 662 |
| 450 | | - |
| 451 | return str; executed: return str;Execution Count:1191 | 1191 |
| 452 | } | - |
| 453 | | - |
| 454 | /*! | - |
| 455 | \fn int QSpinBox::valueFromText(const QString &text) const | - |
| 456 | | - |
| 457 | This virtual function is used by the spin box whenever it needs to | - |
| 458 | interpret \a text entered by the user as a value. | - |
| 459 | | - |
| 460 | Subclasses that need to display spin box values in a non-numeric | - |
| 461 | way need to reimplement this function. | - |
| 462 | | - |
| 463 | Note: QSpinBox handles specialValueText() separately; this | - |
| 464 | function is only concerned with the other values. | - |
| 465 | | - |
| 466 | \sa textFromValue(), validate() | - |
| 467 | */ | - |
| 468 | | - |
| 469 | int QSpinBox::valueFromText(const QString &text) const | - |
| 470 | { | - |
| 471 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 472 | | - |
| 473 | QString copy = text; executed (the execution status of this line is deduced): QString copy = text; | - |
| 474 | int pos = d->edit->cursorPosition(); executed (the execution status of this line is deduced): int pos = d->edit->cursorPosition(); | - |
| 475 | QValidator::State state = QValidator::Acceptable; executed (the execution status of this line is deduced): QValidator::State state = QValidator::Acceptable; | - |
| 476 | return d->validateAndInterpret(copy, pos, state).toInt(); executed: return d->validateAndInterpret(copy, pos, state).toInt();Execution Count:74 | 74 |
| 477 | } | - |
| 478 | | - |
| 479 | /*! | - |
| 480 | \reimp | - |
| 481 | */ | - |
| 482 | QValidator::State QSpinBox::validate(QString &text, int &pos) const | - |
| 483 | { | - |
| 484 | Q_D(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBoxPrivate * const d = d_func(); | - |
| 485 | | - |
| 486 | QValidator::State state; executed (the execution status of this line is deduced): QValidator::State state; | - |
| 487 | d->validateAndInterpret(text, pos, state); executed (the execution status of this line is deduced): d->validateAndInterpret(text, pos, state); | - |
| 488 | return state; executed: return state;Execution Count:1400 | 1400 |
| 489 | } | - |
| 490 | | - |
| 491 | | - |
| 492 | /*! | - |
| 493 | \reimp | - |
| 494 | */ | - |
| 495 | void QSpinBox::fixup(QString &input) const | - |
| 496 | { | - |
| 497 | input.remove(locale().groupSeparator()); executed (the execution status of this line is deduced): input.remove(locale().groupSeparator()); | - |
| 498 | } executed: }Execution Count:5 | 5 |
| 499 | | - |
| 500 | | - |
| 501 | // --- QDoubleSpinBox --- | - |
| 502 | | - |
| 503 | /*! | - |
| 504 | \class QDoubleSpinBox | - |
| 505 | \brief The QDoubleSpinBox class provides a spin box widget that | - |
| 506 | takes doubles. | - |
| 507 | | - |
| 508 | \ingroup basicwidgets | - |
| 509 | \inmodule QtWidgets | - |
| 510 | | - |
| 511 | QDoubleSpinBox allows the user to choose a value by clicking the | - |
| 512 | up and down buttons or by pressing Up or Down on the keyboard to | - |
| 513 | increase or decrease the value currently displayed. The user can | - |
| 514 | also type the value in manually. The spin box supports double | - |
| 515 | values but can be extended to use different strings with | - |
| 516 | validate(), textFromValue() and valueFromText(). | - |
| 517 | | - |
| 518 | Every time the value changes QDoubleSpinBox emits two | - |
| 519 | valueChanged() signals, one taking providing a double and the other | - |
| 520 | a QString. The QString overload provides the value with both | - |
| 521 | prefix() and suffix(). The current value can be fetched with | - |
| 522 | value() and set with setValue(). | - |
| 523 | | - |
| 524 | Note: QDoubleSpinBox will round numbers so they can be displayed | - |
| 525 | with the current precision. In a QDoubleSpinBox with decimals set | - |
| 526 | to 2, calling setValue(2.555) will cause value() to return 2.56. | - |
| 527 | | - |
| 528 | Clicking the up and down buttons or using the keyboard accelerator's | - |
| 529 | Up and Down arrows will increase or decrease the current value in | - |
| 530 | steps of size singleStep(). If you want to change this behavior you | - |
| 531 | can reimplement the virtual function stepBy(). The minimum and | - |
| 532 | maximum value and the step size can be set using one of the | - |
| 533 | constructors, and can be changed later with setMinimum(), | - |
| 534 | setMaximum() and setSingleStep(). The spinbox has a default | - |
| 535 | precision of 2 decimal places but this can be changed using | - |
| 536 | setDecimals(). | - |
| 537 | | - |
| 538 | Most spin boxes are directional, but QDoubleSpinBox can also | - |
| 539 | operate as a circular spin box, i.e. if the range is 0.0-99.9 and | - |
| 540 | the current value is 99.9, clicking "up" will give 0 if wrapping() | - |
| 541 | is set to true. Use setWrapping() if you want circular behavior. | - |
| 542 | | - |
| 543 | The displayed value can be prepended and appended with arbitrary | - |
| 544 | strings indicating, for example, currency or the unit of | - |
| 545 | measurement. See setPrefix() and setSuffix(). The text in the spin | - |
| 546 | box is retrieved with text() (which includes any prefix() and | - |
| 547 | suffix()), or with cleanText() (which has no prefix(), no suffix() | - |
| 548 | and no leading or trailing whitespace). | - |
| 549 | | - |
| 550 | It is often desirable to give the user a special (often default) | - |
| 551 | choice in addition to the range of numeric values. See | - |
| 552 | setSpecialValueText() for how to do this with QDoubleSpinBox. | - |
| 553 | | - |
| 554 | \sa QSpinBox, QDateTimeEdit, QSlider, {Spin Boxes Example} | - |
| 555 | */ | - |
| 556 | | - |
| 557 | /*! | - |
| 558 | \fn void QDoubleSpinBox::valueChanged(double d); | - |
| 559 | | - |
| 560 | This signal is emitted whenever the spin box's value is changed. | - |
| 561 | The new value is passed in \a d. | - |
| 562 | */ | - |
| 563 | | - |
| 564 | /*! | - |
| 565 | \fn void QDoubleSpinBox::valueChanged(const QString &text); | - |
| 566 | | - |
| 567 | \overload | - |
| 568 | | - |
| 569 | The new value is passed in \a text with prefix() and suffix(). | - |
| 570 | */ | - |
| 571 | | - |
| 572 | /*! | - |
| 573 | Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, | - |
| 574 | a step value of 1.0 and a precision of 2 decimal places. The value is | - |
| 575 | initially set to 0.00. The spin box has the given \a parent. | - |
| 576 | | - |
| 577 | \sa setMinimum(), setMaximum(), setSingleStep() | - |
| 578 | */ | - |
| 579 | QDoubleSpinBox::QDoubleSpinBox(QWidget *parent) | - |
| 580 | : QAbstractSpinBox(*new QDoubleSpinBoxPrivate, parent) | - |
| 581 | { | - |
| 582 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 583 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 584 | } executed: }Execution Count:182 | 182 |
| 585 | | - |
| 586 | /*! | - |
| 587 | Destructor. | - |
| 588 | */ | - |
| 589 | QDoubleSpinBox::~QDoubleSpinBox() {} | - |
| 590 | | - |
| 591 | /*! | - |
| 592 | \property QDoubleSpinBox::value | - |
| 593 | \brief the value of the spin box | - |
| 594 | | - |
| 595 | setValue() will emit valueChanged() if the new value is different | - |
| 596 | from the old one. The value property has a second notifier | - |
| 597 | signal which includes the spin box's prefix and suffix. | - |
| 598 | | - |
| 599 | Note: The value will be rounded so it can be displayed with the | - |
| 600 | current setting of decimals. | - |
| 601 | | - |
| 602 | \sa decimals | - |
| 603 | */ | - |
| 604 | double QDoubleSpinBox::value() const | - |
| 605 | { | - |
| 606 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 607 | | - |
| 608 | return d->value.toDouble(); executed: return d->value.toDouble();Execution Count:277 | 277 |
| 609 | } | - |
| 610 | | - |
| 611 | void QDoubleSpinBox::setValue(double value) | - |
| 612 | { | - |
| 613 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 614 | QVariant v(d->round(value)); executed (the execution status of this line is deduced): QVariant v(d->round(value)); | - |
| 615 | d->setValue(v, EmitIfChanged); executed (the execution status of this line is deduced): d->setValue(v, EmitIfChanged); | - |
| 616 | } executed: }Execution Count:183 | 183 |
| 617 | /*! | - |
| 618 | \property QDoubleSpinBox::prefix | - |
| 619 | \brief the spin box's prefix | - |
| 620 | | - |
| 621 | The prefix is prepended to the start of the displayed value. | - |
| 622 | Typical use is to display a unit of measurement or a currency | - |
| 623 | symbol. For example: | - |
| 624 | | - |
| 625 | \snippet code/src_gui_widgets_qspinbox.cpp 4 | - |
| 626 | | - |
| 627 | To turn off the prefix display, set this property to an empty | - |
| 628 | string. The default is no prefix. The prefix is not displayed when | - |
| 629 | value() == minimum() and specialValueText() is set. | - |
| 630 | | - |
| 631 | If no prefix is set, prefix() returns an empty string. | - |
| 632 | | - |
| 633 | \sa suffix(), setSuffix(), specialValueText(), setSpecialValueText() | - |
| 634 | */ | - |
| 635 | | - |
| 636 | QString QDoubleSpinBox::prefix() const | - |
| 637 | { | - |
| 638 | Q_D(const QDoubleSpinBox); never executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 639 | | - |
| 640 | return d->prefix; never executed: return d->prefix; | 0 |
| 641 | } | - |
| 642 | | - |
| 643 | void QDoubleSpinBox::setPrefix(const QString &prefix) | - |
| 644 | { | - |
| 645 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 646 | | - |
| 647 | d->prefix = prefix; executed (the execution status of this line is deduced): d->prefix = prefix; | - |
| 648 | d->updateEdit(); executed (the execution status of this line is deduced): d->updateEdit(); | - |
| 649 | } executed: }Execution Count:10 | 10 |
| 650 | | - |
| 651 | /*! | - |
| 652 | \property QDoubleSpinBox::suffix | - |
| 653 | \brief the suffix of the spin box | - |
| 654 | | - |
| 655 | The suffix is appended to the end of the displayed value. Typical | - |
| 656 | use is to display a unit of measurement or a currency symbol. For | - |
| 657 | example: | - |
| 658 | | - |
| 659 | \snippet code/src_gui_widgets_qspinbox.cpp 5 | - |
| 660 | | - |
| 661 | To turn off the suffix display, set this property to an empty | - |
| 662 | string. The default is no suffix. The suffix is not displayed for | - |
| 663 | the minimum() if specialValueText() is set. | - |
| 664 | | - |
| 665 | If no suffix is set, suffix() returns an empty string. | - |
| 666 | | - |
| 667 | \sa prefix(), setPrefix(), specialValueText(), setSpecialValueText() | - |
| 668 | */ | - |
| 669 | | - |
| 670 | QString QDoubleSpinBox::suffix() const | - |
| 671 | { | - |
| 672 | Q_D(const QDoubleSpinBox); never executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 673 | | - |
| 674 | return d->suffix; never executed: return d->suffix; | 0 |
| 675 | } | - |
| 676 | | - |
| 677 | void QDoubleSpinBox::setSuffix(const QString &suffix) | - |
| 678 | { | - |
| 679 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 680 | | - |
| 681 | d->suffix = suffix; executed (the execution status of this line is deduced): d->suffix = suffix; | - |
| 682 | d->updateEdit(); executed (the execution status of this line is deduced): d->updateEdit(); | - |
| 683 | | - |
| 684 | d->cachedSizeHint = QSize(); executed (the execution status of this line is deduced): d->cachedSizeHint = QSize(); | - |
| 685 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 686 | } executed: }Execution Count:9 | 9 |
| 687 | | - |
| 688 | /*! | - |
| 689 | \property QDoubleSpinBox::cleanText | - |
| 690 | | - |
| 691 | \brief the text of the spin box excluding any prefix, suffix, | - |
| 692 | or leading or trailing whitespace. | - |
| 693 | | - |
| 694 | \sa text, QDoubleSpinBox::prefix, QDoubleSpinBox::suffix | - |
| 695 | */ | - |
| 696 | | - |
| 697 | QString QDoubleSpinBox::cleanText() const | - |
| 698 | { | - |
| 699 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 700 | | - |
| 701 | return d->stripped(d->edit->displayText()); executed: return d->stripped(d->edit->displayText());Execution Count:9 | 9 |
| 702 | } | - |
| 703 | | - |
| 704 | /*! | - |
| 705 | \property QDoubleSpinBox::singleStep | - |
| 706 | \brief the step value | - |
| 707 | | - |
| 708 | When the user uses the arrows to change the spin box's value the | - |
| 709 | value will be incremented/decremented by the amount of the | - |
| 710 | singleStep. The default value is 1.0. Setting a singleStep value | - |
| 711 | of less than 0 does nothing. | - |
| 712 | */ | - |
| 713 | double QDoubleSpinBox::singleStep() const | - |
| 714 | { | - |
| 715 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 716 | | - |
| 717 | return d->singleStep.toDouble(); executed: return d->singleStep.toDouble();Execution Count:2 | 2 |
| 718 | } | - |
| 719 | | - |
| 720 | void QDoubleSpinBox::setSingleStep(double value) | - |
| 721 | { | - |
| 722 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 723 | | - |
| 724 | if (value >= 0) { partially evaluated: value >= 0| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 725 | d->singleStep = value; executed (the execution status of this line is deduced): d->singleStep = value; | - |
| 726 | d->updateEdit(); executed (the execution status of this line is deduced): d->updateEdit(); | - |
| 727 | } executed: }Execution Count:6 | 6 |
| 728 | } executed: }Execution Count:6 | 6 |
| 729 | | - |
| 730 | /*! | - |
| 731 | \property QDoubleSpinBox::minimum | - |
| 732 | | - |
| 733 | \brief the minimum value of the spin box | - |
| 734 | | - |
| 735 | When setting this property the \l maximum is adjusted | - |
| 736 | if necessary to ensure that the range remains valid. | - |
| 737 | | - |
| 738 | The default minimum value is 0.0. | - |
| 739 | | - |
| 740 | Note: The minimum value will be rounded to match the decimals | - |
| 741 | property. | - |
| 742 | | - |
| 743 | \sa decimals, setRange(), specialValueText | - |
| 744 | */ | - |
| 745 | | - |
| 746 | double QDoubleSpinBox::minimum() const | - |
| 747 | { | - |
| 748 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 749 | | - |
| 750 | return d->minimum.toDouble(); executed: return d->minimum.toDouble();Execution Count:53 | 53 |
| 751 | } | - |
| 752 | | - |
| 753 | void QDoubleSpinBox::setMinimum(double minimum) | - |
| 754 | { | - |
| 755 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 756 | d->actualMin = minimum; executed (the execution status of this line is deduced): d->actualMin = minimum; | - |
| 757 | const QVariant m(d->round(minimum)); executed (the execution status of this line is deduced): const QVariant m(d->round(minimum)); | - |
| 758 | d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); executed (the execution status of this line is deduced): d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); | - |
| 759 | } executed: }Execution Count:61 | 61 |
| 760 | | - |
| 761 | /*! | - |
| 762 | \property QDoubleSpinBox::maximum | - |
| 763 | | - |
| 764 | \brief the maximum value of the spin box | - |
| 765 | | - |
| 766 | When setting this property the \l minimum is adjusted | - |
| 767 | if necessary, to ensure that the range remains valid. | - |
| 768 | | - |
| 769 | The default maximum value is 99.99. | - |
| 770 | | - |
| 771 | Note: The maximum value will be rounded to match the decimals | - |
| 772 | property. | - |
| 773 | | - |
| 774 | \sa decimals, setRange() | - |
| 775 | */ | - |
| 776 | | - |
| 777 | double QDoubleSpinBox::maximum() const | - |
| 778 | { | - |
| 779 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 780 | | - |
| 781 | return d->maximum.toDouble(); executed: return d->maximum.toDouble();Execution Count:56 | 56 |
| 782 | } | - |
| 783 | | - |
| 784 | void QDoubleSpinBox::setMaximum(double maximum) | - |
| 785 | { | - |
| 786 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 787 | d->actualMax = maximum; executed (the execution status of this line is deduced): d->actualMax = maximum; | - |
| 788 | const QVariant m(d->round(maximum)); executed (the execution status of this line is deduced): const QVariant m(d->round(maximum)); | - |
| 789 | d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); executed (the execution status of this line is deduced): d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); | - |
| 790 | } executed: }Execution Count:62 | 62 |
| 791 | | - |
| 792 | /*! | - |
| 793 | Convenience function to set the \a minimum and \a maximum values | - |
| 794 | with a single function call. | - |
| 795 | | - |
| 796 | Note: The maximum and minimum values will be rounded to match the | - |
| 797 | decimals property. | - |
| 798 | | - |
| 799 | \snippet code/src_gui_widgets_qspinbox.cpp 6 | - |
| 800 | is equivalent to: | - |
| 801 | \snippet code/src_gui_widgets_qspinbox.cpp 7 | - |
| 802 | | - |
| 803 | \sa minimum, maximum | - |
| 804 | */ | - |
| 805 | | - |
| 806 | void QDoubleSpinBox::setRange(double minimum, double maximum) | - |
| 807 | { | - |
| 808 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 809 | d->actualMin = minimum; executed (the execution status of this line is deduced): d->actualMin = minimum; | - |
| 810 | d->actualMax = maximum; executed (the execution status of this line is deduced): d->actualMax = maximum; | - |
| 811 | d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum))); executed (the execution status of this line is deduced): d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum))); | - |
| 812 | } executed: }Execution Count:180 | 180 |
| 813 | | - |
| 814 | /*! | - |
| 815 | \property QDoubleSpinBox::decimals | - |
| 816 | | - |
| 817 | \brief the precision of the spin box, in decimals | - |
| 818 | | - |
| 819 | Sets how many decimals the spinbox will use for displaying and | - |
| 820 | interpreting doubles. | - |
| 821 | | - |
| 822 | \warning The maximum value for \a decimals is DBL_MAX_10_EXP + | - |
| 823 | DBL_DIG (ie. 323) because of the limitations of the double type. | - |
| 824 | | - |
| 825 | Note: The maximum, minimum and value might change as a result of | - |
| 826 | changing this property. | - |
| 827 | */ | - |
| 828 | | - |
| 829 | int QDoubleSpinBox::decimals() const | - |
| 830 | { | - |
| 831 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 832 | | - |
| 833 | return d->decimals; executed: return d->decimals;Execution Count:22 | 22 |
| 834 | } | - |
| 835 | | - |
| 836 | void QDoubleSpinBox::setDecimals(int decimals) | - |
| 837 | { | - |
| 838 | Q_D(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 839 | d->decimals = qBound(0, decimals, DBL_MAX_10_EXP + DBL_DIG); executed (the execution status of this line is deduced): d->decimals = qBound(0, decimals, 308 + 15); | - |
| 840 | | - |
| 841 | setRange(d->actualMin, d->actualMax); // make sure values are rounded executed (the execution status of this line is deduced): setRange(d->actualMin, d->actualMax); | - |
| 842 | setValue(value()); executed (the execution status of this line is deduced): setValue(value()); | - |
| 843 | } executed: }Execution Count:83 | 83 |
| 844 | | - |
| 845 | /*! | - |
| 846 | This virtual function is used by the spin box whenever it needs to | - |
| 847 | display the given \a value. The default implementation returns a string | - |
| 848 | containing \a value printed using QWidget::locale().toString(\a value, | - |
| 849 | QLatin1Char('f'), decimals()) and will remove the thousand | - |
| 850 | separator. Reimplementations may return anything. | - |
| 851 | | - |
| 852 | Note: QDoubleSpinBox does not call this function for | - |
| 853 | specialValueText() and that neither prefix() nor suffix() should | - |
| 854 | be included in the return value. | - |
| 855 | | - |
| 856 | If you reimplement this, you may also need to reimplement | - |
| 857 | valueFromText(). | - |
| 858 | | - |
| 859 | \sa valueFromText(), QLocale::groupSeparator() | - |
| 860 | */ | - |
| 861 | | - |
| 862 | | - |
| 863 | QString QDoubleSpinBox::textFromValue(double value) const | - |
| 864 | { | - |
| 865 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 866 | QString str = locale().toString(value, 'f', d->decimals); executed (the execution status of this line is deduced): QString str = locale().toString(value, 'f', d->decimals); | - |
| 867 | if (qAbs(value) >= 1000.0) { evaluated: qAbs(value) >= 1000.0| yes Evaluation Count:59 | yes Evaluation Count:786 |
| 59-786 |
| 868 | str.remove(locale().groupSeparator()); executed (the execution status of this line is deduced): str.remove(locale().groupSeparator()); | - |
| 869 | } executed: }Execution Count:59 | 59 |
| 870 | return str; executed: return str;Execution Count:845 | 845 |
| 871 | } | - |
| 872 | | - |
| 873 | /*! | - |
| 874 | This virtual function is used by the spin box whenever it needs to | - |
| 875 | interpret \a text entered by the user as a value. | - |
| 876 | | - |
| 877 | Subclasses that need to display spin box values in a non-numeric | - |
| 878 | way need to reimplement this function. | - |
| 879 | | - |
| 880 | Note: QDoubleSpinBox handles specialValueText() separately; this | - |
| 881 | function is only concerned with the other values. | - |
| 882 | | - |
| 883 | \sa textFromValue(), validate() | - |
| 884 | */ | - |
| 885 | double QDoubleSpinBox::valueFromText(const QString &text) const | - |
| 886 | { | - |
| 887 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 888 | | - |
| 889 | QString copy = text; executed (the execution status of this line is deduced): QString copy = text; | - |
| 890 | int pos = d->edit->cursorPosition(); executed (the execution status of this line is deduced): int pos = d->edit->cursorPosition(); | - |
| 891 | QValidator::State state = QValidator::Acceptable; executed (the execution status of this line is deduced): QValidator::State state = QValidator::Acceptable; | - |
| 892 | return d->validateAndInterpret(copy, pos, state).toDouble(); executed: return d->validateAndInterpret(copy, pos, state).toDouble();Execution Count:245 | 245 |
| 893 | } | - |
| 894 | | - |
| 895 | /*! | - |
| 896 | \reimp | - |
| 897 | */ | - |
| 898 | QValidator::State QDoubleSpinBox::validate(QString &text, int &pos) const | - |
| 899 | { | - |
| 900 | Q_D(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBoxPrivate * const d = d_func(); | - |
| 901 | | - |
| 902 | QValidator::State state; executed (the execution status of this line is deduced): QValidator::State state; | - |
| 903 | d->validateAndInterpret(text, pos, state); executed (the execution status of this line is deduced): d->validateAndInterpret(text, pos, state); | - |
| 904 | return state; executed: return state;Execution Count:2729 | 2729 |
| 905 | } | - |
| 906 | | - |
| 907 | | - |
| 908 | /*! | - |
| 909 | \reimp | - |
| 910 | */ | - |
| 911 | void QDoubleSpinBox::fixup(QString &input) const | - |
| 912 | { | - |
| 913 | input.remove(locale().groupSeparator()); executed (the execution status of this line is deduced): input.remove(locale().groupSeparator()); | - |
| 914 | } executed: }Execution Count:17 | 17 |
| 915 | | - |
| 916 | // --- QSpinBoxPrivate --- | - |
| 917 | | - |
| 918 | /*! | - |
| 919 | \internal | - |
| 920 | Constructs a QSpinBoxPrivate object | - |
| 921 | */ | - |
| 922 | | - |
| 923 | QSpinBoxPrivate::QSpinBoxPrivate() | - |
| 924 | { | - |
| 925 | minimum = QVariant((int)0); executed (the execution status of this line is deduced): minimum = QVariant((int)0); | - |
| 926 | maximum = QVariant((int)99); executed (the execution status of this line is deduced): maximum = QVariant((int)99); | - |
| 927 | value = minimum; executed (the execution status of this line is deduced): value = minimum; | - |
| 928 | singleStep = QVariant((int)1); executed (the execution status of this line is deduced): singleStep = QVariant((int)1); | - |
| 929 | type = QVariant::Int; executed (the execution status of this line is deduced): type = QVariant::Int; | - |
| 930 | } executed: }Execution Count:148 | 148 |
| 931 | | - |
| 932 | /*! | - |
| 933 | \internal | - |
| 934 | \reimp | - |
| 935 | */ | - |
| 936 | | - |
| 937 | void QSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) | - |
| 938 | { | - |
| 939 | Q_Q(QSpinBox); executed (the execution status of this line is deduced): QSpinBox * const q = q_func(); | - |
| 940 | if (ep != NeverEmit) { partially evaluated: ep != NeverEmit| yes Evaluation Count:800 | no Evaluation Count:0 |
| 0-800 |
| 941 | pendingEmit = false; executed (the execution status of this line is deduced): pendingEmit = false; | - |
| 942 | if (ep == AlwaysEmit || value != old) { evaluated: ep == AlwaysEmit| yes Evaluation Count:12 | yes Evaluation Count:788 |
partially evaluated: value != old| yes Evaluation Count:788 | no Evaluation Count:0 |
| 0-788 |
| 943 | emit q->valueChanged(edit->displayText()); executed (the execution status of this line is deduced): q->valueChanged(edit->displayText()); | - |
| 944 | emit q->valueChanged(value.toInt()); executed (the execution status of this line is deduced): q->valueChanged(value.toInt()); | - |
| 945 | } executed: }Execution Count:800 | 800 |
| 946 | } executed: }Execution Count:800 | 800 |
| 947 | } executed: }Execution Count:800 | 800 |
| 948 | | - |
| 949 | /*! | - |
| 950 | \internal | - |
| 951 | \reimp | - |
| 952 | */ | - |
| 953 | | - |
| 954 | QString QSpinBoxPrivate::textFromValue(const QVariant &value) const | - |
| 955 | { | - |
| 956 | Q_Q(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBox * const q = q_func(); | - |
| 957 | return q->textFromValue(value.toInt()); executed: return q->textFromValue(value.toInt());Execution Count:1195 | 1195 |
| 958 | } | - |
| 959 | /*! | - |
| 960 | \internal | - |
| 961 | \reimp | - |
| 962 | */ | - |
| 963 | | - |
| 964 | QVariant QSpinBoxPrivate::valueFromText(const QString &text) const | - |
| 965 | { | - |
| 966 | Q_Q(const QSpinBox); executed (the execution status of this line is deduced): const QSpinBox * const q = q_func(); | - |
| 967 | | - |
| 968 | return QVariant(q->valueFromText(text)); executed: return QVariant(q->valueFromText(text));Execution Count:74 | 74 |
| 969 | } | - |
| 970 | | - |
| 971 | | - |
| 972 | /*! | - |
| 973 | \internal Multi purpose function that parses input, sets state to | - |
| 974 | the appropriate state and returns the value it will be interpreted | - |
| 975 | as. | - |
| 976 | */ | - |
| 977 | | - |
| 978 | QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, | - |
| 979 | QValidator::State &state) const | - |
| 980 | { | - |
| 981 | if (cachedText == input && !input.isEmpty()) { evaluated: cachedText == input| yes Evaluation Count:456 | yes Evaluation Count:1018 |
evaluated: !input.isEmpty()| yes Evaluation Count:419 | yes Evaluation Count:37 |
| 37-1018 |
| 982 | state = cachedState; executed (the execution status of this line is deduced): state = cachedState; | - |
| 983 | QSBDEBUG() << "cachedText was '" << cachedText << "' state was " never executed: QMessageLogger("widgets/qspinbox.cpp", 983, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:419 |
| 0-419 |
| 984 | << state << " and value was " << cachedValue; never executed: QMessageLogger("widgets/qspinbox.cpp", 983, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue; | 0 |
| 985 | | - |
| 986 | return cachedValue; executed: return cachedValue;Execution Count:419 | 419 |
| 987 | } | - |
| 988 | const int max = maximum.toInt(); executed (the execution status of this line is deduced): const int max = maximum.toInt(); | - |
| 989 | const int min = minimum.toInt(); executed (the execution status of this line is deduced): const int min = minimum.toInt(); | - |
| 990 | | - |
| 991 | QString copy = stripped(input, &pos); executed (the execution status of this line is deduced): QString copy = stripped(input, &pos); | - |
| 992 | QSBDEBUG() << "input" << input << "copy" << copy; never executed: QMessageLogger("widgets/qspinbox.cpp", 992, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:1055 |
| 0-1055 |
| 993 | state = QValidator::Acceptable; executed (the execution status of this line is deduced): state = QValidator::Acceptable; | - |
| 994 | int num = min; executed (the execution status of this line is deduced): int num = min; | - |
| 995 | | - |
| 996 | if (max != min && (copy.isEmpty() evaluated: max != min| yes Evaluation Count:1046 | yes Evaluation Count:9 |
evaluated: copy.isEmpty()| yes Evaluation Count:46 | yes Evaluation Count:1000 |
| 9-1046 |
| 997 | || (min < 0 && copy == QLatin1String("-")) evaluated: min < 0| yes Evaluation Count:184 | yes Evaluation Count:816 |
evaluated: copy == QLatin1String("-")| yes Evaluation Count:11 | yes Evaluation Count:173 |
| 11-816 |
| 998 | || (min >= 0 && copy == QLatin1String("+")))) { evaluated: min >= 0| yes Evaluation Count:816 | yes Evaluation Count:173 |
partially evaluated: copy == QLatin1String("+")| no Evaluation Count:0 | yes Evaluation Count:816 |
| 0-816 |
| 999 | state = QValidator::Intermediate; executed (the execution status of this line is deduced): state = QValidator::Intermediate; | - |
| 1000 | QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num; never executed: QMessageLogger("widgets/qspinbox.cpp", 1000, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1000<< "num is set to" << num; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:57 |
| 0-57 |
| 1001 | } else if (copy.startsWith(QLatin1Char('-')) && min >= 0) { executed: }Execution Count:57 evaluated: copy.startsWith(QLatin1Char('-'))| yes Evaluation Count:59 | yes Evaluation Count:939 |
evaluated: min >= 0| yes Evaluation Count:2 | yes Evaluation Count:57 |
| 2-939 |
| 1002 | state = QValidator::Invalid; // special-case -0 will be interpreted as 0 and thus not be invalid with a range from 0-100 executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1003 | } else { executed: }Execution Count:2 | 2 |
| 1004 | bool ok = false; executed (the execution status of this line is deduced): bool ok = false; | - |
| 1005 | num = locale.toInt(copy, &ok); executed (the execution status of this line is deduced): num = locale.toInt(copy, &ok); | - |
| 1006 | if (!ok && copy.contains(locale.groupSeparator()) && (max >= 1000 || min <= -1000)) { evaluated: !ok| yes Evaluation Count:39 | yes Evaluation Count:957 |
evaluated: copy.contains(locale.groupSeparator())| yes Evaluation Count:1 | yes Evaluation Count:38 |
partially evaluated: max >= 1000| yes Evaluation Count:1 | no Evaluation Count:0 |
never evaluated: min <= -1000 | 0-957 |
| 1007 | QString copy2 = copy; executed (the execution status of this line is deduced): QString copy2 = copy; | - |
| 1008 | copy2.remove(locale.groupSeparator()); executed (the execution status of this line is deduced): copy2.remove(locale.groupSeparator()); | - |
| 1009 | num = locale.toInt(copy2, &ok); executed (the execution status of this line is deduced): num = locale.toInt(copy2, &ok); | - |
| 1010 | } executed: }Execution Count:1 | 1 |
| 1011 | QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num; never executed: QMessageLogger("widgets/qspinbox.cpp", 1011, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1011<< "num is set to" << num; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:996 |
| 0-996 |
| 1012 | if (!ok) { evaluated: !ok| yes Evaluation Count:38 | yes Evaluation Count:958 |
| 38-958 |
| 1013 | state = QValidator::Invalid; executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1014 | } else if (num >= min && num <= max) { executed: }Execution Count:38 evaluated: num >= min| yes Evaluation Count:935 | yes Evaluation Count:23 |
evaluated: num <= max| yes Evaluation Count:907 | yes Evaluation Count:28 |
| 23-935 |
| 1015 | state = QValidator::Acceptable; executed (the execution status of this line is deduced): state = QValidator::Acceptable; | - |
| 1016 | } else if (max == min) { executed: }Execution Count:907 partially evaluated: max == min| no Evaluation Count:0 | yes Evaluation Count:51 |
| 0-907 |
| 1017 | state = QValidator::Invalid; never executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1018 | } else { | 0 |
| 1019 | if ((num >= 0 && num > max) || (num < 0 && num < min)) { evaluated: num >= 0| yes Evaluation Count:28 | yes Evaluation Count:23 |
evaluated: num > max| yes Evaluation Count:8 | yes Evaluation Count:20 |
evaluated: num < 0| yes Evaluation Count:23 | yes Evaluation Count:20 |
evaluated: num < min| yes Evaluation Count:3 | yes Evaluation Count:20 |
| 3-28 |
| 1020 | state = QValidator::Invalid; executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1021 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1021, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1021<< "state is set to Invalid"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
| 1022 | } else { executed: }Execution Count:11 | 11 |
| 1023 | state = QValidator::Intermediate; executed (the execution status of this line is deduced): state = QValidator::Intermediate; | - |
| 1024 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Intermediate"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1024, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1024<< "state is set to Intermediate"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
| 1025 | } executed: }Execution Count:40 | 40 |
| 1026 | } | - |
| 1027 | } | - |
| 1028 | if (state != QValidator::Acceptable) evaluated: state != QValidator::Acceptable| yes Evaluation Count:148 | yes Evaluation Count:907 |
| 148-907 |
| 1029 | num = max > 0 ? min : max; executed: num = max > 0 ? min : max;Execution Count:148 evaluated: max > 0| yes Evaluation Count:82 | yes Evaluation Count:66 |
| 66-148 |
| 1030 | input = prefix + copy + suffix; executed (the execution status of this line is deduced): input = prefix + copy + suffix; | - |
| 1031 | cachedText = input; executed (the execution status of this line is deduced): cachedText = input; | - |
| 1032 | cachedState = state; executed (the execution status of this line is deduced): cachedState = state; | - |
| 1033 | cachedValue = QVariant((int)num); executed (the execution status of this line is deduced): cachedValue = QVariant((int)num); | - |
| 1034 | | - |
| 1035 | QSBDEBUG() << "cachedText is set to '" << cachedText << "' state is set to " never executed: QMessageLogger("widgets/qspinbox.cpp", 1035, __PRETTY_FUNCTION__).debug() << "cachedText is set to '" << cachedText << "' state is set to " << state << " and value is set to " << cachedValue; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:1055 |
| 0-1055 |
| 1036 | << state << " and value is set to " << cachedValue; never executed: QMessageLogger("widgets/qspinbox.cpp", 1035, __PRETTY_FUNCTION__).debug() << "cachedText is set to '" << cachedText << "' state is set to " << state << " and value is set to " << cachedValue; | 0 |
| 1037 | return cachedValue; executed: return cachedValue;Execution Count:1055 | 1055 |
| 1038 | } | - |
| 1039 | | - |
| 1040 | // --- QDoubleSpinBoxPrivate --- | - |
| 1041 | | - |
| 1042 | /*! | - |
| 1043 | \internal | - |
| 1044 | Constructs a QSpinBoxPrivate object | - |
| 1045 | */ | - |
| 1046 | | - |
| 1047 | QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate() | - |
| 1048 | { | - |
| 1049 | actualMin = 0.0; executed (the execution status of this line is deduced): actualMin = 0.0; | - |
| 1050 | actualMax = 99.99; executed (the execution status of this line is deduced): actualMax = 99.99; | - |
| 1051 | minimum = QVariant(actualMin); executed (the execution status of this line is deduced): minimum = QVariant(actualMin); | - |
| 1052 | maximum = QVariant(actualMax); executed (the execution status of this line is deduced): maximum = QVariant(actualMax); | - |
| 1053 | value = minimum; executed (the execution status of this line is deduced): value = minimum; | - |
| 1054 | singleStep = QVariant(1.0); executed (the execution status of this line is deduced): singleStep = QVariant(1.0); | - |
| 1055 | decimals = 2; executed (the execution status of this line is deduced): decimals = 2; | - |
| 1056 | type = QVariant::Double; executed (the execution status of this line is deduced): type = QVariant::Double; | - |
| 1057 | } executed: }Execution Count:182 | 182 |
| 1058 | | - |
| 1059 | /*! | - |
| 1060 | \internal | - |
| 1061 | \reimp | - |
| 1062 | */ | - |
| 1063 | | - |
| 1064 | void QDoubleSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) | - |
| 1065 | { | - |
| 1066 | Q_Q(QDoubleSpinBox); executed (the execution status of this line is deduced): QDoubleSpinBox * const q = q_func(); | - |
| 1067 | if (ep != NeverEmit) { partially evaluated: ep != NeverEmit| yes Evaluation Count:393 | no Evaluation Count:0 |
| 0-393 |
| 1068 | pendingEmit = false; executed (the execution status of this line is deduced): pendingEmit = false; | - |
| 1069 | if (ep == AlwaysEmit || value != old) { evaluated: ep == AlwaysEmit| yes Evaluation Count:10 | yes Evaluation Count:383 |
partially evaluated: value != old| yes Evaluation Count:383 | no Evaluation Count:0 |
| 0-383 |
| 1070 | emit q->valueChanged(edit->displayText()); executed (the execution status of this line is deduced): q->valueChanged(edit->displayText()); | - |
| 1071 | emit q->valueChanged(value.toDouble()); executed (the execution status of this line is deduced): q->valueChanged(value.toDouble()); | - |
| 1072 | } executed: }Execution Count:393 | 393 |
| 1073 | } executed: }Execution Count:393 | 393 |
| 1074 | } executed: }Execution Count:393 | 393 |
| 1075 | | - |
| 1076 | | - |
| 1077 | /*! | - |
| 1078 | \internal | - |
| 1079 | \reimp | - |
| 1080 | */ | - |
| 1081 | QVariant QDoubleSpinBoxPrivate::valueFromText(const QString &f) const | - |
| 1082 | { | - |
| 1083 | Q_Q(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBox * const q = q_func(); | - |
| 1084 | return QVariant(q->valueFromText(f)); executed: return QVariant(q->valueFromText(f));Execution Count:245 | 245 |
| 1085 | } | - |
| 1086 | | - |
| 1087 | /*! | - |
| 1088 | \internal | - |
| 1089 | Rounds to a double value that is restricted to decimals. | - |
| 1090 | E.g. // decimals = 2 | - |
| 1091 | | - |
| 1092 | round(5.555) => 5.56 | - |
| 1093 | */ | - |
| 1094 | | - |
| 1095 | double QDoubleSpinBoxPrivate::round(double value) const | - |
| 1096 | { | - |
| 1097 | return QString::number(value, 'f', decimals).toDouble(); executed: return QString::number(value, 'f', decimals).toDouble();Execution Count:666 | 666 |
| 1098 | } | - |
| 1099 | | - |
| 1100 | | - |
| 1101 | /*! | - |
| 1102 | \internal Multi purpose function that parses input, sets state to | - |
| 1103 | the appropriate state and returns the value it will be interpreted | - |
| 1104 | as. | - |
| 1105 | */ | - |
| 1106 | | - |
| 1107 | QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, | - |
| 1108 | QValidator::State &state) const | - |
| 1109 | { | - |
| 1110 | if (cachedText == input && !input.isEmpty()) { evaluated: cachedText == input| yes Evaluation Count:1831 | yes Evaluation Count:1143 |
evaluated: !input.isEmpty()| yes Evaluation Count:1730 | yes Evaluation Count:101 |
| 101-1831 |
| 1111 | state = cachedState; executed (the execution status of this line is deduced): state = cachedState; | - |
| 1112 | QSBDEBUG() << "cachedText was '" << cachedText << "' state was " never executed: QMessageLogger("widgets/qspinbox.cpp", 1112, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:1730 |
| 0-1730 |
| 1113 | << state << " and value was " << cachedValue; never executed: QMessageLogger("widgets/qspinbox.cpp", 1112, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue; | 0 |
| 1114 | return cachedValue; executed: return cachedValue;Execution Count:1730 | 1730 |
| 1115 | } | - |
| 1116 | const double max = maximum.toDouble(); executed (the execution status of this line is deduced): const double max = maximum.toDouble(); | - |
| 1117 | const double min = minimum.toDouble(); executed (the execution status of this line is deduced): const double min = minimum.toDouble(); | - |
| 1118 | | - |
| 1119 | QString copy = stripped(input, &pos); executed (the execution status of this line is deduced): QString copy = stripped(input, &pos); | - |
| 1120 | QSBDEBUG() << "input" << input << "copy" << copy; never executed: QMessageLogger("widgets/qspinbox.cpp", 1120, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:1244 |
| 0-1244 |
| 1121 | int len = copy.size(); executed (the execution status of this line is deduced): int len = copy.size(); | - |
| 1122 | double num = min; executed (the execution status of this line is deduced): double num = min; | - |
| 1123 | const bool plus = max >= 0; executed (the execution status of this line is deduced): const bool plus = max >= 0; | - |
| 1124 | const bool minus = min <= 0; executed (the execution status of this line is deduced): const bool minus = min <= 0; | - |
| 1125 | | - |
| 1126 | switch (len) { | - |
| 1127 | case 0: | - |
| 1128 | state = max != min ? QValidator::Intermediate : QValidator::Invalid; partially evaluated: max != min| yes Evaluation Count:122 | no Evaluation Count:0 |
| 0-122 |
| 1129 | goto end; executed: goto end;Execution Count:122 | 122 |
| 1130 | case 1: | - |
| 1131 | if (copy.at(0) == locale.decimalPoint() evaluated: copy.at(0) == locale.decimalPoint()| yes Evaluation Count:25 | yes Evaluation Count:243 |
| 25-243 |
| 1132 | || (plus && copy.at(0) == QLatin1Char('+')) evaluated: plus| yes Evaluation Count:204 | yes Evaluation Count:39 |
partially evaluated: copy.at(0) == QLatin1Char('+')| no Evaluation Count:0 | yes Evaluation Count:204 |
| 0-204 |
| 1133 | || (minus && copy.at(0) == QLatin1Char('-'))) { evaluated: minus| yes Evaluation Count:202 | yes Evaluation Count:41 |
evaluated: copy.at(0) == QLatin1Char('-')| yes Evaluation Count:41 | yes Evaluation Count:161 |
| 41-202 |
| 1134 | state = QValidator::Intermediate; executed (the execution status of this line is deduced): state = QValidator::Intermediate; | - |
| 1135 | goto end; executed: goto end;Execution Count:66 | 66 |
| 1136 | } | - |
| 1137 | break; executed: break;Execution Count:202 | 202 |
| 1138 | case 2: | - |
| 1139 | if (copy.at(1) == locale.decimalPoint() evaluated: copy.at(1) == locale.decimalPoint()| yes Evaluation Count:59 | yes Evaluation Count:94 |
| 59-94 |
| 1140 | && ((plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-')))) { partially evaluated: plus| yes Evaluation Count:59 | no Evaluation Count:0 |
partially evaluated: copy.at(0) == QLatin1Char('+')| no Evaluation Count:0 | yes Evaluation Count:59 |
evaluated: minus| yes Evaluation Count:44 | yes Evaluation Count:15 |
partially evaluated: copy.at(0) == QLatin1Char('-')| no Evaluation Count:0 | yes Evaluation Count:44 |
| 0-59 |
| 1141 | state = QValidator::Intermediate; never executed (the execution status of this line is deduced): state = QValidator::Intermediate; | - |
| 1142 | goto end; never executed: goto end; | 0 |
| 1143 | } | - |
| 1144 | break; executed: break;Execution Count:153 | 153 |
| 1145 | default: break; executed: break;Execution Count:701 | 701 |
| 1146 | } | - |
| 1147 | | - |
| 1148 | if (copy.at(0) == locale.groupSeparator()) { evaluated: copy.at(0) == locale.groupSeparator()| yes Evaluation Count:1 | yes Evaluation Count:1055 |
| 1-1055 |
| 1149 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1149, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1149<< "state is set to Invalid"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1150 | state = QValidator::Invalid; executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1151 | goto end; executed: goto end;Execution Count:1 | 1 |
| 1152 | } else if (len > 1) { evaluated: len > 1| yes Evaluation Count:854 | yes Evaluation Count:201 |
| 201-854 |
| 1153 | const int dec = copy.indexOf(locale.decimalPoint()); executed (the execution status of this line is deduced): const int dec = copy.indexOf(locale.decimalPoint()); | - |
| 1154 | if (dec != -1) { evaluated: dec != -1| yes Evaluation Count:719 | yes Evaluation Count:135 |
| 135-719 |
| 1155 | if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) { evaluated: dec + 1 < copy.size()| yes Evaluation Count:629 | yes Evaluation Count:90 |
evaluated: copy.at(dec + 1) == locale.decimalPoint()| yes Evaluation Count:1 | yes Evaluation Count:628 |
partially evaluated: pos == dec + 1| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-629 |
| 1156 | copy.remove(dec + 1, 1); // typing a delimiter when you are on the delimiter executed (the execution status of this line is deduced): copy.remove(dec + 1, 1); | - |
| 1157 | } // should be treated as typing right arrow executed: }Execution Count:1 | 1 |
| 1158 | | - |
| 1159 | if (copy.size() - dec > decimals + 1) { evaluated: copy.size() - dec > decimals + 1| yes Evaluation Count:15 | yes Evaluation Count:704 |
| 15-704 |
| 1160 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1160, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1160<< "state is set to Invalid"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
| 1161 | state = QValidator::Invalid; executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1162 | goto end; executed: goto end;Execution Count:15 | 15 |
| 1163 | } | - |
| 1164 | for (int i=dec + 1; i<copy.size(); ++i) { evaluated: i<copy.size()| yes Evaluation Count:3508 | yes Evaluation Count:704 |
| 704-3508 |
| 1165 | if (copy.at(i).isSpace() || copy.at(i) == locale.groupSeparator()) { partially evaluated: copy.at(i).isSpace()| no Evaluation Count:0 | yes Evaluation Count:3508 |
partially evaluated: copy.at(i) == locale.groupSeparator()| no Evaluation Count:0 | yes Evaluation Count:3508 |
| 0-3508 |
| 1166 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1166, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1166<< "state is set to Invalid"; never evaluated: false | 0 |
| 1167 | state = QValidator::Invalid; never executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1168 | goto end; never executed: goto end; | 0 |
| 1169 | } | - |
| 1170 | } executed: }Execution Count:3508 | 3508 |
| 1171 | } else { executed: }Execution Count:704 | 704 |
| 1172 | const QChar last = copy.at(len - 1); executed (the execution status of this line is deduced): const QChar last = copy.at(len - 1); | - |
| 1173 | const QChar secondLast = copy.at(len - 2); executed (the execution status of this line is deduced): const QChar secondLast = copy.at(len - 2); | - |
| 1174 | if ((last == locale.groupSeparator() || last.isSpace()) evaluated: last == locale.groupSeparator()| yes Evaluation Count:3 | yes Evaluation Count:132 |
partially evaluated: last.isSpace()| no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
| 1175 | && (secondLast == locale.groupSeparator() || secondLast.isSpace())) { partially evaluated: secondLast == locale.groupSeparator()| no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: secondLast.isSpace()| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 1176 | state = QValidator::Invalid; never executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1177 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1177, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1177<< "state is set to Invalid"; never evaluated: false | 0 |
| 1178 | goto end; never executed: goto end; | 0 |
| 1179 | } else if (last.isSpace() && (!locale.groupSeparator().isSpace() || secondLast.isSpace())) { partially evaluated: last.isSpace()| no Evaluation Count:0 | yes Evaluation Count:135 |
never evaluated: !locale.groupSeparator().isSpace() never evaluated: secondLast.isSpace() | 0-135 |
| 1180 | state = QValidator::Invalid; never executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1181 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1181, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1181<< "state is set to Invalid"; never evaluated: false | 0 |
| 1182 | goto end; never executed: goto end; | 0 |
| 1183 | } | - |
| 1184 | } | - |
| 1185 | } | - |
| 1186 | | - |
| 1187 | { | - |
| 1188 | bool ok = false; executed (the execution status of this line is deduced): bool ok = false; | - |
| 1189 | num = locale.toDouble(copy, &ok); executed (the execution status of this line is deduced): num = locale.toDouble(copy, &ok); | - |
| 1190 | QSBDEBUG() << __FILE__ << __LINE__ << locale << copy << num << ok; never executed: QMessageLogger("widgets/qspinbox.cpp", 1190, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1190 << locale << copy << num << ok; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:1040 |
| 0-1040 |
| 1191 | | - |
| 1192 | if (!ok) { evaluated: !ok| yes Evaluation Count:109 | yes Evaluation Count:931 |
| 109-931 |
| 1193 | if (locale.groupSeparator().isPrint()) { partially evaluated: locale.groupSeparator().isPrint()| yes Evaluation Count:109 | no Evaluation Count:0 |
| 0-109 |
| 1194 | if (max < 1000 && min > -1000 && copy.contains(locale.groupSeparator())) { evaluated: max < 1000| yes Evaluation Count:98 | yes Evaluation Count:11 |
partially evaluated: min > -1000| yes Evaluation Count:98 | no Evaluation Count:0 |
evaluated: copy.contains(locale.groupSeparator())| yes Evaluation Count:1 | yes Evaluation Count:97 |
| 0-98 |
| 1195 | state = QValidator::Invalid; executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1196 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1196, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1196<< "state is set to Invalid"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1197 | goto end; executed: goto end;Execution Count:1 | 1 |
| 1198 | } | - |
| 1199 | | - |
| 1200 | const int len = copy.size(); executed (the execution status of this line is deduced): const int len = copy.size(); | - |
| 1201 | for (int i=0; i<len- 1; ++i) { evaluated: i<len- 1| yes Evaluation Count:37 | yes Evaluation Count:107 |
| 37-107 |
| 1202 | if (copy.at(i) == locale.groupSeparator() && copy.at(i + 1) == locale.groupSeparator()) { evaluated: copy.at(i) == locale.groupSeparator()| yes Evaluation Count:7 | yes Evaluation Count:30 |
evaluated: copy.at(i + 1) == locale.groupSeparator()| yes Evaluation Count:1 | yes Evaluation Count:6 |
| 1-30 |
| 1203 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1203, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1203<< "state is set to Invalid"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1204 | state = QValidator::Invalid; executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1205 | goto end; executed: goto end;Execution Count:1 | 1 |
| 1206 | } | - |
| 1207 | } executed: }Execution Count:36 | 36 |
| 1208 | | - |
| 1209 | QString copy2 = copy; executed (the execution status of this line is deduced): QString copy2 = copy; | - |
| 1210 | copy2.remove(locale.groupSeparator()); executed (the execution status of this line is deduced): copy2.remove(locale.groupSeparator()); | - |
| 1211 | num = locale.toDouble(copy2, &ok); executed (the execution status of this line is deduced): num = locale.toDouble(copy2, &ok); | - |
| 1212 | QSBDEBUG() << locale.groupSeparator() << num << copy2 << ok; never executed: QMessageLogger("widgets/qspinbox.cpp", 1212, __PRETTY_FUNCTION__).debug() << locale.groupSeparator() << num << copy2 << ok; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:107 |
| 0-107 |
| 1213 | | - |
| 1214 | if (!ok) { evaluated: !ok| yes Evaluation Count:99 | yes Evaluation Count:8 |
| 8-99 |
| 1215 | state = QValidator::Invalid; executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1216 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1216, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1216<< "state is set to Invalid"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:99 |
| 0-99 |
| 1217 | goto end; executed: goto end;Execution Count:99 | 99 |
| 1218 | } | - |
| 1219 | } executed: }Execution Count:8 | 8 |
| 1220 | } executed: }Execution Count:8 | 8 |
| 1221 | | - |
| 1222 | if (!ok) { partially evaluated: !ok| no Evaluation Count:0 | yes Evaluation Count:939 |
| 0-939 |
| 1223 | state = QValidator::Invalid; never executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1224 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1224, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1224<< "state is set to Invalid"; never evaluated: false | 0 |
| 1225 | } else if (num >= min && num <= max) { never executed: } evaluated: num >= min| yes Evaluation Count:818 | yes Evaluation Count:121 |
evaluated: num <= max| yes Evaluation Count:744 | yes Evaluation Count:74 |
| 0-818 |
| 1226 | state = QValidator::Acceptable; executed (the execution status of this line is deduced): state = QValidator::Acceptable; | - |
| 1227 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Acceptable"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1227, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1227<< "state is set to Acceptable"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:744 |
| 0-744 |
| 1228 | } else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min) executed: }Execution Count:744 partially evaluated: max == min| no Evaluation Count:0 | yes Evaluation Count:195 |
| 0-744 |
| 1229 | state = QValidator::Invalid; never executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1230 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1230, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1230<< "state is set to Invalid"; never evaluated: false | 0 |
| 1231 | } else { | 0 |
| 1232 | if ((num >= 0 && num > max) || (num < 0 && num < min)) { evaluated: num >= 0| yes Evaluation Count:131 | yes Evaluation Count:64 |
evaluated: num > max| yes Evaluation Count:27 | yes Evaluation Count:104 |
evaluated: num < 0| yes Evaluation Count:64 | yes Evaluation Count:104 |
evaluated: num < min| yes Evaluation Count:17 | yes Evaluation Count:47 |
| 17-131 |
| 1233 | state = QValidator::Invalid; executed (the execution status of this line is deduced): state = QValidator::Invalid; | - |
| 1234 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1234, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1234<< "state is set to Invalid"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:44 |
| 0-44 |
| 1235 | } else { executed: }Execution Count:44 | 44 |
| 1236 | state = QValidator::Intermediate; executed (the execution status of this line is deduced): state = QValidator::Intermediate; | - |
| 1237 | QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Intermediate"; never executed: QMessageLogger("widgets/qspinbox.cpp", 1237, __PRETTY_FUNCTION__).debug() << "widgets/qspinbox.cpp" << 1237<< "state is set to Intermediate"; partially evaluated: false| no Evaluation Count:0 | yes Evaluation Count:151 |
| 0-151 |
| 1238 | } executed: }Execution Count:151 | 151 |
| 1239 | } | - |
| 1240 | } | - |
| 1241 | | - |
| 1242 | end: code before this statement executed: end:Execution Count:939 | 939 |
| 1243 | if (state != QValidator::Acceptable) { evaluated: state != QValidator::Acceptable| yes Evaluation Count:500 | yes Evaluation Count:744 |
| 500-744 |
| 1244 | num = max > 0 ? min : max; evaluated: max > 0| yes Evaluation Count:303 | yes Evaluation Count:197 |
| 197-303 |
| 1245 | } executed: }Execution Count:500 | 500 |
| 1246 | | - |
| 1247 | input = prefix + copy + suffix; executed (the execution status of this line is deduced): input = prefix + copy + suffix; | - |
| 1248 | cachedText = input; executed (the execution status of this line is deduced): cachedText = input; | - |
| 1249 | cachedState = state; executed (the execution status of this line is deduced): cachedState = state; | - |
| 1250 | cachedValue = QVariant(num); executed (the execution status of this line is deduced): cachedValue = QVariant(num); | - |
| 1251 | return QVariant(num); executed: return QVariant(num);Execution Count:1244 | 1244 |
| 1252 | } | - |
| 1253 | | - |
| 1254 | /* | - |
| 1255 | \internal | - |
| 1256 | \reimp | - |
| 1257 | */ | - |
| 1258 | | - |
| 1259 | QString QDoubleSpinBoxPrivate::textFromValue(const QVariant &f) const | - |
| 1260 | { | - |
| 1261 | Q_Q(const QDoubleSpinBox); executed (the execution status of this line is deduced): const QDoubleSpinBox * const q = q_func(); | - |
| 1262 | return q->textFromValue(f.toDouble()); executed: return q->textFromValue(f.toDouble());Execution Count:851 | 851 |
| 1263 | } | - |
| 1264 | | - |
| 1265 | /*! \reimp */ | - |
| 1266 | bool QSpinBox::event(QEvent *event) | - |
| 1267 | { | - |
| 1268 | Q_D(QSpinBox); executed (the execution status of this line is deduced): QSpinBoxPrivate * const d = d_func(); | - |
| 1269 | if (event->type() == QEvent::StyleChange evaluated: event->type() == QEvent::StyleChange| yes Evaluation Count:2 | yes Evaluation Count:1732 |
| 2-1732 |
| 1270 | #ifdef Q_OS_MAC | - |
| 1271 | || event->type() == QEvent::MacSizeChange | - |
| 1272 | #endif | - |
| 1273 | ) | - |
| 1274 | d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem); executed: d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);Execution Count:2 | 2 |
| 1275 | return QAbstractSpinBox::event(event); executed: return QAbstractSpinBox::event(event);Execution Count:1734 | 1734 |
| 1276 | } | - |
| 1277 | | - |
| 1278 | QT_END_NAMESPACE | - |
| 1279 | | - |
| 1280 | #endif // QT_NO_SPINBOX | - |
| 1281 | | - |
| | |