Add more comments and clean up code
This commit is contained in:
parent
711d667661
commit
af24a07464
@ -555,7 +555,7 @@ void DevicePlugin::loadMetaData()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load vendors
|
||||||
foreach (const QJsonValue &vendorJson, m_metaData.value("vendors").toArray()) {
|
foreach (const QJsonValue &vendorJson, m_metaData.value("vendors").toArray()) {
|
||||||
bool broken = false;
|
bool broken = false;
|
||||||
QJsonObject vendorObject = vendorJson.toObject();
|
QJsonObject vendorObject = vendorJson.toObject();
|
||||||
@ -581,6 +581,8 @@ void DevicePlugin::loadMetaData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
VendorId vendorId = vendorObject.value("id").toString();
|
VendorId vendorId = vendorObject.value("id").toString();
|
||||||
|
|
||||||
|
// Load deviceclasses of this vendor
|
||||||
foreach (const QJsonValue &deviceClassJson, vendorJson.toObject().value("deviceClasses").toArray()) {
|
foreach (const QJsonValue &deviceClassJson, vendorJson.toObject().value("deviceClasses").toArray()) {
|
||||||
QJsonObject deviceClassObject = deviceClassJson.toObject();
|
QJsonObject deviceClassObject = deviceClassJson.toObject();
|
||||||
QPair<QStringList, QStringList> verificationResult = verifyFields(DeviceClass::jsonProperties(), DeviceClass::mandatoryJsonProperties(), deviceClassObject);
|
QPair<QStringList, QStringList> verificationResult = verifyFields(DeviceClass::jsonProperties(), DeviceClass::mandatoryJsonProperties(), deviceClassObject);
|
||||||
@ -714,6 +716,7 @@ void DevicePlugin::loadMetaData()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is a writable stateType, there must be also the displayNameAction property
|
||||||
if (st.contains("writable") && st.value("writable").toBool()) {
|
if (st.contains("writable") && st.value("writable").toBool()) {
|
||||||
writableState = true;
|
writableState = true;
|
||||||
if (!st.contains("displayNameAction")) {
|
if (!st.contains("displayNameAction")) {
|
||||||
@ -810,7 +813,6 @@ void DevicePlugin::loadMetaData()
|
|||||||
index = 0;
|
index = 0;
|
||||||
foreach (const QJsonValue &actionTypesJson, deviceClassObject.value("actionTypes").toArray()) {
|
foreach (const QJsonValue &actionTypesJson, deviceClassObject.value("actionTypes").toArray()) {
|
||||||
QJsonObject at = actionTypesJson.toObject();
|
QJsonObject at = actionTypesJson.toObject();
|
||||||
|
|
||||||
QPair<QStringList, QStringList> verificationResult = verifyFields(ActionType::jsonProperties(), ActionType::mandatoryJsonProperties(), at);
|
QPair<QStringList, QStringList> verificationResult = verifyFields(ActionType::jsonProperties(), ActionType::mandatoryJsonProperties(), at);
|
||||||
|
|
||||||
// Check mandatory fields
|
// Check mandatory fields
|
||||||
@ -865,7 +867,6 @@ void DevicePlugin::loadMetaData()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EventType eventType(et.value("id").toString());
|
EventType eventType(et.value("id").toString());
|
||||||
eventType.setName(et.value("name").toString());
|
eventType.setName(et.value("name").toString());
|
||||||
eventType.setDisplayName(translateValue(m_metaData.value("name").toString(), et.value("displayName").toString()));
|
eventType.setDisplayName(translateValue(m_metaData.value("name").toString(), et.value("displayName").toString()));
|
||||||
@ -888,7 +889,6 @@ void DevicePlugin::loadMetaData()
|
|||||||
deviceClass.setEventTypes(eventTypes);
|
deviceClass.setEventTypes(eventTypes);
|
||||||
|
|
||||||
// Note: keep this after the actionType / stateType / eventType parsing
|
// Note: keep this after the actionType / stateType / eventType parsing
|
||||||
|
|
||||||
if (deviceClassObject.contains("criticalStateTypeId")) {
|
if (deviceClassObject.contains("criticalStateTypeId")) {
|
||||||
StateTypeId criticalStateTypeId = StateTypeId(deviceClassObject.value("criticalStateTypeId").toString());
|
StateTypeId criticalStateTypeId = StateTypeId(deviceClassObject.value("criticalStateTypeId").toString());
|
||||||
if (!deviceClass.hasStateType(criticalStateTypeId)) {
|
if (!deviceClass.hasStateType(criticalStateTypeId)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user