Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
#include <qdatetimeparser_p.h>
Classes | |
struct | SectionNode |
struct | StateNode |
Public Types | |
enum | Context { FromString , DateTimeEdit } |
enum | Section { NoSection = 0x00000 , AmPmSection = 0x00001 , MSecSection = 0x00002 , SecondSection = 0x00004 , MinuteSection = 0x00008 , Hour12Section = 0x00010 , Hour24Section = 0x00020 , TimeZoneSection = 0x00040 , HourSectionMask = (Hour12Section | Hour24Section) , TimeSectionMask , DaySection = 0x00100 , MonthSection = 0x00200 , YearSection = 0x00400 , YearSection2Digits = 0x00800 , YearSectionMask = YearSection | YearSection2Digits , DayOfWeekSectionShort = 0x01000 , DayOfWeekSectionLong = 0x02000 , DayOfWeekSectionMask = DayOfWeekSectionShort | DayOfWeekSectionLong , DaySectionMask = DaySection | DayOfWeekSectionMask , DateSectionMask = DaySectionMask | MonthSection | YearSectionMask , Internal = 0x10000 , FirstSection = 0x20000 | Internal , LastSection = 0x40000 | Internal , CalendarPopupSection = 0x80000 | Internal , NoSectionIndex = -1 , FirstSectionIndex = -2 , LastSectionIndex = -3 , CalendarPopupIndex = -4 } |
enum | State { Invalid , Intermediate , Acceptable } |
enum | AmPm { AmText , PmText } |
enum | FieldInfoFlag { Numeric = 0x01 , FixedWidth = 0x02 , AllowPartial = 0x04 , Fraction = 0x08 } |
Public Member Functions | |
QDateTimeParser (QMetaType::Type t, Context ctx, QCalendar cal=QCalendar()) | |
virtual | ~QDateTimeParser () |
StateNode | parse (const QString &input, int position, const QDateTime &defaultValue, bool fixup) const |
bool | fromString (const QString &text, QDate *date, QTime *time, int baseYear=QLocale::DefaultTwoDigitBaseYear) const |
bool | fromString (const QString &text, QDateTime *datetime, int baseYear) const |
bool | parseFormat (QStringView format) |
FieldInfo | fieldInfo (int index) const |
void | setDefaultLocale (const QLocale &loc) |
virtual QString | displayText () const |
void | setCalendar (QCalendar calendar) |
Sets cal as the calendar to use. | |
Protected Member Functions | |
int | sectionSize (int index) const |
int | sectionMaxSize (int index) const |
int | sectionPos (int index) const |
int | sectionPos (SectionNode sn) const |
const SectionNode & | sectionNode (int index) const |
Section | sectionType (int index) const |
QString | sectionText (int sectionIndex) const |
int | getDigit (const QDateTime &dt, int index) const |
bool | setDigit (QDateTime &t, int index, int newval) const |
int | absoluteMax (int index, const QDateTime &value=QDateTime()) const |
int | absoluteMin (int index) const |
bool | skipToNextSection (int section, const QDateTime ¤t, QStringView sectionText) const |
bool | skipToNextSection (int section, const QDateTime ¤t, const QString §ionText) const |
QString | stateName (State s) const |
virtual QDateTime | getMinimum () const |
virtual QDateTime | getMaximum () const |
virtual int | cursorPosition () const |
virtual QLocale | locale () const |
Protected Attributes | |
int | currentSectionIndex = int(NoSectionIndex) |
int | defaultCenturyStart = QLocale::DefaultTwoDigitBaseYear |
Sections | display |
int | cachedDay = -1 |
QString | m_text |
QList< SectionNode > | sectionNodes |
SectionNode | first |
SectionNode | last |
SectionNode | none |
SectionNode | popup |
QStringList | separators |
QString | displayFormat |
QLocale | defaultLocale |
QMetaType::Type | parserType |
bool | fixday = false |
Context | context |
QCalendar | calendar |
Friends | |
class | QDTPUnitTestParser |
Definition at line 42 of file qdatetimeparser_p.h.
Enumerator | |
---|---|
AmText | |
PmText |
Definition at line 132 of file qdatetimeparser_p.h.
Enumerator | |
---|---|
FromString | |
DateTimeEdit |
Definition at line 45 of file qdatetimeparser_p.h.
Enumerator | |
---|---|
Numeric | |
FixedWidth | |
AllowPartial | |
Fraction |
Definition at line 144 of file qdatetimeparser_p.h.
Definition at line 68 of file qdatetimeparser_p.h.
Enumerator | |
---|---|
Invalid | |
Intermediate | |
Acceptable |
Definition at line 116 of file qdatetimeparser_p.h.
|
inline |
Definition at line 49 of file qdatetimeparser_p.h.
References QLocale::system().
|
virtual |
Definition at line 35 of file qdatetimeparser.cpp.
Returns the absolute maximum for a section
Definition at line 223 of file qdatetimeparser.cpp.
References AmPmSection, calendar, DayOfWeekSectionLong, DayOfWeekSectionShort, DaySection, Hour12Section, Hour24Section, QCalendar::maximumDaysInMonth(), QCalendar::maximumMonthsInYear(), QTimeZone::MaxUtcOffsetSecs, MinuteSection, MonthSection, MSecSection, QDateTimeParser::SectionNode::name(), qUtf16Printable, qWarning, SecondSection, sectionNode(), TimeZoneSection, QDateTimeParser::SectionNode::type, YearSection, and YearSection2Digits.
Referenced by parse(), setDigit(), skipToNextSection(), and QDateTimeEditPrivate::stepBy().
|
protected |
Returns the absolute minimum for a section
Definition at line 267 of file qdatetimeparser.cpp.
References AmPmSection, DayOfWeekSectionLong, DayOfWeekSectionShort, DaySection, Hour12Section, Hour24Section, QTimeZone::MinUtcOffsetSecs, MinuteSection, MonthSection, MSecSection, QDateTimeParser::SectionNode::name(), qUtf16Printable, qWarning, SecondSection, sectionNode(), TimeZoneSection, QDateTimeParser::SectionNode::type, YearSection, and YearSection2Digits.
Referenced by setDigit(), skipToNextSection(), and QDateTimeEditPrivate::stepBy().
|
inlineprotectedvirtual |
Reimplemented in QDateTimeEditPrivate.
Definition at line 235 of file qdatetimeparser_p.h.
Referenced by skipToNextSection().
|
inlinevirtual |
Reimplemented in QDateTimeEditPrivate.
Definition at line 155 of file qdatetimeparser_p.h.
Referenced by sectionPos(), sectionSize(), and sectionText().
QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo | ( | int | index | ) | const |
Definition at line 2027 of file qdatetimeparser.cpp.
References AllowPartial, AmPmSection, AmText, QDateTimeParser::SectionNode::count, DayOfWeekSectionLong, DayOfWeekSectionShort, DaySection, FixedWidth, Fraction, Hour12Section, Hour24Section, MinuteSection, MonthSection, MSecSection, QDateTimeParser::SectionNode::name(), Numeric, PmText, Q_FALLTHROUGH, qUtf16Printable, qWarning, ret, SecondSection, sectionNode(), QString::size(), TimeZoneSection, QDateTimeParser::SectionNode::type, YearSection, and YearSection2Digits.
Referenced by QDateTimeEditPrivate::interpret(), QDateTimeEditPrivate::isSeparatorKey(), and parse().
bool QDateTimeParser::fromString | ( | const QString & | text, |
QDate * | date, | ||
QTime * | time, | ||
int | baseYear = QLocale::DefaultTwoDigitBaseYear ) const |
Definition at line 2245 of file qdatetimeparser.cpp.
References Acceptable, QDateTimeParser::StateNode::conflicts, d, date, QDateTime::date(), defaultCenturyStart, parse(), Q_ASSERT, QDateTimeParser::StateNode::state, time, QDateTime::time(), QTimeZone::UTC, and QDateTimeParser::StateNode::value.
Definition at line 2271 of file qdatetimeparser.cpp.
References QDateTimeParser::StateNode::conflicts, defaultCenturyStart, Intermediate, QDateTime::isValid(), QTimeZone::LocalTime, parse(), QDateTimeParser::StateNode::state, and QDateTimeParser::StateNode::value.
|
protected |
Gets the digit from a datetime. E.g.
QDateTime var(QDate(2004, 02, 02)); int digit = getDigit(var, Year); digit = 2004
Definition at line 48 of file qdatetimeparser.cpp.
References AmPmSection, calendar, QCalendar::dayOfWeek(), DayOfWeekSectionLong, DayOfWeekSectionShort, DaySection, Hour12Section, Hour24Section, MinuteSection, MonthSection, MSecSection, qUtf16Printable, qWarning, SecondSection, sectionNodes, TimeZoneSection, QDateTimeParser::SectionNode::type, YearSection, and YearSection2Digits.
Referenced by parse(), skipToNextSection(), and QDateTimeEditPrivate::stepBy().
|
protectedvirtual |
Reimplemented in QDateTimeEditPrivate.
Definition at line 2291 of file qdatetimeparser.cpp.
References QDATETIMEEDIT_DATE_MAX.
Referenced by QDateTimeEditPrivate::getMaximum(), parse(), and skipToNextSection().
|
protectedvirtual |
Reimplemented in QDateTimeEditPrivate.
Definition at line 2280 of file qdatetimeparser.cpp.
References QDATETIMEEDIT_DATE_MIN.
Referenced by QDateTimeEditPrivate::getMinimum(), parse(), and skipToNextSection().
|
inlineprotectedvirtual |
Reimplemented in QDateTimeEditPrivate.
Definition at line 236 of file qdatetimeparser_p.h.
QDateTimeParser::StateNode QDateTimeParser::parse | ( | const QString & | input, |
int | position, | ||
const QDateTime & | defaultValue, | ||
bool | fixup ) const |
Definition at line 1501 of file qdatetimeparser.cpp.
References absoluteMax(), Acceptable, QDateTime::addMonths(), QDateTime::addSecs(), AmPmSection, calendar, QByteArray::constData(), context, copy(), QDateTimeParser::SectionNode::count, QDateTime::date(), QDateTime::daysTo(), done, fieldInfo(), FixedWidth, FromString, getDigit(), getMaximum(), getMinimum(), i, Intermediate, Invalid, QDateTime::isValid(), m_text, QDateTimeParser::SectionNode::maxChange(), QDate::month(), MonthSection, QTime::msecsTo(), QDateTimeParser::SectionNode::name(), Numeric, QDateTimeParser::StateNode::padded, pos, QDateTimeParser::SectionNode::pos, position(), Q_ASSERT, Q_FALLTHROUGH, QDTPDEBUG, QDTPDEBUGN, qUtf16Printable, qWarning, sectionNodes, QDateTimeParser::StateNode::state, stateName(), time, QDateTime::time(), TimeSectionMask, QDate::toJulianDay(), QString::toLatin1(), QString::toLower(), QDateTimeParser::SectionNode::type, QDateTimeParser::StateNode::value, and QDate::year().
Referenced by fromString(), fromString(), and QDateTimeEditPrivate::validateAndInterpret().
bool QDateTimeParser::parseFormat | ( | QStringView | newFormat | ) |
Parses the format newFormat. If successful, returns true
and sets up the format. Else keeps the old format and returns false
.
Definition at line 422 of file qdatetimeparser.cpp.
References add(), AmPmSection, appendSeparator(), Qt::CaseInsensitive, context, QDateTimeParser::SectionNode::count, countRepeat(), DateTimeEdit, DayOfWeekSectionLong, DayOfWeekSectionShort, DaySection, displayFormat, Hour12Section, Hour24Section, i, QString::isEmpty(), last, MinuteSection, MonthSection, MSecSection, parserType, pos, QDateTimeParser::SectionNode::pos, QDTPDEBUG, QDTPDEBUGN, quote(), SecondSection, sectionNodes, sectionType(), separators, TimeZoneSection, QDateTimeParser::SectionNode::type, unquote(), YearSection, YearSection2Digits, and zero.
|
protected |
Definition at line 725 of file qdatetimeparser.cpp.
References QDateTimeParser::SectionNode::count, sectionNode(), and QDateTimeParser::SectionNode::type.
|
protected |
Returns the sectionNode for the Section s.
Definition at line 300 of file qdatetimeparser.cpp.
References first, FirstSectionIndex, last, LastSectionIndex, none, NoSectionIndex, qWarning, and sectionNodes.
Referenced by absoluteMax(), absoluteMin(), QDateTimeEditPrivate::editorCursorPositionChanged(), fieldInfo(), sectionMaxSize(), sectionPos(), sectionText(), sectionType(), QDateTimeEditPrivate::setSelected(), skipToNextSection(), and QDateTimeEditPrivate::stepBy().
|
protected |
Returns the starting position for section s.
Definition at line 332 of file qdatetimeparser.cpp.
References sectionNode(), and sectionPos().
Referenced by QDateTimeEditPrivate::clearSection(), QDateTimeEditPrivate::closestSection(), QDateTimeEditPrivate::editorCursorPositionChanged(), QDateTimeEditPrivate::sectionAt(), sectionPos(), sectionSize(), QDateTimeEditPrivate::setSelected(), and QDateTimeEditPrivate::updateEdit().
|
protected |
Definition at line 337 of file qdatetimeparser.cpp.
References displayText(), FirstSection, LastSection, QDateTimeParser::SectionNode::name(), QDateTimeParser::SectionNode::pos, qUtf16Printable, qWarning, and QDateTimeParser::SectionNode::type.
|
protected |
Returns the size of section s.
Definition at line 605 of file qdatetimeparser.cpp.
References begin(), context, DateTimeEdit, displayText(), m_text, qWarning, sectionNodes, sectionPos(), separators, and QString::size().
Referenced by QDateTimeEditPrivate::clearSection(), QDateTimeEditPrivate::closestSection(), QDateTimeEditPrivate::editorCursorPositionChanged(), QDateTimeEditPrivate::sectionAt(), and QDateTimeEditPrivate::setSelected().
|
protected |
Definition at line 783 of file qdatetimeparser.cpp.
References displayText(), QDateTimeParser::SectionNode::pos, and sectionNode().
|
protected |
Definition at line 320 of file qdatetimeparser.cpp.
References sectionNode(), and QDateTimeParser::SectionNode::type.
Referenced by parseFormat().
Sets cal as the calendar to use.
The default is Gregorian.
Definition at line 2328 of file qdatetimeparser.cpp.
References calendar.
Definition at line 154 of file qdatetimeparser_p.h.
|
protected |
Sets a digit in a datetime. E.g.
QDateTime var(QDate(2004, 02, 02)); int digit = getDigit(var, Year); digit = 2004 setDigit(&var, Year, 2005); digit = getDigit(var, Year); digit = 2005
Definition at line 118 of file qdatetimeparser.cpp.
References absoluteMax(), absoluteMin(), AmPmSection, cachedDay, calendar, date, QCalendar::dateFromParts(), QDate::day(), QCalendar::dayOfWeek(), dayOfWeekDiff(), DayOfWeekSectionLong, DayOfWeekSectionShort, DaySection, DaySectionMask, QCalendar::daysInMonth(), QTimeZone::fromSecondsAheadOfUtc(), QTime::hour(), Hour12Section, Hour24Section, QDate::isValid(), QTime::minute(), MinuteSection, QDate::month(), MonthSection, QTime::msec(), MSecSection, QDateTimeParser::SectionNode::name(), QCalendar::partsFromDate(), preferDayOfWeek(), Q_ASSERT, qUtf16Printable, qWarning, QTime::second(), SecondSection, sectionNodes, time, TimeZoneSection, QDateTimeParser::SectionNode::type, WeekDay(), QDate::year(), YearSection, and YearSection2Digits.
Referenced by skipToNextSection(), and QDateTimeEditPrivate::stepBy().
|
inlineprotected |
Definition at line 227 of file qdatetimeparser_p.h.
|
protected |
Definition at line 2154 of file qdatetimeparser.cpp.
References absoluteMax(), absoluteMin(), cursorPosition(), getDigit(), getMaximum(), getMinimum(), Qt::OffsetFromUTC, pos, QDateTimeParser::SectionNode::pos, Q_ASSERT, sectionNode(), setDigit(), QString::size(), text, QDateTime::timeSpec(), TimeZoneSection, and QDateTimeParser::SectionNode::type.
For debugging. Returns the name of the state s.
Definition at line 2219 of file qdatetimeparser.cpp.
References Acceptable, Intermediate, Invalid, and QString::number().
Referenced by parse().
|
friend |
Definition at line 209 of file qdatetimeparser_p.h.
|
mutableprotected |
Definition at line 254 of file qdatetimeparser_p.h.
Referenced by QDateTimeEditPrivate::clearCache(), setDigit(), and QDateTimeEditPrivate::stepBy().
|
protected |
Definition at line 264 of file qdatetimeparser_p.h.
Referenced by absoluteMax(), getDigit(), QDateTimeEditPrivate::initCalendarPopup(), parse(), setCalendar(), setDigit(), and QDateTimeEditPrivate::stepBy().
|
protected |
Definition at line 263 of file qdatetimeparser_p.h.
Referenced by parse(), parseFormat(), and sectionSize().
|
mutableprotected |
Definition at line 238 of file qdatetimeparser_p.h.
Referenced by QDateTimeEditPrivate::QDateTimeEditPrivate(), QDateTimeEditPrivate::editorCursorPositionChanged(), QDateTimeEditPrivate::interpret(), QDateTimeEditPrivate::isSeparatorKey(), and QDateTimeEditPrivate::updateEdit().
|
mutableprotected |
Definition at line 239 of file qdatetimeparser_p.h.
Referenced by fromString(), and fromString().
|
protected |
Definition at line 260 of file qdatetimeparser_p.h.
|
protected |
Definition at line 240 of file qdatetimeparser_p.h.
|
protected |
Definition at line 259 of file qdatetimeparser_p.h.
Referenced by parseFormat().
|
protected |
Definition at line 257 of file qdatetimeparser_p.h.
Referenced by sectionNode(), and QDateTimeEditPrivate::stepBy().
|
protected |
Definition at line 262 of file qdatetimeparser_p.h.
Referenced by QDateTimeEditPrivate::QDateTimeEditPrivate().
|
protected |
Definition at line 257 of file qdatetimeparser_p.h.
Referenced by parseFormat(), and sectionNode().
|
mutableprotected |
Definition at line 255 of file qdatetimeparser_p.h.
Referenced by parse(), sectionSize(), and QDateTimeEditPrivate::validateAndInterpret().
|
protected |
Definition at line 257 of file qdatetimeparser_p.h.
Referenced by sectionNode().
|
protected |
Definition at line 261 of file qdatetimeparser_p.h.
Referenced by parseFormat().
|
protected |
Definition at line 257 of file qdatetimeparser_p.h.
|
protected |
Definition at line 256 of file qdatetimeparser_p.h.
Referenced by QDateTimeEditPrivate::absoluteIndex(), QDateTimeEditPrivate::absoluteIndex(), QDateTimeEditPrivate::closestSection(), QDateTimeEditPrivate::editorCursorPositionChanged(), getDigit(), QDateTimeEditPrivate::init(), QDateTimeEditPrivate::isSeparatorKey(), QDateTimeEditPrivate::nextPrevSection(), parse(), parseFormat(), QDateTimeEditPrivate::sectionAt(), sectionNode(), sectionSize(), setDigit(), and QDateTimeEditPrivate::validateAndInterpret().
|
protected |
Definition at line 258 of file qdatetimeparser_p.h.
Referenced by QDateTimeEditPrivate::closestSection(), QDateTimeEditPrivate::isSeparatorKey(), parseFormat(), QDateTimeEditPrivate::sectionAt(), and sectionSize().