summaryrefslogtreecommitdiffstats
path: root/src/corelib/time
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2019-12-02 17:54:48 +0100
committerOlivier Goffart <ogoffart@woboq.com>2020-01-23 16:46:51 +0100
commit73d1476fb1397948a4d806bd921fce372bd8d63b (patch)
treea476349c26627027d78c1279da00ef633323311f /src/corelib/time
parenta78d66743171557d79b16c08be775e3ac15bb4ef (diff)
Replace most use of QVariant::type and occurrences of QVariant::Type
I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/time')
-rw-r--r--src/corelib/time/qdatetime.cpp6
-rw-r--r--src/corelib/time/qdatetimeparser.cpp24
-rw-r--r--src/corelib/time/qdatetimeparser_p.h4
3 files changed, 17 insertions, 17 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 67d37f19d8..80751e60a0 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -1791,7 +1791,7 @@ QDate QDate::fromString(const QString &string, const QString &format, QCalendar
{
QDate date;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format))
dt.fromString(string, &date, nullptr);
@@ -2537,7 +2537,7 @@ QTime QTime::fromString(const QString &string, const QString &format)
{
QTime time;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, QCalendar());
+ QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, QCalendar());
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format))
dt.fromString(string, nullptr, &time);
@@ -5482,7 +5482,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format, QC
QTime time;
QDate date;
- QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time);
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp
index 31d8e6cc20..70460ae632 100644
--- a/src/corelib/time/qdatetimeparser.cpp
+++ b/src/corelib/time/qdatetimeparser.cpp
@@ -425,7 +425,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
switch (sect) {
case 'H':
case 'h':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const Section hour = (sect == 'h') ? Hour12Section : Hour24Section;
const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
@@ -436,7 +436,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'm':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -446,7 +446,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 's':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -457,7 +457,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
break;
case 'z':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -468,7 +468,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
break;
case 'A':
case 'a':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const bool cap = (sect == 'A');
const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 };
newSectionNodes.append(sn);
@@ -482,7 +482,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'y':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const int repeat = countRepeat(newFormat, i, 4);
if (repeat >= 2) {
const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
@@ -496,7 +496,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'M':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn);
newSeparators.append(unquote(newFormat.midRef(index, i - index)));
@@ -506,7 +506,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'd':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const int repeat = countRepeat(newFormat, i, 4);
const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong
: (repeat == 3 ? DayOfWeekSectionShort : DaySection));
@@ -519,7 +519,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 't':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -1252,7 +1252,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
return StateNode();
}
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
if (year % 100 != year2digits && (isSet & YearSection2Digits)) {
if (!(isSet & YearSection)) {
year = (year / 100) * 100;
@@ -1322,7 +1322,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
}
}
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
if (isSet & Hour12Section) {
const bool hasHour = isSet & Hour24Section;
if (ampm == -1) {
@@ -1360,7 +1360,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
// If hour wasn't specified, check the default we're using exists on the
// given date (which might be a spring-forward, skipping an hour).
- if (parserType == QVariant::DateTime && !(isSet & HourSectionMask) && !when.isValid()) {
+ if (parserType == QMetaType::QDateTime && !(isSet & HourSectionMask) && !when.isValid()) {
qint64 msecs = when.toMSecsSinceEpoch();
// Fortunately, that gets a useful answer, even though when is invalid ...
const QDateTime replace =
diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h
index ec4e4e4df2..5c612ef6a4 100644
--- a/src/corelib/time/qdatetimeparser_p.h
+++ b/src/corelib/time/qdatetimeparser_p.h
@@ -83,7 +83,7 @@ public:
FromString,
DateTimeEdit
};
- QDateTimeParser(QVariant::Type t, Context ctx, const QCalendar &cal = QCalendar())
+ QDateTimeParser(QMetaType::Type t, Context ctx, const QCalendar &cal = QCalendar())
: currentSectionIndex(-1), cachedDay(-1), parserType(t),
fixday(false), spec(Qt::LocalTime), context(ctx), calendar(cal)
{
@@ -295,7 +295,7 @@ protected: // for the benefit of QDateTimeEditPrivate
QStringList separators;
QString displayFormat;
QLocale defaultLocale;
- QVariant::Type parserType;
+ QMetaType::Type parserType;
bool fixday;
Qt::TimeSpec spec; // spec if used by QDateTimeEdit
Context context;