mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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:
parent
322c1b56b2
commit
8733828380
9 changed files with 861 additions and 865 deletions
|
@ -41,7 +41,7 @@ void ConfigureDiveComputer::readSettings(device_data_t *data)
|
|||
readThread->start();
|
||||
}
|
||||
|
||||
void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_data_t *data)
|
||||
void ConfigureDiveComputer::saveDeviceDetails(const DeviceDetails &details, device_data_t *data)
|
||||
{
|
||||
setState(WRITING);
|
||||
|
||||
|
@ -65,7 +65,7 @@ static QString writeGasDetails(gas g)
|
|||
}).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 vendor = data->vendor;
|
||||
|
@ -80,37 +80,37 @@ bool ConfigureDiveComputer::saveXMLBackup(const QString &fileName, DeviceDetails
|
|||
writer.writeTextElement("Product", product);
|
||||
writer.writeEndElement();
|
||||
writer.writeStartElement("Settings");
|
||||
writer.writeTextElement("CustomText", details->customText);
|
||||
writer.writeTextElement("CustomText", details.customText);
|
||||
//Add gasses
|
||||
writer.writeTextElement("Gas1", writeGasDetails(details->gas1));
|
||||
writer.writeTextElement("Gas2", writeGasDetails(details->gas2));
|
||||
writer.writeTextElement("Gas3", writeGasDetails(details->gas3));
|
||||
writer.writeTextElement("Gas4", writeGasDetails(details->gas4));
|
||||
writer.writeTextElement("Gas5", writeGasDetails(details->gas5));
|
||||
writer.writeTextElement("Gas1", writeGasDetails(details.gas1));
|
||||
writer.writeTextElement("Gas2", writeGasDetails(details.gas2));
|
||||
writer.writeTextElement("Gas3", writeGasDetails(details.gas3));
|
||||
writer.writeTextElement("Gas4", writeGasDetails(details.gas4));
|
||||
writer.writeTextElement("Gas5", writeGasDetails(details.gas5));
|
||||
//
|
||||
//Add dil values
|
||||
writer.writeTextElement("Dil1", writeGasDetails(details->dil1));
|
||||
writer.writeTextElement("Dil2", writeGasDetails(details->dil2));
|
||||
writer.writeTextElement("Dil3", writeGasDetails(details->dil3));
|
||||
writer.writeTextElement("Dil4", writeGasDetails(details->dil4));
|
||||
writer.writeTextElement("Dil5", writeGasDetails(details->dil5));
|
||||
writer.writeTextElement("Dil1", writeGasDetails(details.dil1));
|
||||
writer.writeTextElement("Dil2", writeGasDetails(details.dil2));
|
||||
writer.writeTextElement("Dil3", writeGasDetails(details.dil3));
|
||||
writer.writeTextElement("Dil4", writeGasDetails(details.dil4));
|
||||
writer.writeTextElement("Dil5", writeGasDetails(details.dil5));
|
||||
|
||||
//Add setpoint values
|
||||
QString sp1 = QString("%1,%2")
|
||||
.arg(QString::number(details->sp1.sp),
|
||||
QString::number(details->sp1.depth));
|
||||
.arg(QString::number(details.sp1.sp),
|
||||
QString::number(details.sp1.depth));
|
||||
QString sp2 = QString("%1,%2")
|
||||
.arg(QString::number(details->sp2.sp),
|
||||
QString::number(details->sp2.depth));
|
||||
.arg(QString::number(details.sp2.sp),
|
||||
QString::number(details.sp2.depth));
|
||||
QString sp3 = QString("%1,%2")
|
||||
.arg(QString::number(details->sp3.sp),
|
||||
QString::number(details->sp3.depth));
|
||||
.arg(QString::number(details.sp3.sp),
|
||||
QString::number(details.sp3.depth));
|
||||
QString sp4 = QString("%1,%2")
|
||||
.arg(QString::number(details->sp4.sp),
|
||||
QString::number(details->sp4.depth));
|
||||
.arg(QString::number(details.sp4.sp),
|
||||
QString::number(details.sp4.depth));
|
||||
QString sp5 = QString("%1,%2")
|
||||
.arg(QString::number(details->sp5.sp),
|
||||
QString::number(details->sp5.depth));
|
||||
.arg(QString::number(details.sp5.sp),
|
||||
QString::number(details.sp5.depth));
|
||||
writer.writeTextElement("SetPoint1", sp1);
|
||||
writer.writeTextElement("SetPoint2", sp2);
|
||||
writer.writeTextElement("SetPoint3", sp3);
|
||||
|
@ -118,60 +118,60 @@ bool ConfigureDiveComputer::saveXMLBackup(const QString &fileName, DeviceDetails
|
|||
writer.writeTextElement("SetPoint5", sp5);
|
||||
|
||||
//Other Settings
|
||||
writer.writeTextElement("DiveMode", QString::number(details->diveMode));
|
||||
writer.writeTextElement("Saturation", QString::number(details->saturation));
|
||||
writer.writeTextElement("Desaturation", QString::number(details->desaturation));
|
||||
writer.writeTextElement("LastDeco", QString::number(details->lastDeco));
|
||||
writer.writeTextElement("Brightness", QString::number(details->brightness));
|
||||
writer.writeTextElement("Units", QString::number(details->units));
|
||||
writer.writeTextElement("SamplingRate", QString::number(details->samplingRate));
|
||||
writer.writeTextElement("Salinity", QString::number(details->salinity));
|
||||
writer.writeTextElement("DiveModeColor", QString::number(details->diveModeColor));
|
||||
writer.writeTextElement("Language", QString::number(details->language));
|
||||
writer.writeTextElement("DateFormat", QString::number(details->dateFormat));
|
||||
writer.writeTextElement("CompassGain", QString::number(details->compassGain));
|
||||
writer.writeTextElement("SafetyStop", QString::number(details->safetyStop));
|
||||
writer.writeTextElement("GfHigh", QString::number(details->gfHigh));
|
||||
writer.writeTextElement("GfLow", QString::number(details->gfLow));
|
||||
writer.writeTextElement("PressureSensorOffset", QString::number(details->pressureSensorOffset));
|
||||
writer.writeTextElement("PpO2Min", QString::number(details->ppO2Min));
|
||||
writer.writeTextElement("PpO2Max", QString::number(details->ppO2Max));
|
||||
writer.writeTextElement("FutureTTS", QString::number(details->futureTTS));
|
||||
writer.writeTextElement("CcrMode", QString::number(details->ccrMode));
|
||||
writer.writeTextElement("DecoType", QString::number(details->decoType));
|
||||
writer.writeTextElement("AGFSelectable", QString::number(details->aGFSelectable));
|
||||
writer.writeTextElement("AGFHigh", QString::number(details->aGFHigh));
|
||||
writer.writeTextElement("AGFLow", QString::number(details->aGFLow));
|
||||
writer.writeTextElement("CalibrationGas", QString::number(details->calibrationGas));
|
||||
writer.writeTextElement("FlipScreen", QString::number(details->flipScreen));
|
||||
writer.writeTextElement("SetPointFallback", QString::number(details->setPointFallback));
|
||||
writer.writeTextElement("LeftButtonSensitivity", QString::number(details->leftButtonSensitivity));
|
||||
writer.writeTextElement("RightButtonSensitivity", QString::number(details->rightButtonSensitivity));
|
||||
writer.writeTextElement("BottomGasConsumption", QString::number(details->bottomGasConsumption));
|
||||
writer.writeTextElement("DecoGasConsumption", QString::number(details->decoGasConsumption));
|
||||
writer.writeTextElement("ModWarning", QString::number(details->modWarning));
|
||||
writer.writeTextElement("DynamicAscendRate", QString::number(details->dynamicAscendRate));
|
||||
writer.writeTextElement("GraphicalSpeedIndicator", QString::number(details->graphicalSpeedIndicator));
|
||||
writer.writeTextElement("AlwaysShowppO2", QString::number(details->alwaysShowppO2));
|
||||
writer.writeTextElement("DiveMode", QString::number(details.diveMode));
|
||||
writer.writeTextElement("Saturation", QString::number(details.saturation));
|
||||
writer.writeTextElement("Desaturation", QString::number(details.desaturation));
|
||||
writer.writeTextElement("LastDeco", QString::number(details.lastDeco));
|
||||
writer.writeTextElement("Brightness", QString::number(details.brightness));
|
||||
writer.writeTextElement("Units", QString::number(details.units));
|
||||
writer.writeTextElement("SamplingRate", QString::number(details.samplingRate));
|
||||
writer.writeTextElement("Salinity", QString::number(details.salinity));
|
||||
writer.writeTextElement("DiveModeColor", QString::number(details.diveModeColor));
|
||||
writer.writeTextElement("Language", QString::number(details.language));
|
||||
writer.writeTextElement("DateFormat", QString::number(details.dateFormat));
|
||||
writer.writeTextElement("CompassGain", QString::number(details.compassGain));
|
||||
writer.writeTextElement("SafetyStop", QString::number(details.safetyStop));
|
||||
writer.writeTextElement("GfHigh", QString::number(details.gfHigh));
|
||||
writer.writeTextElement("GfLow", QString::number(details.gfLow));
|
||||
writer.writeTextElement("PressureSensorOffset", QString::number(details.pressureSensorOffset));
|
||||
writer.writeTextElement("PpO2Min", QString::number(details.ppO2Min));
|
||||
writer.writeTextElement("PpO2Max", QString::number(details.ppO2Max));
|
||||
writer.writeTextElement("FutureTTS", QString::number(details.futureTTS));
|
||||
writer.writeTextElement("CcrMode", QString::number(details.ccrMode));
|
||||
writer.writeTextElement("DecoType", QString::number(details.decoType));
|
||||
writer.writeTextElement("AGFSelectable", QString::number(details.aGFSelectable));
|
||||
writer.writeTextElement("AGFHigh", QString::number(details.aGFHigh));
|
||||
writer.writeTextElement("AGFLow", QString::number(details.aGFLow));
|
||||
writer.writeTextElement("CalibrationGas", QString::number(details.calibrationGas));
|
||||
writer.writeTextElement("FlipScreen", QString::number(details.flipScreen));
|
||||
writer.writeTextElement("SetPointFallback", QString::number(details.setPointFallback));
|
||||
writer.writeTextElement("LeftButtonSensitivity", QString::number(details.leftButtonSensitivity));
|
||||
writer.writeTextElement("RightButtonSensitivity", QString::number(details.rightButtonSensitivity));
|
||||
writer.writeTextElement("BottomGasConsumption", QString::number(details.bottomGasConsumption));
|
||||
writer.writeTextElement("DecoGasConsumption", QString::number(details.decoGasConsumption));
|
||||
writer.writeTextElement("ModWarning", QString::number(details.modWarning));
|
||||
writer.writeTextElement("DynamicAscendRate", QString::number(details.dynamicAscendRate));
|
||||
writer.writeTextElement("GraphicalSpeedIndicator", QString::number(details.graphicalSpeedIndicator));
|
||||
writer.writeTextElement("AlwaysShowppO2", QString::number(details.alwaysShowppO2));
|
||||
|
||||
// Suunto vyper settings.
|
||||
writer.writeTextElement("Altitude", QString::number(details->altitude));
|
||||
writer.writeTextElement("PersonalSafety", QString::number(details->personalSafety));
|
||||
writer.writeTextElement("TimeFormat", QString::number(details->timeFormat));
|
||||
writer.writeTextElement("Altitude", QString::number(details.altitude));
|
||||
writer.writeTextElement("PersonalSafety", QString::number(details.personalSafety));
|
||||
writer.writeTextElement("TimeFormat", QString::number(details.timeFormat));
|
||||
|
||||
writer.writeStartElement("Light");
|
||||
writer.writeAttribute("enabled", QString::number(details->lightEnabled));
|
||||
writer.writeCharacters(QString::number(details->light));
|
||||
writer.writeAttribute("enabled", QString::number(details.lightEnabled));
|
||||
writer.writeCharacters(QString::number(details.light));
|
||||
writer.writeEndElement();
|
||||
|
||||
writer.writeStartElement("AlarmTime");
|
||||
writer.writeAttribute("enabled", QString::number(details->alarmTimeEnabled));
|
||||
writer.writeCharacters(QString::number(details->alarmTime));
|
||||
writer.writeAttribute("enabled", QString::number(details.alarmTimeEnabled));
|
||||
writer.writeCharacters(QString::number(details.alarmTime));
|
||||
writer.writeEndElement();
|
||||
|
||||
writer.writeStartElement("AlarmDepth");
|
||||
writer.writeAttribute("enabled", QString::number(details->alarmDepthEnabled));
|
||||
writer.writeCharacters(QString::number(details->alarmDepth));
|
||||
writer.writeAttribute("enabled", QString::number(details.alarmDepthEnabled));
|
||||
writer.writeCharacters(QString::number(details.alarmDepth));
|
||||
writer.writeEndElement();
|
||||
|
||||
writer.writeEndElement();
|
||||
|
@ -192,7 +192,7 @@ bool ConfigureDiveComputer::saveXMLBackup(const QString &fileName, DeviceDetails
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDetails *details)
|
||||
bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDetails &details)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
|
@ -211,7 +211,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
QString keyString = reader.text().toString();
|
||||
|
||||
if (settingName == "CustomText")
|
||||
details->customText = keyString;
|
||||
details.customText = keyString;
|
||||
|
||||
if (settingName == "Gas1") {
|
||||
QStringList gasData = keyString.split(",");
|
||||
|
@ -220,7 +220,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
gas1.helium = gasData.at(1).toInt();
|
||||
gas1.type = gasData.at(2).toInt();
|
||||
gas1.depth = gasData.at(3).toInt();
|
||||
details->gas1 = gas1;
|
||||
details.gas1 = gas1;
|
||||
}
|
||||
|
||||
if (settingName == "Gas2") {
|
||||
|
@ -230,7 +230,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
gas2.helium = gasData.at(1).toInt();
|
||||
gas2.type = gasData.at(2).toInt();
|
||||
gas2.depth = gasData.at(3).toInt();
|
||||
details->gas2 = gas2;
|
||||
details.gas2 = gas2;
|
||||
}
|
||||
|
||||
if (settingName == "Gas3") {
|
||||
|
@ -240,7 +240,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
gas3.helium = gasData.at(1).toInt();
|
||||
gas3.type = gasData.at(2).toInt();
|
||||
gas3.depth = gasData.at(3).toInt();
|
||||
details->gas3 = gas3;
|
||||
details.gas3 = gas3;
|
||||
}
|
||||
|
||||
if (settingName == "Gas4") {
|
||||
|
@ -250,7 +250,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
gas4.helium = gasData.at(1).toInt();
|
||||
gas4.type = gasData.at(2).toInt();
|
||||
gas4.depth = gasData.at(3).toInt();
|
||||
details->gas4 = gas4;
|
||||
details.gas4 = gas4;
|
||||
}
|
||||
|
||||
if (settingName == "Gas5") {
|
||||
|
@ -260,7 +260,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
gas5.helium = gasData.at(1).toInt();
|
||||
gas5.type = gasData.at(2).toInt();
|
||||
gas5.depth = gasData.at(3).toInt();
|
||||
details->gas5 = gas5;
|
||||
details.gas5 = gas5;
|
||||
}
|
||||
|
||||
if (settingName == "Dil1") {
|
||||
|
@ -270,7 +270,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
dil1.helium = dilData.at(1).toInt();
|
||||
dil1.type = dilData.at(2).toInt();
|
||||
dil1.depth = dilData.at(3).toInt();
|
||||
details->dil1 = dil1;
|
||||
details.dil1 = dil1;
|
||||
}
|
||||
|
||||
if (settingName == "Dil2") {
|
||||
|
@ -280,7 +280,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
dil2.helium = dilData.at(1).toInt();
|
||||
dil2.type = dilData.at(2).toInt();
|
||||
dil2.depth = dilData.at(3).toInt();
|
||||
details->dil1 = dil2;
|
||||
details.dil1 = dil2;
|
||||
}
|
||||
|
||||
if (settingName == "Dil3") {
|
||||
|
@ -290,7 +290,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
dil3.helium = dilData.at(1).toInt();
|
||||
dil3.type = dilData.at(2).toInt();
|
||||
dil3.depth = dilData.at(3).toInt();
|
||||
details->dil3 = dil3;
|
||||
details.dil3 = dil3;
|
||||
}
|
||||
|
||||
if (settingName == "Dil4") {
|
||||
|
@ -300,7 +300,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
dil4.helium = dilData.at(1).toInt();
|
||||
dil4.type = dilData.at(2).toInt();
|
||||
dil4.depth = dilData.at(3).toInt();
|
||||
details->dil4 = dil4;
|
||||
details.dil4 = dil4;
|
||||
}
|
||||
|
||||
if (settingName == "Dil5") {
|
||||
|
@ -310,7 +310,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
dil5.helium = dilData.at(1).toInt();
|
||||
dil5.type = dilData.at(2).toInt();
|
||||
dil5.depth = dilData.at(3).toInt();
|
||||
details->dil5 = dil5;
|
||||
details.dil5 = dil5;
|
||||
}
|
||||
|
||||
if (settingName == "SetPoint1") {
|
||||
|
@ -318,7 +318,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
setpoint sp1;
|
||||
sp1.sp = spData.at(0).toInt();
|
||||
sp1.depth = spData.at(1).toInt();
|
||||
details->sp1 = sp1;
|
||||
details.sp1 = sp1;
|
||||
}
|
||||
|
||||
if (settingName == "SetPoint2") {
|
||||
|
@ -326,7 +326,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
setpoint sp2;
|
||||
sp2.sp = spData.at(0).toInt();
|
||||
sp2.depth = spData.at(1).toInt();
|
||||
details->sp2 = sp2;
|
||||
details.sp2 = sp2;
|
||||
}
|
||||
|
||||
if (settingName == "SetPoint3") {
|
||||
|
@ -334,7 +334,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
setpoint sp3;
|
||||
sp3.sp = spData.at(0).toInt();
|
||||
sp3.depth = spData.at(1).toInt();
|
||||
details->sp3 = sp3;
|
||||
details.sp3 = sp3;
|
||||
}
|
||||
|
||||
if (settingName == "SetPoint4") {
|
||||
|
@ -342,7 +342,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
setpoint sp4;
|
||||
sp4.sp = spData.at(0).toInt();
|
||||
sp4.depth = spData.at(1).toInt();
|
||||
details->sp4 = sp4;
|
||||
details.sp4 = sp4;
|
||||
}
|
||||
|
||||
if (settingName == "SetPoint5") {
|
||||
|
@ -350,139 +350,139 @@ bool ConfigureDiveComputer::restoreXMLBackup(const QString &fileName, DeviceDeta
|
|||
setpoint sp5;
|
||||
sp5.sp = spData.at(0).toInt();
|
||||
sp5.depth = spData.at(1).toInt();
|
||||
details->sp5 = sp5;
|
||||
details.sp5 = sp5;
|
||||
}
|
||||
|
||||
if (settingName == "Saturation")
|
||||
details->saturation = keyString.toInt();
|
||||
details.saturation = keyString.toInt();
|
||||
|
||||
if (settingName == "Desaturation")
|
||||
details->desaturation = keyString.toInt();
|
||||
details.desaturation = keyString.toInt();
|
||||
|
||||
if (settingName == "DiveMode")
|
||||
details->diveMode = keyString.toInt();
|
||||
details.diveMode = keyString.toInt();
|
||||
|
||||
if (settingName == "LastDeco")
|
||||
details->lastDeco = keyString.toInt();
|
||||
details.lastDeco = keyString.toInt();
|
||||
|
||||
if (settingName == "Brightness")
|
||||
details->brightness = keyString.toInt();
|
||||
details.brightness = keyString.toInt();
|
||||
|
||||
if (settingName == "Units")
|
||||
details->units = keyString.toInt();
|
||||
details.units = keyString.toInt();
|
||||
|
||||
if (settingName == "SamplingRate")
|
||||
details->samplingRate = keyString.toInt();
|
||||
details.samplingRate = keyString.toInt();
|
||||
|
||||
if (settingName == "Salinity")
|
||||
details->salinity = keyString.toInt();
|
||||
details.salinity = keyString.toInt();
|
||||
|
||||
if (settingName == "DiveModeColour")
|
||||
details->diveModeColor = keyString.toInt();
|
||||
details.diveModeColor = keyString.toInt();
|
||||
|
||||
if (settingName == "Language")
|
||||
details->language = keyString.toInt();
|
||||
details.language = keyString.toInt();
|
||||
|
||||
if (settingName == "DateFormat")
|
||||
details->dateFormat = keyString.toInt();
|
||||
details.dateFormat = keyString.toInt();
|
||||
|
||||
if (settingName == "CompassGain")
|
||||
details->compassGain = keyString.toInt();
|
||||
details.compassGain = keyString.toInt();
|
||||
|
||||
if (settingName == "SafetyStop")
|
||||
details->safetyStop = keyString.toInt();
|
||||
details.safetyStop = keyString.toInt();
|
||||
|
||||
if (settingName == "GfHigh")
|
||||
details->gfHigh = keyString.toInt();
|
||||
details.gfHigh = keyString.toInt();
|
||||
|
||||
if (settingName == "GfLow")
|
||||
details->gfLow = keyString.toInt();
|
||||
details.gfLow = keyString.toInt();
|
||||
|
||||
if (settingName == "PressureSensorOffset")
|
||||
details->pressureSensorOffset = keyString.toInt();
|
||||
details.pressureSensorOffset = keyString.toInt();
|
||||
|
||||
if (settingName == "PpO2Min")
|
||||
details->ppO2Min = keyString.toInt();
|
||||
details.ppO2Min = keyString.toInt();
|
||||
|
||||
if (settingName == "PpO2Max")
|
||||
details->ppO2Max = keyString.toInt();
|
||||
details.ppO2Max = keyString.toInt();
|
||||
|
||||
if (settingName == "FutureTTS")
|
||||
details->futureTTS = keyString.toInt();
|
||||
details.futureTTS = keyString.toInt();
|
||||
|
||||
if (settingName == "CcrMode")
|
||||
details->ccrMode = keyString.toInt();
|
||||
details.ccrMode = keyString.toInt();
|
||||
|
||||
if (settingName == "DecoType")
|
||||
details->decoType = keyString.toInt();
|
||||
details.decoType = keyString.toInt();
|
||||
|
||||
if (settingName == "AGFSelectable")
|
||||
details->aGFSelectable = keyString.toInt();
|
||||
details.aGFSelectable = keyString.toInt();
|
||||
|
||||
if (settingName == "AGFHigh")
|
||||
details->aGFHigh = keyString.toInt();
|
||||
details.aGFHigh = keyString.toInt();
|
||||
|
||||
if (settingName == "AGFLow")
|
||||
details->aGFLow = keyString.toInt();
|
||||
details.aGFLow = keyString.toInt();
|
||||
|
||||
if (settingName == "CalibrationGas")
|
||||
details->calibrationGas = keyString.toInt();
|
||||
details.calibrationGas = keyString.toInt();
|
||||
|
||||
if (settingName == "FlipScreen")
|
||||
details->flipScreen = keyString.toInt();
|
||||
details.flipScreen = keyString.toInt();
|
||||
|
||||
if (settingName == "SetPointFallback")
|
||||
details->setPointFallback = keyString.toInt();
|
||||
details.setPointFallback = keyString.toInt();
|
||||
|
||||
if (settingName == "LeftButtonSensitivity")
|
||||
details->leftButtonSensitivity = keyString.toInt();
|
||||
details.leftButtonSensitivity = keyString.toInt();
|
||||
|
||||
if (settingName == "RightButtonSensitivity")
|
||||
details->rightButtonSensitivity = keyString.toInt();
|
||||
details.rightButtonSensitivity = keyString.toInt();
|
||||
|
||||
if (settingName == "BottomGasConsumption")
|
||||
details->bottomGasConsumption = keyString.toInt();
|
||||
details.bottomGasConsumption = keyString.toInt();
|
||||
|
||||
if (settingName == "DecoGasConsumption")
|
||||
details->decoGasConsumption = keyString.toInt();
|
||||
details.decoGasConsumption = keyString.toInt();
|
||||
|
||||
if (settingName == "ModWarning")
|
||||
details->modWarning = keyString.toInt();
|
||||
details.modWarning = keyString.toInt();
|
||||
|
||||
if (settingName == "DynamicAscendRate")
|
||||
details->dynamicAscendRate = keyString.toInt();
|
||||
details.dynamicAscendRate = keyString.toInt();
|
||||
|
||||
if (settingName == "GraphicalSpeedIndicator")
|
||||
details->graphicalSpeedIndicator = keyString.toInt();
|
||||
details.graphicalSpeedIndicator = keyString.toInt();
|
||||
|
||||
if (settingName == "AlwaysShowppO2")
|
||||
details->alwaysShowppO2 = keyString.toInt();
|
||||
details.alwaysShowppO2 = keyString.toInt();
|
||||
|
||||
if (settingName == "Altitude")
|
||||
details->altitude = keyString.toInt();
|
||||
details.altitude = keyString.toInt();
|
||||
|
||||
if (settingName == "PersonalSafety")
|
||||
details->personalSafety = keyString.toInt();
|
||||
details.personalSafety = keyString.toInt();
|
||||
|
||||
if (settingName == "TimeFormat")
|
||||
details->timeFormat = keyString.toInt();
|
||||
details.timeFormat = keyString.toInt();
|
||||
|
||||
if (settingName == "Light") {
|
||||
if (attributes.hasAttribute("enabled"))
|
||||
details->lightEnabled = attributes.value("enabled").toString().toInt();
|
||||
details->light = keyString.toInt();
|
||||
details.lightEnabled = attributes.value("enabled").toString().toInt();
|
||||
details.light = keyString.toInt();
|
||||
}
|
||||
|
||||
if (settingName == "AlarmDepth") {
|
||||
if (attributes.hasAttribute("enabled"))
|
||||
details->alarmDepthEnabled = attributes.value("enabled").toString().toInt();
|
||||
details->alarmDepth = keyString.toInt();
|
||||
details.alarmDepthEnabled = attributes.value("enabled").toString().toInt();
|
||||
details.alarmDepth = keyString.toInt();
|
||||
}
|
||||
|
||||
if (settingName == "AlarmTime") {
|
||||
if (attributes.hasAttribute("enabled"))
|
||||
details->alarmTimeEnabled = attributes.value("enabled").toString().toInt();
|
||||
details->alarmTime = keyString.toInt();
|
||||
details.alarmTimeEnabled = attributes.value("enabled").toString().toInt();
|
||||
details.alarmTime = keyString.toInt();
|
||||
}
|
||||
}
|
||||
reader.readNext();
|
||||
|
|
|
@ -32,10 +32,10 @@ public:
|
|||
|
||||
QString lastError;
|
||||
states currentState;
|
||||
void saveDeviceDetails(DeviceDetails *details, device_data_t *data);
|
||||
void saveDeviceDetails(const DeviceDetails &details, device_data_t *data);
|
||||
void fetchDeviceDetails();
|
||||
bool saveXMLBackup(const QString &fileName, DeviceDetails *details, device_data_t *data);
|
||||
bool restoreXMLBackup(const QString &fileName, DeviceDetails *details);
|
||||
bool saveXMLBackup(const QString &fileName, const DeviceDetails &details, device_data_t *data);
|
||||
bool restoreXMLBackup(const QString &fileName, DeviceDetails &details);
|
||||
void startFirmwareUpdate(const QString &fileName, device_data_t *data, bool forceUpdate);
|
||||
void resetSettings(device_data_t *data);
|
||||
|
||||
|
@ -48,7 +48,7 @@ signals:
|
|||
void message(QString msg);
|
||||
void error(QString err);
|
||||
void stateChanged(states newState);
|
||||
void deviceDetailsChanged(DeviceDetails *newDetails);
|
||||
void deviceDetailsChanged(DeviceDetails newDetails);
|
||||
|
||||
private:
|
||||
ReadSettingsThread *readThread;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -27,18 +27,18 @@ public:
|
|||
ReadSettingsThread(QObject *parent, device_data_t *data);
|
||||
void run();
|
||||
signals:
|
||||
void devicedetails(DeviceDetails *newDeviceDetails);
|
||||
void devicedetails(DeviceDetails newDeviceDetails);
|
||||
};
|
||||
|
||||
class WriteSettingsThread : public DeviceThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
WriteSettingsThread(QObject *parent, device_data_t *data);
|
||||
void setDeviceDetails(DeviceDetails *details);
|
||||
void setDeviceDetails(const DeviceDetails &details);
|
||||
void run();
|
||||
|
||||
private:
|
||||
DeviceDetails *m_deviceDetails;
|
||||
DeviceDetails m_deviceDetails;
|
||||
};
|
||||
|
||||
class FirmwareUpdateThread : public DeviceThread {
|
||||
|
|
|
@ -11,8 +11,7 @@ setpoint::setpoint(unsigned char sp, unsigned char depth) :
|
|||
{
|
||||
}
|
||||
|
||||
DeviceDetails::DeviceDetails(QObject *parent) :
|
||||
QObject(parent),
|
||||
DeviceDetails::DeviceDetails() :
|
||||
syncTime(false),
|
||||
setPointFallback(0),
|
||||
ccrMode(0),
|
||||
|
|
|
@ -20,11 +20,10 @@ struct setpoint {
|
|||
setpoint(unsigned char sp = 0, unsigned char depth = 0);
|
||||
};
|
||||
|
||||
class DeviceDetails : public QObject
|
||||
class DeviceDetails
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DeviceDetails(QObject *parent = 0);
|
||||
DeviceDetails();
|
||||
|
||||
QString serialNo;
|
||||
QString firmwareVersion;
|
||||
|
@ -103,5 +102,6 @@ public:
|
|||
unsigned safetyStopResetDepth;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(DeviceDetails);
|
||||
|
||||
#endif // DEVICEDETAILS_H
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -74,7 +74,7 @@ slots:
|
|||
void configError(QString err);
|
||||
void on_close_clicked();
|
||||
void on_saveSettingsPushButton_clicked();
|
||||
void deviceDetailsReceived(DeviceDetails *newDeviceDetails);
|
||||
void deviceDetailsReceived(DeviceDetails newDeviceDetails);
|
||||
void reloadValues();
|
||||
void on_backupButton_clicked();
|
||||
|
||||
|
@ -104,7 +104,7 @@ private:
|
|||
|
||||
void fill_device_list(unsigned int transport);
|
||||
|
||||
DeviceDetails *deviceDetails;
|
||||
DeviceDetails deviceDetails;
|
||||
void populateDeviceDetails();
|
||||
void populateDeviceDetailsOSTC3();
|
||||
void populateDeviceDetailsOSTC();
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#endif
|
||||
|
||||
#include "stats/statsview.h"
|
||||
#include "core/devicedetails.h"
|
||||
#include "core/globals.h"
|
||||
#include "core/qt-gui.h"
|
||||
#include "core/settings/qPref.h"
|
||||
|
@ -201,6 +202,7 @@ Q_DECLARE_METATYPE(duration_t)
|
|||
static void register_meta_types()
|
||||
{
|
||||
qRegisterMetaType<duration_t>();
|
||||
qRegisterMetaType<DeviceDetails>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
Loading…
Add table
Reference in a new issue