computer configuration: use value semantics for DeviceDetails

The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.

Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.

To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.

Moreover, this removes the prefix from  number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>

make DeviceDetails a metatype

So that we can pass it as value through the signal/slot system.
(squash with original commit)

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-16 09:29:54 +01:00 committed by bstoeger
parent 322c1b56b2
commit 8733828380
9 changed files with 861 additions and 865 deletions

View file

@ -41,7 +41,7 @@ void ConfigureDiveComputer::readSettings(device_data_t *data)
readThread->start(); readThread->start();
} }
void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_data_t *data) void ConfigureDiveComputer::saveDeviceDetails(const DeviceDetails &details, device_data_t *data)
{ {
setState(WRITING); setState(WRITING);
@ -65,7 +65,7 @@ static QString writeGasDetails(gas g)
}).join(QLatin1Char(',')); }).join(QLatin1Char(','));
} }
bool ConfigureDiveComputer::saveXMLBackup(const QString &fileName, DeviceDetails *details, device_data_t *data) bool ConfigureDiveComputer::saveXMLBackup(const QString &fileName, const DeviceDetails &details, device_data_t *data)
{ {
QString xml = ""; QString xml = "";
QString vendor = data->vendor; QString vendor = data->vendor;
@ -80,37 +80,37 @@ bool ConfigureDiveComputer::saveXMLBackup(const QString &fileName, DeviceDetails
writer.writeTextElement("Product", product); writer.writeTextElement("Product", product);
writer.writeEndElement(); writer.writeEndElement();
writer.writeStartElement("Settings"); writer.writeStartElement("Settings");
writer.writeTextElement("CustomText", details->customText); writer.writeTextElement("CustomText", details.customText);
//Add gasses //Add gasses
writer.writeTextElement("Gas1", writeGasDetails(details->gas1)); writer.writeTextElement("Gas1", writeGasDetails(details.gas1));
writer.writeTextElement("Gas2", writeGasDetails(details->gas2)); writer.writeTextElement("Gas2", writeGasDetails(details.gas2));
writer.writeTextElement("Gas3", writeGasDetails(details->gas3)); writer.writeTextElement("Gas3", writeGasDetails(details.gas3));
writer.writeTextElement("Gas4", writeGasDetails(details->gas4)); writer.writeTextElement("Gas4", writeGasDetails(details.gas4));
writer.writeTextElement("Gas5", writeGasDetails(details->gas5)); writer.writeTextElement("Gas5", writeGasDetails(details.gas5));
// //
//Add dil values //Add dil values
writer.writeTextElement("Dil1", writeGasDetails(details->dil1)); writer.writeTextElement("Dil1", writeGasDetails(details.dil1));
writer.writeTextElement("Dil2", writeGasDetails(details->dil2)); writer.writeTextElement("Dil2", writeGasDetails(details.dil2));
writer.writeTextElement("Dil3", writeGasDetails(details->dil3)); writer.writeTextElement("Dil3", writeGasDetails(details.dil3));
writer.writeTextElement("Dil4", writeGasDetails(details->dil4)); writer.writeTextElement("Dil4", writeGasDetails(details.dil4));
writer.writeTextElement("Dil5", writeGasDetails(details->dil5)); writer.writeTextElement("Dil5", writeGasDetails(details.dil5));
//Add setpoint values //Add setpoint values
QString sp1 = QString("%1,%2") QString sp1 = QString("%1,%2")
.arg(QString::number(details->sp1.sp), .arg(QString::number(details.sp1.sp),
QString::number(details->sp1.depth)); QString::number(details.sp1.depth));
QString sp2 = QString("%1,%2") QString sp2 = QString("%1,%2")
.arg(QString::number(details->sp2.sp), .arg(QString::number(details.sp2.sp),
QString::number(details->sp2.depth)); QString::number(details.sp2.depth));
QString sp3 = QString("%1,%2") QString sp3 = QString("%1,%2")
.arg(QString::number(details->sp3.sp), .arg(QString::number(details.sp3.sp),
QString::number(details->sp3.depth)); QString::number(details.sp3.depth));
QString sp4 = QString("%1,%2") QString sp4 = QString("%1,%2")
.arg(QString::number(details->sp4.sp), .arg(QString::number(details.sp4.sp),
QString::number(details->sp4.depth)); QString::number(details.sp4.depth));
QString sp5 = QString("%1,%2") QString sp5 = QString("%1,%2")
.arg(QString::number(details->sp5.sp), .arg(QString::number(details.sp5.sp),
QString::number(details->sp5.depth)); QString::number(details.sp5.depth));
writer.writeTextElement("SetPoint1", sp1); writer.writeTextElement("SetPoint1", sp1);
writer.writeTextElement("SetPoint2", sp2); writer.writeTextElement("SetPoint2", sp2);
writer.writeTextElement("SetPoint3", sp3); writer.writeTextElement("SetPoint3", sp3);
@ -118,60 +118,60 @@ bool ConfigureDiveComputer::saveXMLBackup(const QString &fileName, DeviceDetails
writer.writeTextElement("SetPoint5", sp5); writer.writeTextElement("SetPoint5", sp5);
//Other Settings //Other Settings
writer.writeTextElement("DiveMode", QString::number(details->diveMode)); writer.writeTextElement("DiveMode", QString::number(details.diveMode));
writer.writeTextElement("Saturation", QString::number(details->saturation)); writer.writeTextElement("Saturation", QString::number(details.saturation));
writer.writeTextElement("Desaturation", QString::number(details->desaturation)); writer.writeTextElement("Desaturation", QString::number(details.desaturation));
writer.writeTextElement("LastDeco", QString::number(details->lastDeco)); writer.writeTextElement("LastDeco", QString::number(details.lastDeco));
writer.writeTextElement("Brightness", QString::number(details->brightness)); writer.writeTextElement("Brightness", QString::number(details.brightness));
writer.writeTextElement("Units", QString::number(details->units)); writer.writeTextElement("Units", QString::number(details.units));
writer.writeTextElement("SamplingRate", QString::number(details->samplingRate)); writer.writeTextElement("SamplingRate", QString::number(details.samplingRate));
writer.writeTextElement("Salinity", QString::number(details->salinity)); writer.writeTextElement("Salinity", QString::number(details.salinity));
writer.writeTextElement("DiveModeColor", QString::number(details->diveModeColor)); writer.writeTextElement("DiveModeColor", QString::number(details.diveModeColor));
writer.writeTextElement("Language", QString::number(details->language)); writer.writeTextElement("Language", QString::number(details.language));
writer.writeTextElement("DateFormat", QString::number(details->dateFormat)); writer.writeTextElement("DateFormat", QString::number(details.dateFormat));
writer.writeTextElement("CompassGain", QString::number(details->compassGain)); writer.writeTextElement("CompassGain", QString::number(details.compassGain));
writer.writeTextElement("SafetyStop", QString::number(details->safetyStop)); writer.writeTextElement("SafetyStop", QString::number(details.safetyStop));
writer.writeTextElement("GfHigh", QString::number(details->gfHigh)); writer.writeTextElement("GfHigh", QString::number(details.gfHigh));
writer.writeTextElement("GfLow", QString::number(details->gfLow)); writer.writeTextElement("GfLow", QString::number(details.gfLow));
writer.writeTextElement("PressureSensorOffset", QString::number(details->pressureSensorOffset)); writer.writeTextElement("PressureSensorOffset", QString::number(details.pressureSensorOffset));
writer.writeTextElement("PpO2Min", QString::number(details->ppO2Min)); writer.writeTextElement("PpO2Min", QString::number(details.ppO2Min));
writer.writeTextElement("PpO2Max", QString::number(details->ppO2Max)); writer.writeTextElement("PpO2Max", QString::number(details.ppO2Max));
writer.writeTextElement("FutureTTS", QString::number(details->futureTTS)); writer.writeTextElement("FutureTTS", QString::number(details.futureTTS));
writer.writeTextElement("CcrMode", QString::number(details->ccrMode)); writer.writeTextElement("CcrMode", QString::number(details.ccrMode));
writer.writeTextElement("DecoType", QString::number(details->decoType)); writer.writeTextElement("DecoType", QString::number(details.decoType));
writer.writeTextElement("AGFSelectable", QString::number(details->aGFSelectable)); writer.writeTextElement("AGFSelectable", QString::number(details.aGFSelectable));
writer.writeTextElement("AGFHigh", QString::number(details->aGFHigh)); writer.writeTextElement("AGFHigh", QString::number(details.aGFHigh));
writer.writeTextElement("AGFLow", QString::number(details->aGFLow)); writer.writeTextElement("AGFLow", QString::number(details.aGFLow));
writer.writeTextElement("CalibrationGas", QString::number(details->calibrationGas)); writer.writeTextElement("CalibrationGas", QString::number(details.calibrationGas));
writer.writeTextElement("FlipScreen", QString::number(details->flipScreen)); writer.writeTextElement("FlipScreen", QString::number(details.flipScreen));
writer.writeTextElement("SetPointFallback", QString::number(details->setPointFallback)); writer.writeTextElement("SetPointFallback", QString::number(details.setPointFallback));
writer.writeTextElement("LeftButtonSensitivity", QString::number(details->leftButtonSensitivity)); writer.writeTextElement("LeftButtonSensitivity", QString::number(details.leftButtonSensitivity));
writer.writeTextElement("RightButtonSensitivity", QString::number(details->rightButtonSensitivity)); writer.writeTextElement("RightButtonSensitivity", QString::number(details.rightButtonSensitivity));
writer.writeTextElement("BottomGasConsumption", QString::number(details->bottomGasConsumption)); writer.writeTextElement("BottomGasConsumption", QString::number(details.bottomGasConsumption));
writer.writeTextElement("DecoGasConsumption", QString::number(details->decoGasConsumption)); writer.writeTextElement("DecoGasConsumption", QString::number(details.decoGasConsumption));
writer.writeTextElement("ModWarning", QString::number(details->modWarning)); writer.writeTextElement("ModWarning", QString::number(details.modWarning));
writer.writeTextElement("DynamicAscendRate", QString::number(details->dynamicAscendRate)); writer.writeTextElement("DynamicAscendRate", QString::number(details.dynamicAscendRate));
writer.writeTextElement("GraphicalSpeedIndicator", QString::number(details->graphicalSpeedIndicator)); writer.writeTextElement("GraphicalSpeedIndicator", QString::number(details.graphicalSpeedIndicator));
writer.writeTextElement("AlwaysShowppO2", QString::number(details->alwaysShowppO2)); writer.writeTextElement("AlwaysShowppO2", QString::number(details.alwaysShowppO2));
// Suunto vyper settings. // Suunto vyper settings.
writer.writeTextElement("Altitude", QString::number(details->altitude)); writer.writeTextElement("Altitude", QString::number(details.altitude));
writer.writeTextElement("PersonalSafety", QString::number(details->personalSafety)); writer.writeTextElement("PersonalSafety", QString::number(details.personalSafety));
writer.writeTextElement("TimeFormat", QString::number(details->timeFormat)); writer.writeTextElement("TimeFormat", QString::number(details.timeFormat));
writer.writeStartElement("Light"); writer.writeStartElement("Light");
writer.writeAttribute("enabled", QString::number(details->lightEnabled)); writer.writeAttribute("enabled", QString::number(details.lightEnabled));
writer.writeCharacters(QString::number(details->light)); writer.writeCharacters(QString::number(details.light));
writer.writeEndElement(); writer.writeEndElement();
writer.writeStartElement("AlarmTime"); writer.writeStartElement("AlarmTime");
writer.writeAttribute("enabled", QString::number(details->alarmTimeEnabled)); writer.writeAttribute("enabled", QString::number(details.alarmTimeEnabled));
writer.writeCharacters(QString::number(details->alarmTime)); writer.writeCharacters(QString::number(details.alarmTime));
writer.writeEndElement(); writer.writeEndElement();
writer.writeStartElement("AlarmDepth"); writer.writeStartElement("AlarmDepth");
writer.writeAttribute("enabled", QString::number(details->alarmDepthEnabled)); writer.writeAttribute("enabled", QString::number(details.alarmDepthEnabled));
writer.writeCharacters(QString::number(details->alarmDepth)); writer.writeCharacters(QString::number(details.alarmDepth));
writer.writeEndElement(); writer.writeEndElement();
writer.writeEndElement(); writer.writeEndElement();
@ -192,7 +192,7 @@ bool ConfigureDiveComputer::saveXMLBackup(const QString &fileName, DeviceDetails
return true; return true;
} }
bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDetails *details) bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDetails &details)
{ {
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
@ -211,7 +211,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
QString keyString = reader.text().toString(); QString keyString = reader.text().toString();
if (settingName == "CustomText") if (settingName == "CustomText")
details->customText = keyString; details.customText = keyString;
if (settingName == "Gas1") { if (settingName == "Gas1") {
QStringList gasData = keyString.split(","); QStringList gasData = keyString.split(",");
@ -220,7 +220,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
gas1.helium = gasData.at(1).toInt(); gas1.helium = gasData.at(1).toInt();
gas1.type = gasData.at(2).toInt(); gas1.type = gasData.at(2).toInt();
gas1.depth = gasData.at(3).toInt(); gas1.depth = gasData.at(3).toInt();
details->gas1 = gas1; details.gas1 = gas1;
} }
if (settingName == "Gas2") { if (settingName == "Gas2") {
@ -230,7 +230,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
gas2.helium = gasData.at(1).toInt(); gas2.helium = gasData.at(1).toInt();
gas2.type = gasData.at(2).toInt(); gas2.type = gasData.at(2).toInt();
gas2.depth = gasData.at(3).toInt(); gas2.depth = gasData.at(3).toInt();
details->gas2 = gas2; details.gas2 = gas2;
} }
if (settingName == "Gas3") { if (settingName == "Gas3") {
@ -240,7 +240,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
gas3.helium = gasData.at(1).toInt(); gas3.helium = gasData.at(1).toInt();
gas3.type = gasData.at(2).toInt(); gas3.type = gasData.at(2).toInt();
gas3.depth = gasData.at(3).toInt(); gas3.depth = gasData.at(3).toInt();
details->gas3 = gas3; details.gas3 = gas3;
} }
if (settingName == "Gas4") { if (settingName == "Gas4") {
@ -250,7 +250,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
gas4.helium = gasData.at(1).toInt(); gas4.helium = gasData.at(1).toInt();
gas4.type = gasData.at(2).toInt(); gas4.type = gasData.at(2).toInt();
gas4.depth = gasData.at(3).toInt(); gas4.depth = gasData.at(3).toInt();
details->gas4 = gas4; details.gas4 = gas4;
} }
if (settingName == "Gas5") { if (settingName == "Gas5") {
@ -260,7 +260,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
gas5.helium = gasData.at(1).toInt(); gas5.helium = gasData.at(1).toInt();
gas5.type = gasData.at(2).toInt(); gas5.type = gasData.at(2).toInt();
gas5.depth = gasData.at(3).toInt(); gas5.depth = gasData.at(3).toInt();
details->gas5 = gas5; details.gas5 = gas5;
} }
if (settingName == "Dil1") { if (settingName == "Dil1") {
@ -270,7 +270,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
dil1.helium = dilData.at(1).toInt(); dil1.helium = dilData.at(1).toInt();
dil1.type = dilData.at(2).toInt(); dil1.type = dilData.at(2).toInt();
dil1.depth = dilData.at(3).toInt(); dil1.depth = dilData.at(3).toInt();
details->dil1 = dil1; details.dil1 = dil1;
} }
if (settingName == "Dil2") { if (settingName == "Dil2") {
@ -280,7 +280,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
dil2.helium = dilData.at(1).toInt(); dil2.helium = dilData.at(1).toInt();
dil2.type = dilData.at(2).toInt(); dil2.type = dilData.at(2).toInt();
dil2.depth = dilData.at(3).toInt(); dil2.depth = dilData.at(3).toInt();
details->dil1 = dil2; details.dil1 = dil2;
} }
if (settingName == "Dil3") { if (settingName == "Dil3") {
@ -290,7 +290,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
dil3.helium = dilData.at(1).toInt(); dil3.helium = dilData.at(1).toInt();
dil3.type = dilData.at(2).toInt(); dil3.type = dilData.at(2).toInt();
dil3.depth = dilData.at(3).toInt(); dil3.depth = dilData.at(3).toInt();
details->dil3 = dil3; details.dil3 = dil3;
} }
if (settingName == "Dil4") { if (settingName == "Dil4") {
@ -300,7 +300,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
dil4.helium = dilData.at(1).toInt(); dil4.helium = dilData.at(1).toInt();
dil4.type = dilData.at(2).toInt(); dil4.type = dilData.at(2).toInt();
dil4.depth = dilData.at(3).toInt(); dil4.depth = dilData.at(3).toInt();
details->dil4 = dil4; details.dil4 = dil4;
} }
if (settingName == "Dil5") { if (settingName == "Dil5") {
@ -310,7 +310,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
dil5.helium = dilData.at(1).toInt(); dil5.helium = dilData.at(1).toInt();
dil5.type = dilData.at(2).toInt(); dil5.type = dilData.at(2).toInt();
dil5.depth = dilData.at(3).toInt(); dil5.depth = dilData.at(3).toInt();
details->dil5 = dil5; details.dil5 = dil5;
} }
if (settingName == "SetPoint1") { if (settingName == "SetPoint1") {
@ -318,7 +318,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
setpoint sp1; setpoint sp1;
sp1.sp = spData.at(0).toInt(); sp1.sp = spData.at(0).toInt();
sp1.depth = spData.at(1).toInt(); sp1.depth = spData.at(1).toInt();
details->sp1 = sp1; details.sp1 = sp1;
} }
if (settingName == "SetPoint2") { if (settingName == "SetPoint2") {
@ -326,7 +326,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
setpoint sp2; setpoint sp2;
sp2.sp = spData.at(0).toInt(); sp2.sp = spData.at(0).toInt();
sp2.depth = spData.at(1).toInt(); sp2.depth = spData.at(1).toInt();
details->sp2 = sp2; details.sp2 = sp2;
} }
if (settingName == "SetPoint3") { if (settingName == "SetPoint3") {
@ -334,7 +334,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
setpoint sp3; setpoint sp3;
sp3.sp = spData.at(0).toInt(); sp3.sp = spData.at(0).toInt();
sp3.depth = spData.at(1).toInt(); sp3.depth = spData.at(1).toInt();
details->sp3 = sp3; details.sp3 = sp3;
} }
if (settingName == "SetPoint4") { if (settingName == "SetPoint4") {
@ -342,7 +342,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
setpoint sp4; setpoint sp4;
sp4.sp = spData.at(0).toInt(); sp4.sp = spData.at(0).toInt();
sp4.depth = spData.at(1).toInt(); sp4.depth = spData.at(1).toInt();
details->sp4 = sp4; details.sp4 = sp4;
} }
if (settingName == "SetPoint5") { if (settingName == "SetPoint5") {
@ -350,139 +350,139 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
setpoint sp5; setpoint sp5;
sp5.sp = spData.at(0).toInt(); sp5.sp = spData.at(0).toInt();
sp5.depth = spData.at(1).toInt(); sp5.depth = spData.at(1).toInt();
details->sp5 = sp5; details.sp5 = sp5;
} }
if (settingName == "Saturation") if (settingName == "Saturation")
details->saturation = keyString.toInt(); details.saturation = keyString.toInt();
if (settingName == "Desaturation") if (settingName == "Desaturation")
details->desaturation = keyString.toInt(); details.desaturation = keyString.toInt();
if (settingName == "DiveMode") if (settingName == "DiveMode")
details->diveMode = keyString.toInt(); details.diveMode = keyString.toInt();
if (settingName == "LastDeco") if (settingName == "LastDeco")
details->lastDeco = keyString.toInt(); details.lastDeco = keyString.toInt();
if (settingName == "Brightness") if (settingName == "Brightness")
details->brightness = keyString.toInt(); details.brightness = keyString.toInt();
if (settingName == "Units") if (settingName == "Units")
details->units = keyString.toInt(); details.units = keyString.toInt();
if (settingName == "SamplingRate") if (settingName == "SamplingRate")
details->samplingRate = keyString.toInt(); details.samplingRate = keyString.toInt();
if (settingName == "Salinity") if (settingName == "Salinity")
details->salinity = keyString.toInt(); details.salinity = keyString.toInt();
if (settingName == "DiveModeColour") if (settingName == "DiveModeColour")
details->diveModeColor = keyString.toInt(); details.diveModeColor = keyString.toInt();
if (settingName == "Language") if (settingName == "Language")
details->language = keyString.toInt(); details.language = keyString.toInt();
if (settingName == "DateFormat") if (settingName == "DateFormat")
details->dateFormat = keyString.toInt(); details.dateFormat = keyString.toInt();
if (settingName == "CompassGain") if (settingName == "CompassGain")
details->compassGain = keyString.toInt(); details.compassGain = keyString.toInt();
if (settingName == "SafetyStop") if (settingName == "SafetyStop")
details->safetyStop = keyString.toInt(); details.safetyStop = keyString.toInt();
if (settingName == "GfHigh") if (settingName == "GfHigh")
details->gfHigh = keyString.toInt(); details.gfHigh = keyString.toInt();
if (settingName == "GfLow") if (settingName == "GfLow")
details->gfLow = keyString.toInt(); details.gfLow = keyString.toInt();
if (settingName == "PressureSensorOffset") if (settingName == "PressureSensorOffset")
details->pressureSensorOffset = keyString.toInt(); details.pressureSensorOffset = keyString.toInt();
if (settingName == "PpO2Min") if (settingName == "PpO2Min")
details->ppO2Min = keyString.toInt(); details.ppO2Min = keyString.toInt();
if (settingName == "PpO2Max") if (settingName == "PpO2Max")
details->ppO2Max = keyString.toInt(); details.ppO2Max = keyString.toInt();
if (settingName == "FutureTTS") if (settingName == "FutureTTS")
details->futureTTS = keyString.toInt(); details.futureTTS = keyString.toInt();
if (settingName == "CcrMode") if (settingName == "CcrMode")
details->ccrMode = keyString.toInt(); details.ccrMode = keyString.toInt();
if (settingName == "DecoType") if (settingName == "DecoType")
details->decoType = keyString.toInt(); details.decoType = keyString.toInt();
if (settingName == "AGFSelectable") if (settingName == "AGFSelectable")
details->aGFSelectable = keyString.toInt(); details.aGFSelectable = keyString.toInt();
if (settingName == "AGFHigh") if (settingName == "AGFHigh")
details->aGFHigh = keyString.toInt(); details.aGFHigh = keyString.toInt();
if (settingName == "AGFLow") if (settingName == "AGFLow")
details->aGFLow = keyString.toInt(); details.aGFLow = keyString.toInt();
if (settingName == "CalibrationGas") if (settingName == "CalibrationGas")
details->calibrationGas = keyString.toInt(); details.calibrationGas = keyString.toInt();
if (settingName == "FlipScreen") if (settingName == "FlipScreen")
details->flipScreen = keyString.toInt(); details.flipScreen = keyString.toInt();
if (settingName == "SetPointFallback") if (settingName == "SetPointFallback")
details->setPointFallback = keyString.toInt(); details.setPointFallback = keyString.toInt();
if (settingName == "LeftButtonSensitivity") if (settingName == "LeftButtonSensitivity")
details->leftButtonSensitivity = keyString.toInt(); details.leftButtonSensitivity = keyString.toInt();
if (settingName == "RightButtonSensitivity") if (settingName == "RightButtonSensitivity")
details->rightButtonSensitivity = keyString.toInt(); details.rightButtonSensitivity = keyString.toInt();
if (settingName == "BottomGasConsumption") if (settingName == "BottomGasConsumption")
details->bottomGasConsumption = keyString.toInt(); details.bottomGasConsumption = keyString.toInt();
if (settingName == "DecoGasConsumption") if (settingName == "DecoGasConsumption")
details->decoGasConsumption = keyString.toInt(); details.decoGasConsumption = keyString.toInt();
if (settingName == "ModWarning") if (settingName == "ModWarning")
details->modWarning = keyString.toInt(); details.modWarning = keyString.toInt();
if (settingName == "DynamicAscendRate") if (settingName == "DynamicAscendRate")
details->dynamicAscendRate = keyString.toInt(); details.dynamicAscendRate = keyString.toInt();
if (settingName == "GraphicalSpeedIndicator") if (settingName == "GraphicalSpeedIndicator")
details->graphicalSpeedIndicator = keyString.toInt(); details.graphicalSpeedIndicator = keyString.toInt();
if (settingName == "AlwaysShowppO2") if (settingName == "AlwaysShowppO2")
details->alwaysShowppO2 = keyString.toInt(); details.alwaysShowppO2 = keyString.toInt();
if (settingName == "Altitude") if (settingName == "Altitude")
details->altitude = keyString.toInt(); details.altitude = keyString.toInt();
if (settingName == "PersonalSafety") if (settingName == "PersonalSafety")
details->personalSafety = keyString.toInt(); details.personalSafety = keyString.toInt();
if (settingName == "TimeFormat") if (settingName == "TimeFormat")
details->timeFormat = keyString.toInt(); details.timeFormat = keyString.toInt();
if (settingName == "Light") { if (settingName == "Light") {
if (attributes.hasAttribute("enabled")) if (attributes.hasAttribute("enabled"))
details->lightEnabled = attributes.value("enabled").toString().toInt(); details.lightEnabled = attributes.value("enabled").toString().toInt();
details->light = keyString.toInt(); details.light = keyString.toInt();
} }
if (settingName == "AlarmDepth") { if (settingName == "AlarmDepth") {
if (attributes.hasAttribute("enabled")) if (attributes.hasAttribute("enabled"))
details->alarmDepthEnabled = attributes.value("enabled").toString().toInt(); details.alarmDepthEnabled = attributes.value("enabled").toString().toInt();
details->alarmDepth = keyString.toInt(); details.alarmDepth = keyString.toInt();
} }
if (settingName == "AlarmTime") { if (settingName == "AlarmTime") {
if (attributes.hasAttribute("enabled")) if (attributes.hasAttribute("enabled"))
details->alarmTimeEnabled = attributes.value("enabled").toString().toInt(); details.alarmTimeEnabled = attributes.value("enabled").toString().toInt();
details->alarmTime = keyString.toInt(); details.alarmTime = keyString.toInt();
} }
} }
reader.readNext(); reader.readNext();

View file

@ -32,10 +32,10 @@ public:
QString lastError; QString lastError;
states currentState; states currentState;
void saveDeviceDetails(DeviceDetails *details, device_data_t *data); void saveDeviceDetails(const DeviceDetails &details, device_data_t *data);
void fetchDeviceDetails(); void fetchDeviceDetails();
bool saveXMLBackup(const QString &fileName, DeviceDetails *details, device_data_t *data); bool saveXMLBackup(const QString &fileName, const DeviceDetails &details, device_data_t *data);
bool restoreXMLBackup(const QString &fileName, DeviceDetails *details); bool restoreXMLBackup(const QString &fileName, DeviceDetails &details);
void startFirmwareUpdate(const QString &fileName, device_data_t *data, bool forceUpdate); void startFirmwareUpdate(const QString &fileName, device_data_t *data, bool forceUpdate);
void resetSettings(device_data_t *data); void resetSettings(device_data_t *data);
@ -48,7 +48,7 @@ signals:
void message(QString msg); void message(QString msg);
void error(QString err); void error(QString err);
void stateChanged(states newState); void stateChanged(states newState);
void deviceDetailsChanged(DeviceDetails *newDetails); void deviceDetailsChanged(DeviceDetails newDetails);
private: private:
ReadSettingsThread *readThread; ReadSettingsThread *readThread;

File diff suppressed because it is too large Load diff

View file

@ -27,18 +27,18 @@ public:
ReadSettingsThread(QObject *parent, device_data_t *data); ReadSettingsThread(QObject *parent, device_data_t *data);
void run(); void run();
signals: signals:
void devicedetails(DeviceDetails *newDeviceDetails); void devicedetails(DeviceDetails newDeviceDetails);
}; };
class WriteSettingsThread : public DeviceThread { class WriteSettingsThread : public DeviceThread {
Q_OBJECT Q_OBJECT
public: public:
WriteSettingsThread(QObject *parent, device_data_t *data); WriteSettingsThread(QObject *parent, device_data_t *data);
void setDeviceDetails(DeviceDetails *details); void setDeviceDetails(const DeviceDetails &details);
void run(); void run();
private: private:
DeviceDetails *m_deviceDetails; DeviceDetails m_deviceDetails;
}; };
class FirmwareUpdateThread : public DeviceThread { class FirmwareUpdateThread : public DeviceThread {

View file

@ -11,8 +11,7 @@ setpoint::setpoint(unsigned char sp, unsigned char depth) :
{ {
} }
DeviceDetails::DeviceDetails(QObject *parent) : DeviceDetails::DeviceDetails() :
QObject(parent),
syncTime(false), syncTime(false),
setPointFallback(0), setPointFallback(0),
ccrMode(0), ccrMode(0),

View file

@ -20,11 +20,10 @@ struct setpoint {
setpoint(unsigned char sp = 0, unsigned char depth = 0); setpoint(unsigned char sp = 0, unsigned char depth = 0);
}; };
class DeviceDetails : public QObject class DeviceDetails
{ {
Q_OBJECT
public: public:
explicit DeviceDetails(QObject *parent = 0); DeviceDetails();
QString serialNo; QString serialNo;
QString firmwareVersion; QString firmwareVersion;
@ -103,5 +102,6 @@ public:
unsigned safetyStopResetDepth; unsigned safetyStopResetDepth;
}; };
Q_DECLARE_METATYPE(DeviceDetails);
#endif // DEVICEDETAILS_H #endif // DEVICEDETAILS_H

File diff suppressed because it is too large Load diff

View file

@ -74,7 +74,7 @@ slots:
void configError(QString err); void configError(QString err);
void on_close_clicked(); void on_close_clicked();
void on_saveSettingsPushButton_clicked(); void on_saveSettingsPushButton_clicked();
void deviceDetailsReceived(DeviceDetails *newDeviceDetails); void deviceDetailsReceived(DeviceDetails newDeviceDetails);
void reloadValues(); void reloadValues();
void on_backupButton_clicked(); void on_backupButton_clicked();
@ -104,7 +104,7 @@ private:
void fill_device_list(unsigned int transport); void fill_device_list(unsigned int transport);
DeviceDetails *deviceDetails; DeviceDetails deviceDetails;
void populateDeviceDetails(); void populateDeviceDetails();
void populateDeviceDetailsOSTC3(); void populateDeviceDetailsOSTC3();
void populateDeviceDetailsOSTC(); void populateDeviceDetailsOSTC();

View file

@ -8,6 +8,7 @@
#endif #endif
#include "stats/statsview.h" #include "stats/statsview.h"
#include "core/devicedetails.h"
#include "core/globals.h" #include "core/globals.h"
#include "core/qt-gui.h" #include "core/qt-gui.h"
#include "core/settings/qPref.h" #include "core/settings/qPref.h"
@ -201,6 +202,7 @@ Q_DECLARE_METATYPE(duration_t)
static void register_meta_types() static void register_meta_types()
{ {
qRegisterMetaType<duration_t>(); qRegisterMetaType<duration_t>();
qRegisterMetaType<DeviceDetails>();
} }
template <typename T> template <typename T>