Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativevaluetype.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qdeclarativevaluetype_p.h"
43
44 #include "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             && idx != QVariant::StringList
97             && idx != QMetaType::QObjectStar
98             && idx != QMetaType::QWidgetStar
99             && idx != QMetaType::VoidStar
100             && idx != QMetaType::QVariant) {
101         return true;
102     }
103     return false;
104 }
105
106 void QDeclarativeValueTypeFactory::registerBaseTypes(const char *uri, int versionMajor, int versionMinor)
107 {
108     qmlRegisterValueTypeEnums<QDeclarativeEasingValueType>(uri, versionMajor, versionMinor, "Easing");
109     qmlRegisterValueTypeEnums<QDeclarativeFontValueType>(uri, versionMajor, versionMinor, "Font");
110 }
111
112 void QDeclarativeValueTypeFactory::registerValueTypes()
113 {
114     registerBaseTypes("QtQuick", 2, 0);
115 }
116
117 QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
118 {
119     QDeclarativeValueType *rv = 0;
120
121     switch (t) {
122     case QVariant::Point:
123         rv = new QDeclarativePointValueType;
124         break;
125     case QVariant::PointF:
126         rv = new QDeclarativePointFValueType;
127         break;
128     case QVariant::Size:
129         rv = new QDeclarativeSizeValueType;
130         break;
131     case QVariant::SizeF:
132         rv = new QDeclarativeSizeFValueType;
133         break;
134     case QVariant::Rect:
135         rv = new QDeclarativeRectValueType;
136         break;
137     case QVariant::RectF:
138         rv = new QDeclarativeRectFValueType;
139         break;
140     case QVariant::Vector2D:
141         rv = new QDeclarativeVector2DValueType;
142         break;
143     case QVariant::Vector3D:
144         rv = new QDeclarativeVector3DValueType;
145         break;
146     case QVariant::Vector4D:
147         rv = new QDeclarativeVector4DValueType;
148         break;
149     case QVariant::Quaternion:
150         rv = new QDeclarativeQuaternionValueType;
151         break;
152     case QVariant::Matrix4x4:
153         rv = new QDeclarativeMatrix4x4ValueType;
154         break;
155     case QVariant::EasingCurve:
156         rv = new QDeclarativeEasingValueType;
157         break;
158     case QVariant::Font:
159         rv = new QDeclarativeFontValueType;
160         break;
161     case QVariant::Color:
162         rv = new QDeclarativeColorValueType;
163         break;
164     default:
165         break;
166     }
167
168     Q_ASSERT(!rv || rv->metaObject()->propertyCount() < 32);
169     return rv;
170 }
171
172 QDeclarativeValueType::QDeclarativeValueType(QObject *parent)
173 : QObject(parent)
174 {
175 }
176
177 #define QML_VALUETYPE_READWRITE(name, cpptype, var) \
178     QDeclarative ## name ## ValueType::QDeclarative ## name ## ValueType(QObject *parent) \
179     : QDeclarativeValueType(parent) \
180     { \
181     } \
182     void QDeclarative ## name ## ValueType::read(QObject *obj, int idx) \
183     { \
184         void *a[] = { &var, 0 }; \
185         QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); \
186         onLoad(); \
187     } \
188     void QDeclarative ## name ## ValueType::write(QObject *obj, int idx, \
189                                                   QDeclarativePropertyPrivate::WriteFlags flags) \
190     { \
191         int status = -1; \
192         void *a[] = { &var, 0, &status, &flags }; \
193         QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); \
194     } \
195     bool QDeclarative ## name ## ValueType::isEqual(const QVariant &value) const \
196     { \
197         return QVariant(var) == value; \
198     } \
199     QVariant QDeclarative ## name ## ValueType::value() \
200     { \
201         return QVariant(var); \
202     } \
203     void QDeclarative ## name ## ValueType::setValue(const QVariant &value) \
204     { \
205         var = qvariant_cast<cpptype>(value); \
206         onLoad(); \
207     }
208
209 QML_VALUETYPE_READWRITE(PointF, QPointF, point);
210 QML_VALUETYPE_READWRITE(Point, QPoint, point);
211 QML_VALUETYPE_READWRITE(SizeF, QSizeF, size);
212 QML_VALUETYPE_READWRITE(Size, QSize, size);
213 QML_VALUETYPE_READWRITE(RectF, QRectF, rect);
214 QML_VALUETYPE_READWRITE(Rect, QRect, rect);
215 QML_VALUETYPE_READWRITE(Vector2D, QVector2D, vector);
216 QML_VALUETYPE_READWRITE(Vector3D, QVector3D, vector);
217 QML_VALUETYPE_READWRITE(Vector4D, QVector4D, vector);
218 QML_VALUETYPE_READWRITE(Quaternion, QQuaternion, quaternion);
219 QML_VALUETYPE_READWRITE(Matrix4x4, QMatrix4x4, matrix);
220 QML_VALUETYPE_READWRITE(Easing, QEasingCurve, easing);
221 QML_VALUETYPE_READWRITE(Font, QFont, font);
222 QML_VALUETYPE_READWRITE(Color, QColor, color);
223
224 QString QDeclarativePointFValueType::toString() const
225 {
226     return QString(QLatin1String("QPointF(%1, %2)")).arg(point.x()).arg(point.y());
227 }
228
229 qreal QDeclarativePointFValueType::x() const
230 {
231     return point.x();
232 }
233
234 qreal QDeclarativePointFValueType::y() const
235 {
236     return point.y();
237 }
238
239 void QDeclarativePointFValueType::setX(qreal x)
240 {
241     point.setX(x);
242 }
243
244 void QDeclarativePointFValueType::setY(qreal y)
245 {
246     point.setY(y);
247 }
248
249 QString QDeclarativePointValueType::toString() const
250 {
251     return QString(QLatin1String("QPoint(%1, %2)")).arg(point.x()).arg(point.y());
252 }
253
254 int QDeclarativePointValueType::x() const
255 {
256     return point.x();
257 }
258
259 int QDeclarativePointValueType::y() const
260 {
261     return point.y();
262 }
263
264 void QDeclarativePointValueType::setX(int x)
265 {
266     point.setX(x);
267 }
268
269 void QDeclarativePointValueType::setY(int y)
270 {
271     point.setY(y);
272 }
273
274 QString QDeclarativeSizeFValueType::toString() const
275 {
276     return QString(QLatin1String("QSizeF(%1, %2)")).arg(size.width()).arg(size.height());
277 }
278
279 qreal QDeclarativeSizeFValueType::width() const
280 {
281     return size.width();
282 }
283
284 qreal QDeclarativeSizeFValueType::height() const
285 {
286     return size.height();
287 }
288
289 void QDeclarativeSizeFValueType::setWidth(qreal w)
290 {
291     size.setWidth(w);
292 }
293
294 void QDeclarativeSizeFValueType::setHeight(qreal h)
295 {
296     size.setHeight(h);
297 }
298
299 QString QDeclarativeSizeValueType::toString() const
300 {
301     return QString(QLatin1String("QSize(%1, %2)")).arg(size.width()).arg(size.height());
302 }
303
304 int QDeclarativeSizeValueType::width() const
305 {
306     return size.width();
307 }
308
309 int QDeclarativeSizeValueType::height() const
310 {
311     return size.height();
312 }
313
314 void QDeclarativeSizeValueType::setWidth(int w)
315 {
316     size.setWidth(w);
317 }
318
319 void QDeclarativeSizeValueType::setHeight(int h)
320 {
321     size.setHeight(h);
322 }
323
324 QString QDeclarativeRectFValueType::toString() const
325 {
326     return QString(QLatin1String("QRectF(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
327 }
328
329 qreal QDeclarativeRectFValueType::x() const
330 {
331     return rect.x();
332 }
333
334 qreal QDeclarativeRectFValueType::y() const
335 {
336     return rect.y();
337 }
338
339 void QDeclarativeRectFValueType::setX(qreal x)
340 {
341     rect.moveLeft(x);
342 }
343
344 void QDeclarativeRectFValueType::setY(qreal y)
345 {
346     rect.moveTop(y);
347 }
348
349 qreal QDeclarativeRectFValueType::width() const
350 {
351     return rect.width();
352 }
353
354 qreal QDeclarativeRectFValueType::height() const
355 {
356     return rect.height();
357 }
358
359 void QDeclarativeRectFValueType::setWidth(qreal w)
360 {
361     rect.setWidth(w);
362 }
363
364 void QDeclarativeRectFValueType::setHeight(qreal h)
365 {
366     rect.setHeight(h);
367 }
368
369 QString QDeclarativeRectValueType::toString() const
370 {
371     return QString(QLatin1String("QRect(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
372 }
373
374 int QDeclarativeRectValueType::x() const
375 {
376     return rect.x();
377 }
378
379 int QDeclarativeRectValueType::y() const
380 {
381     return rect.y();
382 }
383
384 void QDeclarativeRectValueType::setX(int x)
385 {
386     rect.moveLeft(x);
387 }
388
389 void QDeclarativeRectValueType::setY(int y)
390 {
391     rect.moveTop(y);
392 }
393
394 int QDeclarativeRectValueType::width() const
395 {
396     return rect.width();
397 }
398
399 int QDeclarativeRectValueType::height() const
400 {
401     return rect.height();
402 }
403
404 void QDeclarativeRectValueType::setWidth(int w)
405 {
406     rect.setWidth(w);
407 }
408
409 void QDeclarativeRectValueType::setHeight(int h)
410 {
411     rect.setHeight(h);
412 }
413
414 QString QDeclarativeVector2DValueType::toString() const
415 {
416     return QString(QLatin1String("QVector2D(%1, %2)")).arg(vector.x()).arg(vector.y());
417 }
418
419 qreal QDeclarativeVector2DValueType::x() const
420 {
421     return vector.x();
422 }
423
424 qreal QDeclarativeVector2DValueType::y() const
425 {
426     return vector.y();
427 }
428
429 void QDeclarativeVector2DValueType::setX(qreal x)
430 {
431     vector.setX(x);
432 }
433
434 void QDeclarativeVector2DValueType::setY(qreal y)
435 {
436     vector.setY(y);
437 }
438
439 QString QDeclarativeVector3DValueType::toString() const
440 {
441     return QString(QLatin1String("QVector3D(%1, %2, %3)")).arg(vector.x()).arg(vector.y()).arg(vector.z());
442 }
443
444 qreal QDeclarativeVector3DValueType::x() const
445 {
446     return vector.x();
447 }
448
449 qreal QDeclarativeVector3DValueType::y() const
450 {
451     return vector.y();
452 }
453
454 qreal QDeclarativeVector3DValueType::z() const
455 {
456     return vector.z();
457 }
458
459 void QDeclarativeVector3DValueType::setX(qreal x)
460 {
461     vector.setX(x);
462 }
463
464 void QDeclarativeVector3DValueType::setY(qreal y)
465 {
466     vector.setY(y);
467 }
468
469 void QDeclarativeVector3DValueType::setZ(qreal z)
470 {
471     vector.setZ(z);
472 }
473
474 QString QDeclarativeVector4DValueType::toString() const
475 {
476     return QString(QLatin1String("QVector4D(%1, %2, %3, %4)")).arg(vector.x()).arg(vector.y()).arg(vector.z()).arg(vector.w());
477 }
478
479 qreal QDeclarativeVector4DValueType::x() const
480 {
481     return vector.x();
482 }
483
484 qreal QDeclarativeVector4DValueType::y() const
485 {
486     return vector.y();
487 }
488
489 qreal QDeclarativeVector4DValueType::z() const
490 {
491     return vector.z();
492 }
493
494 qreal QDeclarativeVector4DValueType::w() const
495 {
496     return vector.w();
497 }
498
499 void QDeclarativeVector4DValueType::setX(qreal x)
500 {
501     vector.setX(x);
502 }
503
504 void QDeclarativeVector4DValueType::setY(qreal y)
505 {
506     vector.setY(y);
507 }
508
509 void QDeclarativeVector4DValueType::setZ(qreal z)
510 {
511     vector.setZ(z);
512 }
513
514 void QDeclarativeVector4DValueType::setW(qreal w)
515 {
516     vector.setW(w);
517 }
518
519 QString QDeclarativeQuaternionValueType::toString() const
520 {
521     return QString(QLatin1String("QQuaternion(%1, %2, %3, %4)")).arg(quaternion.scalar()).arg(quaternion.x()).arg(quaternion.y()).arg(quaternion.z());
522 }
523
524 qreal QDeclarativeQuaternionValueType::scalar() const
525 {
526     return quaternion.scalar();
527 }
528
529 qreal QDeclarativeQuaternionValueType::x() const
530 {
531     return quaternion.x();
532 }
533
534 qreal QDeclarativeQuaternionValueType::y() const
535 {
536     return quaternion.y();
537 }
538
539 qreal QDeclarativeQuaternionValueType::z() const
540 {
541     return quaternion.z();
542 }
543
544 void QDeclarativeQuaternionValueType::setScalar(qreal scalar)
545 {
546     quaternion.setScalar(scalar);
547 }
548
549 void QDeclarativeQuaternionValueType::setX(qreal x)
550 {
551     quaternion.setX(x);
552 }
553
554 void QDeclarativeQuaternionValueType::setY(qreal y)
555 {
556     quaternion.setY(y);
557 }
558
559 void QDeclarativeQuaternionValueType::setZ(qreal z)
560 {
561     quaternion.setZ(z);
562 }
563
564 QString QDeclarativeMatrix4x4ValueType::toString() const
565 {
566     return QString(QLatin1String("QMatrix4x4(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16)"))
567             .arg(matrix(0, 0)).arg(matrix(0, 1)).arg(matrix(0, 2)).arg(matrix(0, 3))
568             .arg(matrix(1, 0)).arg(matrix(1, 1)).arg(matrix(1, 2)).arg(matrix(1, 3))
569             .arg(matrix(2, 0)).arg(matrix(2, 1)).arg(matrix(2, 2)).arg(matrix(2, 3))
570             .arg(matrix(3, 0)).arg(matrix(3, 1)).arg(matrix(3, 2)).arg(matrix(3, 3));
571 }
572
573 QString QDeclarativeEasingValueType::toString() const
574 {
575     return QString(QLatin1String("QEasingCurve(%1, %2, %3, %4)")).arg(easing.type()).arg(easing.amplitude()).arg(easing.overshoot()).arg(easing.period());
576 }
577
578 QDeclarativeEasingValueType::Type QDeclarativeEasingValueType::type() const
579 {
580     return (QDeclarativeEasingValueType::Type)easing.type();
581 }
582
583 qreal QDeclarativeEasingValueType::amplitude() const
584 {
585     return easing.amplitude();
586 }
587
588 qreal QDeclarativeEasingValueType::overshoot() const
589 {
590     return easing.overshoot();
591 }
592
593 qreal QDeclarativeEasingValueType::period() const
594 {
595     return easing.period();
596 }
597
598 void QDeclarativeEasingValueType::setType(QDeclarativeEasingValueType::Type type)
599 {
600     easing.setType((QEasingCurve::Type)type);
601 }
602
603 void QDeclarativeEasingValueType::setAmplitude(qreal amplitude)
604 {
605     easing.setAmplitude(amplitude);
606 }
607
608 void QDeclarativeEasingValueType::setOvershoot(qreal overshoot)
609 {
610     easing.setOvershoot(overshoot);
611 }
612
613 void QDeclarativeEasingValueType::setPeriod(qreal period)
614 {
615     easing.setPeriod(period);
616 }
617
618 void QDeclarativeEasingValueType::setBezierCurve(const QVariantList &customCurveVariant)
619 {
620     if (customCurveVariant.isEmpty())
621         return;
622
623     QVariantList variantList = customCurveVariant;
624     if ((variantList.count() % 6) == 0) {
625         bool allRealsOk = true;
626         QList<qreal> reals;
627         for (int i = 0; i < variantList.count(); i++) {
628             bool ok;
629             const qreal real = variantList.at(i).toReal(&ok);
630             reals.append(real);
631             if (!ok)
632                 allRealsOk = false;
633         }
634         if (allRealsOk) {
635             QEasingCurve newEasingCurve(QEasingCurve::BezierSpline);
636             for (int i = 0; i < reals.count() / 6; i++) {
637                 const qreal c1x = reals.at(i * 6);
638                 const qreal c1y = reals.at(i * 6 + 1);
639                 const qreal c2x = reals.at(i * 6 + 2);
640                 const qreal c2y = reals.at(i * 6 + 3);
641                 const qreal c3x = reals.at(i * 6 + 4);
642                 const qreal c3y = reals.at(i * 6 + 5);
643
644                 const QPointF c1(c1x, c1y);
645                 const QPointF c2(c2x, c2y);
646                 const QPointF c3(c3x, c3y);
647
648                 newEasingCurve.addCubicBezierSegment(c1, c2, c3);
649                 easing = newEasingCurve;
650             }
651         }
652     }
653 }
654
655 QVariantList QDeclarativeEasingValueType::bezierCurve() const
656 {
657     QVariantList rv;
658     QList<QPointF> points = easing.cubicBezierSpline();
659     for (int ii = 0; ii < points.count(); ++ii)
660         rv << QVariant(points.at(ii).x()) << QVariant(points.at(ii).y());
661     return rv;
662 }
663
664 void QDeclarativeFontValueType::onLoad()
665 {
666     pixelSizeSet = false;
667     pointSizeSet = false;
668 }
669
670 QString QDeclarativeFontValueType::toString() const
671 {
672     return QString(QLatin1String("QFont(%1)")).arg(font.toString());
673 }
674
675 QString QDeclarativeFontValueType::family() const
676 {
677     return font.family();
678 }
679
680 void QDeclarativeFontValueType::setFamily(const QString &family)
681 {
682     font.setFamily(family);
683 }
684
685 bool QDeclarativeFontValueType::bold() const
686 {
687     return font.bold();
688 }
689
690 void QDeclarativeFontValueType::setBold(bool b)
691 {
692     font.setBold(b);
693 }
694
695 QDeclarativeFontValueType::FontWeight QDeclarativeFontValueType::weight() const
696 {
697     return (QDeclarativeFontValueType::FontWeight)font.weight();
698 }
699
700 void QDeclarativeFontValueType::setWeight(QDeclarativeFontValueType::FontWeight w)
701 {
702     font.setWeight((QFont::Weight)w);
703 }
704
705 bool QDeclarativeFontValueType::italic() const
706 {
707     return font.italic();
708 }
709
710 void QDeclarativeFontValueType::setItalic(bool b)
711 {
712     font.setItalic(b);
713 }
714
715 bool QDeclarativeFontValueType::underline() const
716 {
717     return font.underline();
718 }
719
720 void QDeclarativeFontValueType::setUnderline(bool b)
721 {
722     font.setUnderline(b);
723 }
724
725 bool QDeclarativeFontValueType::overline() const
726 {
727     return font.overline();
728 }
729
730 void QDeclarativeFontValueType::setOverline(bool b)
731 {
732     font.setOverline(b);
733 }
734
735 bool QDeclarativeFontValueType::strikeout() const
736 {
737     return font.strikeOut();
738 }
739
740 void QDeclarativeFontValueType::setStrikeout(bool b)
741 {
742     font.setStrikeOut(b);
743 }
744
745 qreal QDeclarativeFontValueType::pointSize() const
746 {
747     if (font.pointSizeF() == -1) {
748         if (dpi.isNull)
749             dpi = qt_defaultDpi();
750         return font.pixelSize() * qreal(72.) / qreal(dpi);
751     }
752     return font.pointSizeF();
753 }
754
755 void QDeclarativeFontValueType::setPointSize(qreal size)
756 {
757     if (pixelSizeSet) {
758         qWarning() << "Both point size and pixel size set. Using pixel size.";
759         return;
760     }
761
762     if (size >= 0.0) {
763         pointSizeSet = true;
764         font.setPointSizeF(size);
765     } else {
766         pointSizeSet = false;
767     }
768 }
769
770 int QDeclarativeFontValueType::pixelSize() const
771 {
772     if (font.pixelSize() == -1) {
773         if (dpi.isNull)
774             dpi = qt_defaultDpi();
775         return (font.pointSizeF() * dpi) / qreal(72.);
776     }
777     return font.pixelSize();
778 }
779
780 void QDeclarativeFontValueType::setPixelSize(int size)
781 {
782     if (size >0) {
783         if (pointSizeSet)
784             qWarning() << "Both point size and pixel size set. Using pixel size.";
785         font.setPixelSize(size);
786         pixelSizeSet = true;
787     } else {
788         pixelSizeSet = false;
789     }
790 }
791
792 QDeclarativeFontValueType::Capitalization QDeclarativeFontValueType::capitalization() const
793 {
794     return (QDeclarativeFontValueType::Capitalization)font.capitalization();
795 }
796
797 void QDeclarativeFontValueType::setCapitalization(QDeclarativeFontValueType::Capitalization c)
798 {
799     font.setCapitalization((QFont::Capitalization)c);
800 }
801
802 qreal QDeclarativeFontValueType::letterSpacing() const
803 {
804     return font.letterSpacing();
805 }
806
807 void QDeclarativeFontValueType::setLetterSpacing(qreal size)
808 {
809     font.setLetterSpacing(QFont::AbsoluteSpacing, size);
810 }
811
812 qreal QDeclarativeFontValueType::wordSpacing() const
813 {
814     return font.wordSpacing();
815 }
816
817 void QDeclarativeFontValueType::setWordSpacing(qreal size)
818 {
819     font.setWordSpacing(size);
820 }
821
822 QString QDeclarativeColorValueType::toString() const
823 {
824     // special case - to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
825     return QVariant(color).toString();
826 }
827
828 qreal QDeclarativeColorValueType::r() const
829 {
830     return color.redF();
831 }
832
833 qreal QDeclarativeColorValueType::g() const
834 {
835     return color.greenF();
836 }
837
838 qreal QDeclarativeColorValueType::b() const
839 {
840     return color.blueF();
841 }
842
843 qreal QDeclarativeColorValueType::a() const
844 {
845     return color.alphaF();
846 }
847
848 void QDeclarativeColorValueType::setR(qreal r)
849 {
850     color.setRedF(r);
851 }
852
853 void QDeclarativeColorValueType::setG(qreal g)
854 {
855     color.setGreenF(g);
856 }
857
858 void QDeclarativeColorValueType::setB(qreal b)
859 {
860     color.setBlueF(b);
861 }
862
863 void QDeclarativeColorValueType::setA(qreal a)
864 {
865     color.setAlphaF(a);
866 }
867
868 QT_END_NAMESPACE