diff options
author | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2016-01-20 09:42:34 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2016-04-08 14:45:49 +0000 |
commit | fd5720af2cb1e641c433c73fd977c8ba9d278305 (patch) | |
tree | 598eb14da7e92650dc670cda67a05638e5c8a0f9 /src/widgets/widgets/qdatetimeedit.cpp | |
parent | c671e66802b75b511ad85347c70f6193134d81ca (diff) |
QDateTimeParser: new Section mask values simplify code.
Various |s of existing section flags were used repeatedly; naming
these masks makes the relevant code easier to read. In QDateTimeEdit,
add a comment to make clear that its Section enum is based on QDTP's.
Change-Id: Ifd8364cd396a6d0d5ed7ae7dc4d31690f77edd30
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets/widgets/qdatetimeedit.cpp')
-rw-r--r-- | src/widgets/widgets/qdatetimeedit.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 8ee32a2a8b..eb001bade4 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2047,7 +2047,7 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c // doesn't mean that we hit the floor in the other if (steps > 0) { setDigit(v, sectionIndex, min); - if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) && sections & DateSectionMask) { + if (!(sn.type & DaySectionMask) && sections & DateSectionMask) { const int daysInMonth = v.date().daysInMonth(); if (v.date().day() < oldDay && v.date().day() < daysInMonth) { const int adds = qMin(oldDay, daysInMonth); @@ -2062,7 +2062,7 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c } } else { setDigit(v, sectionIndex, max); - if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) && sections & DateSectionMask) { + if (!(sn.type & DaySectionMask) && sections & DateSectionMask) { const int daysInMonth = v.date().daysInMonth(); if (v.date().day() < oldDay && v.date().day() < daysInMonth) { const int adds = qMin(oldDay, daysInMonth); @@ -2080,7 +2080,7 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c setDigit(v, sectionIndex, (steps > 0 ? localmax : localmin)); } } - if (!test && oldDay != v.date().day() && !(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) { + if (!test && oldDay != v.date().day() && !(sn.type & DaySectionMask)) { // this should not happen when called from stepEnabled cachedDay = qMax<int>(oldDay, cachedDay); } @@ -2272,15 +2272,15 @@ QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections(QDateTimeParser::S ret |= QDateTimeEdit::SecondSection; if (s & QDateTimeParser::MinuteSection) ret |= QDateTimeEdit::MinuteSection; - if (s & (QDateTimeParser::Hour24Section|QDateTimeParser::Hour12Section)) + if (s & (QDateTimeParser::HourSectionMask)) ret |= QDateTimeEdit::HourSection; if (s & QDateTimeParser::AmPmSection) ret |= QDateTimeEdit::AmPmSection; - if (s & (QDateTimeParser::DaySection|QDateTimeParser::DayOfWeekSectionShort|QDateTimeParser::DayOfWeekSectionLong)) + if (s & (QDateTimeParser::DaySectionMask)) ret |= QDateTimeEdit::DaySection; if (s & QDateTimeParser::MonthSection) ret |= QDateTimeEdit::MonthSection; - if (s & (QDateTimeParser::YearSection|QDateTimeParser::YearSection2Digits)) + if (s & (QDateTimeParser::YearSectionMask)) ret |= QDateTimeEdit::YearSection; return ret; |