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