Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativeecmascript / testtypes.h
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 test suite 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 #ifndef TESTTYPES_H
42 #define TESTTYPES_H
43
44 #include <QtCore/qobject.h>
45 #include <QtDeclarative/qdeclarative.h>
46 #include <QtDeclarative/qdeclarativeexpression.h>
47 #include <QtCore/qpoint.h>
48 #include <QtCore/qsize.h>
49 #include <QtDeclarative/qdeclarativelist.h>
50 #include <QtCore/qrect.h>
51 #include <QtGui/qmatrix.h>
52 #include <QtGui/qcolor.h>
53 #include <QtGui/qvector3d.h>
54 #include <QtGui/QPixmap>
55 #include <QtCore/qdatetime.h>
56 #include <QtDeclarative/qjsvalue.h>
57 #include <QtDeclarative/qdeclarativescriptstring.h>
58 #include <QtDeclarative/qdeclarativecomponent.h>
59
60 #include <private/qdeclarativeengine_p.h>
61 #include <private/qv8engine_p.h>
62
63 class MyQmlAttachedObject : public QObject
64 {
65     Q_OBJECT
66     Q_PROPERTY(int value READ value CONSTANT)
67     Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
68 public:
69     MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
70
71     int value() const { return 19; }
72     int value2() const { return m_value2; }
73     void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
74
75     void emitMySignal() { emit mySignal(); }
76
77 signals:
78     void value2Changed();
79     void mySignal();
80
81 private:
82     int m_value2;
83 };
84
85 class MyQmlObject : public QObject
86 {
87     Q_OBJECT
88     Q_ENUMS(MyEnum)
89     Q_ENUMS(MyEnum2)
90     Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
91     Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
92     Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
93     Q_PROPERTY(int value READ value WRITE setValue)
94     Q_PROPERTY(int console READ console CONSTANT)
95     Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
96     Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlChanged)
97     Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
98     Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
99     Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
100     Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
101     Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false)
102     Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged)
103
104 public:
105     MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0) {}
106
107     enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
108     enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
109
110     bool trueProperty() const { return true; }
111     bool falseProperty() const { return false; }
112
113     QString stringProperty() const { return m_string; }
114     void setStringProperty(const QString &s)
115     {
116         if (s == m_string)
117             return;
118         m_string = s;
119         emit stringChanged();
120     }
121
122     QUrl urlProperty() const { return m_url; }
123     void setUrlProperty(const QUrl &url)
124     {
125         if (url == m_url)
126             return;
127         m_url = url;
128         emit urlChanged();
129     }
130
131     QObject *objectProperty() const { return m_object; }
132     void setObjectProperty(QObject *obj) { 
133         if (obj == m_object)
134             return;
135         m_object = obj;
136         emit objectChanged();
137     }
138
139     QDeclarativeListProperty<QObject> objectListProperty() { return QDeclarativeListProperty<QObject>(this, m_objectQList); }
140
141     bool methodCalled() const { return m_methodCalled; }
142     bool methodIntCalled() const { return m_methodIntCalled; }
143
144     QString string() const { return m_string; }
145
146     static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
147         return new MyQmlAttachedObject(o);
148     }
149
150     int deleteOnSet() const { return 1; }
151     void setDeleteOnSet(int v) { if(v) delete this; }
152
153     int value() const { return m_value; }
154     void setValue(int v) { m_value = v; }
155
156     int resettableProperty() const { return m_resetProperty; }
157     void setResettableProperty(int v) { m_resetProperty = v; }
158     void resetProperty() { m_resetProperty = 13; }
159
160     QRegExp regExp() { return m_regExp; }
161     void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
162
163     int console() const { return 11; }
164
165     int nonscriptable() const { return 0; }
166     void setNonscriptable(int) {}
167
168     MyQmlObject *myinvokableObject;
169     Q_INVOKABLE MyQmlObject *returnme() { return this; }
170
171     struct MyType {
172         int value;
173     };
174     QVariant variant() const { return m_variant; }
175     QJSValue qjsvalue() const { return m_qjsvalue; }
176
177     int intProperty() const { return m_intProperty; }
178     void setIntProperty(int i) { m_intProperty = i; emit intChanged(); }
179     
180 signals:
181     void basicSignal();
182     void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
183     void stringChanged();
184     void urlChanged();
185     void objectChanged();
186     void anotherBasicSignal();
187     void thirdBasicSignal();
188     void signalWithUnknownType(const MyQmlObject::MyType &arg);
189     void signalWithVariant(const QVariant &arg);
190     void signalWithQJSValue(const QJSValue &arg);
191     void intChanged();
192
193 public slots:
194     void deleteMe() { delete this; }
195     void methodNoArgs() { m_methodCalled = true; }
196     void method(int a) { if(a == 163) m_methodIntCalled = true; }
197     void setString(const QString &s) { m_string = s; }
198     void myinvokable(MyQmlObject *o) { myinvokableObject = o; }
199     void variantMethod(const QVariant &v) { m_variant = v; }
200     void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; }
201     void v8function(QDeclarativeV8Function*);
202
203 private:
204     friend class tst_qdeclarativeecmascript;
205     bool m_methodCalled;
206     bool m_methodIntCalled;
207
208     QObject *m_object;
209     QString m_string;
210     QUrl m_url;
211     QList<QObject *> m_objectQList;
212     int m_value;
213     int m_resetProperty;
214     QRegExp m_regExp;
215     QVariant m_variant;
216     QJSValue m_qjsvalue;
217     int m_intProperty;
218 };
219
220 QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
221
222 class MyQmlContainer : public QObject
223 {
224     Q_OBJECT
225     Q_PROPERTY(QDeclarativeListProperty<MyQmlObject> children READ children CONSTANT)
226 public:
227     MyQmlContainer() {}
228
229     QDeclarativeListProperty<MyQmlObject> children() { return QDeclarativeListProperty<MyQmlObject>(this, m_children); }
230
231 private:
232     QList<MyQmlObject*> m_children;
233 };
234
235
236 class MyExpression : public QDeclarativeExpression
237 {
238     Q_OBJECT
239 public:
240     MyExpression(QDeclarativeContext *ctxt, const QString &expr)
241         : QDeclarativeExpression(ctxt, 0, expr), changed(false)
242     {
243         QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged()));
244         setNotifyOnValueChanged(true);
245     }
246
247     bool changed;
248
249 public slots:
250     void expressionValueChanged() {
251         changed = true;
252     }
253 };
254
255
256 class MyDefaultObject1 : public QObject
257 {
258     Q_OBJECT
259     Q_PROPERTY(int horseLegs READ horseLegs CONSTANT)
260     Q_PROPERTY(int antLegs READ antLegs CONSTANT)
261     Q_PROPERTY(int emuLegs READ emuLegs CONSTANT)
262 public:
263     int horseLegs() const { return 4; }
264     int antLegs() const { return 6; }
265     int emuLegs() const { return 2; }
266 };
267
268 class MyDefaultObject3 : public QObject
269 {
270     Q_OBJECT
271     Q_PROPERTY(int antLegs READ antLegs CONSTANT)
272     Q_PROPERTY(int humanLegs READ humanLegs CONSTANT)
273 public:
274     int antLegs() const { return 7; } // Mutant
275     int humanLegs() const { return 2; }
276     int millipedeLegs() const { return 1000; }
277 };
278
279 class MyDeferredObject : public QObject
280 {
281     Q_OBJECT
282     Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
283     Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
284     Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2)
285     Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2")
286
287 public:
288     MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
289
290     int value() const { return m_value; }
291     void setValue(int v) { m_value = v; emit valueChanged(); }
292
293     QObject *objectProperty() const { return m_object; }
294     void setObjectProperty(QObject *obj) { m_object = obj; }
295
296     QObject *objectProperty2() const { return m_object2; }
297     void setObjectProperty2(QObject *obj) { m_object2 = obj; }
298
299 signals:
300     void valueChanged();
301
302 private:
303     int m_value;
304     QObject *m_object;
305     QObject *m_object2;
306 };
307
308 class MyBaseExtendedObject : public QObject
309 {
310 Q_OBJECT
311 Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
312 public:
313     MyBaseExtendedObject() : m_value(0) {}
314
315     int baseProperty() const { return m_value; }
316     void setBaseProperty(int v) { m_value = v; }
317
318 private:
319     int m_value;
320 };
321
322 class MyExtendedObject : public MyBaseExtendedObject
323 {
324 Q_OBJECT
325 Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty)
326 public:
327     MyExtendedObject() : m_value(0) {}
328
329     int coreProperty() const { return m_value; }
330     void setCoreProperty(int v) { m_value = v; }
331
332 private:
333     int m_value;
334 };
335
336 class MyTypeObject : public QObject
337 {
338     Q_OBJECT
339     Q_ENUMS(MyEnum)
340     Q_FLAGS(MyFlags)
341
342     Q_PROPERTY(QString id READ id WRITE setId)
343     Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
344     Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty)
345     Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
346     Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
347     Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
348     Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
349     Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
350     Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
351     Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
352     Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
353     Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
354     Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
355     Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
356     Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
357     Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
358     Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
359     Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
360     Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
361     Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
362     Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
363     Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
364     Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
365     Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
366     Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
367     Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
368
369     Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
370
371 public:
372     MyTypeObject()
373         : objectPropertyValue(0), componentPropertyValue(0) {}
374
375     QString idValue;
376     QString id() const {
377         return idValue;
378     }
379     void setId(const QString &v) {
380         idValue = v;
381     }
382
383     QObject *objectPropertyValue;
384     QObject *objectProperty() const {
385         return objectPropertyValue;
386     }
387     void setObjectProperty(QObject *v) {
388         objectPropertyValue = v;
389     }
390
391     QDeclarativeComponent *componentPropertyValue;
392     QDeclarativeComponent *componentProperty() const {
393         return componentPropertyValue;
394     }
395     void setComponentProperty(QDeclarativeComponent *v) {
396         componentPropertyValue = v;
397     }
398
399     enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
400     Q_DECLARE_FLAGS(MyFlags, MyFlag)
401     MyFlags flagPropertyValue;
402     MyFlags flagProperty() const {
403         return flagPropertyValue;
404     }
405     void setFlagProperty(MyFlags v) {
406         flagPropertyValue = v;
407     }
408
409     enum MyEnum { EnumVal1, EnumVal2 };
410     MyEnum enumPropertyValue;
411     MyEnum enumProperty() const {
412         return enumPropertyValue;
413     }
414     void setEnumProperty(MyEnum v) {
415         enumPropertyValue = v;
416     }
417
418     QString stringPropertyValue;
419     QString stringProperty() const {
420        return stringPropertyValue;
421     }
422     void setStringProperty(const QString &v) {
423         stringPropertyValue = v;
424     }
425
426     uint uintPropertyValue;
427     uint uintProperty() const {
428        return uintPropertyValue;
429     }
430     void setUintProperty(const uint &v) {
431         uintPropertyValue = v;
432     }
433
434     int intPropertyValue;
435     int intProperty() const {
436        return intPropertyValue;
437     }
438     void setIntProperty(const int &v) {
439         intPropertyValue = v;
440     }
441
442     qreal realPropertyValue;
443     qreal realProperty() const {
444        return realPropertyValue;
445     }
446     void setRealProperty(const qreal &v) {
447         realPropertyValue = v;
448     }
449
450     double doublePropertyValue;
451     double doubleProperty() const {
452        return doublePropertyValue;
453     }
454     void setDoubleProperty(const double &v) {
455         doublePropertyValue = v;
456     }
457
458     float floatPropertyValue;
459     float floatProperty() const {
460        return floatPropertyValue;
461     }
462     void setFloatProperty(const float &v) {
463         floatPropertyValue = v;
464     }
465
466     QColor colorPropertyValue;
467     QColor colorProperty() const {
468        return colorPropertyValue;
469     }
470     void setColorProperty(const QColor &v) {
471         colorPropertyValue = v;
472     }
473
474     QDate datePropertyValue;
475     QDate dateProperty() const {
476        return datePropertyValue;
477     }
478     void setDateProperty(const QDate &v) {
479         datePropertyValue = v;
480     }
481
482     QTime timePropertyValue;
483     QTime timeProperty() const {
484        return timePropertyValue;
485     }
486     void setTimeProperty(const QTime &v) {
487         timePropertyValue = v;
488     }
489
490     QDateTime dateTimePropertyValue;
491     QDateTime dateTimeProperty() const {
492        return dateTimePropertyValue;
493     }
494     void setDateTimeProperty(const QDateTime &v) {
495         dateTimePropertyValue = v;
496     }
497
498     QPoint pointPropertyValue;
499     QPoint pointProperty() const {
500        return pointPropertyValue;
501     }
502     void setPointProperty(const QPoint &v) {
503         pointPropertyValue = v;
504     }
505
506     QPointF pointFPropertyValue;
507     QPointF pointFProperty() const {
508        return pointFPropertyValue;
509     }
510     void setPointFProperty(const QPointF &v) {
511         pointFPropertyValue = v;
512     }
513
514     QSize sizePropertyValue;
515     QSize sizeProperty() const {
516        return sizePropertyValue;
517     }
518     void setSizeProperty(const QSize &v) {
519         sizePropertyValue = v;
520     }
521
522     QSizeF sizeFPropertyValue;
523     QSizeF sizeFProperty() const {
524        return sizeFPropertyValue;
525     }
526     void setSizeFProperty(const QSizeF &v) {
527         sizeFPropertyValue = v;
528     }
529
530     QRect rectPropertyValue;
531     QRect rectProperty() const {
532        return rectPropertyValue;
533     }
534     void setRectProperty(const QRect &v) {
535         rectPropertyValue = v;
536         emit rectPropertyChanged();
537     }
538
539     QRect rectPropertyValue2;
540     QRect rectProperty2() const {
541        return rectPropertyValue2;
542     }
543     void setRectProperty2(const QRect &v) {
544         rectPropertyValue2 = v;
545     }
546
547     QRectF rectFPropertyValue;
548     QRectF rectFProperty() const {
549        return rectFPropertyValue;
550     }
551     void setRectFProperty(const QRectF &v) {
552         rectFPropertyValue = v;
553     }
554
555     bool boolPropertyValue;
556     bool boolProperty() const {
557        return boolPropertyValue;
558     }
559     void setBoolProperty(const bool &v) {
560         boolPropertyValue = v;
561     }
562
563     QVariant variantPropertyValue;
564     QVariant variantProperty() const {
565        return variantPropertyValue;
566     }
567     void setVariantProperty(const QVariant &v) {
568         variantPropertyValue = v;
569     }
570
571     QVector3D vectorPropertyValue;
572     QVector3D vectorProperty() const {
573         return vectorPropertyValue;
574     }
575     void setVectorProperty(const QVector3D &v) {
576         vectorPropertyValue = v;
577     }
578
579     QUrl urlPropertyValue;
580     QUrl urlProperty() const {
581         return urlPropertyValue;
582     }
583     void setUrlProperty(const QUrl &v) {
584         urlPropertyValue = v;
585     }
586
587     QDeclarativeScriptString scriptPropertyValue;
588     QDeclarativeScriptString scriptProperty() const {
589         return scriptPropertyValue;
590     }
591     void setScriptProperty(const QDeclarativeScriptString &v) {
592         scriptPropertyValue = v;
593     }
594
595     void doAction() { emit action(); }
596 signals:
597     void action();
598     void rectPropertyChanged();
599 };
600 Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
601
602 class MyDerivedObject : public MyTypeObject
603 {
604     Q_OBJECT
605 public:
606     Q_INVOKABLE bool intProperty() const {
607         return true;
608     }
609 };
610
611 Q_DECLARE_METATYPE(QJSValue);
612 class MyInvokableBaseObject : public QObject
613 {
614     Q_OBJECT
615 public:
616     inline ~MyInvokableBaseObject() = 0;
617
618     Q_INVOKABLE inline void method_inherited(int a);
619     Q_INVOKABLE inline void method_overload();
620 };
621
622 class MyInvokableObject : public MyInvokableBaseObject
623 {
624     Q_OBJECT
625     Q_ENUMS(TestEnum)
626 public:
627     enum TestEnum { EnumValue1, EnumValue2 };
628     MyInvokableObject() { reset(); }
629
630     int invoked() const { return m_invoked; }
631     bool error() const { return m_invokedError; }
632     const QVariantList &actuals() const { return m_actuals; }
633     void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
634
635     Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
636     Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
637
638     Q_INVOKABLE void method_NoArgs() { invoke(0); }
639     Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; }
640     Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; }
641     Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); }
642     Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; }
643     Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; }
644     Q_INVOKABLE QJSValue method_NoArgs_QScriptValue() { invoke(6); return QJSValue("Hello world"); }
645     Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
646
647     Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
648     Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
649     Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
650     Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
651     Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
652     Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
653     Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
654     Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
655     
656     Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
657     Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
658     Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; }
659
660     Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(19); m_actuals << (int)e; }
661
662     Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; }
663
664     Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; }
665
666 private:
667     friend class MyInvokableBaseObject;
668     void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
669     int m_invoked;
670     bool m_invokedError;
671     QVariantList m_actuals;
672 };
673
674 MyInvokableBaseObject::~MyInvokableBaseObject() {}
675
676 void MyInvokableBaseObject::method_inherited(int a)
677 {
678     static_cast<MyInvokableObject *>(this)->invoke(-3);
679     static_cast<MyInvokableObject *>(this)->m_actuals << a;
680 }
681
682 // This is a hidden overload of the MyInvokableObject::method_overload() method
683 void MyInvokableBaseObject::method_overload()
684 {
685     static_cast<MyInvokableObject *>(this)->invoke(-2);
686 }
687
688 class NumberAssignment : public QObject
689 {
690     Q_OBJECT
691 public:
692     Q_PROPERTY(qreal test1 READ test1 WRITE setTest1)
693     qreal _test1;
694     qreal test1() const { return _test1; }
695     void setTest1(qreal v) { _test1 = v; }
696
697     Q_PROPERTY(qreal test2 READ test2 WRITE setTest2)
698     qreal _test2;
699     qreal test2() const { return _test2; }
700     void setTest2(qreal v) { _test2 = v; }
701
702     Q_PROPERTY(qreal test3 READ test3 WRITE setTest3)
703     qreal _test3;
704     qreal test3() const { return _test3; }
705     void setTest3(qreal v) { _test3 = v; }
706
707     Q_PROPERTY(qreal test4 READ test4 WRITE setTest4)
708     qreal _test4;
709     qreal test4() const { return _test4; }
710     void setTest4(qreal v) { _test4 = v; }
711
712     Q_PROPERTY(int test5 READ test5 WRITE setTest5)
713     int _test5;
714     int test5() const { return _test5; }
715     void setTest5(int v) { _test5 = v; }
716
717     Q_PROPERTY(int test6 READ test6 WRITE setTest6)
718     int _test6;
719     int test6() const { return _test6; }
720     void setTest6(int v) { _test6 = v; }
721
722     Q_PROPERTY(int test7 READ test7 WRITE setTest7)
723     int _test7;
724     int test7() const { return _test7; }
725     void setTest7(int v) { _test7 = v; }
726
727     Q_PROPERTY(int test8 READ test8 WRITE setTest8)
728     int _test8;
729     int test8() const { return _test8; }
730     void setTest8(int v) { _test8 = v; }
731
732     Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9)
733     unsigned int _test9;
734     unsigned int test9() const { return _test9; }
735     void setTest9(unsigned int v) { _test9 = v; }
736
737     Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10)
738     unsigned int _test10;
739     unsigned int test10() const { return _test10; }
740     void setTest10(unsigned int v) { _test10 = v; }
741
742     Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11)
743     unsigned int _test11;
744     unsigned int test11() const { return _test11; }
745     void setTest11(unsigned int v) { _test11 = v; }
746
747     Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12)
748     unsigned int _test12;
749     unsigned int test12() const { return _test12; }
750     void setTest12(unsigned int v) { _test12 = v; }
751 };
752
753 class DefaultPropertyExtendedObject : public QObject
754 {
755     Q_OBJECT
756     Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty)
757     Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty)
758 public:
759     DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {}
760
761     QObject *firstProperty() const { return m_firstProperty; }
762     QObject *secondProperty() const { return m_secondProperty; }
763     void setFirstProperty(QObject *property) { m_firstProperty = property; }
764     void setSecondProperty(QObject *property) { m_secondProperty = property; }
765 private:
766     QObject* m_firstProperty;
767     QObject* m_secondProperty;
768 };
769
770 class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject
771 {
772     Q_OBJECT
773     Q_CLASSINFO("DefaultProperty", "secondProperty")
774 public:
775     OverrideDefaultPropertyObject() {}
776 };
777
778 class MyRevisionedBaseClassRegistered : public QObject
779 {
780 Q_OBJECT
781     Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
782     Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
783
784 public:
785     MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
786
787     qreal propA() const { return m_pa; }
788     void setPropA(qreal p) {
789         if (p != m_pa) {
790             m_pa = p;
791             emit propAChanged();
792         }
793     }
794     qreal propB() const { return m_pb; }
795     void setPropB(qreal p) {
796         if (p != m_pb) {
797             m_pb = p;
798             emit propBChanged();
799         }
800     }
801
802     Q_INVOKABLE void methodA() { }
803     Q_INVOKABLE Q_REVISION(1) void methodB() { }
804
805 signals:
806     void propAChanged();
807     void propBChanged();
808
809     void signalA();
810     Q_REVISION(1) void signalB();
811
812 protected:
813     qreal m_pa;
814     qreal m_pb;
815 };
816
817 class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
818 {
819 Q_OBJECT
820     Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
821     Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
822
823 public:
824     MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
825
826     qreal propC() const { return m_pc; }
827     void setPropC(qreal p) {
828         if (p != m_pc) {
829             m_pc = p;
830             emit propCChanged();
831         }
832     }
833     qreal propD() const { return m_pd; }
834     void setPropD(qreal p) {
835         if (p != m_pd) {
836             m_pd = p;
837             emit propDChanged();
838         }
839     }
840
841     Q_INVOKABLE void methodC() { }
842     Q_INVOKABLE Q_REVISION(1) void methodD() { }
843
844 signals:
845     void propCChanged();
846     void propDChanged();
847
848     void signalC();
849     Q_REVISION(1) void signalD();
850
851 protected:
852     qreal m_pc;
853     qreal m_pd;
854 };
855
856 class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
857 {
858     Q_OBJECT
859     Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
860     Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
861
862 public:
863     MyRevisionedClass() {}
864
865     qreal prop1() const { return m_p1; }
866     void setProp1(qreal p) {
867         if (p != m_p1) {
868             m_p1 = p;
869             emit prop1Changed();
870         }
871     }
872     qreal prop2() const { return m_p2; }
873     void setProp2(qreal p) {
874         if (p != m_p2) {
875             m_p2 = p;
876             emit prop2Changed();
877         }
878     }
879
880     Q_INVOKABLE void method1() { }
881     Q_INVOKABLE Q_REVISION(1) void method2() { }
882
883 signals:
884     void prop1Changed();
885     void prop2Changed();
886
887     void signal1();
888     Q_REVISION(1) void signal2();
889
890 protected:
891     qreal m_p1;
892     qreal m_p2;
893 };
894
895 class MyRevisionedSubclass : public MyRevisionedClass
896 {
897     Q_OBJECT
898     Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
899     Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
900
901 public:
902     MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
903
904     qreal prop3() const { return m_p3; }
905     void setProp3(qreal p) {
906         if (p != m_p3) {
907             m_p3 = p;
908             emit prop3Changed();
909         }
910     }
911     qreal prop4() const { return m_p4; }
912     void setProp4(qreal p) {
913         if (p != m_p4) {
914             m_p4 = p;
915             emit prop4Changed();
916         }
917     }
918
919     Q_INVOKABLE void method3() { }
920     Q_INVOKABLE Q_REVISION(1) void method4() { }
921
922 signals:
923     void prop3Changed();
924     void prop4Changed();
925
926     void signal3();
927     Q_REVISION(1) void signal4();
928
929 protected:
930     qreal m_p3;
931     qreal m_p4;
932 };
933
934 QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
935 QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
936 QML_DECLARE_TYPE(MyRevisionedClass)
937 QML_DECLARE_TYPE(MyRevisionedSubclass)
938 Q_DECLARE_METATYPE(MyQmlObject::MyType)
939
940
941 class ScarceResourceObject : public QObject
942 {
943     Q_OBJECT
944     Q_PROPERTY(QPixmap scarceResource READ scarceResource WRITE setScarceResource NOTIFY scarceResourceChanged)
945 public:
946     ScarceResourceObject(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); }
947     ~ScarceResourceObject() {}
948
949     QPixmap scarceResource() const { return m_value; }
950     void setScarceResource(QPixmap v) { m_value = v; emit scarceResourceChanged(); }
951
952     bool scarceResourceIsDetached() const { return m_value.isDetached(); }
953
954     // this particular one returns a new one each time
955     // this means that every Scarce Resource Copy will
956     // consume resources (so that we can track disposal
957     // of v8 handles with circular references).
958     Q_INVOKABLE QPixmap newScarceResource() const
959     {
960         QPixmap retn(800, 600);
961         retn.fill(QColor(100, 110, 120, 45));
962         return retn;
963     }
964
965 signals:
966     void scarceResourceChanged();
967
968 private:
969     QPixmap m_value;
970 };
971 QML_DECLARE_TYPE(ScarceResourceObject)
972
973 class testQObjectApi : public QObject
974 {
975     Q_OBJECT
976     Q_ENUMS(MyEnum)
977     Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged)
978     Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged)
979
980 public:
981     testQObjectApi(QObject* parent = 0)
982         : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_methodCallCount(0)
983     {
984     }
985
986     ~testQObjectApi() {}
987
988     enum MyEnum { EnumValue1 = 25, EnumValue2 = 42 };
989     Q_INVOKABLE int qobjectEnumTestMethod(MyEnum val) { return (static_cast<int>(val) + 5); }
990     Q_INVOKABLE int qobjectTestMethod(int increment = 1) { m_methodCallCount += increment; return m_methodCallCount; }
991
992     int qobjectTestProperty() const { return m_testProperty; }
993     void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); }
994
995     int qobjectTestWritableProperty() const { return m_testWritableProperty; }
996     void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); }
997
998 signals:
999     void qobjectTestPropertyChanged(int testProperty);
1000     void qobjectTestWritablePropertyChanged(int testWritableProperty);
1001
1002 private:
1003     int m_testProperty;
1004     int m_testWritableProperty;
1005     int m_methodCallCount;
1006 };
1007
1008 class CircularReferenceObject : public QObject,
1009                                 public QV8GCCallback::Node
1010 {
1011     Q_OBJECT
1012
1013 public:
1014     CircularReferenceObject(QObject *parent = 0)
1015         : QObject(parent), QV8GCCallback::Node(callback), m_referenced(0), m_dtorCount(0)
1016     {
1017         QV8GCCallback::addGcCallbackNode(this);
1018     }
1019
1020     ~CircularReferenceObject()
1021     {
1022         if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
1023     }
1024
1025     Q_INVOKABLE void setDtorCount(int *dtorCount)
1026     {
1027         m_dtorCount = dtorCount;
1028     }
1029
1030     Q_INVOKABLE CircularReferenceObject *generate(QObject *parent = 0)
1031     {
1032         CircularReferenceObject *retn = new CircularReferenceObject(parent);
1033         retn->m_dtorCount = m_dtorCount;
1034         retn->m_engine = m_engine;
1035         return retn;
1036     }
1037
1038     Q_INVOKABLE void addReference(QObject *other)
1039     {
1040         m_referenced = other;
1041     }
1042
1043     static void callback(QV8GCCallback::Node *n)
1044     {
1045         CircularReferenceObject *cro = static_cast<CircularReferenceObject*>(n);
1046         if (cro->m_referenced) {
1047             cro->m_engine->addRelationshipForGC(cro, cro->m_referenced);
1048         }
1049     }
1050
1051     void setEngine(QDeclarativeEngine* declarativeEngine)
1052     {
1053         m_engine = QDeclarativeEnginePrivate::get(declarativeEngine)->v8engine();
1054     }
1055
1056 private:
1057     QObject *m_referenced;
1058     int *m_dtorCount;
1059     QV8Engine* m_engine;
1060 };
1061 Q_DECLARE_METATYPE(CircularReferenceObject*)
1062
1063 class CircularReferenceHandle : public QObject,
1064                                 public QV8GCCallback::Node
1065 {
1066     Q_OBJECT
1067
1068 public:
1069     CircularReferenceHandle(QObject *parent = 0)
1070         : QObject(parent), QV8GCCallback::Node(gccallback), m_dtorCount(0), m_engine(0)
1071     {
1072         QV8GCCallback::addGcCallbackNode(this);
1073     }
1074
1075     ~CircularReferenceHandle()
1076     {
1077         if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
1078     }
1079
1080     Q_INVOKABLE void setDtorCount(int *dtorCount)
1081     {
1082         m_dtorCount = dtorCount;
1083     }
1084
1085     Q_INVOKABLE CircularReferenceHandle *generate(QObject *parent = 0)
1086     {
1087         CircularReferenceHandle *retn = new CircularReferenceHandle(parent);
1088         retn->m_dtorCount = m_dtorCount;
1089         retn->m_engine = m_engine;
1090         return retn;
1091     }
1092
1093     Q_INVOKABLE void addReference(v8::Persistent<v8::Value> handle)
1094     {
1095         m_referenced = qPersistentNew(handle);
1096         m_referenced.MakeWeak(static_cast<void*>(this), wrcallback);
1097     }
1098
1099     static void wrcallback(v8::Persistent<v8::Value> handle, void *params)
1100     {
1101         CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(params);
1102         qPersistentDispose(handle);
1103         crh->m_referenced.Clear();
1104     }
1105
1106     static void gccallback(QV8GCCallback::Node *n)
1107     {
1108         CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(n);
1109         crh->m_engine->addRelationshipForGC(crh, crh->m_referenced);
1110     }
1111
1112     void setEngine(QDeclarativeEngine* declarativeEngine)
1113     {
1114         m_engine = QDeclarativeEnginePrivate::get(declarativeEngine)->v8engine();
1115     }
1116
1117 private:
1118     v8::Persistent<v8::Value> m_referenced;
1119     int *m_dtorCount;
1120     QV8Engine* m_engine;
1121 };
1122 Q_DECLARE_METATYPE(CircularReferenceHandle*)
1123
1124 class MyDynamicCreationDestructionObject : public QObject
1125 {
1126     Q_OBJECT
1127     Q_PROPERTY (int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged)
1128
1129 public:
1130     MyDynamicCreationDestructionObject(QObject *parent = 0) : QObject(parent), m_intProperty(0), m_dtorCount(0)
1131     {
1132     }
1133
1134     ~MyDynamicCreationDestructionObject()
1135     {
1136         if (m_dtorCount) {
1137             (*m_dtorCount)++;
1138         }
1139     }
1140
1141     int intProperty() const { return m_intProperty; }
1142     void setIntProperty(int val) { m_intProperty = val; emit intPropertyChanged(); }
1143
1144     Q_INVOKABLE MyDynamicCreationDestructionObject *createNew()
1145     {
1146         // no parent == ownership transfers to JS; same dtor counter.
1147         MyDynamicCreationDestructionObject *retn = new MyDynamicCreationDestructionObject;
1148         retn->setDtorCount(m_dtorCount);
1149         return retn;
1150     }
1151
1152     void setDtorCount(int *dtorCount)
1153     {
1154         m_dtorCount = dtorCount;
1155     }
1156
1157 signals:
1158     void intPropertyChanged();
1159
1160 private:
1161     int m_intProperty;
1162     int *m_dtorCount;
1163 };
1164
1165 class WriteCounter : public QObject
1166 {
1167     Q_OBJECT
1168     Q_PROPERTY(int value READ value WRITE setValue);
1169 public:
1170     WriteCounter() : m_value(0), m_count(0) {}
1171
1172     int value() const { return m_value; }
1173     void setValue(int v) { m_value = v; ++m_count; }
1174
1175     int count() const { return m_count; }
1176
1177 private:
1178     int m_value;
1179     int m_count;
1180 };
1181
1182 class MySequenceConversionObject : public QObject
1183 {
1184     Q_OBJECT
1185
1186     Q_PROPERTY (QList<int> intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged)
1187     Q_PROPERTY (QList<int> intListProperty2 READ intListProperty2 WRITE setIntListProperty2 NOTIFY intListProperty2Changed)
1188     Q_PROPERTY (QList<qreal> qrealListProperty READ qrealListProperty WRITE setQrealListProperty NOTIFY qrealListPropertyChanged)
1189     Q_PROPERTY (QList<bool> boolListProperty READ boolListProperty WRITE setBoolListProperty NOTIFY boolListPropertyChanged)
1190     Q_PROPERTY (QList<QString> stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged)
1191     Q_PROPERTY (QList<QUrl> urlListProperty READ urlListProperty WRITE setUrlListProperty NOTIFY urlListPropertyChanged)
1192     Q_PROPERTY (QStringList qstringListProperty READ qstringListProperty WRITE setQStringListProperty NOTIFY qstringListPropertyChanged)
1193
1194     Q_PROPERTY (QList<QPoint> pointListProperty READ pointListProperty WRITE setPointListProperty NOTIFY pointListPropertyChanged)
1195     Q_PROPERTY (QList<QVariant> variantListProperty READ variantListProperty WRITE setVariantListProperty NOTIFY variantListPropertyChanged)
1196
1197 public:
1198     MySequenceConversionObject()
1199     {
1200         m_intList << 1 << 2 << 3 << 4;
1201         m_intList2 << 1 << 2 << 3 << 4;
1202         m_qrealList << 1.1 << 2.2 << 3.3 << 4.4;
1203         m_boolList << true << false << true << false;
1204         m_stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
1205         m_urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
1206         m_qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
1207
1208         m_pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6);
1209         m_variantList << QVariant(QLatin1String("one")) << QVariant(true) << QVariant(3);
1210     }
1211
1212     ~MySequenceConversionObject() {}
1213
1214     QList<int> intListProperty() const { return m_intList; }
1215     void setIntListProperty(const QList<int> &list) { m_intList = list; emit intListPropertyChanged(); }
1216     QList<int> intListProperty2() const { return m_intList2; }
1217     void setIntListProperty2(const QList<int> &list) { m_intList2 = list; emit intListProperty2Changed(); }
1218     QList<qreal> qrealListProperty() const { return m_qrealList; }
1219     void setQrealListProperty(const QList<qreal> &list) { m_qrealList = list; emit qrealListPropertyChanged(); }
1220     QList<bool> boolListProperty() const { return m_boolList; }
1221     void setBoolListProperty(const QList<bool> &list) { m_boolList = list; emit boolListPropertyChanged(); }
1222     QList<QString> stringListProperty() const { return m_stringList; }
1223     void setStringListProperty(const QList<QString> &list) { m_stringList = list; emit stringListPropertyChanged(); }
1224     QList<QUrl> urlListProperty() const { return m_urlList; }
1225     void setUrlListProperty(const QList<QUrl> &list) { m_urlList = list; emit urlListPropertyChanged(); }
1226     QStringList qstringListProperty() const { return m_qstringList; }
1227     void setQStringListProperty(const QStringList &list) { m_qstringList = list; emit qstringListPropertyChanged(); }
1228     QList<QPoint> pointListProperty() const { return m_pointList; }
1229     void setPointListProperty(const QList<QPoint> &list) { m_pointList = list; emit pointListPropertyChanged(); }
1230     QList<QVariant> variantListProperty() const { return m_variantList; }
1231     void setVariantListProperty(const QList<QVariant> &list) { m_variantList = list; emit variantListPropertyChanged(); }
1232
1233     // now for "copy resource" sequences:
1234     Q_INVOKABLE QList<int> generateIntSequence() const { QList<int> retn; retn << 1 << 2 << 3; return retn; }
1235     Q_INVOKABLE QList<qreal> generateQrealSequence() const { QList<qreal> retn; retn << 1.1 << 2.2 << 3.3; return retn; }
1236     Q_INVOKABLE QList<bool> generateBoolSequence() const { QList<bool> retn; retn << true << false << true; return retn; }
1237     Q_INVOKABLE QList<QString> generateStringSequence() const { QList<QString> retn; retn << "one" << "two" << "three"; return retn; }
1238     Q_INVOKABLE QList<QUrl> generateUrlSequence() const { QList<QUrl> retn; retn << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); return retn; }
1239     Q_INVOKABLE QStringList generateQStringSequence() const { QStringList retn; retn << "one" << "two" << "three"; return retn; }
1240
1241     // "reference resource" underlying qobject deletion test:
1242     Q_INVOKABLE MySequenceConversionObject *generateTestObject() const { return new MySequenceConversionObject; }
1243     Q_INVOKABLE void deleteTestObject(QObject *object) const { delete object; }
1244
1245 signals:
1246     void intListPropertyChanged();
1247     void intListProperty2Changed();
1248     void qrealListPropertyChanged();
1249     void boolListPropertyChanged();
1250     void stringListPropertyChanged();
1251     void urlListPropertyChanged();
1252     void qstringListPropertyChanged();
1253     void pointListPropertyChanged();
1254     void variantListPropertyChanged();
1255
1256 private:
1257     QList<int> m_intList;
1258     QList<int> m_intList2;
1259     QList<qreal> m_qrealList;
1260     QList<bool> m_boolList;
1261     QList<QString> m_stringList;
1262     QList<QUrl> m_urlList;
1263     QStringList m_qstringList;
1264
1265     QList<QPoint> m_pointList; // not a supported sequence type
1266     QList<QVariant> m_variantList; // not a supported sequence type, but QVariantList support is hardcoded.
1267 };
1268
1269 class MyDeleteObject : public QObject
1270 {
1271     Q_OBJECT
1272     Q_PROPERTY(QObject *nestedObject READ nestedObject NOTIFY nestedObjectChanged);
1273     Q_PROPERTY(int deleteNestedObject READ deleteNestedObject NOTIFY deleteNestedObjectChanged);
1274
1275 public:
1276     MyDeleteObject() : m_nestedObject(new MyQmlObject) {}
1277
1278     QObject *nestedObject() const { return m_nestedObject; }
1279     int deleteNestedObject() { delete m_nestedObject; m_nestedObject = 0; return 1; }
1280
1281 signals:
1282     void nestedObjectChanged();
1283     void deleteNestedObjectChanged();
1284
1285 private:
1286     MyQmlObject *m_nestedObject;
1287 };
1288
1289 void registerTypes();
1290
1291 #endif // TESTTYPES_H
1292