aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvmemetaobject.cpp
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-03-02 08:25:43 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-20 03:15:43 +0100
commitab1e510121c8a679fdaca12ccd30e0f7ac12a26b (patch)
tree68c377ba468a667c43211f005ead5b49b16e49f3 /src/qml/qml/qqmlvmemetaobject.cpp
parentb143d3fb589e7ce7171c9975679fa47181a6a10f (diff)
Migrate gui dependencies from QtQml to QtQuick.
Ensure that users of declarative that have no need for functionality provided by the Qt Gui module do not have to link against it. Any use of QtGui functionality is delegated to providers that can be installed by another library; QtQuick adds default providers for this functionality when linked against QtQml. Task-number: QTBUG-24559 Change-Id: I5e6a58a4198732dc2f8f52f71abfa1152b871aa7 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp56
1 files changed, 24 insertions, 32 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index c4e801f2db..afcc57e479 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -51,6 +51,7 @@
#include "qqmlpropertyvalueinterceptor_p.h"
#include <private/qv8variantresource_p.h>
+#include <private/qqmlglobal_p.h>
Q_DECLARE_METATYPE(QJSValue);
@@ -87,6 +88,7 @@ public:
inline const void *dataPtr() const;
inline void *dataPtr();
inline int dataType() const;
+ inline size_t dataSize() const;
inline QObject *asQObject();
inline const QVariant &asQVariant();
@@ -95,7 +97,6 @@ public:
inline double asDouble();
inline const QString &asQString();
inline const QUrl &asQUrl();
- inline const QColor &asQColor();
inline const QTime &asQTime();
inline const QDate &asQDate();
inline const QDateTime &asQDateTime();
@@ -108,11 +109,13 @@ public:
inline void setValue(double);
inline void setValue(const QString &);
inline void setValue(const QUrl &);
- inline void setValue(const QColor &);
inline void setValue(const QTime &);
inline void setValue(const QDate &);
inline void setValue(const QDateTime &);
inline void setValue(const QJSValue &);
+
+ inline void setDataType(int t);
+
private:
int type;
void *data[6]; // Large enough to hold all types
@@ -157,9 +160,6 @@ void QQmlVMEVariant::cleanup()
} else if (type == QMetaType::QUrl) {
((QUrl *)dataPtr())->~QUrl();
type = QVariant::Invalid;
- } else if (type == QMetaType::QColor) {
- ((QColor *)dataPtr())->~QColor();
- type = QVariant::Invalid;
} else if (type == QMetaType::QTime) {
((QTime *)dataPtr())->~QTime();
type = QVariant::Invalid;
@@ -175,8 +175,11 @@ void QQmlVMEVariant::cleanup()
} else if (type == qMetaTypeId<QJSValue>()) {
((QJSValue *)dataPtr())->~QJSValue();
type = QVariant::Invalid;
+ } else {
+ if (QQml_valueTypeProvider()->destroyValueType(type, dataPtr(), dataSize())) {
+ type = QVariant::Invalid;
+ }
}
-
}
int QQmlVMEVariant::dataType() const
@@ -194,6 +197,11 @@ void *QQmlVMEVariant::dataPtr()
return &data;
}
+size_t QQmlVMEVariant::dataSize() const
+{
+ return sizeof(data);
+}
+
QObject *QQmlVMEVariant::asQObject()
{
if (type != QMetaType::QObjectStar)
@@ -250,14 +258,6 @@ const QUrl &QQmlVMEVariant::asQUrl()
return *(QUrl *)(dataPtr());
}
-const QColor &QQmlVMEVariant::asQColor()
-{
- if (type != QMetaType::QColor)
- setValue(QColor());
-
- return *(QColor *)(dataPtr());
-}
-
const QTime &QQmlVMEVariant::asQTime()
{
if (type != QMetaType::QTime)
@@ -360,17 +360,6 @@ void QQmlVMEVariant::setValue(const QUrl &v)
}
}
-void QQmlVMEVariant::setValue(const QColor &v)
-{
- if (type != QMetaType::QColor) {
- cleanup();
- type = QMetaType::QColor;
- new (dataPtr()) QColor(v);
- } else {
- *(QColor *)(dataPtr()) = v;
- }
-}
-
void QQmlVMEVariant::setValue(const QTime &v)
{
if (type != QMetaType::QTime) {
@@ -415,6 +404,11 @@ void QQmlVMEVariant::setValue(const QJSValue &v)
}
}
+void QQmlVMEVariant::setDataType(int t)
+{
+ type = t;
+}
+
QQmlVMEMetaObjectEndpoint::QQmlVMEMetaObjectEndpoint()
{
callback = &vmecallback;
@@ -587,9 +581,6 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
case QVariant::Url:
*reinterpret_cast<QUrl *>(a[0]) = data[id].asQUrl();
break;
- case QVariant::Color:
- *reinterpret_cast<QColor *>(a[0]) = data[id].asQColor();
- break;
case QVariant::Date:
*reinterpret_cast<QDate *>(a[0]) = data[id].asQDate();
break;
@@ -603,6 +594,7 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
*reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id);
break;
default:
+ QQml_valueTypeProvider()->readValueType(data[id].dataType(), data[id].dataPtr(), t, a[0]);
break;
}
if (t == qMetaTypeId<QQmlListProperty<QObject> >()) {
@@ -637,10 +629,6 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
needActivate = *reinterpret_cast<QUrl *>(a[0]) != data[id].asQUrl();
data[id].setValue(*reinterpret_cast<QUrl *>(a[0]));
break;
- case QVariant::Color:
- needActivate = *reinterpret_cast<QColor *>(a[0]) != data[id].asQColor();
- data[id].setValue(*reinterpret_cast<QColor *>(a[0]));
- break;
case QVariant::Date:
needActivate = *reinterpret_cast<QDate *>(a[0]) != data[id].asQDate();
data[id].setValue(*reinterpret_cast<QDate *>(a[0]));
@@ -657,6 +645,10 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
writeProperty(id, *reinterpret_cast<QVariant *>(a[0]));
break;
default:
+ needActivate = QQml_valueTypeProvider()->writeValueType(t, a[0], data[id].dataPtr(), data[id].dataSize());
+ if (needActivate) {
+ data[id].setDataType(t);
+ }
break;
}
}