From 72b57a5dfa49b4d4dd3b88cca8cc97e7283dcdf0 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Jan 2016 18:19:21 +0100 Subject: Disintermediate QDateTimeParser::SectionNode operations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: JÄ™drzej Nowacki --- src/corelib/tools/qdatetimeparser_p.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/corelib/tools/qdatetimeparser_p.h') 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, -- cgit v1.2.3