fix some plugin's json
This commit is contained in:
parent
d81dd97d5f
commit
ba8e3d7ec9
@ -163,6 +163,7 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
|
||||
deviceClass.setCreateMethods(createMethods);
|
||||
|
||||
deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray()));
|
||||
qDebug() << "loaded deviceClass" << deviceClass.discoveryParamTypes();
|
||||
|
||||
QString setupMethod = jo.value("setupMethod").toString();
|
||||
if (setupMethod == "pushButton") {
|
||||
@ -293,6 +294,11 @@ QList<ParamType> DevicePlugin::parseParamTypes(const QJsonArray &array) const
|
||||
foreach (const QJsonValue ¶mTypesJson, array) {
|
||||
QJsonObject pt = paramTypesJson.toObject();
|
||||
QVariant::Type t = QVariant::nameToType(pt.value("type").toString().toLatin1().data());
|
||||
Q_ASSERT_X(t != QVariant::Invalid,
|
||||
pluginName().toLatin1().data(),
|
||||
QString("Invalid type %1 for param %2 in json file.")
|
||||
.arg(pt.value("type").toString())
|
||||
.arg(pt.value("name").toString()).toLatin1().data());
|
||||
ParamType paramType(pt.value("name").toString(), t, pt.value("defaultValue").toVariant());
|
||||
QVariantList allowedValues;
|
||||
foreach (const QJsonValue &allowedTypesJson, pt.value("allowedValues").toArray()) {
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "button",
|
||||
"type": "string"
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"name": "repeat",
|
||||
|
||||
@ -13,21 +13,21 @@
|
||||
"discoveryParamTypes": [
|
||||
{
|
||||
"name": "location",
|
||||
"type": "string"
|
||||
"type": "QString"
|
||||
}
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "location",
|
||||
"type": "string"
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"name": "country",
|
||||
"type": "string"
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"type": "string"
|
||||
"type": "QString"
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
|
||||
@ -371,6 +371,7 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass)
|
||||
}
|
||||
QVariantList discoveryParamTypes;
|
||||
foreach (const ParamType ¶mType, deviceClass.discoveryParamTypes()) {
|
||||
qDebug() << "packing discoverparam" << packParamType(paramType);
|
||||
discoveryParamTypes.append(packParamType(paramType));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user