b76c0c36aacc0c5c6f22d61243843d828cc6aec3
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativelanguage / testtypes.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the test suite of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #ifndef TESTTYPES_H
42 #define TESTTYPES_H
43
44 #include <QtCore/qobject.h>
45 #include <QtCore/qrect.h>
46 #include <QtCore/qdatetime.h>
47 #include <QtGui/qmatrix.h>
48 #include <QtGui/qcolor.h>
49 #include <QtGui/qvector3d.h>
50 #include <QtGui/qvector4d.h>
51 #include <QtDeclarative/qdeclarative.h>
52 #include <QtDeclarative/qdeclarativecomponent.h>
53 #include <QtDeclarative/qdeclarativeparserstatus.h>
54 #include <QtDeclarative/qdeclarativepropertyvaluesource.h>
55 #include <QtDeclarative/qdeclarativescriptstring.h>
56 #include <QtDeclarative/qdeclarativeproperty.h>
57
58 #include <private/qdeclarativecustomparser_p.h>
59
60 QVariant myCustomVariantTypeConverter(const QString &data);
61
62 class MyInterface 
63 {
64 public:
65     MyInterface() : id(913) {}
66     int id;
67 };
68
69 QT_BEGIN_NAMESPACE
70 Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
71 QT_END_NAMESPACE
72 QML_DECLARE_INTERFACE(MyInterface);
73
74 struct MyCustomVariantType
75 {
76     MyCustomVariantType() : a(0) {}
77     int a;
78 };
79 Q_DECLARE_METATYPE(MyCustomVariantType);
80
81 class MyAttachedObject : public QObject
82 {
83     Q_OBJECT
84     Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
85     Q_PROPERTY(int value2 READ value2 WRITE setValue2)
86 public:
87     MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {}
88
89     int value() const { return m_value; }
90     void setValue(int v) { if (m_value != v) { m_value = v; emit valueChanged(); } }
91
92     int value2() const { return m_value2; }
93     void setValue2(int v) { m_value2 = v; }
94
95 signals:
96     void valueChanged();
97
98 private:
99     int m_value;
100     int m_value2;
101 };
102
103 class MyQmlObject : public QObject, public MyInterface
104 {
105     Q_OBJECT
106     Q_PROPERTY(int value READ value WRITE setValue FINAL)
107     Q_PROPERTY(QString readOnlyString READ readOnlyString)
108     Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
109     Q_PROPERTY(QRect rect READ rect WRITE setRect)
110     Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix)  //assumed to be unsupported by QML
111     Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
112     Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal)
113     Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType)
114     Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
115     Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
116     Q_PROPERTY(int nonScriptable READ nonScriptable WRITE setNonScriptable SCRIPTABLE false)
117
118     Q_INTERFACES(MyInterface)
119 public:
120     MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
121
122     int value() const { return m_value; }
123     void setValue(int v) { m_value = v; }
124
125     QString readOnlyString() const { return QLatin1String(""); }
126
127     bool enabled() const { return false; }
128     void setEnabled(bool) {}
129
130     QRect rect() const { return QRect(); }
131     void setRect(const QRect&) {}
132
133     QMatrix matrix() const { return QMatrix(); }
134     void setMatrix(const QMatrix&) {}
135
136     MyInterface *interface() const { return m_interface; }
137     void setInterface(MyInterface *iface) { m_interface = iface; }
138
139     static MyAttachedObject *qmlAttachedProperties(QObject *other) {
140         return new MyAttachedObject(other);
141     }
142     Q_CLASSINFO("DefaultMethod", "basicSlot()")
143
144     int onLiteralSignal() const { return m_value; }
145     void setOnLiteralSignal(int v) { m_value = v; }
146
147     MyQmlObject *qmlobject() const { return m_qmlobject; }
148     void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
149
150     MyCustomVariantType customType() const { return m_custom; }
151     void setCustomType(const MyCustomVariantType &v)  { m_custom = v; }
152
153     int propertyWithNotify() const { return m_propertyWithNotify; }
154     void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
155
156     int nonScriptable() const { return 0; }
157     void setNonScriptable(int) {}
158 public slots:
159     void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
160     void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
161
162 signals:
163     void basicSignal();
164     void basicParameterizedSignal(int parameter);
165     void oddlyNamedNotifySignal();
166
167 private:
168     friend class tst_qdeclarativelanguage;
169     int m_value;
170     MyInterface *m_interface;
171     MyQmlObject *m_qmlobject;
172     MyCustomVariantType m_custom;
173     int m_propertyWithNotify;
174 };
175 QML_DECLARE_TYPE(MyQmlObject)
176 QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
177
178 class MyGroupedObject : public QObject
179 {
180     Q_OBJECT
181     Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
182     Q_PROPERTY(int value READ value WRITE setValue)
183 public:
184     QDeclarativeScriptString script() const { return m_script; }
185     void setScript(const QDeclarativeScriptString &s) { m_script = s; }
186
187     int value() const { return m_value; }
188     void setValue(int v) { m_value = v; }
189
190 private:
191     int m_value;
192     QDeclarativeScriptString m_script;
193 };
194
195
196 class MyTypeObject : public QObject
197 {
198     Q_OBJECT
199     Q_ENUMS(MyEnum)
200     Q_FLAGS(MyFlags)
201
202     Q_PROPERTY(QString id READ id WRITE setId)
203     Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
204     Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty)
205     Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
206     Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
207     Q_PROPERTY(MyEnum readOnlyEnumProperty READ readOnlyEnumProperty)
208     Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
209     Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
210     Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
211     Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
212     Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
213     Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
214     Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
215     Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
216     Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
217     Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
218     Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
219     Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
220     Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
221     Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
222     Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
223     Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
224     Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
225     Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
226     Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
227     Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
228     Q_PROPERTY(QVector4D vector4Property READ vector4Property WRITE setVector4Property)
229     Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
230
231     Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
232     Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT)
233     Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT)
234
235 public:
236     MyTypeObject()
237         : objectPropertyValue(0), componentPropertyValue(0) {}
238
239     QString idValue;
240     QString id() const {
241         return idValue;
242     }
243     void setId(const QString &v) {
244         idValue = v;
245     }
246
247     QObject *objectPropertyValue;
248     QObject *objectProperty() const {
249         return objectPropertyValue;
250     }
251     void setObjectProperty(QObject *v) {
252         objectPropertyValue = v;
253     }
254
255     QDeclarativeComponent *componentPropertyValue;
256     QDeclarativeComponent *componentProperty() const {
257         return componentPropertyValue;
258     }
259     void setComponentProperty(QDeclarativeComponent *v) {
260         componentPropertyValue = v;
261     }
262
263     enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
264     Q_DECLARE_FLAGS(MyFlags, MyFlag)
265     MyFlags flagPropertyValue;
266     MyFlags flagProperty() const {
267         return flagPropertyValue;
268     }
269     void setFlagProperty(MyFlags v) {
270         flagPropertyValue = v;
271     }
272
273     enum MyEnum { EnumVal1, EnumVal2 };
274     MyEnum enumPropertyValue;
275     MyEnum enumProperty() const {
276         return enumPropertyValue;
277     }
278     void setEnumProperty(MyEnum v) {
279         enumPropertyValue = v;
280     }
281
282     MyEnum readOnlyEnumProperty() const {
283         return EnumVal1;
284     }
285
286     QString stringPropertyValue;
287     QString stringProperty() const {
288        return stringPropertyValue;
289     }
290     void setStringProperty(const QString &v) {
291         stringPropertyValue = v;
292     }
293
294     uint uintPropertyValue;
295     uint uintProperty() const {
296        return uintPropertyValue;
297     }
298     void setUintProperty(const uint &v) {
299         uintPropertyValue = v;
300     }
301
302     int intPropertyValue;
303     int intProperty() const {
304        return intPropertyValue;
305     }
306     void setIntProperty(const int &v) {
307         intPropertyValue = v;
308     }
309
310     qreal realPropertyValue;
311     qreal realProperty() const {
312        return realPropertyValue;
313     }
314     void setRealProperty(const qreal &v) {
315         realPropertyValue = v;
316     }
317
318     double doublePropertyValue;
319     double doubleProperty() const {
320        return doublePropertyValue;
321     }
322     void setDoubleProperty(const double &v) {
323         doublePropertyValue = v;
324     }
325
326     float floatPropertyValue;
327     float floatProperty() const {
328        return floatPropertyValue;
329     }
330     void setFloatProperty(const float &v) {
331         floatPropertyValue = v;
332     }
333
334     QColor colorPropertyValue;
335     QColor colorProperty() const {
336        return colorPropertyValue;
337     }
338     void setColorProperty(const QColor &v) {
339         colorPropertyValue = v;
340     }
341
342     QDate datePropertyValue;
343     QDate dateProperty() const {
344        return datePropertyValue;
345     }
346     void setDateProperty(const QDate &v) {
347         datePropertyValue = v;
348     }
349
350     QTime timePropertyValue;
351     QTime timeProperty() const {
352        return timePropertyValue;
353     }
354     void setTimeProperty(const QTime &v) {
355         timePropertyValue = v;
356     }
357
358     QDateTime dateTimePropertyValue;
359     QDateTime dateTimeProperty() const {
360        return dateTimePropertyValue;
361     }
362     void setDateTimeProperty(const QDateTime &v) {
363         dateTimePropertyValue = v;
364     }
365
366     QPoint pointPropertyValue;
367     QPoint pointProperty() const {
368        return pointPropertyValue;
369     }
370     void setPointProperty(const QPoint &v) {
371         pointPropertyValue = v;
372     }
373
374     QPointF pointFPropertyValue;
375     QPointF pointFProperty() const {
376        return pointFPropertyValue;
377     }
378     void setPointFProperty(const QPointF &v) {
379         pointFPropertyValue = v;
380     }
381
382     QSize sizePropertyValue;
383     QSize sizeProperty() const {
384        return sizePropertyValue;
385     }
386     void setSizeProperty(const QSize &v) {
387         sizePropertyValue = v;
388     }
389
390     QSizeF sizeFPropertyValue;
391     QSizeF sizeFProperty() const {
392        return sizeFPropertyValue;
393     }
394     void setSizeFProperty(const QSizeF &v) {
395         sizeFPropertyValue = v;
396     }
397
398     QRect rectPropertyValue;
399     QRect rectProperty() const {
400        return rectPropertyValue;
401     }
402     void setRectProperty(const QRect &v) {
403         rectPropertyValue = v;
404         emit rectPropertyChanged();
405     }
406
407     QRect rectPropertyValue2;
408     QRect rectProperty2() const {
409        return rectPropertyValue2;
410     }
411     void setRectProperty2(const QRect &v) {
412         rectPropertyValue2 = v;
413     }
414
415     QRectF rectFPropertyValue;
416     QRectF rectFProperty() const {
417        return rectFPropertyValue;
418     }
419     void setRectFProperty(const QRectF &v) {
420         rectFPropertyValue = v;
421     }
422
423     bool boolPropertyValue;
424     bool boolProperty() const {
425        return boolPropertyValue;
426     }
427     void setBoolProperty(const bool &v) {
428         boolPropertyValue = v;
429     }
430
431     QVariant variantPropertyValue;
432     QVariant variantProperty() const {
433        return variantPropertyValue;
434     }
435     void setVariantProperty(const QVariant &v) {
436         variantPropertyValue = v;
437     }
438
439     QVector3D vectorPropertyValue;
440     QVector3D vectorProperty() const {
441         return vectorPropertyValue;
442     }
443     void setVectorProperty(const QVector3D &v) {
444         vectorPropertyValue = v;
445     }
446
447     QVector4D vector4PropertyValue;
448     QVector4D vector4Property() const {
449         return vector4PropertyValue;
450     }
451     void setVector4Property(const QVector4D &v) {
452         vector4PropertyValue = v;
453     }
454
455     QUrl urlPropertyValue;
456     QUrl urlProperty() const {
457         return urlPropertyValue;
458     }
459     void setUrlProperty(const QUrl &v) {
460         urlPropertyValue = v;
461     }
462
463     QDeclarativeScriptString scriptPropertyValue;
464     QDeclarativeScriptString scriptProperty() const {
465         return scriptPropertyValue;
466     }
467     void setScriptProperty(const QDeclarativeScriptString &v) {
468         scriptPropertyValue = v;
469     }
470
471     MyGroupedObject groupedValue;
472     MyGroupedObject *grouped() { return &groupedValue; }
473
474     MyGroupedObject *nullGrouped() { return 0; }
475
476     void doAction() { emit action(); }
477 signals:
478     void action();
479     void rectPropertyChanged();
480 };
481 Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
482
483
484 class MyContainer : public QObject
485 {
486     Q_OBJECT
487     Q_PROPERTY(QDeclarativeListProperty<QObject> children READ children)
488     Q_PROPERTY(QDeclarativeListProperty<MyContainer> containerChildren READ containerChildren)
489     Q_PROPERTY(QDeclarativeListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
490     Q_CLASSINFO("DefaultProperty", "children")
491 public:
492     MyContainer() {}
493
494     QDeclarativeListProperty<QObject> children() { return QDeclarativeListProperty<QObject>(this, m_children); }
495     QDeclarativeListProperty<MyContainer> containerChildren() { return QDeclarativeListProperty<MyContainer>(this, m_containerChildren); }
496     QList<QObject *> *getChildren() { return &m_children; }
497     QDeclarativeListProperty<MyInterface> qlistInterfaces() { return QDeclarativeListProperty<MyInterface>(this, m_interfaces); }
498     QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
499
500     QList<MyContainer*> m_containerChildren;
501     QList<QObject*> m_children;
502     QList<MyInterface *> m_interfaces;
503 };
504
505
506 class MyPropertyValueSource : public QObject, public QDeclarativePropertyValueSource
507 {
508     Q_OBJECT
509     Q_INTERFACES(QDeclarativePropertyValueSource)
510 public:
511     MyPropertyValueSource()
512         : QDeclarativePropertyValueSource() {}
513
514     QDeclarativeProperty prop;
515     virtual void setTarget(const QDeclarativeProperty &p)
516     {
517         prop = p;
518     }
519 };
520
521 class UnavailableType : public QObject
522 {
523     Q_OBJECT
524 public:
525     UnavailableType() {}
526 };
527
528 class MyDotPropertyObject : public QObject
529 {
530     Q_OBJECT
531     Q_PROPERTY(MyQmlObject *obj READ obj)
532     Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj)
533 public:
534     MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {}
535     ~MyDotPropertyObject()
536     {
537         if (m_ownRWObj)
538             delete m_rwobj;
539     }
540
541     MyQmlObject *obj() { return 0; }
542
543     MyQmlObject *readWriteObj()
544     {
545         if (!m_rwobj) {
546             m_rwobj = new MyQmlObject;
547             m_ownRWObj = true;
548         }
549         return m_rwobj;
550     }
551
552     void setReadWriteObj(MyQmlObject *obj)
553     {
554         if (m_ownRWObj) {
555             delete m_rwobj;
556             m_ownRWObj = false;
557         }
558
559         m_rwobj = obj;
560     }
561
562 private:
563     MyQmlObject *m_rwobj;
564     bool m_ownRWObj;
565 };
566
567
568 namespace MyNamespace {
569     class MyNamespacedType : public QObject
570     {
571         Q_OBJECT
572     };
573
574     class MySecondNamespacedType : public QObject
575     {
576         Q_OBJECT
577         Q_PROPERTY(QDeclarativeListProperty<MyNamespace::MyNamespacedType> list READ list)
578     public:
579         QDeclarativeListProperty<MyNamespacedType> list() { return QDeclarativeListProperty<MyNamespacedType>(this, m_list); }
580
581     private:
582         QList<MyNamespacedType *> m_list;
583     };
584 }
585
586 class MyCustomParserType : public QObject
587 {
588     Q_OBJECT
589 };
590
591 class MyCustomParserTypeParser : public QDeclarativeCustomParser
592 {
593 public:
594     QByteArray compile(const QList<QDeclarativeCustomParserProperty> &) { return QByteArray(); }
595     void setCustomData(QObject *, const QByteArray &) {}
596 };
597
598 class MyParserStatus : public QObject, public QDeclarativeParserStatus
599 {
600     Q_INTERFACES(QDeclarativeParserStatus)
601     Q_OBJECT
602 public:
603     MyParserStatus() : m_cbc(0), m_ccc(0) {}
604
605     int classBeginCount() const { return m_cbc; }
606     int componentCompleteCount() const { return m_ccc; }
607
608     virtual void classBegin() { m_cbc++; }
609     virtual void componentComplete() { m_ccc++; }
610 private:
611     int m_cbc;
612     int m_ccc;
613 };
614
615 class MyRevisionedBaseClassRegistered : public QObject
616 {
617     Q_OBJECT
618     Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
619     Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
620
621 public:
622     MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
623
624     qreal propA() const { return m_pa; }
625     void setPropA(qreal p) {
626         if (p != m_pa) {
627             m_pa = p;
628             emit propAChanged();
629         }
630     }
631     qreal propB() const { return m_pb; }
632     void setPropB(qreal p) {
633         if (p != m_pb) {
634             m_pb = p;
635             emit propBChanged();
636         }
637     }
638
639     Q_INVOKABLE void methodA() { }
640     Q_INVOKABLE Q_REVISION(1) void methodB() { }
641
642 signals:
643     void propAChanged();
644     void propBChanged();
645
646     void signalA();
647     Q_REVISION(1) void signalB();
648
649 protected:
650     qreal m_pa;
651     qreal m_pb;
652 };
653
654 class MyRevisionedIllegalOverload : public MyRevisionedBaseClassRegistered
655 {
656     Q_OBJECT
657     Q_PROPERTY(qreal propA READ propA WRITE setPropA REVISION 1);
658 };
659
660 class MyRevisionedLegalOverload : public MyRevisionedBaseClassRegistered
661 {
662     Q_OBJECT
663     Q_PROPERTY(qreal propB READ propB WRITE setPropB REVISION 1);
664 };
665
666 class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
667 {
668     Q_OBJECT
669     Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
670     Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
671
672 public:
673     MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
674
675     qreal propC() const { return m_pc; }
676     void setPropC(qreal p) {
677         if (p != m_pc) {
678             m_pc = p;
679             emit propCChanged();
680         }
681     }
682     qreal propD() const { return m_pd; }
683     void setPropD(qreal p) {
684         if (p != m_pd) {
685             m_pd = p;
686             emit propDChanged();
687         }
688     }
689
690     Q_INVOKABLE void methodC() { }
691     Q_INVOKABLE Q_REVISION(1) void methodD() { }
692
693 signals:
694     void propCChanged();
695     void propDChanged();
696
697     void signalC();
698     Q_REVISION(1) void signalD();
699
700 protected:
701     qreal m_pc;
702     qreal m_pd;
703 };
704
705 class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
706 {
707     Q_OBJECT
708     Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
709     Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
710
711 public:
712     MyRevisionedClass() : m_p1(1), m_p2(2) {}
713
714     qreal prop1() const { return m_p1; }
715     void setProp1(qreal p) {
716         if (p != m_p1) {
717             m_p1 = p;
718             emit prop1Changed();
719         }
720     }
721     qreal prop2() const { return m_p2; }
722     void setProp2(qreal p) {
723         if (p != m_p2) {
724             m_p2 = p;
725             emit prop2Changed();
726         }
727     }
728
729     Q_INVOKABLE void method1() { }
730     Q_INVOKABLE Q_REVISION(1) void method2() { }
731
732 signals:
733     void prop1Changed();
734     void prop2Changed();
735
736     void signal1();
737     Q_REVISION(1) void signal2();
738
739 protected:
740     qreal m_p1;
741     qreal m_p2;
742 };
743
744 class MyRevisionedSubclass : public MyRevisionedClass
745 {
746     Q_OBJECT
747     Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
748     Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
749
750 public:
751     MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
752
753     qreal prop3() const { return m_p3; }
754     void setProp3(qreal p) {
755         if (p != m_p3) {
756             m_p3 = p;
757             emit prop3Changed();
758         }
759     }
760     qreal prop4() const { return m_p4; }
761     void setProp4(qreal p) {
762         if (p != m_p4) {
763             m_p4 = p;
764             emit prop4Changed();
765         }
766     }
767
768     Q_INVOKABLE void method3() { }
769     Q_INVOKABLE Q_REVISION(1) void method4() { }
770
771 signals:
772     void prop3Changed();
773     void prop4Changed();
774
775     void signal3();
776     Q_REVISION(1) void signal4();
777
778 protected:
779     qreal m_p3;
780     qreal m_p4;
781 };
782
783 class MySubclass : public MyRevisionedClass
784 {
785     Q_OBJECT
786     Q_PROPERTY(qreal prop5 READ prop5 WRITE setProp5 NOTIFY prop5Changed)
787
788 public:
789     MySubclass() : m_p5(5) {}
790
791     qreal prop5() const { return m_p5; }
792     void setProp5(qreal p) {
793         if (p != m_p5) {
794             m_p5 = p;
795             emit prop5Changed();
796         }
797     }
798
799     Q_INVOKABLE void method5() { }
800
801 signals:
802     void prop5Changed();
803
804 protected:
805     qreal m_p5;
806 };
807
808 class MyVersion2Class : public QObject
809 {
810     Q_OBJECT
811 };
812
813 QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
814 QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
815 QML_DECLARE_TYPE(MyRevisionedClass)
816 QML_DECLARE_TYPE(MyRevisionedSubclass)
817 QML_DECLARE_TYPE(MySubclass)
818
819
820
821 void registerTypes();
822
823 #endif // TESTTYPES_H