diff options
author | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2016-01-18 18:19:21 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2016-02-02 16:28:48 +0000 |
commit | 72b57a5dfa49b4d4dd3b88cca8cc97e7283dcdf0 (patch) | |
tree | 42638bcd2c57cdba5b27d7ccaacb3c726948736d /src/corelib/tools/qdatetimeparser_p.h | |
parent | a965d505a0149007cae2cbfe5d5c530b3986e826 (diff) |
Disintermediate QDateTimeParser::SectionNode operations.
The name, format and maxChange of a Section depend only on the
section, not on the details of the currently parsed text it matches;
so we don't need the parser object's list of all sections to work them
out. Move these methods to the SectionNode and act directly on that
instead of going via the section list.
Make the name take a Section enum instead of an int.
Likewise, make stateName take a State enum instead of an int.
Change-Id: Ie340d042ab95aec517013c4dcc30901d40305c78
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Diffstat (limited to 'src/corelib/tools/qdatetimeparser_p.h')
-rw-r--r-- | src/corelib/tools/qdatetimeparser_p.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index dbfc7be64c..fe6bfa9c3c 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -135,11 +135,16 @@ public: }; // duplicated from qdatetimeedit.h Q_DECLARE_FLAGS(Sections, Section) - struct SectionNode { + struct Q_CORE_EXPORT SectionNode { Section type; mutable int pos; int count; int zeroesAdded; + + static QString name(Section s); + QString name() const { return name(type); } + QString format() const; + int maxChange() const; }; enum State { // duplicated from QValidator @@ -197,15 +202,11 @@ public: QString *dayName = 0, int *used = 0) const; #endif int findAmPm(QString &str1, int index, int *used = 0) const; - int maxChange(int s) const; bool potentialValue(const QString &str, int min, int max, int index, const QDateTime ¤tValue, int insert) const; bool skipToNextSection(int section, const QDateTime ¤t, const QString §ionText) const; - QString sectionName(int s) const; - QString stateName(int s) const; - QString sectionFormat(int index) const; - QString sectionFormat(Section s, int count) const; + QString stateName(State s) const; enum FieldInfoFlag { Numeric = 0x01, |