OpenCoverage

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 (__builtin_expect(!!(base < 2 || base > 36), false)
__builtin_expe... > 36), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
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
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);-
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
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
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
never executed: return state;
state;
never executed: return state;
0
217}-
218-
219-
220-
221-
222-
223void QSpinBox::fixup(QString &input) const-
224{-
225 if (!isGroupSeparatorShown()
!isGroupSeparatorShown()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
226 input.remove(locale().groupSeparator());
never executed: input.remove(locale().groupSeparator());
0
227}
never executed: end of block
0
228QDoubleSpinBox::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-
238QDoubleSpinBox::~QDoubleSpinBox() {}-
239double QDoubleSpinBox::value() const-
240{-
241 const QDoubleSpinBoxPrivate * const d = d_func();-
242-
243 return
never executed: return d->value.toDouble();
d->value.toDouble();
never executed: return d->value.toDouble();
0
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}
never executed: end of block
0
252QString QDoubleSpinBox::prefix() const-
253{-
254 const QDoubleSpinBoxPrivate * const d = d_func();-
255-
256 return
never executed: return d->prefix;
d->prefix;
never executed: return d->prefix;
0
257}-
258-
259void 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
266QString QDoubleSpinBox::suffix() const-
267{-
268 const QDoubleSpinBoxPrivate * const d = d_func();-
269-
270 return
never executed: return d->suffix;
d->suffix;
never executed: return d->suffix;
0
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}
never executed: end of block
0
283QString QDoubleSpinBox::cleanText() const-
284{-
285 const QDoubleSpinBoxPrivate * const d = d_func();-
286-
287 return
never executed: return d->stripped(d->edit->displayText());
d->stripped(d->edit->displayText());
never executed: return d->stripped(d->edit->displayText());
0
288}-
289double QDoubleSpinBox::singleStep() const-
290{-
291 const QDoubleSpinBoxPrivate * const d = d_func();-
292-
293 return
never executed: return d->singleStep.toDouble();
d->singleStep.toDouble();
never executed: return d->singleStep.toDouble();
0
294}-
295-
296void QDoubleSpinBox::setSingleStep(double value)-
297{-
298 QDoubleSpinBoxPrivate * const d = d_func();-
299-
300 if (value >= 0
value >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
301 d->singleStep = value;-
302 d->updateEdit();-
303 }
never executed: end of block
0
304}
never executed: end of block
0
305double QDoubleSpinBox::minimum() const-
306{-
307 const QDoubleSpinBoxPrivate * const d = d_func();-
308-
309 return
never executed: return d->minimum.toDouble();
d->minimum.toDouble();
never executed: return d->minimum.toDouble();
0
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}
never executed: end of block
0
319double QDoubleSpinBox::maximum() const-
320{-
321 const QDoubleSpinBoxPrivate * const d = d_func();-
322-
323 return
never executed: return d->maximum.toDouble();
d->maximum.toDouble();
never executed: return d->maximum.toDouble();
0
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}
never executed: end of block
0
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}
never executed: end of block
0
340int QDoubleSpinBox::decimals() const-
341{-
342 const QDoubleSpinBoxPrivate * const d = d_func();-
343-
344 return
never executed: return d->decimals;
d->decimals;
never executed: return d->decimals;
0
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}
never executed: end of block
0
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
!d->showGroupSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
&& qAbs(value) >= 1000.0
qAbs(value) >= 1000.0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
360 str.remove(locale().groupSeparator());
never executed: str.remove(locale().groupSeparator());
0
361-
362 return
never executed: return str;
str;
never executed: return str;
0
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
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
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
never executed: return state;
state;
never executed: return state;
0
384}-
385-
386-
387-
388-
389-
390void QDoubleSpinBox::fixup(QString &input) const-
391{-
392 input.remove(locale().groupSeparator());-
393}
never executed: end of block
0
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}
never executed: end of block
0
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
ep != NeverEmitDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
413 pendingEmit = false;-
414 if (ep == AlwaysEmit
ep == AlwaysEmitDescription
TRUEnever evaluated
FALSEnever evaluated
|| value != old
value != oldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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-
426QString QSpinBoxPrivate::textFromValue(const QVariant &value) const-
427{-
428 const QSpinBox * const q = q_func();-
429 return
never executed: return q->textFromValue(value.toInt());
q->textFromValue(value.toInt());
never executed: return q->textFromValue(value.toInt());
0
430}-
431-
432-
433-
434-
435-
436QVariant QSpinBoxPrivate::valueFromText(const QString &text) const-
437{-
438 const QSpinBox * const q = q_func();-
439-
440 return
never executed: return QVariant(q->valueFromText(text));
QVariant(q->valueFromText(text));
never executed: return QVariant(q->valueFromText(text));
0
441}-
442QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,-
443 QValidator::State &state) const-
444{-
445 if (cachedText == input
cachedText == inputDescription
TRUEnever evaluated
FALSEnever evaluated
&& !input.isEmpty()
!input.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
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: return cachedValue;
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
max != minDescription
TRUEnever evaluated
FALSEnever evaluated
&& (copy.isEmpty()
copy.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
461 || (min < 0
min < 0Description
TRUEnever evaluated
FALSEnever evaluated
&& copy == QLatin1String("-")
copy == QLatin1String("-")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
462 || (max >= 0
max >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& copy == QLatin1String("+")
copy == QLatin1String("+")Description
TRUEnever evaluated
FALSEnever evaluated
))) {
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: 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
466 state = QValidator::Invalid;-
467 }
never executed: end of block
else {
0
468 bool ok = false;-
469 if (displayIntegerBase != 10
displayIntegerBase != 10Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
470 num = copy.toInt(&ok, displayIntegerBase);-
471 }
never executed: end of block
else {
0
472 num = locale.toInt(copy, &ok);-
473 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
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
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
481 state = QValidator::Invalid;-
482 }
never executed: end of block
else if (num >= min
num >= minDescription
TRUEnever evaluated
FALSEnever evaluated
&& num <= max
num <= maxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
483 state = QValidator::Acceptable;-
484 }
never executed: end of block
else if (max == min
max == minDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
485 state = QValidator::Invalid;-
486 }
never executed: end of block
else {
0
487 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
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: end of block
else {
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
state != QVali...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
497 num = max > 0
max > 0Description
TRUEnever evaluated
FALSEnever evaluated
? min : max;
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: return cachedValue;
cachedValue;
never executed: return cachedValue;
0
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}
never executed: end of block
0
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
ep != NeverEmitDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
528 pendingEmit = false;-
529 if (ep == AlwaysEmit
ep == AlwaysEmitDescription
TRUEnever evaluated
FALSEnever evaluated
|| value != old
value != oldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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-
541QVariant QDoubleSpinBoxPrivate::valueFromText(const QString &f) const-
542{-
543 const QDoubleSpinBox * const q = q_func();-
544 return
never executed: return QVariant(q->valueFromText(f));
QVariant(q->valueFromText(f));
never executed: return QVariant(q->valueFromText(f));
0
545}-
546double QDoubleSpinBoxPrivate::round(double value) const-
547{-
548 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
549}-
550QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,-
551 QValidator::State &state) const-
552{-
553 if (cachedText == input
cachedText == inputDescription
TRUEnever evaluated
FALSEnever evaluated
&& !input.isEmpty()
!input.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
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: return cachedValue;
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: case 0:
0:
never executed: case 0:
0
571 state = max != min
max != minDescription
TRUEnever evaluated
FALSEnever evaluated
? QValidator::Intermediate : QValidator::Invalid;
0
572 goto
never executed: goto end;
end;
never executed: goto end;
0
573 case
never executed: case 1:
1:
never executed: case 1:
0
574 if (copy.at(0) == locale.decimalPoint()
copy.at(0) == ...decimalPoint()Description
TRUEnever evaluated
FALSEnever evaluated
0
575 || (plus
plusDescription
TRUEnever evaluated
FALSEnever evaluated
&& copy.at(0) == QLatin1Char('+')
copy.at(0) == QLatin1Char('+')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
576 || (minus
minusDescription
TRUEnever evaluated
FALSEnever evaluated
&& copy.at(0) == QLatin1Char('-')
copy.at(0) == QLatin1Char('-')Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
577 state = QValidator::Intermediate;-
578 goto
never executed: goto end;
end;
never executed: goto end;
0
579 }-
580 break;
never executed: break;
0
581 case
never executed: case 2:
2:
never executed: case 2:
0
582 if (copy.at(1) == locale.decimalPoint()
copy.at(1) == ...decimalPoint()Description
TRUEnever evaluated
FALSEnever evaluated
0
583 && ((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
584 state = QValidator::Intermediate;-
585 goto
never executed: goto end;
end;
never executed: goto end;
0
586 }-
587 break;
never executed: break;
0
588 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
589 }-
590-
591 if (copy.at(0) == locale.groupSeparator()
copy.at(0) == ...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
) {
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: goto end;
end;
never executed: goto end;
0
595 } else if (len > 1
len > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
596 const int dec = copy.indexOf(locale.decimalPoint());-
597 if (dec != -1
dec != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
598 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
599 copy.remove(dec + 1, 1);-
600 }
never executed: end of block
0
601-
602 if (copy.size() - dec > decimals + 1
copy.size() - ...> decimals + 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
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: goto end;
end;
never executed: goto end;
0
606 }-
607 for (int i=dec + 1; i<copy.size()
i<copy.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
608 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
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: goto end;
end;
never executed: goto end;
0
612 }-
613 }
never executed: end of block
0
614 }
never executed: end of block
else {
0
615 const QChar last = copy.at(len - 1);-
616 const QChar secondLast = copy.at(len - 2);-
617 if ((last == locale.groupSeparator()
last == locale...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
|| last.isSpace()
last.isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
618 && (secondLast == locale.groupSeparator()
secondLast == ...oupSeparator()Description
TRUEnever evaluated
FALSEnever evaluated
|| secondLast.isSpace()
secondLast.isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
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: goto end;
end;
never executed: goto end;
0
622 } 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
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: goto end;
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
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
636 if (locale.groupSeparator().isPrint()
locale.groupSe...or().isPrint()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
637 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
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: goto end;
end;
never executed: goto end;
0
641 }-
642-
643 const int len = copy.size();-
644 for (int i=0; i<len- 1
i<len- 1Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
645 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
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: goto end;
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
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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: goto end;
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
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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: end of block
else if (num >= min
num >= minDescription
TRUEnever evaluated
FALSEnever evaluated
&& num <= max
num <= maxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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: end of block
else if (max == min
max == minDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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: end of block
else {
0
675 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
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: end of block
else {
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-
685end:
code before this statement never executed: end:
0
686 if (state != QValidator::Acceptable
state != QVali...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
687 num = max > 0
max > 0Description
TRUEnever evaluated
FALSEnever evaluated
? min : max;
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: return QVariant(num);
QVariant(num);
never executed: return QVariant(num);
0
695}-
696-
697-
698-
699-
700-
701-
702QString QDoubleSpinBoxPrivate::textFromValue(const QVariant &f) const-
703{-
704 const QDoubleSpinBox * const q = q_func();-
705 return
never executed: return q->textFromValue(f.toDouble());
q->textFromValue(f.toDouble());
never executed: return q->textFromValue(f.toDouble());
0
706}-
707-
708-
709bool QSpinBox::event(QEvent *event)-
710{-
711 QSpinBoxPrivate * const d = d_func();-
712 if (event->type() == QEvent::StyleChange
event->type() ...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
713-
714-
715-
716 )-
717 d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);
never executed: d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);
0
718 return
never executed: return QAbstractSpinBox::event(event);
QAbstractSpinBox::event(event);
never executed: return QAbstractSpinBox::event(event);
0
719}-
720-
721-
722-
Switch to Source codePreprocessed file

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