diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-24 15:00:21 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-27 09:32:17 +0200 |
commit | 03c12974bbaf6f5f394d846099c7a67b058d65e2 (patch) | |
tree | d0a0b56b0efb5bda791b874f4570dd479d471328 | |
parent | e0ff15ffd89adbe6e64386c919e6e8fd10aeeed3 (diff) |
Simplify the preamble of QDateTimeEditPrivate::stepBy()
Repetition and needless complexity: eleven lines rewritten in three.
Change-Id: I1dadbbc5329b18d3e25f38f73b69abd2d7aac30d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
-rw-r--r-- | src/widgets/widgets/qdatetimeedit.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index df3b7c3876..5697c96791 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2107,18 +2107,10 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c int pos = edit->cursorPosition(); const SectionNode sn = sectionNode(sectionIndex); - int val; // to make sure it behaves reasonably when typing something and then stepping in non-tracking mode - if (!test && pendingEmit) { - if (q->validate(str, pos) != QValidator::Acceptable) { - v = value.toDateTime(); - } else { - v = q->dateTimeFromText(str); - } - val = getDigit(v, sectionIndex); - } else { - val = getDigit(v, sectionIndex); - } + if (!test && pendingEmit && q->validate(str, pos) == QValidator::Acceptable) + v = q->dateTimeFromText(str); + int val = getDigit(v, sectionIndex); val += steps; |