summaryrefslogtreecommitdiffstats
path: root/src/plugins
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/plugins
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/plugins')
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp40
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp3
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.cpp8
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.h4
-rw-r--r--src/plugins/sqldrivers/ibase/qsql_ibase.cpp4
-rw-r--r--src/plugins/sqldrivers/mysql/qsql_mysql.cpp116
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp6
-rw-r--r--src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp2
9 files changed, 95 insertions, 94 deletions
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index cb82672acd..6ad4597b19 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -226,7 +226,7 @@ void QTuioHandler::process2DCurSource(const QOscMessage &message)
return;
}
- if (QMetaType::Type(arguments.at(1).type()) != QMetaType::QByteArray) {
+ if (QMetaType::Type(arguments.at(1).userType()) != QMetaType::QByteArray) {
qCWarning(lcTuioSource, "Ignoring malformed TUIO source message (bad argument type)");
return;
}
@@ -248,7 +248,7 @@ void QTuioHandler::process2DCurAlive(const QOscMessage &message)
QMap<int, QTuioCursor> newActiveCursors;
for (int i = 1; i < arguments.count(); ++i) {
- if (QMetaType::Type(arguments.at(i).type()) != QMetaType::Int) {
+ if (QMetaType::Type(arguments.at(i).userType()) != QMetaType::Int) {
qCWarning(lcTuioHandler) << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')';
return;
}
@@ -293,12 +293,12 @@ void QTuioHandler::process2DCurSet(const QOscMessage &message)
return;
}
- if (QMetaType::Type(arguments.at(1).type()) != QMetaType::Int ||
- QMetaType::Type(arguments.at(2).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(3).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(4).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(5).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(6).type()) != QMetaType::Float
+ if (QMetaType::Type(arguments.at(1).userType()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(2).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(3).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(4).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(5).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(6).userType()) != QMetaType::Float
) {
qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with bad types: " << arguments;
return;
@@ -391,7 +391,7 @@ void QTuioHandler::process2DObjSource(const QOscMessage &message)
return;
}
- if (QMetaType::Type(arguments.at(1).type()) != QMetaType::QByteArray) {
+ if (QMetaType::Type(arguments.at(1).userType()) != QMetaType::QByteArray) {
qCWarning(lcTuioSource, "Ignoring malformed TUIO source message (bad argument type)");
return;
}
@@ -413,7 +413,7 @@ void QTuioHandler::process2DObjAlive(const QOscMessage &message)
QMap<int, QTuioToken> newActiveTokens;
for (int i = 1; i < arguments.count(); ++i) {
- if (QMetaType::Type(arguments.at(i).type()) != QMetaType::Int) {
+ if (QMetaType::Type(arguments.at(i).userType()) != QMetaType::Int) {
qCWarning(lcTuioHandler) << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')';
return;
}
@@ -458,16 +458,16 @@ void QTuioHandler::process2DObjSet(const QOscMessage &message)
return;
}
- if (QMetaType::Type(arguments.at(1).type()) != QMetaType::Int ||
- QMetaType::Type(arguments.at(2).type()) != QMetaType::Int ||
- QMetaType::Type(arguments.at(3).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(4).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(5).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(6).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(7).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(8).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(9).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(10).type()) != QMetaType::Float) {
+ if (QMetaType::Type(arguments.at(1).userType()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(2).userType()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(3).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(4).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(5).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(6).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(7).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(8).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(9).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(10).userType()) != QMetaType::Float) {
qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with bad types: " << arguments;
return;
}
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index c2d9d060fb..fe9ddfece7 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -123,8 +123,9 @@ protected:
return list.contains(format);
}
- QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const override
+ QVariant retrieveData_sys(const QString &fmt, QVariant::Type type) const override
{
+ auto requestedType = QMetaType::Type(type);
if (fmt.isEmpty() || isEmpty())
return QByteArray();
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 47d58fa880..e76fc8bd40 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -114,7 +114,7 @@ protected:
QStringList formats_sys() const override;
QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const override;
- QVariant xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const;
+ QVariant xdndObtainData(const QByteArray &format, QMetaType::Type requestedType) const;
QXcbDrag *drag;
};
@@ -1248,11 +1248,11 @@ QXcbDropData::~QXcbDropData()
QVariant QXcbDropData::retrieveData_sys(const QString &mimetype, QVariant::Type requestedType) const
{
QByteArray mime = mimetype.toLatin1();
- QVariant data = xdndObtainData(mime, requestedType);
+ QVariant data = xdndObtainData(mime, QMetaType::Type(requestedType));
return data;
}
-QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const
+QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QMetaType::Type requestedType) const
{
QByteArray result;
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp
index d611f86a9c..0b3219f792 100644
--- a/src/plugins/platforms/xcb/qxcbmime.cpp
+++ b/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -159,7 +159,7 @@ QVector<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, con
}
QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &d, const QString &format,
- QVariant::Type requestedType, const QByteArray &encoding)
+ QMetaType::Type requestedType, const QByteArray &encoding)
{
QByteArray data = d;
QString atomName = mimeAtomToString(connection, a);
@@ -169,7 +169,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
&& atomName == format + QLatin1String(";charset=") + QLatin1String(encoding)) {
#if QT_CONFIG(textcodec)
- if (requestedType == QVariant::String) {
+ if (requestedType == QMetaType::QString) {
QTextCodec *codec = QTextCodec::codecForName(encoding);
if (codec)
return codec->toUnicode(data);
@@ -264,7 +264,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
return QVariant();
}
-xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,
+xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QMetaType::Type requestedType,
const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding)
{
requestedEncoding->clear();
@@ -297,7 +297,7 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString
// for string/text requests try to use a format with a well-defined charset
// first to avoid encoding problems
- if (requestedType == QVariant::String
+ if (requestedType == QMetaType::QString
&& format.startsWith(QLatin1String("text/"))
&& !format.contains(QLatin1String("charset="))) {
diff --git a/src/plugins/platforms/xcb/qxcbmime.h b/src/plugins/platforms/xcb/qxcbmime.h
index f2136ec9f4..dcb4f6b6c6 100644
--- a/src/plugins/platforms/xcb/qxcbmime.h
+++ b/src/plugins/platforms/xcb/qxcbmime.h
@@ -60,8 +60,8 @@ public:
static bool mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeData *mimeData, QByteArray *data,
xcb_atom_t *atomFormat, int *dataFormat);
static QVariant mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &data, const QString &format,
- QVariant::Type requestedType, const QByteArray &encoding);
- static xcb_atom_t mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,
+ QMetaType::Type requestedType, const QByteArray &encoding);
+ static xcb_atom_t mimeAtomForFormat(QXcbConnection *connection, const QString &format, QMetaType::Type requestedType,
const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding);
};
diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
index d0928fe6ab..7bacb59994 100644
--- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
@@ -730,7 +730,7 @@ static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
if (curDim != dim) {
for(i = 0; i < list.size(); ++i) {
- if (list.at(i).type() != QVariant::List) { // dimensions mismatch
+ if (list.at(i).userType() != QVariant::List) { // dimensions mismatch
error = QLatin1String("Array dimensons mismatch. Fieldname: %1");
return 0;
}
@@ -1162,7 +1162,7 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
// null value
QVariant v;
v.convert(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype, d->sqlda->sqlvar[i].sqlscale < 0));
- if(v.type() == QVariant::Double) {
+ if (v.userType() == QVariant::Double) {
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
v.convert(QVariant::Int);
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
index 0e195cfdb4..90a810d516 100644
--- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
@@ -223,13 +223,13 @@ public:
{
QMyField()
: outField(0), nullIndicator(false), bufLength(0ul),
- myField(0), type(QVariant::Invalid)
+ myField(0), type(QMetaType::UnknownType)
{}
char *outField;
my_bool nullIndicator;
ulong bufLength;
MYSQL_FIELD *myField;
- QVariant::Type type;
+ QMetaType::Type type;
};
QVector<QMyField> fields;
@@ -263,25 +263,25 @@ static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type,
}
-static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
+static QMetaType::Type qDecodeMYSQLType(int mysqltype, uint flags)
{
- QVariant::Type type;
+ QMetaType::Type type;
switch (mysqltype) {
case FIELD_TYPE_TINY :
- type = static_cast<QVariant::Type>((flags & UNSIGNED_FLAG) ? QMetaType::UChar : QMetaType::Char);
+ type = (flags & UNSIGNED_FLAG) ? QMetaType::UChar : QMetaType::Char;
break;
case FIELD_TYPE_SHORT :
- type = static_cast<QVariant::Type>((flags & UNSIGNED_FLAG) ? QMetaType::UShort : QMetaType::Short);
+ type = (flags & UNSIGNED_FLAG) ? QMetaType::UShort : QMetaType::Short;
break;
case FIELD_TYPE_LONG :
case FIELD_TYPE_INT24 :
- type = (flags & UNSIGNED_FLAG) ? QVariant::UInt : QVariant::Int;
+ type = (flags & UNSIGNED_FLAG) ? QMetaType::UInt : QMetaType::Int;
break;
case FIELD_TYPE_YEAR :
- type = QVariant::Int;
+ type = QMetaType::Int;
break;
case FIELD_TYPE_LONGLONG :
- type = (flags & UNSIGNED_FLAG) ? QVariant::ULongLong : QVariant::LongLong;
+ type = (flags & UNSIGNED_FLAG) ? QMetaType::ULongLong : QMetaType::LongLong;
break;
case FIELD_TYPE_FLOAT :
case FIELD_TYPE_DOUBLE :
@@ -289,19 +289,19 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
#if defined(FIELD_TYPE_NEWDECIMAL)
case FIELD_TYPE_NEWDECIMAL:
#endif
- type = QVariant::Double;
+ type = QMetaType::Double;
break;
case FIELD_TYPE_DATE :
- type = QVariant::Date;
+ type = QMetaType::QDate;
break;
case FIELD_TYPE_TIME :
// A time field can be within the range '-838:59:59' to '838:59:59' so
// use QString instead of QTime since QTime is limited to 24 hour clock
- type = QVariant::String;
+ type = QMetaType::QString;
break;
case FIELD_TYPE_DATETIME :
case FIELD_TYPE_TIMESTAMP :
- type = QVariant::DateTime;
+ type = QMetaType::QDateTime;
break;
case FIELD_TYPE_STRING :
case FIELD_TYPE_VAR_STRING :
@@ -309,12 +309,12 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
case FIELD_TYPE_TINY_BLOB :
case FIELD_TYPE_MEDIUM_BLOB :
case FIELD_TYPE_LONG_BLOB :
- type = (flags & BINARY_FLAG) ? QVariant::ByteArray : QVariant::String;
+ type = (flags & BINARY_FLAG) ? QMetaType::QByteArray : QMetaType::QString;
break;
default:
case FIELD_TYPE_ENUM :
case FIELD_TYPE_SET :
- type = QVariant::String;
+ type = QMetaType::QString;
break;
}
return type;
@@ -323,7 +323,7 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
static QSqlField qToField(MYSQL_FIELD *field, QTextCodec *tc)
{
QSqlField f(toUnicode(tc, field->name),
- qDecodeMYSQLType(int(field->type), field->flags),
+ QVariant::Type(qDecodeMYSQLType(int(field->type), field->flags)),
toUnicode(tc, field->table));
f.setRequired(IS_NOT_NULL(field->flags));
f.setLength(field->length);
@@ -610,7 +610,7 @@ QVariant QMYSQLResult::data(int field)
QString val;
if (d->preparedQuery) {
if (f.nullIndicator)
- return QVariant(f.type);
+ return QVariant(QVariant::Type(f.type));
if (qIsInteger(f.type)) {
QVariant variant(f.type, f.outField);
@@ -622,34 +622,34 @@ QVariant QMYSQLResult::data(int field)
return variant;
}
- if (f.type != QVariant::ByteArray)
+ if (f.type != QMetaType::QByteArray)
val = toUnicode(d->drv_d_func()->tc, f.outField, f.bufLength);
} else {
if (d->row[field] == NULL) {
// NULL value
- return QVariant(f.type);
+ return QVariant(QVariant::Type(f.type));
}
fieldLength = mysql_fetch_lengths(d->result)[field];
- if (f.type != QVariant::ByteArray)
+ if (f.type != QMetaType::QByteArray)
val = toUnicode(d->drv_d_func()->tc, d->row[field], fieldLength);
}
switch (static_cast<int>(f.type)) {
- case QVariant::LongLong:
+ case QMetaType::LongLong:
return QVariant(val.toLongLong());
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return QVariant(val.toULongLong());
case QMetaType::Char:
case QMetaType::Short:
- case QVariant::Int:
+ case QMetaType::Int:
return QVariant(val.toInt());
case QMetaType::UChar:
case QMetaType::UShort:
- case QVariant::UInt:
+ case QMetaType::UInt:
return QVariant(val.toUInt());
- case QVariant::Double: {
+ case QMetaType::Double: {
QVariant v;
bool ok=false;
double dbl = val.toDouble(&ok);
@@ -673,13 +673,13 @@ QVariant QMYSQLResult::data(int field)
return v;
return QVariant();
}
- case QVariant::Date:
+ case QMetaType::QDate:
return qDateFromString(val);
- case QVariant::Time:
+ case QMetaType::QTime:
return qTimeFromString(val);
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return qDateTimeFromString(val);
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
QByteArray ba;
if (d->preparedQuery) {
@@ -689,7 +689,7 @@ QVariant QMYSQLResult::data(int field)
}
return QVariant(ba);
}
- case QVariant::String:
+ case QMetaType::QString:
default:
return QVariant(val);
}
@@ -867,21 +867,21 @@ void QMYSQLResult::virtual_hook(int id, void *data)
QSqlResult::virtual_hook(id, data);
}
-static MYSQL_TIME *toMySqlDate(QDate date, QTime time, QVariant::Type type)
+static MYSQL_TIME *toMySqlDate(QDate date, QTime time, int type)
{
- Q_ASSERT(type == QVariant::Time || type == QVariant::Date
- || type == QVariant::DateTime);
+ Q_ASSERT(type == QMetaType::QTime || type == QMetaType::QDate
+ || type == QMetaType::QDateTime);
MYSQL_TIME *myTime = new MYSQL_TIME;
memset(myTime, 0, sizeof(MYSQL_TIME));
- if (type == QVariant::Time || type == QVariant::DateTime) {
+ if (type == QMetaType::QTime || type == QMetaType::QDateTime) {
myTime->hour = time.hour();
myTime->minute = time.minute();
myTime->second = time.second();
myTime->second_part = time.msec() * 1000;
}
- if (type == QVariant::Date || type == QVariant::DateTime) {
+ if (type == QMetaType::QDate || type == QMetaType::QDateTime) {
myTime->year = date.year();
myTime->month = date.month();
myTime->day = date.day();
@@ -971,30 +971,30 @@ bool QMYSQLResult::exec()
currBind->length = 0;
currBind->is_unsigned = 0;
- switch (val.type()) {
- case QVariant::ByteArray:
+ switch (val.userType()) {
+ case QMetaType::QByteArray:
currBind->buffer_type = MYSQL_TYPE_BLOB;
currBind->buffer = const_cast<char *>(val.toByteArray().constData());
currBind->buffer_length = val.toByteArray().size();
break;
- case QVariant::Time:
- case QVariant::Date:
- case QVariant::DateTime: {
- MYSQL_TIME *myTime = toMySqlDate(val.toDate(), val.toTime(), val.type());
+ case QMetaType::QTime:
+ case QMetaType::QDate:
+ case QMetaType::QDateTime: {
+ MYSQL_TIME *myTime = toMySqlDate(val.toDate(), val.toTime(), val.userType());
timeVector.append(myTime);
currBind->buffer = myTime;
- switch(val.type()) {
- case QVariant::Time:
+ switch (val.userType()) {
+ case QMetaType::QTime:
currBind->buffer_type = MYSQL_TYPE_TIME;
myTime->time_type = MYSQL_TIMESTAMP_TIME;
break;
- case QVariant::Date:
+ case QMetaType::QDate:
currBind->buffer_type = MYSQL_TYPE_DATE;
myTime->time_type = MYSQL_TIMESTAMP_DATE;
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
currBind->buffer_type = MYSQL_TYPE_DATETIME;
myTime->time_type = MYSQL_TIMESTAMP_DATETIME;
break;
@@ -1004,32 +1004,32 @@ bool QMYSQLResult::exec()
currBind->buffer_length = sizeof(MYSQL_TIME);
currBind->length = 0;
break; }
- case QVariant::UInt:
- case QVariant::Int:
+ case QMetaType::UInt:
+ case QMetaType::Int:
currBind->buffer_type = MYSQL_TYPE_LONG;
currBind->buffer = data;
currBind->buffer_length = sizeof(int);
- currBind->is_unsigned = (val.type() != QVariant::Int);
+ currBind->is_unsigned = (val.userType() != QMetaType::Int);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
currBind->buffer_type = MYSQL_TYPE_TINY;
currBind->buffer = data;
currBind->buffer_length = sizeof(bool);
currBind->is_unsigned = false;
break;
- case QVariant::Double:
+ case QMetaType::Double:
currBind->buffer_type = MYSQL_TYPE_DOUBLE;
currBind->buffer = data;
currBind->buffer_length = sizeof(double);
break;
- case QVariant::LongLong:
- case QVariant::ULongLong:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
currBind->buffer_type = MYSQL_TYPE_LONGLONG;
currBind->buffer = data;
currBind->buffer_length = sizeof(qint64);
- currBind->is_unsigned = (val.type() == QVariant::ULongLong);
+ currBind->is_unsigned = (val.userType() == QMetaType::ULongLong);
break;
- case QVariant::String:
+ case QMetaType::QString:
default: {
QByteArray ba = fromUnicode(d->drv_d_func()->tc, val.toString());
stringVector.append(ba);
@@ -1548,16 +1548,16 @@ QString QMYSQLDriver::formatValue(const QSqlField &field, bool trimStrings) cons
if (field.isNull()) {
r = QStringLiteral("NULL");
} else {
- switch(field.type()) {
- case QVariant::Double:
+ switch (+field.type()) {
+ case QMetaType::Double:
r = QString::number(field.value().toDouble(), 'g', field.precision());
break;
- case QVariant::String:
+ case QMetaType::QString:
// Escape '\' characters
r = QSqlDriver::formatValue(field, trimStrings);
r.replace(QLatin1String("\\"), QLatin1String("\\\\"));
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
if (isOpen()) {
const QByteArray ba = field.value().toByteArray();
// buffer has to be at least length*2+1 bytes
diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index 7709b13cd1..33bad23e3b 100644
--- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
@@ -1422,7 +1422,7 @@ bool QODBCResult::exec()
SQLLEN *ind = &indicators[i];
if (val.isNull())
*ind = SQL_NULL_DATA;
- switch (val.type()) {
+ switch (val.userType()) {
case QVariant::Date: {
QByteArray &ba = tmpStorage[i];
ba.resize(sizeof(DATE_STRUCT));
@@ -1694,7 +1694,7 @@ bool QODBCResult::exec()
return true;
for (i = 0; i < values.count(); ++i) {
- switch (values.at(i).type()) {
+ switch (values.at(i).userType()) {
case QVariant::Date: {
DATE_STRUCT ds = *((DATE_STRUCT *)const_cast<char *>(tmpStorage.at(i).constData()));
values[i] = QVariant(QDate(ds.year, ds.month, ds.day));
@@ -1735,7 +1735,7 @@ bool QODBCResult::exec()
break; }
}
if (indicators[i] == SQL_NULL_DATA)
- values[i] = QVariant(values[i].type());
+ values[i] = QVariant(QVariant::Type(values[i].userType()));
}
return true;
}
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index 65d3f0a580..551d762434 100644
--- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -505,7 +505,7 @@ bool QSQLiteResult::exec()
if (value.isNull()) {
res = sqlite3_bind_null(d->stmt, i + 1);
} else {
- switch (value.type()) {
+ switch (value.userType()) {
case QVariant::ByteArray: {
const QByteArray *ba = static_cast<const QByteArray*>(value.constData());
res = sqlite3_bind_blob(d->stmt, i + 1, ba->constData(),