Deprecate QVariant::Type

It's been obsolete for a long time already. Make sure
the compiler now warns about it and remove all remaining
uses in qtbase.

Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
bb10
Lars Knoll 2020-09-10 17:05:10 +02:00
parent a618c260ed
commit 11bad61096
62 changed files with 701 additions and 672 deletions

View File

@ -71,7 +71,7 @@ v = QVariant(QStringList());
//! [1]
QVariant x, y(QString()), z(QString(""));
x.convert(QVariant::Int);
x.convert(QMetaType::Int);
// x.isNull() == true
// y.isNull() == true, z.isNull() == false
//! [1]

View File

@ -381,7 +381,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
{
QString result;
switch (v.userType()) {
switch (v.metaType().id()) {
case QMetaType::UnknownType:
result = QLatin1String("@Invalid()");
break;
@ -1815,8 +1815,8 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti
QVariant(QString("foo")).toList() returns an empty
list, not a list containing "foo".
*/
if (value.userType() == QMetaType::QStringList
|| (value.userType() == QMetaType::QVariantList && value.toList().size() != 1)) {
if (value.metaType().id() == QMetaType::QStringList
|| (value.metaType().id() == QMetaType::QVariantList && value.toList().size() != 1)) {
iniEscapedStringList(variantListToStringList(value.toList()), block);
} else {
iniEscapedString(variantToString(value), block);

View File

@ -106,8 +106,8 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value)
{
CFPropertyListRef result = 0;
switch (value.type()) {
case QVariant::ByteArray:
switch (value.metaType().id()) {
case QMetaType::QByteArray:
{
QByteArray ba = value.toByteArray();
result = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(ba.data()),
@ -115,12 +115,12 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value)
}
break;
// should be same as below (look for LIST)
case QVariant::List:
case QVariant::StringList:
case QVariant::Polygon:
case QMetaType::QVariantList:
case QMetaType::QStringList:
case QMetaType::QPolygon:
result = macList(value.toList());
break;
case QVariant::Map:
case QMetaType::QVariantMap:
{
const QVariantMap &map = value.toMap();
const int mapSize = map.size();
@ -145,7 +145,7 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value)
&kCFTypeDictionaryValueCallBacks);
}
break;
case QVariant::DateTime:
case QMetaType::QDateTime:
{
QDateTime dateTime = value.toDateTime();
// CFDate, unlike QDateTime, doesn't store timezone information
@ -155,30 +155,30 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value)
goto string_case;
}
break;
case QVariant::Bool:
case QMetaType::Bool:
result = value.toBool() ? kCFBooleanTrue : kCFBooleanFalse;
break;
case QVariant::Int:
case QVariant::UInt:
case QMetaType::Int:
case QMetaType::UInt:
{
int n = value.toInt();
result = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &n);
}
break;
case QVariant::Double:
case QMetaType::Double:
{
double n = value.toDouble();
result = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &n);
}
break;
case QVariant::LongLong:
case QVariant::ULongLong:
case QMetaType::LongLong:
case QMetaType::ULongLong:
{
qint64 n = value.toLongLong();
result = CFNumberCreate(0, kCFNumberLongLongType, &n);
}
break;
case QVariant::String:
case QMetaType::QString:
string_case:
default:
QString string = QSettingsPrivate::variantToString(value);
@ -226,7 +226,7 @@ static QVariant qtValue(CFPropertyListRef cfvalue)
bool metNonString = false;
for (CFIndex i = 0; i < size; ++i) {
QVariant value = qtValue(CFArrayGetValueAtIndex(cfarray, i));
if (value.type() != QVariant::String)
if (value.typeId() != QMetaType::QString)
metNonString = true;
list << value;
}

View File

@ -670,9 +670,9 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
QByteArray regValueBuff;
// Determine the type
switch (value.type()) {
case QVariant::List:
case QVariant::StringList: {
switch (value.typeId()) {
case QMetaType::QVariantList:
case QMetaType::QStringList: {
// If none of the elements contains '\0', we can use REG_MULTI_SZ, the
// native registry string list type. Otherwise we use REG_BINARY.
type = REG_MULTI_SZ;
@ -700,23 +700,23 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
break;
}
case QVariant::Int:
case QVariant::UInt: {
case QMetaType::Int:
case QMetaType::UInt: {
type = REG_DWORD;
qint32 i = value.toInt();
regValueBuff = QByteArray(reinterpret_cast<const char*>(&i), sizeof(qint32));
break;
}
case QVariant::LongLong:
case QVariant::ULongLong: {
case QMetaType::LongLong:
case QMetaType::ULongLong: {
type = REG_QWORD;
qint64 i = value.toLongLong();
regValueBuff = QByteArray(reinterpret_cast<const char*>(&i), sizeof(qint64));
break;
}
case QVariant::ByteArray:
case QMetaType::QByteArray:
Q_FALLTHROUGH();
default: {

View File

@ -2941,21 +2941,16 @@ const char *QMetaProperty::typeName() const
return rawTypeNameFromTypeInfo(mobj, data.type());
}
/*!
/*! \fn QVariant::Type QMetaProperty::type() const
\deprecated
Returns this property's type. The return value is one
of the values of the QVariant::Type enumeration.
\sa userType(), typeName(), name(), metaType()
\sa metaType().id(), typeName(), name(), metaType()
*/
QVariant::Type QMetaProperty::type() const
{
uint type = userType();
if (type >= QMetaType::User)
return QVariant::UserType;
return QVariant::Type(type);
}
/*!
/*! \fn int QMetaProperty::userType() const
\since 4.2
Returns this property's user type. The return value is one
@ -2965,12 +2960,6 @@ QVariant::Type QMetaProperty::type() const
\sa type(), QMetaType, typeName(), metaType()
*/
int QMetaProperty::userType() const
{
if (!mobj)
return QMetaType::UnknownType;
return QMetaType(mobj->d.metaTypes[data.index(mobj)]).id();
}
/*!
\since 6.0
@ -3197,7 +3186,7 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const
QVariant v = value;
QMetaType t(mobj->d.metaTypes[data.index(mobj)]);
if (t != QMetaType::fromType<QVariant>() && t != v.metaType()) {
if (isEnumType() && !t.metaObject() && v.userType() == QMetaType::QString) {
if (isEnumType() && !t.metaObject() && v.metaType().id() == QMetaType::QString) {
// Assigning a string to a property of type Q_ENUMS (instead of Q_ENUM)
bool ok;
if (isFlagType())

View File

@ -280,8 +280,15 @@ public:
const char *name() const;
const char *typeName() const;
QVariant::Type type() const;
int userType() const;
#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QT_DEPRECATED_VERSION_6_0
QVariant::Type type() const
{ int t = userType(); return t >= QMetaType::User ? QVariant::UserType : QVariant::Type(t); }
QT_WARNING_POP
#endif
int userType() const { return metaType().id(); }
QMetaType metaType() const;
int propertyIndex() const;
int relativePropertyIndex() const;

View File

@ -765,15 +765,15 @@ QVariant::QVariant(const QVariant &p)
Constructs a new variant with the regular expression value \a re.
*/
/*!
/*! \fn QVariant::QVariant(Type type)
\deprecated
Constructs an uninitialized variant of type \a type. This will create a
variant in a special null state that if accessed will return a default
constructed value of the \a type.
\sa isNull()
*/
QVariant::QVariant(Type type)
{ create(type, nullptr); }
/*!
Constructs variant of type \a type, and initializes with
@ -793,110 +793,110 @@ QVariant::QVariant(QMetaType type, const void *copy) : d(type)
}
QVariant::QVariant(int val)
: d(Int)
: d(QMetaType::Int)
{ d.set(val); }
QVariant::QVariant(uint val)
: d(UInt)
: d(QMetaType::UInt)
{ d.set(val); }
QVariant::QVariant(qlonglong val)
: d(LongLong)
: d(QMetaType::LongLong)
{ d.set(val); }
QVariant::QVariant(qulonglong val)
: d(ULongLong)
: d(QMetaType::ULongLong)
{ d.set(val); }
QVariant::QVariant(bool val)
: d(Bool)
: d(QMetaType::Bool)
{ d.set(val); }
QVariant::QVariant(double val)
: d(Double)
: d(QMetaType::Double)
{ d.set(val); }
QVariant::QVariant(float val)
: d(QMetaType::Float)
{ d.set(val); }
QVariant::QVariant(const QByteArray &val)
: d(ByteArray)
: d(QMetaType::QByteArray)
{ v_construct<QByteArray>(&d, val); }
QVariant::QVariant(const QBitArray &val)
: d(BitArray)
: d(QMetaType::QBitArray)
{ v_construct<QBitArray>(&d, val); }
QVariant::QVariant(const QString &val)
: d(String)
: d(QMetaType::QString)
{ v_construct<QString>(&d, val); }
QVariant::QVariant(QChar val)
: d(Char)
: d(QMetaType::QChar)
{ v_construct<QChar>(&d, val); }
QVariant::QVariant(QLatin1String val)
: d(String)
: d(QMetaType::QString)
{ v_construct<QString>(&d, val); }
QVariant::QVariant(const QStringList &val)
: d(StringList)
: d(QMetaType::QStringList)
{ v_construct<QStringList>(&d, val); }
QVariant::QVariant(QDate val)
: d(Date)
: d(QMetaType::QDate)
{ v_construct<QDate>(&d, val); }
QVariant::QVariant(QTime val)
: d(Time)
: d(QMetaType::QTime)
{ v_construct<QTime>(&d, val); }
QVariant::QVariant(const QDateTime &val)
: d(DateTime)
: d(QMetaType::QDateTime)
{ v_construct<QDateTime>(&d, val); }
#if QT_CONFIG(easingcurve)
QVariant::QVariant(const QEasingCurve &val)
: d(EasingCurve)
: d(QMetaType::QEasingCurve)
{ v_construct<QEasingCurve>(&d, val); }
#endif
QVariant::QVariant(const QList<QVariant> &list)
: d(List)
: d(QMetaType::QVariantList)
{ v_construct<QVariantList>(&d, list); }
QVariant::QVariant(const QMap<QString, QVariant> &map)
: d(Map)
: d(QMetaType::QVariantMap)
{ v_construct<QVariantMap>(&d, map); }
QVariant::QVariant(const QHash<QString, QVariant> &hash)
: d(Hash)
: d(QMetaType::QVariantHash)
{ v_construct<QVariantHash>(&d, hash); }
#ifndef QT_NO_GEOM_VARIANT
QVariant::QVariant(const QPoint &pt)
: d(Point)
: d(QMetaType::QPoint)
{ v_construct<QPoint>(&d, pt); }
QVariant::QVariant(const QPointF &pt)
: d(PointF)
: d(QMetaType::QPointF)
{ v_construct<QPointF>(&d, pt); }
QVariant::QVariant(const QRectF &r)
: d(RectF)
: d(QMetaType::QRectF)
{ v_construct<QRectF>(&d, r); }
QVariant::QVariant(const QLineF &l)
: d(LineF)
: d(QMetaType::QLineF)
{ v_construct<QLineF>(&d, l); }
QVariant::QVariant(const QLine &l)
: d(Line)
: d(QMetaType::QLine)
{ v_construct<QLine>(&d, l); }
QVariant::QVariant(const QRect &r)
: d(Rect)
: d(QMetaType::QRect)
{ v_construct<QRect>(&d, r); }
QVariant::QVariant(const QSize &s)
: d(Size)
: d(QMetaType::QSize)
{ v_construct<QSize>(&d, s); }
QVariant::QVariant(const QSizeF &s)
: d(SizeF)
: d(QMetaType::QSizeF)
{ v_construct<QSizeF>(&d, s); }
#endif
#ifndef QT_BOOTSTRAPPED
QVariant::QVariant(const QUrl &u)
: d(Url)
: d(QMetaType::QUrl)
{ v_construct<QUrl>(&d, u); }
#endif
QVariant::QVariant(const QLocale &l)
: d(Locale)
: d(QMetaType::QLocale)
{ v_construct<QLocale>(&d, l); }
#if QT_CONFIG(regularexpression)
QVariant::QVariant(const QRegularExpression &re)
: d(RegularExpression)
: d(QMetaType::QRegularExpression)
{ v_construct<QRegularExpression>(&d, re); }
#endif // QT_CONFIG(regularexpression)
QVariant::QVariant(const QUuid &uuid)
: d(Uuid)
: d(QMetaType::QUuid)
{ v_construct<QUuid>(&d, uuid); }
#ifndef QT_BOOTSTRAPPED
QVariant::QVariant(const QJsonValue &jsonValue)
@ -914,14 +914,16 @@ QVariant::QVariant(const QJsonDocument &jsonDocument)
#endif // QT_BOOTSTRAPPED
#if QT_CONFIG(itemmodel)
QVariant::QVariant(const QModelIndex &modelIndex)
: d(ModelIndex)
: d(QMetaType::QModelIndex)
{ v_construct<QModelIndex>(&d, modelIndex); }
QVariant::QVariant(const QPersistentModelIndex &modelIndex)
: d(PersistentModelIndex)
: d(QMetaType::QPersistentModelIndex)
{ v_construct<QPersistentModelIndex>(&d, modelIndex); }
#endif
/*!
/*! \fn QVariant::Type QVariant::type() const
\deprecated
Returns the storage type of the value stored in the variant.
Although this function is declared as returning QVariant::Type,
the return value should be interpreted as QMetaType::Type. In
@ -954,21 +956,15 @@ QVariant::QVariant(const QPersistentModelIndex &modelIndex)
\sa userType(), metaType()
*/
QVariant::Type QVariant::type() const
{
int type = d.typeId();
return type >= QMetaType::User ? UserType : static_cast<Type>(type);
}
/*!
Returns the storage type of the value stored in the variant. For
non-user types, this is the same as type().
/*! \fn int QVariant::userType() const
\fn int QVariant::typeId() const
Returns the storage type of the value stored in the variant. This is
the same as metaType().id().
\sa type(), metaType()
*/
int QVariant::userType() const
{
return d.typeId();
}
/*!
\since 6.0
@ -1187,7 +1183,7 @@ void QVariant::load(QDataStream &s)
qint8 is_null = false;
if (s.version() >= QDataStream::Qt_4_2)
s >> is_null;
if (typeId == QVariant::UserType) {
if (typeId == QMetaType::User) {
QByteArray name;
s >> name;
typeId = QMetaType::fromName(name).id();
@ -1330,28 +1326,17 @@ QDataStream& operator<<(QDataStream &s, const QVariant &p)
return s;
}
/*!
/*! \fn QDataStream& operator>>(QDataStream &s, QVariant::Type &p)
\deprecated
Reads a variant type \a p in enum representation from the stream \a s.
*/
QDataStream& operator>>(QDataStream &s, QVariant::Type &p)
{
quint32 u;
s >> u;
p = (QVariant::Type)u;
return s;
}
/*! \fn QDataStream& operator<<(QDataStream &s, const QVariant::Type p)
\deprecated
/*!
Writes a variant type \a p to the stream \a s.
*/
QDataStream& operator<<(QDataStream &s, const QVariant::Type p)
{
s << static_cast<quint32>(p);
return s;
}
#endif //QT_NO_DATASTREAM
/*!
@ -2461,6 +2446,10 @@ QDebug QVariant::qdebugHelper(QDebug dbg) const
return dbg;
}
#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QDebug operator<<(QDebug dbg, const QVariant::Type p)
{
QDebugStateSaver saver(dbg);
@ -2470,8 +2459,11 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
: "Invalid");
return dbg;
}
QT_WARNING_POP
#endif
#endif
/*! \fn template<typename T> void QVariant::setValue(T &&value)

View File

@ -99,7 +99,9 @@ inline T qvariant_cast(const QVariant &);
class Q_CORE_EXPORT QVariant
{
public:
enum Type {
#if QT_DEPRECATED_SINCE(6, 0)
enum QT_DEPRECATED_VERSION_X_6_0("Use QMetaType::Type instead.") Type
{
Invalid = QMetaType::UnknownType,
Bool = QMetaType::Bool,
Int = QMetaType::Int,
@ -172,10 +174,9 @@ class Q_CORE_EXPORT QVariant
UserType = QMetaType::User,
LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type
};
#endif
QVariant() noexcept : d() {}
~QVariant();
explicit QVariant(Type type);
explicit QVariant(QMetaType type, const void *copy = nullptr);
QVariant(const QVariant &other);
@ -241,8 +242,8 @@ class Q_CORE_EXPORT QVariant
inline void swap(QVariant &other) noexcept { qSwap(d, other.d); }
Type type() const;
int userType() const;
int typeId() const { return d.typeId(); }
int userType() const { return d.typeId(); }
const char *typeName() const;
QMetaType metaType() const;
@ -325,6 +326,18 @@ class Q_CORE_EXPORT QVariant
void save(QDataStream &ds) const;
#endif
#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QT_DEPRECATED_VERSION_X_6_0("Use the constructor taking a QMetaType instead.")
explicit QVariant(Type type)
: QVariant(QMetaType(int(type)))
{}
QT_DEPRECATED_VERSION_X_6_0("Use metaType().")
Type type() const
{
int type = d.typeId();
return type >= QMetaType::User ? UserType : static_cast<Type>(type);
}
QT_DEPRECATED_VERSION_6_0
static const char *typeToName(int typeId)
{ return QMetaType(typeId).name(); }
@ -334,6 +347,7 @@ class Q_CORE_EXPORT QVariant
int metaType = QMetaType::fromName(name).id();
return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType;
}
QT_WARNING_POP
#endif
void *data();
@ -567,8 +581,27 @@ inline bool QVariant::isValid() const
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream& operator>> (QDataStream& s, QVariant& p);
Q_CORE_EXPORT QDataStream& operator<< (QDataStream& s, const QVariant& p);
Q_CORE_EXPORT QDataStream& operator>> (QDataStream& s, QVariant::Type& p);
Q_CORE_EXPORT QDataStream& operator<< (QDataStream& s, const QVariant::Type p);
#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QT_DEPRECATED_VERSION_6_0
inline QDataStream& operator>> (QDataStream& s, QVariant::Type &p)
{
quint32 u;
s >> u;
p = static_cast<QVariant::Type>(u);
return s;
}
QT_DEPRECATED_VERSION_6_0
inline QDataStream& operator<< (QDataStream& s, const QVariant::Type p)
{
s << static_cast<quint32>(p);
return s;
}
QT_WARNING_POP
#endif
#endif
inline bool QVariant::isDetached() const
@ -597,7 +630,7 @@ template<typename T> inline T qvariant_cast(const QVariant &v)
template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
{
if (v.userType() == QMetaType::QVariant)
if (v.metaType().id() == QMetaType::QVariant)
return *reinterpret_cast<const QVariant *>(v.constData());
return v;
}
@ -605,7 +638,13 @@ template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
#endif
#ifndef QT_NO_DEBUG_STREAM
#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QT_DEPRECATED_VERSION_6_0
Q_CORE_EXPORT QDebug operator<<(QDebug, const QVariant::Type);
QT_WARNING_POP
#endif
#endif
namespace QtPrivate {

View File

@ -662,7 +662,7 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant)
{
// Handle strings and byte arrays directly, to avoid creating a temporary
// dummy container to hold their data.
int type = variant.userType();
int type = variant.metaType().id();
if (type == QMetaType::QString) {
d->append(variant.toString());
} else if (type == QMetaType::QByteArray) {
@ -728,7 +728,7 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant)
*/
QCborValue QCborValue::fromVariant(const QVariant &variant)
{
switch (variant.userType()) {
switch (variant.metaType().id()) {
case QMetaType::UnknownType:
return {};
case QMetaType::Nullptr:

View File

@ -228,7 +228,7 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
{
QJsonDocument doc;
switch (variant.userType()) {
switch (variant.metaType().id()) {
case QMetaType::QVariantMap:
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
break;

View File

@ -463,7 +463,7 @@ void QJsonValue::swap(QJsonValue &other) noexcept
*/
QJsonValue QJsonValue::fromVariant(const QVariant &variant)
{
switch (variant.userType()) {
switch (variant.metaType().id()) {
case QMetaType::Nullptr:
return QJsonValue(Null);
case QMetaType::Bool:

View File

@ -1159,7 +1159,7 @@
\variable QSystemLocale::CurrencyToStringArgument::value
An input value that should be converted to its string representation.
Contains one of QVariant::LongLong, QVariant::ULongLong or QVariant::Double
Contains one of QMetaType::LongLong, QMetaType::ULongLong or QMetaType::Double
types.
*/
/*!

View File

@ -366,19 +366,19 @@ static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument &
{
QCFType<CFNumberRef> value;
switch (arg.value.type()) {
case QVariant::Int:
case QVariant::UInt: {
case QMetaType::Int:
case QMetaType::UInt: {
int v = arg.value.toInt();
value = CFNumberCreate(NULL, kCFNumberIntType, &v);
break;
}
case QVariant::Double: {
case QMetaType::Double: {
double v = arg.value.toDouble();
value = CFNumberCreate(NULL, kCFNumberDoubleType, &v);
break;
}
case QVariant::LongLong:
case QVariant::ULongLong: {
case QMetaType::LongLong:
case QMetaType::ULongLong: {
qint64 v = arg.value.toLongLong();
value = CFNumberCreate(NULL, kCFNumberLongLongType, &v);
break;

View File

@ -519,23 +519,23 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
{
QString value;
switch (arg.value.type()) {
case QVariant::Int:
case QMetaType::Int:
value = QLocaleData::c()->longLongToString(
arg.value.toInt(), -1, 10, -1, QLocale::OmitGroupSeparator);
break;
case QVariant::UInt:
case QMetaType::UInt:
value = QLocaleData::c()->unsLongLongToString(
arg.value.toUInt(), -1, 10, -1, QLocale::OmitGroupSeparator);
break;
case QVariant::Double:
case QMetaType::Double:
value = QLocaleData::c()->doubleToString(
arg.value.toDouble(), -1, QLocaleData::DFDecimal, -1, QLocale::OmitGroupSeparator);
break;
case QVariant::LongLong:
case QMetaType::LongLong:
value = QLocaleData::c()->longLongToString(
arg.value.toLongLong(), -1, 10, -1, QLocale::OmitGroupSeparator);
break;
case QVariant::ULongLong:
case QMetaType::ULongLong:
value = QLocaleData::c()->unsLongLongToString(
arg.value.toULongLong(), -1, 10, -1, QLocale::OmitGroupSeparator);
break;

View File

@ -242,7 +242,7 @@ QDBusArgument &operator<<(QDBusArgument &argument, const MyArray &myArray)
// Append a dictionary that associates ints to MyValue types
QDBusArgument &operator<<(QDBusArgument &argument, const MyDictionary &myDict)
{
argument.beginMap(QVariant::Int, qMetaTypeId<MyValue>());
argument.beginMap(QMetaType::fromType<int>(), QMetaType::fromType<MyValue>());
MyDictionary::const_iterator i;
for (i = myDict.cbegin(); i != myDict.cend(); ++i) {
argument.beginMapEntry();

View File

@ -1107,7 +1107,7 @@ bool QDBusArgument::atEnd() const
argument (for example, by calling asVariant() in it).
For example, if the current argument is an INT32, this function
will return a QVariant with an argument of type QVariant::Int. For
will return a QVariant with an argument of type QMetaType::Int. For
an array of INT32, it will return a QVariant containing a
QDBusArgument.

View File

@ -192,7 +192,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
QMetaType id = value.metaType();
if (!id.isValid()) {
qWarning("QDBusMarshaller: cannot add a null QDBusVariant");
error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
error(QLatin1String("Invalid QVariant passed in arguments"));
return false;
}
@ -386,7 +386,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
QMetaType id = arg.metaType();
if (!id.isValid()) {
qWarning("QDBusMarshaller: cannot add an invalid QVariant");
error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
error(QLatin1String("Invalid QVariant passed in arguments"));
return false;
}

View File

@ -2052,10 +2052,10 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
\value UnknownResource No resource is loaded, or the resource type is not known.
\value HtmlResource The resource contains HTML.
\value ImageResource The resource contains image data.
Currently supported data types are QVariant::Pixmap and
QVariant::Image. If the corresponding variant is of type
QVariant::ByteArray then Qt attempts to load the image using
QImage::loadFromData. QVariant::Icon is currently not supported.
Currently supported data types are QMetaType::QPixmap and
QMetaType::QImage. If the corresponding variant is of type
QMetaType::QByteArray then Qt attempts to load the image using
QImage::loadFromData. QMetaType::QIcon is currently not supported.
The icon needs to be converted to one of the supported types first,
for example using QIcon::pixmap.
\value StyleSheetResource The resource contains CSS.

View File

@ -1036,7 +1036,7 @@ int QTextFormat::intProperty(int propertyId) const
/*!
Returns the value of the property specified by \a propertyId. If the
property isn't of QVariant::Double or QMetaType::Float type, 0 is
property isn't of QMetaType::Double or QMetaType::Float type, 0 is
returned instead.
\sa setProperty(), boolProperty(), intProperty(), stringProperty(), colorProperty(),
@ -1054,7 +1054,7 @@ qreal QTextFormat::doubleProperty(int propertyId) const
/*!
Returns the value of the property given by \a propertyId; if the
property isn't of QVariant::String type, an empty string is
property isn't of QMetaType::QString type, an empty string is
returned instead.
\sa setProperty(), boolProperty(), intProperty(), doubleProperty(), colorProperty(),
@ -1072,7 +1072,7 @@ QString QTextFormat::stringProperty(int propertyId) const
/*!
Returns the value of the property given by \a propertyId; if the
property isn't of QVariant::Color type, an invalid color is
property isn't of QMetaType::QColor type, an invalid color is
returned instead.
\sa setProperty(), boolProperty(), intProperty(), doubleProperty(),
@ -1090,7 +1090,7 @@ QColor QTextFormat::colorProperty(int propertyId) const
/*!
Returns the value of the property given by \a propertyId; if the
property isn't of QVariant::Pen type, Qt::NoPen is
property isn't of QMetaType::QPen type, Qt::NoPen is
returned instead.
\sa setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(),
@ -1108,7 +1108,7 @@ QPen QTextFormat::penProperty(int propertyId) const
/*!
Returns the value of the property given by \a propertyId; if the
property isn't of QVariant::Brush type, Qt::NoBrush is
property isn't of QMetaType::QBrush type, Qt::NoBrush is
returned instead.
\sa setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(),

View File

@ -140,15 +140,15 @@ QVariant QAndroidSystemLocale::query(QueryType type, QVariant in) const
return m_locale .currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
case CurrencyToString: {
switch (in.type()) {
case QVariant::Int:
case QMetaType::Int:
return m_locale .toCurrencyString(in.toInt());
case QVariant::UInt:
case QMetaType::UInt:
return m_locale .toCurrencyString(in.toUInt());
case QVariant::Double:
case QMetaType::Double:
return m_locale .toCurrencyString(in.toDouble());
case QVariant::LongLong:
case QMetaType::LongLong:
return m_locale .toCurrencyString(in.toLongLong());
case QVariant::ULongLong:
case QMetaType::ULongLong:
return m_locale .toCurrencyString(in.toULongLong());
default:
break;

View File

@ -104,7 +104,7 @@ QVariant QWindowsInternalMimeData::retrieveData_sys(const QString &mimeType, QMe
if (QWindowsContext::verbose) {
qCDebug(lcQpaMime) <<__FUNCTION__ << ' ' << mimeType << ' ' << type.name()
<< " returns " << result.metaType().name()
<< (result.userType() != QVariant::ByteArray ? result.toString() : QStringLiteral("<data>"));
<< (result.metaType().id() != QMetaType::QByteArray ? result.toString() : QStringLiteral("<data>"));
}
return result;
}

View File

@ -164,7 +164,7 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve
}
}
}
if (event->value().type() == QVariant::String) {
if (event->value().typeId() == QMetaType::QString) {
if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) {
// Tries to notify the change using UiaRaiseNotificationEvent(), which is only available on

View File

@ -248,25 +248,25 @@ static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type,
errorCodes.join(QLatin1Char(';')));
}
static QVariant::Type qDecodeDB2Type(SQLSMALLINT sqltype)
static QMetaType qDecodeDB2Type(SQLSMALLINT sqltype)
{
QVariant::Type type = QVariant::Invalid;
int type = QMetaType::UnknownType;
switch (sqltype) {
case SQL_REAL:
case SQL_FLOAT:
case SQL_DOUBLE:
case SQL_DECIMAL:
case SQL_NUMERIC:
type = QVariant::Double;
type = QMetaType::Double;
break;
case SQL_SMALLINT:
case SQL_INTEGER:
case SQL_BIT:
case SQL_TINYINT:
type = QVariant::Int;
type = QMetaType::Int;
break;
case SQL_BIGINT:
type = QVariant::LongLong;
type = QMetaType::LongLong;
break;
case SQL_BLOB:
case SQL_BINARY:
@ -274,19 +274,19 @@ static QVariant::Type qDecodeDB2Type(SQLSMALLINT sqltype)
case SQL_LONGVARBINARY:
case SQL_CLOB:
case SQL_DBCLOB:
type = QVariant::ByteArray;
type = QMetaType::QByteArray;
break;
case SQL_DATE:
case SQL_TYPE_DATE:
type = QVariant::Date;
type = QMetaType::QDate;
break;
case SQL_TIME:
case SQL_TYPE_TIME:
type = QVariant::Time;
type = QMetaType::QTime;
break;
case SQL_TIMESTAMP:
case SQL_TYPE_TIMESTAMP:
type = QVariant::DateTime;
type = QMetaType::QDateTime;
break;
case SQL_WCHAR:
case SQL_WVARCHAR:
@ -294,13 +294,13 @@ static QVariant::Type qDecodeDB2Type(SQLSMALLINT sqltype)
case SQL_CHAR:
case SQL_VARCHAR:
case SQL_LONGVARCHAR:
type = QVariant::String;
type = QMetaType::QString;
break;
default:
type = QVariant::ByteArray;
type = QMetaType::QByteArray;
break;
}
return type;
return QMetaType(type);
}
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate* d, int i)
@ -703,7 +703,7 @@ bool QDB2Result::exec()
values[i].detach();
switch (values.at(i).metaType().id()) {
case QVariant::Date: {
case QMetaType::QDate: {
QByteArray ba;
ba.resize(sizeof(DATE_STRUCT));
DATE_STRUCT *dt = (DATE_STRUCT *)ba.constData();
@ -723,7 +723,7 @@ bool QDB2Result::exec()
*ind == SQL_NULL_DATA ? ind : NULL);
tmpStorage.append(ba);
break; }
case QVariant::Time: {
case QMetaType::QTime: {
QByteArray ba;
ba.resize(sizeof(TIME_STRUCT));
TIME_STRUCT *dt = (TIME_STRUCT *)ba.constData();
@ -743,7 +743,7 @@ bool QDB2Result::exec()
*ind == SQL_NULL_DATA ? ind : NULL);
tmpStorage.append(ba);
break; }
case QVariant::DateTime: {
case QMetaType::QDateTime: {
QByteArray ba;
ba.resize(sizeof(TIMESTAMP_STRUCT));
TIMESTAMP_STRUCT * dt = (TIMESTAMP_STRUCT *)ba.constData();
@ -767,7 +767,7 @@ bool QDB2Result::exec()
*ind == SQL_NULL_DATA ? ind : NULL);
tmpStorage.append(ba);
break; }
case QVariant::Int:
case QMetaType::Int:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & 3],
@ -779,7 +779,7 @@ bool QDB2Result::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
case QVariant::Double:
case QMetaType::Double:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & 3],
@ -791,7 +791,7 @@ bool QDB2Result::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
case QVariant::ByteArray: {
case QMetaType::QByteArray: {
int len = values.at(i).toByteArray().size();
if (*ind != SQL_NULL_DATA)
*ind = len;
@ -806,7 +806,7 @@ bool QDB2Result::exec()
len,
ind);
break; }
case QVariant::String:
case QMetaType::QString:
{
QString str(values.at(i).toString());
if (*ind != SQL_NULL_DATA)
@ -895,24 +895,24 @@ bool QDB2Result::exec()
for (i = 0; i < values.count(); ++i) {
switch (values[i].metaType().id()) {
case QVariant::Date: {
case QMetaType::QDate: {
DATE_STRUCT ds = *((DATE_STRUCT *)tmpStorage.takeFirst().constData());
values[i] = QVariant(QDate(ds.year, ds.month, ds.day));
break; }
case QVariant::Time: {
case QMetaType::QTime: {
TIME_STRUCT dt = *((TIME_STRUCT *)tmpStorage.takeFirst().constData());
values[i] = QVariant(QTime(dt.hour, dt.minute, dt.second));
break; }
case QVariant::DateTime: {
case QMetaType::QDateTime: {
TIMESTAMP_STRUCT dt = *((TIMESTAMP_STRUCT *)tmpStorage.takeFirst().constData());
values[i] = QVariant(QDateTime(QDate(dt.year, dt.month, dt.day),
QTime(dt.hour, dt.minute, dt.second, dt.fraction / 1000000)));
break; }
case QVariant::Int:
case QVariant::Double:
case QVariant::ByteArray:
case QMetaType::Int:
case QMetaType::Double:
case QMetaType::ByteArray:
break;
case QVariant::String:
case QMetaType::QString:
if (bindValueType(i) & QSql::Out)
values[i] = QString((const QChar *)tmpStorage.takeFirst().constData());
break;
@ -1054,13 +1054,13 @@ QVariant QDB2Result::data(int field)
QVariant *v = nullptr;
switch (info.metaType().id()) {
case QVariant::LongLong:
case QMetaType::LongLong:
v = new QVariant((qint64) qGetBigIntData(d->hStmt, field, isNull));
break;
case QVariant::Int:
case QMetaType::Int:
v = new QVariant(qGetIntData(d->hStmt, field, isNull));
break;
case QVariant::Date: {
case QMetaType::QDate: {
DATE_STRUCT dbuf;
r = SQLGetData(d->hStmt,
field + 1,
@ -1075,7 +1075,7 @@ QVariant QDB2Result::data(int field)
isNull = true;
}
break; }
case QVariant::Time: {
case QMetaType::QTime: {
TIME_STRUCT tbuf;
r = SQLGetData(d->hStmt,
field + 1,
@ -1090,7 +1090,7 @@ QVariant QDB2Result::data(int field)
isNull = true;
}
break; }
case QVariant::DateTime: {
case QMetaType::QDateTime: {
TIMESTAMP_STRUCT dtbuf;
r = SQLGetData(d->hStmt,
field + 1,
@ -1106,10 +1106,10 @@ QVariant QDB2Result::data(int field)
isNull = true;
}
break; }
case QVariant::ByteArray:
case QMetaType::QByteArray:
v = new QVariant(qGetBinaryData(d->hStmt, field, lengthIndicator, isNull));
break;
case QVariant::Double:
case QMetaType::Double:
{
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
@ -1129,7 +1129,7 @@ QVariant QDB2Result::data(int field)
}
break;
}
case QVariant::String:
case QMetaType::QString:
default:
v = new QVariant(qGetStringData(d->hStmt, field, info.length(), isNull));
break;
@ -1688,7 +1688,7 @@ QString QDB2Driver::formatValue(const QSqlField &field, bool trimStrings) const
return QLatin1String("NULL");
switch (field.metaType().id()) {
case QVariant::DateTime: {
case QMetaType::QDateTime: {
// Use an escape sequence for the datetime fields
if (field.value().toDateTime().isValid()) {
QDate dt = field.value().toDateTime().date();
@ -1708,7 +1708,7 @@ QString QDB2Driver::formatValue(const QSqlField &field, bool trimStrings) const
return QLatin1String("NULL");
}
}
case QVariant::ByteArray: {
case QMetaType::QByteArray: {
QByteArray ba = field.value().toByteArray();
QString res;
res += QLatin1String("BLOB(X'");

View File

@ -158,7 +158,7 @@ static void delDA(XSQLDA *&sqlda)
sqlda = 0;
}
static QVariant::Type qIBaseTypeName(int iType, bool hasScale)
static int qIBaseTypeName(int iType, bool hasScale)
{
switch (iType) {
case blr_varying:
@ -166,60 +166,60 @@ static QVariant::Type qIBaseTypeName(int iType, bool hasScale)
case blr_text:
case blr_cstring:
case blr_cstring2:
return QVariant::String;
return QMetaType::QString;
case blr_sql_time:
return QVariant::Time;
return QMetaType::QTime;
case blr_sql_date:
return QVariant::Date;
return QMetaType::QDate;
case blr_timestamp:
return QVariant::DateTime;
return QMetaType::QDateTime;
case blr_blob:
return QVariant::ByteArray;
return QMetaType::QByteArray;
case blr_quad:
case blr_short:
case blr_long:
return (hasScale ? QVariant::Double : QVariant::Int);
return (hasScale ? QMetaType::Double : QMetaType::Int);
case blr_int64:
return (hasScale ? QVariant::Double : QVariant::LongLong);
return (hasScale ? QMetaType::Double : QMetaType::LongLong);
case blr_float:
case blr_d_float:
case blr_double:
return QVariant::Double;
return QMetaType::Double;
case blr_boolean_dtype:
return QVariant::Bool;
return QMetaType::Bool;
}
qWarning("qIBaseTypeName: unknown datatype: %d", iType);
return QVariant::Invalid;
return QMetaType::UnknownType;
}
static QVariant::Type qIBaseTypeName2(int iType, bool hasScale)
static int qIBaseTypeName2(int iType, bool hasScale)
{
switch(iType & ~1) {
case SQL_VARYING:
case SQL_TEXT:
return QVariant::String;
return QMetaType::QString;
case SQL_LONG:
case SQL_SHORT:
return (hasScale ? QVariant::Double : QVariant::Int);
return (hasScale ? QMetaType::Double : QMetaType::Int);
case SQL_INT64:
return (hasScale ? QVariant::Double : QVariant::LongLong);
return (hasScale ? QMetaType::Double : QMetaType::LongLong);
case SQL_FLOAT:
case SQL_DOUBLE:
return QVariant::Double;
return QMetaType::Double;
case SQL_TIMESTAMP:
return QVariant::DateTime;
return QMetaType::QDateTime;
case SQL_TYPE_TIME:
return QVariant::Time;
return QMetaType::QTime;
case SQL_TYPE_DATE:
return QVariant::Date;
return QMetaType::QDate;
case SQL_ARRAY:
return QVariant::List;
return QMetaType::QVariantList;
case SQL_BLOB:
return QVariant::ByteArray;
return QMetaType::QByteArray;
case SQL_BOOLEAN:
return QVariant::Bool;
return QMetaType::Bool;
default:
return QVariant::Invalid;
return QMetaType::UnknownType;
}
}
@ -674,7 +674,7 @@ static char* qFillBufferWithString(char *buffer, const QString& string,
}
static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
QVariant::Type type, short curDim, ISC_ARRAY_DESC *arrayDesc,
int type, short curDim, ISC_ARRAY_DESC *arrayDesc,
QString& error)
{
int i;
@ -694,7 +694,7 @@ static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
if (curDim != dim) {
for(i = 0; i < list.size(); ++i) {
if (list.at(i).userType() != QVariant::List) { // dimensions mismatch
if (list.at(i).typeId() != QMetaType::QVariantList) { // dimensions mismatch
error = QLatin1String("Array dimensons mismatch. Fieldname: %1");
return 0;
}
@ -706,52 +706,52 @@ static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
}
} else {
switch(type) {
case QVariant::Int:
case QVariant::UInt:
case QMetaType::Int:
case QMetaType::UInt:
if (arrayDesc->array_desc_dtype == blr_short)
buffer = fillList<short>(buffer, list);
else
buffer = fillList<int>(buffer, list);
break;
case QVariant::Double:
case QMetaType::Double:
if (arrayDesc->array_desc_dtype == blr_float)
buffer = fillList<float>(buffer, list, static_cast<float *>(0));
else
buffer = fillList<double>(buffer, list);
break;
case QVariant::LongLong:
case QMetaType::LongLong:
buffer = fillList<qint64>(buffer, list);
break;
case QVariant::ULongLong:
case QMetaType::ULongLong:
buffer = fillList<quint64>(buffer, list);
break;
case QVariant::String:
case QMetaType::QString:
for (i = 0; i < list.size(); ++i)
buffer = qFillBufferWithString(buffer, list.at(i).toString(),
arrayDesc->array_desc_length,
arrayDesc->array_desc_dtype == blr_varying,
true);
break;
case QVariant::Date:
case QMetaType::QDate:
for (i = 0; i < list.size(); ++i) {
*((ISC_DATE*)buffer) = toDate(list.at(i).toDate());
buffer += sizeof(ISC_DATE);
}
break;
case QVariant::Time:
case QMetaType::QTime:
for (i = 0; i < list.size(); ++i) {
*((ISC_TIME*)buffer) = toTime(list.at(i).toTime());
buffer += sizeof(ISC_TIME);
}
break;
case QVariant::DateTime:
case QMetaType::QDateTime:
for (i = 0; i < list.size(); ++i) {
*((ISC_TIMESTAMP*)buffer) = toTimeStamp(list.at(i).toDateTime());
buffer += sizeof(ISC_TIMESTAMP);
}
break;
case QVariant::Bool:
case QMetaType::Bool:
buffer = fillList<bool>(buffer, list);
break;
default:
@ -1132,16 +1132,16 @@ 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.userType() == QVariant::Double) {
if (v.userType() == QMetaType::Double) {
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
v.convert(QVariant::Int);
v.convert(QMetaType::Int);
break;
case QSql::LowPrecisionInt64:
v.convert(QVariant::LongLong);
v.convert(QMetaType::LongLong);
break;
case QSql::HighPrecision:
v.convert(QVariant::String);
v.convert(QMetaType::QString);
break;
case QSql::LowPrecisionDouble:
// no conversion
@ -1214,19 +1214,19 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
QVariant v = row[idx];
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
if(v.convert(QVariant::Int))
if (v.convert(QMetaType::Int))
row[idx]=v;
break;
case QSql::LowPrecisionInt64:
if(v.convert(QVariant::LongLong))
if (v.convert(QMetaType::LongLong))
row[idx]=v;
break;
case QSql::LowPrecisionDouble:
if(v.convert(QVariant::Double))
if (v.convert(QMetaType::Double))
row[idx]=v;
break;
case QSql::HighPrecision:
if(v.convert(QVariant::String))
if (v.convert(QMetaType::QString))
row[idx]=v;
break;
}
@ -1695,7 +1695,7 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const
QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) const
{
switch (field.type()) {
case QVariant::DateTime: {
case QMetaType::QDateTime: {
QDateTime datetime = field.value().toDateTime();
if (datetime.isValid())
return QLatin1Char('\'') + QString::number(datetime.date().year()) + QLatin1Char('-') +
@ -1709,7 +1709,7 @@ QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) cons
else
return QLatin1String("NULL");
}
case QVariant::Time: {
case QMetaType::QTime: {
QTime time = field.value().toTime();
if (time.isValid())
return QLatin1Char('\'') + QString::number(time.hour()) + QLatin1Char(':') +
@ -1720,7 +1720,7 @@ QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) cons
else
return QLatin1String("NULL");
}
case QVariant::Date: {
case QMetaType::QDate: {
QDate date = field.value().toDate();
if (date.isValid())
return QLatin1Char('\'') + QString::number(date.year()) + QLatin1Char('-') +

View File

@ -364,8 +364,8 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
int r = OCI_SUCCESS;
void *data = const_cast<void *>(val.constData());
switch (val.type()) {
case QVariant::ByteArray:
switch (val.typeId()) {
case QMetaType::QByteArray:
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
isOutValue(pos)
@ -374,9 +374,9 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
reinterpret_cast<QByteArray *>(data)->size(),
SQLT_BIN, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
case QVariant::Time:
case QVariant::Date:
case QVariant::DateTime: {
case QMetaType::QTime:
case QMetaType::QDate:
case QMetaType::QDateTime: {
QOCIDateTime *ptr = new QOCIDateTime(env, err, val.toDateTime());
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
@ -386,7 +386,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
tmpStorage.dateTimes.append(ptr);
break;
}
case QVariant::Int:
case QMetaType::Int:
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// if it's an out value, the data is already detached
@ -395,7 +395,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
sizeof(int),
SQLT_INT, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
case QVariant::UInt:
case QMetaType::UInt:
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// if it's an out value, the data is already detached
@ -404,7 +404,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
sizeof(uint),
SQLT_UIN, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
case QVariant::LongLong:
case QMetaType::LongLong:
{
QByteArray ba = qMakeOCINumber(val.toLongLong(), err);
r = OCIBindByPos(sql, hbnd, err,
@ -415,7 +415,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
tmpStorage.rawData.append(ba);
break;
}
case QVariant::ULongLong:
case QMetaType::ULongLong:
{
QByteArray ba = qMakeOCINumber(val.toULongLong(), err);
r = OCIBindByPos(sql, hbnd, err,
@ -426,7 +426,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
tmpStorage.rawData.append(ba);
break;
}
case QVariant::Double:
case QMetaType::Double:
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// if it's an out value, the data is already detached
@ -435,22 +435,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
sizeof(double),
SQLT_FLT, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
case QVariant::UserType:
if (val.canConvert<QOCIRowIdPointer>() && !isOutValue(pos)) {
// use a const pointer to prevent a detach
const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// it's an IN value, so const_cast is ok
const_cast<OCIRowid **>(&rptr->id),
-1,
SQLT_RDD, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
} else {
qWarning("Unknown bind variable");
r = OCI_ERROR;
}
break;
case QVariant::String: {
case QMetaType::QString: {
const QString s = val.toString();
if (isBinaryValue(pos)) {
r = OCIBindByPos(sql, hbnd, err,
@ -473,27 +458,43 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
}
} // fall through for OUT values
default: {
const QString s = val.toString();
// create a deep-copy
QByteArray ba(reinterpret_cast<const char *>(s.utf16()), (s.length() + 1) * sizeof(QChar));
if (isOutValue(pos)) {
ba.reserve((s.capacity() + 1) * sizeof(QChar));
*tmpSize = ba.size();
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
ba.data(),
ba.capacity(),
SQLT_STR, indPtr, tmpSize, 0, 0, 0, OCI_DEFAULT);
if (val.typeId() >= QMetaType::User) {
if (val.canConvert<QOCIRowIdPointer>() && !isOutValue(pos)) {
// use a const pointer to prevent a detach
const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// it's an IN value, so const_cast is ok
const_cast<OCIRowid **>(&rptr->id),
-1,
SQLT_RDD, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
} else {
qWarning("Unknown bind variable");
r = OCI_ERROR;
}
} else {
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
ba.data(),
ba.size(),
SQLT_STR, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
const QString s = val.toString();
// create a deep-copy
QByteArray ba(reinterpret_cast<const char *>(s.utf16()), (s.length() + 1) * sizeof(QChar));
if (isOutValue(pos)) {
ba.reserve((s.capacity() + 1) * sizeof(QChar));
*tmpSize = ba.size();
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
ba.data(),
ba.capacity(),
SQLT_STR, indPtr, tmpSize, 0, 0, 0, OCI_DEFAULT);
} else {
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
ba.data(),
ba.size(),
SQLT_STR, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
}
if (r == OCI_SUCCESS)
setCharset(*hbnd, OCI_HTYPE_BIND);
tmpStorage.rawData.append(ba);
}
if (r == OCI_SUCCESS)
setCharset(*hbnd, OCI_HTYPE_BIND);
tmpStorage.rawData.append(ba);
break;
} // default case
} // switch
@ -523,26 +524,26 @@ int QOCIResultPrivate::bindValues(QVariantList &values, IndicatorArray &indicato
// will assign out value and remove its temp storage.
static void qOraOutValue(QVariant &value, TempStorage &tmpStorage, OCIEnv *env, OCIError* err)
{
switch (value.type()) {
case QVariant::Time:
switch (value.typeId()) {
case QMetaType::QTime:
value = QOCIDateTime::fromOCIDateTime(env, err,
tmpStorage.dateTimes.takeFirst()->dateTime).time();
break;
case QVariant::Date:
case QMetaType::QDate:
value = QOCIDateTime::fromOCIDateTime(env, err,
tmpStorage.dateTimes.takeFirst()->dateTime).date();
break;
case QVariant::DateTime:
case QMetaType::QDateTime:
value = QOCIDateTime::fromOCIDateTime(env, err,
tmpStorage.dateTimes.takeFirst()->dateTime);
break;
case QVariant::LongLong:
case QMetaType::LongLong:
value = qMakeLongLong(tmpStorage.rawData.takeFirst(), err);
break;
case QVariant::ULongLong:
case QMetaType::ULongLong:
value = qMakeULongLong(tmpStorage.rawData.takeFirst(), err);
break;
case QVariant::String:
case QMetaType::String:
value = QString(
reinterpret_cast<const QChar *>(tmpStorage.rawData.takeFirst().constData()));
break;
@ -591,7 +592,7 @@ void QOCIDriverPrivate::allocErrorHandle()
struct OraFieldInfo
{
QString name;
QVariant::Type type;
QMetaType type;
ub1 oraIsNull;
ub4 oraType;
sb1 oraScale;
@ -650,53 +651,53 @@ QSqlError qMakeError(const QString& errString, QSqlError::ErrorType type, OCIErr
errorCode != -1 ? QString::number(errorCode) : QString());
}
QVariant::Type qDecodeOCIType(const QString& ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
QMetaType qDecodeOCIType(const QString& ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
{
QVariant::Type type = QVariant::Invalid;
int type = QMetaType::UnknownType;
if (ocitype == QLatin1String("VARCHAR2") || ocitype == QLatin1String("VARCHAR")
|| ocitype.startsWith(QLatin1String("INTERVAL"))
|| ocitype == QLatin1String("CHAR") || ocitype == QLatin1String("NVARCHAR2")
|| ocitype == QLatin1String("NCHAR"))
type = QVariant::String;
type = QMetaType::QString;
else if (ocitype == QLatin1String("NUMBER")
|| ocitype == QLatin1String("FLOAT")
|| ocitype == QLatin1String("BINARY_FLOAT")
|| ocitype == QLatin1String("BINARY_DOUBLE")) {
switch(precisionPolicy) {
case QSql::LowPrecisionInt32:
type = QVariant::Int;
type = QMetaType::Int;
break;
case QSql::LowPrecisionInt64:
type = QVariant::LongLong;
type = QMetaType::LongLong;
break;
case QSql::LowPrecisionDouble:
type = QVariant::Double;
type = QMetaType::Double;
break;
case QSql::HighPrecision:
default:
type = QVariant::String;
type = QMetaType::QString;
break;
}
}
else if (ocitype == QLatin1String("LONG") || ocitype == QLatin1String("NCLOB")
|| ocitype == QLatin1String("CLOB"))
type = QVariant::ByteArray;
type = QMetaType::QByteArray;
else if (ocitype == QLatin1String("RAW") || ocitype == QLatin1String("LONG RAW")
|| ocitype == QLatin1String("ROWID") || ocitype == QLatin1String("BLOB")
|| ocitype == QLatin1String("CFILE") || ocitype == QLatin1String("BFILE"))
type = QVariant::ByteArray;
type = QMetaType::QByteArray;
else if (ocitype == QLatin1String("DATE") || ocitype.startsWith(QLatin1String("TIME")))
type = QVariant::DateTime;
type = QMetaType::QDateTime;
else if (ocitype == QLatin1String("UNDEFINED"))
type = QVariant::Invalid;
if (type == QVariant::Invalid)
type = QMetaType::UnknownType;
if (type == QMetaType::UnknownType)
qWarning("qDecodeOCIType: unknown type: %s", ocitype.toLocal8Bit().constData());
return type;
return QMetaType(type);
}
QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
QMetaType qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
{
QVariant::Type type = QVariant::Invalid;
int type = QMetaType::UnknownType;
switch (ocitype) {
case SQLT_STR:
case SQLT_VST:
@ -712,10 +713,10 @@ QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precis
#ifdef SQLT_INTERVAL_DS
case SQLT_INTERVAL_DS:
#endif
type = QVariant::String;
type = QMetaType::QString;
break;
case SQLT_INT:
type = QVariant::Int;
type = QMetaType::Int;
break;
case SQLT_FLT:
case SQLT_NUM:
@ -723,17 +724,17 @@ QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precis
case SQLT_UIN:
switch(precisionPolicy) {
case QSql::LowPrecisionInt32:
type = QVariant::Int;
type = QMetaType::Int;
break;
case QSql::LowPrecisionInt64:
type = QVariant::LongLong;
type = QMetaType::LongLong;
break;
case QSql::LowPrecisionDouble:
type = QVariant::Double;
type = QMetaType::Double;
break;
case QSql::HighPrecision:
default:
type = QVariant::String;
type = QMetaType::QString;
break;
}
break;
@ -748,21 +749,20 @@ QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precis
case SQLT_NTY:
case SQLT_REF:
case SQLT_RID:
type = QVariant::ByteArray;
type = QMetaType::QByteArray;
break;
case SQLT_DAT:
case SQLT_ODT:
case SQLT_TIMESTAMP:
case SQLT_TIMESTAMP_TZ:
case SQLT_TIMESTAMP_LTZ:
type = QVariant::DateTime;
type = QMetaType::QDateTime;
break;
default:
type = QVariant::Invalid;
qWarning("qDecodeOCIType: unknown OCI datatype: %d", ocitype);
break;
}
return type;
return QMetaType(type);
}
static QSqlField qFromOraInf(const OraFieldInfo &ofi)
@ -770,7 +770,7 @@ static QSqlField qFromOraInf(const OraFieldInfo &ofi)
QSqlField f(ofi.name, ofi.type);
f.setRequired(ofi.oraIsNull == 0);
if (ofi.type == QVariant::String && ofi.oraType != SQLT_NUM && ofi.oraType != SQLT_VNU)
if (ofi.type.id() == QMetaType::QString && ofi.oraType != SQLT_NUM && ofi.oraType != SQLT_VNU)
f.setLength(ofi.oraFieldLength);
else
f.setLength(ofi.oraPrecision == 0 ? 38 : int(ofi.oraPrecision));
@ -852,13 +852,13 @@ private:
class OraFieldInf
{
public:
OraFieldInf() : data(0), len(0), ind(0), typ(QVariant::Invalid), oraType(0), def(0), lob(0), dataPtr(nullptr)
OraFieldInf() : data(0), len(0), ind(0), oraType(0), def(0), lob(0), dataPtr(nullptr)
{}
~OraFieldInf();
char *data;
int len;
sb2 ind;
QVariant::Type typ;
QMetaType typ;
ub4 oraType;
OCIDefine *def;
OCILobLocator *lob;
@ -879,9 +879,9 @@ QOCICols::OraFieldInf::~OraFieldInf()
}
if (dataPtr) {
switch (typ) {
case QVariant::Date:
case QVariant::Time:
case QVariant::DateTime: {
case QMetaType::QDate:
case QMetaType::QTime:
case QMetaType::QDateTime: {
int r = OCIDescriptorFree(dataPtr, OCI_DTYPE_TIMESTAMP_TZ);
if (r != OCI_SUCCESS)
qWarning("QOCICols: Cannot free OCIDateTime descriptor");
@ -935,8 +935,8 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
fieldInf[idx].oraType = ofi.oraType;
rec.append(qFromOraInf(ofi));
switch (ofi.type) {
case QVariant::DateTime:
switch (ofi.type.id()) {
case QMetaType::QDateTime:
r = OCIDescriptorAlloc(d->env, (void **)&fieldInf[idx].dataPtr, OCI_DTYPE_TIMESTAMP_TZ, 0, 0);
if (r != OCI_SUCCESS) {
qWarning("QOCICols: Unable to allocate the OCIDateTime descriptor");
@ -952,7 +952,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
&(fieldInf[idx].ind),
0, 0, OCI_DEFAULT);
break;
case QVariant::Double:
case QMetaType::Double:
r = OCIDefineByPos(d->sql,
&dfn,
d->err,
@ -963,7 +963,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
&(fieldInf[idx].ind),
0, 0, OCI_DEFAULT);
break;
case QVariant::Int:
case QMetaType::Int:
r = OCIDefineByPos(d->sql,
&dfn,
d->err,
@ -974,7 +974,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
&(fieldInf[idx].ind),
0, 0, OCI_DEFAULT);
break;
case QVariant::LongLong:
case QMetaType::LongLong:
r = OCIDefineByPos(d->sql,
&dfn,
d->err,
@ -985,7 +985,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
&(fieldInf[idx].ind),
0, 0, OCI_DEFAULT);
break;
case QVariant::ByteArray:
case QMetaType::QByteArray:
// RAW and LONG RAW fields can't be bound to LOB locators
if (ofi.oraType == SQLT_BIN) {
// qDebug("binding SQLT_BIN");
@ -1032,7 +1032,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
0, 0, OCI_DEFAULT);
}
break;
case QVariant::String:
case QMetaType::QString:
if (ofi.oraType == SQLT_LNG) {
r = OCIDefineByPos(d->sql,
&dfn,
@ -1192,7 +1192,6 @@ OraFieldInfo QOCICols::qMakeOraField(const QOCIResultPrivate* p, OCIParam* param
sb2 colPrecision(0);
ub1 colIsNull(0);
int r(0);
QVariant::Type type(QVariant::Invalid);
r = OCIAttrGet(param,
OCI_DTYPE_PARAM,
@ -1269,28 +1268,26 @@ OraFieldInfo QOCICols::qMakeOraField(const QOCIResultPrivate* p, OCIParam* param
if (r != 0)
qOraWarning("qMakeOraField:", p->err);
type = qDecodeOCIType(colType, p->q_func()->numericalPrecisionPolicy());
QMetaType type = qDecodeOCIType(colType, p->q_func()->numericalPrecisionPolicy());
if (type == QVariant::Int) {
if (colLength == 22 && colPrecision == 0 && colScale == 0)
type = QVariant::String;
if (colScale > 0)
type = QVariant::String;
if (type.id() == QMetaType::Int) {
if ((colLength == 22 && colPrecision == 0 && colScale == 0) || colScale > 0)
type = QMetaType(QMetaType::QString);
}
// bind as double if the precision policy asks for it
if (((colType == SQLT_FLT) || (colType == SQLT_NUM))
&& (p->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionDouble)) {
type = QVariant::Double;
type = QMetaType(QMetaType::Double);
}
// bind as int32 or int64 if the precision policy asks for it
if ((colType == SQLT_NUM) || (colType == SQLT_VNU) || (colType == SQLT_UIN)
|| (colType == SQLT_INT)) {
if (p->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionInt64)
type = QVariant::LongLong;
type = QMetaType(QMetaType::LongLong);
else if (p->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionInt32)
type = QVariant::Int;
type = QMetaType(QMetaType::Int);
}
if (colType == SQLT_BLOB)
@ -1357,11 +1354,10 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
int i;
sword r;
QVarLengthArray<QVariant::Type> fieldTypes;
QVarLengthArray<QMetaType> fieldTypes;
for (i = 0; i < columnCount; ++i) {
QVariant::Type tp = boundValues.at(i).type();
fieldTypes.append(tp == QVariant::List ? boundValues.at(i).toList().value(0).type()
: tp);
QMetaType tp = boundValues.at(i).metaType();
fieldTypes.append(tp.id() == QMetaType::QVariantList ? boundValues.at(i).toList().value(0).metaType() : tp);
}
SizeArray tmpSizes(columnCount);
QList<QOCIBatchColumn> columns(columnCount);
@ -1371,7 +1367,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
// figuring out buffer sizes
for (i = 0; i < columnCount; ++i) {
if (boundValues.at(i).type() != QVariant::List) {
if (boundValues.at(i).typeId() != QMetaType::QVariantList) {
// not a list - create a deep-copy of the single value
QOCIBatchColumn &singleCol = columns[i];
@ -1399,45 +1395,40 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
col.maxarr_len = col.recordCount;
col.curelep = col.recordCount;
switch (fieldTypes[i]) {
case QVariant::Time:
case QVariant::Date:
case QVariant::DateTime:
switch (fieldTypes[i].id()) {
case QMetaType::QTime:
case QMetaType::QDate:
case QMetaType::QDateTime:
col.bindAs = SQLT_TIMESTAMP_TZ;
col.maxLen = sizeof(OCIDateTime *);
break;
case QVariant::Int:
case QMetaType::Int:
col.bindAs = SQLT_INT;
col.maxLen = sizeof(int);
break;
case QVariant::UInt:
case QMetaType::UInt:
col.bindAs = SQLT_UIN;
col.maxLen = sizeof(uint);
break;
case QVariant::LongLong:
case QMetaType::LongLong:
col.bindAs = SQLT_VNU;
col.maxLen = sizeof(OCINumber);
break;
case QVariant::ULongLong:
case QMetaType::ULongLong:
col.bindAs = SQLT_VNU;
col.maxLen = sizeof(OCINumber);
break;
case QVariant::Double:
case QMetaType::Double:
col.bindAs = SQLT_FLT;
col.maxLen = sizeof(double);
break;
case QVariant::UserType:
col.bindAs = SQLT_RDD;
col.maxLen = sizeof(OCIRowid*);
break;
case QVariant::String: {
case QMetaType::QString: {
col.bindAs = SQLT_STR;
for (uint j = 0; j < col.recordCount; ++j) {
uint len;
@ -1451,18 +1442,23 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
col.maxLen *= sizeof(QChar);
break; }
case QVariant::ByteArray:
case QMetaType::QByteArray:
default: {
col.bindAs = SQLT_LBI;
for (uint j = 0; j < col.recordCount; ++j) {
if(d->isOutValue(i))
col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().capacity();
else
col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().size();
if (col.lengths[j] > col.maxLen)
col.maxLen = col.lengths[j];
if (fieldTypes[i].typeId() >= QMetaType::User) {
col.bindAs = SQLT_RDD;
col.maxLen = sizeof(OCIRowid*);
} else {
col.bindAs = SQLT_LBI;
for (uint j = 0; j < col.recordCount; ++j) {
if (d->isOutValue(i))
col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().capacity();
else
col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().size();
if (col.lengths[j] > col.maxLen)
col.maxLen = col.lengths[j];
}
}
break; }
break;
}
col.data = new char[col.maxLen * col.recordCount];
@ -1478,26 +1474,26 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
} else {
columns[i].indicators[row] = 0;
char *dataPtr = columns[i].data + (columns[i].maxLen * row);
switch (fieldTypes[i]) {
case QVariant::Time:
case QVariant::Date:
case QVariant::DateTime:{
switch (fieldTypes[i].id()) {
case QMetaType::QTime:
case QMetaType::QDate:
case QMetaType::QDateTime:{
columns[i].lengths[row] = columns[i].maxLen;
QOCIDateTime *date = new QOCIDateTime(d->env, d->err, val.toDateTime());
*reinterpret_cast<OCIDateTime**>(dataPtr) = date->dateTime;
break;
}
case QVariant::Int:
case QMetaType::Int:
columns[i].lengths[row] = columns[i].maxLen;
*reinterpret_cast<int*>(dataPtr) = val.toInt();
break;
case QVariant::UInt:
case QMetaType::UInt:
columns[i].lengths[row] = columns[i].maxLen;
*reinterpret_cast<uint*>(dataPtr) = val.toUInt();
break;
case QVariant::LongLong:
case QMetaType::LongLong:
{
columns[i].lengths[row] = columns[i].maxLen;
const QByteArray ba = qMakeOCINumber(val.toLongLong(), d->err);
@ -1505,7 +1501,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
memcpy(dataPtr, ba.constData(), columns[i].maxLen);
break;
}
case QVariant::ULongLong:
case QMetaType::ULongLong:
{
columns[i].lengths[row] = columns[i].maxLen;
const QByteArray ba = qMakeOCINumber(val.toULongLong(), d->err);
@ -1513,29 +1509,31 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
memcpy(dataPtr, ba.constData(), columns[i].maxLen);
break;
}
case QVariant::Double:
case QMetaType::Double:
columns[i].lengths[row] = columns[i].maxLen;
*reinterpret_cast<double*>(dataPtr) = val.toDouble();
break;
case QVariant::String: {
case QMetaType::QString: {
const QString s = val.toString();
columns[i].lengths[row] = (s.length() + 1) * sizeof(QChar);
memcpy(dataPtr, s.utf16(), columns[i].lengths[row]);
break;
}
case QVariant::UserType:
if (val.canConvert<QOCIRowIdPointer>()) {
const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
*reinterpret_cast<OCIRowid**>(dataPtr) = rptr->id;
columns[i].lengths[row] = 0;
break;
}
case QVariant::ByteArray:
case QMetaType::QByteArray:
default: {
const QByteArray ba = val.toByteArray();
columns[i].lengths[row] = ba.size();
memcpy(dataPtr, ba.constData(), ba.size());
if (fieldTypes[i].id() >= QMetaType::User) {
if (val.canConvert<QOCIRowIdPointer>()) {
const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
*reinterpret_cast<OCIRowid**>(dataPtr) = rptr->id;
columns[i].lengths[row] = 0;
break;
}
} else {
const QByteArray ba = val.toByteArray();
columns[i].lengths[row] = ba.size();
memcpy(dataPtr, ba.constData(), ba.size());
}
break;
}
}
@ -1618,7 +1616,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
if (!d->isOutValue(i))
continue;
if (auto tp = boundValues.at(i).metaType(); tp.id() != QVariant::List) {
if (auto tp = boundValues.at(i).metaType(); tp.id() != QMetaType::QVariantList) {
qOraOutValue(boundValues[i], tmpStorage, d->env, d->err);
if (*columns[i].indicators == -1)
boundValues[i] = QVariant(tp);
@ -1651,11 +1649,11 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
case SQLT_VNU:
{
switch (boundValues.at(i).type()) {
case QVariant::LongLong:
switch (boundValues.at(i).typeId()) {
case QMetaType::LongLong:
(*list)[r] = qMakeLongLong(data + r * columns[i].maxLen, d->err);
break;
case QVariant::ULongLong:
case QMetaType::ULongLong:
(*list)[r] = qMakeULongLong(data + r * columns[i].maxLen, d->err);
break;
default:
@ -1791,21 +1789,21 @@ void QOCICols::getValues(QVariantList &v, int index)
if (fld.oraType == SQLT_BIN || fld.oraType == SQLT_LBI || fld.oraType == SQLT_LNG)
continue; // already fetched piecewise
switch (fld.typ) {
case QVariant::DateTime:
switch (fld.typ.id()) {
case QMetaType::QDateTime:
v[index + i] = QVariant(QOCIDateTime::fromOCIDateTime(d->env, d->err,
reinterpret_cast<OCIDateTime *>(fld.dataPtr)));
break;
case QVariant::Double:
case QVariant::Int:
case QVariant::LongLong:
case QMetaType::Double:
case QMetaType::Int:
case QMetaType::LongLong:
if (d->q_func()->numericalPrecisionPolicy() != QSql::HighPrecision) {
if ((d->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionDouble)
&& (fld.typ == QVariant::Double)) {
&& (fld.typ.id() == QMetaType::Double)) {
v[index + i] = *reinterpret_cast<double *>(fld.data);
break;
} else if ((d->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionInt64)
&& (fld.typ == QVariant::LongLong)) {
&& (fld.typ.id() == QMetaType::LongLong)) {
qint64 qll = 0;
int r = OCINumberToInt(d->err, reinterpret_cast<OCINumber *>(fld.data), sizeof(qint64),
OCI_NUMBER_SIGNED, &qll);
@ -1815,20 +1813,20 @@ void QOCICols::getValues(QVariantList &v, int index)
v[index + i] = QVariant();
break;
} else if ((d->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionInt32)
&& (fld.typ == QVariant::Int)) {
&& (fld.typ.id() == QMetaType::Int)) {
v[index + i] = *reinterpret_cast<int *>(fld.data);
break;
}
}
// else fall through
case QVariant::String:
case QMetaType::QString:
v[index + i] = QString(reinterpret_cast<const QChar *>(fld.data));
break;
case QVariant::ByteArray:
case QMetaType::QByteArray:
if (fld.len > 0)
v[index + i] = QByteArray(fld.data, fld.len);
else
v[index + i] = QVariant(QVariant::ByteArray);
v[index + i] = QVariant(QMetaType::QByteArray);
break;
default:
qWarning("QOCICols::value: unknown data type");
@ -2617,11 +2615,11 @@ QSqlRecord QOCIDriver::record(const QString& tablename) const
<< QLatin1String("BINARY_DOUBLE");
if (buildRecordInfo) {
do {
QVariant::Type ty = qDecodeOCIType(t.value(1).toString(), t.numericalPrecisionPolicy());
QMetaType ty = qDecodeOCIType(t.value(1).toString(), t.numericalPrecisionPolicy());
QSqlField f(t.value(0).toString(), ty);
f.setRequired(t.value(5).toString() == QLatin1String("N"));
f.setPrecision(t.value(4).toInt());
if (d->serverVersion >= 9 && (ty == QVariant::String) && !t.isNull(3) && !keywords.contains(t.value(1).toString())) {
if (d->serverVersion >= 9 && (ty.id() == QMetaType::QString) && !t.isNull(3) && !keywords.contains(t.value(1).toString())) {
// Oracle9: data_length == size in bytes, char_length == amount of characters
f.setLength(t.value(7).toInt());
} else {
@ -2704,8 +2702,8 @@ QSqlIndex QOCIDriver::primaryIndex(const QString& tablename) const
QString QOCIDriver::formatValue(const QSqlField &field, bool trimStrings) const
{
switch (field.type()) {
case QVariant::DateTime: {
switch (field.typeId()) {
case QMetaType::QDateTime: {
QDateTime datetime = field.value().toDateTime();
QString datestring;
if (datetime.isValid()) {
@ -2722,7 +2720,7 @@ QString QOCIDriver::formatValue(const QSqlField &field, bool trimStrings) const
}
return datestring;
}
case QVariant::Time: {
case QMetaType::QTime: {
QDateTime datetime = field.value().toDateTime();
QString datestring;
if (datetime.isValid()) {
@ -2736,7 +2734,7 @@ QString QOCIDriver::formatValue(const QSqlField &field, bool trimStrings) const
}
return datestring;
}
case QVariant::Date: {
case QMetaType::QDate: {
QDate date = field.value().toDate();
QString datestring;
if (date.isValid()) {

View File

@ -554,7 +554,7 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column)
if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO)
break;
if (lengthIndicator == SQL_NULL_DATA)
return QVariant(QMetaType(QVariant::ByteArray));
return QVariant(QMetaType(QMetaType::QByteArray));
if (lengthIndicator > SQLLEN(colSize) || lengthIndicator == SQL_NO_TOTAL) {
read += colSize;
colSize = 65536;
@ -1213,19 +1213,19 @@ QVariant QODBCResult::data(int field)
// fetched column n+1, so cache all previous columns here
const QSqlField info = d->rInf.field(i);
switch (info.metaType().id()) {
case QVariant::LongLong:
case QMetaType::LongLong:
d->fieldCache[i] = qGetBigIntData(d->hStmt, i);
break;
case QVariant::ULongLong:
case QMetaType::ULongLong:
d->fieldCache[i] = qGetBigIntData(d->hStmt, i, false);
break;
case QVariant::Int:
case QMetaType::Int:
d->fieldCache[i] = qGetIntData(d->hStmt, i);
break;
case QVariant::UInt:
case QMetaType::UInt:
d->fieldCache[i] = qGetIntData(d->hStmt, i, false);
break;
case QVariant::Date:
case QMetaType::QDate:
DATE_STRUCT dbuf;
r = SQLGetData(d->hStmt,
i + 1,
@ -1238,7 +1238,7 @@ QVariant QODBCResult::data(int field)
else
d->fieldCache[i] = QVariant(QMetaType::fromType<QDate>());
break;
case QVariant::Time:
case QMetaType::QTime:
TIME_STRUCT tbuf;
r = SQLGetData(d->hStmt,
i + 1,
@ -1251,7 +1251,7 @@ QVariant QODBCResult::data(int field)
else
d->fieldCache[i] = QVariant(QMetaType::fromType<QTime>());
break;
case QVariant::DateTime:
case QMetaType::QDateTime:
TIMESTAMP_STRUCT dtbuf;
r = SQLGetData(d->hStmt,
i + 1,
@ -1265,13 +1265,13 @@ QVariant QODBCResult::data(int field)
else
d->fieldCache[i] = QVariant(QMetaType::fromType<QDateTime>());
break;
case QVariant::ByteArray:
case QMetaType::QByteArray:
d->fieldCache[i] = qGetBinaryData(d->hStmt, i);
break;
case QVariant::String:
case QMetaType::QString:
d->fieldCache[i] = qGetStringData(d->hStmt, i, info.length(), d->unicode);
break;
case QVariant::Double:
case QMetaType::Double:
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
d->fieldCache[i] = qGetIntData(d->hStmt, i);
@ -1414,8 +1414,8 @@ bool QODBCResult::exec()
SQLLEN *ind = &indicators[i];
if (val.isNull())
*ind = SQL_NULL_DATA;
switch (val.userType()) {
case QVariant::Date: {
switch (val.typeId()) {
case QMetaType::QDate: {
QByteArray &ba = tmpStorage[i];
ba.resize(sizeof(DATE_STRUCT));
DATE_STRUCT *dt = (DATE_STRUCT *)const_cast<char *>(ba.constData());
@ -1434,7 +1434,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break; }
case QVariant::Time: {
case QMetaType::QTime: {
QByteArray &ba = tmpStorage[i];
ba.resize(sizeof(TIME_STRUCT));
TIME_STRUCT *dt = (TIME_STRUCT *)const_cast<char *>(ba.constData());
@ -1453,7 +1453,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break; }
case QVariant::DateTime: {
case QMetaType::QDateTime: {
QByteArray &ba = tmpStorage[i];
ba.resize(sizeof(TIMESTAMP_STRUCT));
TIMESTAMP_STRUCT *dt = reinterpret_cast<TIMESTAMP_STRUCT *>(const_cast<char *>(ba.constData()));
@ -1489,7 +1489,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break; }
case QVariant::Int:
case QMetaType::Int:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@ -1501,7 +1501,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
case QVariant::UInt:
case QMetaType::UInt:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@ -1513,7 +1513,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
case QVariant::Double:
case QMetaType::Double:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@ -1525,7 +1525,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
case QVariant::LongLong:
case QMetaType::LongLong:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@ -1537,7 +1537,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
case QVariant::ULongLong:
case QMetaType::ULongLong:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@ -1549,7 +1549,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
case QVariant::ByteArray:
case QMetaType::QByteArray:
if (*ind != SQL_NULL_DATA) {
*ind = val.toByteArray().size();
}
@ -1564,7 +1564,7 @@ bool QODBCResult::exec()
val.toByteArray().size(),
ind);
break;
case QVariant::Bool:
case QMetaType::Bool:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@ -1576,7 +1576,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
case QVariant::String:
case QMetaType::QString:
if (d->unicode) {
QByteArray &ba = tmpStorage[i];
QString str = val.toString();
@ -1689,31 +1689,31 @@ bool QODBCResult::exec()
return true;
for (i = 0; i < values.count(); ++i) {
switch (values.at(i).userType()) {
case QVariant::Date: {
switch (values.at(i).typeId()) {
case QMetaType::QDate: {
DATE_STRUCT ds = *((DATE_STRUCT *)const_cast<char *>(tmpStorage.at(i).constData()));
values[i] = QVariant(QDate(ds.year, ds.month, ds.day));
break; }
case QVariant::Time: {
case QMetaType::QTime: {
TIME_STRUCT dt = *((TIME_STRUCT *)const_cast<char *>(tmpStorage.at(i).constData()));
values[i] = QVariant(QTime(dt.hour, dt.minute, dt.second));
break; }
case QVariant::DateTime: {
case QMetaType::QDateTime: {
TIMESTAMP_STRUCT dt = *((TIMESTAMP_STRUCT*)
const_cast<char *>(tmpStorage.at(i).constData()));
values[i] = QVariant(QDateTime(QDate(dt.year, dt.month, dt.day),
QTime(dt.hour, dt.minute, dt.second, dt.fraction / 1000000)));
break; }
case QVariant::Bool:
case QVariant::Int:
case QVariant::UInt:
case QVariant::Double:
case QVariant::ByteArray:
case QVariant::LongLong:
case QVariant::ULongLong:
case QMetaType::Bool:
case QMetaType::Int:
case QMetaType::UInt:
case QMetaType::Double:
case QMetaType::QByteArray:
case QMetaType::LongLong:
case QMetaType::ULongLong:
//nothing to do
break;
case QVariant::String:
case QMetaType::QString:
if (d->unicode) {
if (bindValueType(i) & QSql::Out) {
const QByteArray &first = tmpStorage.at(i);
@ -2583,7 +2583,7 @@ QString QODBCDriver::formatValue(const QSqlField &field,
QString r;
if (field.isNull()) {
r = QLatin1String("NULL");
} else if (field.metaType().id() == QVariant::DateTime) {
} else if (field.metaType().id() == QMetaType::QDateTime) {
// Use an escape sequence for the datetime fields
if (field.value().toDateTime().isValid()){
QDate dt = field.value().toDateTime().date();
@ -2599,7 +2599,7 @@ QString QODBCDriver::formatValue(const QSqlField &field,
QLatin1String("' }");
} else
r = QLatin1String("NULL");
} else if (field.metaType().id() == QVariant::ByteArray) {
} else if (field.metaType().id() == QMetaType::QByteArray) {
QByteArray ba = field.value().toByteArray();
QString res;
static const char hexchars[] = "0123456789abcdef";

View File

@ -364,15 +364,15 @@ bool QPSQLResultPrivate::processResults()
return false;
}
static QVariant::Type qDecodePSQLType(int t)
static QMetaType qDecodePSQLType(int t)
{
QVariant::Type type = QVariant::Invalid;
int type = QMetaType::UnknownType;
switch (t) {
case QBOOLOID:
type = QVariant::Bool;
type = QMetaType::Bool;
break;
case QINT8OID:
type = QVariant::LongLong;
type = QMetaType::LongLong;
break;
case QINT2OID:
case QINT4OID:
@ -380,34 +380,34 @@ static QVariant::Type qDecodePSQLType(int t)
case QREGPROCOID:
case QXIDOID:
case QCIDOID:
type = QVariant::Int;
type = QMetaType::Int;
break;
case QNUMERICOID:
case QFLOAT4OID:
case QFLOAT8OID:
type = QVariant::Double;
type = QMetaType::Double;
break;
case QABSTIMEOID:
case QRELTIMEOID:
case QDATEOID:
type = QVariant::Date;
type = QMetaType::QDate;
break;
case QTIMEOID:
case QTIMETZOID:
type = QVariant::Time;
type = QMetaType::QTime;
break;
case QTIMESTAMPOID:
case QTIMESTAMPTZOID:
type = QVariant::DateTime;
type = QMetaType::QDateTime;
break;
case QBYTEAOID:
type = QVariant::ByteArray;
type = QMetaType::QByteArray;
break;
default:
type = QVariant::String;
type = QMetaType::QString;
break;
}
return type;
return QMetaType(type);
}
void QPSQLResultPrivate::deallocatePreparedStmt()
@ -632,23 +632,23 @@ QVariant QPSQLResult::data(int i)
}
const int currentRow = isForwardOnly() ? 0 : at();
int ptype = PQftype(d->result, i);
QVariant::Type type = qDecodePSQLType(ptype);
QMetaType type = qDecodePSQLType(ptype);
if (PQgetisnull(d->result, currentRow, i))
return QVariant(QMetaType(type), nullptr);
return QVariant(type, nullptr);
const char *val = PQgetvalue(d->result, currentRow, i);
switch (type) {
case QVariant::Bool:
switch (type.id()) {
case QMetaType::Bool:
return QVariant((bool)(val[0] == 't'));
case QVariant::String:
case QMetaType::QString:
return d->drv_d_func()->isUtf8 ? QString::fromUtf8(val) : QString::fromLatin1(val);
case QVariant::LongLong:
case QMetaType::LongLong:
if (val[0] == '-')
return QByteArray::fromRawData(val, qstrlen(val)).toLongLong();
else
return QByteArray::fromRawData(val, qstrlen(val)).toULongLong();
case QVariant::Int:
case QMetaType::Int:
return atoi(val);
case QVariant::Double: {
case QMetaType::Double: {
if (ptype == QNUMERICOID) {
if (numericalPrecisionPolicy() == QSql::HighPrecision)
return QString::fromLatin1(val);
@ -675,26 +675,26 @@ QVariant QPSQLResult::data(int i)
}
return dbl;
}
case QVariant::Date:
case QMetaType::QDate:
#if QT_CONFIG(datestring)
return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate));
#else
return QVariant(QString::fromLatin1(val));
#endif
case QVariant::Time:
case QMetaType::QTime:
#if QT_CONFIG(datestring)
return QVariant(QTime::fromString(QString::fromLatin1(val), Qt::ISODate));
#else
return QVariant(QString::fromLatin1(val));
#endif
case QVariant::DateTime:
case QMetaType::QDateTime:
#if QT_CONFIG(datestring)
return QVariant(QDateTime::fromString(QString::fromLatin1(val),
Qt::ISODate).toLocalTime());
#else
return QVariant(QString::fromLatin1(val));
#endif
case QVariant::ByteArray: {
case QMetaType::QByteArray: {
size_t len;
unsigned char *data = PQunescapeBytea((const unsigned char*)val, &len);
QByteArray ba(reinterpret_cast<const char *>(data), int(len));
@ -702,7 +702,6 @@ QVariant QPSQLResult::data(int i)
return QVariant(ba);
}
default:
case QVariant::Invalid:
qWarning("QPSQLResult::data: unknown data type");
}
return QVariant();
@ -805,7 +804,7 @@ QSqlRecord QPSQLResult::record() const
f.setTableName(QString());
}
int ptype = PQftype(d->result, i);
f.setMetaType(QMetaType(qDecodePSQLType(ptype)));
f.setMetaType(qDecodePSQLType(ptype));
f.setValue(QVariant(f.metaType())); // only set in setType() when it's invalid before
int len = PQfsize(d->result, i);
int precision = PQfmod(d->result, i);
@ -1477,7 +1476,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
r = nullStr();
} else {
switch (field.metaType().id()) {
case QVariant::DateTime:
case QMetaType::QDateTime:
#if QT_CONFIG(datestring)
if (field.value().toDateTime().isValid()) {
// we force the value to be considered with a timezone information, and we force it to be UTC
@ -1493,7 +1492,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
r = nullStr();
#endif // datestring
break;
case QVariant::Time:
case QMetaType::QTime:
#if QT_CONFIG(datestring)
if (field.value().toTime().isValid()) {
r = QLatin1Char('\'') + field.value().toTime().toString(u"hh:mm:ss.zzz") + QLatin1Char('\'');
@ -1503,18 +1502,18 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
r = nullStr();
}
break;
case QVariant::String:
case QMetaType::QString:
r = QSqlDriver::formatValue(field, trimStrings);
if (d->hasBackslashEscape)
r.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
break;
case QVariant::Bool:
case QMetaType::Bool:
if (field.value().toBool())
r = QStringLiteral("TRUE");
else
r = QStringLiteral("FALSE");
break;
case QVariant::ByteArray: {
case QMetaType::QByteArray: {
QByteArray ba(field.value().toByteArray());
size_t len;
#if defined PG_VERSION_NUM && PG_VERSION_NUM-0 >= 80200
@ -1533,12 +1532,12 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
if (r.isEmpty())
r = QSqlDriver::formatValue(field, trimStrings);
break;
case QVariant::Double:
case QMetaType::Double:
assignSpecialPsqlFloatValue(field.value().toDouble(), &r);
if (r.isEmpty())
r = QSqlDriver::formatValue(field, trimStrings);
break;
case QVariant::Uuid:
case QMetaType::QUuid:
r = QLatin1Char('\'') + field.value().toString() + QLatin1Char('\'');
break;
default:

View File

@ -73,7 +73,7 @@ ints << 1 << 2 << 3 << 4;
q.addBindValue(ints);
QVariantList names;
names << "Harald" << "Boris" << "Trond" << QVariant(QVariant::String);
names << "Harald" << "Boris" << "Trond" << QVariant(QMetaType::QString);
q.addBindValue(names);
if (!q.execBatch())

View File

@ -54,13 +54,6 @@ class Q_SQL_EXPORT QSqlField
public:
enum RequiredStatus { Unknown = -1, Optional = 0, Required = 1 };
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_X_6_0("Use the constructor using a QMetaType instead")
QSqlField(const QString& fieldName, QVariant::Type type, const QString &tableName = QString())
: QSqlField(fieldName, QMetaType(type), tableName)
{}
#endif
explicit QSqlField(const QString& fieldName = QString(), QMetaType type = QMetaType(), const QString &tableName = QString());
QSqlField(const QSqlField& other);
@ -86,10 +79,17 @@ public:
void setMetaType(QMetaType type);
#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QT_DEPRECATED_VERSION_X_6_0("Use the constructor using a QMetaType instead")
QSqlField(const QString& fieldName, QVariant::Type type, const QString &tableName = QString())
: QSqlField(fieldName, QMetaType(type), tableName)
{}
QT_DEPRECATED_VERSION_X_6_0("Use metaType() instead")
QVariant::Type type() const { return QVariant::Type(metaType().id()); };
QT_DEPRECATED_VERSION_X_6_0("Use setMetaType() instead")
void setType(QVariant::Type type) { setMetaType(QMetaType(int(type))); }
QT_WARNING_POP
#endif
void setRequiredStatus(RequiredStatus status);

View File

@ -1047,7 +1047,7 @@ bool QSqlQuery::exec()
To bind NULL values, a null QVariant of the relevant type has to be
added to the bound QVariantList; for example, \c
{QVariant(QVariant::String)} should be used if you are using
{QVariant(QMetaType::QString)} should be used if you are using
strings.
\note Every bound QVariantList must contain the same amount of
@ -1085,7 +1085,7 @@ bool QSqlQuery::execBatch(BatchExecutionMode mode)
the result into.
To bind a NULL value, use a null QVariant; for example, use
\c {QVariant(QVariant::String)} if you are binding a string.
\c {QVariant(QMetaType::QString)} if you are binding a string.
\sa addBindValue(), prepare(), exec(), boundValue(), boundValues()
*/
@ -1115,7 +1115,7 @@ void QSqlQuery::bindValue(int pos, const QVariant& val, QSql::ParamType paramTyp
overwritten with data from the database after the exec() call.
To bind a NULL value, use a null QVariant; for example, use \c
{QVariant(QVariant::String)} if you are binding a string.
{QVariant(QMetaType::QString)} if you are binding a string.
\sa bindValue(), prepare(), exec(), boundValue(), boundValues()
*/

View File

@ -935,7 +935,7 @@ void QSqlResult::virtual_hook(int, void *)
contain equal amount of values (rows).
NULL values are passed in as typed QVariants, for example
\c {QVariant(QVariant::Int)} for an integer NULL value.
\c {QVariant(QMetaType::Int)} for an integer NULL value.
Example:

View File

@ -68,9 +68,9 @@ QSignalSpy spy(myCustomObject, SIGNAL(mySignal(int,QString,double)));
myCustomObject->doSomething(); // trigger emission of the signal
QList<QVariant> arguments = spy.takeFirst();
QVERIFY(arguments.at(0).type() == QVariant::Int);
QVERIFY(arguments.at(1).type() == QVariant::String);
QVERIFY(arguments.at(2).type() == QVariant::double);
QVERIFY(arguments.at(0).typeId() == QMetaType::Int);
QVERIFY(arguments.at(1).typeId() == QMetaType::QString);
QVERIFY(arguments.at(2).typeId() == QMetaType::Double);
//! [1]

View File

@ -64,7 +64,7 @@ QItemEditorFactory *factory = new QItemEditorFactory;
//! [2]
QItemEditorFactory *editorFactory = new QItemEditorFactory;
QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<MyFancyDateTimeEdit>();
editorFactory->registerEditor(QVariant::DateType, creator);
editorFactory->registerEditor(QMetaType::QDateTime, creator);
//! [2]

View File

@ -432,7 +432,7 @@ QItemEditorCreatorBase::~QItemEditorCreatorBase()
the creator is registered for. For example, a creator which constructs
QCheckBox widgets to edit boolean values would return the
\l{QCheckBox::checkable}{checkable} property name from this function,
and must be registered in the item editor factory for the QVariant::Bool
and must be registered in the item editor factory for the QMetaType::Bool
type.
Note: Since Qt 4.2 the item delegates query the user property of widgets,
@ -513,7 +513,7 @@ QItemEditorCreatorBase::~QItemEditorCreatorBase()
Setting the \c editorFactory created above in an item delegate via
QStyledItemDelegate::setItemEditorFactory() makes sure that all values of type
QVariant::DateTime will be edited in \c{MyFancyDateTimeEdit}.
QMetaType::QDateTime will be edited in \c{MyFancyDateTimeEdit}.
The editor must provide a user property that will contain the
editing data. The property is used by \l{QStyledItemDelegate}s to set

View File

@ -2232,7 +2232,7 @@ QIcon QComboBox::itemIcon(int index) const
/*!
Returns the data for the given \a role in the given \a index in the
combobox, or QVariant::Invalid if there is no data for this role.
combobox, or an invalid QVariant if there is no data for this role.
*/
QVariant QComboBox::itemData(int index, int role) const
{

View File

@ -721,11 +721,11 @@ void tst_QSettings::embeddedZeroByte()
QSettings settings("QtProject", "tst_qsettings");
QVariant outValue = settings.value(QTest::currentDataTag());
switch (value.type()) {
case QVariant::ByteArray:
switch (value.typeId()) {
case QMetaType::QByteArray:
QCOMPARE(outValue.toByteArray(), value.toByteArray());
break;
case QVariant::String:
case QMetaType::QString:
QCOMPARE(outValue.toString(), value.toString());
break;
default:
@ -932,9 +932,9 @@ void tst_QSettings::testIniParsing()
if (expect.isValid())
QVERIFY(v.canConvert(expect.type()));
// check some types so as to give prettier error messages
if ( v.type() == QVariant::String ) {
if ( v.typeId() == QMetaType::QString ) {
QCOMPARE(v.toString(), expect.toString());
} else if ( v.type() == QVariant::Int ) {
} else if ( v.typeId() == QMetaType::Int ) {
QCOMPARE(v.toInt(), expect.toInt());
} else {
QCOMPARE(v, expect);

View File

@ -1609,16 +1609,16 @@ void tst_QSortFilterProxyModel::removeSourceRows()
QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count());
for (int i = 0; i < aboutToRemoveSpy.count(); ++i) {
const auto &args = aboutToRemoveSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second);
}
QCOMPARE(removeSpy.count(), expectedRemovedProxyIntervals.count());
for (int i = 0; i < removeSpy.count(); ++i) {
const auto &args = removeSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second);
}
@ -1787,8 +1787,8 @@ void tst_QSortFilterProxyModel::changeFilter()
QCOMPARE(initialInsertSpy.count(), 0);
for (int i = 0; i < initialRemoveSpy.count(); ++i) {
const auto &args = initialRemoveSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), initialRemoveIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), initialRemoveIntervals.at(i).second);
}
@ -1810,8 +1810,8 @@ void tst_QSortFilterProxyModel::changeFilter()
QCOMPARE(finalRemoveSpy.count(), finalRemoveIntervals.count());
for (int i = 0; i < finalRemoveSpy.count(); ++i) {
const auto &args = finalRemoveSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), finalRemoveIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), finalRemoveIntervals.at(i).second);
}
@ -1819,8 +1819,8 @@ void tst_QSortFilterProxyModel::changeFilter()
QCOMPARE(finalInsertSpy.count(), insertIntervals.count());
for (int i = 0; i < finalInsertSpy.count(); ++i) {
const auto &args = finalInsertSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), insertIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), insertIntervals.at(i).second);
}
@ -2025,8 +2025,8 @@ void tst_QSortFilterProxyModel::changeSourceData()
QCOMPARE(removeSpy.count(), removeIntervals.count());
for (int i = 0; i < removeSpy.count(); ++i) {
const auto &args = removeSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), removeIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), removeIntervals.at(i).second);
}
@ -2034,8 +2034,8 @@ void tst_QSortFilterProxyModel::changeSourceData()
QCOMPARE(insertSpy.count(), insertIntervals.count());
for (int i = 0; i < insertSpy.count(); ++i) {
const auto &args = insertSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), insertIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), insertIntervals.at(i).second);
}
@ -4606,16 +4606,16 @@ void tst_QSortFilterProxyModel::removeIntervals()
QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count());
for (int i = 0; i < aboutToRemoveSpy.count(); ++i) {
const auto &args = aboutToRemoveSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second);
}
QCOMPARE(removeSpy.count(), expectedRemovedProxyIntervals.count());
for (int i = 0; i < removeSpy.count(); ++i) {
const auto &args = removeSpy.at(i);
QCOMPARE(args.at(1).type(), QVariant::Int);
QCOMPARE(args.at(2).type(), QVariant::Int);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second);
}

View File

@ -1447,7 +1447,15 @@ void tst_QMetaObject::customPropertyType()
{
QMetaProperty prop = metaObject()->property(metaObject()->indexOfProperty("value3"));
#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QCOMPARE(prop.type(), QVariant::UserType);
QT_WARNING_POP
#endif
QCOMPARE(prop.userType(), QMetaType::fromType<MyStruct>().id());
QCOMPARE(prop.metaType(), QMetaType::fromType<MyStruct>());
@ -1455,11 +1463,11 @@ void tst_QMetaObject::customPropertyType()
QCOMPARE(prop.userType(), QMetaType::fromName("MyStruct").id());
prop = metaObject()->property(metaObject()->indexOfProperty("value4"));
QCOMPARE(prop.type(), QVariant::List);
QCOMPARE(prop.metaType().id(), QMetaType::QVariantList);
QCOMPARE(prop.metaType(), QMetaType::fromType<QList<QVariant>>());
prop = metaObject()->property(metaObject()->indexOfProperty("value5"));
QCOMPARE(prop.type(), QVariant::List);
QCOMPARE(prop.metaType().id(), QMetaType::QVariantList);
}
void tst_QMetaObject::checkScope_data()

View File

@ -749,7 +749,7 @@ void tst_QMetaObjectBuilder::variantProperty()
QMetaObject *meta = builder.toMetaObject();
QMetaProperty prop = meta->property(meta->propertyOffset());
QCOMPARE(QMetaType::Type(prop.type()), QMetaType::QVariant);
QCOMPARE(QMetaType::Type(prop.userType()), QMetaType::QVariant);
QCOMPARE(QMetaType::Type(prop.userType()), QMetaType::QVariant);
QCOMPARE(QByteArray(prop.typeName()), QByteArray("QVariant"));
@ -1582,7 +1582,7 @@ void tst_QMetaObjectBuilder::usage_property()
QScopedPointer<TestObject> testObject(new TestObject);
QVariant prop = testObject->property("intProp");
QCOMPARE(prop.type(), QVariant::Int);
QCOMPARE(prop.metaType(), QMetaType(QMetaType::Int));
QCOMPARE(prop.toInt(), testObject->intProp());
QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged);
@ -1590,7 +1590,7 @@ void tst_QMetaObjectBuilder::usage_property()
testObject->setProperty("intProp", 123);
QCOMPARE(propChangedSpy.count(), 1);
prop = testObject->property("intProp");
QCOMPARE(prop.type(), QVariant::Int);
QCOMPARE(prop.metaType(), QMetaType(QMetaType::Int));
QCOMPARE(prop.toInt(), 123);
}
@ -1618,9 +1618,9 @@ void tst_QMetaObjectBuilder::usage_method()
QVERIFY(listInvokableQRealQString.invoke(testObject.data(), Q_RETURN_ARG(QVariantList, list),
Q_ARG(qreal, 123.0), Q_ARG(QString, "ciao")));
QCOMPARE(list.size(), 2);
QCOMPARE(list.at(0).type(), QVariant::Type(QMetaType::QReal));
QCOMPARE(list.at(0).metaType(), QMetaType(QMetaType::QReal));
QCOMPARE(list.at(0).toDouble(), double(123));
QCOMPARE(list.at(1).type(), QVariant::String);
QCOMPARE(list.at(1).metaType(), QMetaType(QMetaType::QString));
QCOMPARE(list.at(1).toString(), QString::fromLatin1("ciao"));
}

View File

@ -451,7 +451,7 @@ void tst_QUuid::qvariant()
QUuid uuid = QUuid::createUuid();
QVariant v = QVariant::fromValue(uuid);
QVERIFY(!v.isNull());
QCOMPARE(v.type(), QVariant::Uuid);
QCOMPARE(v.metaType(), QMetaType(QMetaType::QUuid));
QUuid uuid2 = v.value<QUuid>();
QVERIFY(!uuid2.isNull());
@ -478,14 +478,14 @@ void tst_QUuid::qvariant_conversion()
// try reverse conversion QString -> QUuid
QVariant sv = QVariant::fromValue(uuid.toString());
QCOMPARE(sv.type(), QVariant::String);
QCOMPARE(sv.metaType(), QMetaType(QMetaType::QString));
QVERIFY(sv.canConvert<QUuid>());
QCOMPARE(sv.value<QUuid>(), uuid);
// QString -> QUuid
{
QVariant sv = QVariant::fromValue(uuid.toByteArray());
QCOMPARE(sv.type(), QVariant::ByteArray);
QCOMPARE(sv.metaType(), QMetaType(QMetaType::QByteArray));
QVERIFY(sv.canConvert<QUuid>());
QCOMPARE(sv.value<QUuid>(), uuid);
}

View File

@ -224,7 +224,7 @@ void tst_QCborValue_Json::fromVariant()
QCOMPARE(QCborArray::fromVariantList({variant}), QCborArray{v});
QCOMPARE(QCborArray::fromVariantList({variant, variant}), QCborArray({v, v}));
if (variant.type() == QVariant::String) {
if (variant.metaType() == QMetaType(QMetaType::QString)) {
QString s = variant.toString();
QCOMPARE(QCborArray::fromStringList({s}), QCborArray{v});
QCOMPARE(QCborArray::fromStringList({s, s}), QCborArray({v, v}));

View File

@ -578,7 +578,7 @@ void tst_QDataStream::readQRegularExpression(QDataStream *s)
*s >> R;
QCOMPARE(R, test);
*s >> V;
QCOMPARE(V.type(), QVariant::RegularExpression);
QCOMPARE(V.userType(), QMetaType::QRegularExpression);
QCOMPARE(V.toRegularExpression(), test);
}
#endif //QT_CONFIG(regularexpression)

View File

@ -198,15 +198,15 @@ public:
void emitSignal(const QString &, const QVariant &value)
{
switch (value.type())
switch (value.metaType().id())
{
case QVariant::Invalid:
case QMetaType::UnknownType:
emit signal();
break;
case QVariant::Int:
case QMetaType::Int:
emit signal(value.toInt());
break;
case QVariant::String:
case QMetaType::QString:
emit signal(value.toString());
break;
default:

View File

@ -953,7 +953,7 @@ void tst_QDBusAbstractAdaptor::readPropertiesEmptyInterface()
continue;
}
QCOMPARE(int(reply.value().type()), int(QVariant::String));
QCOMPARE(reply.value().userType(), int(QMetaType::QString));
if (it.value().isValid())
QCOMPARE(reply.value().toString(), it.value().toString());
}
@ -1479,7 +1479,7 @@ void tst_QDBusAbstractAdaptor::readPropertiesEmptyInterfacePeer()
continue;
}
QCOMPARE(int(reply.value().type()), int(QVariant::String));
QCOMPARE(int(reply.value().userType()), int(QMetaType::QString));
if (it.value().isValid())
QCOMPARE(reply.value().toString(), it.value().toString());
}

View File

@ -483,14 +483,14 @@ void tst_QDBusInterface::callMethod()
QCOMPARE(MyObject::callArgs.count(), 1);
QVariant v = MyObject::callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("foo"));
// verify reply
QCOMPARE(reply.arguments().count(), 1);
v = reply.arguments().at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("foo"));
// call an INVOKABLE method
@ -502,14 +502,14 @@ void tst_QDBusInterface::callMethod()
QCOMPARE(MyObject::callArgs.count(), 1);
v = MyObject::callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("bar"));
// verify reply
QCOMPARE(reply.arguments().count(), 1);
v = reply.arguments().at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("bar"));
}
@ -530,7 +530,7 @@ void tst_QDBusInterface::invokeMethod()
QCOMPARE(MyObject::callArgs.count(), 1);
QVariant v = MyObject::callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("foo"));
// make the INVOKABLE call without a return type
@ -542,7 +542,7 @@ void tst_QDBusInterface::invokeMethod()
QCOMPARE(MyObject::callArgs.count(), 1);
v = MyObject::callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("bar"));
}
@ -564,7 +564,7 @@ void tst_QDBusInterface::invokeMethodWithReturn()
QCOMPARE(MyObject::callArgs.count(), 1);
QVariant v = MyObject::callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg.variant().toString());
// verify that we got the reply as expected
@ -579,7 +579,7 @@ void tst_QDBusInterface::invokeMethodWithReturn()
QCOMPARE(MyObject::callArgs.count(), 1);
v = MyObject::callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg2.variant().toString());
// verify that we got the reply as expected
@ -608,12 +608,12 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn()
QCOMPARE(MyObject::callArgs.count(), 2);
QVariant v = MyObject::callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg.variant().toString());
v = MyObject::callArgs.at(1);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg2.variant().toString());
// verify that we got the replies as expected
@ -633,12 +633,12 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn()
QCOMPARE(MyObject::callArgs.count(), 2);
v = MyObject::callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg3.variant().toString());
v = MyObject::callArgs.at(1);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg4.variant().toString());
// verify that we got the replies as expected
@ -718,14 +718,14 @@ void tst_QDBusInterface::callMethodPeer()
QCOMPARE(callArgs.count(), 1);
QVariant v = callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("foo"));
// verify reply
QCOMPARE(reply.arguments().count(), 1);
v = reply.arguments().at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("foo"));
// call an INVOKABLE method
@ -738,14 +738,14 @@ void tst_QDBusInterface::callMethodPeer()
QCOMPARE(callArgs.count(), 1);
v = callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("bar"));
// verify reply
QCOMPARE(reply.arguments().count(), 1);
v = reply.arguments().at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("bar"));
}
@ -767,7 +767,7 @@ void tst_QDBusInterface::invokeMethodPeer()
QCOMPARE(callArgs.count(), 1);
QVariant v = callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("foo"));
// make the INVOKABLE call without a return type
@ -780,7 +780,7 @@ void tst_QDBusInterface::invokeMethodPeer()
QCOMPARE(callArgs.count(), 1);
v = callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("bar"));
}
@ -803,7 +803,7 @@ void tst_QDBusInterface::invokeMethodWithReturnPeer()
QCOMPARE(callArgs.count(), 1);
QVariant v = callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg.variant().toString());
// verify that we got the reply as expected
@ -819,7 +819,7 @@ void tst_QDBusInterface::invokeMethodWithReturnPeer()
QCOMPARE(callArgs.count(), 1);
v = callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg2.variant().toString());
// verify that we got the reply as expected
@ -849,12 +849,12 @@ void tst_QDBusInterface::invokeMethodWithMultiReturnPeer()
QCOMPARE(callArgs.count(), 2);
QVariant v = callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg.variant().toString());
v = callArgs.at(1);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg2.variant().toString());
// verify that we got the replies as expected
@ -875,12 +875,12 @@ void tst_QDBusInterface::invokeMethodWithMultiReturnPeer()
QCOMPARE(callArgs.count(), 2);
v = callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg3.variant().toString());
v = callArgs.at(1);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), arg4.variant().toString());
// verify that we got the replies as expected

View File

@ -861,8 +861,7 @@ void tst_QDBusMarshall::sendArgument()
QVERIFY(arg.atEnd());
QCOMPARE(arg.currentType(), QDBusArgument::UnknownType);
if (value.type() != QVariant::UserType)
QCOMPARE(extracted, value);
QCOMPARE(extracted, value);
}
void tst_QDBusMarshall::sendSignalErrors()
@ -1272,7 +1271,7 @@ void tst_QDBusMarshall::demarshallPrimitives()
QCOMPARE(receiveArg.currentSignature(), sig);
const QVariant receiveValue = demarshallPrimitiveAs(typeIndex, receiveArg);
if (receiveValue.type() == value.type()) {
if (receiveValue.metaType() == value.metaType()) {
// Value type is the same, compare the values
QCOMPARE(receiveValue, value);
QVERIFY(receiveArg.atEnd());

View File

@ -418,7 +418,7 @@ void tst_QDBusMetaObject::types()
QCOMPARE(constructed.isUser(), expected.isUser());
QCOMPARE(constructed.isWritable(), expected.isWritable());
QCOMPARE(constructed.typeName(), expected.typeName());
QCOMPARE(constructed.type(), expected.type());
QCOMPARE(constructed.metaType(), expected.metaType());
QCOMPARE(constructed.userType(), expected.userType());
}
}

View File

@ -108,8 +108,6 @@ typedef QMap<int, QString> IntStringMap;
typedef QMap<QString, QString> StringStringMap;
typedef QMap<QString, Struct1> StringStruct1Map;
Q_DECLARE_METATYPE(QVariant::Type)
QT_BEGIN_NAMESPACE
QDBusArgument &operator<<(QDBusArgument &arg, const Struct1 &)
{
@ -289,70 +287,70 @@ void tst_QDBusMetaType::initTestCase()
void tst_QDBusMetaType::staticTypes_data()
{
QTest::addColumn<QVariant::Type>("typeId");
QTest::addColumn<int>("typeId");
QTest::addColumn<QString>("signature");
QTest::newRow("uchar") << QVariant::Type(QMetaType::UChar) << "y";
QTest::newRow("bool") << QVariant::Bool << "b";
QTest::newRow("short") << QVariant::Type(QMetaType::Short) << "n";
QTest::newRow("ushort") << QVariant::Type(QMetaType::UShort) << "q";
QTest::newRow("int") << QVariant::Int << "i";
QTest::newRow("uint") << QVariant::UInt << "u";
QTest::newRow("qlonglong") << QVariant::LongLong << "x";
QTest::newRow("qulonglong") << QVariant::ULongLong << "t";
QTest::newRow("double") << QVariant::Double << "d";
QTest::newRow("QString") << QVariant::String << "s";
QTest::newRow("QDBusObjectPath") << QVariant::Type(qMetaTypeId<QDBusObjectPath>()) << "o";
QTest::newRow("QDBusSignature") << QVariant::Type(qMetaTypeId<QDBusSignature>()) << "g";
QTest::newRow("QDBusVariant") << QVariant::Type(qMetaTypeId<QDBusVariant>()) << "v";
QTest::newRow("uchar") << int(QMetaType::UChar) << "y";
QTest::newRow("bool") << int(QMetaType::Bool) << "b";
QTest::newRow("short") << int(QMetaType::Short) << "n";
QTest::newRow("ushort") << int(QMetaType::UShort) << "q";
QTest::newRow("int") << int(QMetaType::Int) << "i";
QTest::newRow("uint") << int(QMetaType::UInt) << "u";
QTest::newRow("qlonglong") << int(QMetaType::LongLong) << "x";
QTest::newRow("qulonglong") << int(QMetaType::ULongLong) << "t";
QTest::newRow("double") << int(QMetaType::Double) << "d";
QTest::newRow("QString") << int(QMetaType::QString) << "s";
QTest::newRow("QDBusObjectPath") << qMetaTypeId<QDBusObjectPath>() << "o";
QTest::newRow("QDBusSignature") << qMetaTypeId<QDBusSignature>() << "g";
QTest::newRow("QDBusVariant") << qMetaTypeId<QDBusVariant>() << "v";
QTest::newRow("QByteArray") << QVariant::ByteArray << "ay";
QTest::newRow("QStringList") << QVariant::StringList << "as";
QTest::newRow("QByteArray") << int(QMetaType::QByteArray) << "ay";
QTest::newRow("QStringList") << int(QMetaType::QStringList) << "as";
}
void tst_QDBusMetaType::dynamicTypes_data()
{
QTest::addColumn<QVariant::Type>("typeId");
QTest::addColumn<int>("typeId");
QTest::addColumn<QString>("signature");
QTest::newRow("QVariantList") << QVariant::List << "av";
QTest::newRow("QVariantMap") << QVariant::Map << "a{sv}";
QTest::newRow("QDate") << QVariant::Date << "(iii)";
QTest::newRow("QTime") << QVariant::Time << "(iiii)";
QTest::newRow("QDateTime") << QVariant::DateTime << "((iii)(iiii)i)";
QTest::newRow("QRect") << QVariant::Rect << "(iiii)";
QTest::newRow("QRectF") << QVariant::RectF << "(dddd)";
QTest::newRow("QSize") << QVariant::Size << "(ii)";
QTest::newRow("QSizeF") << QVariant::SizeF << "(dd)";
QTest::newRow("QPoint") << QVariant::Point << "(ii)";
QTest::newRow("QPointF") << QVariant::PointF << "(dd)";
QTest::newRow("QLine") << QVariant::Line << "((ii)(ii))";
QTest::newRow("QLineF") << QVariant::LineF << "((dd)(dd))";
QTest::newRow("QVariantList") << int(QMetaType::QVariantList) << "av";
QTest::newRow("QVariantMap") << int(QMetaType::QVariantMap) << "a{sv}";
QTest::newRow("QDate") << int(QMetaType::QDate) << "(iii)";
QTest::newRow("QTime") << int(QMetaType::QTime) << "(iiii)";
QTest::newRow("QDateTime") << int(QMetaType::QDateTime) << "((iii)(iiii)i)";
QTest::newRow("QRect") << int(QMetaType::QRect) << "(iiii)";
QTest::newRow("QRectF") << int(QMetaType::QRectF) << "(dddd)";
QTest::newRow("QSize") << int(QMetaType::QSize) << "(ii)";
QTest::newRow("QSizeF") << int(QMetaType::QSizeF) << "(dd)";
QTest::newRow("QPoint") << int(QMetaType::QPoint) << "(ii)";
QTest::newRow("QPointF") << int(QMetaType::QPointF) << "(dd)";
QTest::newRow("QLine") << int(QMetaType::QLine) << "((ii)(ii))";
QTest::newRow("QLineF") << int(QMetaType::QLineF) << "((dd)(dd))";
QTest::newRow("Struct1") << QVariant::Type(qMetaTypeId<Struct1>()) << "(s)";
QTest::newRow("QList<Struct1>") << QVariant::Type(qMetaTypeId<QList<Struct1> >()) << "a(s)";
QTest::newRow("Struct1") << qMetaTypeId<Struct1>() << "(s)";
QTest::newRow("QList<Struct1>") << qMetaTypeId<QList<Struct1> >() << "a(s)";
QTest::newRow("Struct2") << QVariant::Type(qMetaTypeId<Struct2>()) << "(sos)";
QTest::newRow("QList<Struct2>") << QVariant::Type(qMetaTypeId<QList<Struct2> >()) << "a(sos)";
QTest::newRow("Struct2") << qMetaTypeId<Struct2>() << "(sos)";
QTest::newRow("QList<Struct2>") << qMetaTypeId<QList<Struct2>>() << "a(sos)";
QTest::newRow("QList<Struct3>") << QVariant::Type(qMetaTypeId<QList<Struct3> >()) << "a(sas)";
QTest::newRow("Struct3") << QVariant::Type(qMetaTypeId<Struct3>()) << "(sas)";
QTest::newRow("QList<Struct3>") << qMetaTypeId<QList<Struct3>>() << "a(sas)";
QTest::newRow("Struct3") << qMetaTypeId<Struct3>() << "(sas)";
QTest::newRow("Struct4") << QVariant::Type(qMetaTypeId<Struct4>()) << "(ssa(ss)sayasx)";
QTest::newRow("QList<Struct4>") << QVariant::Type(qMetaTypeId<QList<Struct4> >()) << "a(ssa(ss)sayasx)";
QTest::newRow("Struct4") << qMetaTypeId<Struct4>() << "(ssa(ss)sayasx)";
QTest::newRow("QList<Struct4>") << qMetaTypeId<QList<Struct4>>() << "a(ssa(ss)sayasx)";
QTest::newRow("Struct5") << QVariant::Type(qMetaTypeId<Struct5>()) << "a{sa{sv}}";
QTest::newRow("Struct5") << qMetaTypeId<Struct5>() << "a{sa{sv}}";
QTest::newRow("Struct6") << QVariant::Type(qMetaTypeId<Struct6>()) << "av";
QTest::newRow("Struct6") << qMetaTypeId<Struct6>() << "av";
QTest::newRow("QMap<int,QString>") << QVariant::Type(intStringMap) << "a{is}";
QTest::newRow("QMap<QString,QString>") << QVariant::Type(stringStringMap) << "a{ss}";
QTest::newRow("QMap<QString,Struct1>") << QVariant::Type(stringStruct1Map) << "a{s(s)}";
QTest::newRow("QMap<int,QString>") << intStringMap << "a{is}";
QTest::newRow("QMap<QString,QString>") << stringStringMap << "a{ss}";
QTest::newRow("QMap<QString,Struct1>") << stringStruct1Map << "a{s(s)}";
}
void tst_QDBusMetaType::staticTypes()
{
QFETCH(QVariant::Type, typeId);
QFETCH(int, typeId);
QString result = QDBusMetaType::typeToSignature(QMetaType(typeId));
QTEST(result, "signature");
@ -366,22 +364,22 @@ void tst_QDBusMetaType::dynamicTypes()
void tst_QDBusMetaType::invalidTypes_data()
{
QTest::addColumn<QVariant::Type>("typeId");
QTest::addColumn<int>("typeId");
QTest::addColumn<QString>("signature");
QTest::newRow("Invalid0") << QVariant::Type(qMetaTypeId<Invalid0>()) << "";
QTest::newRow("Invalid1") << QVariant::Type(qMetaTypeId<Invalid1>()) << "";
QTest::newRow("Invalid2") << QVariant::Type(qMetaTypeId<Invalid2>()) << "";
QTest::newRow("Invalid3") << QVariant::Type(qMetaTypeId<Invalid3>()) << "";
QTest::newRow("Invalid4") << QVariant::Type(qMetaTypeId<Invalid4>()) << "";
QTest::newRow("Invalid5") << QVariant::Type(qMetaTypeId<Invalid5>()) << "";
QTest::newRow("Invalid6") << QVariant::Type(qMetaTypeId<Invalid6>()) << "";
QTest::newRow("Invalid7") << QVariant::Type(qMetaTypeId<Invalid7>()) << "";
QTest::newRow("Invalid0") << qMetaTypeId<Invalid0>() << "";
QTest::newRow("Invalid1") << qMetaTypeId<Invalid1>() << "";
QTest::newRow("Invalid2") << qMetaTypeId<Invalid2>() << "";
QTest::newRow("Invalid3") << qMetaTypeId<Invalid3>() << "";
QTest::newRow("Invalid4") << qMetaTypeId<Invalid4>() << "";
QTest::newRow("Invalid5") << qMetaTypeId<Invalid5>() << "";
QTest::newRow("Invalid6") << qMetaTypeId<Invalid6>() << "";
QTest::newRow("Invalid7") << qMetaTypeId<Invalid7>() << "";
QTest::newRow("QList<Invalid0>") << QVariant::Type(qMetaTypeId<QList<Invalid0> >()) << "";
QTest::newRow("QList<Invalid0>") << qMetaTypeId<QList<Invalid0>>() << "";
QTest::newRow("long") << QVariant::Type(QMetaType::Long) << "";
QTest::newRow("void*") << QVariant::Type(QMetaType::VoidStar) << "";
QTest::newRow("long") << int(QMetaType::Long) << "";
QTest::newRow("void*") << int(QMetaType::VoidStar) << "";
}
void tst_QDBusMetaType::invalidTypes()

View File

@ -179,7 +179,7 @@ void tst_QDBusPendingCall::waitForFinished()
QCOMPARE(args.count(), 1);
const QVariant &arg = args.at(0);
QCOMPARE(arg.type(), QVariant::StringList);
QCOMPARE(arg.userType(), QMetaType::QStringList);
QVERIFY(arg.toStringList().contains(conn.baseService()));
}

View File

@ -128,7 +128,7 @@ void tst_QGuiVariant::constructor_invalid()
QFETCH(uint, typeId);
{
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(static_cast<QVariant::Type>(typeId));
QVariant variant{QMetaType(typeId)};
QVERIFY(!variant.isValid());
QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
@ -655,7 +655,7 @@ void tst_QGuiVariant::debugStream_data()
const char *tagName = QMetaType(id).name();
if (!tagName)
continue;
QTest::newRow(tagName) << QVariant(static_cast<QVariant::Type>(id)) << id;
QTest::newRow(tagName) << QVariant(QMetaType(id)) << id;
}
}

View File

@ -154,7 +154,7 @@ static void dumpConfiguration(QTextStream &str)
// On Windows, this will provide addition GPU info similar to the output of dxdiag.
if (QGuiApplication::platformNativeInterface()) {
const QVariant gpuInfoV = QGuiApplication::platformNativeInterface()->property("gpu");
if (gpuInfoV.type() == QVariant::Map) {
if (gpuInfoV.userType() == QMetaType::QVariantMap) {
const QString description = gpuInfoV.toMap().value(QStringLiteral("printable")).toString();
if (!description.isEmpty())
str << "\nGPU:\n" << description << "\n\n";

View File

@ -498,7 +498,7 @@ void tst_QNetworkRequest::rawHeaderParsing()
QCOMPARE(QString(request.rawHeader(rawHeader.toLatin1())), rawValue);
QCOMPARE(request.header(cookedHeader).isNull(), !success);
if (cookedValue.type() != QVariant::UserType)
if (cookedValue.metaType().id() < QMetaType::User)
QCOMPARE(request.header(cookedHeader), cookedValue);
else if (cookedValue.userType() == qMetaTypeId<QList<QNetworkCookie> >())
QCOMPARE(qvariant_cast<QList<QNetworkCookie> >(request.header(cookedHeader)),

View File

@ -311,7 +311,7 @@ void tst_Cmptest::compare_tostring_data()
;
QTest::newRow("null hash, invalid")
<< QVariant(QVariant::Hash)
<< QVariant(QMetaType(QMetaType::QVariantHash))
<< QVariant()
;

View File

@ -881,7 +881,7 @@ void tst_QItemDelegate::dateAndTimeEditorTest2()
QCOMPARE(w.fastEdit(i1), timeEdit.data());
timeEdit->setTime(time1);
d->setModelData(timeEdit, &s, i1);
QCOMPARE(s.data(i1).type(), QVariant::Time); // ensure that we wrote a time variant.
QCOMPARE(s.data(i1).metaType().id(), QMetaType::QTime); // ensure that we wrote a time variant.
QCOMPARE(s.data(i1).toTime(), time1); // ensure that it is the correct time.
w.doCloseEditor(timeEdit);
QVERIFY(d->currentEditor() == 0); // should happen at doCloseEditor. We only test this once.
@ -910,7 +910,7 @@ void tst_QItemDelegate::dateAndTimeEditorTest2()
QCOMPARE(dateTimeEdit->dateTime(), datetime2);
dateTimeEdit->setDateTime(datetime1);
d->setModelData(dateTimeEdit, &s, i1);
QCOMPARE(s.data(i1).type(), QVariant::DateTime); // ensure that we wrote a datetime variant.
QCOMPARE(s.data(i1).metaType().id(), QMetaType::QDateTime); // ensure that we wrote a datetime variant.
QCOMPARE(s.data(i1).toDateTime(), datetime1);
w.doCloseEditor(dateTimeEdit);
@ -921,7 +921,7 @@ void tst_QItemDelegate::dateAndTimeEditorTest2()
QCOMPARE(w.fastEdit(i2), dateEdit.data());
dateEdit->setDate(date1);
d->setModelData(dateEdit, &s, i2);
QCOMPARE(s.data(i2).type(), QVariant::Date); // ensure that we wrote a time variant.
QCOMPARE(s.data(i2).metaType().id(), QMetaType::QDate); // ensure that we wrote a time variant.
QCOMPARE(s.data(i2).toDate(), date1); // ensure that it is the correct date.
w.doCloseEditor(dateEdit);
@ -1002,30 +1002,30 @@ void tst_QItemDelegate::decoration_data()
int pm = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
QTest::newRow("pixmap 30x30")
<< (int)QVariant::Pixmap
<< (int)QMetaType::QPixmap
<< QSize(30, 30)
<< QSize(30, 30);
QTest::newRow("image 30x30")
<< (int)QVariant::Image
<< (int)QMetaType::QImage
<< QSize(30, 30)
<< QSize(30, 30);
//The default engine scales pixmaps down if required, but never up. For WinCE we need bigger IconSize than 30
QTest::newRow("icon 30x30")
<< (int)QVariant::Icon
<< (int)QMetaType::QIcon
<< QSize(60, 60)
<< QSize(pm, pm);
QTest::newRow("color 30x30")
<< (int)QVariant::Color
<< (int)QMetaType::QColor
<< QSize(30, 30)
<< QSize(pm, pm);
// This demands too much memory and potentially hangs. Feel free to uncomment
// for your own testing.
// QTest::newRow("pixmap 30x30 big")
// << (int)QVariant::Pixmap
// << (int)QMetaType::QPixmap
// << QSize(1024, 1024) // Over 1M
// << QSize(1024, 1024);
}
@ -1049,26 +1049,26 @@ void tst_QItemDelegate::decoration()
QVERIFY(QTest::qWaitForWindowActive(&table));
QVariant value;
switch ((QVariant::Type)type) {
case QVariant::Pixmap: {
switch (type) {
case QMetaType::QPixmap: {
QPixmap pm(size);
pm.fill(Qt::black);
value = pm;
break;
}
case QVariant::Image: {
case QMetaType::QImage: {
QImage img(size, QImage::Format_Mono);
memset(img.bits(), 0, img.sizeInBytes());
value = img;
break;
}
case QVariant::Icon: {
case QMetaType::QIcon: {
QPixmap pm(size);
pm.fill(Qt::black);
value = QIcon(pm);
break;
}
case QVariant::Color:
case QMetaType::QColor:
value = QColor(Qt::green);
break;
default:

View File

@ -46,7 +46,7 @@ void tst_QItemEditorFactory::createEditor()
QWidget parent;
QWidget *w = factory->createEditor(QVariant::String, &parent);
QWidget *w = factory->createEditor(QMetaType::QString, &parent);
QCOMPARE(w->metaObject()->className(), "QExpandingLineEdit");
}
@ -63,23 +63,23 @@ void tst_QItemEditorFactory::createCustomEditor()
{
QItemEditorFactory editorFactory;
editorFactory.registerEditor(QVariant::Rect, creator);
editorFactory.registerEditor(QVariant::RectF, creator);
editorFactory.registerEditor(QMetaType::QRect, creator);
editorFactory.registerEditor(QMetaType::QRectF, creator);
//creator should not be deleted as a result of calling the next line
editorFactory.registerEditor(QVariant::Rect, creator2);
editorFactory.registerEditor(QMetaType::QRect, creator2);
QVERIFY(creator);
//this should erase creator2
editorFactory.registerEditor(QVariant::Rect, creator);
editorFactory.registerEditor(QMetaType::QRect, creator);
QVERIFY(creator2.isNull());
QWidget parent;
QWidget *w = editorFactory.createEditor(QVariant::Rect, &parent);
QWidget *w = editorFactory.createEditor(QMetaType::QRect, &parent);
QCOMPARE(w->metaObject()->className(), "QDoubleSpinBox");
QCOMPARE(w->metaObject()->userProperty().type(), QVariant::Double);
QCOMPARE(w->metaObject()->userProperty().userType(), QMetaType::Double);
}
//editorFactory has been deleted, so should be creator
@ -99,12 +99,12 @@ void tst_QItemEditorFactory::uintValues()
{
QWidget *editor = editorFactory.createEditor(QMetaType::UInt, &parent);
QCOMPARE(editor->metaObject()->className(), "QUIntSpinBox");
QCOMPARE(editor->metaObject()->userProperty().type(), QVariant::UInt);
QCOMPARE(editor->metaObject()->userProperty().userType(), QMetaType::UInt);
}
{
QWidget *editor = editorFactory.createEditor(QMetaType::Int, &parent);
QCOMPARE(editor->metaObject()->className(), "QSpinBox");
QCOMPARE(editor->metaObject()->userProperty().type(), QVariant::Int);
QCOMPARE(editor->metaObject()->userProperty().userType(), QMetaType::Int);
}
}

View File

@ -1938,13 +1938,13 @@ void tst_QTreeWidget::setData()
// ### add more data types here
item->setData(0, Qt::DisplayRole, 5);
QCOMPARE(item->data(0, Qt::DisplayRole).type(), QVariant::Int);
QCOMPARE(item->data(0, Qt::DisplayRole).userType(), QMetaType::Int);
item->setData(0, Qt::DisplayRole, "test");
QCOMPARE(item->data(0, Qt::DisplayRole).type(), QVariant::String);
QCOMPARE(item->data(0, Qt::DisplayRole).userType(), QMetaType::QString);
item->setData(0, Qt::DisplayRole, 0.4);
QCOMPARE(item->data(0, Qt::DisplayRole).type(), QVariant::Double);
QCOMPARE(item->data(0, Qt::DisplayRole).userType(), QMetaType::Double);
delete item;
}

View File

@ -77,7 +77,7 @@ void tst_QWidgetsVariant::constructor_invalid()
QFETCH(uint, typeId);
{
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(static_cast<QVariant::Type>(typeId));
QVariant variant{QMetaType(typeId)};
QVERIFY(!variant.isValid());
QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
@ -218,7 +218,7 @@ void tst_QWidgetsVariant::debugStream_data()
const char *tagName = QMetaType(id).name();
if (!tagName)
continue;
QTest::newRow(tagName) << QVariant(static_cast<QVariant::Type>(id)) << id;
QTest::newRow(tagName) << QVariant(QMetaType(id)) << id;
}
}

View File

@ -4601,7 +4601,7 @@ void tst_QDateTimeEdit::stepModifierPressAndHold()
QTest::mouseRelease(&edit, Qt::LeftButton, modifiers, buttonRect.center());
const auto value = spy.last().at(0);
QVERIFY(value.type() == QVariant::Date);
QVERIFY(value.userType() == QMetaType::QDate);
const QDate expectedDate = startDate.addYears(spy.length() *
expectedStepModifier);
QCOMPARE(value.toDate(), expectedDate);

View File

@ -1790,7 +1790,7 @@ void tst_QDoubleSpinBox::stepModifierPressAndHold()
QTest::mouseRelease(&spin, Qt::LeftButton, modifiers, buttonRect.center());
const auto value = spy.last().at(0);
QVERIFY(value.type() == QVariant::Double);
QVERIFY(value.userType() == QMetaType::Double);
QCOMPARE(value.toDouble(), spy.length() * expectedStepModifier);
}

View File

@ -1739,7 +1739,7 @@ void tst_QPlainTextEdit::inputMethodCursorRect()
ed->moveCursor(QTextCursor::End);
const QRectF cursorRect = ed->cursorRect();
const QVariant cursorRectV = ed->inputMethodQuery(Qt::ImCursorRectangle);
QCOMPARE(cursorRectV.type(), QVariant::RectF);
QCOMPARE(cursorRectV.userType(), QMetaType::QRectF);
QCOMPARE(cursorRectV.toRect(), cursorRect.toRect());
}

View File

@ -163,12 +163,12 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
QVariant val = forwardEmissions.takeLast()[0];
QCOMPARE(val.type(), QVariant::Bool);
QCOMPARE(val.userType(), QMetaType::Bool);
QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
QCOMPARE(val.type(), QVariant::Bool);
QCOMPARE(val.userType(), QMetaType::Bool);
QVERIFY(!val.toBool());
QVERIFY(browser->historyTitle(-1).isEmpty());
@ -181,12 +181,12 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
QCOMPARE(val.type(), QVariant::Bool);
QCOMPARE(val.userType(), QMetaType::Bool);
QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
QCOMPARE(val.type(), QVariant::Bool);
QCOMPARE(val.userType(), QMetaType::Bool);
QVERIFY(val.toBool());
QCOMPARE(browser->historyTitle(-1), QString("Page With BG"));
@ -197,12 +197,12 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
QCOMPARE(val.type(), QVariant::Bool);
QCOMPARE(val.userType(), QMetaType::Bool);
QVERIFY(val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
QCOMPARE(val.type(), QVariant::Bool);
QCOMPARE(val.userType(), QMetaType::Bool);
QVERIFY(!val.toBool());
QVERIFY(browser->historyTitle(-1).isEmpty());
@ -213,12 +213,12 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
QCOMPARE(val.type(), QVariant::Bool);
QCOMPARE(val.userType(), QMetaType::Bool);
QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
QCOMPARE(val.type(), QVariant::Bool);
QCOMPARE(val.userType(), QMetaType::Bool);
QVERIFY(val.toBool());
}
@ -546,7 +546,7 @@ void tst_QTextBrowser::loadResourceOnRelativeLocalFiles()
QVERIFY(!browser->toPlainText().isEmpty());
QVariant v = browser->loadResource(QTextDocument::HtmlResource, QUrl("../anchor.html"));
QVERIFY(v.isValid());
QCOMPARE(v.type(), QVariant::ByteArray);
QCOMPARE(v.userType(), QMetaType::QByteArray);
QVERIFY(!v.toByteArray().isEmpty());
}

View File

@ -2545,7 +2545,7 @@ void tst_QTextEdit::inputMethodCursorRect()
ed->moveCursor(QTextCursor::End);
const QRectF cursorRect = ed->cursorRect();
const QVariant cursorRectV = ed->inputMethodQuery(Qt::ImCursorRectangle);
QCOMPARE(cursorRectV.type(), QVariant::RectF);
QCOMPARE(cursorRectV.userType(), QMetaType::QRectF);
QCOMPARE(cursorRectV.toRect(), cursorRect.toRect());
}