Make QDateTimeParser a separate feature
It was being mis-described in some places by a QT_CONFIG(timezone) test, replacing older QT_BOOTSTRAPPED checks; but it has no time-zone dependency (until 5.10). So make it a separate feature in its own right. It turns out QAbstractSpinBox's presumed dependency on datetimeedit was an illusion caused by use of QDATETIMEEDIT_*_MIN symbols actually provided by datetimeparser; so remove its bogus dependency. Change-Id: Ibc12f4a9ee35acb64a39a1c7a15d2934b5710dc0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
2c35ef04ff
commit
aa4fef8812
@ -733,10 +733,16 @@
|
||||
},
|
||||
"timezone": {
|
||||
"label": "QTimeZone",
|
||||
"purpose": "Provides support for timezone handling.",
|
||||
"purpose": "Provides support for time-zone handling.",
|
||||
"section": "Utilities",
|
||||
"output": [ "publicFeature" ]
|
||||
},
|
||||
"datetimeparser": {
|
||||
"label": "QDateTimeParser",
|
||||
"purpose": "Provides support for parsing date-time texts.",
|
||||
"section": "Utilities",
|
||||
"output": [ "privateFeature" ]
|
||||
},
|
||||
"commandlineparser": {
|
||||
"label": "QCommandlineParser",
|
||||
"purpose": "Provides support for command line parsing.",
|
||||
|
@ -87,6 +87,7 @@
|
||||
#define QT_FEATURE_temporaryfile 1
|
||||
#define QT_NO_THREAD
|
||||
#define QT_FEATURE_timezone -1
|
||||
#define QT_FEATURE_datetimeparser -1
|
||||
#define QT_FEATURE_topleveldomain -1
|
||||
#define QT_NO_TRANSLATION
|
||||
#define QT_FEATURE_translation -1
|
||||
|
@ -40,7 +40,9 @@
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
#include "private/qdatetime_p.h"
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
#include "private/qdatetimeparser_p.h"
|
||||
#endif
|
||||
|
||||
#include "qdatastream.h"
|
||||
#include "qset.h"
|
||||
@ -1331,7 +1333,7 @@ QDate QDate::fromString(const QString& string, Qt::DateFormat format)
|
||||
QDate QDate::fromString(const QString &string, const QString &format)
|
||||
{
|
||||
QDate date;
|
||||
#if QT_CONFIG(timezone)
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString);
|
||||
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
|
||||
if (dt.parseFormat(format))
|
||||
@ -2037,7 +2039,7 @@ QTime QTime::fromString(const QString& string, Qt::DateFormat format)
|
||||
QTime QTime::fromString(const QString &string, const QString &format)
|
||||
{
|
||||
QTime time;
|
||||
#if QT_CONFIG(timezone)
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString);
|
||||
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
|
||||
if (dt.parseFormat(format))
|
||||
@ -4997,7 +4999,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format)
|
||||
|
||||
QDateTime QDateTime::fromString(const QString &string, const QString &format)
|
||||
{
|
||||
#if QT_CONFIG(timezone)
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
QTime time;
|
||||
QDate date;
|
||||
|
||||
|
@ -58,8 +58,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
|
||||
QDateTimeParser::~QDateTimeParser()
|
||||
{
|
||||
}
|
||||
@ -1715,6 +1713,4 @@ bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::S
|
||||
return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count);
|
||||
}
|
||||
|
||||
#endif // QT_BOOTSTRAPPED
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -63,6 +63,8 @@
|
||||
#include "QtCore/qvector.h"
|
||||
#include "QtCore/qcoreapplication.h"
|
||||
|
||||
QT_REQUIRE_CONFIG(datetimeparser);
|
||||
|
||||
#define QDATETIMEEDIT_TIME_MIN QTime(0, 0, 0, 0)
|
||||
#define QDATETIMEEDIT_TIME_MAX QTime(23, 59, 59, 999)
|
||||
#define QDATETIMEEDIT_DATE_MIN QDate(100, 1, 1)
|
||||
@ -75,8 +77,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
|
||||
class Q_CORE_EXPORT QDateTimeParser
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QDateTimeParser)
|
||||
@ -287,8 +287,6 @@ Q_CORE_EXPORT bool operator==(const QDateTimeParser::SectionNode &s1, const QDat
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeParser::Sections)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeParser::FieldInfo)
|
||||
|
||||
#endif // QT_BOOTSTRAPPED
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDATETIME_P_H
|
||||
|
@ -54,7 +54,9 @@
|
||||
#include "qlocale.h"
|
||||
#include "qlocale_p.h"
|
||||
#include "qlocale_tools_p.h"
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
#include "qdatetimeparser_p.h"
|
||||
#endif
|
||||
#include "qnamespace.h"
|
||||
#include "qdatetime.h"
|
||||
#include "qstringlist.h"
|
||||
@ -1862,7 +1864,7 @@ QDateTime QLocale::toDateTime(const QString &string, FormatType format) const
|
||||
QTime QLocale::toTime(const QString &string, const QString &format) const
|
||||
{
|
||||
QTime time;
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString);
|
||||
dt.setDefaultLocale(*this);
|
||||
if (dt.parseFormat(format))
|
||||
@ -1893,7 +1895,7 @@ QTime QLocale::toTime(const QString &string, const QString &format) const
|
||||
QDate QLocale::toDate(const QString &string, const QString &format) const
|
||||
{
|
||||
QDate date;
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString);
|
||||
dt.setDefaultLocale(*this);
|
||||
if (dt.parseFormat(format))
|
||||
@ -1923,7 +1925,7 @@ QDate QLocale::toDate(const QString &string, const QString &format) const
|
||||
#ifndef QT_NO_DATESTRING
|
||||
QDateTime QLocale::toDateTime(const QString &string, const QString &format) const
|
||||
{
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
QTime time;
|
||||
QDate date;
|
||||
|
||||
|
@ -21,7 +21,6 @@ HEADERS += \
|
||||
tools/qcryptographichash.h \
|
||||
tools/qdatetime.h \
|
||||
tools/qdatetime_p.h \
|
||||
tools/qdatetimeparser_p.h \
|
||||
tools/qdoublescanprint_p.h \
|
||||
tools/qeasingcurve.h \
|
||||
tools/qfreelist_p.h \
|
||||
@ -82,7 +81,6 @@ SOURCES += \
|
||||
tools/qcollator.cpp \
|
||||
tools/qcryptographichash.cpp \
|
||||
tools/qdatetime.cpp \
|
||||
tools/qdatetimeparser.cpp \
|
||||
tools/qeasingcurve.cpp \
|
||||
tools/qfreelist.cpp \
|
||||
tools/qhash.cpp \
|
||||
@ -170,6 +168,11 @@ qtConfig(timezone) {
|
||||
SOURCES += tools/qtimezoneprivate_icu.cpp
|
||||
}
|
||||
|
||||
qtConfig(datetimeparser) {
|
||||
HEADERS += tools/qdatetimeparser_p.h
|
||||
SOURCES += tools/qdatetimeparser.cpp
|
||||
}
|
||||
|
||||
qtConfig(regularexpression) {
|
||||
QMAKE_USE_PRIVATE += pcre2
|
||||
|
||||
|
@ -135,7 +135,7 @@
|
||||
"label": "QDateTimeEdit",
|
||||
"purpose": "Supports editing dates and times.",
|
||||
"section": "Widgets",
|
||||
"condition": "features.calendarwidget && features.datestring && features.textdate",
|
||||
"condition": "features.calendarwidget && features.datestring && features.textdate && features.datetimeparser",
|
||||
"output": [ "publicFeature", "feature" ]
|
||||
},
|
||||
"stackedwidget": {
|
||||
|
@ -39,7 +39,9 @@
|
||||
|
||||
#include <qplatformdefs.h>
|
||||
#include <private/qabstractspinbox_p.h>
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
#include <private/qdatetimeparser_p.h>
|
||||
#endif
|
||||
#include <private/qlineedit_p.h>
|
||||
#include <qabstractspinbox.h>
|
||||
|
||||
@ -47,9 +49,6 @@
|
||||
#include <qstylehints.h>
|
||||
#include <qclipboard.h>
|
||||
#include <qdatetime.h>
|
||||
#if QT_CONFIG(datetimeedit)
|
||||
#include <qdatetimeedit.h>
|
||||
#endif
|
||||
#include <qevent.h>
|
||||
#if QT_CONFIG(menu)
|
||||
#include <qmenu.h>
|
||||
@ -1962,12 +1961,15 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2)
|
||||
break;
|
||||
}
|
||||
case QVariant::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break;
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
case QVariant::DateTime: {
|
||||
QDateTime a2 = arg2.toDateTime();
|
||||
QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATETIME_MIN.daysTo(a2));
|
||||
a1.setTime(a1.time().addMSecs(QTime().msecsTo(a2.time())));
|
||||
ret = QVariant(a1);
|
||||
break;
|
||||
}
|
||||
#endif // datetimeparser
|
||||
default: break;
|
||||
}
|
||||
return ret;
|
||||
@ -2022,6 +2024,7 @@ QVariant operator*(const QVariant &arg1, double multiplier)
|
||||
ret = static_cast<int>(qBound<double>(INT_MIN, arg1.toInt() * multiplier, INT_MAX));
|
||||
break;
|
||||
case QVariant::Double: ret = QVariant(arg1.toDouble() * multiplier); break;
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
case QVariant::DateTime: {
|
||||
double days = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDateTime().date()) * multiplier;
|
||||
int daysInt = (int)days;
|
||||
@ -2031,6 +2034,7 @@ QVariant operator*(const QVariant &arg1, double multiplier)
|
||||
ret = QDateTime(QDate().addDays(int(days)), QTime().addMSecs(msecs));
|
||||
break;
|
||||
}
|
||||
#endif // datetimeparser
|
||||
default: ret = arg1; break;
|
||||
}
|
||||
|
||||
@ -2053,11 +2057,14 @@ double operator/(const QVariant &arg1, const QVariant &arg2)
|
||||
a1 = arg1.toDouble();
|
||||
a2 = arg2.toDouble();
|
||||
break;
|
||||
#if QT_CONFIG(datetimeparser)
|
||||
case QVariant::DateTime:
|
||||
a1 = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDate());
|
||||
a2 = QDATETIMEEDIT_DATE_MIN.daysTo(arg2.toDate());
|
||||
a1 += (double)QDATETIMEEDIT_TIME_MIN.msecsTo(arg1.toDateTime().time()) / (long)(3600 * 24 * 1000);
|
||||
a2 += (double)QDATETIMEEDIT_TIME_MIN.msecsTo(arg2.toDateTime().time()) / (long)(3600 * 24 * 1000);
|
||||
break;
|
||||
#endif // datetimeparser
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user