return keys;
}
-static int EnumType(const QMetaObject *meta, const QByteArray &str)
+struct StaticQtMetaObject : public QObject
+{
+ static const QMetaObject *get()
+ { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
+};
+
+static int EnumType(const QMetaObject *metaobj, const QByteArray &str)
{
QByteArray scope;
QByteArray name;
} else {
name = str;
}
+ const QMetaObject *meta;
+ if (scope == "Qt")
+ meta = StaticQtMetaObject::get();
+ else
+ meta = metaobj;
for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
QMetaEnum m = meta->enumerator(i);
if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope)))
bValue = newValue;
}
+ onValueCChanged: {
+ cValue = newValue;
+ }
+
+ onValueDChanged: {
+ dValue = newValue;
+ }
+
property int aValue: 0
property int bValue: 0
+ property int cValue: 0
+ property int dValue: 0
}
function setEnumValues() {
enum1Class.setValue(MyEnum1Class.A_13);
enumDerivedClass.setValueA(MyEnum1Class.A_11);
enumDerivedClass.setValueB(MyEnum2Class.B_37);
+ enumDerivedClass.setValueC(Qt.RichText);
+ enumDerivedClass.setValueD(Qt.ElideMiddle);
}
}
MyEnum1Class::EnumA getValueA() { return valueA; }
EnumB getValueB() { return valueB; }
+ Qt::TextFormat getValueC() { return valueC; }
+ Qt::TextElideMode getValueD() { return valueD; }
Q_INVOKABLE void setValueA(MyEnum1Class::EnumA v) { valueA = v; emit valueAChanged(v); }
Q_INVOKABLE void setValueB(EnumB v) { valueB = v; emit valueBChanged(v); }
+ Q_INVOKABLE void setValueC(Qt::TextFormat v) { valueC = v; emit valueCChanged(v); } //registered
+ Q_INVOKABLE void setValueD(Qt::TextElideMode v) { valueD = v; emit valueDChanged(v); } //unregistered
signals:
void valueAChanged(MyEnum1Class::EnumA newValue);
void valueBChanged(MyEnum2Class::EnumB newValue);
+ void valueCChanged(Qt::TextFormat newValue);
+ void valueDChanged(Qt::TextElideMode newValue);
private:
MyEnum1Class::EnumA valueA;
EnumB valueB;
+ Qt::TextFormat valueC;
+ Qt::TextElideMode valueD;
};
class MyEnumDerivedClass : public MyEnum2Class
Q_DECLARE_METATYPE(MyEnum2Class::EnumB)
Q_DECLARE_METATYPE(MyEnum1Class::EnumA)
+Q_DECLARE_METATYPE(Qt::TextFormat)
QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
{
qRegisterMetaType<MyEnum1Class::EnumA>();
qRegisterMetaType<MyEnum2Class::EnumB>();
+ qRegisterMetaType<Qt::TextFormat>();
QQmlComponent component(&engine, TEST_FILE("globalEnums.qml"));
QVERIFY(enum2Class->property("aValue") == 0);
QVERIFY(enum2Class->property("bValue") == 0);
+ QVERIFY(enum2Class->property("cValue") == 0);
+ QVERIFY(enum2Class->property("dValue") == 0);
QSignalSpy signalA(enum2Class, SIGNAL(valueAChanged(MyEnum1Class::EnumA)));
QSignalSpy signalB(enum2Class, SIGNAL(valueBChanged(MyEnum2Class::EnumB)));
QVERIFY(enum1Class->getValue() == MyEnum1Class::A_13);
QVERIFY(enum2Class->getValueA() == MyEnum1Class::A_11);
QVERIFY(enum2Class->getValueB() == MyEnum2Class::B_37);
+ QVERIFY(enum2Class->getValueC() == Qt::RichText);
+ QVERIFY(enum2Class->getValueD() == Qt::ElideMiddle);
QVERIFY(signalA.count() == 1);
QVERIFY(signalB.count() == 1);
QVERIFY(enum2Class->property("aValue") == MyEnum1Class::A_11);
QVERIFY(enum2Class->property("bValue") == 37);
+ QVERIFY(enum2Class->property("cValue") == 1);
+ QVERIFY(enum2Class->property("dValue") == 2);
delete o;
}