Initial import from the monolithic Qt.
[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 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file.  Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **
32 **
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::registerValueTypes()
101 {
102     qmlRegisterValueTypeEnums<QDeclarativeEasingValueType>("QtQuick",1,0,"Easing");
103     qmlRegisterValueTypeEnums<QDeclarativeFontValueType>("QtQuick",1,0,"Font");
104 #ifndef QT_NO_IMPORT_QT47_QML
105     qmlRegisterValueTypeEnums<QDeclarativeEasingValueType>("Qt",4,7,"Easing");
106     qmlRegisterValueTypeEnums<QDeclarativeFontValueType>("Qt",4,7,"Font");
107 #endif
108 }
109
110 QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
111 {
112     QDeclarativeValueType *rv = 0;
113
114     switch (t) {
115     case QVariant::Point:
116         rv = new QDeclarativePointValueType;
117         break;
118     case QVariant::PointF:
119         rv = new QDeclarativePointFValueType;
120         break;
121     case QVariant::Size:
122         rv = new QDeclarativeSizeValueType;
123         break;
124     case QVariant::SizeF:
125         rv = new QDeclarativeSizeFValueType;
126         break;
127     case QVariant::Rect:
128         rv = new QDeclarativeRectValueType;
129         break;
130     case QVariant::RectF:
131         rv = new QDeclarativeRectFValueType;
132         break;
133     case QVariant::Vector2D:
134         rv = new QDeclarativeVector2DValueType;
135         break;
136     case QVariant::Vector3D:
137         rv = new QDeclarativeVector3DValueType;
138         break;
139     case QVariant::Vector4D:
140         rv = new QDeclarativeVector4DValueType;
141         break;
142     case QVariant::Quaternion:
143         rv = new QDeclarativeQuaternionValueType;
144         break;
145     case QVariant::Matrix4x4:
146         rv = new QDeclarativeMatrix4x4ValueType;
147         break;
148     case QVariant::EasingCurve:
149         rv = new QDeclarativeEasingValueType;
150         break;
151     case QVariant::Font:
152         rv = new QDeclarativeFontValueType;
153         break;
154     default:
155         break;
156     }
157
158     Q_ASSERT(!rv || rv->metaObject()->propertyCount() < 32);
159     return rv;
160 }
161
162 QDeclarativeValueType::QDeclarativeValueType(QObject *parent)
163 : QObject(parent)
164 {
165 }
166
167 QDeclarativePointFValueType::QDeclarativePointFValueType(QObject *parent)
168 : QDeclarativeValueType(parent)
169 {
170 }
171
172 void QDeclarativePointFValueType::read(QObject *obj, int idx)
173 {
174     void *a[] = { &point, 0 };
175     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
176 }
177
178 void QDeclarativePointFValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
179 {
180     int status = -1;
181     void *a[] = { &point, 0, &status, &flags };
182     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
183 }
184
185 QVariant QDeclarativePointFValueType::value()
186 {
187     return QVariant(point);
188 }
189
190 void QDeclarativePointFValueType::setValue(QVariant value)
191 {
192     point = qvariant_cast<QPointF>(value);
193 }
194
195 qreal QDeclarativePointFValueType::x() const
196 {
197     return point.x();
198 }
199
200 qreal QDeclarativePointFValueType::y() const
201 {
202     return point.y();
203 }
204
205 void QDeclarativePointFValueType::setX(qreal x)
206 {
207     point.setX(x);
208 }
209
210 void QDeclarativePointFValueType::setY(qreal y)
211 {
212     point.setY(y);
213 }
214
215 QDeclarativePointValueType::QDeclarativePointValueType(QObject *parent)
216 : QDeclarativeValueType(parent)
217 {
218 }
219
220 void QDeclarativePointValueType::read(QObject *obj, int idx)
221 {
222     void *a[] = { &point, 0 };
223     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
224 }
225
226 void QDeclarativePointValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
227 {
228     int status = -1;
229     void *a[] = { &point, 0, &status, &flags };
230     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
231 }
232
233 QVariant QDeclarativePointValueType::value()
234 {
235     return QVariant(point);
236 }
237
238 void QDeclarativePointValueType::setValue(QVariant value)
239 {
240     point = qvariant_cast<QPoint>(value);
241 }
242
243 int QDeclarativePointValueType::x() const
244 {
245     return point.x();
246 }
247
248 int QDeclarativePointValueType::y() const
249 {
250     return point.y();
251 }
252
253 void QDeclarativePointValueType::setX(int x)
254 {
255     point.setX(x);
256 }
257
258 void QDeclarativePointValueType::setY(int y)
259 {
260     point.setY(y);
261 }
262
263 QDeclarativeSizeFValueType::QDeclarativeSizeFValueType(QObject *parent)
264 : QDeclarativeValueType(parent)
265 {
266 }
267
268 void QDeclarativeSizeFValueType::read(QObject *obj, int idx)
269 {
270     void *a[] = { &size, 0 };
271     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
272 }
273
274 void QDeclarativeSizeFValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
275 {
276     int status = -1;
277     void *a[] = { &size, 0, &status, &flags };
278     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
279 }
280
281 QVariant QDeclarativeSizeFValueType::value()
282 {
283     return QVariant(size);
284 }
285
286 void QDeclarativeSizeFValueType::setValue(QVariant value)
287 {
288     size = qvariant_cast<QSizeF>(value);
289 }
290
291 qreal QDeclarativeSizeFValueType::width() const
292 {
293     return size.width();
294 }
295
296 qreal QDeclarativeSizeFValueType::height() const
297 {
298     return size.height();
299 }
300
301 void QDeclarativeSizeFValueType::setWidth(qreal w)
302 {
303     size.setWidth(w);
304 }
305
306 void QDeclarativeSizeFValueType::setHeight(qreal h)
307 {
308     size.setHeight(h);
309 }
310
311 QDeclarativeSizeValueType::QDeclarativeSizeValueType(QObject *parent)
312 : QDeclarativeValueType(parent)
313 {
314 }
315
316 void QDeclarativeSizeValueType::read(QObject *obj, int idx)
317 {
318     void *a[] = { &size, 0 };
319     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
320 }
321
322 void QDeclarativeSizeValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
323 {
324     int status = -1;
325     void *a[] = { &size, 0, &status, &flags };
326     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
327 }
328
329 QVariant QDeclarativeSizeValueType::value()
330 {
331     return QVariant(size);
332 }
333
334 void QDeclarativeSizeValueType::setValue(QVariant value)
335 {
336     size = qvariant_cast<QSize>(value);
337 }
338
339 int QDeclarativeSizeValueType::width() const
340 {
341     return size.width();
342 }
343
344 int QDeclarativeSizeValueType::height() const
345 {
346     return size.height();
347 }
348
349 void QDeclarativeSizeValueType::setWidth(int w)
350 {
351     size.setWidth(w);
352 }
353
354 void QDeclarativeSizeValueType::setHeight(int h)
355 {
356     size.setHeight(h);
357 }
358
359 QDeclarativeRectFValueType::QDeclarativeRectFValueType(QObject *parent)
360 : QDeclarativeValueType(parent)
361 {
362 }
363
364 void QDeclarativeRectFValueType::read(QObject *obj, int idx)
365 {
366     void *a[] = { &rect, 0 };
367     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
368 }
369
370 void QDeclarativeRectFValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
371 {
372     int status = -1;
373     void *a[] = { &rect, 0, &status, &flags };
374     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
375 }
376
377 QVariant QDeclarativeRectFValueType::value()
378 {
379     return QVariant(rect);
380 }
381
382 void QDeclarativeRectFValueType::setValue(QVariant value)
383 {
384     rect = qvariant_cast<QRectF>(value);
385 }
386
387 qreal QDeclarativeRectFValueType::x() const
388 {
389     return rect.x();
390 }
391
392 qreal QDeclarativeRectFValueType::y() const
393 {
394     return rect.y();
395 }
396
397 void QDeclarativeRectFValueType::setX(qreal x)
398 {
399     rect.moveLeft(x);
400 }
401
402 void QDeclarativeRectFValueType::setY(qreal y)
403 {
404     rect.moveTop(y);
405 }
406
407 qreal QDeclarativeRectFValueType::width() const
408 {
409     return rect.width();
410 }
411
412 qreal QDeclarativeRectFValueType::height() const
413 {
414     return rect.height();
415 }
416
417 void QDeclarativeRectFValueType::setWidth(qreal w)
418 {
419     rect.setWidth(w);
420 }
421
422 void QDeclarativeRectFValueType::setHeight(qreal h)
423 {
424     rect.setHeight(h);
425 }
426
427 QDeclarativeRectValueType::QDeclarativeRectValueType(QObject *parent)
428 : QDeclarativeValueType(parent)
429 {
430 }
431
432 void QDeclarativeRectValueType::read(QObject *obj, int idx)
433 {
434     void *a[] = { &rect, 0 };
435     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
436 }
437
438 void QDeclarativeRectValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
439 {
440     int status = -1;
441     void *a[] = { &rect, 0, &status, &flags };
442     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
443 }
444
445 QVariant QDeclarativeRectValueType::value()
446 {
447     return QVariant(rect);
448 }
449
450 void QDeclarativeRectValueType::setValue(QVariant value)
451 {
452     rect = qvariant_cast<QRect>(value);
453 }
454
455 int QDeclarativeRectValueType::x() const
456 {
457     return rect.x();
458 }
459
460 int QDeclarativeRectValueType::y() const
461 {
462     return rect.y();
463 }
464
465 void QDeclarativeRectValueType::setX(int x)
466 {
467     rect.moveLeft(x);
468 }
469
470 void QDeclarativeRectValueType::setY(int y)
471 {
472     rect.moveTop(y);
473 }
474
475 int QDeclarativeRectValueType::width() const
476 {
477     return rect.width();
478 }
479
480 int QDeclarativeRectValueType::height() const
481 {
482     return rect.height();
483 }
484
485 void QDeclarativeRectValueType::setWidth(int w)
486 {
487     rect.setWidth(w);
488 }
489
490 void QDeclarativeRectValueType::setHeight(int h)
491 {
492     rect.setHeight(h);
493 }
494
495 QDeclarativeVector2DValueType::QDeclarativeVector2DValueType(QObject *parent)
496 : QDeclarativeValueType(parent)
497 {
498 }
499
500 void QDeclarativeVector2DValueType::read(QObject *obj, int idx)
501 {
502     void *a[] = { &vector, 0 };
503     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
504 }
505
506 void QDeclarativeVector2DValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
507 {
508     int status = -1;
509     void *a[] = { &vector, 0, &status, &flags };
510     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
511 }
512
513 QVariant  QDeclarativeVector2DValueType::value()
514 {
515     return QVariant(vector);
516 }
517
518 void QDeclarativeVector2DValueType::setValue(QVariant value)
519 {
520     vector = qvariant_cast<QVector2D>(value);
521 }
522
523 qreal QDeclarativeVector2DValueType::x() const
524 {
525     return vector.x();
526 }
527
528 qreal QDeclarativeVector2DValueType::y() const
529 {
530     return vector.y();
531 }
532
533 void QDeclarativeVector2DValueType::setX(qreal x)
534 {
535     vector.setX(x);
536 }
537
538 void QDeclarativeVector2DValueType::setY(qreal y)
539 {
540     vector.setY(y);
541 }
542
543 QDeclarativeVector3DValueType::QDeclarativeVector3DValueType(QObject *parent)
544 : QDeclarativeValueType(parent)
545 {
546 }
547
548 void QDeclarativeVector3DValueType::read(QObject *obj, int idx)
549 {
550     void *a[] = { &vector, 0 };
551     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
552 }
553
554 void QDeclarativeVector3DValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
555 {
556     int status = -1;
557     void *a[] = { &vector, 0, &status, &flags };
558     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
559 }
560
561 QVariant  QDeclarativeVector3DValueType::value()
562 {
563     return QVariant(vector);
564 }
565
566 void QDeclarativeVector3DValueType::setValue(QVariant value)
567 {
568     vector = qvariant_cast<QVector3D>(value);
569 }
570
571 qreal QDeclarativeVector3DValueType::x() const
572 {
573     return vector.x();
574 }
575
576 qreal QDeclarativeVector3DValueType::y() const
577 {
578     return vector.y();
579 }
580
581 qreal QDeclarativeVector3DValueType::z() const
582 {
583     return vector.z();
584 }
585
586 void QDeclarativeVector3DValueType::setX(qreal x)
587 {
588     vector.setX(x);
589 }
590
591 void QDeclarativeVector3DValueType::setY(qreal y)
592 {
593     vector.setY(y);
594 }
595
596 void QDeclarativeVector3DValueType::setZ(qreal z)
597 {
598     vector.setZ(z);
599 }
600
601 QDeclarativeVector4DValueType::QDeclarativeVector4DValueType(QObject *parent)
602 : QDeclarativeValueType(parent)
603 {
604 }
605
606 void QDeclarativeVector4DValueType::read(QObject *obj, int idx)
607 {
608     void *a[] = { &vector, 0 };
609     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
610 }
611
612 void QDeclarativeVector4DValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
613 {
614     int status = -1;
615     void *a[] = { &vector, 0, &status, &flags };
616     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
617 }
618
619 QVariant  QDeclarativeVector4DValueType::value()
620 {
621     return QVariant(vector);
622 }
623
624 void QDeclarativeVector4DValueType::setValue(QVariant value)
625 {
626     vector = qvariant_cast<QVector4D>(value);
627 }
628
629 qreal QDeclarativeVector4DValueType::x() const
630 {
631     return vector.x();
632 }
633
634 qreal QDeclarativeVector4DValueType::y() const
635 {
636     return vector.y();
637 }
638
639 qreal QDeclarativeVector4DValueType::z() const
640 {
641     return vector.z();
642 }
643
644 qreal QDeclarativeVector4DValueType::w() const
645 {
646     return vector.w();
647 }
648
649 void QDeclarativeVector4DValueType::setX(qreal x)
650 {
651     vector.setX(x);
652 }
653
654 void QDeclarativeVector4DValueType::setY(qreal y)
655 {
656     vector.setY(y);
657 }
658
659 void QDeclarativeVector4DValueType::setZ(qreal z)
660 {
661     vector.setZ(z);
662 }
663
664 void QDeclarativeVector4DValueType::setW(qreal w)
665 {
666     vector.setW(w);
667 }
668
669 QDeclarativeQuaternionValueType::QDeclarativeQuaternionValueType(QObject *parent)
670 : QDeclarativeValueType(parent)
671 {
672 }
673
674 void QDeclarativeQuaternionValueType::read(QObject *obj, int idx)
675 {
676     void *a[] = { &quaternion, 0 };
677     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
678 }
679
680 void QDeclarativeQuaternionValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
681 {
682     int status = -1;
683     void *a[] = { &quaternion, 0, &status, &flags };
684     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
685 }
686
687 QVariant  QDeclarativeQuaternionValueType::value()
688 {
689     return QVariant(quaternion);
690 }
691
692 void QDeclarativeQuaternionValueType::setValue(QVariant value)
693 {
694     quaternion = qvariant_cast<QQuaternion>(value);
695 }
696
697 qreal QDeclarativeQuaternionValueType::scalar() const
698 {
699     return quaternion.scalar();
700 }
701
702 qreal QDeclarativeQuaternionValueType::x() const
703 {
704     return quaternion.x();
705 }
706
707 qreal QDeclarativeQuaternionValueType::y() const
708 {
709     return quaternion.y();
710 }
711
712 qreal QDeclarativeQuaternionValueType::z() const
713 {
714     return quaternion.z();
715 }
716
717 void QDeclarativeQuaternionValueType::setScalar(qreal scalar)
718 {
719     quaternion.setScalar(scalar);
720 }
721
722 void QDeclarativeQuaternionValueType::setX(qreal x)
723 {
724     quaternion.setX(x);
725 }
726
727 void QDeclarativeQuaternionValueType::setY(qreal y)
728 {
729     quaternion.setY(y);
730 }
731
732 void QDeclarativeQuaternionValueType::setZ(qreal z)
733 {
734     quaternion.setZ(z);
735 }
736
737 QDeclarativeMatrix4x4ValueType::QDeclarativeMatrix4x4ValueType(QObject *parent)
738 : QDeclarativeValueType(parent)
739 {
740 }
741
742 void QDeclarativeMatrix4x4ValueType::read(QObject *obj, int idx)
743 {
744     void *a[] = { &matrix, 0 };
745     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
746 }
747
748 void QDeclarativeMatrix4x4ValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
749 {
750     int status = -1;
751     void *a[] = { &matrix, 0, &status, &flags };
752     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
753 }
754
755 QVariant  QDeclarativeMatrix4x4ValueType::value()
756 {
757     return QVariant(matrix);
758 }
759
760 void QDeclarativeMatrix4x4ValueType::setValue(QVariant value)
761 {
762     matrix = qvariant_cast<QMatrix4x4>(value);
763 }
764
765 QDeclarativeEasingValueType::QDeclarativeEasingValueType(QObject *parent)
766 : QDeclarativeValueType(parent)
767 {
768 }
769
770 void QDeclarativeEasingValueType::read(QObject *obj, int idx)
771 {
772     void *a[] = { &easing, 0 };
773     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
774 }
775
776 void QDeclarativeEasingValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
777 {
778     int status = -1;
779     void *a[] = { &easing, 0, &status, &flags };
780     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
781 }
782
783 QVariant QDeclarativeEasingValueType::value()
784 {
785     return QVariant(easing);
786 }
787
788 void QDeclarativeEasingValueType::setValue(QVariant value)
789 {
790     easing = qvariant_cast<QEasingCurve>(value);
791 }
792
793 QDeclarativeEasingValueType::Type QDeclarativeEasingValueType::type() const
794 {
795     return (QDeclarativeEasingValueType::Type)easing.type();
796 }
797
798 qreal QDeclarativeEasingValueType::amplitude() const
799 {
800     return easing.amplitude();
801 }
802
803 qreal QDeclarativeEasingValueType::overshoot() const
804 {
805     return easing.overshoot();
806 }
807
808 qreal QDeclarativeEasingValueType::period() const
809 {
810     return easing.period();
811 }
812
813 void QDeclarativeEasingValueType::setType(QDeclarativeEasingValueType::Type type)
814 {
815     easing.setType((QEasingCurve::Type)type);
816 }
817
818 void QDeclarativeEasingValueType::setAmplitude(qreal amplitude)
819 {
820     easing.setAmplitude(amplitude);
821 }
822
823 void QDeclarativeEasingValueType::setOvershoot(qreal overshoot)
824 {
825     easing.setOvershoot(overshoot);
826 }
827
828 void QDeclarativeEasingValueType::setPeriod(qreal period)
829 {
830     easing.setPeriod(period);
831 }
832
833 QDeclarativeFontValueType::QDeclarativeFontValueType(QObject *parent)
834 : QDeclarativeValueType(parent), pixelSizeSet(false), pointSizeSet(false)
835 {
836 }
837
838 void QDeclarativeFontValueType::read(QObject *obj, int idx)
839 {
840     void *a[] = { &font, 0 };
841     QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
842     pixelSizeSet = false;
843     pointSizeSet = false;
844 }
845
846 void QDeclarativeFontValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
847 {
848     int status = -1;
849     void *a[] = { &font, 0, &status, &flags };
850     QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
851 }
852
853 QVariant  QDeclarativeFontValueType::value()
854 {
855     return QVariant(font);
856 }
857
858 void QDeclarativeFontValueType::setValue(QVariant value)
859 {
860     font = qvariant_cast<QFont>(value);
861 }
862
863
864 QString QDeclarativeFontValueType::family() const
865 {
866     return font.family();
867 }
868
869 void QDeclarativeFontValueType::setFamily(const QString &family)
870 {
871     font.setFamily(family);
872 }
873
874 bool QDeclarativeFontValueType::bold() const
875 {
876     return font.bold();
877 }
878
879 void QDeclarativeFontValueType::setBold(bool b)
880 {
881     font.setBold(b);
882 }
883
884 QDeclarativeFontValueType::FontWeight QDeclarativeFontValueType::weight() const
885 {
886     return (QDeclarativeFontValueType::FontWeight)font.weight();
887 }
888
889 void QDeclarativeFontValueType::setWeight(QDeclarativeFontValueType::FontWeight w)
890 {
891     font.setWeight((QFont::Weight)w);
892 }
893
894 bool QDeclarativeFontValueType::italic() const
895 {
896     return font.italic();
897 }
898
899 void QDeclarativeFontValueType::setItalic(bool b)
900 {
901     font.setItalic(b);
902 }
903
904 bool QDeclarativeFontValueType::underline() const
905 {
906     return font.underline();
907 }
908
909 void QDeclarativeFontValueType::setUnderline(bool b)
910 {
911     font.setUnderline(b);
912 }
913
914 bool QDeclarativeFontValueType::overline() const
915 {
916     return font.overline();
917 }
918
919 void QDeclarativeFontValueType::setOverline(bool b)
920 {
921     font.setOverline(b);
922 }
923
924 bool QDeclarativeFontValueType::strikeout() const
925 {
926     return font.strikeOut();
927 }
928
929 void QDeclarativeFontValueType::setStrikeout(bool b)
930 {
931     font.setStrikeOut(b);
932 }
933
934 qreal QDeclarativeFontValueType::pointSize() const
935 {
936     if (font.pointSizeF() == -1) {
937         if (dpi.isNull)
938             dpi = qt_defaultDpi();
939         return font.pixelSize() * qreal(72.) / qreal(dpi);
940     }
941     return font.pointSizeF();
942 }
943
944 void QDeclarativeFontValueType::setPointSize(qreal size)
945 {
946     if (pixelSizeSet) {
947         qWarning() << "Both point size and pixel size set. Using pixel size.";
948         return;
949     }
950
951     if (size >= 0.0) {
952         pointSizeSet = true;
953         font.setPointSizeF(size);
954     } else {
955         pointSizeSet = false;
956     }
957 }
958
959 int QDeclarativeFontValueType::pixelSize() const
960 {
961     if (font.pixelSize() == -1) {
962         if (dpi.isNull)
963             dpi = qt_defaultDpi();
964         return (font.pointSizeF() * dpi) / qreal(72.);
965     }
966     return font.pixelSize();
967 }
968
969 void QDeclarativeFontValueType::setPixelSize(int size)
970 {
971     if (size >0) {
972         if (pointSizeSet)
973             qWarning() << "Both point size and pixel size set. Using pixel size.";
974         font.setPixelSize(size);
975         pixelSizeSet = true;
976     } else {
977         pixelSizeSet = false;
978     }
979 }
980
981 QDeclarativeFontValueType::Capitalization QDeclarativeFontValueType::capitalization() const
982 {
983     return (QDeclarativeFontValueType::Capitalization)font.capitalization();
984 }
985
986 void QDeclarativeFontValueType::setCapitalization(QDeclarativeFontValueType::Capitalization c)
987 {
988     font.setCapitalization((QFont::Capitalization)c);
989 }
990
991 qreal QDeclarativeFontValueType::letterSpacing() const
992 {
993     return font.letterSpacing();
994 }
995
996 void QDeclarativeFontValueType::setLetterSpacing(qreal size)
997 {
998     font.setLetterSpacing(QFont::AbsoluteSpacing, size);
999 }
1000
1001 qreal QDeclarativeFontValueType::wordSpacing() const
1002 {
1003     return font.wordSpacing();
1004 }
1005
1006 void QDeclarativeFontValueType::setWordSpacing(qreal size)
1007 {
1008     font.setWordSpacing(size);
1009 }
1010
1011 QT_END_NAMESPACE