qspinbox.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qspinbox.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7class 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;-
10public:-
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 }-
24-
25 int displayIntegerBase;-
26};-
27-
28class 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;-
31public:-
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 }-
47-
48-
49 double actualMin;-
50 double actualMax;-
51};-
52QSpinBox::QSpinBox(QWidget *parent)-
53 : QAbstractSpinBox(*new QSpinBoxPrivate, parent)-
54{-
55 QSpinBoxPrivate * const d = d_func();-
56 d->init();-
57}-
58-
59-
60-
61-
62QSpinBox::~QSpinBox() {}-
63int QSpinBox::value() const-
64{-
65 const QSpinBoxPrivate * const d = d_func();-
66 return d->value.toInt();-
67}-
68-
69void QSpinBox::setValue(int value)-
70{-
71 QSpinBoxPrivate * const d = d_func();-
72 d->setValue(QVariant(value), EmitIfChanged);-
73}-
74QString QSpinBox::prefix() const-
75{-
76 const QSpinBoxPrivate * const d = d_func();-
77 return d->prefix;-
78}-
79-
80void 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}-
91QString QSpinBox::suffix() const-
92{-
93 const QSpinBoxPrivate * const d = d_func();-
94-
95 return d->suffix;-
96}-
97-
98void 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}-
108QString QSpinBox::cleanText() const-
109{-
110 const QSpinBoxPrivate * const d = d_func();-
111-
112 return d->stripped(d->edit->displayText());-
113}-
114int QSpinBox::singleStep() const-
115{-
116 const QSpinBoxPrivate * const d = d_func();-
117-
118 return d->singleStep.toInt();-
119}-
120-
121void QSpinBox::setSingleStep(int value)-
122{-
123 QSpinBoxPrivate * const d = d_func();-
124 if (value >= 0) {-
125 d->singleStep = QVariant(value);-
126 d->updateEdit();-
127 }-
128}-
129int QSpinBox::minimum() const-
130{-
131 const QSpinBoxPrivate * const d = d_func();-
132-
133 return d->minimum.toInt();-
134}-
135-
136void 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}-
142int QSpinBox::maximum() const-
143{-
144 const QSpinBoxPrivate * const d = d_func();-
145-
146 return d->maximum.toInt();-
147}-
148-
149void 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}-
155void QSpinBox::setRange(int minimum, int maximum)-
156{-
157 QSpinBoxPrivate * const d = d_func();-
158 d->setRange(QVariant(minimum), QVariant(maximum));-
159}-
160int QSpinBox::displayIntegerBase() const-
161{-
162 const QSpinBoxPrivate * const d = d_func();-
163 return d->displayIntegerBase;-
164}-
165-
166void QSpinBox::setDisplayIntegerBase(int base)-
167{-
168 QSpinBoxPrivate * const d = d_func();-
169-
170 if (__builtin_expect(!!(
__builtin_expe... > 36), false)Description
TRUEnever evaluated
FALSEnever evaluated
base < 2 || base > 36)), false)
__builtin_expe... > 36), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
171 QMessageLogger(__FILE__, 442448, __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
base != d->displayIntegerBaseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
176 d->displayIntegerBase = base;-
177 d->updateEdit();-
178 }
never executed: end of block
0
179}
never executed: end of block
0
180QString QSpinBox::textFromValue(int value) const-
181{-
182 const QSpinBoxPrivate * const d = d_func();-
183 QString str;-
184-
185 if (d->displayIntegerBase != 10
d->displayIntegerBase != 10Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
186 const QLatin1String prefix = value < 0
value < 0Description
TRUEnever evaluated
FALSEnever evaluated
? QLatin1String("-") : QLatin1String();
0
187 str = prefix + QString::number(qAbs(value), d->displayIntegerBase);-
if (value < 0)
str.prepend('-');
188 }
never executed: end of block
else {
0
189 str = locale().toString(value);-
190 if (!d->showGroupSeparator
!d->showGroupSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
&& (qAbs(value) >= 1000
qAbs(value) >= 1000Description
TRUEnever evaluated
FALSEnever evaluated
|| value == (-2147483647 - 1)
value == (-2147483647 - 1)Description
TRUEnever evaluated
FALSEnever evaluated
)) {
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: return str;
str;
never executed: return str;
0
196}-
197int 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 d->validateAndInterpret(copy, pos, state).toInt();-
205}-
206-
207-
208-
209-
210QValidator::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 state;-
217}-
218-
219-
220-
221-
222-
223void QSpinBox::fixup(QString &input) const-
224{-
225 if (!isGroupSeparatorShown())-
226 input.remove(locale().groupSeparator());-
227}-
228QDoubleSpinBox::QDoubleSpinBox(QWidget *parent)-
229 : QAbstractSpinBox(*new QDoubleSpinBoxPrivate, parent)-
230{-
231 QDoubleSpinBoxPrivate * const d = d_func();-
232 d->init();-
233}-
234-
235-
236-
237-
238QDoubleSpinBox::~QDoubleSpinBox() {}-
239double QDoubleSpinBox::value() const-
240{-
241 const QDoubleSpinBoxPrivate * const d = d_func();-
242-
243 return d->value.toDouble();-
244}-
245-
246void QDoubleSpinBox::setValue(double value)-
247{-
248 QDoubleSpinBoxPrivate * const d = d_func();-
249 QVariant v(d->round(value));-
250 d->setValue(v, EmitIfChanged);-
251}-
252QString QDoubleSpinBox::prefix() const-
253{-
254 const QDoubleSpinBoxPrivate * const d = d_func();-
255-
256 return d->prefix;-
257}-
258-
259void QDoubleSpinBox::setPrefix(const QString &prefix)-
260{-
261 QDoubleSpinBoxPrivate * const d = d_func();-
262-
263 d->prefix = prefix;-
264 d->updateEdit();-
265}-
266QString QDoubleSpinBox::suffix() const-
267{-
268 const QDoubleSpinBoxPrivate * const d = d_func();-
269-
270 return d->suffix;-
271}-
272-
273void 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}-
283QString QDoubleSpinBox::cleanText() const-
284{-
285 const QDoubleSpinBoxPrivate * const d = d_func();-
286-
287 return d->stripped(d->edit->displayText());-
288}-
289double QDoubleSpinBox::singleStep() const-
290{-
291 const QDoubleSpinBoxPrivate * const d = d_func();-
292-
293 return d->singleStep.toDouble();-
294}-
295-
296void QDoubleSpinBox::setSingleStep(double value)-
297{-
298 QDoubleSpinBoxPrivate * const d = d_func();-
299-
300 if (value >= 0) {-
301 d->singleStep = value;-
302 d->updateEdit();-
303 }-
304}-
305double QDoubleSpinBox::minimum() const-
306{-
307 const QDoubleSpinBoxPrivate * const d = d_func();-
308-
309 return d->minimum.toDouble();-
310}-
311-
312void 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}-
319double QDoubleSpinBox::maximum() const-
320{-
321 const QDoubleSpinBoxPrivate * const d = d_func();-
322-
323 return d->maximum.toDouble();-
324}-
325-
326void 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}-
333void 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}-
340int QDoubleSpinBox::decimals() const-
341{-
342 const QDoubleSpinBoxPrivate * const d = d_func();-
343-
344 return d->decimals;-
345}-
346-
347void 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}-
355QString 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 && qAbs(value) >= 1000.0)-
360 str.remove(locale().groupSeparator());-
361-
362 return str;-
363}-
364double 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 d->validateAndInterpret(copy, pos, state).toDouble();-
372}-
373-
374-
375-
376-
377QValidator::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 state;-
384}-
385-
386-
387-
388-
389-
390void QDoubleSpinBox::fixup(QString &input) const-
391{-
392 input.remove(locale().groupSeparator());-
393}-
394QSpinBoxPrivate::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}-
403-
404-
405-
406-
407-
408-
409void QSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old)-
410{-
411 QSpinBox * const q = q_func();-
412 if (ep != NeverEmit) {-
413 pendingEmit = false;-
414 if (ep == AlwaysEmit || value != old) {-
415 q->valueChanged(edit->displayText());-
416 q->valueChanged(value.toInt());-
417 }-
418 }-
419}-
420-
421-
422-
423-
424-
425-
426QString QSpinBoxPrivate::textFromValue(const QVariant &value) const-
427{-
428 const QSpinBox * const q = q_func();-
429 return q->textFromValue(value.toInt());-
430}-
431-
432-
433-
434-
435-
436QVariant QSpinBoxPrivate::valueFromText(const QString &text) const-
437{-
438 const QSpinBox * const q = q_func();-
439-
440 return QVariant(q->valueFromText(text));-
441}-
442QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,-
443 QValidator::State &state) const-
444{-
445 if (cachedText == input && !input.isEmpty()) {-
446 state = cachedState;-
447 if (false) QMessageLogger(__FILE__, 10241029, __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 cachedValue;-
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__, 10331038, __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 && (copy.isEmpty()-
461 || (min < 0 && copy == QLatin1String("-"))-
462 || (max >= 0 && copy == QLatin1String("+")))) {-
463 state = QValidator::Intermediate;-
464 if (false) QMessageLogger(__FILE__, 10411046, __PRETTY_FUNCTION__).debug() << __FILE__ << 10411046<< "num is set to" << num;
dead code: QMessageLogger(__FILE__, 1046, __PRETTY_FUNCTION__).debug() << __FILE__ << 1046<< "num is set to" << num;
-
465 } else if (copy.startsWith(QLatin1Char('-')) && min >= 0) {-
466 state = QValidator::Invalid;-
467 } else {-
468 bool ok = false;-
469 if (displayIntegerBase != 10) {-
470 num = copy.toInt(&ok, displayIntegerBase);-
471 } else {-
472 num = locale.toInt(copy, &ok);-
473 if (!ok && copy.contains(locale.groupSeparator()) && (max >= 1000 || min <= -1000)) {-
474 QString copy2 = copy;-
475 copy2.remove(locale.groupSeparator());-
476 num = locale.toInt(copy2, &ok);-
477 }-
478 }-
479 if (false) QMessageLogger(__FILE__, 10561061, __PRETTY_FUNCTION__).debug() << __FILE__ << 10561061<< "num is set to" << num;
dead code: QMessageLogger(__FILE__, 1061, __PRETTY_FUNCTION__).debug() << __FILE__ << 1061<< "num is set to" << num;
-
480 if (!ok) {-
481 state = QValidator::Invalid;-
482 } else if (num >= min && num <= max) {-
483 state = QValidator::Acceptable;-
484 } else if (max == min) {-
485 state = QValidator::Invalid;-
486 } else {-
487 if ((num >= 0 && num > max) || (num < 0 && num < min)) {-
488 state = QValidator::Invalid;-
489 if (false) QMessageLogger(__FILE__, 10661071, __PRETTY_FUNCTION__).debug() << __FILE__ << 10661071<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1071, __PRETTY_FUNCTION__).debug() << __FILE__ << 1071<< "state is set to Invalid";
-
490 } else {-
491 state = QValidator::Intermediate;-
492 if (false) QMessageLogger(__FILE__, 10691074, __PRETTY_FUNCTION__).debug() << __FILE__ << 10691074<< "state is set to Intermediate";
dead code: QMessageLogger(__FILE__, 1074, __PRETTY_FUNCTION__).debug() << __FILE__ << 1074<< "state is set to Intermediate";
-
493 }-
494 }-
495 }-
496 if (state != QValidator::Acceptable)-
497 num = max > 0 ? min : max;-
498 input = prefix + copy + suffix;-
499 cachedText = input;-
500 cachedState = state;-
501 cachedValue = QVariant((int)num);-
502-
503 if (false) QMessageLogger(__FILE__, 10801085, __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 cachedValue;-
506}-
507QDoubleSpinBoxPrivate::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}-
518-
519-
520-
521-
522-
523-
524void QDoubleSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old)-
525{-
526 QDoubleSpinBox * const q = q_func();-
527 if (ep != NeverEmit) {-
528 pendingEmit = false;-
529 if (ep == AlwaysEmit || value != old) {-
530 q->valueChanged(edit->displayText());-
531 q->valueChanged(value.toDouble());-
532 }-
533 }-
534}-
535-
536-
537-
538-
539-
540-
541QVariant QDoubleSpinBoxPrivate::valueFromText(const QString &f) const-
542{-
543 const QDoubleSpinBox * const q = q_func();-
544 return QVariant(q->valueFromText(f));-
545}-
546double QDoubleSpinBoxPrivate::round(double value) const-
547{-
548 return QString::number(value, 'f', decimals).toDouble();-
549}-
550QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,-
551 QValidator::State &state) const-
552{-
553 if (cachedText == input && !input.isEmpty()) {-
554 state = cachedState;-
555 if (false) QMessageLogger(__FILE__, 11571162, __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 cachedValue;-
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__, 11651170, __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 0:-
571 state = max != min ? QValidator::Intermediate : QValidator::Invalid;-
572 goto end;-
573 case 1:-
574 if (copy.at(0) == locale.decimalPoint()-
575 || (plus && copy.at(0) == QLatin1Char('+'))-
576 || (minus && copy.at(0) == QLatin1Char('-'))) {-
577 state = QValidator::Intermediate;-
578 goto end;-
579 }-
580 break;-
581 case 2:-
582 if (copy.at(1) == locale.decimalPoint()-
583 && ((plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-')))) {-
584 state = QValidator::Intermediate;-
585 goto end;-
586 }-
587 break;-
588 default: break;-
589 }-
590-
591 if (copy.at(0) == locale.groupSeparator()) {-
592 if (false) QMessageLogger(__FILE__, 11941199, __PRETTY_FUNCTION__).debug() << __FILE__ << 11941199<< "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 end;-
595 } else if (len > 1) {-
596 const int dec = copy.indexOf(locale.decimalPoint());-
597 if (dec != -1) {-
598 if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) {-
599 copy.remove(dec + 1, 1);-
600 }-
601-
602 if (copy.size() - dec > decimals + 1) {-
603 if (false) QMessageLogger(__FILE__, 12051210, __PRETTY_FUNCTION__).debug() << __FILE__ << 12051210<< "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 end;-
606 }-
607 for (int i=dec + 1; i<copy.size(); ++i) {-
608 if (copy.at(i).isSpace() || copy.at(i) == locale.groupSeparator()) {-
609 if (false) QMessageLogger(__FILE__, 12111216, __PRETTY_FUNCTION__).debug() << __FILE__ << 12111216<< "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 end;-
612 }-
613 }-
614 } else {-
615 const QChar last = copy.at(len - 1);-
616 const QChar secondLast = copy.at(len - 2);-
617 if ((last == locale.groupSeparator() || last.isSpace())-
618 && (secondLast == locale.groupSeparator() || secondLast.isSpace())) {-
619 state = QValidator::Invalid;-
620 if (false) QMessageLogger(__FILE__, 12221227, __PRETTY_FUNCTION__).debug() << __FILE__ << 12221227<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1227, __PRETTY_FUNCTION__).debug() << __FILE__ << 1227<< "state is set to Invalid";
-
621 goto end;-
622 } else if (last.isSpace() && (!locale.groupSeparator().isSpace() || secondLast.isSpace())) {-
623 state = QValidator::Invalid;-
624 if (false) QMessageLogger(__FILE__, 12261231, __PRETTY_FUNCTION__).debug() << __FILE__ << 12261231<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__).debug() << __FILE__ << 1231<< "state is set to Invalid";
-
625 goto end;-
626 }-
627 }-
628 }-
629-
630 {-
631 bool ok = false;-
632 num = locale.toDouble(copy, &ok);-
633 if (false) QMessageLogger(__FILE__, 12351240, __PRETTY_FUNCTION__).debug() << __FILE__ << 12351240 << locale << copy << num << ok;
dead code: QMessageLogger(__FILE__, 1240, __PRETTY_FUNCTION__).debug() << __FILE__ << 1240 << locale << copy << num << ok;
-
634-
635 if (!ok) {-
636 if (locale.groupSeparator().isPrint()) {-
637 if (max < 1000 && min > -1000 && copy.contains(locale.groupSeparator())) {-
638 state = QValidator::Invalid;-
639 if (false) QMessageLogger(__FILE__, 12411246, __PRETTY_FUNCTION__).debug() << __FILE__ << 12411246<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1246, __PRETTY_FUNCTION__).debug() << __FILE__ << 1246<< "state is set to Invalid";
-
640 goto end;-
641 }-
642-
643 const int len = copy.size();-
644 for (int i=0; i<len- 1; ++i) {-
645 if (copy.at(i) == locale.groupSeparator() && copy.at(i + 1) == locale.groupSeparator()) {-
646 if (false) QMessageLogger(__FILE__, 12481253, __PRETTY_FUNCTION__).debug() << __FILE__ << 12481253<< "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 end;-
649 }-
650 }-
651-
652 QString copy2 = copy;-
653 copy2.remove(locale.groupSeparator());-
654 num = locale.toDouble(copy2, &ok);-
655 if (false) QMessageLogger(__FILE__, 12571262, __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) {-
658 state = QValidator::Invalid;-
659 if (false) QMessageLogger(__FILE__, 12611266, __PRETTY_FUNCTION__).debug() << __FILE__ << 12611266<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1266, __PRETTY_FUNCTION__).debug() << __FILE__ << 1266<< "state is set to Invalid";
-
660 goto end;-
661 }-
662 }-
663 }-
664-
665 if (!ok) {-
666 state = QValidator::Invalid;-
667 if (false) QMessageLogger(__FILE__, 12691274, __PRETTY_FUNCTION__).debug() << __FILE__ << 12691274<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1274, __PRETTY_FUNCTION__).debug() << __FILE__ << 1274<< "state is set to Invalid";
-
668 } else if (num >= min && num <= max) {-
669 state = QValidator::Acceptable;-
670 if (false) QMessageLogger(__FILE__, 12721277, __PRETTY_FUNCTION__).debug() << __FILE__ << 12721277<< "state is set to Acceptable";
dead code: QMessageLogger(__FILE__, 1277, __PRETTY_FUNCTION__).debug() << __FILE__ << 1277<< "state is set to Acceptable";
-
671 } else if (max == min) {-
672 state = QValidator::Invalid;-
673 if (false) QMessageLogger(__FILE__, 12751280, __PRETTY_FUNCTION__).debug() << __FILE__ << 12751280<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1280, __PRETTY_FUNCTION__).debug() << __FILE__ << 1280<< "state is set to Invalid";
-
674 } else {-
675 if ((num >= 0 && num > max) || (num < 0 && num < min)) {-
676 state = QValidator::Invalid;-
677 if (false) QMessageLogger(__FILE__, 12791284, __PRETTY_FUNCTION__).debug() << __FILE__ << 12791284<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1284, __PRETTY_FUNCTION__).debug() << __FILE__ << 1284<< "state is set to Invalid";
-
678 } else {-
679 state = QValidator::Intermediate;-
680 if (false) QMessageLogger(__FILE__, 12821287, __PRETTY_FUNCTION__).debug() << __FILE__ << 12821287<< "state is set to Intermediate";
dead code: QMessageLogger(__FILE__, 1287, __PRETTY_FUNCTION__).debug() << __FILE__ << 1287<< "state is set to Intermediate";
-
681 }-
682 }-
683 }-
684-
685end:-
686 if (state != QValidator::Acceptable) {-
687 num = max > 0 ? min : max;-
688 }-
689-
690 input = prefix + copy + suffix;-
691 cachedText = input;-
692 cachedState = state;-
693 cachedValue = QVariant(num);-
694 return QVariant(num);-
695}-
696-
697-
698-
699-
700-
701-
702QString QDoubleSpinBoxPrivate::textFromValue(const QVariant &f) const-
703{-
704 const QDoubleSpinBox * const q = q_func();-
705 return q->textFromValue(f.toDouble());-
706}-
707-
708-
709bool QSpinBox::event(QEvent *event)-
710{-
711 QSpinBoxPrivate * const d = d_func();-
712 if (event->type() == QEvent::StyleChange-
713-
714-
715-
716 )-
717 d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);-
718 return QAbstractSpinBox::event(event);-
719}-
720-
721-
722-
Switch to Source codePreprocessed file

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