Improve QJSValueIterator implementation.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativevaluetype.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "private/qdeclarativevaluetype_p.h"
43
44 #include "private/qdeclarativemetatype_p.h"
45 #include "private/qfont_p.h"
46
47 #include <QtCore/qdebug.h>
48
49 QT_BEGIN_NAMESPACE
50
51 template<typename T>
52 int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
53 {
54     QByteArray name(T::staticMetaObject.className());
55
56     QByteArray pointerName(name + '*');
57
58     QDeclarativePrivate::RegisterType type = {
59         0,
60
61         qRegisterMetaType<T *>(pointerName.constData()), 0, 0, 0,
62
63         QString(),
64
65         uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
66
67         0, 0,
68
69         0, 0, 0,
70
71         0, 0,
72
73         0,
74         0
75     };
76
77     return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
78 }
79
80 QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
81 {
82     // ### Optimize
83     for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
84         valueTypes[ii] = valueType(ii);
85 }
86
87 QDeclarativeValueTypeFactory::~QDeclarativeValueTypeFactory()
88 {
89     for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
90         delete valueTypes[ii];
91 }
92
93 bool QDeclarativeValueTypeFactory::isValueType(int idx)
94 {
95     if ((uint)idx < QVariant::UserType)
96         return true;
97     return false;
98 }
99
100 void QDeclarativeValueTypeFactory::registerBaseTypes(const char *uri, int versionMajor, int versionMinor)
101 {
102     qmlRegisterValueTypeEnums<QDeclarativeEasingValueType>(uri, versionMajor, versionMinor, "Easing");
103     qmlRegisterValueTypeEnums<QDeclarativeFontValueType>(uri, versionMajor, versionMinor, "Font");
104 }
105
106 void QDeclarativeValueTypeFactory::registerValueTypes()
107 {
108     registerBaseTypes("QtQuick", 2, 0);
109 }
110
111 QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
112 {
113     QDeclarativeValueType *rv = 0;
114
115     switch (t) {
116     case QVariant::Point:
117         rv = new QDeclarativePointValueType;
118         break;
119     case QVariant::PointF:
120         rv = new QDeclarativePointFValueType;
121         break;
122     case QVariant::Size:
123         rv = new QDeclarativeSizeValueType;
124         break;
125     case QVariant::SizeF:
126         rv = new QDeclarativeSizeFValueType;
127         break;
128     case QVariant::Rect:
129         rv = new QDeclarativeRectValueType;
130         break;
131     case QVariant::RectF:
132         rv = new QDeclarativeRectFValueType;
133         break;
134     case QVariant::Vector2D:
135         rv = new QDeclarativeVector2DValueType;
136         break;
137     case QVariant::Vector3D:
138         rv = new QDeclarativeVector3DValueType;
139         break;
140     case QVariant::Vector4D:
141         rv = new QDeclarativeVector4DValueType;
142         break;
143     case QVariant::Quaternion:
144         rv = new QDeclarativeQuaternionValueType;
145         break;
146     case QVariant::Matrix4x4:
147         rv = new QDeclarativeMatrix4x4ValueType;
148         break;
149     case QVariant::EasingCurve:
150         rv = new QDeclarativeEasingValueType;
151         break;
152     case QVariant::Font:
153         rv = new QDeclarativeFontValueType;
154         break;
155     default:
156         break;
157     }
158
159     Q_ASSERT(!rv || rv->metaObject()->propertyCount() < 32);
160     return rv;
161 }
162
163 QDeclarativeValueType::QDeclarativeValueType(QObject *parent)
164 : QObject(parent)
165 {
166 }
167
168 QDeclarativePointFValueType::QDeclarativePointFValueType(QObject *parent)
169 : QDeclarativeValueType(parent)
170 {
171 }
172
173 void QDeclarativePointFValueType::read(QObject *obj, int idx)
174 {
175     void *a[] = { &point, 0 };
176     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
177 }
178
179 void QDeclarativePointFValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
180 {
181     int status = -1;
182     void *a[] = { &point, 0, &status, &flags };
183     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
184 }
185
186 QVariant QDeclarativePointFValueType::value()
187 {
188     return QVariant(point);
189 }
190
191 void QDeclarativePointFValueType::setValue(QVariant value)
192 {
193     point = qvariant_cast<QPointF>(value);
194 }
195
196 QString QDeclarativePointFValueType::toString() const
197 {
198     return QString(QLatin1String("QPointF(%1, %2)")).arg(point.x()).arg(point.y());
199 }
200
201 bool QDeclarativePointFValueType::isEqual(const QVariant &value) const
202 {
203     return (QVariant(point) == value);
204 }
205
206 qreal QDeclarativePointFValueType::x() const
207 {
208     return point.x();
209 }
210
211 qreal QDeclarativePointFValueType::y() const
212 {
213     return point.y();
214 }
215
216 void QDeclarativePointFValueType::setX(qreal x)
217 {
218     point.setX(x);
219 }
220
221 void QDeclarativePointFValueType::setY(qreal y)
222 {
223     point.setY(y);
224 }
225
226 QDeclarativePointValueType::QDeclarativePointValueType(QObject *parent)
227 : QDeclarativeValueType(parent)
228 {
229 }
230
231 void QDeclarativePointValueType::read(QObject *obj, int idx)
232 {
233     void *a[] = { &point, 0 };
234     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
235 }
236
237 void QDeclarativePointValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
238 {
239     int status = -1;
240     void *a[] = { &point, 0, &status, &flags };
241     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
242 }
243
244 QVariant QDeclarativePointValueType::value()
245 {
246     return QVariant(point);
247 }
248
249 void QDeclarativePointValueType::setValue(QVariant value)
250 {
251     point = qvariant_cast<QPoint>(value);
252 }
253
254 QString QDeclarativePointValueType::toString() const
255 {
256     return QString(QLatin1String("QPoint(%1, %2)")).arg(point.x()).arg(point.y());
257 }
258
259 bool QDeclarativePointValueType::isEqual(const QVariant &value) const
260 {
261     return (QVariant(point) == value);
262 }
263
264 int QDeclarativePointValueType::x() const
265 {
266     return point.x();
267 }
268
269 int QDeclarativePointValueType::y() const
270 {
271     return point.y();
272 }
273
274 void QDeclarativePointValueType::setX(int x)
275 {
276     point.setX(x);
277 }
278
279 void QDeclarativePointValueType::setY(int y)
280 {
281     point.setY(y);
282 }
283
284 QDeclarativeSizeFValueType::QDeclarativeSizeFValueType(QObject *parent)
285 : QDeclarativeValueType(parent)
286 {
287 }
288
289 void QDeclarativeSizeFValueType::read(QObject *obj, int idx)
290 {
291     void *a[] = { &size, 0 };
292     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
293 }
294
295 void QDeclarativeSizeFValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
296 {
297     int status = -1;
298     void *a[] = { &size, 0, &status, &flags };
299     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
300 }
301
302 QVariant QDeclarativeSizeFValueType::value()
303 {
304     return QVariant(size);
305 }
306
307 void QDeclarativeSizeFValueType::setValue(QVariant value)
308 {
309     size = qvariant_cast<QSizeF>(value);
310 }
311
312 QString QDeclarativeSizeFValueType::toString() const
313 {
314     return QString(QLatin1String("QSizeF(%1, %2)")).arg(size.width()).arg(size.height());
315 }
316
317 bool QDeclarativeSizeFValueType::isEqual(const QVariant &value) const
318 {
319     return (QVariant(size) == value);
320 }
321
322 qreal QDeclarativeSizeFValueType::width() const
323 {
324     return size.width();
325 }
326
327 qreal QDeclarativeSizeFValueType::height() const
328 {
329     return size.height();
330 }
331
332 void QDeclarativeSizeFValueType::setWidth(qreal w)
333 {
334     size.setWidth(w);
335 }
336
337 void QDeclarativeSizeFValueType::setHeight(qreal h)
338 {
339     size.setHeight(h);
340 }
341
342 QDeclarativeSizeValueType::QDeclarativeSizeValueType(QObject *parent)
343 : QDeclarativeValueType(parent)
344 {
345 }
346
347 void QDeclarativeSizeValueType::read(QObject *obj, int idx)
348 {
349     void *a[] = { &size, 0 };
350     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
351 }
352
353 void QDeclarativeSizeValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
354 {
355     int status = -1;
356     void *a[] = { &size, 0, &status, &flags };
357     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
358 }
359
360 QVariant QDeclarativeSizeValueType::value()
361 {
362     return QVariant(size);
363 }
364
365 void QDeclarativeSizeValueType::setValue(QVariant value)
366 {
367     size = qvariant_cast<QSize>(value);
368 }
369
370 QString QDeclarativeSizeValueType::toString() const
371 {
372     return QString(QLatin1String("QSize(%1, %2)")).arg(size.width()).arg(size.height());
373 }
374
375 bool QDeclarativeSizeValueType::isEqual(const QVariant &value) const
376 {
377     return (QVariant(size) == value);
378 }
379
380 int QDeclarativeSizeValueType::width() const
381 {
382     return size.width();
383 }
384
385 int QDeclarativeSizeValueType::height() const
386 {
387     return size.height();
388 }
389
390 void QDeclarativeSizeValueType::setWidth(int w)
391 {
392     size.setWidth(w);
393 }
394
395 void QDeclarativeSizeValueType::setHeight(int h)
396 {
397     size.setHeight(h);
398 }
399
400 QDeclarativeRectFValueType::QDeclarativeRectFValueType(QObject *parent)
401 : QDeclarativeValueType(parent)
402 {
403 }
404
405 void QDeclarativeRectFValueType::read(QObject *obj, int idx)
406 {
407     void *a[] = { &rect, 0 };
408     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
409 }
410
411 void QDeclarativeRectFValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
412 {
413     int status = -1;
414     void *a[] = { &rect, 0, &status, &flags };
415     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
416 }
417
418 QVariant QDeclarativeRectFValueType::value()
419 {
420     return QVariant(rect);
421 }
422
423 void QDeclarativeRectFValueType::setValue(QVariant value)
424 {
425     rect = qvariant_cast<QRectF>(value);
426 }
427
428 QString QDeclarativeRectFValueType::toString() const
429 {
430     return QString(QLatin1String("QRectF(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
431 }
432
433 bool QDeclarativeRectFValueType::isEqual(const QVariant &value) const
434 {
435     return (QVariant(rect) == value);
436 }
437
438 qreal QDeclarativeRectFValueType::x() const
439 {
440     return rect.x();
441 }
442
443 qreal QDeclarativeRectFValueType::y() const
444 {
445     return rect.y();
446 }
447
448 void QDeclarativeRectFValueType::setX(qreal x)
449 {
450     rect.moveLeft(x);
451 }
452
453 void QDeclarativeRectFValueType::setY(qreal y)
454 {
455     rect.moveTop(y);
456 }
457
458 qreal QDeclarativeRectFValueType::width() const
459 {
460     return rect.width();
461 }
462
463 qreal QDeclarativeRectFValueType::height() const
464 {
465     return rect.height();
466 }
467
468 void QDeclarativeRectFValueType::setWidth(qreal w)
469 {
470     rect.setWidth(w);
471 }
472
473 void QDeclarativeRectFValueType::setHeight(qreal h)
474 {
475     rect.setHeight(h);
476 }
477
478 QDeclarativeRectValueType::QDeclarativeRectValueType(QObject *parent)
479 : QDeclarativeValueType(parent)
480 {
481 }
482
483 void QDeclarativeRectValueType::read(QObject *obj, int idx)
484 {
485     void *a[] = { &rect, 0 };
486     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
487 }
488
489 void QDeclarativeRectValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
490 {
491     int status = -1;
492     void *a[] = { &rect, 0, &status, &flags };
493     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
494 }
495
496 QVariant QDeclarativeRectValueType::value()
497 {
498     return QVariant(rect);
499 }
500
501 void QDeclarativeRectValueType::setValue(QVariant value)
502 {
503     rect = qvariant_cast<QRect>(value);
504 }
505
506 QString QDeclarativeRectValueType::toString() const
507 {
508     return QString(QLatin1String("QRect(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
509 }
510
511 bool QDeclarativeRectValueType::isEqual(const QVariant &value) const
512 {
513     return (QVariant(rect) == value);
514 }
515
516 int QDeclarativeRectValueType::x() const
517 {
518     return rect.x();
519 }
520
521 int QDeclarativeRectValueType::y() const
522 {
523     return rect.y();
524 }
525
526 void QDeclarativeRectValueType::setX(int x)
527 {
528     rect.moveLeft(x);
529 }
530
531 void QDeclarativeRectValueType::setY(int y)
532 {
533     rect.moveTop(y);
534 }
535
536 int QDeclarativeRectValueType::width() const
537 {
538     return rect.width();
539 }
540
541 int QDeclarativeRectValueType::height() const
542 {
543     return rect.height();
544 }
545
546 void QDeclarativeRectValueType::setWidth(int w)
547 {
548     rect.setWidth(w);
549 }
550
551 void QDeclarativeRectValueType::setHeight(int h)
552 {
553     rect.setHeight(h);
554 }
555
556 QDeclarativeVector2DValueType::QDeclarativeVector2DValueType(QObject *parent)
557 : QDeclarativeValueType(parent)
558 {
559 }
560
561 void QDeclarativeVector2DValueType::read(QObject *obj, int idx)
562 {
563     void *a[] = { &vector, 0 };
564     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
565 }
566
567 void QDeclarativeVector2DValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
568 {
569     int status = -1;
570     void *a[] = { &vector, 0, &status, &flags };
571     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
572 }
573
574 QVariant  QDeclarativeVector2DValueType::value()
575 {
576     return QVariant(vector);
577 }
578
579 void QDeclarativeVector2DValueType::setValue(QVariant value)
580 {
581     vector = qvariant_cast<QVector2D>(value);
582 }
583
584 QString QDeclarativeVector2DValueType::toString() const
585 {
586     return QString(QLatin1String("QVector2D(%1, %2)")).arg(vector.x()).arg(vector.y());
587 }
588
589 bool QDeclarativeVector2DValueType::isEqual(const QVariant &value) const
590 {
591     return (QVariant(vector) == value);
592 }
593
594 qreal QDeclarativeVector2DValueType::x() const
595 {
596     return vector.x();
597 }
598
599 qreal QDeclarativeVector2DValueType::y() const
600 {
601     return vector.y();
602 }
603
604 void QDeclarativeVector2DValueType::setX(qreal x)
605 {
606     vector.setX(x);
607 }
608
609 void QDeclarativeVector2DValueType::setY(qreal y)
610 {
611     vector.setY(y);
612 }
613
614 QDeclarativeVector3DValueType::QDeclarativeVector3DValueType(QObject *parent)
615 : QDeclarativeValueType(parent)
616 {
617 }
618
619 void QDeclarativeVector3DValueType::read(QObject *obj, int idx)
620 {
621     void *a[] = { &vector, 0 };
622     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
623 }
624
625 void QDeclarativeVector3DValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
626 {
627     int status = -1;
628     void *a[] = { &vector, 0, &status, &flags };
629     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
630 }
631
632 QVariant  QDeclarativeVector3DValueType::value()
633 {
634     return QVariant(vector);
635 }
636
637 void QDeclarativeVector3DValueType::setValue(QVariant value)
638 {
639     vector = qvariant_cast<QVector3D>(value);
640 }
641
642 QString QDeclarativeVector3DValueType::toString() const
643 {
644     return QString(QLatin1String("QVector3D(%1, %2, %3)")).arg(vector.x()).arg(vector.y()).arg(vector.z());
645 }
646
647 bool QDeclarativeVector3DValueType::isEqual(const QVariant &value) const
648 {
649     return (QVariant(vector) == value);
650 }
651
652 qreal QDeclarativeVector3DValueType::x() const
653 {
654     return vector.x();
655 }
656
657 qreal QDeclarativeVector3DValueType::y() const
658 {
659     return vector.y();
660 }
661
662 qreal QDeclarativeVector3DValueType::z() const
663 {
664     return vector.z();
665 }
666
667 void QDeclarativeVector3DValueType::setX(qreal x)
668 {
669     vector.setX(x);
670 }
671
672 void QDeclarativeVector3DValueType::setY(qreal y)
673 {
674     vector.setY(y);
675 }
676
677 void QDeclarativeVector3DValueType::setZ(qreal z)
678 {
679     vector.setZ(z);
680 }
681
682 QDeclarativeVector4DValueType::QDeclarativeVector4DValueType(QObject *parent)
683 : QDeclarativeValueType(parent)
684 {
685 }
686
687 void QDeclarativeVector4DValueType::read(QObject *obj, int idx)
688 {
689     void *a[] = { &vector, 0 };
690     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
691 }
692
693 void QDeclarativeVector4DValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
694 {
695     int status = -1;
696     void *a[] = { &vector, 0, &status, &flags };
697     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
698 }
699
700 QVariant  QDeclarativeVector4DValueType::value()
701 {
702     return QVariant(vector);
703 }
704
705 void QDeclarativeVector4DValueType::setValue(QVariant value)
706 {
707     vector = qvariant_cast<QVector4D>(value);
708 }
709
710 QString QDeclarativeVector4DValueType::toString() const
711 {
712     return QString(QLatin1String("QVector4D(%1, %2, %3, %4)")).arg(vector.x()).arg(vector.y()).arg(vector.z()).arg(vector.w());
713 }
714
715 bool QDeclarativeVector4DValueType::isEqual(const QVariant &value) const
716 {
717     return (QVariant(vector) == value);
718 }
719
720 qreal QDeclarativeVector4DValueType::x() const
721 {
722     return vector.x();
723 }
724
725 qreal QDeclarativeVector4DValueType::y() const
726 {
727     return vector.y();
728 }
729
730 qreal QDeclarativeVector4DValueType::z() const
731 {
732     return vector.z();
733 }
734
735 qreal QDeclarativeVector4DValueType::w() const
736 {
737     return vector.w();
738 }
739
740 void QDeclarativeVector4DValueType::setX(qreal x)
741 {
742     vector.setX(x);
743 }
744
745 void QDeclarativeVector4DValueType::setY(qreal y)
746 {
747     vector.setY(y);
748 }
749
750 void QDeclarativeVector4DValueType::setZ(qreal z)
751 {
752     vector.setZ(z);
753 }
754
755 void QDeclarativeVector4DValueType::setW(qreal w)
756 {
757     vector.setW(w);
758 }
759
760 QDeclarativeQuaternionValueType::QDeclarativeQuaternionValueType(QObject *parent)
761 : QDeclarativeValueType(parent)
762 {
763 }
764
765 void QDeclarativeQuaternionValueType::read(QObject *obj, int idx)
766 {
767     void *a[] = { &quaternion, 0 };
768     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
769 }
770
771 void QDeclarativeQuaternionValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
772 {
773     int status = -1;
774     void *a[] = { &quaternion, 0, &status, &flags };
775     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
776 }
777
778 QVariant  QDeclarativeQuaternionValueType::value()
779 {
780     return QVariant(quaternion);
781 }
782
783 void QDeclarativeQuaternionValueType::setValue(QVariant value)
784 {
785     quaternion = qvariant_cast<QQuaternion>(value);
786 }
787
788 QString QDeclarativeQuaternionValueType::toString() const
789 {
790     return QString(QLatin1String("QQuaternion(%1, %2, %3, %4)")).arg(quaternion.scalar()).arg(quaternion.x()).arg(quaternion.y()).arg(quaternion.z());
791 }
792
793 bool QDeclarativeQuaternionValueType::isEqual(const QVariant &value) const
794 {
795     return (QVariant(quaternion) == value);
796 }
797
798 qreal QDeclarativeQuaternionValueType::scalar() const
799 {
800     return quaternion.scalar();
801 }
802
803 qreal QDeclarativeQuaternionValueType::x() const
804 {
805     return quaternion.x();
806 }
807
808 qreal QDeclarativeQuaternionValueType::y() const
809 {
810     return quaternion.y();
811 }
812
813 qreal QDeclarativeQuaternionValueType::z() const
814 {
815     return quaternion.z();
816 }
817
818 void QDeclarativeQuaternionValueType::setScalar(qreal scalar)
819 {
820     quaternion.setScalar(scalar);
821 }
822
823 void QDeclarativeQuaternionValueType::setX(qreal x)
824 {
825     quaternion.setX(x);
826 }
827
828 void QDeclarativeQuaternionValueType::setY(qreal y)
829 {
830     quaternion.setY(y);
831 }
832
833 void QDeclarativeQuaternionValueType::setZ(qreal z)
834 {
835     quaternion.setZ(z);
836 }
837
838 QDeclarativeMatrix4x4ValueType::QDeclarativeMatrix4x4ValueType(QObject *parent)
839 : QDeclarativeValueType(parent)
840 {
841 }
842
843 void QDeclarativeMatrix4x4ValueType::read(QObject *obj, int idx)
844 {
845     void *a[] = { &matrix, 0 };
846     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
847 }
848
849 void QDeclarativeMatrix4x4ValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
850 {
851     int status = -1;
852     void *a[] = { &matrix, 0, &status, &flags };
853     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
854 }
855
856 QVariant  QDeclarativeMatrix4x4ValueType::value()
857 {
858     return QVariant(matrix);
859 }
860
861 void QDeclarativeMatrix4x4ValueType::setValue(QVariant value)
862 {
863     matrix = qvariant_cast<QMatrix4x4>(value);
864 }
865
866 QString QDeclarativeMatrix4x4ValueType::toString() const
867 {
868     return QString(QLatin1String("QMatrix4x4(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16)"))
869             .arg(matrix(0, 0)).arg(matrix(0, 1)).arg(matrix(0, 2)).arg(matrix(0, 3))
870             .arg(matrix(1, 0)).arg(matrix(1, 1)).arg(matrix(1, 2)).arg(matrix(1, 3))
871             .arg(matrix(2, 0)).arg(matrix(2, 1)).arg(matrix(2, 2)).arg(matrix(2, 3))
872             .arg(matrix(3, 0)).arg(matrix(3, 1)).arg(matrix(3, 2)).arg(matrix(3, 3));
873 }
874
875 bool QDeclarativeMatrix4x4ValueType::isEqual(const QVariant &value) const
876 {
877     return (QVariant(matrix) == value);
878 }
879
880 QDeclarativeEasingValueType::QDeclarativeEasingValueType(QObject *parent)
881 : QDeclarativeValueType(parent)
882 {
883 }
884
885 void QDeclarativeEasingValueType::read(QObject *obj, int idx)
886 {
887     void *a[] = { &easing, 0 };
888     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
889 }
890
891 void QDeclarativeEasingValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
892 {
893     int status = -1;
894     void *a[] = { &easing, 0, &status, &flags };
895     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
896 }
897
898 QVariant QDeclarativeEasingValueType::value()
899 {
900     return QVariant(easing);
901 }
902
903 void QDeclarativeEasingValueType::setValue(QVariant value)
904 {
905     easing = qvariant_cast<QEasingCurve>(value);
906 }
907
908 QString QDeclarativeEasingValueType::toString() const
909 {
910     return QString(QLatin1String("QEasingCurve(%1, %2, %3, %4)")).arg(easing.type()).arg(easing.amplitude()).arg(easing.overshoot()).arg(easing.period());
911 }
912
913 bool QDeclarativeEasingValueType::isEqual(const QVariant &value) const
914 {
915     return (QVariant(easing) == value);
916 }
917
918 QDeclarativeEasingValueType::Type QDeclarativeEasingValueType::type() const
919 {
920     return (QDeclarativeEasingValueType::Type)easing.type();
921 }
922
923 qreal QDeclarativeEasingValueType::amplitude() const
924 {
925     return easing.amplitude();
926 }
927
928 qreal QDeclarativeEasingValueType::overshoot() const
929 {
930     return easing.overshoot();
931 }
932
933 qreal QDeclarativeEasingValueType::period() const
934 {
935     return easing.period();
936 }
937
938 void QDeclarativeEasingValueType::setType(QDeclarativeEasingValueType::Type type)
939 {
940     easing.setType((QEasingCurve::Type)type);
941 }
942
943 void QDeclarativeEasingValueType::setAmplitude(qreal amplitude)
944 {
945     easing.setAmplitude(amplitude);
946 }
947
948 void QDeclarativeEasingValueType::setOvershoot(qreal overshoot)
949 {
950     easing.setOvershoot(overshoot);
951 }
952
953 void QDeclarativeEasingValueType::setPeriod(qreal period)
954 {
955     easing.setPeriod(period);
956 }
957
958 QDeclarativeFontValueType::QDeclarativeFontValueType(QObject *parent)
959 : QDeclarativeValueType(parent), pixelSizeSet(false), pointSizeSet(false)
960 {
961 }
962
963 void QDeclarativeFontValueType::read(QObject *obj, int idx)
964 {
965     void *a[] = { &font, 0 };
966     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
967     pixelSizeSet = false;
968     pointSizeSet = false;
969 }
970
971 void QDeclarativeFontValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
972 {
973     int status = -1;
974     void *a[] = { &font, 0, &status, &flags };
975     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
976 }
977
978 QVariant  QDeclarativeFontValueType::value()
979 {
980     return QVariant(font);
981 }
982
983 void QDeclarativeFontValueType::setValue(QVariant value)
984 {
985     font = qvariant_cast<QFont>(value);
986 }
987
988 QString QDeclarativeFontValueType::toString() const
989 {
990     return QString(QLatin1String("QFont(%1)")).arg(font.toString());
991 }
992
993 bool QDeclarativeFontValueType::isEqual(const QVariant &value) const
994 {
995     return (QVariant(font) == value);
996 }
997
998
999 QString QDeclarativeFontValueType::family() const
1000 {
1001     return font.family();
1002 }
1003
1004 void QDeclarativeFontValueType::setFamily(const QString &family)
1005 {
1006     font.setFamily(family);
1007 }
1008
1009 bool QDeclarativeFontValueType::bold() const
1010 {
1011     return font.bold();
1012 }
1013
1014 void QDeclarativeFontValueType::setBold(bool b)
1015 {
1016     font.setBold(b);
1017 }
1018
1019 QDeclarativeFontValueType::FontWeight QDeclarativeFontValueType::weight() const
1020 {
1021     return (QDeclarativeFontValueType::FontWeight)font.weight();
1022 }
1023
1024 void QDeclarativeFontValueType::setWeight(QDeclarativeFontValueType::FontWeight w)
1025 {
1026     font.setWeight((QFont::Weight)w);
1027 }
1028
1029 bool QDeclarativeFontValueType::italic() const
1030 {
1031     return font.italic();
1032 }
1033
1034 void QDeclarativeFontValueType::setItalic(bool b)
1035 {
1036     font.setItalic(b);
1037 }
1038
1039 bool QDeclarativeFontValueType::underline() const
1040 {
1041     return font.underline();
1042 }
1043
1044 void QDeclarativeFontValueType::setUnderline(bool b)
1045 {
1046     font.setUnderline(b);
1047 }
1048
1049 bool QDeclarativeFontValueType::overline() const
1050 {
1051     return font.overline();
1052 }
1053
1054 void QDeclarativeFontValueType::setOverline(bool b)
1055 {
1056     font.setOverline(b);
1057 }
1058
1059 bool QDeclarativeFontValueType::strikeout() const
1060 {
1061     return font.strikeOut();
1062 }
1063
1064 void QDeclarativeFontValueType::setStrikeout(bool b)
1065 {
1066     font.setStrikeOut(b);
1067 }
1068
1069 qreal QDeclarativeFontValueType::pointSize() const
1070 {
1071     if (font.pointSizeF() == -1) {
1072         if (dpi.isNull)
1073             dpi = qt_defaultDpi();
1074         return font.pixelSize() * qreal(72.) / qreal(dpi);
1075     }
1076     return font.pointSizeF();
1077 }
1078
1079 void QDeclarativeFontValueType::setPointSize(qreal size)
1080 {
1081     if (pixelSizeSet) {
1082         qWarning() << "Both point size and pixel size set. Using pixel size.";
1083         return;
1084     }
1085
1086     if (size >= 0.0) {
1087         pointSizeSet = true;
1088         font.setPointSizeF(size);
1089     } else {
1090         pointSizeSet = false;
1091     }
1092 }
1093
1094 int QDeclarativeFontValueType::pixelSize() const
1095 {
1096     if (font.pixelSize() == -1) {
1097         if (dpi.isNull)
1098             dpi = qt_defaultDpi();
1099         return (font.pointSizeF() * dpi) / qreal(72.);
1100     }
1101     return font.pixelSize();
1102 }
1103
1104 void QDeclarativeFontValueType::setPixelSize(int size)
1105 {
1106     if (size >0) {
1107         if (pointSizeSet)
1108             qWarning() << "Both point size and pixel size set. Using pixel size.";
1109         font.setPixelSize(size);
1110         pixelSizeSet = true;
1111     } else {
1112         pixelSizeSet = false;
1113     }
1114 }
1115
1116 QDeclarativeFontValueType::Capitalization QDeclarativeFontValueType::capitalization() const
1117 {
1118     return (QDeclarativeFontValueType::Capitalization)font.capitalization();
1119 }
1120
1121 void QDeclarativeFontValueType::setCapitalization(QDeclarativeFontValueType::Capitalization c)
1122 {
1123     font.setCapitalization((QFont::Capitalization)c);
1124 }
1125
1126 qreal QDeclarativeFontValueType::letterSpacing() const
1127 {
1128     return font.letterSpacing();
1129 }
1130
1131 void QDeclarativeFontValueType::setLetterSpacing(qreal size)
1132 {
1133     font.setLetterSpacing(QFont::AbsoluteSpacing, size);
1134 }
1135
1136 qreal QDeclarativeFontValueType::wordSpacing() const
1137 {
1138     return font.wordSpacing();
1139 }
1140
1141 void QDeclarativeFontValueType::setWordSpacing(qreal size)
1142 {
1143     font.setWordSpacing(size);
1144 }
1145
1146 QT_END_NAMESPACE