summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativevmemetaobject.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-29 04:47:53 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-29 04:48:58 (GMT)
commitd6817c59b664b1ce08e45bed902f17b58160a30f (patch)
tree8a0c8736a0c26446756976f8dfd1212345ab847e /src/declarative/qml/qdeclarativevmemetaobject.cpp
parente3ec89ed31439a83c10a2fc2d770283f4f10f31a (diff)
downloadQt-d6817c59b664b1ce08e45bed902f17b58160a30f.zip
Qt-d6817c59b664b1ce08e45bed902f17b58160a30f.tar.gz
Qt-d6817c59b664b1ce08e45bed902f17b58160a30f.tar.bz2
Use QDateTime when specifying a "date" property in QML
QT-718
Diffstat (limited to 'src/declarative/qml/qdeclarativevmemetaobject.cpp')
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp
index 2404fdd..721e1f1 100644
--- a/src/declarative/qml/qdeclarativevmemetaobject.cpp
+++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp
@@ -69,6 +69,7 @@ public:
inline const QString &asQString();
inline const QUrl &asQUrl();
inline const QColor &asQColor();
+ inline const QTime &asQTime();
inline const QDate &asQDate();
inline const QDateTime &asQDateTime();
inline const QScriptValue &asQScriptValue();
@@ -81,6 +82,7 @@ public:
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 QScriptValue &);
@@ -119,6 +121,9 @@ void QDeclarativeVMEVariant::cleanup()
} else if (type == QMetaType::QColor) {
((QColor *)dataPtr())->~QColor();
type = QVariant::Invalid;
+ } else if (type == QMetaType::QTime) {
+ ((QTime *)dataPtr())->~QTime();
+ type = QVariant::Invalid;
} else if (type == QMetaType::QDate) {
((QDate *)dataPtr())->~QDate();
type = QVariant::Invalid;
@@ -214,6 +219,14 @@ const QColor &QDeclarativeVMEVariant::asQColor()
return *(QColor *)(dataPtr());
}
+const QTime &QDeclarativeVMEVariant::asQTime()
+{
+ if (type != QMetaType::QTime)
+ setValue(QTime());
+
+ return *(QTime *)(dataPtr());
+}
+
const QDate &QDeclarativeVMEVariant::asQDate()
{
if (type != QMetaType::QDate)
@@ -318,6 +331,17 @@ void QDeclarativeVMEVariant::setValue(const QColor &v)
}
}
+void QDeclarativeVMEVariant::setValue(const QTime &v)
+{
+ if (type != QMetaType::QTime) {
+ cleanup();
+ type = QMetaType::QTime;
+ new (dataPtr()) QTime(v);
+ } else {
+ *(QTime *)(dataPtr()) = v;
+ }
+}
+
void QDeclarativeVMEVariant::setValue(const QDate &v)
{
if (type != QMetaType::QDate) {