From af24a0746446aa0381cc927da1475d5c6f85c1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 30 Mar 2018 13:14:25 +0200 Subject: [PATCH] Add more comments and clean up code --- libnymea/plugin/deviceplugin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libnymea/plugin/deviceplugin.cpp b/libnymea/plugin/deviceplugin.cpp index fc63bcb5..cbe4c555 100644 --- a/libnymea/plugin/deviceplugin.cpp +++ b/libnymea/plugin/deviceplugin.cpp @@ -555,7 +555,7 @@ void DevicePlugin::loadMetaData() return; } - + // Load vendors foreach (const QJsonValue &vendorJson, m_metaData.value("vendors").toArray()) { bool broken = false; QJsonObject vendorObject = vendorJson.toObject(); @@ -581,6 +581,8 @@ void DevicePlugin::loadMetaData() } VendorId vendorId = vendorObject.value("id").toString(); + + // Load deviceclasses of this vendor foreach (const QJsonValue &deviceClassJson, vendorJson.toObject().value("deviceClasses").toArray()) { QJsonObject deviceClassObject = deviceClassJson.toObject(); QPair verificationResult = verifyFields(DeviceClass::jsonProperties(), DeviceClass::mandatoryJsonProperties(), deviceClassObject); @@ -714,6 +716,7 @@ void DevicePlugin::loadMetaData() break; } + // If this is a writable stateType, there must be also the displayNameAction property if (st.contains("writable") && st.value("writable").toBool()) { writableState = true; if (!st.contains("displayNameAction")) { @@ -810,7 +813,6 @@ void DevicePlugin::loadMetaData() index = 0; foreach (const QJsonValue &actionTypesJson, deviceClassObject.value("actionTypes").toArray()) { QJsonObject at = actionTypesJson.toObject(); - QPair verificationResult = verifyFields(ActionType::jsonProperties(), ActionType::mandatoryJsonProperties(), at); // Check mandatory fields @@ -865,7 +867,6 @@ void DevicePlugin::loadMetaData() break; } - EventType eventType(et.value("id").toString()); eventType.setName(et.value("name").toString()); eventType.setDisplayName(translateValue(m_metaData.value("name").toString(), et.value("displayName").toString())); @@ -888,7 +889,6 @@ void DevicePlugin::loadMetaData() deviceClass.setEventTypes(eventTypes); // Note: keep this after the actionType / stateType / eventType parsing - if (deviceClassObject.contains("criticalStateTypeId")) { StateTypeId criticalStateTypeId = StateTypeId(deviceClassObject.value("criticalStateTypeId").toString()); if (!deviceClass.hasStateType(criticalStateTypeId)) {