diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 56381125460..72456498554 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -27,6 +27,10 @@ QT_BEGIN_NAMESPACE +constexpr int QDateTimeParser::NoSectionIndex; +constexpr int QDateTimeParser::FirstSectionIndex; +constexpr int QDateTimeParser::LastSectionIndex; + using namespace Qt::StringLiterals; template @@ -710,13 +714,6 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const qWarning("QDateTimeParser::sectionMaxSize: Invalid section %s", SectionNode::name(s).toLatin1().constData()); break; - - case NoSectionIndex: - case FirstSectionIndex: - case LastSectionIndex: - case CalendarPopupIndex: - // these cases can't happen - break; } return -1; } @@ -768,15 +765,6 @@ static int matchesSeparator(QStringView text, QStringView separator) QString QDateTimeParser::sectionText(const QString &text, int sectionIndex, int index) const { - const SectionNode &sn = sectionNode(sectionIndex); - switch (sn.type) { - case NoSectionIndex: - case FirstSectionIndex: - case LastSectionIndex: - return QString(); - default: break; - } - return text.mid(index, sectionSize(sectionIndex)); } diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index 30e9e4d5242..dd922bc6276 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -93,14 +93,13 @@ public: FirstSection = 0x20000 | Internal, LastSection = 0x40000 | Internal, CalendarPopupSection = 0x80000 | Internal, - - NoSectionIndex = -1, - FirstSectionIndex = -2, - LastSectionIndex = -3, - CalendarPopupIndex = -4 }; // extending qdatetimeedit.h's equivalent Q_DECLARE_FLAGS(Sections, Section) + static constexpr int NoSectionIndex = -1; + static constexpr int FirstSectionIndex = -2; + static constexpr int LastSectionIndex = -3; + struct Q_CORE_EXPORT SectionNode { Section type; mutable int pos;