QDateTimeParser: Move magic section indices out of section type enum
They never belonged there and their presence implied cases for them in switches on type that make no sense. Presumably it was just a handy enum in which to declare some constants, but we can do that with constexpr class members these days, without compilers grumbling about unchecked members of an enum in a switch. One of them wasn't even referenced anywhere, so dropped it entirely. Pick-to: 6.7 6.5 Change-Id: I304cdb07cd86e8d7e926c316729d68fc7770afc5 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit c7e75b2b8da79d736e9d01d81959fec66c4c90e9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b819709c3a
commit
29934f62ef
@ -27,6 +27,10 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
constexpr int QDateTimeParser::NoSectionIndex;
|
||||
constexpr int QDateTimeParser::FirstSectionIndex;
|
||||
constexpr int QDateTimeParser::LastSectionIndex;
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
template <typename T>
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user