| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qspinbox.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | class QSpinBoxPrivate : public QAbstractSpinBoxPrivate | - | ||||||||||||||||||||||||
| 8 | { | - | ||||||||||||||||||||||||
| 9 | inline QSpinBox* q_func() { return static_cast<QSpinBox *>(q_ptr); } inline const QSpinBox* q_func() const { return static_cast<const QSpinBox *>(q_ptr); } friend class QSpinBox; | - | ||||||||||||||||||||||||
| 10 | public: | - | ||||||||||||||||||||||||
| 11 | QSpinBoxPrivate(); | - | ||||||||||||||||||||||||
| 12 | void emitSignals(EmitPolicy ep, const QVariant &) override; | - | ||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | virtual QVariant valueFromText(const QString &n) const override; | - | ||||||||||||||||||||||||
| 15 | virtual QString textFromValue(const QVariant &n) const override; | - | ||||||||||||||||||||||||
| 16 | QVariant validateAndInterpret(QString &input, int &pos, | - | ||||||||||||||||||||||||
| 17 | QValidator::State &state) const; | - | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | inline void init() { | - | ||||||||||||||||||||||||
| 20 | QSpinBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 21 | q->setInputMethodHints(Qt::ImhDigitsOnly); | - | ||||||||||||||||||||||||
| 22 | setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem); | - | ||||||||||||||||||||||||
| 23 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | int displayIntegerBase; | - | ||||||||||||||||||||||||
| 26 | }; | - | ||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | class QDoubleSpinBoxPrivate : public QAbstractSpinBoxPrivate | - | ||||||||||||||||||||||||
| 29 | { | - | ||||||||||||||||||||||||
| 30 | inline QDoubleSpinBox* q_func() { return static_cast<QDoubleSpinBox *>(q_ptr); } inline const QDoubleSpinBox* q_func() const { return static_cast<const QDoubleSpinBox *>(q_ptr); } friend class QDoubleSpinBox; | - | ||||||||||||||||||||||||
| 31 | public: | - | ||||||||||||||||||||||||
| 32 | QDoubleSpinBoxPrivate(); | - | ||||||||||||||||||||||||
| 33 | void emitSignals(EmitPolicy ep, const QVariant &) override; | - | ||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||
| 35 | virtual QVariant valueFromText(const QString &n) const override; | - | ||||||||||||||||||||||||
| 36 | virtual QString textFromValue(const QVariant &n) const override; | - | ||||||||||||||||||||||||
| 37 | QVariant validateAndInterpret(QString &input, int &pos, | - | ||||||||||||||||||||||||
| 38 | QValidator::State &state) const; | - | ||||||||||||||||||||||||
| 39 | double round(double input) const; | - | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | int decimals; | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | inline void init() { | - | ||||||||||||||||||||||||
| 44 | QDoubleSpinBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 45 | q->setInputMethodHints(Qt::ImhFormattedNumbersOnly); | - | ||||||||||||||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | double actualMin; | - | ||||||||||||||||||||||||
| 50 | double actualMax; | - | ||||||||||||||||||||||||
| 51 | }; | - | ||||||||||||||||||||||||
| 52 | QSpinBox::QSpinBox(QWidget *parent) | - | ||||||||||||||||||||||||
| 53 | : QAbstractSpinBox(*new QSpinBoxPrivate, parent) | - | ||||||||||||||||||||||||
| 54 | { | - | ||||||||||||||||||||||||
| 55 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 56 | d->init(); | - | ||||||||||||||||||||||||
| 57 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | QSpinBox::~QSpinBox() {} | - | ||||||||||||||||||||||||
| 63 | int QSpinBox::value() const | - | ||||||||||||||||||||||||
| 64 | { | - | ||||||||||||||||||||||||
| 65 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 66 | return never executed: d->value.toInt();return d->value.toInt();never executed: return d->value.toInt(); | 0 | ||||||||||||||||||||||||
| 67 | } | - | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | void QSpinBox::setValue(int value) | - | ||||||||||||||||||||||||
| 70 | { | - | ||||||||||||||||||||||||
| 71 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 72 | d->setValue(QVariant(value), EmitIfChanged); | - | ||||||||||||||||||||||||
| 73 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 74 | QString QSpinBox::prefix() const | - | ||||||||||||||||||||||||
| 75 | { | - | ||||||||||||||||||||||||
| 76 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 77 | return never executed: d->prefix;return d->prefix;never executed: return d->prefix; | 0 | ||||||||||||||||||||||||
| 78 | } | - | ||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | void QSpinBox::setPrefix(const QString &prefix) | - | ||||||||||||||||||||||||
| 81 | { | - | ||||||||||||||||||||||||
| 82 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||
| 84 | d->prefix = prefix; | - | ||||||||||||||||||||||||
| 85 | d->updateEdit(); | - | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | d->cachedSizeHint = QSize(); | - | ||||||||||||||||||||||||
| 88 | d->cachedMinimumSizeHint = QSize(); | - | ||||||||||||||||||||||||
| 89 | updateGeometry(); | - | ||||||||||||||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 91 | QString QSpinBox::suffix() const | - | ||||||||||||||||||||||||
| 92 | { | - | ||||||||||||||||||||||||
| 93 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||
| 95 | return never executed: d->suffix;return d->suffix;never executed: return d->suffix; | 0 | ||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | void QSpinBox::setSuffix(const QString &suffix) | - | ||||||||||||||||||||||||
| 99 | { | - | ||||||||||||||||||||||||
| 100 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||
| 102 | d->suffix = suffix; | - | ||||||||||||||||||||||||
| 103 | d->updateEdit(); | - | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | d->cachedSizeHint = QSize(); | - | ||||||||||||||||||||||||
| 106 | updateGeometry(); | - | ||||||||||||||||||||||||
| 107 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 108 | QString QSpinBox::cleanText() const | - | ||||||||||||||||||||||||
| 109 | { | - | ||||||||||||||||||||||||
| 110 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | return never executed: d->stripped(d->edit->displayText());return d->stripped(d->edit->displayText());never executed: return d->stripped(d->edit->displayText()); | 0 | ||||||||||||||||||||||||
| 113 | } | - | ||||||||||||||||||||||||
| 114 | int QSpinBox::singleStep() const | - | ||||||||||||||||||||||||
| 115 | { | - | ||||||||||||||||||||||||
| 116 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | return never executed: d->singleStep.toInt();return d->singleStep.toInt();never executed: return d->singleStep.toInt(); | 0 | ||||||||||||||||||||||||
| 119 | } | - | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | void QSpinBox::setSingleStep(int value) | - | ||||||||||||||||||||||||
| 122 | { | - | ||||||||||||||||||||||||
| 123 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 124 | if (value >= 0
| 0 | ||||||||||||||||||||||||
| 125 | d->singleStep = QVariant(value); | - | ||||||||||||||||||||||||
| 126 | d->updateEdit(); | - | ||||||||||||||||||||||||
| 127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 128 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 129 | int QSpinBox::minimum() const | - | ||||||||||||||||||||||||
| 130 | { | - | ||||||||||||||||||||||||
| 131 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | return never executed: d->minimum.toInt();return d->minimum.toInt();never executed: return d->minimum.toInt(); | 0 | ||||||||||||||||||||||||
| 134 | } | - | ||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | void QSpinBox::setMinimum(int minimum) | - | ||||||||||||||||||||||||
| 137 | { | - | ||||||||||||||||||||||||
| 138 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 139 | const QVariant m(minimum); | - | ||||||||||||||||||||||||
| 140 | d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); | - | ||||||||||||||||||||||||
| 141 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 142 | int QSpinBox::maximum() const | - | ||||||||||||||||||||||||
| 143 | { | - | ||||||||||||||||||||||||
| 144 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | return never executed: d->maximum.toInt();return d->maximum.toInt();never executed: return d->maximum.toInt(); | 0 | ||||||||||||||||||||||||
| 147 | } | - | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | void QSpinBox::setMaximum(int maximum) | - | ||||||||||||||||||||||||
| 150 | { | - | ||||||||||||||||||||||||
| 151 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 152 | const QVariant m(maximum); | - | ||||||||||||||||||||||||
| 153 | d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); | - | ||||||||||||||||||||||||
| 154 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 155 | void QSpinBox::setRange(int minimum, int maximum) | - | ||||||||||||||||||||||||
| 156 | { | - | ||||||||||||||||||||||||
| 157 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 158 | d->setRange(QVariant(minimum), QVariant(maximum)); | - | ||||||||||||||||||||||||
| 159 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 160 | int QSpinBox::displayIntegerBase() const | - | ||||||||||||||||||||||||
| 161 | { | - | ||||||||||||||||||||||||
| 162 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 163 | return never executed: d->displayIntegerBase;return d->displayIntegerBase;never executed: return d->displayIntegerBase; | 0 | ||||||||||||||||||||||||
| 164 | } | - | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | void QSpinBox::setDisplayIntegerBase(int base) | - | ||||||||||||||||||||||||
| 167 | { | - | ||||||||||||||||||||||||
| 168 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | if (__builtin_expect(!!(base < 2 || base > 36), false)
| 0 | ||||||||||||||||||||||||
| 171 | QMessageLogger(__FILE__, 448, __PRETTY_FUNCTION__).warning("QSpinBox::setDisplayIntegerBase: Invalid base (%d)", base); | - | ||||||||||||||||||||||||
| 172 | base = 10; | - | ||||||||||||||||||||||||
| 173 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||
| 175 | if (base != d->displayIntegerBase
| 0 | ||||||||||||||||||||||||
| 176 | d->displayIntegerBase = base; | - | ||||||||||||||||||||||||
| 177 | d->updateEdit(); | - | ||||||||||||||||||||||||
| 178 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 179 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 180 | QString QSpinBox::textFromValue(int value) const | - | ||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||
| 182 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 183 | QString str; | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | if (d->displayIntegerBase != 10
| 0 | ||||||||||||||||||||||||
| 186 | const QLatin1String prefix = value < 0
| 0 | ||||||||||||||||||||||||
| 187 | str = prefix + QString::number(qAbs(value), d->displayIntegerBase); | - | ||||||||||||||||||||||||
| 188 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 189 | str = locale().toString(value); | - | ||||||||||||||||||||||||
| 190 | if (!d->showGroupSeparator
| 0 | ||||||||||||||||||||||||
| 191 | str.remove(locale().groupSeparator()); | - | ||||||||||||||||||||||||
| 192 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 193 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||
| 195 | return never executed: str;return str;never executed: return str; | 0 | ||||||||||||||||||||||||
| 196 | } | - | ||||||||||||||||||||||||
| 197 | int QSpinBox::valueFromText(const QString &text) const | - | ||||||||||||||||||||||||
| 198 | { | - | ||||||||||||||||||||||||
| 199 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||
| 201 | QString copy = text; | - | ||||||||||||||||||||||||
| 202 | int pos = d->edit->cursorPosition(); | - | ||||||||||||||||||||||||
| 203 | QValidator::State state = QValidator::Acceptable; | - | ||||||||||||||||||||||||
| 204 | return never executed: d->validateAndInterpret(copy, pos, state).toInt();return d->validateAndInterpret(copy, pos, state).toInt();never executed: return d->validateAndInterpret(copy, pos, state).toInt(); | 0 | ||||||||||||||||||||||||
| 205 | } | - | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||
| 210 | QValidator::State QSpinBox::validate(QString &text, int &pos) const | - | ||||||||||||||||||||||||
| 211 | { | - | ||||||||||||||||||||||||
| 212 | const QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | QValidator::State state; | - | ||||||||||||||||||||||||
| 215 | d->validateAndInterpret(text, pos, state); | - | ||||||||||||||||||||||||
| 216 | return never executed: state;return state;never executed: return state; | 0 | ||||||||||||||||||||||||
| 217 | } | - | ||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||
| 223 | void QSpinBox::fixup(QString &input) const | - | ||||||||||||||||||||||||
| 224 | { | - | ||||||||||||||||||||||||
| 225 | if (!isGroupSeparatorShown()
| 0 | ||||||||||||||||||||||||
| 226 | input.remove(locale().groupSeparator()); never executed: input.remove(locale().groupSeparator()); | 0 | ||||||||||||||||||||||||
| 227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 228 | QDoubleSpinBox::QDoubleSpinBox(QWidget *parent) | - | ||||||||||||||||||||||||
| 229 | : QAbstractSpinBox(*new QDoubleSpinBoxPrivate, parent) | - | ||||||||||||||||||||||||
| 230 | { | - | ||||||||||||||||||||||||
| 231 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 232 | d->init(); | - | ||||||||||||||||||||||||
| 233 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | QDoubleSpinBox::~QDoubleSpinBox() {} | - | ||||||||||||||||||||||||
| 239 | double QDoubleSpinBox::value() const | - | ||||||||||||||||||||||||
| 240 | { | - | ||||||||||||||||||||||||
| 241 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||
| 243 | return never executed: d->value.toDouble();return d->value.toDouble();never executed: return d->value.toDouble(); | 0 | ||||||||||||||||||||||||
| 244 | } | - | ||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||
| 246 | void QDoubleSpinBox::setValue(double value) | - | ||||||||||||||||||||||||
| 247 | { | - | ||||||||||||||||||||||||
| 248 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 249 | QVariant v(d->round(value)); | - | ||||||||||||||||||||||||
| 250 | d->setValue(v, EmitIfChanged); | - | ||||||||||||||||||||||||
| 251 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 252 | QString QDoubleSpinBox::prefix() const | - | ||||||||||||||||||||||||
| 253 | { | - | ||||||||||||||||||||||||
| 254 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | return never executed: d->prefix;return d->prefix;never executed: return d->prefix; | 0 | ||||||||||||||||||||||||
| 257 | } | - | ||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | void QDoubleSpinBox::setPrefix(const QString &prefix) | - | ||||||||||||||||||||||||
| 260 | { | - | ||||||||||||||||||||||||
| 261 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||
| 263 | d->prefix = prefix; | - | ||||||||||||||||||||||||
| 264 | d->updateEdit(); | - | ||||||||||||||||||||||||
| 265 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 266 | QString QDoubleSpinBox::suffix() const | - | ||||||||||||||||||||||||
| 267 | { | - | ||||||||||||||||||||||||
| 268 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | return never executed: d->suffix;return d->suffix;never executed: return d->suffix; | 0 | ||||||||||||||||||||||||
| 271 | } | - | ||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||
| 273 | void QDoubleSpinBox::setSuffix(const QString &suffix) | - | ||||||||||||||||||||||||
| 274 | { | - | ||||||||||||||||||||||||
| 275 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||
| 277 | d->suffix = suffix; | - | ||||||||||||||||||||||||
| 278 | d->updateEdit(); | - | ||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | d->cachedSizeHint = QSize(); | - | ||||||||||||||||||||||||
| 281 | updateGeometry(); | - | ||||||||||||||||||||||||
| 282 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 283 | QString QDoubleSpinBox::cleanText() const | - | ||||||||||||||||||||||||
| 284 | { | - | ||||||||||||||||||||||||
| 285 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | return never executed: d->stripped(d->edit->displayText());return d->stripped(d->edit->displayText());never executed: return d->stripped(d->edit->displayText()); | 0 | ||||||||||||||||||||||||
| 288 | } | - | ||||||||||||||||||||||||
| 289 | double QDoubleSpinBox::singleStep() const | - | ||||||||||||||||||||||||
| 290 | { | - | ||||||||||||||||||||||||
| 291 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | return never executed: d->singleStep.toDouble();return d->singleStep.toDouble();never executed: return d->singleStep.toDouble(); | 0 | ||||||||||||||||||||||||
| 294 | } | - | ||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||
| 296 | void QDoubleSpinBox::setSingleStep(double value) | - | ||||||||||||||||||||||||
| 297 | { | - | ||||||||||||||||||||||||
| 298 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | if (value >= 0
| 0 | ||||||||||||||||||||||||
| 301 | d->singleStep = value; | - | ||||||||||||||||||||||||
| 302 | d->updateEdit(); | - | ||||||||||||||||||||||||
| 303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 304 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 305 | double QDoubleSpinBox::minimum() const | - | ||||||||||||||||||||||||
| 306 | { | - | ||||||||||||||||||||||||
| 307 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||
| 309 | return never executed: d->minimum.toDouble();return d->minimum.toDouble();never executed: return d->minimum.toDouble(); | 0 | ||||||||||||||||||||||||
| 310 | } | - | ||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||
| 312 | void QDoubleSpinBox::setMinimum(double minimum) | - | ||||||||||||||||||||||||
| 313 | { | - | ||||||||||||||||||||||||
| 314 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 315 | d->actualMin = minimum; | - | ||||||||||||||||||||||||
| 316 | const QVariant m(d->round(minimum)); | - | ||||||||||||||||||||||||
| 317 | d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); | - | ||||||||||||||||||||||||
| 318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 319 | double QDoubleSpinBox::maximum() const | - | ||||||||||||||||||||||||
| 320 | { | - | ||||||||||||||||||||||||
| 321 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||
| 323 | return never executed: d->maximum.toDouble();return d->maximum.toDouble();never executed: return d->maximum.toDouble(); | 0 | ||||||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | void QDoubleSpinBox::setMaximum(double maximum) | - | ||||||||||||||||||||||||
| 327 | { | - | ||||||||||||||||||||||||
| 328 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 329 | d->actualMax = maximum; | - | ||||||||||||||||||||||||
| 330 | const QVariant m(d->round(maximum)); | - | ||||||||||||||||||||||||
| 331 | d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); | - | ||||||||||||||||||||||||
| 332 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 333 | void QDoubleSpinBox::setRange(double minimum, double maximum) | - | ||||||||||||||||||||||||
| 334 | { | - | ||||||||||||||||||||||||
| 335 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 336 | d->actualMin = minimum; | - | ||||||||||||||||||||||||
| 337 | d->actualMax = maximum; | - | ||||||||||||||||||||||||
| 338 | d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum))); | - | ||||||||||||||||||||||||
| 339 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 340 | int QDoubleSpinBox::decimals() const | - | ||||||||||||||||||||||||
| 341 | { | - | ||||||||||||||||||||||||
| 342 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | return never executed: d->decimals;return d->decimals;never executed: return d->decimals; | 0 | ||||||||||||||||||||||||
| 345 | } | - | ||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||
| 347 | void QDoubleSpinBox::setDecimals(int decimals) | - | ||||||||||||||||||||||||
| 348 | { | - | ||||||||||||||||||||||||
| 349 | QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 350 | d->decimals = qBound(0, decimals, 308 + 15); | - | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | setRange(d->actualMin, d->actualMax); | - | ||||||||||||||||||||||||
| 353 | setValue(value()); | - | ||||||||||||||||||||||||
| 354 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 355 | QString QDoubleSpinBox::textFromValue(double value) const | - | ||||||||||||||||||||||||
| 356 | { | - | ||||||||||||||||||||||||
| 357 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 358 | QString str = locale().toString(value, 'f', d->decimals); | - | ||||||||||||||||||||||||
| 359 | if (!d->showGroupSeparator
| 0 | ||||||||||||||||||||||||
| 360 | str.remove(locale().groupSeparator()); never executed: str.remove(locale().groupSeparator()); | 0 | ||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||
| 362 | return never executed: str;return str;never executed: return str; | 0 | ||||||||||||||||||||||||
| 363 | } | - | ||||||||||||||||||||||||
| 364 | double QDoubleSpinBox::valueFromText(const QString &text) const | - | ||||||||||||||||||||||||
| 365 | { | - | ||||||||||||||||||||||||
| 366 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | QString copy = text; | - | ||||||||||||||||||||||||
| 369 | int pos = d->edit->cursorPosition(); | - | ||||||||||||||||||||||||
| 370 | QValidator::State state = QValidator::Acceptable; | - | ||||||||||||||||||||||||
| 371 | return never executed: d->validateAndInterpret(copy, pos, state).toDouble();return d->validateAndInterpret(copy, pos, state).toDouble();never executed: return d->validateAndInterpret(copy, pos, state).toDouble(); | 0 | ||||||||||||||||||||||||
| 372 | } | - | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||
| 377 | QValidator::State QDoubleSpinBox::validate(QString &text, int &pos) const | - | ||||||||||||||||||||||||
| 378 | { | - | ||||||||||||||||||||||||
| 379 | const QDoubleSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||
| 381 | QValidator::State state; | - | ||||||||||||||||||||||||
| 382 | d->validateAndInterpret(text, pos, state); | - | ||||||||||||||||||||||||
| 383 | return never executed: state;return state;never executed: return state; | 0 | ||||||||||||||||||||||||
| 384 | } | - | ||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | void QDoubleSpinBox::fixup(QString &input) const | - | ||||||||||||||||||||||||
| 391 | { | - | ||||||||||||||||||||||||
| 392 | input.remove(locale().groupSeparator()); | - | ||||||||||||||||||||||||
| 393 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 394 | QSpinBoxPrivate::QSpinBoxPrivate() | - | ||||||||||||||||||||||||
| 395 | { | - | ||||||||||||||||||||||||
| 396 | minimum = QVariant((int)0); | - | ||||||||||||||||||||||||
| 397 | maximum = QVariant((int)99); | - | ||||||||||||||||||||||||
| 398 | value = minimum; | - | ||||||||||||||||||||||||
| 399 | displayIntegerBase = 10; | - | ||||||||||||||||||||||||
| 400 | singleStep = QVariant((int)1); | - | ||||||||||||||||||||||||
| 401 | type = QVariant::Int; | - | ||||||||||||||||||||||||
| 402 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | - | |||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | void QSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) | - | ||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||
| 411 | QSpinBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 412 | if (ep != NeverEmit
| 0 | ||||||||||||||||||||||||
| 413 | pendingEmit = false; | - | ||||||||||||||||||||||||
| 414 | if (ep == AlwaysEmit
| 0 | ||||||||||||||||||||||||
| 415 | q->valueChanged(edit->displayText()); | - | ||||||||||||||||||||||||
| 416 | q->valueChanged(value.toInt()); | - | ||||||||||||||||||||||||
| 417 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 418 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 419 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | - | |||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | QString QSpinBoxPrivate::textFromValue(const QVariant &value) const | - | ||||||||||||||||||||||||
| 427 | { | - | ||||||||||||||||||||||||
| 428 | const QSpinBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 429 | return never executed: q->textFromValue(value.toInt());return q->textFromValue(value.toInt());never executed: return q->textFromValue(value.toInt()); | 0 | ||||||||||||||||||||||||
| 430 | } | - | ||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | QVariant QSpinBoxPrivate::valueFromText(const QString &text) const | - | ||||||||||||||||||||||||
| 437 | { | - | ||||||||||||||||||||||||
| 438 | const QSpinBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | return never executed: QVariant(q->valueFromText(text));return QVariant(q->valueFromText(text));never executed: return QVariant(q->valueFromText(text)); | 0 | ||||||||||||||||||||||||
| 441 | } | - | ||||||||||||||||||||||||
| 442 | QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, | - | ||||||||||||||||||||||||
| 443 | QValidator::State &state) const | - | ||||||||||||||||||||||||
| 444 | { | - | ||||||||||||||||||||||||
| 445 | if (cachedText == input
| 0 | ||||||||||||||||||||||||
| 446 | state = cachedState; | - | ||||||||||||||||||||||||
| 447 | if (false) QMessageLogger(__FILE__, 1029, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " dead code: QMessageLogger(__FILE__, 1029, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue; | - | ||||||||||||||||||||||||
| 448 | << state << " and value was " << cachedValue; dead code: QMessageLogger(__FILE__, 1029, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue; | - | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | return never executed: cachedValue;return cachedValue;never executed: return cachedValue; | 0 | ||||||||||||||||||||||||
| 451 | } | - | ||||||||||||||||||||||||
| 452 | const int max = maximum.toInt(); | - | ||||||||||||||||||||||||
| 453 | const int min = minimum.toInt(); | - | ||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | QString copy = stripped(input, &pos); | - | ||||||||||||||||||||||||
| 456 | if (false) QMessageLogger(__FILE__, 1038, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy; dead code: QMessageLogger(__FILE__, 1038, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy; | - | ||||||||||||||||||||||||
| 457 | state = QValidator::Acceptable; | - | ||||||||||||||||||||||||
| 458 | int num = min; | - | ||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | if (max != min
| 0 | ||||||||||||||||||||||||
| 461 | || (min < 0
| 0 | ||||||||||||||||||||||||
| 462 | || (max >= 0
| 0 | ||||||||||||||||||||||||
| 463 | state = QValidator::Intermediate; | - | ||||||||||||||||||||||||
| 464 | if (false) QMessageLogger(__FILE__, 1046, __PRETTY_FUNCTION__).debug() << __FILE__ << 1046<< "num is set to" << num; dead code: QMessageLogger(__FILE__, 1046, __PRETTY_FUNCTION__).debug() << __FILE__ << 1046<< "num is set to" << num; | - | ||||||||||||||||||||||||
| 465 | } never executed: else if (copy.startsWith(QLatin1Char('-'))end of block
| 0 | ||||||||||||||||||||||||
| 466 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 467 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 468 | bool ok = false; | - | ||||||||||||||||||||||||
| 469 | if (displayIntegerBase != 10
| 0 | ||||||||||||||||||||||||
| 470 | num = copy.toInt(&ok, displayIntegerBase); | - | ||||||||||||||||||||||||
| 471 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 472 | num = locale.toInt(copy, &ok); | - | ||||||||||||||||||||||||
| 473 | if (!ok
| 0 | ||||||||||||||||||||||||
| 474 | QString copy2 = copy; | - | ||||||||||||||||||||||||
| 475 | copy2.remove(locale.groupSeparator()); | - | ||||||||||||||||||||||||
| 476 | num = locale.toInt(copy2, &ok); | - | ||||||||||||||||||||||||
| 477 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 478 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 479 | if (false) QMessageLogger(__FILE__, 1061, __PRETTY_FUNCTION__).debug() << __FILE__ << 1061<< "num is set to" << num; dead code: QMessageLogger(__FILE__, 1061, __PRETTY_FUNCTION__).debug() << __FILE__ << 1061<< "num is set to" << num; | - | ||||||||||||||||||||||||
| 480 | if (!ok
| 0 | ||||||||||||||||||||||||
| 481 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 482 | } never executed: else if (num >= minend of block
| 0 | ||||||||||||||||||||||||
| 483 | state = QValidator::Acceptable; | - | ||||||||||||||||||||||||
| 484 | } never executed: else if (max == minend of block
| 0 | ||||||||||||||||||||||||
| 485 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 486 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 487 | if ((num >= 0
| 0 | ||||||||||||||||||||||||
| 488 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 489 | if (false) QMessageLogger(__FILE__, 1071, __PRETTY_FUNCTION__).debug() << __FILE__ << 1071<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1071, __PRETTY_FUNCTION__).debug() << __FILE__ << 1071<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 490 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 491 | state = QValidator::Intermediate; | - | ||||||||||||||||||||||||
| 492 | if (false) QMessageLogger(__FILE__, 1074, __PRETTY_FUNCTION__).debug() << __FILE__ << 1074<< "state is set to Intermediate"; dead code: QMessageLogger(__FILE__, 1074, __PRETTY_FUNCTION__).debug() << __FILE__ << 1074<< "state is set to Intermediate"; | - | ||||||||||||||||||||||||
| 493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 494 | } | - | ||||||||||||||||||||||||
| 495 | } | - | ||||||||||||||||||||||||
| 496 | if (state != QValidator::Acceptable
| 0 | ||||||||||||||||||||||||
| 497 | num = max > 0
never executed: num = max > 0 ? min : max; | 0 | ||||||||||||||||||||||||
| 498 | input = prefix + copy + suffix; | - | ||||||||||||||||||||||||
| 499 | cachedText = input; | - | ||||||||||||||||||||||||
| 500 | cachedState = state; | - | ||||||||||||||||||||||||
| 501 | cachedValue = QVariant((int)num); | - | ||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||
| 503 | if (false) QMessageLogger(__FILE__, 1085, __PRETTY_FUNCTION__).debug() << "cachedText is set to '" << cachedText << "' state is set to " dead code: QMessageLogger(__FILE__, 1085, __PRETTY_FUNCTION__).debug() << "cachedText is set to '" << cachedText << "' state is set to " << state << " and value is set to " << cachedValue; | - | ||||||||||||||||||||||||
| 504 | << state << " and value is set to " << cachedValue; dead code: QMessageLogger(__FILE__, 1085, __PRETTY_FUNCTION__).debug() << "cachedText is set to '" << cachedText << "' state is set to " << state << " and value is set to " << cachedValue; | - | ||||||||||||||||||||||||
| 505 | return never executed: cachedValue;return cachedValue;never executed: return cachedValue; | 0 | ||||||||||||||||||||||||
| 506 | } | - | ||||||||||||||||||||||||
| 507 | QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate() | - | ||||||||||||||||||||||||
| 508 | { | - | ||||||||||||||||||||||||
| 509 | actualMin = 0.0; | - | ||||||||||||||||||||||||
| 510 | actualMax = 99.99; | - | ||||||||||||||||||||||||
| 511 | minimum = QVariant(actualMin); | - | ||||||||||||||||||||||||
| 512 | maximum = QVariant(actualMax); | - | ||||||||||||||||||||||||
| 513 | value = minimum; | - | ||||||||||||||||||||||||
| 514 | singleStep = QVariant(1.0); | - | ||||||||||||||||||||||||
| 515 | decimals = 2; | - | ||||||||||||||||||||||||
| 516 | type = QVariant::Double; | - | ||||||||||||||||||||||||
| 517 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | void QDoubleSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) | - | ||||||||||||||||||||||||
| 525 | { | - | ||||||||||||||||||||||||
| 526 | QDoubleSpinBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 527 | if (ep != NeverEmit
| 0 | ||||||||||||||||||||||||
| 528 | pendingEmit = false; | - | ||||||||||||||||||||||||
| 529 | if (ep == AlwaysEmit
| 0 | ||||||||||||||||||||||||
| 530 | q->valueChanged(edit->displayText()); | - | ||||||||||||||||||||||||
| 531 | q->valueChanged(value.toDouble()); | - | ||||||||||||||||||||||||
| 532 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 533 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 534 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||
| 541 | QVariant QDoubleSpinBoxPrivate::valueFromText(const QString &f) const | - | ||||||||||||||||||||||||
| 542 | { | - | ||||||||||||||||||||||||
| 543 | const QDoubleSpinBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 544 | return never executed: QVariant(q->valueFromText(f));return QVariant(q->valueFromText(f));never executed: return QVariant(q->valueFromText(f)); | 0 | ||||||||||||||||||||||||
| 545 | } | - | ||||||||||||||||||||||||
| 546 | double QDoubleSpinBoxPrivate::round(double value) const | - | ||||||||||||||||||||||||
| 547 | { | - | ||||||||||||||||||||||||
| 548 | return never executed: QString::number(value, 'f', decimals).toDouble();return QString::number(value, 'f', decimals).toDouble();never executed: return QString::number(value, 'f', decimals).toDouble(); | 0 | ||||||||||||||||||||||||
| 549 | } | - | ||||||||||||||||||||||||
| 550 | QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, | - | ||||||||||||||||||||||||
| 551 | QValidator::State &state) const | - | ||||||||||||||||||||||||
| 552 | { | - | ||||||||||||||||||||||||
| 553 | if (cachedText == input
| 0 | ||||||||||||||||||||||||
| 554 | state = cachedState; | - | ||||||||||||||||||||||||
| 555 | if (false) QMessageLogger(__FILE__, 1162, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " dead code: QMessageLogger(__FILE__, 1162, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue; | - | ||||||||||||||||||||||||
| 556 | << state << " and value was " << cachedValue; dead code: QMessageLogger(__FILE__, 1162, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue; | - | ||||||||||||||||||||||||
| 557 | return never executed: cachedValue;return cachedValue;never executed: return cachedValue; | 0 | ||||||||||||||||||||||||
| 558 | } | - | ||||||||||||||||||||||||
| 559 | const double max = maximum.toDouble(); | - | ||||||||||||||||||||||||
| 560 | const double min = minimum.toDouble(); | - | ||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||
| 562 | QString copy = stripped(input, &pos); | - | ||||||||||||||||||||||||
| 563 | if (false) QMessageLogger(__FILE__, 1170, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy; dead code: QMessageLogger(__FILE__, 1170, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy; | - | ||||||||||||||||||||||||
| 564 | int len = copy.size(); | - | ||||||||||||||||||||||||
| 565 | double num = min; | - | ||||||||||||||||||||||||
| 566 | const bool plus = max >= 0; | - | ||||||||||||||||||||||||
| 567 | const bool minus = min <= 0; | - | ||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||
| 569 | switch (len) { | - | ||||||||||||||||||||||||
| 570 | case never executed: 0:case 0:never executed: case 0: | 0 | ||||||||||||||||||||||||
| 571 | state = max != min
| 0 | ||||||||||||||||||||||||
| 572 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 573 | case never executed: 1:case 1:never executed: case 1: | 0 | ||||||||||||||||||||||||
| 574 | if (copy.at(0) == locale.decimalPoint()
| 0 | ||||||||||||||||||||||||
| 575 | || (plus
| 0 | ||||||||||||||||||||||||
| 576 | || (minus
| 0 | ||||||||||||||||||||||||
| 577 | state = QValidator::Intermediate; | - | ||||||||||||||||||||||||
| 578 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 579 | } | - | ||||||||||||||||||||||||
| 580 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 581 | case never executed: 2:case 2:never executed: case 2: | 0 | ||||||||||||||||||||||||
| 582 | if (copy.at(1) == locale.decimalPoint()
| 0 | ||||||||||||||||||||||||
| 583 | && ((plus
| 0 | ||||||||||||||||||||||||
| 584 | state = QValidator::Intermediate; | - | ||||||||||||||||||||||||
| 585 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 586 | } | - | ||||||||||||||||||||||||
| 587 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 588 | default never executed: :default:never executed: break;default:never executed: break; | 0 | ||||||||||||||||||||||||
| 589 | } | - | ||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||
| 591 | if (copy.at(0) == locale.groupSeparator()
| 0 | ||||||||||||||||||||||||
| 592 | if (false) QMessageLogger(__FILE__, 1199, __PRETTY_FUNCTION__).debug() << __FILE__ << 1199<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1199, __PRETTY_FUNCTION__).debug() << __FILE__ << 1199<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 593 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 594 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 595 | } else if (len > 1
| 0 | ||||||||||||||||||||||||
| 596 | const int dec = copy.indexOf(locale.decimalPoint()); | - | ||||||||||||||||||||||||
| 597 | if (dec != -1
| 0 | ||||||||||||||||||||||||
| 598 | if (dec + 1 < copy.size()
| 0 | ||||||||||||||||||||||||
| 599 | copy.remove(dec + 1, 1); | - | ||||||||||||||||||||||||
| 600 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | if (copy.size() - dec > decimals + 1
| 0 | ||||||||||||||||||||||||
| 603 | if (false) QMessageLogger(__FILE__, 1210, __PRETTY_FUNCTION__).debug() << __FILE__ << 1210<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1210, __PRETTY_FUNCTION__).debug() << __FILE__ << 1210<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 604 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 605 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 606 | } | - | ||||||||||||||||||||||||
| 607 | for (int i=dec + 1; i<copy.size()
| 0 | ||||||||||||||||||||||||
| 608 | if (copy.at(i).isSpace()
| 0 | ||||||||||||||||||||||||
| 609 | if (false) QMessageLogger(__FILE__, 1216, __PRETTY_FUNCTION__).debug() << __FILE__ << 1216<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1216, __PRETTY_FUNCTION__).debug() << __FILE__ << 1216<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 610 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 611 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 612 | } | - | ||||||||||||||||||||||||
| 613 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 614 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 615 | const QChar last = copy.at(len - 1); | - | ||||||||||||||||||||||||
| 616 | const QChar secondLast = copy.at(len - 2); | - | ||||||||||||||||||||||||
| 617 | if ((last == locale.groupSeparator()
| 0 | ||||||||||||||||||||||||
| 618 | && (secondLast == locale.groupSeparator()
| 0 | ||||||||||||||||||||||||
| 619 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 620 | if (false) QMessageLogger(__FILE__, 1227, __PRETTY_FUNCTION__).debug() << __FILE__ << 1227<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1227, __PRETTY_FUNCTION__).debug() << __FILE__ << 1227<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 621 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 622 | } else if (last.isSpace()
| 0 | ||||||||||||||||||||||||
| 623 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 624 | if (false) QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__).debug() << __FILE__ << 1231<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__).debug() << __FILE__ << 1231<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 625 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 626 | } | - | ||||||||||||||||||||||||
| 627 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 628 | } | - | ||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||
| 630 | { | - | ||||||||||||||||||||||||
| 631 | bool ok = false; | - | ||||||||||||||||||||||||
| 632 | num = locale.toDouble(copy, &ok); | - | ||||||||||||||||||||||||
| 633 | if (false) QMessageLogger(__FILE__, 1240, __PRETTY_FUNCTION__).debug() << __FILE__ << 1240 << locale << copy << num << ok; dead code: QMessageLogger(__FILE__, 1240, __PRETTY_FUNCTION__).debug() << __FILE__ << 1240 << locale << copy << num << ok; | - | ||||||||||||||||||||||||
| 634 | - | |||||||||||||||||||||||||
| 635 | if (!ok
| 0 | ||||||||||||||||||||||||
| 636 | if (locale.groupSeparator().isPrint()
| 0 | ||||||||||||||||||||||||
| 637 | if (max < 1000
| 0 | ||||||||||||||||||||||||
| 638 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 639 | if (false) QMessageLogger(__FILE__, 1246, __PRETTY_FUNCTION__).debug() << __FILE__ << 1246<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1246, __PRETTY_FUNCTION__).debug() << __FILE__ << 1246<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 640 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 641 | } | - | ||||||||||||||||||||||||
| 642 | - | |||||||||||||||||||||||||
| 643 | const int len = copy.size(); | - | ||||||||||||||||||||||||
| 644 | for (int i=0; i<len- 1
| 0 | ||||||||||||||||||||||||
| 645 | if (copy.at(i) == locale.groupSeparator()
| 0 | ||||||||||||||||||||||||
| 646 | if (false) QMessageLogger(__FILE__, 1253, __PRETTY_FUNCTION__).debug() << __FILE__ << 1253<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1253, __PRETTY_FUNCTION__).debug() << __FILE__ << 1253<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 647 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 648 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 649 | } | - | ||||||||||||||||||||||||
| 650 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | QString copy2 = copy; | - | ||||||||||||||||||||||||
| 653 | copy2.remove(locale.groupSeparator()); | - | ||||||||||||||||||||||||
| 654 | num = locale.toDouble(copy2, &ok); | - | ||||||||||||||||||||||||
| 655 | if (false) QMessageLogger(__FILE__, 1262, __PRETTY_FUNCTION__).debug() << locale.groupSeparator() << num << copy2 << ok; dead code: QMessageLogger(__FILE__, 1262, __PRETTY_FUNCTION__).debug() << locale.groupSeparator() << num << copy2 << ok; | - | ||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||
| 657 | if (!ok
| 0 | ||||||||||||||||||||||||
| 658 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 659 | if (false) QMessageLogger(__FILE__, 1266, __PRETTY_FUNCTION__).debug() << __FILE__ << 1266<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1266, __PRETTY_FUNCTION__).debug() << __FILE__ << 1266<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 660 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 661 | } | - | ||||||||||||||||||||||||
| 662 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 663 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 664 | - | |||||||||||||||||||||||||
| 665 | if (!ok
| 0 | ||||||||||||||||||||||||
| 666 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 667 | if (false) QMessageLogger(__FILE__, 1274, __PRETTY_FUNCTION__).debug() << __FILE__ << 1274<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1274, __PRETTY_FUNCTION__).debug() << __FILE__ << 1274<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 668 | } never executed: else if (num >= minend of block
| 0 | ||||||||||||||||||||||||
| 669 | state = QValidator::Acceptable; | - | ||||||||||||||||||||||||
| 670 | if (false) QMessageLogger(__FILE__, 1277, __PRETTY_FUNCTION__).debug() << __FILE__ << 1277<< "state is set to Acceptable"; dead code: QMessageLogger(__FILE__, 1277, __PRETTY_FUNCTION__).debug() << __FILE__ << 1277<< "state is set to Acceptable"; | - | ||||||||||||||||||||||||
| 671 | } never executed: else if (max == minend of block
| 0 | ||||||||||||||||||||||||
| 672 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 673 | if (false) QMessageLogger(__FILE__, 1280, __PRETTY_FUNCTION__).debug() << __FILE__ << 1280<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1280, __PRETTY_FUNCTION__).debug() << __FILE__ << 1280<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 674 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 675 | if ((num >= 0
| 0 | ||||||||||||||||||||||||
| 676 | state = QValidator::Invalid; | - | ||||||||||||||||||||||||
| 677 | if (false) QMessageLogger(__FILE__, 1284, __PRETTY_FUNCTION__).debug() << __FILE__ << 1284<< "state is set to Invalid"; dead code: QMessageLogger(__FILE__, 1284, __PRETTY_FUNCTION__).debug() << __FILE__ << 1284<< "state is set to Invalid"; | - | ||||||||||||||||||||||||
| 678 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 679 | state = QValidator::Intermediate; | - | ||||||||||||||||||||||||
| 680 | if (false) QMessageLogger(__FILE__, 1287, __PRETTY_FUNCTION__).debug() << __FILE__ << 1287<< "state is set to Intermediate"; dead code: QMessageLogger(__FILE__, 1287, __PRETTY_FUNCTION__).debug() << __FILE__ << 1287<< "state is set to Intermediate"; | - | ||||||||||||||||||||||||
| 681 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 682 | } | - | ||||||||||||||||||||||||
| 683 | } | - | ||||||||||||||||||||||||
| 684 | - | |||||||||||||||||||||||||
| 685 | end: code before this statement never executed: end: | 0 | ||||||||||||||||||||||||
| 686 | if (state != QValidator::Acceptable
| 0 | ||||||||||||||||||||||||
| 687 | num = max > 0
| 0 | ||||||||||||||||||||||||
| 688 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | input = prefix + copy + suffix; | - | ||||||||||||||||||||||||
| 691 | cachedText = input; | - | ||||||||||||||||||||||||
| 692 | cachedState = state; | - | ||||||||||||||||||||||||
| 693 | cachedValue = QVariant(num); | - | ||||||||||||||||||||||||
| 694 | return never executed: QVariant(num);return QVariant(num);never executed: return QVariant(num); | 0 | ||||||||||||||||||||||||
| 695 | } | - | ||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||
| 702 | QString QDoubleSpinBoxPrivate::textFromValue(const QVariant &f) const | - | ||||||||||||||||||||||||
| 703 | { | - | ||||||||||||||||||||||||
| 704 | const QDoubleSpinBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 705 | return never executed: q->textFromValue(f.toDouble());return q->textFromValue(f.toDouble());never executed: return q->textFromValue(f.toDouble()); | 0 | ||||||||||||||||||||||||
| 706 | } | - | ||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | bool QSpinBox::event(QEvent *event) | - | ||||||||||||||||||||||||
| 710 | { | - | ||||||||||||||||||||||||
| 711 | QSpinBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 712 | if (event->type() == QEvent::StyleChange
| 0 | ||||||||||||||||||||||||
| 713 | - | |||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||
| 715 | - | |||||||||||||||||||||||||
| 716 | ) | - | ||||||||||||||||||||||||
| 717 | d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem); never executed: d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem); | 0 | ||||||||||||||||||||||||
| 718 | return never executed: QAbstractSpinBox::event(event);return QAbstractSpinBox::event(event);never executed: return QAbstractSpinBox::event(event); | 0 | ||||||||||||||||||||||||
| 719 | } | - | ||||||||||||||||||||||||
| 720 | - | |||||||||||||||||||||||||
| 721 | - | |||||||||||||||||||||||||
| 722 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |