diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-12-28 20:56:58 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-28 21:02:28 -0800 |
commit | b2f4896f3cf4361e9fc499cb8669eba0d114b4fa (patch) | |
tree | 729bb3153658548983dbb2d96983a1a11e7617ab | |
parent | 4559a26e316931695f892b205257979f0ea13afa (diff) | |
download | subsurface-b2f4896f3cf4361e9fc499cb8669eba0d114b4fa.tar.gz |
Whitespace cleanup
Plus removal of a few qDebug() calls I introduced earlier.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | configuredivecomputer.cpp | 126 | ||||
-rw-r--r-- | configuredivecomputer.h | 26 | ||||
-rw-r--r-- | configuredivecomputerthreads.cpp | 317 | ||||
-rw-r--r-- | configuredivecomputerthreads.h | 16 | ||||
-rw-r--r-- | profile.c | 63 | ||||
-rw-r--r-- | qt-ui/configuredivecomputerdialog.cpp | 252 | ||||
-rw-r--r-- | qt-ui/configuredivecomputerdialog.h | 20 |
7 files changed, 402 insertions, 418 deletions
diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index 3364d92be..0997a1609 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -9,8 +9,7 @@ #include <QStringList> #include <QXmlStreamWriter> -ConfigureDiveComputer::ConfigureDiveComputer() : - readThread(0), +ConfigureDiveComputer::ConfigureDiveComputer() : readThread(0), writeThread(0), resetThread(0), firmwareThread(0) @@ -29,8 +28,8 @@ void ConfigureDiveComputer::readSettings(device_data_t *data) connect(readThread, SIGNAL(finished()), this, SLOT(readThreadFinished()), Qt::QueuedConnection); connect(readThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); - connect(readThread, SIGNAL(devicedetails(DeviceDetails*)), this, - SIGNAL(deviceDetailsChanged(DeviceDetails*))); + connect(readThread, SIGNAL(devicedetails(DeviceDetails *)), this, + SIGNAL(deviceDetailsChanged(DeviceDetails *))); readThread->start(); } @@ -69,35 +68,30 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai writer.writeTextElement("CustomText", details->customText()); //Add gasses QString gas1 = QString("%1,%2,%3,%4") - .arg(QString::number(details->gas1().oxygen), - QString::number(details->gas1().helium), - QString::number(details->gas1().type), - QString::number(details->gas1().depth) - ); + .arg(QString::number(details->gas1().oxygen), + QString::number(details->gas1().helium), + QString::number(details->gas1().type), + QString::number(details->gas1().depth)); QString gas2 = QString("%1,%2,%3,%4") - .arg(QString::number(details->gas2().oxygen), - QString::number(details->gas2().helium), - QString::number(details->gas2().type), - QString::number(details->gas2().depth) - ); + .arg(QString::number(details->gas2().oxygen), + QString::number(details->gas2().helium), + QString::number(details->gas2().type), + QString::number(details->gas2().depth)); QString gas3 = QString("%1,%2,%3,%4") - .arg(QString::number(details->gas3().oxygen), - QString::number(details->gas3().helium), - QString::number(details->gas3().type), - QString::number(details->gas3().depth) - ); + .arg(QString::number(details->gas3().oxygen), + QString::number(details->gas3().helium), + QString::number(details->gas3().type), + QString::number(details->gas3().depth)); QString gas4 = QString("%1,%2,%3,%4") - .arg(QString::number(details->gas4().oxygen), - QString::number(details->gas4().helium), - QString::number(details->gas4().type), - QString::number(details->gas4().depth) - ); + .arg(QString::number(details->gas4().oxygen), + QString::number(details->gas4().helium), + QString::number(details->gas4().type), + QString::number(details->gas4().depth)); QString gas5 = QString("%1,%2,%3,%4") - .arg(QString::number(details->gas5().oxygen), - QString::number(details->gas5().helium), - QString::number(details->gas5().type), - QString::number(details->gas5().depth) - ); + .arg(QString::number(details->gas5().oxygen), + QString::number(details->gas5().helium), + QString::number(details->gas5().type), + QString::number(details->gas5().depth)); writer.writeTextElement("Gas1", gas1); writer.writeTextElement("Gas2", gas2); writer.writeTextElement("Gas3", gas3); @@ -106,35 +100,30 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai // //Add dil values QString dil1 = QString("%1,%2,%3,%4") - .arg(QString::number(details->dil1().oxygen), - QString::number(details->dil1().helium), - QString::number(details->dil1().type), - QString::number(details->dil1().depth) - ); + .arg(QString::number(details->dil1().oxygen), + QString::number(details->dil1().helium), + QString::number(details->dil1().type), + QString::number(details->dil1().depth)); QString dil2 = QString("%1,%2,%3,%4") - .arg(QString::number(details->dil2().oxygen), - QString::number(details->dil2().helium), - QString::number(details->dil2().type), - QString::number(details->dil2().depth) - ); + .arg(QString::number(details->dil2().oxygen), + QString::number(details->dil2().helium), + QString::number(details->dil2().type), + QString::number(details->dil2().depth)); QString dil3 = QString("%1,%2,%3,%4") - .arg(QString::number(details->dil3().oxygen), - QString::number(details->dil3().helium), - QString::number(details->dil3().type), - QString::number(details->dil3().depth) - ); + .arg(QString::number(details->dil3().oxygen), + QString::number(details->dil3().helium), + QString::number(details->dil3().type), + QString::number(details->dil3().depth)); QString dil4 = QString("%1,%2,%3,%4") - .arg(QString::number(details->dil4().oxygen), - QString::number(details->dil4().helium), - QString::number(details->dil4().type), - QString::number(details->dil4().depth) - ); + .arg(QString::number(details->dil4().oxygen), + QString::number(details->dil4().helium), + QString::number(details->dil4().type), + QString::number(details->dil4().depth)); QString dil5 = QString("%1,%2,%3,%4") - .arg(QString::number(details->dil5().oxygen), - QString::number(details->dil5().helium), - QString::number(details->dil5().type), - QString::number(details->dil5().depth) - ); + .arg(QString::number(details->dil5().oxygen), + QString::number(details->dil5().helium), + QString::number(details->dil5().type), + QString::number(details->dil5().depth)); writer.writeTextElement("Dil1", dil1); writer.writeTextElement("Dil2", dil2); writer.writeTextElement("Dil3", dil3); @@ -143,25 +132,20 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai // //Add set point 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); @@ -224,7 +208,7 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) { lastError = tr("Could not save the backup file %1. Error Message: %2") - .arg(fileName, file.errorString()); + .arg(fileName, file.errorString()); return false; } //file open successful. write data and save. @@ -513,7 +497,6 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t *data) { setState(FWUPDATE); - if (firmwareThread) firmwareThread->deleteLater(); @@ -521,7 +504,6 @@ void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t connect(firmwareThread, SIGNAL(finished()), this, SLOT(firmwareThreadFinished()), Qt::QueuedConnection); connect(firmwareThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); - firmwareThread->start(); } diff --git a/configuredivecomputer.h b/configuredivecomputer.h index 66a9bf5f5..6cc9b8fa5 100644 --- a/configuredivecomputer.h +++ b/configuredivecomputer.h @@ -10,24 +10,23 @@ #include "libxml/xmlreader.h" -class ConfigureDiveComputer : public QObject -{ +class ConfigureDiveComputer : public QObject { Q_OBJECT public: explicit ConfigureDiveComputer(); void readSettings(device_data_t *data); enum states { - INITIAL, - READING, - WRITING, - RESETTING, - FWUPDATE, - CANCELLING, - CANCELLED, - ERROR, - DONE, - }; + INITIAL, + READING, + WRITING, + RESETTING, + FWUPDATE, + CANCELLING, + CANCELLED, + ERROR, + DONE, + }; QString lastError; states currentState; @@ -50,7 +49,8 @@ private: ResetSettingsThread *resetThread; FirmwareUpdateThread *firmwareThread; void setState(states newState); -private slots: +private +slots: void readThreadFinished(); void writeThreadFinished(); void resetThreadFinished(); diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index bd0f9bbd6..e8b07a38f 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -106,17 +106,17 @@ static dc_status_t local_hw_ostc_device_clock(void *ignored, dc_datetime_t *time } #endif -ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) - : QThread(parent), m_data(data) +ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data) { - } -static int read_ostc_cf(unsigned char data[], unsigned char cf) { +static int read_ostc_cf(unsigned char data[], unsigned char cf) +{ return data[128 + (cf % 32) * 4 + 3] << 8 ^ data[128 + (cf % 32) * 4 + 2]; } -static void write_ostc_cf(unsigned char data[], unsigned char cf, unsigned char max_CF, unsigned int value) { +static void write_ostc_cf(unsigned char data[], unsigned char cf, unsigned char max_CF, unsigned int value) +{ // Only write settings supported by this firmware. if (cf > max_CF) return; @@ -134,7 +134,7 @@ void ReadSettingsThread::run() rc = DC_STATUS_SUCCESS; else #endif - rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); + rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); if (rc == DC_STATUS_SUCCESS) { DeviceDetails *m_deviceDetails = new DeviceDetails(0); switch (dc_device_get_type(m_data->device)) { @@ -145,7 +145,7 @@ void ReadSettingsThread::run() const char *model; // FIXME: grab this info from libdivecomputer descriptor // instead of hard coded here - switch(data[0]) { + switch (data[0]) { case 0x03: model = "Stinger"; break; @@ -212,11 +212,11 @@ void ReadSettingsThread::run() rc = dc_device_read(m_data->device, SUUNTO_VYPER_CUSTOM_TEXT, data, SUUNTO_VYPER_CUSTOM_TEXT_LENGHT); if (rc == DC_STATUS_SUCCESS) { data[SUUNTO_VYPER_CUSTOM_TEXT_LENGHT] = 0; - m_deviceDetails->setCustomText((const char*) data); + m_deviceDetails->setCustomText((const char *)data); } rc = dc_device_read(m_data->device, SUUNTO_VYPER_SAMPLING_RATE, data, 1); if (rc == DC_STATUS_SUCCESS) { - m_deviceDetails->setSamplingRate((int) data[0]); + m_deviceDetails->setSamplingRate((int)data[0]); } rc = dc_device_read(m_data->device, SUUNTO_VYPER_ALTITUDE_SAFETY, data, 1); if (rc == DC_STATUS_SUCCESS) { @@ -271,7 +271,7 @@ void ReadSettingsThread::run() gas gas4; gas gas5; //Gas 1 - unsigned char gasData[4] = {0,0,0,0}; + unsigned char gasData[4] = { 0, 0, 0, 0 }; rc = hw_ostc3_device_config_read(m_data->device, OSTC3_GAS1, gasData, sizeof(gasData)); if (rc == DC_STATUS_SUCCESS) { //Gas data read successful @@ -330,7 +330,7 @@ void ReadSettingsThread::run() gas dil4; gas dil5; //Dil 1 - unsigned char dilData[4] = {0,0,0,0}; + unsigned char dilData[4] = { 0, 0, 0, 0 }; rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DIL1, dilData, sizeof(dilData)); if (rc == DC_STATUS_SUCCESS) { //Data read successful @@ -389,7 +389,7 @@ void ReadSettingsThread::run() setpoint sp4; setpoint sp5; - unsigned char spData[2] = {0,0}; + unsigned char spData[2] = { 0, 0 }; //Sp 1 rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SP1, spData, sizeof(spData)); @@ -434,14 +434,14 @@ void ReadSettingsThread::run() m_deviceDetails->setSp5(sp5); //Read other settings - unsigned char uData[1] = {0}; + unsigned char uData[1] = { 0 }; -#define READ_SETTING(_OSTC3_SETTING, _DEVICE_DETAIL) \ - do { \ - rc = hw_ostc3_device_config_read(m_data->device, _OSTC3_SETTING, uData, sizeof(uData)); \ - if (rc == DC_STATUS_SUCCESS) \ - m_deviceDetails->_DEVICE_DETAIL(uData[0]); \ - } while (0) +#define READ_SETTING(_OSTC3_SETTING, _DEVICE_DETAIL) \ + do { \ + rc = hw_ostc3_device_config_read(m_data->device, _OSTC3_SETTING, uData, sizeof(uData)); \ + if (rc == DC_STATUS_SUCCESS) \ + m_deviceDetails->_DEVICE_DETAIL(uData[0]); \ + } while (0) READ_SETTING(OSTC3_DIVE_MODE, setDiveMode); READ_SETTING(OSTC3_SATURATION, setSaturation); @@ -449,9 +449,9 @@ void ReadSettingsThread::run() READ_SETTING(OSTC3_LAST_DECO, setLastDeco); READ_SETTING(OSTC3_BRIGHTNESS, setBrightness); READ_SETTING(OSTC3_UNITS, setUnits); - READ_SETTING(OSTC3_SAMPLING_RATE,setSamplingRate); + READ_SETTING(OSTC3_SAMPLING_RATE, setSamplingRate); READ_SETTING(OSTC3_SALINITY, setSalinity); - READ_SETTING(OSTC3_DIVEMODE_COLOR,setDiveModeColor); + READ_SETTING(OSTC3_DIVEMODE_COLOR, setDiveModeColor); READ_SETTING(OSTC3_LANGUAGE, setLanguage); READ_SETTING(OSTC3_DATE_FORMAT, setDateFormat); READ_SETTING(OSTC3_COMPASS_GAIN, setCompassGain); @@ -475,12 +475,12 @@ void ReadSettingsThread::run() rc = hw_ostc3_device_config_read(m_data->device, OSTC3_PRESSURE_SENSOR_OFFSET, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) { // OSTC3 stores the pressureSensorOffset in two-complement - m_deviceDetails->setPressureSensorOffset((signed char) uData[0]); + m_deviceDetails->setPressureSensorOffset((signed char)uData[0]); } //read firmware settings - unsigned char fData[64] = {0}; - rc = hw_ostc3_device_version (m_data->device, fData, sizeof (fData)); + unsigned char fData[64] = { 0 }; + rc = hw_ostc3_device_version(m_data->device, fData, sizeof(fData)); if (rc == DC_STATUS_SUCCESS) { int serial = fData[0] + (fData[1] << 8); m_deviceDetails->setSerialNo(QString::number(serial)); @@ -492,7 +492,7 @@ void ReadSettingsThread::run() emit devicedetails(m_deviceDetails); break; } -#endif // divecomputer 0.5.0 +#endif // divecomputer 0.5.0 #ifdef DEBUG_OSTC case DC_FAMILY_NULL: #endif @@ -549,25 +549,25 @@ void ReadSettingsThread::run() gas4.depth = data[31]; gas5.depth = data[32]; // 33 which gas is Fist gas - switch(data[33]) { - case 1: - gas1.type = 2; - break; - case 2: - gas2.type = 2; - break; - case 3: - gas3.type = 2; - break; - case 4: - gas4.type = 2; - break; - case 5: - gas5.type = 2; - break; - default: - //Error? - break; + switch (data[33]) { + case 1: + gas1.type = 2; + break; + case 2: + gas2.type = 2; + break; + case 3: + gas3.type = 2; + break; + case 4: + gas4.type = 2; + break; + case 5: + gas5.type = 2; + break; + default: + //Error? + break; } // Data filled up, set the gases. m_deviceDetails->setGas1(gas1); @@ -637,10 +637,10 @@ void ReadSettingsThread::run() // Make shure the data is null-terminated data[89] = 0; // Find the internal termination and replace it with 0 - char *term = strchr((char *) data + 65, (int)'}'); + char *term = strchr((char *)data + 65, (int)'}'); if (term) *term = 0; - m_deviceDetails->setCustomText((const char*) data + 65); + m_deviceDetails->setCustomText((const char *)data + 65); } // Byte91: // Dim OLED in Divemode (>0), Normal mode (=0) @@ -696,25 +696,25 @@ void ReadSettingsThread::run() dil5.helium = data[114]; // Byte116: // First Diluent (1-5) - switch(data[115]) { - case 1: - dil1.type = 2; - break; - case 2: - dil2.type = 2; - break; - case 3: - dil3.type = 2; - break; - case 4: - dil4.type = 2; - break; - case 5: - dil5.type = 2; - break; - default: - //Error? - break; + switch (data[115]) { + case 1: + dil1.type = 2; + break; + case 2: + dil2.type = 2; + break; + case 3: + dil3.type = 2; + break; + case 4: + dil4.type = 2; + break; + case 5: + dil5.type = 2; + break; + default: + //Error? + break; } m_deviceDetails->setDil1(dil1); m_deviceDetails->setDil2(dil2); @@ -741,7 +741,7 @@ void ReadSettingsThread::run() m_deviceDetails->setLastDeco(read_ostc_cf(data, 29)); #ifdef DEBUG_OSTC_CF - for(int cf = 0; cf <= 31 && cf <= max_CF; cf++) + for (int cf = 0; cf <= 31 && cf <= max_CF; cf++) printf("CF %d: %d\n", cf, read_ostc_cf(data, cf)); #endif } @@ -769,7 +769,7 @@ void ReadSettingsThread::run() // CF58: Future time to surface setFutureTTS m_deviceDetails->setFutureTTS(read_ostc_cf(data, 58)); #ifdef DEBUG_OSTC_CF - for(int cf = 32; cf <= 63 && cf <= max_CF; cf++) + for (int cf = 32; cf <= 63 && cf <= max_CF; cf++) printf("CF %d: %d\n", cf, read_ostc_cf(data, cf)); #endif } @@ -792,7 +792,7 @@ void ReadSettingsThread::run() // CF69: Allow Gradient Factor change m_deviceDetails->setAGFSelectable(read_ostc_cf(data, 69)); #ifdef DEBUG_OSTC_CF - for(int cf = 64; cf <= 95 && cf <= max_CF; cf++) + for (int cf = 64; cf <= 95 && cf <= max_CF; cf++) printf("CF %d: %d\n", cf, read_ostc_cf(data, cf)); #endif } @@ -818,8 +818,7 @@ unsupported_dc_error: } } -WriteSettingsThread::WriteSettingsThread(QObject *parent, device_data_t *data) - : QThread(parent), m_data(data) +WriteSettingsThread::WriteSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data) { } @@ -852,7 +851,7 @@ void WriteSettingsThread::run() dc_device_write(m_data->device, SUUNTO_VYPER_CUSTOM_TEXT, // Convert the customText to a 30 char wide padded with " " - (const unsigned char *) QString("%1").arg(m_deviceDetails->customText(), -30, QChar(' ')).toUtf8().data(), + (const unsigned char *)QString("%1").arg(m_deviceDetails->customText(), -30, QChar(' ')).toUtf8().data(), SUUNTO_VYPER_CUSTOM_TEXT_LENGHT); data = m_deviceDetails->samplingRate(); dc_device_write(m_data->device, SUUNTO_VYPER_SAMPLING_RATE, &data, 1); @@ -879,34 +878,34 @@ void WriteSettingsThread::run() data2[1] = (int)(mm_to_feet(m_deviceDetails->alarmDepth()) * 128) & 0x0FF; dc_device_write(m_data->device, SUUNTO_VYPER_ALARM_DEPTH, data2, 2); break; -#if DC_VERSION_CHECK(0,5,0) +#if DC_VERSION_CHECK(0, 5, 0) case DC_FAMILY_HW_OSTC3: { supported = true; //write gas values - unsigned char gas1Data[4] = {m_deviceDetails->gas1().oxygen, - m_deviceDetails->gas1().helium, - m_deviceDetails->gas1().type, - m_deviceDetails->gas1().depth}; - - unsigned char gas2Data[4] = {m_deviceDetails->gas2().oxygen, - m_deviceDetails->gas2().helium, - m_deviceDetails->gas2().type, - m_deviceDetails->gas2().depth}; - - unsigned char gas3Data[4] = {m_deviceDetails->gas3().oxygen, - m_deviceDetails->gas3().helium, - m_deviceDetails->gas3().type, - m_deviceDetails->gas3().depth}; - - unsigned char gas4Data[4] = {m_deviceDetails->gas4().oxygen, - m_deviceDetails->gas4().helium, - m_deviceDetails->gas4().type, - m_deviceDetails->gas4().depth}; - - unsigned char gas5Data[4] = {m_deviceDetails->gas5().oxygen, - m_deviceDetails->gas5().helium, - m_deviceDetails->gas5().type, - m_deviceDetails->gas5().depth}; + unsigned char gas1Data[4] = { m_deviceDetails->gas1().oxygen, + m_deviceDetails->gas1().helium, + m_deviceDetails->gas1().type, + m_deviceDetails->gas1().depth }; + + unsigned char gas2Data[4] = { m_deviceDetails->gas2().oxygen, + m_deviceDetails->gas2().helium, + m_deviceDetails->gas2().type, + m_deviceDetails->gas2().depth }; + + unsigned char gas3Data[4] = { m_deviceDetails->gas3().oxygen, + m_deviceDetails->gas3().helium, + m_deviceDetails->gas3().type, + m_deviceDetails->gas3().depth }; + + unsigned char gas4Data[4] = { m_deviceDetails->gas4().oxygen, + m_deviceDetails->gas4().helium, + m_deviceDetails->gas4().type, + m_deviceDetails->gas4().depth }; + + unsigned char gas5Data[4] = { m_deviceDetails->gas5().oxygen, + m_deviceDetails->gas5().helium, + m_deviceDetails->gas5().type, + m_deviceDetails->gas5().depth }; //gas 1 hw_ostc3_device_config_write(m_data->device, OSTC3_GAS1, gas1Data, sizeof(gas1Data)); //gas 2 @@ -919,20 +918,20 @@ void WriteSettingsThread::run() hw_ostc3_device_config_write(m_data->device, OSTC3_GAS5, gas5Data, sizeof(gas5Data)); //write set point values - unsigned char sp1Data[2] = {m_deviceDetails->sp1().sp, - m_deviceDetails->sp1().depth}; + unsigned char sp1Data[2] = { m_deviceDetails->sp1().sp, + m_deviceDetails->sp1().depth }; - unsigned char sp2Data[2] = {m_deviceDetails->sp2().sp, - m_deviceDetails->sp2().depth}; + unsigned char sp2Data[2] = { m_deviceDetails->sp2().sp, + m_deviceDetails->sp2().depth }; - unsigned char sp3Data[2] = {m_deviceDetails->sp3().sp, - m_deviceDetails->sp3().depth}; + unsigned char sp3Data[2] = { m_deviceDetails->sp3().sp, + m_deviceDetails->sp3().depth }; - unsigned char sp4Data[2] = {m_deviceDetails->sp4().sp, - m_deviceDetails->sp4().depth}; + unsigned char sp4Data[2] = { m_deviceDetails->sp4().sp, + m_deviceDetails->sp4().depth }; - unsigned char sp5Data[2] = {m_deviceDetails->sp5().sp, - m_deviceDetails->sp5().depth}; + unsigned char sp5Data[2] = { m_deviceDetails->sp5().sp, + m_deviceDetails->sp5().depth }; //sp 1 hw_ostc3_device_config_write(m_data->device, OSTC3_SP1, sp1Data, sizeof(sp1Data)); @@ -946,30 +945,30 @@ void WriteSettingsThread::run() hw_ostc3_device_config_write(m_data->device, OSTC3_SP5, sp5Data, sizeof(sp5Data)); //write dil values - unsigned char dil1Data[4] = {m_deviceDetails->dil1().oxygen, - m_deviceDetails->dil1().helium, - m_deviceDetails->dil1().type, - m_deviceDetails->dil1().depth}; - - unsigned char dil2Data[4] = {m_deviceDetails->dil2().oxygen, - m_deviceDetails->dil2().helium, - m_deviceDetails->dil2().type, - m_deviceDetails->dil2().depth}; - - unsigned char dil3Data[4] = {m_deviceDetails->dil3().oxygen, - m_deviceDetails->dil3().helium, - m_deviceDetails->dil3().type, - m_deviceDetails->dil3().depth}; - - unsigned char dil4Data[4] = {m_deviceDetails->dil4().oxygen, - m_deviceDetails->dil4().helium, - m_deviceDetails->dil4().type, - m_deviceDetails->dil4().depth}; - - unsigned char dil5Data[4] = {m_deviceDetails->dil5().oxygen, - m_deviceDetails->dil5().helium, - m_deviceDetails->dil5().type, - m_deviceDetails->dil5().depth}; + unsigned char dil1Data[4] = { m_deviceDetails->dil1().oxygen, + m_deviceDetails->dil1().helium, + m_deviceDetails->dil1().type, + m_deviceDetails->dil1().depth }; + + unsigned char dil2Data[4] = { m_deviceDetails->dil2().oxygen, + m_deviceDetails->dil2().helium, + m_deviceDetails->dil2().type, + m_deviceDetails->dil2().depth }; + + unsigned char dil3Data[4] = { m_deviceDetails->dil3().oxygen, + m_deviceDetails->dil3().helium, + m_deviceDetails->dil3().type, + m_deviceDetails->dil3().depth }; + + unsigned char dil4Data[4] = { m_deviceDetails->dil4().oxygen, + m_deviceDetails->dil4().helium, + m_deviceDetails->dil4().type, + m_deviceDetails->dil4().depth }; + + unsigned char dil5Data[4] = { m_deviceDetails->dil5().oxygen, + m_deviceDetails->dil5().helium, + m_deviceDetails->dil5().type, + m_deviceDetails->dil5().depth }; //dil 1 hw_ostc3_device_config_write(m_data->device, OSTC3_DIL1, dil1Data, sizeof(gas1Data)); //dil 2 @@ -986,12 +985,12 @@ void WriteSettingsThread::run() //custom text hw_ostc3_device_customtext(m_data->device, m_deviceDetails->customText().toUtf8().data()); - unsigned char data[1] = {0}; -#define WRITE_SETTING(_OSTC3_SETTING, _DEVICE_DETAIL) \ - do { \ - data[0] = m_deviceDetails->_DEVICE_DETAIL(); \ - hw_ostc3_device_config_write(m_data->device, _OSTC3_SETTING, data, sizeof(data)); \ - } while (0) + unsigned char data[1] = { 0 }; +#define WRITE_SETTING(_OSTC3_SETTING, _DEVICE_DETAIL) \ + do { \ + data[0] = m_deviceDetails->_DEVICE_DETAIL(); \ + hw_ostc3_device_config_write(m_data->device, _OSTC3_SETTING, data, sizeof(data)); \ + } while (0) WRITE_SETTING(OSTC3_DIVE_MODE, diveMode); WRITE_SETTING(OSTC3_SATURATION, saturation); @@ -1023,7 +1022,7 @@ void WriteSettingsThread::run() #undef WRITE_SETTING // OSTC3 stores the pressureSensorOffset in two-complement - data[0] = (unsigned char) m_deviceDetails->pressureSensorOffset(); + data[0] = (unsigned char)m_deviceDetails->pressureSensorOffset(); hw_ostc3_device_config_write(m_data->device, OSTC3_PRESSURE_SENSOR_OFFSET, data, sizeof(data)); //sync date and time @@ -1040,7 +1039,7 @@ void WriteSettingsThread::run() } break; } -#endif // divecomputer 0.5.0 +#endif // divecomputer 0.5.0 #ifdef DEBUG_OSTC case DC_FAMILY_NULL: #endif @@ -1112,11 +1111,11 @@ void WriteSettingsThread::run() data[33] = 4; else if (gas5.type == 2) data[33] = 5; - else { + else // FIXME: No gas was First? // Set gas 1 to first data[33] = 1; - } + data[34] = m_deviceDetails->decoType(); //Byte36: //Use O2 Sensor Module in CC Modes (0= OFF, 1= ON) (Only available in old OSTC1 - unused for OSTC Mk.2/2N) @@ -1165,12 +1164,12 @@ void WriteSettingsThread::run() // Byte66-90: // (25Bytes): Custom Text for Surfacemode (Real text must end with "}") // Example: OSTC Dive Computer} (19 Characters incl. "}") Bytes 85-90 will be ignored. - if (m_deviceDetails->customText() == "") + if (m_deviceDetails->customText() == "") { data[64] = 0; - else { + } else { data[64] = 1; // Copy the string to the right place in the memory, padded with 0x20 (" ") - strncpy((char *) data + 65, QString("%1").arg(m_deviceDetails->customText(), -23, QChar(' ')).toUtf8().data(), 23); + strncpy((char *)data + 65, QString("%1").arg(m_deviceDetails->customText(), -23, QChar(' ')).toUtf8().data(), 23); // And terminate the string. if (m_deviceDetails->customText().length() <= 23) data[65 + m_deviceDetails->customText().length()] = '}'; @@ -1239,11 +1238,11 @@ void WriteSettingsThread::run() data[115] = 4; else if (dil5.type == 2) data[115] = 5; - else { + else // FIXME: No first diluent? // Set gas 1 to fist data[115] = 1; - } + // Byte117-128: // not used/reserved // Byte129-256: @@ -1264,7 +1263,7 @@ void WriteSettingsThread::run() write_ostc_cf(data, 29, max_CF, m_deviceDetails->lastDeco()); #ifdef DEBUG_OSTC_CF - for(int cf = 0; cf <= 31 && cf <= max_CF; cf++) + for (int cf = 0; cf <= 31 && cf <= max_CF; cf++) printf("CF %d: %d\n", cf, read_ostc_cf(data, cf)); #endif rc = hw_ostc_device_eeprom_write(m_data->device, 0, data, sizeof(data)); @@ -1295,7 +1294,7 @@ void WriteSettingsThread::run() // CF58: Future time to surface setFutureTTS write_ostc_cf(data, 58, max_CF, m_deviceDetails->futureTTS()); #ifdef DEBUG_OSTC_CF - for(int cf = 32; cf <= 63 && cf <= max_CF; cf++) + for (int cf = 32; cf <= 63 && cf <= max_CF; cf++) printf("CF %d: %d\n", cf, read_ostc_cf(data, cf)); #endif rc = hw_ostc_device_eeprom_write(m_data->device, 1, data, sizeof(data)); @@ -1322,7 +1321,7 @@ void WriteSettingsThread::run() // CF69: Allow Gradient Factor change write_ostc_cf(data, 69, max_CF, m_deviceDetails->aGFSelectable()); #ifdef DEBUG_OSTC_CF - for(int cf = 64; cf <= 95 && cf <= max_CF; cf++) + for (int cf = 64; cf <= 95 && cf <= max_CF; cf++) printf("CF %d: %d\n", cf, read_ostc_cf(data, cf)); #endif rc = hw_ostc_device_eeprom_write(m_data->device, 2, data, sizeof(data)); @@ -1357,36 +1356,37 @@ void WriteSettingsThread::run() lastError = tr("This feature is not yet available for the selected dive computer."); emit error(lastError); } - } - else { + } else { lastError = tr("Could not a establish connection to the dive computer."); emit error(lastError); } } -FirmwareUpdateThread::FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName) - : QThread(parent), m_data(data), m_fileName(fileName) +FirmwareUpdateThread::FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName) : QThread(parent), m_data(data), m_fileName(fileName) { } void FirmwareUpdateThread::run() { + qDebug() << "in FirmwareUpdateThread::run"; bool supported = false; dc_status_t rc; rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); + qDebug() << "got" << rc << "as return for dc_device_open of" << m_data->devname; if (rc == DC_STATUS_SUCCESS) { switch (dc_device_get_type(m_data->device)) { #if DC_VERSION_CHECK(0, 5, 0) case DC_FAMILY_HW_OSTC3: supported = true; + qDebug() << "it's an OSTC3, let's do it!"; rc = hw_ostc3_device_fwupdate(m_data->device, m_fileName.toUtf8().data()); break; case DC_FAMILY_HW_OSTC: supported = true; rc = hw_ostc_device_fwupdate(m_data->device, m_fileName.toUtf8().data()); break; -#endif // divecomputer 0.5.0 +#endif // divecomputer 0.5.0 default: supported = false; break; @@ -1399,16 +1399,14 @@ void FirmwareUpdateThread::run() } else if (rc != DC_STATUS_SUCCESS) { lastError = tr("Firmware update failed!"); } - } - else { + } else { lastError = tr("Could not a establish connection to the dive computer."); emit error(lastError); } } -ResetSettingsThread::ResetSettingsThread(QObject *parent, device_data_t *data) - : QThread(parent), m_data(data) +ResetSettingsThread::ResetSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data) { } @@ -1423,15 +1421,14 @@ void ResetSettingsThread::run() supported = true; hw_ostc3_device_config_reset(m_data->device); } -#endif // divecomputer 0.5.0 +#endif // divecomputer 0.5.0 dc_device_close(m_data->device); if (!supported) { lastError = tr("This feature is not yet available for the selected dive computer."); emit error(lastError); } - } - else { + } else { lastError = tr("Could not a establish connection to the dive computer."); emit error(lastError); } diff --git a/configuredivecomputerthreads.h b/configuredivecomputerthreads.h index 13f54c406..5c33c9de2 100644 --- a/configuredivecomputerthreads.h +++ b/configuredivecomputerthreads.h @@ -8,8 +8,7 @@ #include <QDateTime> #include "devicedetails.h" -class ReadSettingsThread : public QThread -{ +class ReadSettingsThread : public QThread { Q_OBJECT public: ReadSettingsThread(QObject *parent, device_data_t *data); @@ -19,12 +18,12 @@ public: signals: void error(QString err); void devicedetails(DeviceDetails *newDeviceDetails); + private: device_data_t *m_data; }; -class WriteSettingsThread : public QThread -{ +class WriteSettingsThread : public QThread { Q_OBJECT public: WriteSettingsThread(QObject *parent, device_data_t *data); @@ -34,13 +33,13 @@ public: QString lastError; signals: void error(QString err); + private: device_data_t *m_data; DeviceDetails *m_deviceDetails; }; -class FirmwareUpdateThread : public QThread -{ +class FirmwareUpdateThread : public QThread { Q_OBJECT public: FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName); @@ -50,13 +49,13 @@ signals: void progress(int percent); void message(QString msg); void error(QString err); + private: device_data_t *m_data; QString m_fileName; }; -class ResetSettingsThread : public QThread -{ +class ResetSettingsThread : public QThread { Q_OBJECT public: ResetSettingsThread(QObject *parent, device_data_t *data); @@ -66,6 +65,7 @@ signals: void progress(int percent); void message(QString msg); void error(QString err); + private: device_data_t *m_data; }; @@ -435,7 +435,7 @@ static void check_setpoint_events(struct dive *dive, struct divecomputer *dc, st do { i = set_setpoint(pi, i, setpoint.mbar, ev->time.seconds); setpoint.mbar = ev->value; - if(setpoint.mbar) + if (setpoint.mbar) dc->dctype = CCR; ev = get_next_event(ev->next, "SP change"); } while (ev); @@ -608,15 +608,15 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer * entry->in_deco = sample->in_deco; entry->cns = sample->cns; if (dc->dctype == CCR) { - entry->o2pressure.mbar = sample->setpoint.mbar; // for rebreathers - entry->o2sensor[0].mbar = sample->o2sensor[0].mbar; // for up to three rebreather O2 sensors + entry->o2pressure.mbar = sample->setpoint.mbar; // for rebreathers + entry->o2sensor[0].mbar = sample->o2sensor[0].mbar; // for up to three rebreather O2 sensors entry->o2sensor[1].mbar = sample->o2sensor[1].mbar; entry->o2sensor[2].mbar = sample->o2sensor[2].mbar; } else { entry->pressures.o2 = sample->setpoint.mbar / 1000.0; } /* FIXME! sensor index -> cylinder index translation! */ -// entry->cylinderindex = sample->sensor; + // entry->cylinderindex = sample->sensor; SENSOR_PRESSURE(entry) = sample->cylinderpressure.mbar; O2CYLINDER_PRESSURE(entry) = sample->o2cylinderpressure.mbar; if (sample->temperature.mkelvin) @@ -773,7 +773,7 @@ static void calculate_ndl_tts(double tissue_tolerance, struct plot_data *entry, while (entry->ndl_calc < max_ndl && deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1) <= 0) { entry->ndl_calc += time_stepsize; tissue_tolerance = add_segment(depth_to_mbar(entry->depth, dive) / 1000.0, - &dive->cylinder[cylinderindex].gasmix, time_stepsize, entry->o2pressure.mbar , dive, prefs.bottomsac); + &dive->cylinder[cylinderindex].gasmix, time_stepsize, entry->o2pressure.mbar, dive, prefs.bottomsac); } /* we don't need to calculate anything else */ return; @@ -785,7 +785,7 @@ static void calculate_ndl_tts(double tissue_tolerance, struct plot_data *entry, /* Add segments for movement to stopdepth */ for (; ascent_depth > next_stop; ascent_depth -= ascent_mm_per_step, entry->tts_calc += ascent_s_per_step) { tissue_tolerance = add_segment(depth_to_mbar(ascent_depth, dive) / 1000.0, - &dive->cylinder[cylinderindex].gasmix, ascent_s_per_step, entry->o2pressure.mbar , dive, prefs.decosac); + &dive->cylinder[cylinderindex].gasmix, ascent_s_per_step, entry->o2pressure.mbar, dive, prefs.decosac); next_stop = ROUND_UP(deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1), deco_stepsize); } ascent_depth = next_stop; @@ -829,9 +829,11 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru int j, t0 = (entry - 1)->sec, t1 = entry->sec; int time_stepsize = 20; - entry->ambpressure = (double) depth_to_mbar(entry->depth, dive) / 1000.0; - entry->gfline = MAX((double) prefs.gflow, (entry->ambpressure - surface_pressure) / (gf_low_pressure_this_dive - surface_pressure) * - (prefs.gflow - prefs.gfhigh) + prefs.gfhigh) * (100.0 - AMB_PERCENTAGE) / 100.0 + AMB_PERCENTAGE; + entry->ambpressure = (double)depth_to_mbar(entry->depth, dive) / 1000.0; + entry->gfline = MAX((double)prefs.gflow, (entry->ambpressure - surface_pressure) / (gf_low_pressure_this_dive - surface_pressure) * + (prefs.gflow - prefs.gfhigh) + + prefs.gfhigh) * + (100.0 - AMB_PERCENTAGE) / 100.0 + AMB_PERCENTAGE; if (t0 != t1 && t1 - t0 < time_stepsize) time_stepsize = t1 - t0; for (j = t0 + time_stepsize; j <= t1; j += time_stepsize) { @@ -888,12 +890,13 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru * calculates the po2 value from the sensor data. Several rules are applied, depending on how many o2 sensors * there are and the differences among the readings from these sensors. */ -static int calculate_ccr_po2(struct plot_data *entry, struct divecomputer *dc) { +static int calculate_ccr_po2(struct plot_data *entry, struct divecomputer *dc) +{ int sump = 0, minp = 999999, maxp = -999999; int diff_limit = 100; // The limit beyond which O2 sensor differences are considered significant (default = 100 mbar) int i, np = 0; - for (i=0; i < dc->no_o2sensors; i++) + for (i = 0; i < dc->no_o2sensors; i++) if (entry->o2sensor[i].mbar) { // Valid reading ++np; sump += entry->o2sensor[i].mbar; @@ -907,14 +910,14 @@ static int calculate_ccr_po2(struct plot_data *entry, struct divecomputer *dc) { return sump; case 2: // Take the average return sump / 2; - case 3: // Voting logic + case 3: // Voting logic if (2 * maxp - sump + minp < diff_limit) { // Upper difference acceptable... - if (2 * minp - sump + maxp) // ...and lower difference acceptable + if (2 * minp - sump + maxp) // ...and lower difference acceptable return sump / 3; else return (sump - minp) / 2; } else { - if (2 * minp - sump + maxp) // ...but lower difference acceptable + if (2 * minp - sump + maxp) // ...but lower difference acceptable return (sump - maxp) / 2; else return sump / 3; @@ -938,8 +941,8 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p amb_pressure = depth_to_mbar(entry->depth, dive) / 1000.0; fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->o2pressure.mbar / 1000.0, dive->dc.dctype, entry->sac); - fn2 = (int) (1000.0 * entry->pressures.n2 / amb_pressure); - fhe = (int) (1000.0 * entry->pressures.he / amb_pressure); + fn2 = (int)(1000.0 * entry->pressures.n2 / amb_pressure); + fhe = (int)(1000.0 * entry->pressures.he / amb_pressure); /* Calculate MOD, EAD, END and EADD based on partial pressures calculated before * so there is no difference in calculating between OC and CC @@ -982,21 +985,21 @@ void fill_o2_values(struct divecomputer *dc, struct plot_info *pi, struct dive * for (i = 0; i < pi->nr; i++) { struct plot_data *entry = pi->entry + i; if (dc->dctype == CCR) { - if (i == 0) { // For 1st iteration, initialise the last_sensor values + if (i == 0) { // For 1st iteration, initialise the last_sensor values for (j = 0; j < dc->no_o2sensors; j++) last_sensor[j].mbar = pi->entry->o2sensor[j].mbar; - } else { // Now re-insert the missing oxygen pressure values + } else { // Now re-insert the missing oxygen pressure values for (j = 0; j < dc->no_o2sensors; j++) if (entry->o2sensor[j].mbar) last_sensor[j].mbar = entry->o2sensor[j].mbar; else entry->o2sensor[j].mbar = last_sensor[j].mbar; - } // having initialised the empty o2 sensor values for this point on the profile, + } // having initialised the empty o2 sensor values for this point on the profile, amb_pressure.mbar = depth_to_mbar(entry->depth, dive); - o2pressure.mbar = calculate_ccr_po2(entry,dc); // ...calculate the po2 based on the sensor data + o2pressure.mbar = calculate_ccr_po2(entry, dc); // ...calculate the po2 based on the sensor data entry->o2pressure.mbar = MIN(o2pressure.mbar, amb_pressure.mbar); } else { - entry->o2pressure.mbar = 0; // initialise po2 to zero for dctype = OC + entry->o2pressure.mbar = 0; // initialise po2 to zero for dctype = OC } } } @@ -1010,9 +1013,9 @@ static void debug_print_profiledata(struct plot_info *pi) FILE *f1; struct plot_data *entry; int i; - if (!(f1 = fopen("debug_print_profiledata.dat", "w"))) + if (!(f1 = fopen("debug_print_profiledata.dat", "w"))) { printf("File open error for: debug_print_profiledata.dat\n"); - else { + } else { fprintf(f1, "id t1 gas gasint t2 t3 dil dilint t4 t5 setpoint sensor1 sensor2 sensor3 t6 po2 fo2\n"); for (i = 0; i < pi->nr; i++) { entry = pi->entry + i; @@ -1050,18 +1053,18 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo } last_pi_entry_new = populate_plot_entries(dive, dc, pi); - check_gas_change_events(dive, dc, pi); /* Populate the gas index from the gas change events */ - check_setpoint_events(dive, dc, pi); /* Populate setpoints */ - setup_gas_sensor_pressure(dive, dc, pi); /* Try to populate our gas pressure knowledge */ + check_gas_change_events(dive, dc, pi); /* Populate the gas index from the gas change events */ + check_setpoint_events(dive, dc, pi); /* Populate setpoints */ + setup_gas_sensor_pressure(dive, dc, pi); /* Try to populate our gas pressure knowledge */ if (!fast) { populate_pressure_information(dive, dc, pi, false); /* .. calculate missing pressure entries for all gasses except o2 */ - if (dc->dctype == CCR) /* For CCR dives.. */ + if (dc->dctype == CCR) /* For CCR dives.. */ populate_pressure_information(dive, dc, pi, true); /* .. calculate missing o2 gas pressure entries */ } - fill_o2_values(dc, pi, dive); /* .. and insert the O2 sensor data having 0 values. */ - calculate_sac(dive, pi); /* Calculate sac */ + fill_o2_values(dc, pi, dive); /* .. and insert the O2 sensor data having 0 values. */ + calculate_sac(dive, pi); /* Calculate sac */ calculate_deco_information(dive, dc, pi, false); /* and ceiling information, using gradient factor values in Preferences) */ - calculate_gas_information_new(dive, pi); /* Calculate gas partial pressures */ + calculate_gas_information_new(dive, pi); /* Calculate gas partial pressures */ #ifdef DEBUG_GAS debug_print_profiledata(pi); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 22a0d39c8..f30618f62 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -37,10 +37,14 @@ struct mydescriptor { unsigned int model; }; -GasSpinBoxItemDelegate::GasSpinBoxItemDelegate(QObject *parent, column_type type) : QStyledItemDelegate(parent), type(type) { } -GasSpinBoxItemDelegate::~GasSpinBoxItemDelegate() { } +GasSpinBoxItemDelegate::GasSpinBoxItemDelegate(QObject *parent, column_type type) : QStyledItemDelegate(parent), type(type) +{ +} +GasSpinBoxItemDelegate::~GasSpinBoxItemDelegate() +{ +} -QWidget* GasSpinBoxItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +QWidget *GasSpinBoxItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { // Create the spinbox and give it it's settings QSpinBox *sb = new QSpinBox(parent); @@ -58,7 +62,7 @@ QWidget* GasSpinBoxItemDelegate::createEditor(QWidget *parent, const QStyleOptio void GasSpinBoxItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { - if(QSpinBox *sb = qobject_cast<QSpinBox *>(editor)) + if (QSpinBox *sb = qobject_cast<QSpinBox *>(editor)) sb->setValue(index.data(Qt::EditRole).toInt()); else QStyledItemDelegate::setEditorData(editor, index); @@ -67,16 +71,20 @@ void GasSpinBoxItemDelegate::setEditorData(QWidget *editor, const QModelIndex &i void GasSpinBoxItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - if(QSpinBox *sb = qobject_cast<QSpinBox *>(editor)) + if (QSpinBox *sb = qobject_cast<QSpinBox *>(editor)) model->setData(index, sb->value(), Qt::EditRole); else QStyledItemDelegate::setModelData(editor, model, index); } -GasTypeComboBoxItemDelegate::GasTypeComboBoxItemDelegate(QObject *parent, computer_type type) : QStyledItemDelegate(parent), type(type) { } -GasTypeComboBoxItemDelegate::~GasTypeComboBoxItemDelegate() { } +GasTypeComboBoxItemDelegate::GasTypeComboBoxItemDelegate(QObject *parent, computer_type type) : QStyledItemDelegate(parent), type(type) +{ +} +GasTypeComboBoxItemDelegate::~GasTypeComboBoxItemDelegate() +{ +} -QWidget* GasTypeComboBoxItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +QWidget *GasTypeComboBoxItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { // Create the combobox and populate it QComboBox *cb = new QComboBox(parent); @@ -94,7 +102,7 @@ QWidget* GasTypeComboBoxItemDelegate::createEditor(QWidget *parent, const QStyle void GasTypeComboBoxItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { - if(QComboBox *cb = qobject_cast<QComboBox *>(editor)) + if (QComboBox *cb = qobject_cast<QComboBox *>(editor)) cb->setCurrentIndex(index.data(Qt::EditRole).toInt()); else QStyledItemDelegate::setEditorData(editor, index); @@ -103,14 +111,13 @@ void GasTypeComboBoxItemDelegate::setEditorData(QWidget *editor, const QModelInd void GasTypeComboBoxItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - if(QComboBox *cb = qobject_cast<QComboBox *>(editor)) + if (QComboBox *cb = qobject_cast<QComboBox *>(editor)) model->setData(index, cb->currentIndex(), Qt::EditRole); else QStyledItemDelegate::setModelData(editor, model, index); } -ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : - QDialog(parent), +ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent), config(0), deviceDetails(0) { @@ -120,8 +127,8 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : config = new ConfigureDiveComputer(); connect(config, SIGNAL(error(QString)), this, SLOT(configError(QString))); connect(config, SIGNAL(message(QString)), this, SLOT(configMessage(QString))); - connect(config, SIGNAL(deviceDetailsChanged(DeviceDetails*)), - this, SLOT(deviceDetailsReceived(DeviceDetails*))); + connect(config, SIGNAL(deviceDetailsChanged(DeviceDetails *)), + this, SLOT(deviceDetailsReceived(DeviceDetails *))); connect(ui.retrieveDetails, SIGNAL(clicked()), this, SLOT(readSettings())); connect(ui.resetButton, SIGNAL(clicked()), this, SLOT(resetSettings())); @@ -150,21 +157,21 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : settings.beginGroup("ConfigureDiveComputerDialog"); settings.beginGroup("ostc3GasTable"); for (int i = 0; i < ui.ostc3GasTable->columnCount(); i++) { - QVariant width = settings.value(QString("colwidth%1").arg(i)); + QVariant width = settings.value(QString("colwidth%1").arg(i)); if (width.isValid()) ui.ostc3GasTable->setColumnWidth(i, width.toInt()); } settings.endGroup(); settings.beginGroup("ostc3DilTable"); for (int i = 0; i < ui.ostc3DilTable->columnCount(); i++) { - QVariant width = settings.value(QString("colwidth%1").arg(i)); + QVariant width = settings.value(QString("colwidth%1").arg(i)); if (width.isValid()) ui.ostc3DilTable->setColumnWidth(i, width.toInt()); } settings.endGroup(); settings.beginGroup("ostc3SetPointTable"); for (int i = 0; i < ui.ostc3SetPointTable->columnCount(); i++) { - QVariant width = settings.value(QString("colwidth%1").arg(i)); + QVariant width = settings.value(QString("colwidth%1").arg(i)); if (width.isValid()) ui.ostc3SetPointTable->setColumnWidth(i, width.toInt()); } @@ -172,21 +179,21 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : settings.beginGroup("ostcGasTable"); for (int i = 0; i < ui.ostcGasTable->columnCount(); i++) { - QVariant width = settings.value(QString("colwidth%1").arg(i)); + QVariant width = settings.value(QString("colwidth%1").arg(i)); if (width.isValid()) ui.ostcGasTable->setColumnWidth(i, width.toInt()); } settings.endGroup(); settings.beginGroup("ostcDilTable"); for (int i = 0; i < ui.ostcDilTable->columnCount(); i++) { - QVariant width = settings.value(QString("colwidth%1").arg(i)); + QVariant width = settings.value(QString("colwidth%1").arg(i)); if (width.isValid()) ui.ostcDilTable->setColumnWidth(i, width.toInt()); } settings.endGroup(); settings.beginGroup("ostcSetPointTable"); for (int i = 0; i < ui.ostcSetPointTable->columnCount(); i++) { - QVariant width = settings.value(QString("colwidth%1").arg(i)); + QVariant width = settings.value(QString("colwidth%1").arg(i)); if (width.isValid()) ui.ostcSetPointTable->setColumnWidth(i, width.toInt()); } @@ -216,9 +223,9 @@ void OstcFirmwareCheck::parseOstcFwVersion(QNetworkReply *reply) QString parse = reply->readAll(); int firstOpenBracket = parse.indexOf('['); int firstCloseBracket = parse.indexOf(']'); - latestFirmwareAvailable = parse.mid(firstOpenBracket + 1, firstCloseBracket - firstOpenBracket -1); + latestFirmwareAvailable = parse.mid(firstOpenBracket + 1, firstCloseBracket - firstOpenBracket - 1); qDebug() << "latest firmware available" << latestFirmwareAvailable; - disconnect(&manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseOstcFwVersion(QNetworkReply*))); + disconnect(&manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(parseOstcFwVersion(QNetworkReply *))); } void OstcFirmwareCheck::checkLatest(QWidget *_parent, device_data_t *data) @@ -229,11 +236,12 @@ void OstcFirmwareCheck::checkLatest(QWidget *_parent, device_data_t *data) // for the OSTC that means highbyte.lowbyte is the version number int firmwareOnDevice = devData.libdc_firmware; QString firmware; - firmware = QString("%1.%2").arg(firmwareOnDevice / 256). arg(firmwareOnDevice % 256); + firmware = QString("%1.%2").arg(firmwareOnDevice / 256).arg(firmwareOnDevice % 256); if (!latestFirmwareAvailable.isEmpty() && latestFirmwareAvailable != firmware) { QMessageBox response(parent); QString message = tr("You should update the firmware on your dive computer: you have version %1 but the latest stable version is %2") - .arg(firmware).arg(latestFirmwareAvailable); + .arg(firmware) + .arg(latestFirmwareAvailable); response.addButton(tr("Not now"), QMessageBox::RejectRole); response.addButton(tr("Update firmware"), QMessageBox::AcceptRole); response.setText(message); @@ -275,7 +283,9 @@ void OstcFirmwareCheck::saveOstcFirmware(QNetworkReply *reply) file.open(QIODevice::WriteOnly); file.write(firmwareData); file.close(); + qDebug() << "file closed"; ConfigureDiveComputer *config = new ConfigureDiveComputer(); + qDebug() << "created config object, calling the firwmware uploader"; config->startFirmwareUpdate(storeFirmware, &devData); } @@ -368,7 +378,7 @@ void ConfigureDiveComputerDialog::fill_computer_list() void ConfigureDiveComputerDialog::populateDeviceDetails() { - switch(ui.dcStackedWidget->currentIndex()) { + switch (ui.dcStackedWidget->currentIndex()) { case 0: populateDeviceDetailsOSTC3(); break; @@ -468,7 +478,7 @@ void ConfigureDiveComputerDialog::populateDeviceDetailsOSTC3() dil2.oxygen = GET_INT_FROM(ui.ostc3DilTable->item(1, 1), 21); dil2.helium = GET_INT_FROM(ui.ostc3DilTable->item(1, 2), 0); dil2.type = GET_INT_FROM(ui.ostc3DilTable->item(1, 3), 0); - dil2.depth = GET_INT_FROM(ui.ostc3DilTable->item(1, 4),0); + dil2.depth = GET_INT_FROM(ui.ostc3DilTable->item(1, 4), 0); dil3.oxygen = GET_INT_FROM(ui.ostc3DilTable->item(2, 1), 21); dil3.helium = GET_INT_FROM(ui.ostc3DilTable->item(2, 2), 0); @@ -594,7 +604,7 @@ void ConfigureDiveComputerDialog::populateDeviceDetailsOSTC() dil2.oxygen = GET_INT_FROM(ui.ostcDilTable->item(1, 1), 21); dil2.helium = GET_INT_FROM(ui.ostcDilTable->item(1, 2), 0); dil2.type = GET_INT_FROM(ui.ostcDilTable->item(1, 3), 0); - dil2.depth = GET_INT_FROM(ui.ostcDilTable->item(1, 4),0); + dil2.depth = GET_INT_FROM(ui.ostcDilTable->item(1, 4), 0); dil3.oxygen = GET_INT_FROM(ui.ostcDilTable->item(2, 1), 21); dil3.helium = GET_INT_FROM(ui.ostcDilTable->item(2, 2), 0); @@ -728,7 +738,7 @@ void ConfigureDiveComputerDialog::reloadValues() ui.saveSettingsPushButton->setEnabled(true); ui.backupButton->setEnabled(true); - switch(ui.dcStackedWidget->currentIndex()) { + switch (ui.dcStackedWidget->currentIndex()) { case 0: reloadValuesOSTC3(); break; @@ -775,64 +785,64 @@ void ConfigureDiveComputerDialog::reloadValuesOSTC3() ui.setPointFallbackCheckBox->setChecked(deviceDetails->setPointFallback()); //load gas 1 values - ui.ostc3GasTable->setItem(0,1, new QTableWidgetItem(QString::number(deviceDetails->gas1().oxygen))); - ui.ostc3GasTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->gas1().helium))); - ui.ostc3GasTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->gas1().type))); - ui.ostc3GasTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->gas1().depth))); + ui.ostc3GasTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->gas1().oxygen))); + ui.ostc3GasTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->gas1().helium))); + ui.ostc3GasTable->setItem(0, 3, new QTableWidgetItem(QString::number(deviceDetails->gas1().type))); + ui.ostc3GasTable->setItem(0, 4, new QTableWidgetItem(QString::number(deviceDetails->gas1().depth))); //load gas 2 values - ui.ostc3GasTable->setItem(1,1, new QTableWidgetItem(QString::number(deviceDetails->gas2().oxygen))); - ui.ostc3GasTable->setItem(1,2, new QTableWidgetItem(QString::number(deviceDetails->gas2().helium))); - ui.ostc3GasTable->setItem(1,3, new QTableWidgetItem(QString::number(deviceDetails->gas2().type))); - ui.ostc3GasTable->setItem(1,4, new QTableWidgetItem(QString::number(deviceDetails->gas2().depth))); + ui.ostc3GasTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->gas2().oxygen))); + ui.ostc3GasTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->gas2().helium))); + ui.ostc3GasTable->setItem(1, 3, new QTableWidgetItem(QString::number(deviceDetails->gas2().type))); + ui.ostc3GasTable->setItem(1, 4, new QTableWidgetItem(QString::number(deviceDetails->gas2().depth))); //load gas 3 values - ui.ostc3GasTable->setItem(2,1, new QTableWidgetItem(QString::number(deviceDetails->gas3().oxygen))); - ui.ostc3GasTable->setItem(2,2, new QTableWidgetItem(QString::number(deviceDetails->gas3().helium))); - ui.ostc3GasTable->setItem(2,3, new QTableWidgetItem(QString::number(deviceDetails->gas3().type))); - ui.ostc3GasTable->setItem(2,4, new QTableWidgetItem(QString::number(deviceDetails->gas3().depth))); + ui.ostc3GasTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->gas3().oxygen))); + ui.ostc3GasTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->gas3().helium))); + ui.ostc3GasTable->setItem(2, 3, new QTableWidgetItem(QString::number(deviceDetails->gas3().type))); + ui.ostc3GasTable->setItem(2, 4, new QTableWidgetItem(QString::number(deviceDetails->gas3().depth))); //load gas 4 values - ui.ostc3GasTable->setItem(3,1, new QTableWidgetItem(QString::number(deviceDetails->gas4().oxygen))); - ui.ostc3GasTable->setItem(3,2, new QTableWidgetItem(QString::number(deviceDetails->gas4().helium))); - ui.ostc3GasTable->setItem(3,3, new QTableWidgetItem(QString::number(deviceDetails->gas4().type))); - ui.ostc3GasTable->setItem(3,4, new QTableWidgetItem(QString::number(deviceDetails->gas4().depth))); + ui.ostc3GasTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->gas4().oxygen))); + ui.ostc3GasTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->gas4().helium))); + ui.ostc3GasTable->setItem(3, 3, new QTableWidgetItem(QString::number(deviceDetails->gas4().type))); + ui.ostc3GasTable->setItem(3, 4, new QTableWidgetItem(QString::number(deviceDetails->gas4().depth))); //load gas 5 values - ui.ostc3GasTable->setItem(4,1, new QTableWidgetItem(QString::number(deviceDetails->gas5().oxygen))); - ui.ostc3GasTable->setItem(4,2, new QTableWidgetItem(QString::number(deviceDetails->gas5().helium))); - ui.ostc3GasTable->setItem(4,3, new QTableWidgetItem(QString::number(deviceDetails->gas5().type))); - ui.ostc3GasTable->setItem(4,4, new QTableWidgetItem(QString::number(deviceDetails->gas5().depth))); + ui.ostc3GasTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->gas5().oxygen))); + ui.ostc3GasTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->gas5().helium))); + ui.ostc3GasTable->setItem(4, 3, new QTableWidgetItem(QString::number(deviceDetails->gas5().type))); + ui.ostc3GasTable->setItem(4, 4, new QTableWidgetItem(QString::number(deviceDetails->gas5().depth))); //load dil 1 values - ui.ostc3DilTable->setItem(0,1, new QTableWidgetItem(QString::number(deviceDetails->dil1().oxygen))); - ui.ostc3DilTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->dil1().helium))); - ui.ostc3DilTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->dil1().type))); - ui.ostc3DilTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->dil1().depth))); + ui.ostc3DilTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->dil1().oxygen))); + ui.ostc3DilTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->dil1().helium))); + ui.ostc3DilTable->setItem(0, 3, new QTableWidgetItem(QString::number(deviceDetails->dil1().type))); + ui.ostc3DilTable->setItem(0, 4, new QTableWidgetItem(QString::number(deviceDetails->dil1().depth))); //load dil 2 values - ui.ostc3DilTable->setItem(1,1, new QTableWidgetItem(QString::number(deviceDetails->dil2().oxygen))); - ui.ostc3DilTable->setItem(1,2, new QTableWidgetItem(QString::number(deviceDetails->dil2().helium))); - ui.ostc3DilTable->setItem(1,3, new QTableWidgetItem(QString::number(deviceDetails->dil2().type))); - ui.ostc3DilTable->setItem(1,4, new QTableWidgetItem(QString::number(deviceDetails->dil2().depth))); + ui.ostc3DilTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->dil2().oxygen))); + ui.ostc3DilTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->dil2().helium))); + ui.ostc3DilTable->setItem(1, 3, new QTableWidgetItem(QString::number(deviceDetails->dil2().type))); + ui.ostc3DilTable->setItem(1, 4, new QTableWidgetItem(QString::number(deviceDetails->dil2().depth))); //load dil 3 values - ui.ostc3DilTable->setItem(2,1, new QTableWidgetItem(QString::number(deviceDetails->dil3().oxygen))); - ui.ostc3DilTable->setItem(2,2, new QTableWidgetItem(QString::number(deviceDetails->dil3().helium))); - ui.ostc3DilTable->setItem(2,3, new QTableWidgetItem(QString::number(deviceDetails->dil3().type))); - ui.ostc3DilTable->setItem(2,4, new QTableWidgetItem(QString::number(deviceDetails->dil3().depth))); + ui.ostc3DilTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->dil3().oxygen))); + ui.ostc3DilTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->dil3().helium))); + ui.ostc3DilTable->setItem(2, 3, new QTableWidgetItem(QString::number(deviceDetails->dil3().type))); + ui.ostc3DilTable->setItem(2, 4, new QTableWidgetItem(QString::number(deviceDetails->dil3().depth))); //load dil 4 values - ui.ostc3DilTable->setItem(3,1, new QTableWidgetItem(QString::number(deviceDetails->dil4().oxygen))); - ui.ostc3DilTable->setItem(3,2, new QTableWidgetItem(QString::number(deviceDetails->dil4().helium))); - ui.ostc3DilTable->setItem(3,3, new QTableWidgetItem(QString::number(deviceDetails->dil4().type))); - ui.ostc3DilTable->setItem(3,4, new QTableWidgetItem(QString::number(deviceDetails->dil4().depth))); + ui.ostc3DilTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->dil4().oxygen))); + ui.ostc3DilTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->dil4().helium))); + ui.ostc3DilTable->setItem(3, 3, new QTableWidgetItem(QString::number(deviceDetails->dil4().type))); + ui.ostc3DilTable->setItem(3, 4, new QTableWidgetItem(QString::number(deviceDetails->dil4().depth))); //load dil 5 values - ui.ostc3DilTable->setItem(4,1, new QTableWidgetItem(QString::number(deviceDetails->dil5().oxygen))); - ui.ostc3DilTable->setItem(4,2, new QTableWidgetItem(QString::number(deviceDetails->dil5().helium))); - ui.ostc3DilTable->setItem(4,3, new QTableWidgetItem(QString::number(deviceDetails->dil5().type))); - ui.ostc3DilTable->setItem(4,4, new QTableWidgetItem(QString::number(deviceDetails->dil5().depth))); + ui.ostc3DilTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->dil5().oxygen))); + ui.ostc3DilTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->dil5().helium))); + ui.ostc3DilTable->setItem(4, 3, new QTableWidgetItem(QString::number(deviceDetails->dil5().type))); + ui.ostc3DilTable->setItem(4, 4, new QTableWidgetItem(QString::number(deviceDetails->dil5().depth))); //load set point 1 values ui.ostc3SetPointTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->sp1().sp))); @@ -857,7 +867,7 @@ void ConfigureDiveComputerDialog::reloadValuesOSTC3() void ConfigureDiveComputerDialog::reloadValuesOSTC() { -/* + /* # Not in OSTC setBrightness setCalibrationGas @@ -880,7 +890,7 @@ setNumberOfDives ui.desaturationSpinBox_3->setValue(deviceDetails->desaturation()); ui.lastDecoSpinBox_3->setValue(deviceDetails->lastDeco()); ui.samplingRateSpinBox_3->setValue(deviceDetails->samplingRate()); - ui.salinityDoubleSpinBox_3->setValue((double) deviceDetails->salinity() / 100.0); + ui.salinityDoubleSpinBox_3->setValue((double)deviceDetails->salinity() / 100.0); ui.dateFormatComboBox_3->setCurrentIndex(deviceDetails->dateFormat()); ui.safetyStopCheckBox_3->setChecked(deviceDetails->safetyStop()); ui.gfHighSpinBox_3->setValue(deviceDetails->gfHigh()); @@ -895,64 +905,64 @@ setNumberOfDives ui.numberOfDivesSpinBox_3->setValue(deviceDetails->numberOfDives()); //load gas 1 values - ui.ostcGasTable->setItem(0,1, new QTableWidgetItem(QString::number(deviceDetails->gas1().oxygen))); - ui.ostcGasTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->gas1().helium))); - ui.ostcGasTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->gas1().type))); - ui.ostcGasTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->gas1().depth))); + ui.ostcGasTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->gas1().oxygen))); + ui.ostcGasTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->gas1().helium))); + ui.ostcGasTable->setItem(0, 3, new QTableWidgetItem(QString::number(deviceDetails->gas1().type))); + ui.ostcGasTable->setItem(0, 4, new QTableWidgetItem(QString::number(deviceDetails->gas1().depth))); //load gas 2 values - ui.ostcGasTable->setItem(1,1, new QTableWidgetItem(QString::number(deviceDetails->gas2().oxygen))); - ui.ostcGasTable->setItem(1,2, new QTableWidgetItem(QString::number(deviceDetails->gas2().helium))); - ui.ostcGasTable->setItem(1,3, new QTableWidgetItem(QString::number(deviceDetails->gas2().type))); - ui.ostcGasTable->setItem(1,4, new QTableWidgetItem(QString::number(deviceDetails->gas2().depth))); + ui.ostcGasTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->gas2().oxygen))); + ui.ostcGasTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->gas2().helium))); + ui.ostcGasTable->setItem(1, 3, new QTableWidgetItem(QString::number(deviceDetails->gas2().type))); + ui.ostcGasTable->setItem(1, 4, new QTableWidgetItem(QString::number(deviceDetails->gas2().depth))); //load gas 3 values - ui.ostcGasTable->setItem(2,1, new QTableWidgetItem(QString::number(deviceDetails->gas3().oxygen))); - ui.ostcGasTable->setItem(2,2, new QTableWidgetItem(QString::number(deviceDetails->gas3().helium))); - ui.ostcGasTable->setItem(2,3, new QTableWidgetItem(QString::number(deviceDetails->gas3().type))); - ui.ostcGasTable->setItem(2,4, new QTableWidgetItem(QString::number(deviceDetails->gas3().depth))); + ui.ostcGasTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->gas3().oxygen))); + ui.ostcGasTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->gas3().helium))); + ui.ostcGasTable->setItem(2, 3, new QTableWidgetItem(QString::number(deviceDetails->gas3().type))); + ui.ostcGasTable->setItem(2, 4, new QTableWidgetItem(QString::number(deviceDetails->gas3().depth))); //load gas 4 values - ui.ostcGasTable->setItem(3,1, new QTableWidgetItem(QString::number(deviceDetails->gas4().oxygen))); - ui.ostcGasTable->setItem(3,2, new QTableWidgetItem(QString::number(deviceDetails->gas4().helium))); - ui.ostcGasTable->setItem(3,3, new QTableWidgetItem(QString::number(deviceDetails->gas4().type))); - ui.ostcGasTable->setItem(3,4, new QTableWidgetItem(QString::number(deviceDetails->gas4().depth))); + ui.ostcGasTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->gas4().oxygen))); + ui.ostcGasTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->gas4().helium))); + ui.ostcGasTable->setItem(3, 3, new QTableWidgetItem(QString::number(deviceDetails->gas4().type))); + ui.ostcGasTable->setItem(3, 4, new QTableWidgetItem(QString::number(deviceDetails->gas4().depth))); //load gas 5 values - ui.ostcGasTable->setItem(4,1, new QTableWidgetItem(QString::number(deviceDetails->gas5().oxygen))); - ui.ostcGasTable->setItem(4,2, new QTableWidgetItem(QString::number(deviceDetails->gas5().helium))); - ui.ostcGasTable->setItem(4,3, new QTableWidgetItem(QString::number(deviceDetails->gas5().type))); - ui.ostcGasTable->setItem(4,4, new QTableWidgetItem(QString::number(deviceDetails->gas5().depth))); + ui.ostcGasTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->gas5().oxygen))); + ui.ostcGasTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->gas5().helium))); + ui.ostcGasTable->setItem(4, 3, new QTableWidgetItem(QString::number(deviceDetails->gas5().type))); + ui.ostcGasTable->setItem(4, 4, new QTableWidgetItem(QString::number(deviceDetails->gas5().depth))); //load dil 1 values - ui.ostcDilTable->setItem(0,1, new QTableWidgetItem(QString::number(deviceDetails->dil1().oxygen))); - ui.ostcDilTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->dil1().helium))); - ui.ostcDilTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->dil1().type))); - ui.ostcDilTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->dil1().depth))); + ui.ostcDilTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->dil1().oxygen))); + ui.ostcDilTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->dil1().helium))); + ui.ostcDilTable->setItem(0, 3, new QTableWidgetItem(QString::number(deviceDetails->dil1().type))); + ui.ostcDilTable->setItem(0, 4, new QTableWidgetItem(QString::number(deviceDetails->dil1().depth))); //load dil 2 values - ui.ostcDilTable->setItem(1,1, new QTableWidgetItem(QString::number(deviceDetails->dil2().oxygen))); - ui.ostcDilTable->setItem(1,2, new QTableWidgetItem(QString::number(deviceDetails->dil2().helium))); - ui.ostcDilTable->setItem(1,3, new QTableWidgetItem(QString::number(deviceDetails->dil2().type))); - ui.ostcDilTable->setItem(1,4, new QTableWidgetItem(QString::number(deviceDetails->dil2().depth))); + ui.ostcDilTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->dil2().oxygen))); + ui.ostcDilTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->dil2().helium))); + ui.ostcDilTable->setItem(1, 3, new QTableWidgetItem(QString::number(deviceDetails->dil2().type))); + ui.ostcDilTable->setItem(1, 4, new QTableWidgetItem(QString::number(deviceDetails->dil2().depth))); //load dil 3 values - ui.ostcDilTable->setItem(2,1, new QTableWidgetItem(QString::number(deviceDetails->dil3().oxygen))); - ui.ostcDilTable->setItem(2,2, new QTableWidgetItem(QString::number(deviceDetails->dil3().helium))); - ui.ostcDilTable->setItem(2,3, new QTableWidgetItem(QString::number(deviceDetails->dil3().type))); - ui.ostcDilTable->setItem(2,4, new QTableWidgetItem(QString::number(deviceDetails->dil3().depth))); + ui.ostcDilTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->dil3().oxygen))); + ui.ostcDilTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->dil3().helium))); + ui.ostcDilTable->setItem(2, 3, new QTableWidgetItem(QString::number(deviceDetails->dil3().type))); + ui.ostcDilTable->setItem(2, 4, new QTableWidgetItem(QString::number(deviceDetails->dil3().depth))); //load dil 4 values - ui.ostcDilTable->setItem(3,1, new QTableWidgetItem(QString::number(deviceDetails->dil4().oxygen))); - ui.ostcDilTable->setItem(3,2, new QTableWidgetItem(QString::number(deviceDetails->dil4().helium))); - ui.ostcDilTable->setItem(3,3, new QTableWidgetItem(QString::number(deviceDetails->dil4().type))); - ui.ostcDilTable->setItem(3,4, new QTableWidgetItem(QString::number(deviceDetails->dil4().depth))); + ui.ostcDilTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->dil4().oxygen))); + ui.ostcDilTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->dil4().helium))); + ui.ostcDilTable->setItem(3, 3, new QTableWidgetItem(QString::number(deviceDetails->dil4().type))); + ui.ostcDilTable->setItem(3, 4, new QTableWidgetItem(QString::number(deviceDetails->dil4().depth))); //load dil 5 values - ui.ostcDilTable->setItem(4,1, new QTableWidgetItem(QString::number(deviceDetails->dil5().oxygen))); - ui.ostcDilTable->setItem(4,2, new QTableWidgetItem(QString::number(deviceDetails->dil5().helium))); - ui.ostcDilTable->setItem(4,3, new QTableWidgetItem(QString::number(deviceDetails->dil5().type))); - ui.ostcDilTable->setItem(4,4, new QTableWidgetItem(QString::number(deviceDetails->dil5().depth))); + ui.ostcDilTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->dil5().oxygen))); + ui.ostcDilTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->dil5().helium))); + ui.ostcDilTable->setItem(4, 3, new QTableWidgetItem(QString::number(deviceDetails->dil5().type))); + ui.ostcDilTable->setItem(4, 4, new QTableWidgetItem(QString::number(deviceDetails->dil5().depth))); //load set point 1 values ui.ostcSetPointTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->sp1().sp))); @@ -1007,21 +1017,18 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked() QFileInfo fi(filename); filename = fi.absolutePath().append(QDir::separator()).append("Backup.xml"); QString backupPath = QFileDialog::getSaveFileName(this, tr("Backup dive computer settings"), - filename, tr("Backup files (*.xml)") - ); + filename, tr("Backup files (*.xml)")); if (!backupPath.isEmpty()) { populateDeviceDetails(); getDeviceData(); if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data)) { QMessageBox::critical(this, tr("XML backup error"), tr("An error occurred while saving the backup file.\n%1") - .arg(config->lastError) - ); + .arg(config->lastError)); } else { QMessageBox::information(this, tr("Backup succeeded"), tr("Your settings have been saved to: %1") - .arg(backupPath) - ); + .arg(backupPath)); } } } @@ -1032,21 +1039,18 @@ void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked() QFileInfo fi(filename); filename = fi.absolutePath().append(QDir::separator()).append("Backup.xml"); QString restorePath = QFileDialog::getOpenFileName(this, tr("Restore dive computer settings"), - filename, tr("Backup files (*.xml)") - ); + filename, tr("Backup files (*.xml)")); if (!restorePath.isEmpty()) { if (!config->restoreXMLBackup(restorePath, deviceDetails)) { QMessageBox::critical(this, tr("XML restore error"), tr("An error occurred while restoring the backup file.\n%1") - .arg(config->lastError) - ); + .arg(config->lastError)); } else { reloadValues(); //getDeviceData(); //config->saveDeviceDetails(deviceDetails, &device_data); QMessageBox::information(this, tr("Restore succeeded"), - tr("Your settings have been restored successfully.") - ); + tr("Your settings have been restored successfully.")); } } } @@ -1057,8 +1061,7 @@ void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked() QFileInfo fi(filename); filename = fi.absolutePath(); QString firmwarePath = QFileDialog::getOpenFileName(this, tr("Select firmware file"), - filename, tr("All files (*.*)") - ); + filename, tr("All files (*.*)")); if (!firmwarePath.isEmpty()) { getDeviceData(); config->startFirmwareUpdate(firmwarePath, &device_data); @@ -1066,7 +1069,6 @@ void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked() } - void ConfigureDiveComputerDialog::on_DiveComputerList_currentRowChanged(int currentRow) { // Disable the buttons to do operations on this data diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index e36e88d1f..b2e4ff636 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -9,8 +9,7 @@ #include <QStyledItemDelegate> #include <QNetworkAccessManager> -class GasSpinBoxItemDelegate : public QStyledItemDelegate -{ +class GasSpinBoxItemDelegate : public QStyledItemDelegate { Q_OBJECT public: @@ -25,12 +24,12 @@ public: virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; virtual void setEditorData(QWidget *editor, const QModelIndex &index) const; virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; + private: column_type type; }; -class GasTypeComboBoxItemDelegate : public QStyledItemDelegate -{ +class GasTypeComboBoxItemDelegate : public QStyledItemDelegate { Q_OBJECT public: @@ -45,19 +44,20 @@ public: virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; virtual void setEditorData(QWidget *editor, const QModelIndex &index) const; virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; + private: computer_type type; }; -class ConfigureDiveComputerDialog : public QDialog -{ +class ConfigureDiveComputerDialog : public QDialog { Q_OBJECT public: explicit ConfigureDiveComputerDialog(QWidget *parent = 0); ~ConfigureDiveComputerDialog(); -private slots: +private +slots: void readSettings(); void resetSettings(); void configMessage(QString msg); @@ -102,8 +102,7 @@ private: QString selected_product; }; -class OstcFirmwareCheck : QObject -{ +class OstcFirmwareCheck : QObject { Q_OBJECT public: explicit OstcFirmwareCheck(QString product); @@ -111,7 +110,8 @@ public: public slots: void parseOstcFwVersion(QNetworkReply *reply); - void saveOstcFirmware(QNetworkReply * reply); + void saveOstcFirmware(QNetworkReply *reply); + private: void upgradeFirmware(); device_data_t devData; |