Merge PR #166: Fix loading/saving of params using typeId

This commit is contained in:
Jenkins 2019-06-19 23:52:18 +02:00
commit 1131bce321
2 changed files with 14 additions and 13 deletions

View File

@ -1097,7 +1097,7 @@ void DeviceManager::loadPlugin(DevicePlugin *pluginIface)
ParamTypeId paramTypeId(paramTypeIdString); ParamTypeId paramTypeId(paramTypeIdString);
ParamType paramType = pluginIface->configurationDescription().findById(paramTypeId); ParamType paramType = pluginIface->configurationDescription().findById(paramTypeId);
if (!paramType.isValid()) { if (!paramType.isValid()) {
qCWarning(dcDeviceManager()) << "Skip loading Param for plugin" << pluginIface->pluginName() << "because could not find ParamType for saved Param" << ParamTypeId(paramTypeIdString).toString(); qCWarning(dcDeviceManager()) << "Not loading Param for plugin" << pluginIface->pluginName() << "because the ParamType for the saved Param" << ParamTypeId(paramTypeIdString).toString() << "could not be found.";
continue; continue;
} }
@ -1162,19 +1162,19 @@ void DeviceManager::loadConfiguredDevices()
DeviceClass deviceClass = findDeviceClass(device->deviceClassId()); DeviceClass deviceClass = findDeviceClass(device->deviceClassId());
if (!deviceClass.isValid()) { if (!deviceClass.isValid()) {
qCWarning(dcDeviceManager()) << "Skip loading device" << device << " because could not find device class for this device."; qCWarning(dcDeviceManager()) << "Not loading device" << device << "because the device class for this device could not be found.";
settings.endGroup(); // DeviceId
continue; continue;
} }
ParamList params; ParamList params;
settings.beginGroup("Params"); settings.beginGroup("Params");
if (!settings.childGroups().isEmpty()) { if (!settings.childGroups().isEmpty()) {
foreach (const QString &paramTypeIdString, settings.childGroups()) { foreach (const QString &paramTypeIdString, settings.childGroups()) {
ParamTypeId paramTypeId(paramTypeIdString); ParamTypeId paramTypeId(paramTypeIdString);
ParamType paramType = deviceClass.paramTypes().findById(paramTypeId); ParamType paramType = deviceClass.paramTypes().findById(paramTypeId);
if (!paramType.isValid()) { if (!paramType.isValid()) {
qCWarning(dcDeviceManager()) << "Skip loading Param for device" << device << "because could not find ParamType for saved Param" << ParamTypeId(paramTypeIdString).toString(); qCWarning(dcDeviceManager()) << "Not loading Param for device" << device << "because the ParamType for the saved Param" << ParamTypeId(paramTypeIdString).toString() << "could not be found.";
continue; continue;
} }
@ -1184,7 +1184,7 @@ void DeviceManager::loadConfiguredDevices()
paramValue = settings.value("value", paramType.defaultValue()); paramValue = settings.value("value", paramType.defaultValue());
paramValue.convert(settings.value("type").toInt()); paramValue.convert(settings.value("type").toInt());
params.append(Param(paramTypeId, paramValue)); params.append(Param(paramTypeId, paramValue));
settings.endGroup(); settings.endGroup(); // ParamId
} }
} else { } else {
foreach (const QString &paramTypeIdString, settings.allKeys()) { foreach (const QString &paramTypeIdString, settings.allKeys()) {
@ -1193,8 +1193,8 @@ void DeviceManager::loadConfiguredDevices()
} }
device->setParams(params); device->setParams(params);
settings.endGroup(); settings.endGroup(); // Params
settings.endGroup(); settings.endGroup(); // DeviceId
// We always add the device to the list in this case. If its in the storedDevices // We always add the device to the list in this case. If its in the storedDevices
// it means that it was working at some point so lets still add it as there might // it means that it was working at some point so lets still add it as there might
@ -1242,12 +1242,13 @@ void DeviceManager::storeConfiguredDevices()
settings.beginGroup(param.paramTypeId().toString()); settings.beginGroup(param.paramTypeId().toString());
settings.setValue("type", static_cast<int>(param.value().type())); settings.setValue("type", static_cast<int>(param.value().type()));
settings.setValue("value", param.value()); settings.setValue("value", param.value());
settings.endGroup(); settings.endGroup(); // ParamTypeId
} }
settings.endGroup(); settings.endGroup(); // Params
settings.endGroup();
settings.endGroup(); // DeviceId
} }
settings.endGroup(); settings.endGroup(); // DeviceConfig
} }
void DeviceManager::startMonitoringAutoDevices() void DeviceManager::startMonitoringAutoDevices()

View File

@ -264,8 +264,8 @@ Device *Devices::findById(const DeviceId &id)
QDebug operator<<(QDebug dbg, Device *device) QDebug operator<<(QDebug dbg, Device *device)
{ {
dbg.nospace() << "Device(" << device->name(); dbg.nospace() << "Device(" << device->name();
dbg.nospace() << ", id" << device->id(); dbg.nospace() << ", id: " << device->id().toString();
dbg.nospace() << ", deviceClassId" << device->deviceClassId() << ")"; dbg.nospace() << ", deviceClassId: " << device->deviceClassId().toString() << ")";
return dbg.space(); return dbg.space();
} }