widgets/qspinbox.cpp

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

Generated by Squish Coco Non-Commercial