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 }
never executed: end of block
0
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 }
never executed: end of block
0
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}
never executed: end of block
0
58-
59-
60-
61-
62QSpinBox::~QSpinBox() {}-
63int QSpinBox::value() const-
64{-
65 const QSpinBoxPrivate * const d = d_func();-
66 return
never executed: return d->value.toInt();
d->value.toInt();
never executed: return d->value.toInt();
0
67}-
68-
69void QSpinBox::setValue(int value)-
70{-
71 QSpinBoxPrivate * const d = d_func();-
72 d->setValue(QVariant(value), EmitIfChanged);-
73}
never executed: end of block
0
74QString QSpinBox::prefix() const-
75{-
76 const QSpinBoxPrivate * const d = d_func();-
77 return
never executed: return d->prefix;
d->prefix;
never executed: return d->prefix;
0
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}
never executed: end of block
0
91QString QSpinBox::suffix() const-
92{-
93 const QSpinBoxPrivate * const d = d_func();-
94-
95 return
never executed: return d->suffix;
d->suffix;
never executed: return d->suffix;
0
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}
never executed: end of block
0
108QString QSpinBox::cleanText() const-
109{-
110 const QSpinBoxPrivate * const d = d_func();-
111-
112 return
never executed: return d->stripped(d->edit->displayText());
d->stripped(d->edit->displayText());
never executed: return d->stripped(d->edit->displayText());
0
113}-
114int QSpinBox::singleStep() const-
115{-
116 const QSpinBoxPrivate * const d = d_func();-
117-
118 return
never executed: return d->singleStep.toInt();
d->singleStep.toInt();
never executed: return d->singleStep.toInt();
0
119}-
120-
121void QSpinBox::setSingleStep(int value)-
122{-
123 QSpinBoxPrivate * const d = d_func();-
124 if (value >= 0
value >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
125 d->singleStep = QVariant(value);-
126 d->updateEdit();-
127 }
never executed: end of block
0
128}
never executed: end of block
0
129int QSpinBox::minimum() const-
130{-
131 const QSpinBoxPrivate * const d = d_func();-
132-
133 return
never executed: return d->minimum.toInt();
d->minimum.toInt();
never executed: return d->minimum.toInt();
0
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}
never executed: end of block
0
142int QSpinBox::maximum() const-
143{-
144 const QSpinBoxPrivate * const d = d_func();-
145-
146 return
never executed: return d->maximum.toInt();
d->maximum.toInt();
never executed: return d->maximum.toInt();
0
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}
never executed: end of block
0
155void 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
160int QSpinBox::displayIntegerBase() const-
161{-
162 const QSpinBoxPrivate * const d = d_func();-
163 return
never executed: return d->displayIntegerBase;
d->displayIntegerBase;
never executed: return d->displayIntegerBase;
0
164}-
165-
166void QSpinBox::setDisplayIntegerBase(int base)-
167{-
168 QSpinBoxPrivate * const d = d_func();-
169-
170 if (base < 2
base < 2Description
TRUEnever evaluated
FALSEnever evaluated
|| base > 36
base > 36Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
171 QMessageLogger(__FILE__, 442, __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 str = QString::number(qAbs(value), d->displayIntegerBase);-
187 if (value < 0
value < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
188 str.prepend('-');
never executed: str.prepend('-');
0
189 }
never executed: end of block
else {
0
190 str = locale().toString(value);-
191 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
192 str.remove(locale().groupSeparator());-
193 }
never executed: end of block
0
194 }
never executed: end of block
0
195-
196 return
never executed: return str;
str;
never executed: return str;
0
197}-
198int QSpinBox::valueFromText(const QString &text) const-
199{-
200 const QSpinBoxPrivate * const d = d_func();-
201-
202 QString copy = text;-
203 int pos = d->edit->cursorPosition();-
204 QValidator::State state = QValidator::Acceptable;-
205 return
never executed: return d->validateAndInterpret(copy, pos, state).toInt();
d->validateAndInterpret(copy, pos, state).toInt();
never executed: return d->validateAndInterpret(copy, pos, state).toInt();
0
206}-
207-
208-
209-
210-
211QValidator::State QSpinBox::validate(QString &text, int &pos) const-
212{-
213 const QSpinBoxPrivate * const d = d_func();-
214-
215 QValidator::State state;-
216 d->validateAndInterpret(text, pos, state);-
217 return
never executed: return state;
state;
never executed: return state;
0
218}-
219-
220-
221-
222-
223-
224void QSpinBox::fixup(QString &input) const-
225{-
226 if (!isGroupSeparatorShown()
!isGroupSeparatorShown()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
227 input.remove(locale().groupSeparator());
never executed: input.remove(locale().groupSeparator());
0
228}
never executed: end of block
0
229QDoubleSpinBox::QDoubleSpinBox(QWidget *parent)-
230 : QAbstractSpinBox(*new QDoubleSpinBoxPrivate, parent)-
231{-
232 QDoubleSpinBoxPrivate * const d = d_func();-
233 d->init();-
234}
never executed: end of block
0
235-
236-
237-
238-
239QDoubleSpinBox::~QDoubleSpinBox() {}-
240double QDoubleSpinBox::value() const-
241{-
242 const QDoubleSpinBoxPrivate * const d = d_func();-
243-
244 return
never executed: return d->value.toDouble();
d->value.toDouble();
never executed: return d->value.toDouble();
0
245}-
246-
247void QDoubleSpinBox::setValue(double value)-
248{-
249 QDoubleSpinBoxPrivate * const d = d_func();-
250 QVariant v(d->round(value));-
251 d->setValue(v, EmitIfChanged);-
252}
never executed: end of block
0
253QString QDoubleSpinBox::prefix() const-
254{-
255 const QDoubleSpinBoxPrivate * const d = d_func();-
256-
257 return
never executed: return d->prefix;
d->prefix;
never executed: return d->prefix;
0
258}-
259-
260void QDoubleSpinBox::setPrefix(const QString &prefix)-
261{-
262 QDoubleSpinBoxPrivate * const d = d_func();-
263-
264 d->prefix = prefix;-
265 d->updateEdit();-
266}
never executed: end of block
0
267QString QDoubleSpinBox::suffix() const-
268{-
269 const QDoubleSpinBoxPrivate * const d = d_func();-
270-
271 return
never executed: return d->suffix;
d->suffix;
never executed: return d->suffix;
0
272}-
273-
274void QDoubleSpinBox::setSuffix(const QString &suffix)-
275{-
276 QDoubleSpinBoxPrivate * const d = d_func();-
277-
278 d->suffix = suffix;-
279 d->updateEdit();-
280-
281 d->cachedSizeHint = QSize();-
282 updateGeometry();-
283}
never executed: end of block
0
284QString QDoubleSpinBox::cleanText() const-
285{-
286 const QDoubleSpinBoxPrivate * const d = d_func();-
287-
288 return
never executed: return d->stripped(d->edit->displayText());
d->stripped(d->edit->displayText());
never executed: return d->stripped(d->edit->displayText());
0
289}-
290double QDoubleSpinBox::singleStep() const-
291{-
292 const QDoubleSpinBoxPrivate * const d = d_func();-
293-
294 return
never executed: return d->singleStep.toDouble();
d->singleStep.toDouble();
never executed: return d->singleStep.toDouble();
0
295}-
296-
297void QDoubleSpinBox::setSingleStep(double value)-
298{-
299 QDoubleSpinBoxPrivate * const d = d_func();-
300-
301 if (value >= 0
value >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
302 d->singleStep = value;-
303 d->updateEdit();-
304 }
never executed: end of block
0
305}
never executed: end of block
0
306double QDoubleSpinBox::minimum() const-
307{-
308 const QDoubleSpinBoxPrivate * const d = d_func();-
309-
310 return
never executed: return d->minimum.toDouble();
d->minimum.toDouble();
never executed: return d->minimum.toDouble();
0
311}-
312-
313void QDoubleSpinBox::setMinimum(double minimum)-
314{-
315 QDoubleSpinBoxPrivate * const d = d_func();-
316 d->actualMin = minimum;-
317 const QVariant m(d->round(minimum));-
318 d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m));-
319}
never executed: end of block
0
320double QDoubleSpinBox::maximum() const-
321{-
322 const QDoubleSpinBoxPrivate * const d = d_func();-
323-
324 return
never executed: return d->maximum.toDouble();
d->maximum.toDouble();
never executed: return d->maximum.toDouble();
0
325}-
326-
327void QDoubleSpinBox::setMaximum(double maximum)-
328{-
329 QDoubleSpinBoxPrivate * const d = d_func();-
330 d->actualMax = maximum;-
331 const QVariant m(d->round(maximum));-
332 d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m);-
333}
never executed: end of block
0
334void QDoubleSpinBox::setRange(double minimum, double maximum)-
335{-
336 QDoubleSpinBoxPrivate * const d = d_func();-
337 d->actualMin = minimum;-
338 d->actualMax = maximum;-
339 d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum)));-
340}
never executed: end of block
0
341int QDoubleSpinBox::decimals() const-
342{-
343 const QDoubleSpinBoxPrivate * const d = d_func();-
344-
345 return
never executed: return d->decimals;
d->decimals;
never executed: return d->decimals;
0
346}-
347-
348void QDoubleSpinBox::setDecimals(int decimals)-
349{-
350 QDoubleSpinBoxPrivate * const d = d_func();-
351 d->decimals = qBound(0, decimals, 308 + 15);-
352-
353 setRange(d->actualMin, d->actualMax);-
354 setValue(value());-
355}
never executed: end of block
0
356QString QDoubleSpinBox::textFromValue(double value) const-
357{-
358 const QDoubleSpinBoxPrivate * const d = d_func();-
359 QString str = locale().toString(value, 'f', d->decimals);-
360 if (!d->showGroupSeparator
!d->showGroupSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
&& qAbs(value) >= 1000.0
qAbs(value) >= 1000.0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
361 str.remove(locale().groupSeparator());
never executed: str.remove(locale().groupSeparator());
0
362-
363 return
never executed: return str;
str;
never executed: return str;
0
364}-
365double QDoubleSpinBox::valueFromText(const QString &text) const-
366{-
367 const QDoubleSpinBoxPrivate * const d = d_func();-
368-
369 QString copy = text;-
370 int pos = d->edit->cursorPosition();-
371 QValidator::State state = QValidator::Acceptable;-
372 return
never executed: return d->validateAndInterpret(copy, pos, state).toDouble();
d->validateAndInterpret(copy, pos, state).toDouble();
never executed: return d->validateAndInterpret(copy, pos, state).toDouble();
0
373}-
374-
375-
376-
377-
378QValidator::State QDoubleSpinBox::validate(QString &text, int &pos) const-
379{-
380 const QDoubleSpinBoxPrivate * const d = d_func();-
381-
382 QValidator::State state;-
383 d->validateAndInterpret(text, pos, state);-
384 return
never executed: return state;
state;
never executed: return state;
0
385}-
386-
387-
388-
389-
390-
391void QDoubleSpinBox::fixup(QString &input) const-
392{-
393 input.remove(locale().groupSeparator());-
394}
never executed: end of block
0
395QSpinBoxPrivate::QSpinBoxPrivate()-
396{-
397 minimum = QVariant((int)0);-
398 maximum = QVariant((int)99);-
399 value = minimum;-
400 displayIntegerBase = 10;-
401 singleStep = QVariant((int)1);-
402 type = QVariant::Int;-
403}
never executed: end of block
0
404-
405-
406-
407-
408-
409-
410void QSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old)-
411{-
412 QSpinBox * const q = q_func();-
413 if (ep != NeverEmit
ep != NeverEmitDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
414 pendingEmit = false;-
415 if (ep == AlwaysEmit
ep == AlwaysEmitDescription
TRUEnever evaluated
FALSEnever evaluated
|| value != old
value != oldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
416 q->valueChanged(edit->displayText());-
417 q->valueChanged(value.toInt());-
418 }
never executed: end of block
0
419 }
never executed: end of block
0
420}
never executed: end of block
0
421-
422-
423-
424-
425-
426-
427QString QSpinBoxPrivate::textFromValue(const QVariant &value) const-
428{-
429 const QSpinBox * const q = q_func();-
430 return
never executed: return q->textFromValue(value.toInt());
q->textFromValue(value.toInt());
never executed: return q->textFromValue(value.toInt());
0
431}-
432-
433-
434-
435-
436-
437QVariant QSpinBoxPrivate::valueFromText(const QString &text) const-
438{-
439 const QSpinBox * const q = q_func();-
440-
441 return
never executed: return QVariant(q->valueFromText(text));
QVariant(q->valueFromText(text));
never executed: return QVariant(q->valueFromText(text));
0
442}-
443QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,-
444 QValidator::State &state) const-
445{-
446 if (cachedText == input
cachedText == inputDescription
TRUEnever evaluated
FALSEnever evaluated
&& !input.isEmpty()
!input.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
447 state = cachedState;-
448 if (false) QMessageLogger(__FILE__, 1024, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was "
dead code: QMessageLogger(__FILE__, 1024, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue;
-
449 << state << " and value was " << cachedValue;
dead code: QMessageLogger(__FILE__, 1024, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue;
-
450-
451 return
never executed: return cachedValue;
cachedValue;
never executed: return cachedValue;
0
452 }-
453 const int max = maximum.toInt();-
454 const int min = minimum.toInt();-
455-
456 QString copy = stripped(input, &pos);-
457 if (false) QMessageLogger(__FILE__, 1033, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy;
dead code: QMessageLogger(__FILE__, 1033, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy;
-
458 state = QValidator::Acceptable;-
459 int num = min;-
460-
461 if (max != min
max != minDescription
TRUEnever evaluated
FALSEnever evaluated
&& (copy.isEmpty()
copy.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
462 || (min < 0
min < 0Description
TRUEnever evaluated
FALSEnever evaluated
&& copy == QLatin1String("-")
copy == QLatin1String("-")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
463 || (max >= 0
max >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& copy == QLatin1String("+")
copy == QLatin1String("+")Description
TRUEnever evaluated
FALSEnever evaluated
))) {
0
464 state = QValidator::Intermediate;-
465 if (false) QMessageLogger(__FILE__, 1041, __PRETTY_FUNCTION__).debug() << __FILE__ << 1041<< "num is set to" << num;
dead code: QMessageLogger(__FILE__, 1041, __PRETTY_FUNCTION__).debug() << __FILE__ << 1041<< "num is set to" << num;
-
466 }
never executed: end of block
else if (copy.startsWith(QLatin1Char('-'))
copy.startsWit...tin1Char('-'))Description
TRUEnever evaluated
FALSEnever evaluated
&& min >= 0
min >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
467 state = QValidator::Invalid;-
468 }
never executed: end of block
else {
0
469 bool ok = false;-
470 if (displayIntegerBase != 10
displayIntegerBase != 10Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
471 num = copy.toInt(&ok, displayIntegerBase);-
472 }
never executed: end of block
else {
0
473 num = locale.toInt(copy, &ok);-
474 if (!ok
!okDescription
TRUEnever evaluated
FALSEnever evaluated
&& copy.contains(locale.groupSeparator())
copy.contains(...upSeparator())Description
TRUEnever evaluated
FALSEnever evaluated
&& (max >= 1000
max >= 1000Description
TRUEnever evaluated
FALSEnever evaluated
|| min <= -1000
min <= -1000Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
475 QString copy2 = copy;-
476 copy2.remove(locale.groupSeparator());-
477 num = locale.toInt(copy2, &ok);-
478 }
never executed: end of block
0
479 }
never executed: end of block
0
480 if (false) QMessageLogger(__FILE__, 1056, __PRETTY_FUNCTION__).debug() << __FILE__ << 1056<< "num is set to" << num;
dead code: QMessageLogger(__FILE__, 1056, __PRETTY_FUNCTION__).debug() << __FILE__ << 1056<< "num is set to" << num;
-
481 if (!ok
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
482 state = QValidator::Invalid;-
483 }
never executed: end of block
else if (num >= min
num >= minDescription
TRUEnever evaluated
FALSEnever evaluated
&& num <= max
num <= maxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
484 state = QValidator::Acceptable;-
485 }
never executed: end of block
else if (max == min
max == minDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
486 state = QValidator::Invalid;-
487 }
never executed: end of block
else {
0
488 if ((num >= 0
num >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& num > max
num > maxDescription
TRUEnever evaluated
FALSEnever evaluated
) || (num < 0
num < 0Description
TRUEnever evaluated
FALSEnever evaluated
&& num < min
num < minDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
489 state = QValidator::Invalid;-
490 if (false) QMessageLogger(__FILE__, 1066, __PRETTY_FUNCTION__).debug() << __FILE__ << 1066<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1066, __PRETTY_FUNCTION__).debug() << __FILE__ << 1066<< "state is set to Invalid";
-
491 }
never executed: end of block
else {
0
492 state = QValidator::Intermediate;-
493 if (false) QMessageLogger(__FILE__, 1069, __PRETTY_FUNCTION__).debug() << __FILE__ << 1069<< "state is set to Intermediate";
dead code: QMessageLogger(__FILE__, 1069, __PRETTY_FUNCTION__).debug() << __FILE__ << 1069<< "state is set to Intermediate";
-
494 }
never executed: end of block
0
495 }-
496 }-
497 if (state != QValidator::Acceptable
state != QVali...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
498 num = max > 0
max > 0Description
TRUEnever evaluated
FALSEnever evaluated
? min : max;
never executed: num = max > 0 ? min : max;
0
499 input = prefix + copy + suffix;-
500 cachedText = input;-
501 cachedState = state;-
502 cachedValue = QVariant((int)num);-
503-
504 if (false) QMessageLogger(__FILE__, 1080, __PRETTY_FUNCTION__).debug() << "cachedText is set to '" << cachedText << "' state is set to "
dead code: QMessageLogger(__FILE__, 1080, __PRETTY_FUNCTION__).debug() << "cachedText is set to '" << cachedText << "' state is set to " << state << " and value is set to " << cachedValue;
-
505 << state << " and value is set to " << cachedValue;
dead code: QMessageLogger(__FILE__, 1080, __PRETTY_FUNCTION__).debug() << "cachedText is set to '" << cachedText << "' state is set to " << state << " and value is set to " << cachedValue;
-
506 return
never executed: return cachedValue;
cachedValue;
never executed: return cachedValue;
0
507}-
508QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate()-
509{-
510 actualMin = 0.0;-
511 actualMax = 99.99;-
512 minimum = QVariant(actualMin);-
513 maximum = QVariant(actualMax);-
514 value = minimum;-
515 singleStep = QVariant(1.0);-
516 decimals = 2;-
517 type = QVariant::Double;-
518}
never executed: end of block
0
519-
520-
521-
522-
523-
524-
525void QDoubleSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old)-
526{-
527 QDoubleSpinBox * const q = q_func();-
528 if (ep != NeverEmit
ep != NeverEmitDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
529 pendingEmit = false;-
530 if (ep == AlwaysEmit
ep == AlwaysEmitDescription
TRUEnever evaluated
FALSEnever evaluated
|| value != old
value != oldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
531 q->valueChanged(edit->displayText());-
532 q->valueChanged(value.toDouble());-
533 }
never executed: end of block
0
534 }
never executed: end of block
0
535}
never executed: end of block
0
536-
537-
538-
539-
540-
541-
542QVariant QDoubleSpinBoxPrivate::valueFromText(const QString &f) const-
543{-
544 const QDoubleSpinBox * const q = q_func();-
545 return
never executed: return QVariant(q->valueFromText(f));
QVariant(q->valueFromText(f));
never executed: return QVariant(q->valueFromText(f));
0
546}-
547double QDoubleSpinBoxPrivate::round(double value) const-
548{-
549 return
never executed: return QString::number(value, 'f', decimals).toDouble();
QString::number(value, 'f', decimals).toDouble();
never executed: return QString::number(value, 'f', decimals).toDouble();
0
550}-
551QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,-
552 QValidator::State &state) const-
553{-
554 if (cachedText == input
cachedText == inputDescription
TRUEnever evaluated
FALSEnever evaluated
&& !input.isEmpty()
!input.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
555 state = cachedState;-
556 if (false) QMessageLogger(__FILE__, 1157, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was "
dead code: QMessageLogger(__FILE__, 1157, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue;
-
557 << state << " and value was " << cachedValue;
dead code: QMessageLogger(__FILE__, 1157, __PRETTY_FUNCTION__).debug() << "cachedText was '" << cachedText << "' state was " << state << " and value was " << cachedValue;
-
558 return
never executed: return cachedValue;
cachedValue;
never executed: return cachedValue;
0
559 }-
560 const double max = maximum.toDouble();-
561 const double min = minimum.toDouble();-
562-
563 QString copy = stripped(input, &pos);-
564 if (false) QMessageLogger(__FILE__, 1165, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy;
dead code: QMessageLogger(__FILE__, 1165, __PRETTY_FUNCTION__).debug() << "input" << input << "copy" << copy;
-
565 int len = copy.size();-
566 double num = min;-
567 const bool plus = max >= 0;-
568 const bool minus = min <= 0;-
569-
570 switch (len) {-
571 case
never executed: case 0:
0:
never executed: case 0:
0
572 state = max != min
max != minDescription
TRUEnever evaluated
FALSEnever evaluated
? QValidator::Intermediate : QValidator::Invalid;
0
573 goto
never executed: goto end;
end;
never executed: goto end;
0
574 case
never executed: case 1:
1:
never executed: case 1:
0
575 if (copy.at(0) == locale.decimalPoint()
copy.at(0) == ...decimalPoint()Description
TRUEnever evaluated
FALSEnever evaluated
0
576 || (plus
plusDescription
TRUEnever evaluated
FALSEnever evaluated
&& copy.at(0) == QLatin1Char('+')
copy.at(0) == QLatin1Char('+')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
577 || (minus
minusDescription
TRUEnever evaluated
FALSEnever evaluated
&& copy.at(0) == QLatin1Char('-')
copy.at(0) == QLatin1Char('-')Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
578 state = QValidator::Intermediate;-
579 goto
never executed: goto end;
end;
never executed: goto end;
0
580 }-
581 break;
never executed: break;
0
582 case
never executed: case 2:
2:
never executed: case 2:
0
583 if (copy.at(1) == locale.decimalPoint()
copy.at(1) == ...decimalPoint()Description
TRUEnever evaluated
FALSEnever evaluated
0
584 && ((plus
plusDescription
TRUEnever evaluated
FALSEnever evaluated
&& copy.at(0) == QLatin1Char('+')
copy.at(0) == QLatin1Char('+')Description
TRUEnever evaluated
FALSEnever evaluated
) || (minus
minusDescription
TRUEnever evaluated
FALSEnever evaluated
&& copy.at(0) == QLatin1Char('-')
copy.at(0) == QLatin1Char('-')Description
TRUEnever evaluated
FALSEnever evaluated
))) {
0
585 state = QValidator::Intermediate;-
586 goto
never executed: goto end;
end;
never executed: goto end;
0
587 }-
588 break;
never executed: break;
0
589 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
590 }-
591-
592 if (copy.at(0) == locale.groupSeparator()
copy.at(0) == ...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
593 if (false) QMessageLogger(__FILE__, 1194, __PRETTY_FUNCTION__).debug() << __FILE__ << 1194<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1194, __PRETTY_FUNCTION__).debug() << __FILE__ << 1194<< "state is set to Invalid";
-
594 state = QValidator::Invalid;-
595 goto
never executed: goto end;
end;
never executed: goto end;
0
596 } else if (len > 1
len > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
597 const int dec = copy.indexOf(locale.decimalPoint());-
598 if (dec != -1
dec != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
599 if (dec + 1 < copy.size()
dec + 1 < copy.size()Description
TRUEnever evaluated
FALSEnever evaluated
&& copy.at(dec + 1) == locale.decimalPoint()
copy.at(dec + ...decimalPoint()Description
TRUEnever evaluated
FALSEnever evaluated
&& pos == dec + 1
pos == dec + 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
600 copy.remove(dec + 1, 1);-
601 }
never executed: end of block
0
602-
603 if (copy.size() - dec > decimals + 1
copy.size() - ...> decimals + 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
604 if (false) QMessageLogger(__FILE__, 1205, __PRETTY_FUNCTION__).debug() << __FILE__ << 1205<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1205, __PRETTY_FUNCTION__).debug() << __FILE__ << 1205<< "state is set to Invalid";
-
605 state = QValidator::Invalid;-
606 goto
never executed: goto end;
end;
never executed: goto end;
0
607 }-
608 for (int i=dec + 1; i<copy.size()
i<copy.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
609 if (copy.at(i).isSpace()
copy.at(i).isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
|| copy.at(i) == locale.groupSeparator()
copy.at(i) == ...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
610 if (false) QMessageLogger(__FILE__, 1211, __PRETTY_FUNCTION__).debug() << __FILE__ << 1211<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1211, __PRETTY_FUNCTION__).debug() << __FILE__ << 1211<< "state is set to Invalid";
-
611 state = QValidator::Invalid;-
612 goto
never executed: goto end;
end;
never executed: goto end;
0
613 }-
614 }
never executed: end of block
0
615 }
never executed: end of block
else {
0
616 const QChar last = copy.at(len - 1);-
617 const QChar secondLast = copy.at(len - 2);-
618 if ((last == locale.groupSeparator()
last == locale...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
|| last.isSpace()
last.isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
619 && (secondLast == locale.groupSeparator()
secondLast == ...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
|| secondLast.isSpace()
secondLast.isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
620 state = QValidator::Invalid;-
621 if (false) QMessageLogger(__FILE__, 1222, __PRETTY_FUNCTION__).debug() << __FILE__ << 1222<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1222, __PRETTY_FUNCTION__).debug() << __FILE__ << 1222<< "state is set to Invalid";
-
622 goto
never executed: goto end;
end;
never executed: goto end;
0
623 } else if (last.isSpace()
last.isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
&& (!locale.groupSeparator().isSpace()
!locale.groupS...or().isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
|| secondLast.isSpace()
secondLast.isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
624 state = QValidator::Invalid;-
625 if (false) QMessageLogger(__FILE__, 1226, __PRETTY_FUNCTION__).debug() << __FILE__ << 1226<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1226, __PRETTY_FUNCTION__).debug() << __FILE__ << 1226<< "state is set to Invalid";
-
626 goto
never executed: goto end;
end;
never executed: goto end;
0
627 }-
628 }
never executed: end of block
0
629 }-
630-
631 {-
632 bool ok = false;-
633 num = locale.toDouble(copy, &ok);-
634 if (false) QMessageLogger(__FILE__, 1235, __PRETTY_FUNCTION__).debug() << __FILE__ << 1235 << locale << copy << num << ok;
dead code: QMessageLogger(__FILE__, 1235, __PRETTY_FUNCTION__).debug() << __FILE__ << 1235 << locale << copy << num << ok;
-
635-
636 if (!ok
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
637 if (locale.groupSeparator().isPrint()
locale.groupSe...or().isPrint()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
638 if (max < 1000
max < 1000Description
TRUEnever evaluated
FALSEnever evaluated
&& min > -1000
min > -1000Description
TRUEnever evaluated
FALSEnever evaluated
&& copy.contains(locale.groupSeparator())
copy.contains(...upSeparator())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
639 state = QValidator::Invalid;-
640 if (false) QMessageLogger(__FILE__, 1241, __PRETTY_FUNCTION__).debug() << __FILE__ << 1241<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1241, __PRETTY_FUNCTION__).debug() << __FILE__ << 1241<< "state is set to Invalid";
-
641 goto
never executed: goto end;
end;
never executed: goto end;
0
642 }-
643-
644 const int len = copy.size();-
645 for (int i=0; i<len- 1
i<len- 1Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
646 if (copy.at(i) == locale.groupSeparator()
copy.at(i) == ...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
&& copy.at(i + 1) == locale.groupSeparator()
copy.at(i + 1)...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
647 if (false) QMessageLogger(__FILE__, 1248, __PRETTY_FUNCTION__).debug() << __FILE__ << 1248<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1248, __PRETTY_FUNCTION__).debug() << __FILE__ << 1248<< "state is set to Invalid";
-
648 state = QValidator::Invalid;-
649 goto
never executed: goto end;
end;
never executed: goto end;
0
650 }-
651 }
never executed: end of block
0
652-
653 QString copy2 = copy;-
654 copy2.remove(locale.groupSeparator());-
655 num = locale.toDouble(copy2, &ok);-
656 if (false) QMessageLogger(__FILE__, 1257, __PRETTY_FUNCTION__).debug() << locale.groupSeparator() << num << copy2 << ok;
dead code: QMessageLogger(__FILE__, 1257, __PRETTY_FUNCTION__).debug() << locale.groupSeparator() << num << copy2 << ok;
-
657-
658 if (!ok
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
659 state = QValidator::Invalid;-
660 if (false) QMessageLogger(__FILE__, 1261, __PRETTY_FUNCTION__).debug() << __FILE__ << 1261<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1261, __PRETTY_FUNCTION__).debug() << __FILE__ << 1261<< "state is set to Invalid";
-
661 goto
never executed: goto end;
end;
never executed: goto end;
0
662 }-
663 }
never executed: end of block
0
664 }
never executed: end of block
0
665-
666 if (!ok
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
667 state = QValidator::Invalid;-
668 if (false) QMessageLogger(__FILE__, 1269, __PRETTY_FUNCTION__).debug() << __FILE__ << 1269<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1269, __PRETTY_FUNCTION__).debug() << __FILE__ << 1269<< "state is set to Invalid";
-
669 }
never executed: end of block
else if (num >= min
num >= minDescription
TRUEnever evaluated
FALSEnever evaluated
&& num <= max
num <= maxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
670 state = QValidator::Acceptable;-
671 if (false) QMessageLogger(__FILE__, 1272, __PRETTY_FUNCTION__).debug() << __FILE__ << 1272<< "state is set to Acceptable";
dead code: QMessageLogger(__FILE__, 1272, __PRETTY_FUNCTION__).debug() << __FILE__ << 1272<< "state is set to Acceptable";
-
672 }
never executed: end of block
else if (max == min
max == minDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
673 state = QValidator::Invalid;-
674 if (false) QMessageLogger(__FILE__, 1275, __PRETTY_FUNCTION__).debug() << __FILE__ << 1275<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1275, __PRETTY_FUNCTION__).debug() << __FILE__ << 1275<< "state is set to Invalid";
-
675 }
never executed: end of block
else {
0
676 if ((num >= 0
num >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& num > max
num > maxDescription
TRUEnever evaluated
FALSEnever evaluated
) || (num < 0
num < 0Description
TRUEnever evaluated
FALSEnever evaluated
&& num < min
num < minDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
677 state = QValidator::Invalid;-
678 if (false) QMessageLogger(__FILE__, 1279, __PRETTY_FUNCTION__).debug() << __FILE__ << 1279<< "state is set to Invalid";
dead code: QMessageLogger(__FILE__, 1279, __PRETTY_FUNCTION__).debug() << __FILE__ << 1279<< "state is set to Invalid";
-
679 }
never executed: end of block
else {
0
680 state = QValidator::Intermediate;-
681 if (false) QMessageLogger(__FILE__, 1282, __PRETTY_FUNCTION__).debug() << __FILE__ << 1282<< "state is set to Intermediate";
dead code: QMessageLogger(__FILE__, 1282, __PRETTY_FUNCTION__).debug() << __FILE__ << 1282<< "state is set to Intermediate";
-
682 }
never executed: end of block
0
683 }-
684 }-
685-
686end:
code before this statement never executed: end:
0
687 if (state != QValidator::Acceptable
state != QVali...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
688 num = max > 0
max > 0Description
TRUEnever evaluated
FALSEnever evaluated
? min : max;
0
689 }
never executed: end of block
0
690-
691 input = prefix + copy + suffix;-
692 cachedText = input;-
693 cachedState = state;-
694 cachedValue = QVariant(num);-
695 return
never executed: return QVariant(num);
QVariant(num);
never executed: return QVariant(num);
0
696}-
697-
698-
699-
700-
701-
702-
703QString QDoubleSpinBoxPrivate::textFromValue(const QVariant &f) const-
704{-
705 const QDoubleSpinBox * const q = q_func();-
706 return
never executed: return q->textFromValue(f.toDouble());
q->textFromValue(f.toDouble());
never executed: return q->textFromValue(f.toDouble());
0
707}-
708-
709-
710bool QSpinBox::event(QEvent *event)-
711{-
712 QSpinBoxPrivate * const d = d_func();-
713 if (event->type() == QEvent::StyleChange
event->type() ...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
714-
715-
716-
717 )-
718 d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);
never executed: d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);
0
719 return
never executed: return QAbstractSpinBox::event(event);
QAbstractSpinBox::event(event);
never executed: return QAbstractSpinBox::event(event);
0
720}-
721-
722-
723-
Switch to Source codePreprocessed file

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