1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the test suite of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
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 <QtCore/qdatetime.h>
55 #include <QtScript/qscriptvalue.h>
56 #include <QtDeclarative/qdeclarativescriptstring.h>
57 #include <QtDeclarative/qdeclarativecomponent.h>
59 class MyQmlAttachedObject : public QObject
62 Q_PROPERTY(int value READ value CONSTANT)
63 Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
65 MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
67 int value() const { return 19; }
68 int value2() const { return m_value2; }
69 void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
71 void emitMySignal() { emit mySignal(); }
81 class MyQmlObject : public QObject
86 Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
87 Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
88 Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
89 Q_PROPERTY(int value READ value WRITE setValue)
90 Q_PROPERTY(int console READ console CONSTANT)
91 Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
92 Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
93 Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
94 Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
95 Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
96 Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false)
99 MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
101 enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
102 enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
104 bool trueProperty() const { return true; }
105 bool falseProperty() const { return false; }
107 QString stringProperty() const { return m_string; }
108 void setStringProperty(const QString &s)
113 emit stringChanged();
116 QObject *objectProperty() const { return m_object; }
117 void setObjectProperty(QObject *obj) {
121 emit objectChanged();
124 QDeclarativeListProperty<QObject> objectListProperty() { return QDeclarativeListProperty<QObject>(this, m_objectQList); }
126 bool methodCalled() const { return m_methodCalled; }
127 bool methodIntCalled() const { return m_methodIntCalled; }
129 QString string() const { return m_string; }
131 static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
132 return new MyQmlAttachedObject(o);
135 int deleteOnSet() const { return 1; }
136 void setDeleteOnSet(int v) { if(v) delete this; }
138 int value() const { return m_value; }
139 void setValue(int v) { m_value = v; }
141 int resettableProperty() const { return m_resetProperty; }
142 void setResettableProperty(int v) { m_resetProperty = v; }
143 void resetProperty() { m_resetProperty = 13; }
145 QRegExp regExp() { return m_regExp; }
146 void setRegExp(const QRegExp ®Exp) { m_regExp = regExp; }
148 int console() const { return 11; }
150 int nonscriptable() const { return 0; }
151 void setNonscriptable(int) {}
153 MyQmlObject *myinvokableObject;
154 Q_INVOKABLE MyQmlObject *returnme() { return this; }
159 QVariant variant() const { return m_variant; }
163 void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
164 void stringChanged();
165 void objectChanged();
166 void anotherBasicSignal();
167 void thirdBasicSignal();
168 void signalWithUnknownType(const MyQmlObject::MyType &arg);
171 void deleteMe() { delete this; }
172 void methodNoArgs() { m_methodCalled = true; }
173 void method(int a) { if(a == 163) m_methodIntCalled = true; }
174 void setString(const QString &s) { m_string = s; }
175 void myinvokable(MyQmlObject *o) { myinvokableObject = o; }
176 void variantMethod(const QVariant &v) { m_variant = v; }
179 friend class tst_qdeclarativeecmascript;
181 bool m_methodIntCalled;
185 QList<QObject *> m_objectQList;
192 QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
194 class MyQmlContainer : public QObject
197 Q_PROPERTY(QDeclarativeListProperty<MyQmlObject> children READ children CONSTANT)
201 QDeclarativeListProperty<MyQmlObject> children() { return QDeclarativeListProperty<MyQmlObject>(this, m_children); }
204 QList<MyQmlObject*> m_children;
208 class MyExpression : public QDeclarativeExpression
212 MyExpression(QDeclarativeContext *ctxt, const QString &expr)
213 : QDeclarativeExpression(ctxt, 0, expr), changed(false)
215 QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged()));
216 setNotifyOnValueChanged(true);
222 void expressionValueChanged() {
228 class MyDefaultObject1 : public QObject
231 Q_PROPERTY(int horseLegs READ horseLegs CONSTANT)
232 Q_PROPERTY(int antLegs READ antLegs CONSTANT)
233 Q_PROPERTY(int emuLegs READ emuLegs CONSTANT)
235 int horseLegs() const { return 4; }
236 int antLegs() const { return 6; }
237 int emuLegs() const { return 2; }
240 class MyDefaultObject3 : public QObject
243 Q_PROPERTY(int antLegs READ antLegs CONSTANT)
244 Q_PROPERTY(int humanLegs READ humanLegs CONSTANT)
246 int antLegs() const { return 7; } // Mutant
247 int humanLegs() const { return 2; }
248 int millipedeLegs() const { return 1000; }
251 class MyDeferredObject : public QObject
254 Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
255 Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
256 Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2)
257 Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2")
260 MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
262 int value() const { return m_value; }
263 void setValue(int v) { m_value = v; emit valueChanged(); }
265 QObject *objectProperty() const { return m_object; }
266 void setObjectProperty(QObject *obj) { m_object = obj; }
268 QObject *objectProperty2() const { return m_object2; }
269 void setObjectProperty2(QObject *obj) { m_object2 = obj; }
280 class MyBaseExtendedObject : public QObject
283 Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
285 MyBaseExtendedObject() : m_value(0) {}
287 int baseProperty() const { return m_value; }
288 void setBaseProperty(int v) { m_value = v; }
294 class MyExtendedObject : public MyBaseExtendedObject
297 Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty)
299 MyExtendedObject() : m_value(0) {}
301 int coreProperty() const { return m_value; }
302 void setCoreProperty(int v) { m_value = v; }
308 class MyTypeObject : public QObject
314 Q_PROPERTY(QString id READ id WRITE setId)
315 Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
316 Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty)
317 Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
318 Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
319 Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
320 Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
321 Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
322 Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
323 Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
324 Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
325 Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
326 Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
327 Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
328 Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
329 Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
330 Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
331 Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
332 Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
333 Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
334 Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
335 Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
336 Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
337 Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
338 Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
339 Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
341 Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
345 : objectPropertyValue(0), componentPropertyValue(0) {}
351 void setId(const QString &v) {
355 QObject *objectPropertyValue;
356 QObject *objectProperty() const {
357 return objectPropertyValue;
359 void setObjectProperty(QObject *v) {
360 objectPropertyValue = v;
363 QDeclarativeComponent *componentPropertyValue;
364 QDeclarativeComponent *componentProperty() const {
365 return componentPropertyValue;
367 void setComponentProperty(QDeclarativeComponent *v) {
368 componentPropertyValue = v;
371 enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
372 Q_DECLARE_FLAGS(MyFlags, MyFlag)
373 MyFlags flagPropertyValue;
374 MyFlags flagProperty() const {
375 return flagPropertyValue;
377 void setFlagProperty(MyFlags v) {
378 flagPropertyValue = v;
381 enum MyEnum { EnumVal1, EnumVal2 };
382 MyEnum enumPropertyValue;
383 MyEnum enumProperty() const {
384 return enumPropertyValue;
386 void setEnumProperty(MyEnum v) {
387 enumPropertyValue = v;
390 QString stringPropertyValue;
391 QString stringProperty() const {
392 return stringPropertyValue;
394 void setStringProperty(const QString &v) {
395 stringPropertyValue = v;
398 uint uintPropertyValue;
399 uint uintProperty() const {
400 return uintPropertyValue;
402 void setUintProperty(const uint &v) {
403 uintPropertyValue = v;
406 int intPropertyValue;
407 int intProperty() const {
408 return intPropertyValue;
410 void setIntProperty(const int &v) {
411 intPropertyValue = v;
414 qreal realPropertyValue;
415 qreal realProperty() const {
416 return realPropertyValue;
418 void setRealProperty(const qreal &v) {
419 realPropertyValue = v;
422 double doublePropertyValue;
423 double doubleProperty() const {
424 return doublePropertyValue;
426 void setDoubleProperty(const double &v) {
427 doublePropertyValue = v;
430 float floatPropertyValue;
431 float floatProperty() const {
432 return floatPropertyValue;
434 void setFloatProperty(const float &v) {
435 floatPropertyValue = v;
438 QColor colorPropertyValue;
439 QColor colorProperty() const {
440 return colorPropertyValue;
442 void setColorProperty(const QColor &v) {
443 colorPropertyValue = v;
446 QDate datePropertyValue;
447 QDate dateProperty() const {
448 return datePropertyValue;
450 void setDateProperty(const QDate &v) {
451 datePropertyValue = v;
454 QTime timePropertyValue;
455 QTime timeProperty() const {
456 return timePropertyValue;
458 void setTimeProperty(const QTime &v) {
459 timePropertyValue = v;
462 QDateTime dateTimePropertyValue;
463 QDateTime dateTimeProperty() const {
464 return dateTimePropertyValue;
466 void setDateTimeProperty(const QDateTime &v) {
467 dateTimePropertyValue = v;
470 QPoint pointPropertyValue;
471 QPoint pointProperty() const {
472 return pointPropertyValue;
474 void setPointProperty(const QPoint &v) {
475 pointPropertyValue = v;
478 QPointF pointFPropertyValue;
479 QPointF pointFProperty() const {
480 return pointFPropertyValue;
482 void setPointFProperty(const QPointF &v) {
483 pointFPropertyValue = v;
486 QSize sizePropertyValue;
487 QSize sizeProperty() const {
488 return sizePropertyValue;
490 void setSizeProperty(const QSize &v) {
491 sizePropertyValue = v;
494 QSizeF sizeFPropertyValue;
495 QSizeF sizeFProperty() const {
496 return sizeFPropertyValue;
498 void setSizeFProperty(const QSizeF &v) {
499 sizeFPropertyValue = v;
502 QRect rectPropertyValue;
503 QRect rectProperty() const {
504 return rectPropertyValue;
506 void setRectProperty(const QRect &v) {
507 rectPropertyValue = v;
508 emit rectPropertyChanged();
511 QRect rectPropertyValue2;
512 QRect rectProperty2() const {
513 return rectPropertyValue2;
515 void setRectProperty2(const QRect &v) {
516 rectPropertyValue2 = v;
519 QRectF rectFPropertyValue;
520 QRectF rectFProperty() const {
521 return rectFPropertyValue;
523 void setRectFProperty(const QRectF &v) {
524 rectFPropertyValue = v;
527 bool boolPropertyValue;
528 bool boolProperty() const {
529 return boolPropertyValue;
531 void setBoolProperty(const bool &v) {
532 boolPropertyValue = v;
535 QVariant variantPropertyValue;
536 QVariant variantProperty() const {
537 return variantPropertyValue;
539 void setVariantProperty(const QVariant &v) {
540 variantPropertyValue = v;
543 QVector3D vectorPropertyValue;
544 QVector3D vectorProperty() const {
545 return vectorPropertyValue;
547 void setVectorProperty(const QVector3D &v) {
548 vectorPropertyValue = v;
551 QUrl urlPropertyValue;
552 QUrl urlProperty() const {
553 return urlPropertyValue;
555 void setUrlProperty(const QUrl &v) {
556 urlPropertyValue = v;
559 QDeclarativeScriptString scriptPropertyValue;
560 QDeclarativeScriptString scriptProperty() const {
561 return scriptPropertyValue;
563 void setScriptProperty(const QDeclarativeScriptString &v) {
564 scriptPropertyValue = v;
567 void doAction() { emit action(); }
570 void rectPropertyChanged();
572 Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
574 class MyDerivedObject : public MyTypeObject
578 Q_INVOKABLE bool intProperty() const {
583 Q_DECLARE_METATYPE(QScriptValue);
584 class MyInvokableBaseObject : public QObject
588 inline ~MyInvokableBaseObject() = 0;
590 Q_INVOKABLE inline void method_inherited(int a);
591 Q_INVOKABLE inline void method_overload();
594 class MyInvokableObject : public MyInvokableBaseObject
599 enum TestEnum { EnumValue1, EnumValue2 };
600 MyInvokableObject() { reset(); }
602 int invoked() const { return m_invoked; }
603 bool error() const { return m_invokedError; }
604 const QVariantList &actuals() const { return m_actuals; }
605 void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
607 Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
608 Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
610 Q_INVOKABLE void method_NoArgs() { invoke(0); }
611 Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; }
612 Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; }
613 Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); }
614 Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; }
615 Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; }
616 Q_INVOKABLE QScriptValue method_NoArgs_QScriptValue() { invoke(6); return QScriptValue("Hello world"); }
617 Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
619 Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
620 Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
621 Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
622 Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
623 Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
624 Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
625 Q_INVOKABLE void method_QScriptValue(QScriptValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
626 Q_INVOKABLE void method_intQScriptValue(int a, QScriptValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
628 Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
629 Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
630 Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; }
632 Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(19); m_actuals << (int)e; }
634 Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; }
636 Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; }
639 friend class MyInvokableBaseObject;
640 void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
643 QVariantList m_actuals;
646 MyInvokableBaseObject::~MyInvokableBaseObject() {}
648 void MyInvokableBaseObject::method_inherited(int a)
650 static_cast<MyInvokableObject *>(this)->invoke(-3);
651 static_cast<MyInvokableObject *>(this)->m_actuals << a;
654 // This is a hidden overload of the MyInvokableObject::method_overload() method
655 void MyInvokableBaseObject::method_overload()
657 static_cast<MyInvokableObject *>(this)->invoke(-2);
660 class NumberAssignment : public QObject
664 Q_PROPERTY(qreal test1 READ test1 WRITE setTest1)
666 qreal test1() const { return _test1; }
667 void setTest1(qreal v) { _test1 = v; }
669 Q_PROPERTY(qreal test2 READ test2 WRITE setTest2)
671 qreal test2() const { return _test2; }
672 void setTest2(qreal v) { _test2 = v; }
674 Q_PROPERTY(qreal test3 READ test3 WRITE setTest3)
676 qreal test3() const { return _test3; }
677 void setTest3(qreal v) { _test3 = v; }
679 Q_PROPERTY(qreal test4 READ test4 WRITE setTest4)
681 qreal test4() const { return _test4; }
682 void setTest4(qreal v) { _test4 = v; }
684 Q_PROPERTY(int test5 READ test5 WRITE setTest5)
686 int test5() const { return _test5; }
687 void setTest5(int v) { _test5 = v; }
689 Q_PROPERTY(int test6 READ test6 WRITE setTest6)
691 int test6() const { return _test6; }
692 void setTest6(int v) { _test6 = v; }
694 Q_PROPERTY(int test7 READ test7 WRITE setTest7)
696 int test7() const { return _test7; }
697 void setTest7(int v) { _test7 = v; }
699 Q_PROPERTY(int test8 READ test8 WRITE setTest8)
701 int test8() const { return _test8; }
702 void setTest8(int v) { _test8 = v; }
704 Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9)
706 unsigned int test9() const { return _test9; }
707 void setTest9(unsigned int v) { _test9 = v; }
709 Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10)
710 unsigned int _test10;
711 unsigned int test10() const { return _test10; }
712 void setTest10(unsigned int v) { _test10 = v; }
714 Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11)
715 unsigned int _test11;
716 unsigned int test11() const { return _test11; }
717 void setTest11(unsigned int v) { _test11 = v; }
719 Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12)
720 unsigned int _test12;
721 unsigned int test12() const { return _test12; }
722 void setTest12(unsigned int v) { _test12 = v; }
725 class DefaultPropertyExtendedObject : public QObject
728 Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty)
729 Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty)
731 DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {}
733 QObject *firstProperty() const { return m_firstProperty; }
734 QObject *secondProperty() const { return m_secondProperty; }
735 void setFirstProperty(QObject *property) { m_firstProperty = property; }
736 void setSecondProperty(QObject *property) { m_secondProperty = property; }
738 QObject* m_firstProperty;
739 QObject* m_secondProperty;
742 class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject
745 Q_CLASSINFO("DefaultProperty", "secondProperty")
747 OverrideDefaultPropertyObject() {}
750 class MyRevisionedBaseClassRegistered : public QObject
753 Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
754 Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
757 MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
759 qreal propA() const { return m_pa; }
760 void setPropA(qreal p) {
766 qreal propB() const { return m_pb; }
767 void setPropB(qreal p) {
774 Q_INVOKABLE void methodA() { }
775 Q_INVOKABLE Q_REVISION(1) void methodB() { }
782 Q_REVISION(1) void signalB();
789 class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
792 Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
793 Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
796 MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
798 qreal propC() const { return m_pc; }
799 void setPropC(qreal p) {
805 qreal propD() const { return m_pd; }
806 void setPropD(qreal p) {
813 Q_INVOKABLE void methodC() { }
814 Q_INVOKABLE Q_REVISION(1) void methodD() { }
821 Q_REVISION(1) void signalD();
828 class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
831 Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
832 Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
835 MyRevisionedClass() {}
837 qreal prop1() const { return m_p1; }
838 void setProp1(qreal p) {
844 qreal prop2() const { return m_p2; }
845 void setProp2(qreal p) {
852 Q_INVOKABLE void method1() { }
853 Q_INVOKABLE Q_REVISION(1) void method2() { }
860 Q_REVISION(1) void signal2();
867 class MyRevisionedSubclass : public MyRevisionedClass
870 Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
871 Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
874 MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
876 qreal prop3() const { return m_p3; }
877 void setProp3(qreal p) {
883 qreal prop4() const { return m_p4; }
884 void setProp4(qreal p) {
891 Q_INVOKABLE void method3() { }
892 Q_INVOKABLE Q_REVISION(1) void method4() { }
899 Q_REVISION(1) void signal4();
906 QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
907 QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
908 QML_DECLARE_TYPE(MyRevisionedClass)
909 QML_DECLARE_TYPE(MyRevisionedSubclass)
910 Q_DECLARE_METATYPE(MyQmlObject::MyType)
912 void registerTypes();
914 #endif // TESTTYPES_H