fix some plugin's json

This commit is contained in:
Michael Zanetti 2014-10-10 01:14:39 +02:00 committed by Michael Zanetti
parent d81dd97d5f
commit ba8e3d7ec9
4 changed files with 12 additions and 5 deletions

View File

@ -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 &paramTypesJson, 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()) {

View File

@ -23,7 +23,7 @@
"paramTypes": [
{
"name": "button",
"type": "string"
"type": "QString"
},
{
"name": "repeat",

View File

@ -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": [

View File

@ -371,6 +371,7 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass)
}
QVariantList discoveryParamTypes;
foreach (const ParamType &paramType, deviceClass.discoveryParamTypes()) {
qDebug() << "packing discoverparam" << packParamType(paramType);
discoveryParamTypes.append(packParamType(paramType));
}