diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-06-23 12:40:55 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-07-02 15:35:18 +0200 |
commit | 057329c24c00047c8c3e1502a9a8dfa9a4169481 (patch) | |
tree | 307ed9e68e004dad434aa7c5a140f56ae0391bcc /src/corelib | |
parent | c30e0c656f34815f7ba5fac33ce58baa421c4289 (diff) |
Make feature datetimeparser depend on feature datestring
No client of QDateTimeParser actually uses it unless datestring was
enabled, nor is it any use without datestring. Various methods
conditioned on datestring are broken unless datetimeparser is enabled.
We can't condition public API on datetimeparser, as it's a private
feature, but client code can condition use of it on the private
feature. All string-to-date/time conversions that use a string format
(this includes all locale-specific formats) depend on feature
datetimeparser.
Change #if-ery (or add it) in all client (including test) code to test
the right feature.
Tidied up some code in the process. Killed some already-redundant
textdate #if-ery. Renamed a test whose name claimed it involved
locale, which it doesn't, in the course of #if-ing it.
This simplifies the condition for feature datetimeedit (which overtly
depended on textdate, redundantly since it depends on datestring which
depends on textdate; its dependence on datetimeparser now makes its
dependency on datestring also redundant).
It also removes the need for assorted datestring checks in
QDateTimeParser itself.
Change-Id: I5dfe3a977042134b2cfb16cbcc795070634e7adf
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/configure.cmake | 1 | ||||
-rw-r--r-- | src/corelib/configure.json | 1 | ||||
-rw-r--r-- | src/corelib/time/qdatetimeparser.cpp | 20 | ||||
-rw-r--r-- | src/corelib/time/qdatetimeparser_p.h | 6 |
4 files changed, 4 insertions, 24 deletions
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index 2637e2abfc..7f565437cd 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -911,6 +911,7 @@ qt_feature("datetimeparser" PRIVATE SECTION "Utilities" LABEL "QDateTimeParser" PURPOSE "Provides support for parsing date-time texts." + CONDITION QT_FEATURE_datestring ) qt_feature("commandlineparser" PUBLIC SECTION "Utilities" diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 7aa0e0b177..2610392ad1 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -981,6 +981,7 @@ "label": "QDateTimeParser", "purpose": "Provides support for parsing date-time texts.", "section": "Utilities", + "condition": "features.datestring", "output": [ "privateFeature" ] }, "commandlineparser": { diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index dd9e1507e4..ba26398772 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -79,12 +79,8 @@ QDateTimeParser::~QDateTimeParser() int QDateTimeParser::getDigit(const QDateTime &t, int index) const { if (index < 0 || index >= sectionNodes.size()) { -#if QT_CONFIG(datestring) qWarning("QDateTimeParser::getDigit() Internal error (%ls %d)", qUtf16Printable(t.toString()), index); -#else - qWarning("QDateTimeParser::getDigit() Internal error (%d)", index); -#endif return -1; } const SectionNode &node = sectionNodes.at(index); @@ -105,12 +101,8 @@ int QDateTimeParser::getDigit(const QDateTime &t, int index) const default: break; } -#if QT_CONFIG(datestring) qWarning("QDateTimeParser::getDigit() Internal error 2 (%ls %d)", qUtf16Printable(t.toString()), index); -#else - qWarning("QDateTimeParser::getDigit() Internal error 2 (%d)", index); -#endif return -1; } @@ -129,12 +121,8 @@ int QDateTimeParser::getDigit(const QDateTime &t, int index) const bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const { if (index < 0 || index >= sectionNodes.size()) { -#if QT_CONFIG(datestring) qWarning("QDateTimeParser::setDigit() Internal error (%ls %d %d)", qUtf16Printable(v.toString()), index, newVal); -#else - qWarning("QDateTimeParser::setDigit() Internal error (%d %d)", index, newVal); -#endif return false; } @@ -743,9 +731,6 @@ QString QDateTimeParser::sectionText(int sectionIndex) const return sectionText(displayText(), sectionIndex, sn.pos); } - -#if QT_CONFIG(datestring) - QDateTimeParser::ParsedSection QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex, int offset, QString *text) const @@ -1867,7 +1852,6 @@ QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionI return PossibleBoth; return (!broken[amindex] ? PossibleAM : PossiblePM); } -#endif // datestring /*! \internal @@ -2098,7 +2082,6 @@ QString QDateTimeParser::stateName(State s) const } } -#if QT_CONFIG(datestring) bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) const { QDateTime datetime; @@ -2137,7 +2120,6 @@ bool QDateTimeParser::fromString(const QString &t, QDateTime* datetime) const return true; } -#endif // datestring QDateTime QDateTimeParser::getMinimum() const { diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index 43fe4f261e..94358b092d 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -177,11 +177,9 @@ public: LowerCase }; -#if QT_CONFIG(datestring) StateNode parse(QString input, int position, const QDateTime &defaultValue, bool fixup) const; bool fromString(const QString &text, QDate *date, QTime *time) const; bool fromString(const QString &text, QDateTime* datetime) const; -#endif bool parseFormat(const QString &format); enum FieldInfoFlag { @@ -201,7 +199,6 @@ public: private: int sectionMaxSize(Section s, int count) const; QString sectionText(const QString &text, int sectionIndex, int index) const; -#if QT_CONFIG(datestring) StateNode scanString(const QDateTime &defaultValue, bool fixup, QString *input) const; struct ParsedSection { @@ -236,7 +233,6 @@ private: PossibleBoth = 4 }; AmPmFinder findAmPm(QString &str, int index, int *used = nullptr) const; -#endif // datestring bool potentialValue(QStringView str, int min, int max, int index, const QDateTime ¤tValue, int insert) const; |