Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | QAbstractSpinBox::QAbstractSpinBox(QWidget *parent) | - |
7 | : QWidget(*new QAbstractSpinBoxPrivate, parent, 0) | - |
8 | { | - |
9 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
10 | d->init(); | - |
11 | } executed: } Execution Count:1 | 1 |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | QAbstractSpinBox::QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent) | - |
17 | : QWidget(dd, parent, 0) | - |
18 | { | - |
19 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
20 | d->init(); | - |
21 | } executed: } Execution Count:392 | 392 |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | QAbstractSpinBox::~QAbstractSpinBox() | - |
28 | { | - |
29 | } | - |
30 | QAbstractSpinBox::ButtonSymbols QAbstractSpinBox::buttonSymbols() const | - |
31 | { | - |
32 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
33 | return d->buttonSymbols; executed: return d->buttonSymbols; Execution Count:2 | 2 |
34 | } | - |
35 | | - |
36 | void QAbstractSpinBox::setButtonSymbols(ButtonSymbols buttonSymbols) | - |
37 | { | - |
38 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
39 | if (d->buttonSymbols != buttonSymbols) { evaluated: d->buttonSymbols != buttonSymbols yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
40 | d->buttonSymbols = buttonSymbols; | - |
41 | d->updateEditFieldGeometry(); | - |
42 | update(); | - |
43 | } executed: } Execution Count:2 | 2 |
44 | } executed: } Execution Count:3 | 3 |
45 | QString QAbstractSpinBox::text() const | - |
46 | { | - |
47 | return lineEdit()->displayText(); executed: return lineEdit()->displayText(); Execution Count:150 | 150 |
48 | } | - |
49 | QString QAbstractSpinBox::specialValueText() const | - |
50 | { | - |
51 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
52 | return d->specialValueText; executed: return d->specialValueText; Execution Count:4 | 4 |
53 | } | - |
54 | | - |
55 | void QAbstractSpinBox::setSpecialValueText(const QString &specialValueText) | - |
56 | { | - |
57 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
58 | | - |
59 | d->specialValueText = specialValueText; | - |
60 | d->cachedSizeHint = QSize(); | - |
61 | d->clearCache(); | - |
62 | d->updateEdit(); | - |
63 | } executed: } Execution Count:289 | 289 |
64 | bool QAbstractSpinBox::wrapping() const | - |
65 | { | - |
66 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
67 | return d->wrapping; executed: return d->wrapping; Execution Count:9 | 9 |
68 | } | - |
69 | | - |
70 | void QAbstractSpinBox::setWrapping(bool wrapping) | - |
71 | { | - |
72 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
73 | d->wrapping = wrapping; | - |
74 | } executed: } Execution Count:395 | 395 |
75 | bool QAbstractSpinBox::isReadOnly() const | - |
76 | { | - |
77 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
78 | return d->readOnly; never executed: return d->readOnly; | 0 |
79 | } | - |
80 | | - |
81 | void QAbstractSpinBox::setReadOnly(bool enable) | - |
82 | { | - |
83 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
84 | d->readOnly = enable; | - |
85 | d->edit->setReadOnly(enable); | - |
86 | update(); | - |
87 | } executed: } Execution Count:7 | 7 |
88 | bool QAbstractSpinBox::keyboardTracking() const | - |
89 | { | - |
90 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
91 | return d->keyboardTracking; never executed: return d->keyboardTracking; | 0 |
92 | } | - |
93 | | - |
94 | void QAbstractSpinBox::setKeyboardTracking(bool enable) | - |
95 | { | - |
96 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
97 | d->keyboardTracking = enable; | - |
98 | } executed: } Execution Count:5 | 5 |
99 | bool QAbstractSpinBox::hasFrame() const | - |
100 | { | - |
101 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
102 | return d->frame; never executed: return d->frame; | 0 |
103 | } | - |
104 | | - |
105 | | - |
106 | void QAbstractSpinBox::setFrame(bool enable) | - |
107 | { | - |
108 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
109 | d->frame = enable; | - |
110 | update(); | - |
111 | d->updateEditFieldGeometry(); | - |
112 | } executed: } Execution Count:40 | 40 |
113 | void QAbstractSpinBox::setAccelerated(bool accelerate) | - |
114 | { | - |
115 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
116 | d->accelerate = accelerate; | - |
117 | | - |
118 | } | 0 |
119 | bool QAbstractSpinBox::isAccelerated() const | - |
120 | { | - |
121 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
122 | return d->accelerate; never executed: return d->accelerate; | 0 |
123 | } | - |
124 | void QAbstractSpinBox::setCorrectionMode(CorrectionMode correctionMode) | - |
125 | { | - |
126 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
127 | d->correctionMode = correctionMode; | - |
128 | | - |
129 | } | 0 |
130 | QAbstractSpinBox::CorrectionMode QAbstractSpinBox::correctionMode() const | - |
131 | { | - |
132 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
133 | return d->correctionMode; never executed: return d->correctionMode; | 0 |
134 | } | - |
135 | bool QAbstractSpinBox::hasAcceptableInput() const | - |
136 | { | - |
137 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
138 | return d->edit->hasAcceptableInput(); executed: return d->edit->hasAcceptableInput(); Execution Count:1497 | 1497 |
139 | } | - |
140 | Qt::Alignment QAbstractSpinBox::alignment() const | - |
141 | { | - |
142 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
143 | | - |
144 | return (Qt::Alignment)d->edit->alignment(); executed: return (Qt::Alignment)d->edit->alignment(); Execution Count:1 | 1 |
145 | } | - |
146 | | - |
147 | void QAbstractSpinBox::setAlignment(Qt::Alignment flag) | - |
148 | { | - |
149 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
150 | | - |
151 | d->edit->setAlignment(flag); | - |
152 | } | 0 |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | | - |
158 | void QAbstractSpinBox::selectAll() | - |
159 | { | - |
160 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
161 | | - |
162 | | - |
163 | if (!d->specialValue()) { evaluated: !d->specialValue() yes Evaluation Count:388 | yes Evaluation Count:1 |
| 1-388 |
164 | const int tmp = d->edit->displayText().size() - d->suffix.size(); | - |
165 | d->edit->setSelection(tmp, -(tmp - d->prefix.size())); | - |
166 | } else { executed: } Execution Count:388 | 388 |
167 | d->edit->selectAll(); | - |
168 | } executed: } Execution Count:1 | 1 |
169 | } | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | void QAbstractSpinBox::clear() | - |
176 | { | - |
177 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
178 | | - |
179 | d->edit->setText(d->prefix + d->suffix); | - |
180 | d->edit->setCursorPosition(d->prefix.size()); | - |
181 | d->cleared = true; | - |
182 | } executed: } Execution Count:4 | 4 |
183 | QAbstractSpinBox::StepEnabled QAbstractSpinBox::stepEnabled() const | - |
184 | { | - |
185 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
186 | if (d->readOnly || d->type == QVariant::Invalid) evaluated: d->readOnly yes Evaluation Count:2 | yes Evaluation Count:1721 |
evaluated: d->type == QVariant::Invalid yes Evaluation Count:4 | yes Evaluation Count:1717 |
| 2-1721 |
187 | return StepNone; executed: return StepNone; Execution Count:6 | 6 |
188 | if (d->wrapping) evaluated: d->wrapping yes Evaluation Count:40 | yes Evaluation Count:1677 |
| 40-1677 |
189 | return StepEnabled(StepUpEnabled | StepDownEnabled); executed: return StepEnabled(StepUpEnabled | StepDownEnabled); Execution Count:40 | 40 |
190 | StepEnabled ret = StepNone; | - |
191 | if (d->variantCompare(d->value, d->maximum) < 0) { evaluated: d->variantCompare(d->value, d->maximum) < 0 yes Evaluation Count:1597 | yes Evaluation Count:80 |
| 80-1597 |
192 | ret |= StepUpEnabled; | - |
193 | } executed: } Execution Count:1597 | 1597 |
194 | if (d->variantCompare(d->value, d->minimum) > 0) { evaluated: d->variantCompare(d->value, d->minimum) > 0 yes Evaluation Count:308 | yes Evaluation Count:1369 |
| 308-1369 |
195 | ret |= StepDownEnabled; | - |
196 | } executed: } Execution Count:308 | 308 |
197 | return ret; executed: return ret; Execution Count:1677 | 1677 |
198 | } | - |
199 | QValidator::State QAbstractSpinBox::validate(QString & , int & ) const | - |
200 | { | - |
201 | return QValidator::Acceptable; never executed: return QValidator::Acceptable; | 0 |
202 | } | - |
203 | void QAbstractSpinBox::fixup(QString & ) const | - |
204 | { | - |
205 | } | - |
206 | | - |
207 | | - |
208 | | - |
209 | | - |
210 | | - |
211 | | - |
212 | | - |
213 | void QAbstractSpinBox::stepUp() | - |
214 | { | - |
215 | stepBy(1); | - |
216 | } executed: } Execution Count:4 | 4 |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
221 | | - |
222 | | - |
223 | | - |
224 | void QAbstractSpinBox::stepDown() | - |
225 | { | - |
226 | stepBy(-1); | - |
227 | } executed: } Execution Count:8 | 8 |
228 | void QAbstractSpinBox::stepBy(int steps) | - |
229 | { | - |
230 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
231 | | - |
232 | const QVariant old = d->value; | - |
233 | QString tmp = d->edit->displayText(); | - |
234 | int cursorPos = d->edit->cursorPosition(); | - |
235 | bool dontstep = false; | - |
236 | EmitPolicy e = EmitIfChanged; | - |
237 | if (d->pendingEmit) { partially evaluated: d->pendingEmit no Evaluation Count:0 | yes Evaluation Count:123 |
| 0-123 |
238 | dontstep = validate(tmp, cursorPos) != QValidator::Acceptable; | - |
239 | d->cleared = false; | - |
240 | d->interpret(NeverEmit); | - |
241 | if (d->value != old) never evaluated: d->value != old | 0 |
242 | e = AlwaysEmit; never executed: e = AlwaysEmit; | 0 |
243 | } | 0 |
244 | if (!dontstep) { partially evaluated: !dontstep yes Evaluation Count:123 | no Evaluation Count:0 |
| 0-123 |
245 | d->setValue(d->bound(d->value + (d->singleStep * steps), old, steps), e); | - |
246 | } else if (e == AlwaysEmit) { never evaluated: e == AlwaysEmit executed: } Execution Count:123 | 0-123 |
247 | d->emitSignals(e, old); | - |
248 | } | 0 |
249 | selectAll(); | - |
250 | } executed: } Execution Count:123 | 123 |
251 | | - |
252 | | - |
253 | | - |
254 | | - |
255 | | - |
256 | QLineEdit *QAbstractSpinBox::lineEdit() const | - |
257 | { | - |
258 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
259 | | - |
260 | return d->edit; executed: return d->edit; Execution Count:447 | 447 |
261 | } | - |
262 | void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit) | - |
263 | { | - |
264 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
265 | | - |
266 | if (!lineEdit) { evaluated: !lineEdit yes Evaluation Count:1 | yes Evaluation Count:394 |
| 1-394 |
267 | qt_noop(); | - |
268 | return; executed: return; Execution Count:1 | 1 |
269 | } | - |
270 | delete d->edit; | - |
271 | d->edit = lineEdit; | - |
272 | if (!d->edit->validator()) partially evaluated: !d->edit->validator() yes Evaluation Count:394 | no Evaluation Count:0 |
| 0-394 |
273 | d->edit->setValidator(d->validator); executed: d->edit->setValidator(d->validator); Execution Count:394 | 394 |
274 | | - |
275 | if (d->edit->parent() != this) evaluated: d->edit->parent() != this yes Evaluation Count:1 | yes Evaluation Count:393 |
| 1-393 |
276 | d->edit->setParent(this); executed: d->edit->setParent(this); Execution Count:1 | 1 |
277 | | - |
278 | d->edit->setFrame(false); | - |
279 | d->edit->setFocusProxy(this); | - |
280 | d->edit->setAcceptDrops(false); | - |
281 | | - |
282 | if (d->type != QVariant::Invalid) { evaluated: d->type != QVariant::Invalid yes Evaluation Count:392 | yes Evaluation Count:2 |
| 2-392 |
283 | connect(d->edit, "2""textChanged(QString)", | - |
284 | this, "1""_q_editorTextChanged(QString)"); | - |
285 | connect(d->edit, "2""cursorPositionChanged(int,int)", | - |
286 | this, "1""_q_editorCursorPositionChanged(int,int)"); | - |
287 | } executed: } Execution Count:392 | 392 |
288 | d->updateEditFieldGeometry(); | - |
289 | d->edit->setContextMenuPolicy(Qt::NoContextMenu); | - |
290 | | - |
291 | if (isVisible()) partially evaluated: isVisible() no Evaluation Count:0 | yes Evaluation Count:394 |
| 0-394 |
292 | d->edit->show(); never executed: d->edit->show(); | 0 |
293 | if (isVisible()) partially evaluated: isVisible() no Evaluation Count:0 | yes Evaluation Count:394 |
| 0-394 |
294 | d->updateEdit(); never executed: d->updateEdit(); | 0 |
295 | } executed: } Execution Count:394 | 394 |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | | - |
301 | | - |
302 | | - |
303 | void QAbstractSpinBox::interpretText() | - |
304 | { | - |
305 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
306 | d->interpret(EmitIfChanged); | - |
307 | } executed: } Execution Count:3 | 3 |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const | - |
316 | { | - |
317 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
318 | return d->edit->inputMethodQuery(query); executed: return d->edit->inputMethodQuery(query); Execution Count:461 | 461 |
319 | } | - |
320 | | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | bool QAbstractSpinBox::event(QEvent *event) | - |
326 | { | - |
327 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
328 | switch (event->type()) { | - |
329 | case QEvent::FontChange: | - |
330 | case QEvent::StyleChange: | - |
331 | d->cachedSizeHint = d->cachedMinimumSizeHint = QSize(); | - |
332 | break; executed: break; Execution Count:2 | 2 |
333 | case QEvent::ApplicationLayoutDirectionChange: | - |
334 | case QEvent::LayoutDirectionChange: | - |
335 | d->updateEditFieldGeometry(); | - |
336 | break; executed: break; Execution Count:6 | 6 |
337 | case QEvent::HoverEnter: | - |
338 | case QEvent::HoverLeave: | - |
339 | case QEvent::HoverMove: | - |
340 | if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) never evaluated: const QHoverEvent *he = static_cast<const QHoverEvent *>(event) | 0 |
341 | d->updateHoverControl(he->pos()); never executed: d->updateHoverControl(he->pos()); | 0 |
342 | break; | 0 |
343 | case QEvent::ShortcutOverride: | - |
344 | if (d->edit->event(event)) partially evaluated: d->edit->event(event) yes Evaluation Count:2393 | no Evaluation Count:0 |
| 0-2393 |
345 | return true; executed: return true; Execution Count:2393 | 2393 |
346 | break; | 0 |
347 | case QEvent::InputMethod: | - |
348 | return d->edit->event(event); never executed: return d->edit->event(event); | 0 |
349 | default: | - |
350 | break; executed: break; Execution Count:9267 | 9267 |
351 | } | - |
352 | return QWidget::event(event); executed: return QWidget::event(event); Execution Count:9275 | 9275 |
353 | } | - |
354 | | - |
355 | | - |
356 | | - |
357 | | - |
358 | | - |
359 | void QAbstractSpinBox::showEvent(QShowEvent *) | - |
360 | { | - |
361 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
362 | d->reset(); | - |
363 | | - |
364 | if (d->ignoreUpdateEdit) { evaluated: d->ignoreUpdateEdit yes Evaluation Count:1 | yes Evaluation Count:265 |
| 1-265 |
365 | d->ignoreUpdateEdit = false; | - |
366 | } else { executed: } Execution Count:1 | 1 |
367 | d->updateEdit(); | - |
368 | } executed: } Execution Count:265 | 265 |
369 | } | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | | - |
375 | void QAbstractSpinBox::changeEvent(QEvent *event) | - |
376 | { | - |
377 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
378 | | - |
379 | switch (event->type()) { | - |
380 | case QEvent::StyleChange: | - |
381 | d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, 0, this); | - |
382 | d->spinClickThresholdTimerInterval = | - |
383 | style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, 0, this); | - |
384 | d->reset(); | - |
385 | d->updateEditFieldGeometry(); | - |
386 | break; executed: break; Execution Count:2 | 2 |
387 | case QEvent::EnabledChange: | - |
388 | if (!isEnabled()) { partially evaluated: !isEnabled() yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
389 | d->reset(); | - |
390 | } executed: } Execution Count:6 | 6 |
391 | break; executed: break; Execution Count:6 | 6 |
392 | case QEvent::ActivationChange: | - |
393 | if (!isActiveWindow()){ evaluated: !isActiveWindow() yes Evaluation Count:36 | yes Evaluation Count:74 |
| 36-74 |
394 | d->reset(); | - |
395 | if (d->pendingEmit) evaluated: d->pendingEmit yes Evaluation Count:1 | yes Evaluation Count:35 |
| 1-35 |
396 | d->interpret(EmitIfChanged); executed: d->interpret(EmitIfChanged); Execution Count:1 | 1 |
397 | } executed: } Execution Count:36 | 36 |
398 | break; executed: break; Execution Count:110 | 110 |
399 | default: | - |
400 | break; executed: break; Execution Count:15 | 15 |
401 | } | - |
402 | QWidget::changeEvent(event); | - |
403 | } executed: } Execution Count:133 | 133 |
404 | | - |
405 | | - |
406 | | - |
407 | | - |
408 | | - |
409 | void QAbstractSpinBox::resizeEvent(QResizeEvent *event) | - |
410 | { | - |
411 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
412 | QWidget::resizeEvent(event); | - |
413 | | - |
414 | d->updateEditFieldGeometry(); | - |
415 | update(); | - |
416 | } executed: } Execution Count:297 | 297 |
417 | | - |
418 | | - |
419 | | - |
420 | | - |
421 | | - |
422 | QSize QAbstractSpinBox::sizeHint() const | - |
423 | { | - |
424 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
425 | if (d->cachedSizeHint.isEmpty()) { partially evaluated: d->cachedSizeHint.isEmpty() yes Evaluation Count:236 | no Evaluation Count:0 |
| 0-236 |
426 | ensurePolished(); | - |
427 | | - |
428 | const QFontMetrics fm(fontMetrics()); | - |
429 | int h = d->edit->sizeHint().height() + 4; | - |
430 | int w = 0; | - |
431 | QString s; | - |
432 | s = d->prefix + d->textFromValue(d->minimum) + d->suffix + QLatin1Char(' '); | - |
433 | s.truncate(18); | - |
434 | w = qMax(w, fm.width(s)); | - |
435 | s = d->prefix + d->textFromValue(d->maximum) + d->suffix + QLatin1Char(' '); | - |
436 | s.truncate(18); | - |
437 | w = qMax(w, fm.width(s)); | - |
438 | if (d->specialValueText.size()) { evaluated: d->specialValueText.size() yes Evaluation Count:3 | yes Evaluation Count:233 |
| 3-233 |
439 | s = d->specialValueText; | - |
440 | w = qMax(w, fm.width(s)); | - |
441 | } executed: } Execution Count:3 | 3 |
442 | w += 2; | - |
443 | | - |
444 | QStyleOptionSpinBox opt; | - |
445 | initStyleOption(&opt); | - |
446 | QSize hint(w, h); | - |
447 | d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) | - |
448 | .expandedTo(QApplication::globalStrut()); | - |
449 | } executed: } Execution Count:236 | 236 |
450 | return d->cachedSizeHint; executed: return d->cachedSizeHint; Execution Count:236 | 236 |
451 | } | - |
452 | | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | QSize QAbstractSpinBox::minimumSizeHint() const | - |
458 | { | - |
459 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
460 | if (d->cachedMinimumSizeHint.isEmpty()) { evaluated: d->cachedMinimumSizeHint.isEmpty() yes Evaluation Count:54 | yes Evaluation Count:4 |
| 4-54 |
461 | ensurePolished(); | - |
462 | | - |
463 | const QFontMetrics fm(fontMetrics()); | - |
464 | int h = d->edit->minimumSizeHint().height(); | - |
465 | int w = fm.width(QLatin1String("1000")); | - |
466 | w += 2; | - |
467 | | - |
468 | QStyleOptionSpinBox opt; | - |
469 | initStyleOption(&opt); | - |
470 | QSize hint(w, h); | - |
471 | QSize extra(35, 6); | - |
472 | opt.rect.setSize(hint + extra); | - |
473 | extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, | - |
474 | QStyle::SC_SpinBoxEditField, this).size(); | - |
475 | | - |
476 | opt.rect.setSize(hint + extra); | - |
477 | extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, | - |
478 | QStyle::SC_SpinBoxEditField, this).size(); | - |
479 | hint += extra; | - |
480 | | - |
481 | opt.rect = rect(); | - |
482 | | - |
483 | d->cachedMinimumSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) | - |
484 | .expandedTo(QApplication::globalStrut()); | - |
485 | } executed: } Execution Count:54 | 54 |
486 | return d->cachedMinimumSizeHint; executed: return d->cachedMinimumSizeHint; Execution Count:58 | 58 |
487 | } | - |
488 | | - |
489 | | - |
490 | | - |
491 | | - |
492 | | - |
493 | void QAbstractSpinBox::paintEvent(QPaintEvent *) | - |
494 | { | - |
495 | QStyleOptionSpinBox opt; | - |
496 | initStyleOption(&opt); | - |
497 | QStylePainter p(this); | - |
498 | p.drawComplexControl(QStyle::CC_SpinBox, opt); | - |
499 | } executed: } Execution Count:196 | 196 |
500 | void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) | - |
501 | { | - |
502 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
503 | | - |
504 | if (!event->text().isEmpty() && d->edit->cursorPosition() < d->prefix.size()) evaluated: !event->text().isEmpty() yes Evaluation Count:805 | yes Evaluation Count:1284 |
partially evaluated: d->edit->cursorPosition() < d->prefix.size() no Evaluation Count:0 | yes Evaluation Count:805 |
| 0-1284 |
505 | d->edit->setCursorPosition(d->prefix.size()); never executed: d->edit->setCursorPosition(d->prefix.size()); | 0 |
506 | | - |
507 | int steps = 1; | - |
508 | bool isPgUpOrDown = false; | - |
509 | switch (event->key()) { | - |
510 | case Qt::Key_PageUp: | - |
511 | case Qt::Key_PageDown: | - |
512 | steps *= 10; | - |
513 | isPgUpOrDown = true; | - |
514 | case Qt::Key_Up: | - |
515 | case Qt::Key_Down: { | - |
516 | event->accept(); | - |
517 | const bool up = (event->key() == Qt::Key_PageUp || event->key() == Qt::Key_Up); evaluated: event->key() == Qt::Key_PageUp yes Evaluation Count:2 | yes Evaluation Count:1018 |
evaluated: event->key() == Qt::Key_Up yes Evaluation Count:806 | yes Evaluation Count:212 |
| 2-1018 |
518 | if (!(stepEnabled() & (up ? StepUpEnabled : StepDownEnabled))) evaluated: !(stepEnabled() & (up ? StepUpEnabled : StepDownEnabled)) yes Evaluation Count:49 | yes Evaluation Count:971 |
| 49-971 |
519 | return; executed: return; Execution Count:49 | 49 |
520 | if (!up) evaluated: !up yes Evaluation Count:206 | yes Evaluation Count:765 |
| 206-765 |
521 | steps *= -1; executed: steps *= -1; Execution Count:206 | 206 |
522 | if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this)) { partially evaluated: style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this) no Evaluation Count:0 | yes Evaluation Count:971 |
| 0-971 |
523 | d->buttonState = (Keyboard | (up ? Up : Down)); | - |
524 | } | 0 |
525 | if (d->spinClickTimerId == -1) partially evaluated: d->spinClickTimerId == -1 yes Evaluation Count:971 | no Evaluation Count:0 |
| 0-971 |
526 | stepBy(steps); executed: stepBy(steps); Execution Count:971 | 971 |
527 | if(event->isAutoRepeat() && !isPgUpOrDown) { partially evaluated: event->isAutoRepeat() no Evaluation Count:0 | yes Evaluation Count:971 |
never evaluated: !isPgUpOrDown | 0-971 |
528 | if(d->spinClickThresholdTimerId == -1 && d->spinClickTimerId == -1) { never evaluated: d->spinClickThresholdTimerId == -1 never evaluated: d->spinClickTimerId == -1 | 0 |
529 | d->updateState(up, true); | - |
530 | } | 0 |
531 | } | 0 |
532 | | - |
533 | QAccessibleValueChangeEvent event(this, d->value); | - |
534 | QAccessible::updateAccessibility(&event); | - |
535 | | - |
536 | return; executed: return; Execution Count:971 | 971 |
537 | } | - |
538 | case Qt::Key_Enter: | - |
539 | case Qt::Key_Return: | - |
540 | d->edit->d_func()->control->clearUndo(); | - |
541 | d->interpret(d->keyboardTracking ? AlwaysEmit : EmitIfChanged); | - |
542 | selectAll(); | - |
543 | event->ignore(); | - |
544 | editingFinished(); | - |
545 | return; executed: return; Execution Count:28 | 28 |
546 | case Qt::Key_U: | - |
547 | if (event->modifiers() & Qt::ControlModifier partially evaluated: event->modifiers() & Qt::ControlModifier no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
548 | && QGuiApplication::platformName() == QLatin1String("xcb")) { never evaluated: QGuiApplication::platformName() == QLatin1String("xcb") | 0 |
549 | event->accept(); | - |
550 | if (!isReadOnly()) never evaluated: !isReadOnly() | 0 |
551 | clear(); | 0 |
552 | return; | 0 |
553 | } | - |
554 | break; executed: break; Execution Count:2 | 2 |
555 | | - |
556 | case Qt::Key_End: | - |
557 | case Qt::Key_Home: | - |
558 | if (event->modifiers() & Qt::ShiftModifier) { evaluated: event->modifiers() & Qt::ShiftModifier yes Evaluation Count:2 | yes Evaluation Count:52 |
| 2-52 |
559 | int currentPos = d->edit->cursorPosition(); | - |
560 | const QString text = d->edit->displayText(); | - |
561 | if (event->key() == Qt::Key_End) { partially evaluated: event->key() == Qt::Key_End yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
562 | if ((currentPos == 0 && !d->prefix.isEmpty()) || text.size() - d->suffix.size() <= currentPos) { partially evaluated: currentPos == 0 yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: !d->prefix.isEmpty() yes Evaluation Count:2 | no Evaluation Count:0 |
never evaluated: text.size() - d->suffix.size() <= currentPos | 0-2 |
563 | break; executed: break; Execution Count:2 | 2 |
564 | } else { | - |
565 | d->edit->setSelection(currentPos, text.size() - d->suffix.size() - currentPos); | - |
566 | } | 0 |
567 | } else { | - |
568 | if ((currentPos == text.size() && !d->suffix.isEmpty()) || currentPos <= d->prefix.size()) { never evaluated: currentPos == text.size() never evaluated: !d->suffix.isEmpty() never evaluated: currentPos <= d->prefix.size() | 0 |
569 | break; | 0 |
570 | } else { | - |
571 | d->edit->setSelection(currentPos, d->prefix.size() - currentPos); | - |
572 | } | 0 |
573 | } | - |
574 | event->accept(); | - |
575 | return; | 0 |
576 | } | - |
577 | break; executed: break; Execution Count:52 | 52 |
578 | | - |
579 | default: | - |
580 | | - |
581 | if (event == QKeySequence::SelectAll) { partially evaluated: event == QKeySequence::SelectAll no Evaluation Count:0 | yes Evaluation Count:985 |
| 0-985 |
582 | selectAll(); | - |
583 | event->accept(); | - |
584 | return; | 0 |
585 | } | - |
586 | | - |
587 | break; executed: break; Execution Count:985 | 985 |
588 | } | - |
589 | | - |
590 | d->edit->event(event); | - |
591 | if (!isVisible()) evaluated: !isVisible() yes Evaluation Count:73 | yes Evaluation Count:968 |
| 73-968 |
592 | d->ignoreUpdateEdit = true; executed: d->ignoreUpdateEdit = true; Execution Count:73 | 73 |
593 | } executed: } Execution Count:1041 | 1041 |
594 | | - |
595 | | - |
596 | | - |
597 | | - |
598 | | - |
599 | void QAbstractSpinBox::keyReleaseEvent(QKeyEvent *event) | - |
600 | { | - |
601 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
602 | | - |
603 | if (d->buttonState & Keyboard && !event->isAutoRepeat()) { partially evaluated: d->buttonState & Keyboard no Evaluation Count:0 | yes Evaluation Count:2290 |
never evaluated: !event->isAutoRepeat() | 0-2290 |
604 | d->reset(); | - |
605 | } else { | 0 |
606 | d->edit->event(event); | - |
607 | } executed: } Execution Count:2290 | 2290 |
608 | } | - |
609 | | - |
610 | | - |
611 | | - |
612 | | - |
613 | | - |
614 | | - |
615 | void QAbstractSpinBox::wheelEvent(QWheelEvent *event) | - |
616 | { | - |
617 | const int steps = (event->delta() > 0 ? 1 : -1); partially evaluated: event->delta() > 0 yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
618 | if (stepEnabled() & (steps > 0 ? StepUpEnabled : StepDownEnabled)) partially evaluated: stepEnabled() & (steps > 0 ? StepUpEnabled : StepDownEnabled) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
619 | stepBy(event->modifiers() & Qt::ControlModifier ? steps * 10 : steps); executed: stepBy(event->modifiers() & Qt::ControlModifier ? steps * 10 : steps); Execution Count:2 | 2 |
620 | event->accept(); | - |
621 | } executed: } Execution Count:2 | 2 |
622 | | - |
623 | | - |
624 | | - |
625 | | - |
626 | | - |
627 | | - |
628 | void QAbstractSpinBox::focusInEvent(QFocusEvent *event) | - |
629 | { | - |
630 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
631 | | - |
632 | d->edit->event(event); | - |
633 | if (event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason) { evaluated: event->reason() == Qt::TabFocusReason yes Evaluation Count:22 | yes Evaluation Count:94 |
partially evaluated: event->reason() == Qt::BacktabFocusReason no Evaluation Count:0 | yes Evaluation Count:94 |
| 0-94 |
634 | selectAll(); | - |
635 | } executed: } Execution Count:22 | 22 |
636 | QWidget::focusInEvent(event); | - |
637 | } executed: } Execution Count:116 | 116 |
638 | | - |
639 | | - |
640 | | - |
641 | | - |
642 | | - |
643 | void QAbstractSpinBox::focusOutEvent(QFocusEvent *event) | - |
644 | { | - |
645 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
646 | | - |
647 | if (d->pendingEmit) evaluated: d->pendingEmit yes Evaluation Count:1 | yes Evaluation Count:56 |
| 1-56 |
648 | d->interpret(EmitIfChanged); executed: d->interpret(EmitIfChanged); Execution Count:1 | 1 |
649 | | - |
650 | d->reset(); | - |
651 | d->edit->event(event); | - |
652 | d->updateEdit(); | - |
653 | QWidget::focusOutEvent(event); | - |
654 | | - |
655 | | - |
656 | | - |
657 | | - |
658 | | - |
659 | editingFinished(); | - |
660 | } executed: } Execution Count:57 | 57 |
661 | | - |
662 | | - |
663 | | - |
664 | | - |
665 | | - |
666 | void QAbstractSpinBox::closeEvent(QCloseEvent *event) | - |
667 | { | - |
668 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
669 | | - |
670 | d->reset(); | - |
671 | if (d->pendingEmit) never evaluated: d->pendingEmit | 0 |
672 | d->interpret(EmitIfChanged); never executed: d->interpret(EmitIfChanged); | 0 |
673 | QWidget::closeEvent(event); | - |
674 | } | 0 |
675 | | - |
676 | | - |
677 | | - |
678 | | - |
679 | | - |
680 | void QAbstractSpinBox::hideEvent(QHideEvent *event) | - |
681 | { | - |
682 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
683 | d->reset(); | - |
684 | if (d->pendingEmit) evaluated: d->pendingEmit yes Evaluation Count:1 | yes Evaluation Count:65 |
| 1-65 |
685 | d->interpret(EmitIfChanged); executed: d->interpret(EmitIfChanged); Execution Count:1 | 1 |
686 | QWidget::hideEvent(event); | - |
687 | } executed: } Execution Count:66 | 66 |
688 | | - |
689 | | - |
690 | | - |
691 | | - |
692 | | - |
693 | | - |
694 | void QAbstractSpinBox::timerEvent(QTimerEvent *event) | - |
695 | { | - |
696 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
697 | | - |
698 | bool doStep = false; | - |
699 | if (event->timerId() == d->spinClickThresholdTimerId) { never evaluated: event->timerId() == d->spinClickThresholdTimerId | 0 |
700 | killTimer(d->spinClickThresholdTimerId); | - |
701 | d->spinClickThresholdTimerId = -1; | - |
702 | d->effectiveSpinRepeatRate = d->buttonState & Keyboard never evaluated: d->buttonState & Keyboard | 0 |
703 | ? (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->keyboardAutoRepeatRate() | - |
704 | : d->spinClickTimerInterval; | - |
705 | d->spinClickTimerId = startTimer(d->effectiveSpinRepeatRate); | - |
706 | doStep = true; | - |
707 | } else if (event->timerId() == d->spinClickTimerId) { never evaluated: event->timerId() == d->spinClickTimerId | 0 |
708 | if (d->accelerate) { never evaluated: d->accelerate | 0 |
709 | d->acceleration = d->acceleration + (int)(d->effectiveSpinRepeatRate * 0.05); | - |
710 | if (d->effectiveSpinRepeatRate - d->acceleration >= 10) { never evaluated: d->effectiveSpinRepeatRate - d->acceleration >= 10 | 0 |
711 | killTimer(d->spinClickTimerId); | - |
712 | d->spinClickTimerId = startTimer(d->effectiveSpinRepeatRate - d->acceleration); | - |
713 | } | 0 |
714 | } | 0 |
715 | doStep = true; | - |
716 | } | 0 |
717 | | - |
718 | if (doStep) { | 0 |
719 | const StepEnabled st = stepEnabled(); | - |
720 | if (d->buttonState & Up) { never evaluated: d->buttonState & Up | 0 |
721 | if (!(st & StepUpEnabled)) { never evaluated: !(st & StepUpEnabled) | 0 |
722 | d->reset(); | - |
723 | } else { | 0 |
724 | stepBy(1); | - |
725 | } | 0 |
726 | } else if (d->buttonState & Down) { never evaluated: d->buttonState & Down | 0 |
727 | if (!(st & StepDownEnabled)) { never evaluated: !(st & StepDownEnabled) | 0 |
728 | d->reset(); | - |
729 | } else { | 0 |
730 | stepBy(-1); | - |
731 | } | 0 |
732 | } | - |
733 | return; | 0 |
734 | } | - |
735 | QWidget::timerEvent(event); | - |
736 | return; | 0 |
737 | } | - |
738 | | - |
739 | | - |
740 | | - |
741 | | - |
742 | | - |
743 | void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event) | - |
744 | { | - |
745 | | - |
746 | | - |
747 | | - |
748 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
749 | | - |
750 | QPointer<QMenu> menu = d->edit->createStandardContextMenu(); | - |
751 | if (!menu) | 0 |
752 | return; | 0 |
753 | | - |
754 | d->reset(); | - |
755 | | - |
756 | QAction *selAll = new QAction(tr("&Select All"), menu); | - |
757 | menu->insertAction(d->edit->d_func()->selectAllAction, | - |
758 | selAll); | - |
759 | menu->removeAction(d->edit->d_func()->selectAllAction); | - |
760 | menu->addSeparator(); | - |
761 | const uint se = stepEnabled(); | - |
762 | QAction *up = menu->addAction(tr("&Step up")); | - |
763 | up->setEnabled(se & StepUpEnabled); | - |
764 | QAction *down = menu->addAction(tr("Step &down")); | - |
765 | down->setEnabled(se & StepDownEnabled); | - |
766 | menu->addSeparator(); | - |
767 | | - |
768 | const QPointer<QAbstractSpinBox> that = this; | - |
769 | const QPoint pos = (event->reason() == QContextMenuEvent::Mouse) never evaluated: (event->reason() == QContextMenuEvent::Mouse) | 0 |
770 | ? event->globalPos() : mapToGlobal(QPoint(event->pos().x(), 0)) + QPoint(width() / 2, height() / 2); | - |
771 | const QAction *action = menu->exec(pos); | - |
772 | delete static_cast<QMenu *>(menu); | - |
773 | if (that && action) { | 0 |
774 | if (action == up) { never evaluated: action == up | 0 |
775 | stepBy(1); | - |
776 | } else if (action == down) { never evaluated: action == down | 0 |
777 | stepBy(-1); | - |
778 | } else if (action == selAll) { never evaluated: action == selAll | 0 |
779 | selectAll(); | - |
780 | } | 0 |
781 | } | - |
782 | event->accept(); | - |
783 | | - |
784 | } | 0 |
785 | | - |
786 | | - |
787 | | - |
788 | | - |
789 | | - |
790 | void QAbstractSpinBox::mouseMoveEvent(QMouseEvent *event) | - |
791 | { | - |
792 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
793 | | - |
794 | d->updateHoverControl(event->pos()); | - |
795 | | - |
796 | | - |
797 | if (d->spinClickTimerId != -1 && d->buttonSymbols != NoButtons) { never evaluated: d->spinClickTimerId != -1 never evaluated: d->buttonSymbols != NoButtons | 0 |
798 | const StepEnabled se = stepEnabled(); | - |
799 | if ((se & StepUpEnabled) && d->hoverControl == QStyle::SC_SpinBoxUp) never evaluated: (se & StepUpEnabled) never evaluated: d->hoverControl == QStyle::SC_SpinBoxUp | 0 |
800 | d->updateState(true); never executed: d->updateState(true); | 0 |
801 | else if ((se & StepDownEnabled) && d->hoverControl == QStyle::SC_SpinBoxDown) never evaluated: (se & StepDownEnabled) never evaluated: d->hoverControl == QStyle::SC_SpinBoxDown | 0 |
802 | d->updateState(false); never executed: d->updateState(false); | 0 |
803 | else | - |
804 | d->reset(); never executed: d->reset(); | 0 |
805 | event->accept(); | - |
806 | } | 0 |
807 | } | 0 |
808 | | - |
809 | | - |
810 | | - |
811 | | - |
812 | | - |
813 | void QAbstractSpinBox::mousePressEvent(QMouseEvent *event) | - |
814 | { | - |
815 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
816 | | - |
817 | if (event->button() != Qt::LeftButton || d->buttonState != None) { partially evaluated: event->button() != Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: d->buttonState != None no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
818 | return; | 0 |
819 | } | - |
820 | | - |
821 | d->updateHoverControl(event->pos()); | - |
822 | event->accept(); | - |
823 | | - |
824 | const StepEnabled se = (d->buttonSymbols == NoButtons) ? StepEnabled(StepNone) : stepEnabled(); partially evaluated: (d->buttonSymbols == NoButtons) no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
825 | if ((se & StepUpEnabled) && d->hoverControl == QStyle::SC_SpinBoxUp) { partially evaluated: (se & StepUpEnabled) yes Evaluation Count:3 | no Evaluation Count:0 |
evaluated: d->hoverControl == QStyle::SC_SpinBoxUp yes Evaluation Count:1 | yes Evaluation Count:2 |
| 0-3 |
826 | d->updateState(true); | - |
827 | } else if ((se & StepDownEnabled) && d->hoverControl == QStyle::SC_SpinBoxDown) { executed: } Execution Count:1 evaluated: (se & StepDownEnabled) yes Evaluation Count:1 | yes Evaluation Count:1 |
partially evaluated: d->hoverControl == QStyle::SC_SpinBoxDown no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
828 | d->updateState(false); | - |
829 | } else { | 0 |
830 | event->ignore(); | - |
831 | } executed: } Execution Count:2 | 2 |
832 | } | - |
833 | | - |
834 | | - |
835 | | - |
836 | | - |
837 | void QAbstractSpinBox::mouseReleaseEvent(QMouseEvent *event) | - |
838 | { | - |
839 | QAbstractSpinBoxPrivate * const d = d_func(); | - |
840 | | - |
841 | if ((d->buttonState & Mouse) != 0) evaluated: (d->buttonState & Mouse) != 0 yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
842 | d->reset(); executed: d->reset(); Execution Count:2 | 2 |
843 | event->accept(); | - |
844 | } executed: } Execution Count:4 | 4 |
845 | QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate() | - |
846 | : edit(0), type(QVariant::Invalid), spinClickTimerId(-1), | - |
847 | spinClickTimerInterval(100), spinClickThresholdTimerId(-1), spinClickThresholdTimerInterval(-1), | - |
848 | effectiveSpinRepeatRate(1), buttonState(None), cachedText(QLatin1String("\x01")), | - |
849 | cachedState(QValidator::Invalid), pendingEmit(false), readOnly(false), wrapping(false), | - |
850 | ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), | - |
851 | cleared(false), ignoreUpdateEdit(false), correctionMode(QAbstractSpinBox::CorrectToPreviousValue), | - |
852 | acceleration(0), hoverControl(QStyle::SC_None), buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(0) | - |
853 | { | - |
854 | } executed: } Execution Count:393 | 393 |
855 | | - |
856 | | - |
857 | | - |
858 | | - |
859 | | - |
860 | QAbstractSpinBoxPrivate::~QAbstractSpinBoxPrivate() | - |
861 | { | - |
862 | } | - |
863 | | - |
864 | | - |
865 | | - |
866 | | - |
867 | | - |
868 | | - |
869 | bool QAbstractSpinBoxPrivate::updateHoverControl(const QPoint &pos) | - |
870 | { | - |
871 | QAbstractSpinBox * const q = q_func(); | - |
872 | QRect lastHoverRect = hoverRect; | - |
873 | QStyle::SubControl lastHoverControl = hoverControl; | - |
874 | bool doesHover = q->testAttribute(Qt::WA_Hover); | - |
875 | if (lastHoverControl != newHoverControl(pos) && doesHover) { partially evaluated: lastHoverControl != newHoverControl(pos) yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: doesHover no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
876 | q->update(lastHoverRect); | - |
877 | q->update(hoverRect); | - |
878 | return true; never executed: return true; | 0 |
879 | } | - |
880 | return !doesHover; executed: return !doesHover; Execution Count:5 | 5 |
881 | } | - |
882 | | - |
883 | | - |
884 | | - |
885 | | - |
886 | | - |
887 | | - |
888 | QStyle::SubControl QAbstractSpinBoxPrivate::newHoverControl(const QPoint &pos) | - |
889 | { | - |
890 | QAbstractSpinBox * const q = q_func(); | - |
891 | | - |
892 | QStyleOptionSpinBox opt; | - |
893 | q->initStyleOption(&opt); | - |
894 | opt.subControls = QStyle::SC_All; | - |
895 | hoverControl = q->style()->hitTestComplexControl(QStyle::CC_SpinBox, &opt, pos, q); | - |
896 | hoverRect = q->style()->subControlRect(QStyle::CC_SpinBox, &opt, hoverControl, q); | - |
897 | return hoverControl; executed: return hoverControl; Execution Count:3 | 3 |
898 | } | - |
899 | | - |
900 | | - |
901 | | - |
902 | | - |
903 | | - |
904 | | - |
905 | QString QAbstractSpinBoxPrivate::stripped(const QString &t, int *pos) const | - |
906 | { | - |
907 | QString text = t; | - |
908 | if (specialValueText.size() == 0 || text != specialValueText) { evaluated: specialValueText.size() == 0 yes Evaluation Count:2314 | yes Evaluation Count:6 |
partially evaluated: text != specialValueText yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-2314 |
909 | int from = 0; | - |
910 | int size = text.size(); | - |
911 | bool changed = false; | - |
912 | if (prefix.size() && text.startsWith(prefix)) { evaluated: prefix.size() yes Evaluation Count:43 | yes Evaluation Count:2277 |
partially evaluated: text.startsWith(prefix) yes Evaluation Count:43 | no Evaluation Count:0 |
| 0-2277 |
913 | from += prefix.size(); | - |
914 | size -= from; | - |
915 | changed = true; | - |
916 | } executed: } Execution Count:43 | 43 |
917 | if (suffix.size() && text.endsWith(suffix)) { evaluated: suffix.size() yes Evaluation Count:33 | yes Evaluation Count:2287 |
partially evaluated: text.endsWith(suffix) yes Evaluation Count:33 | no Evaluation Count:0 |
| 0-2287 |
918 | size -= suffix.size(); | - |
919 | changed = true; | - |
920 | } executed: } Execution Count:33 | 33 |
921 | if (changed) evaluated: changed yes Evaluation Count:55 | yes Evaluation Count:2265 |
| 55-2265 |
922 | text = text.mid(from, size); executed: text = text.mid(from, size); Execution Count:55 | 55 |
923 | } executed: } Execution Count:2320 | 2320 |
924 | | - |
925 | const int s = text.size(); | - |
926 | text = text.trimmed(); | - |
927 | if (pos) evaluated: pos yes Evaluation Count:2299 | yes Evaluation Count:21 |
| 21-2299 |
928 | (*pos) -= (s - text.size()); executed: (*pos) -= (s - text.size()); Execution Count:2299 | 2299 |
929 | return text; executed: return text; Execution Count:2320 | 2320 |
930 | | - |
931 | } | - |
932 | | - |
933 | void QAbstractSpinBoxPrivate::updateEditFieldGeometry() | - |
934 | { | - |
935 | QAbstractSpinBox * const q = q_func(); | - |
936 | QStyleOptionSpinBox opt; | - |
937 | q->initStyleOption(&opt); | - |
938 | opt.subControls = QStyle::SC_SpinBoxEditField; | - |
939 | edit->setGeometry(q->style()->subControlRect(QStyle::CC_SpinBox, &opt, | - |
940 | QStyle::SC_SpinBoxEditField, q)); | - |
941 | } executed: } Execution Count:738 | 738 |
942 | | - |
943 | | - |
944 | | - |
945 | | - |
946 | | - |
947 | bool QAbstractSpinBoxPrivate::specialValue() const | - |
948 | { | - |
949 | return (value == minimum && !specialValueText.isEmpty()); executed: return (value == minimum && !specialValueText.isEmpty()); Execution Count:16941 | 16941 |
950 | } | - |
951 | | - |
952 | | - |
953 | | - |
954 | | - |
955 | | - |
956 | | - |
957 | void QAbstractSpinBoxPrivate::emitSignals(EmitPolicy, const QVariant &) | - |
958 | { | - |
959 | } | - |
960 | void QAbstractSpinBoxPrivate::_q_editorTextChanged(const QString &t) | - |
961 | { | - |
962 | QAbstractSpinBox * const q = q_func(); | - |
963 | | - |
964 | if (keyboardTracking) { evaluated: keyboardTracking yes Evaluation Count:598 | yes Evaluation Count:13 |
| 13-598 |
965 | QString tmp = t; | - |
966 | int pos = edit->cursorPosition(); | - |
967 | QValidator::State state = q->validate(tmp, pos); | - |
968 | if (state == QValidator::Acceptable) { evaluated: state == QValidator::Acceptable yes Evaluation Count:326 | yes Evaluation Count:272 |
| 272-326 |
969 | const QVariant v = valueFromText(tmp); | - |
970 | setValue(v, EmitIfChanged, tmp != t); | - |
971 | pendingEmit = false; | - |
972 | } else { executed: } Execution Count:326 | 326 |
973 | pendingEmit = true; | - |
974 | } executed: } Execution Count:272 | 272 |
975 | } else { | - |
976 | pendingEmit = true; | - |
977 | } executed: } Execution Count:13 | 13 |
978 | } | - |
979 | void QAbstractSpinBoxPrivate::_q_editorCursorPositionChanged(int oldpos, int newpos) | - |
980 | { | - |
981 | if (!edit->hasSelectedText() && !ignoreCursorPositionChanged && !specialValue()) { evaluated: !edit->hasSelectedText() yes Evaluation Count:511 | yes Evaluation Count:216 |
partially evaluated: !ignoreCursorPositionChanged yes Evaluation Count:511 | no Evaluation Count:0 |
evaluated: !specialValue() yes Evaluation Count:508 | yes Evaluation Count:3 |
| 0-511 |
982 | ignoreCursorPositionChanged = true; | - |
983 | | - |
984 | bool allowSelection = true; | - |
985 | int pos = -1; | - |
986 | if (newpos < prefix.size() && newpos != 0) { evaluated: newpos < prefix.size() yes Evaluation Count:2 | yes Evaluation Count:506 |
partially evaluated: newpos != 0 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-506 |
987 | if (oldpos == 0) { never evaluated: oldpos == 0 | 0 |
988 | allowSelection = false; | - |
989 | pos = prefix.size(); | - |
990 | } else { | 0 |
991 | pos = oldpos; | - |
992 | } | 0 |
993 | } else if (newpos > edit->text().size() - suffix.size() partially evaluated: newpos > edit->text().size() - suffix.size() no Evaluation Count:0 | yes Evaluation Count:508 |
| 0-508 |
994 | && newpos != edit->text().size()) { never evaluated: newpos != edit->text().size() | 0 |
995 | if (oldpos == edit->text().size()) { never evaluated: oldpos == edit->text().size() | 0 |
996 | pos = edit->text().size() - suffix.size(); | - |
997 | allowSelection = false; | - |
998 | } else { | 0 |
999 | pos = edit->text().size(); | - |
1000 | } | 0 |
1001 | } | - |
1002 | if (pos != -1) { partially evaluated: pos != -1 no Evaluation Count:0 | yes Evaluation Count:508 |
| 0-508 |
1003 | const int selSize = edit->selectionStart() >= 0 && allowSelection never evaluated: edit->selectionStart() >= 0 never evaluated: allowSelection | 0 |
1004 | ? (edit->selectedText().size() | - |
1005 | * (newpos < pos ? -1 : 1)) - newpos + pos | - |
1006 | : 0; | - |
1007 | | - |
1008 | const bool wasBlocked = edit->blockSignals(true); | - |
1009 | if (selSize != 0) { never evaluated: selSize != 0 | 0 |
1010 | edit->setSelection(pos - selSize, selSize); | - |
1011 | } else { | 0 |
1012 | edit->setCursorPosition(pos); | - |
1013 | } | 0 |
1014 | edit->blockSignals(wasBlocked); | - |
1015 | } | 0 |
1016 | ignoreCursorPositionChanged = false; | - |
1017 | } executed: } Execution Count:508 | 508 |
1018 | } executed: } Execution Count:727 | 727 |
1019 | | - |
1020 | | - |
1021 | | - |
1022 | | - |
1023 | | - |
1024 | | - |
1025 | | - |
1026 | void QAbstractSpinBoxPrivate::init() | - |
1027 | { | - |
1028 | QAbstractSpinBox * const q = q_func(); | - |
1029 | | - |
1030 | q->setLineEdit(new QLineEdit(q)); | - |
1031 | edit->setObjectName(QLatin1String("qt_spinbox_lineedit")); | - |
1032 | validator = new QSpinBoxValidator(q, this); | - |
1033 | edit->setValidator(validator); | - |
1034 | | - |
1035 | QStyleOptionSpinBox opt; | - |
1036 | q->initStyleOption(&opt); | - |
1037 | spinClickTimerInterval = q->style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, &opt, q); | - |
1038 | spinClickThresholdTimerInterval = q->style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, &opt, q); | - |
1039 | q->setFocusPolicy(Qt::WheelFocus); | - |
1040 | q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::SpinBox)); | - |
1041 | q->setAttribute(Qt::WA_InputMethodEnabled); | - |
1042 | | - |
1043 | q->setAttribute(Qt::WA_MacShowFocusRect); | - |
1044 | } executed: } Execution Count:393 | 393 |
1045 | void QAbstractSpinBoxPrivate::reset() | - |
1046 | { | - |
1047 | QAbstractSpinBox * const q = q_func(); | - |
1048 | | - |
1049 | buttonState = None; | - |
1050 | if (q) { partially evaluated: q yes Evaluation Count:2164 | no Evaluation Count:0 |
| 0-2164 |
1051 | if (spinClickTimerId != -1) partially evaluated: spinClickTimerId != -1 no Evaluation Count:0 | yes Evaluation Count:2164 |
| 0-2164 |
1052 | q->killTimer(spinClickTimerId); never executed: q->killTimer(spinClickTimerId); | 0 |
1053 | if (spinClickThresholdTimerId != -1) evaluated: spinClickThresholdTimerId != -1 yes Evaluation Count:1 | yes Evaluation Count:2163 |
| 1-2163 |
1054 | q->killTimer(spinClickThresholdTimerId); executed: q->killTimer(spinClickThresholdTimerId); Execution Count:1 | 1 |
1055 | spinClickTimerId = spinClickThresholdTimerId = -1; | - |
1056 | acceleration = 0; | - |
1057 | q->update(); | - |
1058 | } executed: } Execution Count:2164 | 2164 |
1059 | } executed: } Execution Count:2164 | 2164 |
1060 | | - |
1061 | | - |
1062 | | - |
1063 | | - |
1064 | | - |
1065 | | - |
1066 | | - |
1067 | void QAbstractSpinBoxPrivate::updateState(bool up, bool fromKeyboard ) | - |
1068 | { | - |
1069 | QAbstractSpinBox * const q = q_func(); | - |
1070 | if ((up && (buttonState & Up)) || (!up && (buttonState & Down))) partially evaluated: up yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: (buttonState & Up) no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: !up no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: (buttonState & Down) | 0-1 |
1071 | return; | 0 |
1072 | reset(); | - |
1073 | if (q && (q->stepEnabled() & (up ? QAbstractSpinBox::StepUpEnabled partially evaluated: q yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1074 | : QAbstractSpinBox::StepDownEnabled))) { partially evaluated: (q->stepEnabled() & (up ? QAbstractSpinBox::StepUpEnabled : QAbstractSpinBox::StepDownEnabled)) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1075 | spinClickThresholdTimerId = q->startTimer(spinClickThresholdTimerInterval); | - |
1076 | buttonState = (up ? Up : Down) | (fromKeyboard ? Keyboard : Mouse); partially evaluated: up yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1077 | q->stepBy(up ? 1 : -1); | - |
1078 | | - |
1079 | QAccessibleValueChangeEvent event(q, value); | - |
1080 | QAccessible::updateAccessibility(&event); | - |
1081 | | - |
1082 | } executed: } Execution Count:1 | 1 |
1083 | } executed: } Execution Count:1 | 1 |
1084 | void QAbstractSpinBox::initStyleOption(QStyleOptionSpinBox *option) const | - |
1085 | { | - |
1086 | if (!option) partially evaluated: !option no Evaluation Count:0 | yes Evaluation Count:1651 |
| 0-1651 |
1087 | return; | 0 |
1088 | | - |
1089 | const QAbstractSpinBoxPrivate * const d = d_func(); | - |
1090 | option->initFrom(this); | - |
1091 | option->activeSubControls = QStyle::SC_None; | - |
1092 | option->buttonSymbols = d->buttonSymbols; | - |
1093 | option->subControls = QStyle::SC_SpinBoxFrame | QStyle::SC_SpinBoxEditField; | - |
1094 | if (d->buttonSymbols != QAbstractSpinBox::NoButtons) { evaluated: d->buttonSymbols != QAbstractSpinBox::NoButtons yes Evaluation Count:1650 | yes Evaluation Count:1 |
| 1-1650 |
1095 | option->subControls |= QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown; | - |
1096 | if (d->buttonState & Up) { partially evaluated: d->buttonState & Up no Evaluation Count:0 | yes Evaluation Count:1650 |
| 0-1650 |
1097 | option->activeSubControls = QStyle::SC_SpinBoxUp; | - |
1098 | } else if (d->buttonState & Down) { partially evaluated: d->buttonState & Down no Evaluation Count:0 | yes Evaluation Count:1650 |
| 0-1650 |
1099 | option->activeSubControls = QStyle::SC_SpinBoxDown; | - |
1100 | } | 0 |
1101 | } | - |
1102 | | - |
1103 | if (d->buttonState) { partially evaluated: d->buttonState no Evaluation Count:0 | yes Evaluation Count:1651 |
| 0-1651 |
1104 | option->state |= QStyle::State_Sunken; | - |
1105 | } else { | 0 |
1106 | option->activeSubControls = d->hoverControl; | - |
1107 | } executed: } Execution Count:1651 | 1651 |
1108 | | - |
1109 | option->stepEnabled = style()->styleHint(QStyle::SH_SpinControls_DisableOnBounds) partially evaluated: style()->styleHint(QStyle::SH_SpinControls_DisableOnBounds) yes Evaluation Count:1651 | no Evaluation Count:0 |
| 0-1651 |
1110 | ? stepEnabled() | - |
1111 | : (QAbstractSpinBox::StepDownEnabled|QAbstractSpinBox::StepUpEnabled); | - |
1112 | | - |
1113 | option->frame = d->frame; | - |
1114 | } executed: } Execution Count:1651 | 1651 |
1115 | QVariant QAbstractSpinBoxPrivate::bound(const QVariant &val, const QVariant &old, int steps) const | - |
1116 | { | - |
1117 | QVariant v = val; | - |
1118 | if (!wrapping || steps == 0 || old.isNull()) { evaluated: !wrapping yes Evaluation Count:6081 | yes Evaluation Count:1878 |
evaluated: steps == 0 yes Evaluation Count:1194 | yes Evaluation Count:684 |
partially evaluated: old.isNull() no Evaluation Count:0 | yes Evaluation Count:684 |
| 0-6081 |
1119 | if (variantCompare(v, minimum) < 0) { evaluated: variantCompare(v, minimum) < 0 yes Evaluation Count:271 | yes Evaluation Count:7004 |
| 271-7004 |
1120 | v = wrapping ? maximum : minimum; partially evaluated: wrapping no Evaluation Count:0 | yes Evaluation Count:271 |
| 0-271 |
1121 | } executed: } Execution Count:271 | 271 |
1122 | if (variantCompare(v, maximum) > 0) { evaluated: variantCompare(v, maximum) > 0 yes Evaluation Count:113 | yes Evaluation Count:7162 |
| 113-7162 |
1123 | v = wrapping ? minimum : maximum; partially evaluated: wrapping no Evaluation Count:0 | yes Evaluation Count:113 |
| 0-113 |
1124 | } executed: } Execution Count:113 | 113 |
1125 | } else { executed: } Execution Count:7275 | 7275 |
1126 | const bool wasMin = old == minimum; | - |
1127 | const bool wasMax = old == maximum; | - |
1128 | const int oldcmp = variantCompare(v, old); | - |
1129 | const int maxcmp = variantCompare(v, maximum); | - |
1130 | const int mincmp = variantCompare(v, minimum); | - |
1131 | const bool wrapped = (oldcmp > 0 && steps < 0) || (oldcmp < 0 && steps > 0); evaluated: oldcmp > 0 yes Evaluation Count:584 | yes Evaluation Count:100 |
evaluated: steps < 0 yes Evaluation Count:24 | yes Evaluation Count:560 |
evaluated: oldcmp < 0 yes Evaluation Count:93 | yes Evaluation Count:567 |
evaluated: steps > 0 yes Evaluation Count:17 | yes Evaluation Count:76 |
| 17-584 |
1132 | if (maxcmp > 0) { evaluated: maxcmp > 0 yes Evaluation Count:6 | yes Evaluation Count:678 |
| 6-678 |
1133 | v = ((wasMax && !wrapped && steps > 0) || (steps < 0 && !wasMin && wrapped)) evaluated: wasMax yes Evaluation Count:4 | yes Evaluation Count:2 |
partially evaluated: !wrapped yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: steps > 0 yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: steps < 0 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-4 |
1134 | ? minimum : maximum; | - |
1135 | } else if (wrapped && (maxcmp > 0 || mincmp < 0)) { executed: } Execution Count:6 evaluated: wrapped yes Evaluation Count:41 | yes Evaluation Count:637 |
partially evaluated: maxcmp > 0 no Evaluation Count:0 | yes Evaluation Count:41 |
partially evaluated: mincmp < 0 no Evaluation Count:0 | yes Evaluation Count:41 |
| 0-637 |
1136 | v = ((wasMax && steps > 0) || (!wasMin && steps < 0)) ? minimum : maximum; never evaluated: steps > 0 never evaluated: steps < 0 | 0 |
1137 | } else if (mincmp < 0) { evaluated: mincmp < 0 yes Evaluation Count:10 | yes Evaluation Count:668 |
| 0-668 |
1138 | v = (!wasMax && !wasMin ? minimum : maximum); partially evaluated: !wasMax yes Evaluation Count:10 | no Evaluation Count:0 |
evaluated: !wasMin yes Evaluation Count:2 | yes Evaluation Count:8 |
| 0-10 |
1139 | } executed: } Execution Count:10 | 10 |
1140 | } | - |
1141 | | - |
1142 | return v; executed: return v; Execution Count:7959 | 7959 |
1143 | } | - |
1144 | void QAbstractSpinBoxPrivate::setValue(const QVariant &val, EmitPolicy ep, | - |
1145 | bool doUpdate) | - |
1146 | { | - |
1147 | QAbstractSpinBox * const q = q_func(); | - |
1148 | const QVariant old = value; | - |
1149 | value = bound(val); | - |
1150 | pendingEmit = false; | - |
1151 | cleared = false; | - |
1152 | if (doUpdate) { evaluated: doUpdate yes Evaluation Count:3651 | yes Evaluation Count:326 |
| 326-3651 |
1153 | updateEdit(); | - |
1154 | } executed: } Execution Count:3651 | 3651 |
1155 | q->update(); | - |
1156 | | - |
1157 | if (ep == AlwaysEmit || (ep == EmitIfChanged && old != value)) { evaluated: ep == AlwaysEmit yes Evaluation Count:199 | yes Evaluation Count:3778 |
partially evaluated: ep == EmitIfChanged yes Evaluation Count:3778 | no Evaluation Count:0 |
evaluated: old != value yes Evaluation Count:2905 | yes Evaluation Count:873 |
| 0-3778 |
1158 | emitSignals(ep, old); | - |
1159 | } executed: } Execution Count:3104 | 3104 |
1160 | } executed: } Execution Count:3977 | 3977 |
1161 | | - |
1162 | | - |
1163 | | - |
1164 | | - |
1165 | | - |
1166 | | - |
1167 | | - |
1168 | void QAbstractSpinBoxPrivate::updateEdit() | - |
1169 | { | - |
1170 | QAbstractSpinBox * const q = q_func(); | - |
1171 | if (type == QVariant::Invalid) partially evaluated: type == QVariant::Invalid no Evaluation Count:0 | yes Evaluation Count:1602 |
| 0-1602 |
1172 | return; | 0 |
1173 | const QString newText = specialValue() ? specialValueText : prefix + textFromValue(value) + suffix; evaluated: specialValue() yes Evaluation Count:28 | yes Evaluation Count:1574 |
| 28-1574 |
1174 | if (newText == edit->displayText() || cleared) evaluated: newText == edit->displayText() yes Evaluation Count:371 | yes Evaluation Count:1231 |
evaluated: cleared yes Evaluation Count:2 | yes Evaluation Count:1229 |
| 2-1231 |
1175 | return; executed: return; Execution Count:373 | 373 |
1176 | | - |
1177 | const bool empty = edit->text().isEmpty(); | - |
1178 | int cursor = edit->cursorPosition(); | - |
1179 | int selsize = edit->selectedText().size(); | - |
1180 | const bool sb = edit->blockSignals(true); | - |
1181 | edit->setText(newText); | - |
1182 | | - |
1183 | if (!specialValue()) { evaluated: !specialValue() yes Evaluation Count:1221 | yes Evaluation Count:8 |
| 8-1221 |
1184 | cursor = qBound(prefix.size(), cursor, edit->displayText().size() - suffix.size()); | - |
1185 | | - |
1186 | if (selsize > 0) { evaluated: selsize > 0 yes Evaluation Count:76 | yes Evaluation Count:1145 |
| 76-1145 |
1187 | edit->setSelection(cursor, selsize); | - |
1188 | } else { executed: } Execution Count:76 | 76 |
1189 | edit->setCursorPosition(empty ? prefix.size() : cursor); | - |
1190 | } executed: } Execution Count:1145 | 1145 |
1191 | } | - |
1192 | edit->blockSignals(sb); | - |
1193 | q->update(); | - |
1194 | } executed: } Execution Count:1229 | 1229 |
1195 | | - |
1196 | | - |
1197 | | - |
1198 | | - |
1199 | | - |
1200 | | - |
1201 | | - |
1202 | void QAbstractSpinBoxPrivate::setRange(const QVariant &min, const QVariant &max) | - |
1203 | { | - |
1204 | QAbstractSpinBox * const q = q_func(); | - |
1205 | | - |
1206 | clearCache(); | - |
1207 | minimum = min; | - |
1208 | maximum = (variantCompare(min, max) < 0 ? max : min); evaluated: variantCompare(min, max) < 0 yes Evaluation Count:1703 | yes Evaluation Count:25 |
| 25-1703 |
1209 | cachedSizeHint = QSize(); | - |
1210 | | - |
1211 | reset(); | - |
1212 | if (!(bound(value) == value)) { evaluated: !(bound(value) == value) yes Evaluation Count:174 | yes Evaluation Count:1554 |
| 174-1554 |
1213 | setValue(bound(value), EmitIfChanged); | - |
1214 | } else if (value == minimum && !specialValueText.isEmpty()) { executed: } Execution Count:174 evaluated: value == minimum yes Evaluation Count:434 | yes Evaluation Count:1120 |
evaluated: !specialValueText.isEmpty() yes Evaluation Count:14 | yes Evaluation Count:420 |
| 14-1120 |
1215 | updateEdit(); | - |
1216 | } executed: } Execution Count:14 | 14 |
1217 | | - |
1218 | q->updateGeometry(); | - |
1219 | } executed: } Execution Count:1728 | 1728 |
1220 | | - |
1221 | | - |
1222 | | - |
1223 | | - |
1224 | | - |
1225 | | - |
1226 | | - |
1227 | QVariant QAbstractSpinBoxPrivate::getZeroVariant() const | - |
1228 | { | - |
1229 | QVariant ret; | - |
1230 | switch (type) { | - |
1231 | case QVariant::Int: ret = QVariant((int)0); break; executed: break; Execution Count:18 | 18 |
1232 | case QVariant::Double: ret = QVariant((double)0.0); break; executed: break; Execution Count:14 | 14 |
1233 | default: break; | 0 |
1234 | } | - |
1235 | return ret; executed: return ret; Execution Count:32 | 32 |
1236 | } | - |
1237 | QString QAbstractSpinBoxPrivate::textFromValue(const QVariant &) const | - |
1238 | { | - |
1239 | return QString(); never executed: return QString(); | 0 |
1240 | } | - |
1241 | QVariant QAbstractSpinBoxPrivate::valueFromText(const QString &) const | - |
1242 | { | - |
1243 | return QVariant(); never executed: return QVariant(); | 0 |
1244 | } | - |
1245 | | - |
1246 | | - |
1247 | | - |
1248 | | - |
1249 | | - |
1250 | | - |
1251 | | - |
1252 | void QAbstractSpinBoxPrivate::interpret(EmitPolicy ep) | - |
1253 | { | - |
1254 | QAbstractSpinBox * const q = q_func(); | - |
1255 | if (type == QVariant::Invalid || cleared) partially evaluated: type == QVariant::Invalid no Evaluation Count:0 | yes Evaluation Count:500 |
evaluated: cleared yes Evaluation Count:1 | yes Evaluation Count:499 |
| 0-500 |
1256 | return; executed: return; Execution Count:1 | 1 |
1257 | | - |
1258 | QVariant v = getZeroVariant(); | - |
1259 | bool doInterpret = true; | - |
1260 | QString tmp = edit->displayText(); | - |
1261 | int pos = edit->cursorPosition(); | - |
1262 | const int oldpos = pos; | - |
1263 | | - |
1264 | if (q->validate(tmp, pos) != QValidator::Acceptable) { evaluated: q->validate(tmp, pos) != QValidator::Acceptable yes Evaluation Count:21 | yes Evaluation Count:478 |
| 21-478 |
1265 | const QString copy = tmp; | - |
1266 | q->fixup(tmp); | - |
1267 | if (false) QMessageLogger("widgets/qabstractspinbox.cpp", 1809, __PRETTY_FUNCTION__).debug() << "QAbstractSpinBoxPrivate::interpret() text '" partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
1268 | << edit->displayText() | 0 |
1269 | << "' >> '" << copy << '\'' | 0 |
1270 | << "' >> '" << tmp << '\''; never executed: QMessageLogger("widgets/qabstractspinbox.cpp", 1809, __PRETTY_FUNCTION__).debug() << "QAbstractSpinBoxPrivate::interpret() text '" << edit->displayText() << "' >> '" << copy << '\'' << "' >> '" << tmp << '\''; | 0 |
1271 | | - |
1272 | doInterpret = tmp != copy && (q->validate(tmp, pos) == QValidator::Acceptable); evaluated: tmp != copy yes Evaluation Count:16 | yes Evaluation Count:5 |
evaluated: (q->validate(tmp, pos) == QValidator::Acceptable) yes Evaluation Count:14 | yes Evaluation Count:2 |
| 2-16 |
1273 | if (!doInterpret) { evaluated: !doInterpret yes Evaluation Count:7 | yes Evaluation Count:14 |
| 7-14 |
1274 | v = (correctionMode == QAbstractSpinBox::CorrectToNearestValue partially evaluated: correctionMode == QAbstractSpinBox::CorrectToNearestValue no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1275 | ? variantBound(minimum, v, maximum) : value); | - |
1276 | } executed: } Execution Count:7 | 7 |
1277 | } executed: } Execution Count:21 | 21 |
1278 | if (doInterpret) { evaluated: doInterpret yes Evaluation Count:492 | yes Evaluation Count:7 |
| 7-492 |
1279 | v = valueFromText(tmp); | - |
1280 | } executed: } Execution Count:492 | 492 |
1281 | clearCache(); | - |
1282 | setValue(v, ep, true); | - |
1283 | if (oldpos != pos) partially evaluated: oldpos != pos no Evaluation Count:0 | yes Evaluation Count:499 |
| 0-499 |
1284 | edit->setCursorPosition(pos); never executed: edit->setCursorPosition(pos); | 0 |
1285 | } executed: } Execution Count:499 | 499 |
1286 | | - |
1287 | void QAbstractSpinBoxPrivate::clearCache() const | - |
1288 | { | - |
1289 | cachedText.clear(); | - |
1290 | cachedValue.clear(); | - |
1291 | cachedState = QValidator::Acceptable; | - |
1292 | } executed: } Execution Count:4117 | 4117 |
1293 | QSpinBoxValidator::QSpinBoxValidator(QAbstractSpinBox *qp, QAbstractSpinBoxPrivate *dp) | - |
1294 | : QValidator(qp), qptr(qp), dptr(dp) | - |
1295 | { | - |
1296 | setObjectName(QLatin1String("qt_spinboxvalidator")); | - |
1297 | } executed: } Execution Count:393 | 393 |
1298 | QValidator::State QSpinBoxValidator::validate(QString &input, int &pos) const | - |
1299 | { | - |
1300 | if (dptr->specialValueText.size() > 0 && input == dptr->specialValueText) evaluated: dptr->specialValueText.size() > 0 yes Evaluation Count:30 | yes Evaluation Count:5821 |
evaluated: input == dptr->specialValueText yes Evaluation Count:14 | yes Evaluation Count:16 |
| 14-5821 |
1301 | return QValidator::Acceptable; executed: return QValidator::Acceptable; Execution Count:14 | 14 |
1302 | | - |
1303 | if (!dptr->prefix.isEmpty() && !input.startsWith(dptr->prefix)) { evaluated: !dptr->prefix.isEmpty() yes Evaluation Count:39 | yes Evaluation Count:5798 |
evaluated: !input.startsWith(dptr->prefix) yes Evaluation Count:3 | yes Evaluation Count:36 |
| 3-5798 |
1304 | input.prepend(dptr->prefix); | - |
1305 | pos += dptr->prefix.length(); | - |
1306 | } executed: } Execution Count:3 | 3 |
1307 | | - |
1308 | if (!dptr->suffix.isEmpty() && !input.endsWith(dptr->suffix)) evaluated: !dptr->suffix.isEmpty() yes Evaluation Count:28 | yes Evaluation Count:5809 |
evaluated: !input.endsWith(dptr->suffix) yes Evaluation Count:2 | yes Evaluation Count:26 |
| 2-5809 |
1309 | input.append(dptr->suffix); executed: input.append(dptr->suffix); Execution Count:2 | 2 |
1310 | | - |
1311 | return qptr->validate(input, pos); executed: return qptr->validate(input, pos); Execution Count:5837 | 5837 |
1312 | } | - |
1313 | | - |
1314 | | - |
1315 | | - |
1316 | | - |
1317 | | - |
1318 | void QSpinBoxValidator::fixup(QString &input) const | - |
1319 | { | - |
1320 | qptr->fixup(input); | - |
1321 | } executed: } Execution Count:21 | 21 |
1322 | QVariant operator+(const QVariant &arg1, const QVariant &arg2) | - |
1323 | { | - |
1324 | QVariant ret; | - |
1325 | if (arg1.type() != arg2.type()) partially evaluated: arg1.type() != arg2.type() no Evaluation Count:0 | yes Evaluation Count:123 |
| 0-123 |
1326 | QMessageLogger("widgets/qabstractspinbox.cpp", 1893, __PRETTY_FUNCTION__).warning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)", | 0 |
1327 | arg1.typeName(), arg2.typeName(), "widgets/qabstractspinbox.cpp", 1894); never executed: QMessageLogger("widgets/qabstractspinbox.cpp", 1893, __PRETTY_FUNCTION__).warning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)", arg1.typeName(), arg2.typeName(), "widgets/qabstractspinbox.cpp", 1894); | 0 |
1328 | switch (arg1.type()) { | - |
1329 | case QVariant::Int: { | - |
1330 | const int int1 = arg1.toInt(); | - |
1331 | const int int2 = arg2.toInt(); | - |
1332 | if (int1 > 0 && (int2 >= 2147483647 - int1)) { evaluated: int1 > 0 yes Evaluation Count:36 | yes Evaluation Count:14 |
evaluated: (int2 >= 2147483647 - int1) yes Evaluation Count:2 | yes Evaluation Count:34 |
| 2-36 |
1333 | | - |
1334 | ret = QVariant(2147483647); | - |
1335 | } else if (int1 < 0 && (int2 <= (-2147483647 - 1) - int1)) { executed: } Execution Count:2 evaluated: int1 < 0 yes Evaluation Count:3 | yes Evaluation Count:45 |
partially evaluated: (int2 <= (-2147483647 - 1) - int1) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-45 |
1336 | | - |
1337 | ret = QVariant((-2147483647 - 1)); | - |
1338 | } else { executed: } Execution Count:3 | 3 |
1339 | ret = QVariant(int1 + int2); | - |
1340 | } executed: } Execution Count:45 | 45 |
1341 | break; executed: break; Execution Count:50 | 50 |
1342 | } | - |
1343 | case QVariant::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break; executed: break; Execution Count:73 | 73 |
1344 | case QVariant::DateTime: { | - |
1345 | QDateTime a2 = arg2.toDateTime(); | - |
1346 | QDateTime a1 = arg1.toDateTime().addDays(QDateTime(QDate(100, 1, 1), QTime(0, 0, 0, 0)).daysTo(a2)); | - |
1347 | a1.setTime(a1.time().addMSecs(QTime().msecsTo(a2.time()))); | - |
1348 | ret = QVariant(a1); | - |
1349 | } | - |
1350 | default: break; | 0 |
1351 | } | - |
1352 | return ret; executed: return ret; Execution Count:123 | 123 |
1353 | } | - |
1354 | | - |
1355 | | - |
1356 | | - |
1357 | | - |
1358 | | - |
1359 | | - |
1360 | | - |
1361 | QVariant operator-(const QVariant &arg1, const QVariant &arg2) | - |
1362 | { | - |
1363 | QVariant ret; | - |
1364 | if (arg1.type() != arg2.type()) never evaluated: arg1.type() != arg2.type() | 0 |
1365 | QMessageLogger("widgets/qabstractspinbox.cpp", 1932, __PRETTY_FUNCTION__).warning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)", | 0 |
1366 | arg1.typeName(), arg2.typeName(), "widgets/qabstractspinbox.cpp", 1933); never executed: QMessageLogger("widgets/qabstractspinbox.cpp", 1932, __PRETTY_FUNCTION__).warning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)", arg1.typeName(), arg2.typeName(), "widgets/qabstractspinbox.cpp", 1933); | 0 |
1367 | switch (arg1.type()) { | - |
1368 | case QVariant::Int: ret = QVariant(arg1.toInt() - arg2.toInt()); break; | 0 |
1369 | case QVariant::Double: ret = QVariant(arg1.toDouble() - arg2.toDouble()); break; | 0 |
1370 | case QVariant::DateTime: { | - |
1371 | QDateTime a1 = arg1.toDateTime(); | - |
1372 | QDateTime a2 = arg2.toDateTime(); | - |
1373 | int days = a2.daysTo(a1); | - |
1374 | int secs = a2.secsTo(a1); | - |
1375 | int msecs = qMax(0, a1.time().msec() - a2.time().msec()); | - |
1376 | if (days < 0 || secs < 0 || msecs < 0) { never evaluated: days < 0 never evaluated: secs < 0 never evaluated: msecs < 0 | 0 |
1377 | ret = arg1; | - |
1378 | } else { | 0 |
1379 | QDateTime dt = a2.addDays(days).addSecs(secs); | - |
1380 | if (msecs > 0) never evaluated: msecs > 0 | 0 |
1381 | dt.setTime(dt.time().addMSecs(msecs)); never executed: dt.setTime(dt.time().addMSecs(msecs)); | 0 |
1382 | ret = QVariant(dt); | - |
1383 | } | 0 |
1384 | } | - |
1385 | default: break; | 0 |
1386 | } | - |
1387 | return ret; never executed: return ret; | 0 |
1388 | } | - |
1389 | | - |
1390 | | - |
1391 | | - |
1392 | | - |
1393 | | - |
1394 | | - |
1395 | QVariant operator*(const QVariant &arg1, double multiplier) | - |
1396 | { | - |
1397 | QVariant ret; | - |
1398 | | - |
1399 | switch (arg1.type()) { | - |
1400 | case QVariant::Int: | - |
1401 | ret = static_cast<int>(qBound<double>((-2147483647 - 1), arg1.toInt() * multiplier, 2147483647)); | - |
1402 | break; executed: break; Execution Count:50 | 50 |
1403 | case QVariant::Double: ret = QVariant(arg1.toDouble() * multiplier); break; executed: break; Execution Count:73 | 73 |
1404 | case QVariant::DateTime: { | - |
1405 | double days = QDate(100, 1, 1).daysTo(arg1.toDateTime().date()) * multiplier; | - |
1406 | int daysInt = (int)days; | - |
1407 | days -= daysInt; | - |
1408 | long msecs = (long)((QTime(0, 0, 0, 0).msecsTo(arg1.toDateTime().time()) * multiplier) | - |
1409 | + (days * (24 * 3600 * 1000))); | - |
1410 | ret = QDateTime(QDate().addDays(int(days)), QTime().addMSecs(msecs)); | - |
1411 | break; | 0 |
1412 | } | - |
1413 | default: ret = arg1; break; | 0 |
1414 | } | - |
1415 | | - |
1416 | return ret; executed: return ret; Execution Count:123 | 123 |
1417 | } | - |
1418 | | - |
1419 | | - |
1420 | | - |
1421 | double operator/(const QVariant &arg1, const QVariant &arg2) | - |
1422 | { | - |
1423 | double a1 = 0; | - |
1424 | double a2 = 0; | - |
1425 | | - |
1426 | switch (arg1.type()) { | - |
1427 | case QVariant::Int: | - |
1428 | a1 = (double)arg1.toInt(); | - |
1429 | a2 = (double)arg2.toInt(); | - |
1430 | break; | 0 |
1431 | case QVariant::Double: | - |
1432 | a1 = arg1.toDouble(); | - |
1433 | a2 = arg2.toDouble(); | - |
1434 | break; | 0 |
1435 | case QVariant::DateTime: | - |
1436 | a1 = QDate(100, 1, 1).daysTo(arg1.toDate()); | - |
1437 | a2 = QDate(100, 1, 1).daysTo(arg2.toDate()); | - |
1438 | a1 += (double)QTime(0, 0, 0, 0).msecsTo(arg1.toDateTime().time()) / (long)(3600 * 24 * 1000); | - |
1439 | a2 += (double)QTime(0, 0, 0, 0).msecsTo(arg2.toDateTime().time()) / (long)(3600 * 24 * 1000); | - |
1440 | default: break; | 0 |
1441 | } | - |
1442 | | - |
1443 | return (a1 != 0 && a2 != 0) ? (a1 / a2) : 0.0; never executed: return (a1 != 0 && a2 != 0) ? (a1 / a2) : 0.0; | 0 |
1444 | } | - |
1445 | | - |
1446 | int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant &arg2) | - |
1447 | { | - |
1448 | switch (arg2.type()) { | - |
1449 | case QVariant::Date: | - |
1450 | qt_noop(); | - |
1451 | | - |
1452 | | - |
1453 | if (arg1.toDate() == arg2.toDate()) { never evaluated: arg1.toDate() == arg2.toDate() | 0 |
1454 | return 0; never executed: return 0; | 0 |
1455 | } else if (arg1.toDate() < arg2.toDate()) { never evaluated: arg1.toDate() < arg2.toDate() | 0 |
1456 | return -1; never executed: return -1; | 0 |
1457 | } else { | - |
1458 | return 1; never executed: return 1; | 0 |
1459 | } | - |
1460 | case QVariant::Time: | - |
1461 | qt_noop(); | - |
1462 | | - |
1463 | | - |
1464 | if (arg1.toTime() == arg2.toTime()) { never evaluated: arg1.toTime() == arg2.toTime() | 0 |
1465 | return 0; never executed: return 0; | 0 |
1466 | } else if (arg1.toTime() < arg2.toTime()) { never evaluated: arg1.toTime() < arg2.toTime() | 0 |
1467 | return -1; never executed: return -1; | 0 |
1468 | } else { | - |
1469 | return 1; never executed: return 1; | 0 |
1470 | } | - |
1471 | | - |
1472 | | - |
1473 | case QVariant::DateTime: | - |
1474 | if (arg1.toDateTime() == arg2.toDateTime()) { evaluated: arg1.toDateTime() == arg2.toDateTime() yes Evaluation Count:379 | yes Evaluation Count:13056 |
| 379-13056 |
1475 | return 0; executed: return 0; Execution Count:379 | 379 |
1476 | } else if (arg1.toDateTime() < arg2.toDateTime()) { evaluated: arg1.toDateTime() < arg2.toDateTime() yes Evaluation Count:7221 | yes Evaluation Count:5835 |
| 5835-7221 |
1477 | return -1; executed: return -1; Execution Count:7221 | 7221 |
1478 | } else { | - |
1479 | return 1; executed: return 1; Execution Count:5835 | 5835 |
1480 | } | - |
1481 | case QVariant::Int: | - |
1482 | if (arg1.toInt() == arg2.toInt()) { evaluated: arg1.toInt() == arg2.toInt() yes Evaluation Count:871 | yes Evaluation Count:3269 |
| 871-3269 |
1483 | return 0; executed: return 0; Execution Count:871 | 871 |
1484 | } else if (arg1.toInt() < arg2.toInt()) { evaluated: arg1.toInt() < arg2.toInt() yes Evaluation Count:2027 | yes Evaluation Count:1242 |
| 1242-2027 |
1485 | return -1; executed: return -1; Execution Count:2027 | 2027 |
1486 | } else { | - |
1487 | return 1; executed: return 1; Execution Count:1242 | 1242 |
1488 | } | - |
1489 | case QVariant::Double: | - |
1490 | if (arg1.toDouble() == arg2.toDouble()) { evaluated: arg1.toDouble() == arg2.toDouble() yes Evaluation Count:1267 | yes Evaluation Count:3129 |
| 1267-3129 |
1491 | return 0; executed: return 0; Execution Count:1267 | 1267 |
1492 | } else if (arg1.toDouble() < arg2.toDouble()) { evaluated: arg1.toDouble() < arg2.toDouble() yes Evaluation Count:2254 | yes Evaluation Count:875 |
| 875-2254 |
1493 | return -1; executed: return -1; Execution Count:2254 | 2254 |
1494 | } else { | - |
1495 | return 1; executed: return 1; Execution Count:875 | 875 |
1496 | } | - |
1497 | case QVariant::Invalid: | - |
1498 | if (arg2.type() == QVariant::Invalid) never evaluated: arg2.type() == QVariant::Invalid | 0 |
1499 | return 0; never executed: return 0; | 0 |
1500 | default: code before this statement never executed: default: | 0 |
1501 | qt_noop(); | - |
1502 | | - |
1503 | | - |
1504 | | - |
1505 | } | 0 |
1506 | return -2; never executed: return -2; | 0 |
1507 | } | - |
1508 | | - |
1509 | QVariant QAbstractSpinBoxPrivate::variantBound(const QVariant &min, | - |
1510 | const QVariant &value, | - |
1511 | const QVariant &max) | - |
1512 | { | - |
1513 | qt_noop(); | - |
1514 | if (variantCompare(min, value) < 0) { never evaluated: variantCompare(min, value) < 0 | 0 |
1515 | const int compMax = variantCompare(value, max); | - |
1516 | return (compMax < 0 ? value : max); never executed: return (compMax < 0 ? value : max); | 0 |
1517 | } else { | - |
1518 | return min; never executed: return min; | 0 |
1519 | } | - |
1520 | } | - |
1521 | | - |
1522 | | - |
1523 | | - |
1524 | | - |
1525 | | - |
| | |