Allow registering lists of ThingId on json rpc
This commit is contained in:
parent
8367f60886
commit
289362fefc
@ -208,7 +208,7 @@ void JsonHandler::registerObject(const QMetaObject &metaObject)
|
|||||||
typeName = QString("$ref:BasicType");
|
typeName = QString("$ref:BasicType");
|
||||||
} else if (QString(metaProperty.typeName()).startsWith("QList")) {
|
} else if (QString(metaProperty.typeName()).startsWith("QList")) {
|
||||||
QString elementType = QString(metaProperty.typeName()).remove("QList<").remove(">");
|
QString elementType = QString(metaProperty.typeName()).remove("QList<").remove(">");
|
||||||
if (elementType == "EventTypeId" || elementType == "StateTypeId" || elementType == "ActionTypeId") {
|
if (elementType == "ThingId" || elementType == "EventTypeId" || elementType == "StateTypeId" || elementType == "ActionTypeId") {
|
||||||
elementType = "QUuid";
|
elementType = "QUuid";
|
||||||
}
|
}
|
||||||
QVariant::Type variantType = QVariant::nameToType(elementType.toUtf8());
|
QVariant::Type variantType = QVariant::nameToType(elementType.toUtf8());
|
||||||
@ -349,6 +349,10 @@ QVariant JsonHandler::pack(const QMetaObject &metaObject, const void *value) con
|
|||||||
foreach (const QUuid &entry, propertyValue.value<QList<QUuid>>()) {
|
foreach (const QUuid &entry, propertyValue.value<QList<QUuid>>()) {
|
||||||
list << entry;
|
list << entry;
|
||||||
}
|
}
|
||||||
|
} else if (propertyTypeName == "QList<ThingId>") {
|
||||||
|
foreach (const ThingId &entry, propertyValue.value<QList<ThingId>>()) {
|
||||||
|
list << entry;
|
||||||
|
}
|
||||||
} else if (propertyTypeName == "QList<EventTypeId>") {
|
} else if (propertyTypeName == "QList<EventTypeId>") {
|
||||||
foreach (const EventTypeId &entry, propertyValue.value<QList<EventTypeId>>()) {
|
foreach (const EventTypeId &entry, propertyValue.value<QList<EventTypeId>>()) {
|
||||||
list << entry;
|
list << entry;
|
||||||
@ -477,6 +481,7 @@ QVariant JsonHandler::unpack(const QMetaObject &metaObject, const QVariant &valu
|
|||||||
}
|
}
|
||||||
metaProperty.writeOnGadget(ptr, QVariant::fromValue(intList));
|
metaProperty.writeOnGadget(ptr, QVariant::fromValue(intList));
|
||||||
} else if (metaProperty.typeName() == QStringLiteral("QList<QUuid>")
|
} else if (metaProperty.typeName() == QStringLiteral("QList<QUuid>")
|
||||||
|
|| metaProperty.typeName() == QStringLiteral("QList<ThingId>")
|
||||||
|| metaProperty.typeName() == QStringLiteral("QList<EventTypeId>")
|
|| metaProperty.typeName() == QStringLiteral("QList<EventTypeId>")
|
||||||
|| metaProperty.typeName() == QStringLiteral("QList<StateTypeId>")
|
|| metaProperty.typeName() == QStringLiteral("QList<StateTypeId>")
|
||||||
|| metaProperty.typeName() == QStringLiteral("QList<ActionTypeId>")) {
|
|| metaProperty.typeName() == QStringLiteral("QList<ActionTypeId>")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user