aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-20 01:00:27 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2020-01-20 07:04:47 +0000
commitb9519d9630d9192cb49b97c7c9fe30d43ab1ee4a (patch)
tree512b32a0e2dea84a89a01e89a1b7868f3c1c8a37 /src/qml/qml
parent0ced82a8cf8472a79b08db05d441caf778ac9131 (diff)
parente5f7c5f2712957d0e1753c629e4cce86a0e6bdbc (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/qml/qml/qqmlvaluetype.cpp tests/auto/qml/qml.pro Change-Id: I78f992f83212bb9fd5e09b64163f15f046185224
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/ftw/qhashedstring.cpp19
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h1
-rw-r--r--src/qml/qml/qqmlbinding.cpp2
-rw-r--r--src/qml/qml/qqmlengine.cpp2
-rw-r--r--src/qml/qml/qqmlfile.cpp2
-rw-r--r--src/qml/qml/qqmllist.cpp132
-rw-r--r--src/qml/qml/qqmllist.h129
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp82
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp48
-rw-r--r--src/qml/qml/qqmlproperty.cpp42
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp8
-rw-r--r--src/qml/qml/qqmlpropertycachecreator_p.h4
-rw-r--r--src/qml/qml/qqmlpropertyvalidator.cpp48
-rw-r--r--src/qml/qml/qqmltypeloader.cpp4
-rw-r--r--src/qml/qml/qqmlvaluetype.cpp39
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h11
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp2
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp14
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp2
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp26
20 files changed, 456 insertions, 161 deletions
diff --git a/src/qml/qml/ftw/qhashedstring.cpp b/src/qml/qml/ftw/qhashedstring.cpp
index bbe374044d..4553fa9359 100644
--- a/src/qml/qml/ftw/qhashedstring.cpp
+++ b/src/qml/qml/ftw/qhashedstring.cpp
@@ -102,6 +102,25 @@ QHashedStringRef QHashedStringRef::mid(int offset, int length) const
(length == -1 || (offset + length) > m_length)?(m_length - offset):length);
}
+QVector<QHashedStringRef> QHashedStringRef::split(const QChar sep) const
+{
+ QVector<QHashedStringRef> ret;
+ auto curLength = 0;
+ auto curOffset = m_data;
+ for (int offset = 0; offset < m_length; ++offset) {
+ if (*(m_data + offset) == sep) {
+ ret.push_back({curOffset, curLength});
+ curOffset = m_data + offset + 1;
+ curLength = 0;
+ } else {
+ ++curLength;
+ }
+ }
+ if (curLength > 0)
+ ret.push_back({curOffset, curLength});
+ return ret;
+}
+
bool QHashedStringRef::endsWith(const QString &s) const
{
return s.length() < m_length &&
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
index b9f3f81219..a2e10ff143 100644
--- a/src/qml/qml/ftw/qhashedstring_p.h
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -125,6 +125,7 @@ public:
bool endsWith(const QString &) const;
int indexOf(const QChar &, int from=0) const;
QHashedStringRef mid(int, int) const;
+ QVector<QHashedStringRef> split(const QChar sep) const;
inline bool isEmpty() const;
inline int length() const;
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 162adf8364..e14b00af22 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -479,7 +479,7 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core,
if (!propertyMetaObject.isNull())
propertyType = propertyMetaObject.className();
}
- } else if (userType != QVariant::Invalid) {
+ } else if (userType != QMetaType::UnknownType) {
if (userType == QMetaType::Nullptr || userType == QMetaType::VoidStar)
valueType = "null";
else
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 6cdb012e26..9b6f83f144 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -101,8 +101,6 @@
# endif
#endif // Q_OS_WIN
-Q_DECLARE_METATYPE(QQmlProperty)
-
QT_BEGIN_NAMESPACE
// Declared in qqml.h
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp
index 465a342129..ee54359d0f 100644
--- a/src/qml/qml/qqmlfile.cpp
+++ b/src/qml/qml/qqmlfile.cpp
@@ -187,7 +187,7 @@ void QQmlFileNetworkReply::networkFinished()
}
}
- if (m_reply->error()) {
+ if (m_reply->networkError()) {
m_p->errorString = m_reply->errorString();
m_p->error = QQmlFilePrivate::Network;
} else {
diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp
index 5425bf498c..b504fdf22d 100644
--- a/src/qml/qml/qqmllist.cpp
+++ b/src/qml/qml/qqmllist.cpp
@@ -250,10 +250,37 @@ bool QQmlListReference::canCount() const
}
/*!
- Return true if at(), count(), append() and clear() are implemented, so you can manipulate
- the list.
+Returns true if items in the list property can be replaced, otherwise false.
+Returns false if the reference is invalid.
+
+\sa replace()
+*/
+bool QQmlListReference::canReplace() const
+{
+ return (isValid() && d->property.replace);
+}
+
+/*!
+Returns true if the last item can be removed from the list property, otherwise false.
+Returns false if the reference is invalid.
+
+\sa removeLast()
+*/
+bool QQmlListReference::canRemoveLast() const
+{
+ return (isValid() && d->property.removeLast);
+}
+
+/*!
+ Return true if at(), count(), append(), and either clear() or removeLast()
+ are implemented, so you can manipulate the list.
+
+ Mind that replace() and removeLast() can be emulated by stashing all
+ items and rebuilding the list using clear() and append(). Therefore,
+ they are not required for the list to be manipulable. Furthermore,
+ clear() can be emulated using removeLast().
-\sa isReadable(), at(), count(), append(), clear()
+\sa isReadable(), at(), count(), append(), clear(), replace(), removeLast()
*/
bool QQmlListReference::isManipulable() const
{
@@ -329,6 +356,39 @@ int QQmlListReference::count() const
}
/*!
+Replaces the item at \a index in the list with \a object.
+Returns true if the operation succeeded, otherwise false.
+
+\sa canReplace()
+*/
+bool QQmlListReference::replace(int index, QObject *object) const
+{
+ if (!canReplace())
+ return false;
+
+ if (object && !QQmlMetaObject::canConvert(object, d->elementType))
+ return false;
+
+ d->property.replace(&d->property, index, object);
+ return true;
+}
+
+/*!
+Removes the last item in the list.
+Returns true if the operation succeeded, otherwise false.
+
+\sa canRemoveLast()
+*/
+bool QQmlListReference::removeLast() const
+{
+ if (!canRemoveLast())
+ return false;
+
+ d->property.removeLast(&d->property);
+ return true;
+}
+
+/*!
\class QQmlListProperty
\since 5.0
\inmodule QtQml
@@ -375,14 +435,25 @@ QML list properties are type-safe - in this case \c {Fruit} is a QObject type th
/*!
\fn template<typename T> QQmlListProperty<T>::QQmlListProperty(QObject *object, QList<T *> &list)
+\deprecated
Convenience constructor for making a QQmlListProperty value from an existing
QList \a list. The \a list reference must remain valid for as long as \a object
exists. \a object must be provided.
-Generally this constructor should not be used in production code, as a
-writable QList violates QML's memory management rules. However, this constructor
-can be very useful while prototyping.
+This constructor synthesizes the removeLast() and replace() methods
+introduced in Qt 5.15, using count(), at(), clear(), and append(). This is slow.
+If you intend to manipulate the list beyond clearing it, you should explicitly
+provide these methods.
+*/
+
+/*!
+\fn template<typename T> QQmlListProperty<T>::QQmlListProperty(QObject *object, QList<T *> *list)
+\since 5.15
+
+Convenience constructor for making a QQmlListProperty value from an existing
+QList \a list. The \a list reference must remain valid for as long as \a object
+exists. \a object must be provided.
*/
/*!
@@ -408,6 +479,39 @@ remains valid while \a object exists.
Null pointers can be passed for any function. If any null pointers are passed in, the list
will be neither designable nor alterable by the debugger. It is recommended to provide valid
pointers for all functions.
+
+\note The resulting QQmlListProperty will synthesize the removeLast() and
+replace() methods using \a count, \a at, \a clear, and \a append if all of those
+are given. This is slow. If you intend to manipulate the list beyond clearing it,
+you should explicitly provide these methods.
+*/
+
+/*!
+\fn template<typename T> QQmlListProperty<T>::QQmlListProperty(
+ QObject *object, void *data, AppendFunction append, CountFunction count,
+ AtFunction at, ClearFunction clear, ReplaceFunction replace,
+ RemoveLastFunction removeLast)
+
+Construct a QQmlListProperty from a set of operation functions \a append,
+\a count, \a at, \a clear, \a replace, and \removeLast. An opaque \a data handle
+may be passed which can be accessed from within the operation functions. The
+list property remains valid while \a object exists.
+
+Null pointers can be passed for any function, causing the respective function to
+be synthesized using the others, if possible. QQmlListProperty can synthesize
+\list
+ \li \a clear using \a count and \a removeLast
+ \li \a replace using \a count, \a at, \a clear, and \a append
+ \li \a replace using \a count, \a at, \a removeLast, and \a append
+ \li \a removeLast using \a count, \a at, \a clear, and \a append
+\endlist
+if those are given. This is slow, but if your list does not natively provide
+faster options for these primitives, you may want to use the synthesized ones.
+
+Furthermore, if either of \a count, \a at, \a append, and \a clear are neither
+given explicitly nor synthesized, the list will be neither designable nor
+alterable by the debugger. It is recommended to provide enough valid pointers
+to avoid this situation.
*/
/*!
@@ -448,4 +552,20 @@ Synonym for \c {void (*)(QQmlListProperty<T> *property)}.
Clear the list \a property.
*/
+/*!
+\typedef QQmlListProperty::ReplaceFunction
+
+Synonym for \c {void (*)(QQmlListProperty<T> *property, int index, T *value)}.
+
+Replace the element at position \a index in the list \a property with \a value.
+*/
+
+/*!
+\typedef QQmlListProperty::RemoveLastFunction
+
+Synonym for \c {void (*)(QQmlListProperty<T> *property)}.
+
+Remove the last element from the list \a property.
+*/
+
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h
index 90ec57c911..17333ca9e4 100644
--- a/src/qml/qml/qqmllist.h
+++ b/src/qml/qml/qqmllist.h
@@ -55,22 +55,28 @@ struct QMetaObject;
template<typename T>
class QQmlListProperty {
public:
- typedef void (*AppendFunction)(QQmlListProperty<T> *, T*);
- typedef int (*CountFunction)(QQmlListProperty<T> *);
- typedef T *(*AtFunction)(QQmlListProperty<T> *, int);
- typedef void (*ClearFunction)(QQmlListProperty<T> *);
-
- QQmlListProperty()
- : append(nullptr),
- count(nullptr),
- at(nullptr),
- clear(nullptr)
- {}
+ using AppendFunction = void (*)(QQmlListProperty<T> *, T *);
+ using CountFunction = int (*)(QQmlListProperty<T> *);
+ using AtFunction = T *(*)(QQmlListProperty<T> *, int);
+ using ClearFunction = void (*)(QQmlListProperty<T> *);
+ using ReplaceFunction = void (*)(QQmlListProperty<T> *, int, T *);
+ using RemoveLastFunction = void (*)(QQmlListProperty<T> *);
+
+ QQmlListProperty() = default;
+
+#if QT_DEPRECATED_SINCE(5,15)
+ QT_DEPRECATED_X("Use constructor taking QList pointer, and gain improved performance")
QQmlListProperty(QObject *o, QList<T *> &list)
: object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at),
- clear(qlist_clear)
+ clear(qlist_clear), replace(qslow_replace), removeLast(qslow_removeLast)
+ {}
+#endif
+ QQmlListProperty(QObject *o, QList<T *> *list)
+ : object(o), data(list), append(qlist_append), count(qlist_count), at(qlist_at),
+ clear(qlist_clear), replace(qlist_replace), removeLast(qlist_removeLast)
{}
+
QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t,
ClearFunction r )
: object(o),
@@ -78,37 +84,47 @@ public:
append(a),
count(c),
at(t),
- clear(r)
-
+ clear(r),
+ replace((a && c && t && r) ? qslow_replace : nullptr),
+ removeLast((a && c && t && r) ? qslow_removeLast : nullptr)
{}
- QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction t)
+
+ QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t,
+ ClearFunction r, ReplaceFunction s, RemoveLastFunction p)
: object(o),
data(d),
- append(nullptr),
- count(c), at(t),
- clear(nullptr)
+ append(a),
+ count(c),
+ at(t),
+ clear((!r && p && c) ? qslow_clear : r),
+ replace((!s && a && c && t && (r || p)) ? qslow_replace : s),
+ removeLast((!p && a && c && t && r) ? qslow_removeLast : p)
+ {}
+
+ QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction a)
+ : object(o), data(d), count(c), at(a)
{}
+
bool operator==(const QQmlListProperty &o) const {
return object == o.object &&
data == o.data &&
append == o.append &&
count == o.count &&
at == o.at &&
- clear == o.clear;
+ clear == o.clear &&
+ replace == o.replace &&
+ removeLast == o.removeLast;
}
QObject *object = nullptr;
void *data = nullptr;
- AppendFunction append;
-
- CountFunction count;
- AtFunction at;
-
- ClearFunction clear;
-
- void *dummy1 = nullptr;
- void *dummy2 = nullptr;
+ AppendFunction append = nullptr;
+ CountFunction count = nullptr;
+ AtFunction at = nullptr;
+ ClearFunction clear = nullptr;
+ ReplaceFunction replace = nullptr;
+ RemoveLastFunction removeLast = nullptr;
private:
static void qlist_append(QQmlListProperty *p, T *v) {
@@ -123,6 +139,59 @@ private:
static void qlist_clear(QQmlListProperty *p) {
return reinterpret_cast<QList<T *> *>(p->data)->clear();
}
+ static void qlist_replace(QQmlListProperty *p, int idx, T *v) {
+ return reinterpret_cast<QList<T *> *>(p->data)->replace(idx, v);
+ }
+ static void qlist_removeLast(QQmlListProperty *p) {
+ return reinterpret_cast<QList<T *> *>(p->data)->removeLast();
+ }
+
+ static void qslow_replace(QQmlListProperty<T> *list, int idx, T *v)
+ {
+ const int length = list->count(list);
+ if (idx < 0 || idx >= length)
+ return;
+
+ QVector<T *> stash;
+ if (list->clear != qslow_clear) {
+ stash.reserve(length);
+ for (int i = 0; i < length; ++i)
+ stash.append(i == idx ? v : list->at(list, i));
+ list->clear(list);
+ for (T *item : qAsConst(stash))
+ list->append(list, item);
+ } else {
+ stash.reserve(length - idx - 1);
+ for (int i = length - 1; i > idx; --i) {
+ stash.append(list->at(list, i));
+ list->removeLast(list);
+ }
+ list->removeLast(list);
+ list->append(list, v);
+ while (!stash.isEmpty())
+ list->append(list, stash.takeLast());
+ }
+ }
+
+ static void qslow_clear(QQmlListProperty<T> *list)
+ {
+ for (int i = 0, end = list->count(list); i < end; ++i)
+ list->removeLast(list);
+ }
+
+ static void qslow_removeLast(QQmlListProperty<T> *list)
+ {
+ const int length = list->count(list) - 1;
+ if (length < 0)
+ return;
+ QVector<T *> stash;
+ stash.reserve(length);
+ for (int i = 0; i < length; ++i)
+ stash.append(list->at(list, i));
+ list->clear(list);
+ for (T *item : qAsConst(stash))
+ list->append(list, item);
+ }
};
#endif
@@ -146,6 +215,8 @@ public:
bool canAt() const;
bool canClear() const;
bool canCount() const;
+ bool canReplace() const;
+ bool canRemoveLast() const;
bool isManipulable() const;
bool isReadable() const;
@@ -154,6 +225,8 @@ public:
QObject *at(int) const;
bool clear() const;
int count() const;
+ bool replace(int, QObject *) const;
+ bool removeLast() const;
private:
friend class QQmlListReferencePrivate;
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 5349572921..e5c1cb04a9 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -119,11 +119,13 @@ ReturnedValue QmlListWrapper::virtualGet(const Managed *m, PropertyKey id, const
if (hasProperty)
*hasProperty = false;
return Value::undefinedValue().asReturnedValue();
- } else if (id.isString()) {
- if (id == v4->id_length()->propertyKey() && !w->d()->object.isNull()) {
- quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
- return Value::fromUInt32(count).asReturnedValue();
- }
+ }
+
+ if (id.isString() && id == v4->id_length()->propertyKey()) {
+ if (hasProperty)
+ *hasProperty = true;
+ quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
+ return Value::fromUInt32(count).asReturnedValue();
}
return Object::virtualGet(m, id, receiver, hasProperty);
@@ -131,12 +133,70 @@ ReturnedValue QmlListWrapper::virtualGet(const Managed *m, PropertyKey id, const
bool QmlListWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
- // doesn't do anything. Should we throw?
- Q_UNUSED(m);
- Q_UNUSED(id);
- Q_UNUSED(value);
- Q_UNUSED(receiver);
- return false;
+ Q_ASSERT(m->as<QmlListWrapper>());
+
+ const auto *w = static_cast<const QmlListWrapper *>(m);
+ QV4::ExecutionEngine *v4 = w->engine();
+
+ QQmlListProperty<QObject> *prop = &(w->d()->property());
+
+ if (id.isArrayIndex()) {
+ if (!prop->count || !prop->replace)
+ return false;
+
+ const uint index = id.asArrayIndex();
+ const int count = prop->count(prop);
+ if (count < 0 || index >= uint(count))
+ return false;
+
+ QV4::Scope scope(v4);
+ QV4::ScopedObject so(scope, value.toObject(scope.engine));
+ if (auto *wrapper = so->as<QV4::QObjectWrapper>()) {
+ prop->replace(prop, index, wrapper->object());
+ return true;
+ }
+
+ return false;
+ }
+
+ if (id.isString() && id == v4->id_length()->propertyKey()) {
+ if (!prop->count)
+ return false;
+
+ const quint32 count = prop->count(prop);
+
+ bool ok = false;
+ const uint newLength = value.asArrayLength(&ok);
+ if (!ok)
+ return false;
+
+ if (newLength == 0) {
+ if (!prop->clear)
+ return false;
+ prop->clear(prop);
+ return true;
+ }
+
+ if (newLength < count) {
+ if (!prop->removeLast)
+ return false;
+
+ for (uint i = newLength; i < count; ++i)
+ prop->removeLast(prop);
+
+ return true;
+ }
+
+ if (!prop->append)
+ return false;
+
+ for (uint i = count; i < newLength; ++i)
+ prop->append(prop, nullptr);
+
+ return true;
+ }
+
+ return Object::virtualPut(m, id, value, receiver);
}
struct QmlListWrapperOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index d68ad69260..78df02554c 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -414,25 +414,25 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
}
break;
- case QVariant::String: {
+ case QMetaType::QString: {
assertOrNull(binding->evaluatesToString());
QString value = compilationUnit->bindingValueAsString(binding);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::StringList: {
+ case QMetaType::QStringList: {
assertOrNull(binding->evaluatesToString());
QStringList value(compilationUnit->bindingValueAsString(binding));
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
assertType(QV4::CompiledData::Binding::Type_String);
QByteArray value(compilationUnit->bindingValueAsString(binding).toUtf8());
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::Url: {
+ case QMetaType::QUrl: {
assertType(QV4::CompiledData::Binding::Type_String);
QString string = compilationUnit->bindingValueAsString(binding);
// Encoded dir-separators defeat QUrl processing - decode them first
@@ -444,7 +444,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::UInt: {
+ case QMetaType::UInt: {
assertType(QV4::CompiledData::Binding::Type_Number);
double d = compilationUnit->bindingValueAsNumber(binding);
uint value = uint(d);
@@ -452,7 +452,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
break;
}
break;
- case QVariant::Int: {
+ case QMetaType::Int: {
assertType(QV4::CompiledData::Binding::Type_Number);
double d = compilationUnit->bindingValueAsNumber(binding);
int value = int(d);
@@ -466,13 +466,13 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::Double: {
+ case QMetaType::Double: {
assertType(QV4::CompiledData::Binding::Type_Number);
double value = compilationUnit->bindingValueAsNumber(binding);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::Color: {
+ case QMetaType::QColor: {
bool ok = false;
uint colorValue = QQmlStringConverters::rgbaFromString(compilationUnit->bindingValueAsString(binding), &ok);
assertOrNull(ok);
@@ -483,21 +483,21 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
break;
#if QT_CONFIG(datestring)
- case QVariant::Date: {
+ case QMetaType::QDate: {
bool ok = false;
QDate value = QQmlStringConverters::dateFromString(compilationUnit->bindingValueAsString(binding), &ok);
assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::Time: {
+ case QMetaType::QTime: {
bool ok = false;
QTime value = QQmlStringConverters::timeFromString(compilationUnit->bindingValueAsString(binding), &ok);
assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
bool ok = false;
QDateTime value = QQmlStringConverters::dateTimeFromString(compilationUnit->bindingValueAsString(binding), &ok);
// ### VME compatibility :(
@@ -511,55 +511,55 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
break;
#endif // datestring
- case QVariant::Point: {
+ case QMetaType::QPoint: {
bool ok = false;
QPoint value = QQmlStringConverters::pointFFromString(compilationUnit->bindingValueAsString(binding), &ok).toPoint();
assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::PointF: {
+ case QMetaType::QPointF: {
bool ok = false;
QPointF value = QQmlStringConverters::pointFFromString(compilationUnit->bindingValueAsString(binding), &ok);
assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::Size: {
+ case QMetaType::QSize: {
bool ok = false;
QSize value = QQmlStringConverters::sizeFFromString(compilationUnit->bindingValueAsString(binding), &ok).toSize();
assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::SizeF: {
+ case QMetaType::QSizeF: {
bool ok = false;
QSizeF value = QQmlStringConverters::sizeFFromString(compilationUnit->bindingValueAsString(binding), &ok);
assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::Rect: {
+ case QMetaType::QRect: {
bool ok = false;
QRect value = QQmlStringConverters::rectFFromString(compilationUnit->bindingValueAsString(binding), &ok).toRect();
assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::RectF: {
+ case QMetaType::QRectF: {
bool ok = false;
QRectF value = QQmlStringConverters::rectFFromString(compilationUnit->bindingValueAsString(binding), &ok);
assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::Bool: {
+ case QMetaType::Bool: {
assertType(QV4::CompiledData::Binding::Type_Boolean);
bool value = binding->valueAsBoolean();
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QVariant::Vector2D: {
+ case QMetaType::QVector2D: {
struct {
float xp;
float yp;
@@ -570,7 +570,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &vec, propertyWriteFlags);
}
break;
- case QVariant::Vector3D: {
+ case QMetaType::QVector3D: {
struct {
float xp;
float yp;
@@ -582,7 +582,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &vec, propertyWriteFlags);
}
break;
- case QVariant::Vector4D: {
+ case QMetaType::QVector4D: {
struct {
float xp;
float yp;
@@ -595,7 +595,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &vec, propertyWriteFlags);
}
break;
- case QVariant::Quaternion: {
+ case QMetaType::QQuaternion: {
struct {
float wp;
float xp;
@@ -608,7 +608,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &vec, propertyWriteFlags);
}
break;
- case QVariant::RegExp:
+ case QMetaType::QRegExp:
assertOrNull(!"not possible");
break;
default: {
@@ -673,7 +673,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
QVariant value = (*converter)(stringValue);
QMetaProperty metaProperty = _qobject->metaObject()->property(property->coreIndex());
- if (value.isNull() || ((int)metaProperty.type() != property->propType() && metaProperty.userType() != property->propType())) {
+ if (value.isNull() || metaProperty.userType() != property->propType()) {
recordError(binding->location, tr("Cannot assign value %1 to property %2").arg(stringValue).arg(QString::fromUtf8(metaProperty.name())));
break;
}
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index 871bec1c17..93020661e2 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -471,7 +471,7 @@ QQmlPropertyPrivate::propertyTypeCategory() const
return QQmlProperty::Normal;
} else if (type & QQmlProperty::Property) {
int type = propertyType();
- if (type == QVariant::Invalid)
+ if (type == QMetaType::UnknownType)
return QQmlProperty::InvalidCategory;
else if (QQmlValueTypeFactory::isValueType((uint)type))
return QQmlProperty::Normal;
@@ -526,7 +526,7 @@ bool QQmlProperty::operator==(const QQmlProperty &other) const
*/
int QQmlProperty::propertyType() const
{
- return d ? d->propertyType() : int(QVariant::Invalid);
+ return d ? d->propertyType() : int(QMetaType::UnknownType);
}
bool QQmlPropertyPrivate::isValueType() const
@@ -542,7 +542,7 @@ int QQmlPropertyPrivate::propertyType() const
} else if (type & QQmlProperty::Property) {
return core.propType();
} else {
- return QVariant::Invalid;
+ return QMetaType::UnknownType;
}
}
@@ -1133,7 +1133,7 @@ bool QQmlPropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx,
QVariant v = value;
if (prop.isEnumType()) {
QMetaEnum menum = prop.enumerator();
- if (v.userType() == QVariant::String
+ if (v.userType() == QMetaType::QString
#ifdef QT3_SUPPORT
|| v.userType() == QVariant::CString
#endif
@@ -1145,13 +1145,13 @@ bool QQmlPropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx,
v = QVariant(menum.keyToValue(value.toByteArray(), &ok));
if (!ok)
return false;
- } else if (v.userType() != QVariant::Int && v.userType() != QVariant::UInt) {
+ } else if (v.userType() != QMetaType::Int && v.userType() != QMetaType::UInt) {
int enumMetaTypeId = QMetaType::type(QByteArray(menum.scope() + QByteArray("::") + menum.name()));
if ((enumMetaTypeId == QMetaType::UnknownType) || (v.userType() != enumMetaTypeId) || !v.constData())
return false;
v = QVariant(*reinterpret_cast<const int *>(v.constData()));
}
- v.convert(QVariant::Int);
+ v.convert(QMetaType::Int);
}
// the status variable is changed by qt_metacall to indicate what it did
@@ -1206,17 +1206,17 @@ bool QQmlPropertyPrivate::write(QObject *object,
QMetaProperty prop = object->metaObject()->property(property.coreIndex());
QVariant v = value;
// Enum values come through the script engine as doubles
- if (variantType == QVariant::Double) {
+ if (variantType == QMetaType::Double) {
double integral;
double fractional = std::modf(value.toDouble(), &integral);
if (qFuzzyIsNull(fractional))
- v.convert(QVariant::Int);
+ v.convert(QMetaType::Int);
}
return writeEnumProperty(prop, property.coreIndex(), object, v, flags);
}
QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(context);
- const bool isUrl = propertyType == QVariant::Url; // handled separately
+ const bool isUrl = propertyType == QMetaType::QUrl; // handled separately
// The cases below are in approximate order of likelyhood:
if (propertyType == variantType && !isUrl && propertyType != qMetaTypeId<QList<QUrl>>() && !property.isQList()) {
@@ -1249,7 +1249,7 @@ bool QQmlPropertyPrivate::write(QObject *object,
} else {
return false;
}
- } else if (value.canConvert(propertyType) && !isUrl && variantType != QVariant::String && propertyType != qMetaTypeId<QList<QUrl>>() && !property.isQList()) {
+ } else if (value.canConvert(propertyType) && !isUrl && variantType != QMetaType::QString && propertyType != qMetaTypeId<QList<QUrl>>() && !property.isQList()) {
// common cases:
switch (propertyType) {
case QMetaType::Bool: {
@@ -1282,14 +1282,14 @@ bool QQmlPropertyPrivate::write(QObject *object,
return property.writeProperty(object, const_cast<QVariant *>(&value), flags);
} else if (isUrl) {
QUrl u;
- if (variantType == QVariant::Url) {
+ if (variantType == QMetaType::QUrl) {
u = value.toUrl();
- } else if (variantType == QVariant::ByteArray) {
+ } else if (variantType == QMetaType::QByteArray) {
QString input(QString::fromUtf8(value.toByteArray()));
// Encoded dir-separators defeat QUrl processing - decode them first
input.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive);
u = QUrl(input);
- } else if (variantType == QVariant::String) {
+ } else if (variantType == QMetaType::QString) {
QString input(value.toString());
// Encoded dir-separators defeat QUrl processing - decode them first
input.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive);
@@ -1355,7 +1355,7 @@ bool QQmlPropertyPrivate::write(QObject *object,
bool ok = false;
QVariant v;
- if (variantType == QVariant::String)
+ if (variantType == QMetaType::QString)
v = QQmlStringConverters::variantFromString(value.toString(), propertyType, &ok);
if (!ok) {
@@ -1368,8 +1368,8 @@ bool QQmlPropertyPrivate::write(QObject *object,
// successful conversion.
Q_ASSERT(v.userType() == propertyType);
ok = true;
- } else if (static_cast<uint>(propertyType) >= QVariant::UserType &&
- variantType == QVariant::String) {
+ } else if (static_cast<uint>(propertyType) >= QMetaType::User &&
+ variantType == QMetaType::QString) {
QQmlMetaType::StringConverter con = QQmlMetaType::customStringConverter(propertyType);
if (con) {
v = con(value.toString());
@@ -1383,28 +1383,28 @@ bool QQmlPropertyPrivate::write(QObject *object,
// to a sequence type property (eg, an int to a QList<int> property).
// or that we encountered an interface type
// Note that we've already handled single-value assignment to QList<QUrl> properties.
- if (variantType == QVariant::Int && propertyType == qMetaTypeId<QList<int> >()) {
+ if (variantType == QMetaType::Int && propertyType == qMetaTypeId<QList<int> >()) {
QList<int> list;
list << value.toInt();
v = QVariant::fromValue<QList<int> >(list);
ok = true;
- } else if ((variantType == QVariant::Double || variantType == QVariant::Int)
+ } else if ((variantType == QMetaType::Double || variantType == QMetaType::Int)
&& (propertyType == qMetaTypeId<QList<qreal> >())) {
QList<qreal> list;
list << value.toReal();
v = QVariant::fromValue<QList<qreal> >(list);
ok = true;
- } else if (variantType == QVariant::Bool && propertyType == qMetaTypeId<QList<bool> >()) {
+ } else if (variantType == QMetaType::Bool && propertyType == qMetaTypeId<QList<bool> >()) {
QList<bool> list;
list << value.toBool();
v = QVariant::fromValue<QList<bool> >(list);
ok = true;
- } else if (variantType == QVariant::String && propertyType == qMetaTypeId<QList<QString> >()) {
+ } else if (variantType == QMetaType::QString && propertyType == qMetaTypeId<QList<QString> >()) {
QList<QString> list;
list << value.toString();
v = QVariant::fromValue<QList<QString> >(list);
ok = true;
- } else if (variantType == QVariant::String && propertyType == qMetaTypeId<QStringList>()) {
+ } else if (variantType == QMetaType::QString && propertyType == qMetaTypeId<QStringList>()) {
QStringList list;
list << value.toString();
v = QVariant::fromValue<QStringList>(list);
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 6336ff28b3..71a8a255a9 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -92,7 +92,7 @@ static void flagsForPropertyType(int propType, QQmlPropertyData::Flags &flags)
flags.type = QQmlPropertyData::Flags::QObjectDerivedType;
} else if (propType == QMetaType::QVariant) {
flags.type = QQmlPropertyData::Flags::QVariantType;
- } else if (propType < static_cast<int>(QVariant::UserType)) {
+ } else if (propType < static_cast<int>(QMetaType::User)) {
// nothing to do
} else if (propType == qMetaTypeId<QQmlBinding *>()) {
flags.type = QQmlPropertyData::Flags::QmlBindingType;
@@ -136,14 +136,14 @@ static void populate(QQmlPropertyData *data, const QMetaProperty &p)
void QQmlPropertyData::lazyLoad(const QMetaProperty &p)
{
populate(this, p);
- int type = static_cast<int>(p.type());
+ int type = static_cast<int>(p.userType());
if (type == QMetaType::QObjectStar) {
setPropType(type);
m_flags.type = Flags::QObjectDerivedType;
} else if (type == QMetaType::QVariant) {
setPropType(type);
m_flags.type = Flags::QVariantType;
- } else if (type == QVariant::UserType || type == -1) {
+ } else if (type >= QMetaType::User || type == 0) {
m_flags.notFullyResolved = true;
} else {
setPropType(type);
@@ -314,7 +314,7 @@ void QQmlPropertyCache::appendSignal(const QString &name, QQmlPropertyData::Flag
const QList<QByteArray> &names)
{
QQmlPropertyData data;
- data.setPropType(QVariant::Invalid);
+ data.setPropType(QMetaType::UnknownType);
data.setCoreIndex(coreIndex);
data.setFlags(flags);
data.setArguments(nullptr);
diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h
index 8571b0c9b3..1f636c8347 100644
--- a/src/qml/qml/qqmlpropertycachecreator_p.h
+++ b/src/qml/qml/qqmlpropertycachecreator_p.h
@@ -806,12 +806,12 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
if (valueTypeIndex != -1) {
const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(*type);
if (valueTypeMetaObject->property(valueTypeIndex).isEnumType())
- *type = QVariant::Int;
+ *type = QMetaType::Int;
else
*type = valueTypeMetaObject->property(valueTypeIndex).userType();
} else {
if (targetProperty->isEnum()) {
- *type = QVariant::Int;
+ *type = QMetaType::Int;
} else {
// Copy type flags
propertyFlags->copyPropertyTypeFlags(targetProperty->flags());
diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp
index 238a535b89..8f6e2737cc 100644
--- a/src/qml/qml/qqmlpropertyvalidator.cpp
+++ b/src/qml/qml/qqmlpropertyvalidator.cpp
@@ -398,31 +398,31 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
switch (property->propType()) {
case QMetaType::QVariant:
break;
- case QVariant::String: {
+ case QMetaType::QString: {
if (!binding->evaluatesToString()) {
return warnOrError(tr("Invalid property assignment: string expected"));
}
}
break;
- case QVariant::StringList: {
+ case QMetaType::QStringList: {
if (!binding->evaluatesToString()) {
return warnOrError(tr("Invalid property assignment: string or string list expected"));
}
}
break;
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
if (binding->type != QV4::CompiledData::Binding::Type_String) {
return warnOrError(tr("Invalid property assignment: byte array expected"));
}
}
break;
- case QVariant::Url: {
+ case QMetaType::QUrl: {
if (binding->type != QV4::CompiledData::Binding::Type_String) {
return warnOrError(tr("Invalid property assignment: url expected"));
}
}
break;
- case QVariant::UInt: {
+ case QMetaType::UInt: {
if (binding->type == QV4::CompiledData::Binding::Type_Number) {
double d = compilationUnit->bindingValueAsNumber(binding);
if (double(uint(d)) == d)
@@ -431,7 +431,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
return warnOrError(tr("Invalid property assignment: unsigned int expected"));
}
break;
- case QVariant::Int: {
+ case QMetaType::Int: {
if (binding->type == QV4::CompiledData::Binding::Type_Number) {
double d = compilationUnit->bindingValueAsNumber(binding);
if (double(int(d)) == d)
@@ -446,13 +446,13 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::Double: {
+ case QMetaType::Double: {
if (binding->type != QV4::CompiledData::Binding::Type_Number) {
return warnOrError(tr("Invalid property assignment: number expected"));
}
}
break;
- case QVariant::Color: {
+ case QMetaType::QColor: {
bool ok = false;
QQmlStringConverters::rgbaFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -461,7 +461,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
break;
#if QT_CONFIG(datestring)
- case QVariant::Date: {
+ case QMetaType::QDate: {
bool ok = false;
QQmlStringConverters::dateFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -469,7 +469,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::Time: {
+ case QMetaType::QTime: {
bool ok = false;
QQmlStringConverters::timeFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -477,7 +477,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
bool ok = false;
QQmlStringConverters::dateTimeFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -486,7 +486,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
break;
#endif // datestring
- case QVariant::Point: {
+ case QMetaType::QPoint: {
bool ok = false;
QQmlStringConverters::pointFFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -494,7 +494,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::PointF: {
+ case QMetaType::QPointF: {
bool ok = false;
QQmlStringConverters::pointFFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -502,7 +502,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::Size: {
+ case QMetaType::QSize: {
bool ok = false;
QQmlStringConverters::sizeFFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -510,7 +510,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::SizeF: {
+ case QMetaType::QSizeF: {
bool ok = false;
QQmlStringConverters::sizeFFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -518,7 +518,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::Rect: {
+ case QMetaType::QRect: {
bool ok = false;
QQmlStringConverters::rectFFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -526,7 +526,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::RectF: {
+ case QMetaType::QRectF: {
bool ok = false;
QQmlStringConverters::rectFFromString(compilationUnit->bindingValueAsString(binding), &ok);
if (!ok) {
@@ -534,13 +534,13 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::Bool: {
+ case QMetaType::Bool: {
if (binding->type != QV4::CompiledData::Binding::Type_Boolean) {
return warnOrError(tr("Invalid property assignment: boolean expected"));
}
}
break;
- case QVariant::Vector2D: {
+ case QMetaType::QVector2D: {
struct {
float xp;
float yp;
@@ -550,7 +550,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::Vector3D: {
+ case QMetaType::QVector3D: {
struct {
float xp;
float yp;
@@ -561,7 +561,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::Vector4D: {
+ case QMetaType::QVector4D: {
struct {
float xp;
float yp;
@@ -573,7 +573,7 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::Quaternion: {
+ case QMetaType::QQuaternion: {
struct {
float wp;
float xp;
@@ -585,8 +585,8 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
}
}
break;
- case QVariant::RegExp:
- case QVariant::RegularExpression:
+ case QMetaType::QRegExp:
+ case QMetaType::QRegularExpression:
return warnOrError(tr("Invalid property assignment: regular expression expected; use /pattern/ syntax"));
default: {
// generate single literal value assignment to a list property if required
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 2de158884b..e9a38945fa 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -357,8 +357,8 @@ void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply)
}
}
- if (reply->error()) {
- blob->networkError(reply->error());
+ if (reply->networkError()) {
+ blob->networkError(reply->networkError());
} else {
QByteArray data = reply->readAll();
setData(blob, data);
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp
index d83fc4bb48..4beb6a4d07 100644
--- a/src/qml/qml/qqmlvaluetype.cpp
+++ b/src/qml/qml/qqmlvaluetype.cpp
@@ -48,6 +48,8 @@
#endif
#include <private/qmetatype_p.h>
+Q_DECLARE_METATYPE(QQmlProperty)
+
QT_BEGIN_NAMESPACE
namespace {
@@ -62,7 +64,7 @@ struct QQmlValueTypeFactoryImpl
const QMetaObject *metaObjectForMetaType(int);
QQmlValueType *valueType(int);
- QQmlValueType *valueTypes[QVariant::UserType];
+ QQmlValueType *valueTypes[QMetaType::User];
QHash<int, QQmlValueType *> userTypes;
QMutex mutex;
@@ -71,7 +73,7 @@ struct QQmlValueTypeFactoryImpl
QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl()
{
- std::fill_n(valueTypes, int(QVariant::UserType), &invalidValueType);
+ std::fill_n(valueTypes, int(QMetaType::User), &invalidValueType);
#if QT_CONFIG(qml_itemmodel)
// See types wrapped in qqmlmodelindexvaluetype_p.h
@@ -118,26 +120,26 @@ bool QQmlValueTypeFactoryImpl::isValueType(int idx)
const QMetaObject *QQmlValueTypeFactoryImpl::metaObjectForMetaType(int t)
{
switch (t) {
- case QVariant::Point:
+ case QMetaType::QPoint:
return &QQmlPointValueType::staticMetaObject;
- case QVariant::PointF:
+ case QMetaType::QPointF:
return &QQmlPointFValueType::staticMetaObject;
- case QVariant::Size:
+ case QMetaType::QSize:
return &QQmlSizeValueType::staticMetaObject;
- case QVariant::SizeF:
+ case QMetaType::QSizeF:
return &QQmlSizeFValueType::staticMetaObject;
- case QVariant::Rect:
+ case QMetaType::QRect:
return &QQmlRectValueType::staticMetaObject;
- case QVariant::RectF:
+ case QMetaType::QRectF:
return &QQmlRectFValueType::staticMetaObject;
#if QT_CONFIG(easingcurve)
- case QVariant::EasingCurve:
+ case QMetaType::QEasingCurve:
return &QQmlEasingValueType::staticMetaObject;
#endif
#if QT_CONFIG(qml_itemmodel)
- case QVariant::ModelIndex:
+ case QMetaType::QModelIndex:
return &QQmlModelIndexValueType::staticMetaObject;
- case QVariant::PersistentModelIndex:
+ case QMetaType::QPersistentModelIndex:
return &QQmlPersistentModelIndexValueType::staticMetaObject;
#endif
default:
@@ -145,7 +147,8 @@ const QMetaObject *QQmlValueTypeFactoryImpl::metaObjectForMetaType(int t)
if (t == qMetaTypeId<QItemSelectionRange>())
return &QQmlItemSelectionRangeValueType::staticMetaObject;
#endif
-
+ if (t == qMetaTypeId<QQmlProperty>())
+ return &QQmlPropertyValueType::staticMetaObject;
if (const QMetaObject *mo = QQml_valueTypeProvider()->metaObjectForMetaType(t))
return mo;
break;
@@ -159,7 +162,7 @@ const QMetaObject *QQmlValueTypeFactoryImpl::metaObjectForMetaType(int t)
QQmlValueType *QQmlValueTypeFactoryImpl::valueType(int idx)
{
- if (idx >= (int)QVariant::UserType) {
+ if (idx >= (int)QMetaType::User) {
// Protect the hash with a mutex
mutex.lock();
@@ -585,6 +588,16 @@ void QQmlEasingValueType::setBezierCurve(const QVariantList &customCurveVariant)
v = newEasingCurve;
}
+QObject *QQmlPropertyValueType::object() const
+{
+ return v.object();
+}
+
+QString QQmlPropertyValueType::name() const
+{
+ return v.name();
+}
+
QVariantList QQmlEasingValueType::bezierCurve() const
{
QVariantList rv;
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index 0601237c4b..ff664adbe7 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -268,6 +268,17 @@ public:
};
#endif
+struct QQmlPropertyValueType
+{
+ QQmlProperty v;
+ Q_PROPERTY(QObject *object READ object CONSTANT FINAL)
+ Q_PROPERTY(QString name READ name CONSTANT FINAL)
+ Q_GADGET
+public:
+ QObject *object() const;
+ QString name() const;
+};
+
template<typename T>
int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index f23921497c..ba5ba96cbe 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -601,7 +601,7 @@ bool QQmlValueTypeWrapper::virtualPut(Managed *m, PropertyKey id, const Value &v
QVariant v = v4->toVariant(value, property.userType());
- if (property.isEnumType() && (QMetaType::Type)v.type() == QMetaType::Double)
+ if (property.isEnumType() && (QMetaType::Type)v.userType() == QMetaType::Double)
v = v.toInt();
void *gadget = r->d()->gadgetPtr();
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 42a90e234c..ecb86e2f10 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -291,7 +291,7 @@ bool QQmlInterceptorMetaObject::intercept(QMetaObject::Call c, int id, void **a)
const int valueIndex = vi->m_propertyIndex.valueTypeIndex();
int type = QQmlData::get(object)->propertyCache->property(id)->propType();
- if (type != QVariant::Invalid) {
+ if (type != QMetaType::UnknownType) {
if (valueIndex != -1) {
QQmlValueType *valueType = QQmlValueTypeFactory::valueType(type);
Q_ASSERT(valueType);
@@ -534,7 +534,7 @@ QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id) const
QV4::Scope scope(engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
const QV4::VariantObject *v = sv->as<QV4::VariantObject>();
- if (!v || v->d()->data().type() != QVariant::Url)
+ if (!v || v->d()->data().userType() != QMetaType::QUrl)
return QUrl();
return v->d()->data().value<QUrl>();
}
@@ -548,7 +548,7 @@ QDate QQmlVMEMetaObject::readPropertyAsDate(int id) const
QV4::Scope scope(engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
const QV4::VariantObject *v = sv->as<QV4::VariantObject>();
- if (!v || v->d()->data().type() != QVariant::Date)
+ if (!v || v->d()->data().userType() != QMetaType::QDate)
return QDate();
return v->d()->data().value<QDate>();
}
@@ -562,7 +562,7 @@ QDateTime QQmlVMEMetaObject::readPropertyAsDateTime(int id)
QV4::Scope scope(engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
const QV4::VariantObject *v = sv->as<QV4::VariantObject>();
- if (!v || v->d()->data().type() != QVariant::DateTime)
+ if (!v || v->d()->data().userType() != QMetaType::QDateTime)
return QDateTime();
return v->d()->data().value<QDateTime>();
}
@@ -576,7 +576,7 @@ QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id) const
QV4::Scope scope(engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
const QV4::VariantObject *v = sv->as<QV4::VariantObject>();
- if (!v || v->d()->data().type() != QVariant::SizeF)
+ if (!v || v->d()->data().userType() != QMetaType::QSizeF)
return QSizeF();
return v->d()->data().value<QSizeF>();
}
@@ -590,7 +590,7 @@ QPointF QQmlVMEMetaObject::readPropertyAsPointF(int id) const
QV4::Scope scope(engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
const QV4::VariantObject *v = sv->as<QV4::VariantObject>();
- if (!v || v->d()->data().type() != QVariant::PointF)
+ if (!v || v->d()->data().userType() != QMetaType::QPointF)
return QPointF();
return v->d()->data().value<QPointF>();
}
@@ -634,7 +634,7 @@ QRectF QQmlVMEMetaObject::readPropertyAsRectF(int id) const
QV4::Scope scope(engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
const QV4::VariantObject *v = sv->as<QV4::VariantObject>();
- if (!v || v->d()->data().type() != QVariant::RectF)
+ if (!v || v->d()->data().userType() != QMetaType::QRectF)
return QRectF();
return v->d()->data().value<QRectF>();
}
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 2afbdb616b..c820499703 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1291,7 +1291,7 @@ void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url)
if (m_network->bytesAvailable() > 0)
readyRead();
- QNetworkReply::NetworkError networkError = m_network->error();
+ QNetworkReply::NetworkError networkError = m_network->networkError();
if (networkError != QNetworkReply::NoError) {
error(networkError);
} else {
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 2c1956553f..2d3c03cedb 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -340,22 +340,22 @@ ReturnedValue QtObject::method_colorEqual(const FunctionObject *b, const Value *
bool ok = false;
QVariant lhs = scope.engine->toVariant(argv[0], -1);
- if (lhs.userType() == QVariant::String) {
+ if (lhs.userType() == QMetaType::QString) {
lhs = QQmlStringConverters::colorFromString(lhs.toString(), &ok);
if (!ok) {
THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid color name");
}
- } else if (lhs.userType() != QVariant::Color) {
+ } else if (lhs.userType() != QMetaType::QColor) {
THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid arguments");
}
QVariant rhs = scope.engine->toVariant(argv[1], -1);
- if (rhs.userType() == QVariant::String) {
+ if (rhs.userType() == QMetaType::QString) {
rhs = QQmlStringConverters::colorFromString(rhs.toString(), &ok);
if (!ok) {
THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid color name");
}
- } else if (rhs.userType() != QVariant::Color) {
+ } else if (rhs.userType() != QMetaType::QColor) {
THROW_GENERIC_ERROR("Qt.colorEqual(): Invalid arguments");
}
@@ -606,13 +606,13 @@ ReturnedValue QtObject::method_lighter(const FunctionObject *b, const Value *, c
THROW_GENERIC_ERROR("Qt.lighter(): Invalid arguments");
QVariant v = scope.engine->toVariant(argv[0], -1);
- if (v.userType() == QVariant::String) {
+ if (v.userType() == QMetaType::QString) {
bool ok = false;
v = QQmlStringConverters::colorFromString(v.toString(), &ok);
if (!ok) {
return QV4::Encode::null();
}
- } else if (v.userType() != QVariant::Color) {
+ } else if (v.userType() != QMetaType::QColor) {
return QV4::Encode::null();
}
@@ -646,13 +646,13 @@ ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, co
THROW_GENERIC_ERROR("Qt.darker(): Invalid arguments");
QVariant v = scope.engine->toVariant(argv[0], -1);
- if (v.userType() == QVariant::String) {
+ if (v.userType() == QMetaType::QString) {
bool ok = false;
v = QQmlStringConverters::colorFromString(v.toString(), &ok);
if (!ok) {
return QV4::Encode::null();
}
- } else if (v.userType() != QVariant::Color) {
+ } else if (v.userType() != QMetaType::QColor) {
return QV4::Encode::null();
}
@@ -697,25 +697,25 @@ ReturnedValue QtObject::method_tint(const FunctionObject *b, const Value *, cons
// base color
QVariant v1 = scope.engine->toVariant(argv[0], -1);
- if (v1.userType() == QVariant::String) {
+ if (v1.userType() == QMetaType::QString) {
bool ok = false;
v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok);
if (!ok) {
return QV4::Encode::null();
}
- } else if (v1.userType() != QVariant::Color) {
+ } else if (v1.userType() != QMetaType::QColor) {
return QV4::Encode::null();
}
// tint color
QVariant v2 = scope.engine->toVariant(argv[1], -1);
- if (v2.userType() == QVariant::String) {
+ if (v2.userType() == QMetaType::QString) {
bool ok = false;
v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok);
if (!ok) {
return QV4::Encode::null();
}
- } else if (v2.userType() != QVariant::Color) {
+ } else if (v2.userType() != QMetaType::QColor) {
return QV4::Encode::null();
}
@@ -789,7 +789,7 @@ ReturnedValue QtObject::method_formatTime(const FunctionObject *b, const Value *
QVariant argVariant = scope.engine->toVariant(argv[0], -1);
QTime time;
- if (argv[0].as<DateObject>() || (argVariant.type() == QVariant::String))
+ if (argv[0].as<DateObject>() || (argVariant.userType() == QMetaType::QString))
time = argVariant.toDateTime().time();
else // if (argVariant.type() == QVariant::Time), or invalid.
time = argVariant.toTime();