summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@theqtcompany.com>2016-01-20 09:42:34 +0100
committerEdward Welbourne <edward.welbourne@theqtcompany.com>2016-04-08 14:45:49 +0000
commitfd5720af2cb1e641c433c73fd977c8ba9d278305 (patch)
tree598eb14da7e92650dc670cda67a05638e5c8a0f9 /src/widgets
parentc671e66802b75b511ad85347c70f6193134d81ca (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')
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp12
-rw-r--r--src/widgets/widgets/qdatetimeedit.h2
2 files changed, 7 insertions, 7 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;
diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h
index 829ce205be..031cc0bbb4 100644
--- a/src/widgets/widgets/qdatetimeedit.h
+++ b/src/widgets/widgets/qdatetimeedit.h
@@ -69,7 +69,7 @@ class Q_WIDGETS_EXPORT QDateTimeEdit : public QAbstractSpinBox
Q_PROPERTY(int sectionCount READ sectionCount)
Q_PROPERTY(Qt::TimeSpec timeSpec READ timeSpec WRITE setTimeSpec)
public:
- enum Section {
+ enum Section { // a sub-type of QDateTimeParser's like-named enum.
NoSection = 0x0000,
AmPmSection = 0x0001,
MSecSection = 0x0002,