2014-05-29 15:54:19 +00:00
|
|
|
#include "configuredivecomputerdialog.h"
|
|
|
|
#include "ui_configuredivecomputerdialog.h"
|
|
|
|
|
2014-05-29 16:16:34 +00:00
|
|
|
#include "../divecomputer.h"
|
|
|
|
#include "../libdivecomputer.h"
|
|
|
|
#include "../helpers.h"
|
|
|
|
#include "../display.h"
|
|
|
|
#include "../divelist.h"
|
2014-05-30 06:56:27 +00:00
|
|
|
#include "configuredivecomputer.h"
|
2014-06-10 16:19:28 +00:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
2014-05-29 16:16:34 +00:00
|
|
|
struct product {
|
|
|
|
const char *product;
|
|
|
|
dc_descriptor_t *descriptor;
|
|
|
|
struct product *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vendor {
|
|
|
|
const char *vendor;
|
|
|
|
struct product *productlist;
|
|
|
|
struct vendor *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mydescriptor {
|
|
|
|
const char *vendor;
|
|
|
|
const char *product;
|
|
|
|
dc_family_t type;
|
|
|
|
unsigned int model;
|
|
|
|
};
|
|
|
|
|
2014-05-29 15:54:19 +00:00
|
|
|
ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
2014-05-29 16:16:34 +00:00
|
|
|
ui(new Ui::ConfigureDiveComputerDialog),
|
2014-05-30 06:56:27 +00:00
|
|
|
config(0),
|
2014-06-10 12:03:26 +00:00
|
|
|
deviceDetails(0)
|
2014-05-29 15:54:19 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2014-05-29 16:16:34 +00:00
|
|
|
|
2014-06-10 12:03:26 +00:00
|
|
|
deviceDetails = new DeviceDetails(this);
|
2014-05-30 06:56:27 +00:00
|
|
|
config = new ConfigureDiveComputer(this);
|
2014-06-23 15:16:27 +00:00
|
|
|
connect(config, SIGNAL(error(QString)), this, SLOT(configError(QString)));
|
|
|
|
connect(config, SIGNAL(message(QString)), this, SLOT(configMessage(QString)));
|
|
|
|
connect(config, SIGNAL(readFinished()), this, SLOT(deviceReadFinished()));
|
|
|
|
connect(config, SIGNAL(deviceDetailsChanged(DeviceDetails*)),
|
2014-06-10 15:25:25 +00:00
|
|
|
this, SLOT(deviceDetailsReceived(DeviceDetails*)));
|
2014-06-23 15:16:27 +00:00
|
|
|
connect(ui->retrieveDetails, SIGNAL(clicked()), this, SLOT(readSettings()));
|
2014-05-30 06:56:27 +00:00
|
|
|
|
2014-06-11 08:47:25 +00:00
|
|
|
memset(&device_data, 0, sizeof(device_data));
|
2014-05-29 16:16:34 +00:00
|
|
|
fill_computer_list();
|
|
|
|
if (default_dive_computer_device)
|
|
|
|
ui->device->setEditText(default_dive_computer_device);
|
2014-05-30 06:56:27 +00:00
|
|
|
|
2014-07-16 09:04:54 +00:00
|
|
|
ui->DiveComputerList->setCurrentRow(0);
|
|
|
|
on_DiveComputerList_currentRowChanged(0);
|
2014-05-29 15:54:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2014-05-29 16:16:34 +00:00
|
|
|
|
2014-06-11 08:47:25 +00:00
|
|
|
|
|
|
|
static void fillDeviceList(const char *name, void *data)
|
|
|
|
{
|
|
|
|
QComboBox *comboBox = (QComboBox *)data;
|
|
|
|
comboBox->addItem(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::fill_device_list(int dc_type)
|
|
|
|
{
|
|
|
|
int deviceIndex;
|
|
|
|
ui->device->clear();
|
|
|
|
deviceIndex = enumerate_devices(fillDeviceList, ui->device, dc_type);
|
|
|
|
if (deviceIndex >= 0)
|
|
|
|
ui->device->setCurrentIndex(deviceIndex);
|
|
|
|
}
|
|
|
|
|
2014-05-29 16:16:34 +00:00
|
|
|
void ConfigureDiveComputerDialog::fill_computer_list()
|
|
|
|
{
|
|
|
|
dc_iterator_t *iterator = NULL;
|
|
|
|
dc_descriptor_t *descriptor = NULL;
|
|
|
|
|
|
|
|
struct mydescriptor *mydescriptor;
|
|
|
|
|
|
|
|
dc_descriptor_iterator(&iterator);
|
|
|
|
while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) {
|
|
|
|
const char *vendor = dc_descriptor_get_vendor(descriptor);
|
|
|
|
const char *product = dc_descriptor_get_product(descriptor);
|
|
|
|
|
|
|
|
if (!vendorList.contains(vendor))
|
|
|
|
vendorList.append(vendor);
|
|
|
|
|
|
|
|
if (!productList[vendor].contains(product))
|
|
|
|
productList[vendor].push_back(product);
|
|
|
|
|
|
|
|
descriptorLookup[QString(vendor) + QString(product)] = descriptor;
|
|
|
|
}
|
|
|
|
dc_iterator_free(iterator);
|
|
|
|
|
|
|
|
mydescriptor = (struct mydescriptor *)malloc(sizeof(struct mydescriptor));
|
|
|
|
mydescriptor->vendor = "Uemis";
|
|
|
|
mydescriptor->product = "Zurich";
|
|
|
|
mydescriptor->type = DC_FAMILY_NULL;
|
|
|
|
mydescriptor->model = 0;
|
|
|
|
|
|
|
|
if (!vendorList.contains("Uemis"))
|
|
|
|
vendorList.append("Uemis");
|
|
|
|
|
|
|
|
if (!productList["Uemis"].contains("Zurich"))
|
|
|
|
productList["Uemis"].push_back("Zurich");
|
|
|
|
|
|
|
|
descriptorLookup["UemisZurich"] = (dc_descriptor_t *)mydescriptor;
|
|
|
|
|
|
|
|
qSort(vendorList);
|
|
|
|
}
|
|
|
|
|
2014-06-10 16:19:28 +00:00
|
|
|
void ConfigureDiveComputerDialog::populateDeviceDetails()
|
|
|
|
{
|
2014-06-11 08:09:01 +00:00
|
|
|
deviceDetails->setCustomText(ui->customTextLlineEdit->text());
|
2014-06-13 14:10:10 +00:00
|
|
|
deviceDetails->setDiveMode(ui->diveModeComboBox->currentIndex());
|
|
|
|
deviceDetails->setSaturation(ui->saturationSpinBox->value());
|
2014-06-20 04:51:32 +00:00
|
|
|
deviceDetails->setDesaturation(ui->desaturationSpinBox->value());
|
2014-06-11 08:09:01 +00:00
|
|
|
deviceDetails->setLastDeco(ui->lastDecoSpinBox->value());
|
2014-06-10 16:19:28 +00:00
|
|
|
deviceDetails->setBrightness(ui->brightnessComboBox->currentIndex());
|
2014-06-11 08:09:01 +00:00
|
|
|
deviceDetails->setUnits(ui->unitsComboBox->currentIndex());
|
|
|
|
deviceDetails->setSamplingRate(ui->samplingRateComboBox->currentIndex());
|
|
|
|
deviceDetails->setSalinity(ui->salinitySpinBox->value());
|
|
|
|
deviceDetails->setDiveModeColor(ui->diveModeColour->currentIndex());
|
2014-06-10 16:19:28 +00:00
|
|
|
deviceDetails->setLanguage(ui->languageComboBox->currentIndex());
|
|
|
|
deviceDetails->setDateFormat(ui->dateFormatComboBox->currentIndex());
|
2014-06-11 08:09:01 +00:00
|
|
|
deviceDetails->setCompassGain(ui->compassGainComboBox->currentIndex());
|
2014-06-10 16:19:28 +00:00
|
|
|
deviceDetails->setSyncTime(ui->dateTimeSyncCheckBox->isChecked());
|
2014-06-21 06:14:55 +00:00
|
|
|
|
|
|
|
//set gas values
|
|
|
|
gas gas1;
|
|
|
|
gas gas2;
|
|
|
|
gas gas3;
|
|
|
|
gas gas4;
|
|
|
|
gas gas5;
|
|
|
|
|
|
|
|
gas1.oxygen = ui->ostc3GasTable->item(0, 1)->text().toInt();
|
|
|
|
gas1.helium = ui->ostc3GasTable->item(0, 2)->text().toInt();
|
|
|
|
gas1.type = ui->ostc3GasTable->item(0, 3)->text().toInt();
|
|
|
|
gas1.depth = ui->ostc3GasTable->item(0, 4)->text().toInt();
|
|
|
|
|
|
|
|
gas2.oxygen = ui->ostc3GasTable->item(1, 1)->text().toInt();
|
|
|
|
gas2.helium = ui->ostc3GasTable->item(1, 2)->text().toInt();
|
|
|
|
gas2.type = ui->ostc3GasTable->item(1, 3)->text().toInt();
|
|
|
|
gas2.depth = ui->ostc3GasTable->item(1, 4)->text().toInt();
|
|
|
|
|
|
|
|
gas3.oxygen = ui->ostc3GasTable->item(2, 1)->text().toInt();
|
|
|
|
gas3.helium = ui->ostc3GasTable->item(2, 2)->text().toInt();
|
|
|
|
gas3.type = ui->ostc3GasTable->item(2, 3)->text().toInt();
|
|
|
|
gas3.depth = ui->ostc3GasTable->item(2, 4)->text().toInt();
|
|
|
|
|
|
|
|
gas4.oxygen = ui->ostc3GasTable->item(3, 1)->text().toInt();
|
|
|
|
gas4.helium = ui->ostc3GasTable->item(3, 2)->text().toInt();
|
|
|
|
gas4.type = ui->ostc3GasTable->item(3, 3)->text().toInt();
|
|
|
|
gas4.depth = ui->ostc3GasTable->item(3, 4)->text().toInt();
|
|
|
|
|
|
|
|
gas5.oxygen = ui->ostc3GasTable->item(4, 1)->text().toInt();
|
|
|
|
gas5.helium = ui->ostc3GasTable->item(4, 2)->text().toInt();
|
|
|
|
gas5.type = ui->ostc3GasTable->item(4, 3)->text().toInt();
|
|
|
|
gas5.depth = ui->ostc3GasTable->item(4, 4)->text().toInt();
|
|
|
|
|
|
|
|
deviceDetails->setGas1(gas1);
|
|
|
|
deviceDetails->setGas2(gas2);
|
|
|
|
deviceDetails->setGas3(gas3);
|
|
|
|
deviceDetails->setGas4(gas4);
|
|
|
|
deviceDetails->setGas5(gas5);
|
2014-06-21 06:53:05 +00:00
|
|
|
|
|
|
|
//set dil values
|
|
|
|
gas dil1;
|
|
|
|
gas dil2;
|
|
|
|
gas dil3;
|
|
|
|
gas dil4;
|
|
|
|
gas dil5;
|
|
|
|
|
|
|
|
dil1.oxygen = ui->ostc3DilTable->item(0, 1)->text().toInt();
|
|
|
|
dil1.helium = ui->ostc3DilTable->item(0, 2)->text().toInt();
|
|
|
|
dil1.type = ui->ostc3DilTable->item(0, 3)->text().toInt();
|
|
|
|
dil1.depth = ui->ostc3DilTable->item(0, 4)->text().toInt();
|
|
|
|
|
|
|
|
dil2.oxygen = ui->ostc3DilTable->item(1, 1)->text().toInt();
|
|
|
|
dil2.helium = ui->ostc3DilTable->item(1, 2)->text().toInt();
|
|
|
|
dil2.type = ui->ostc3DilTable->item(1, 3)->text().toInt();
|
|
|
|
dil2.depth = ui->ostc3DilTable->item(1, 4)->text().toInt();
|
|
|
|
|
|
|
|
dil3.oxygen = ui->ostc3DilTable->item(2, 1)->text().toInt();
|
|
|
|
dil3.helium = ui->ostc3DilTable->item(2, 2)->text().toInt();
|
|
|
|
dil3.type = ui->ostc3DilTable->item(2, 3)->text().toInt();
|
|
|
|
dil3.depth = ui->ostc3DilTable->item(2, 4)->text().toInt();
|
|
|
|
|
|
|
|
dil4.oxygen = ui->ostc3DilTable->item(3, 1)->text().toInt();
|
|
|
|
dil4.helium = ui->ostc3DilTable->item(3, 2)->text().toInt();
|
|
|
|
dil4.type = ui->ostc3DilTable->item(3, 3)->text().toInt();
|
|
|
|
dil4.depth = ui->ostc3DilTable->item(3, 4)->text().toInt();
|
|
|
|
|
|
|
|
dil5.oxygen = ui->ostc3DilTable->item(4, 1)->text().toInt();
|
|
|
|
dil5.helium = ui->ostc3DilTable->item(4, 2)->text().toInt();
|
|
|
|
dil5.type = ui->ostc3DilTable->item(4, 3)->text().toInt();
|
|
|
|
dil5.depth = ui->ostc3DilTable->item(4, 4)->text().toInt();
|
|
|
|
|
|
|
|
deviceDetails->setDil1(dil1);
|
|
|
|
deviceDetails->setDil2(dil2);
|
|
|
|
deviceDetails->setDil3(dil3);
|
|
|
|
deviceDetails->setDil4(dil4);
|
|
|
|
deviceDetails->setDil5(dil5);
|
2014-06-21 07:22:47 +00:00
|
|
|
|
|
|
|
//set set point details
|
|
|
|
setpoint sp1;
|
|
|
|
setpoint sp2;
|
|
|
|
setpoint sp3;
|
|
|
|
setpoint sp4;
|
|
|
|
setpoint sp5;
|
|
|
|
|
|
|
|
sp1.sp = ui->ostc3SetPointTable->item(0, 1)->text().toInt();
|
|
|
|
sp1.depth = ui->ostc3SetPointTable->item(0, 2)->text().toInt();
|
|
|
|
|
|
|
|
sp2.sp = ui->ostc3SetPointTable->item(1, 1)->text().toInt();
|
|
|
|
sp2.depth = ui->ostc3SetPointTable->item(1, 2)->text().toInt();
|
|
|
|
|
|
|
|
sp3.sp = ui->ostc3SetPointTable->item(2, 1)->text().toInt();
|
|
|
|
sp3.depth = ui->ostc3SetPointTable->item(2, 2)->text().toInt();
|
|
|
|
|
|
|
|
sp4.sp = ui->ostc3SetPointTable->item(3, 1)->text().toInt();
|
|
|
|
sp4.depth = ui->ostc3SetPointTable->item(3, 2)->text().toInt();
|
|
|
|
|
|
|
|
sp5.sp = ui->ostc3SetPointTable->item(4, 1)->text().toInt();
|
|
|
|
sp5.depth = ui->ostc3SetPointTable->item(4, 2)->text().toInt();
|
2014-06-10 16:19:28 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 06:56:27 +00:00
|
|
|
void ConfigureDiveComputerDialog::readSettings()
|
|
|
|
{
|
|
|
|
ui->statusLabel->clear();
|
|
|
|
ui->errorLabel->clear();
|
|
|
|
|
|
|
|
getDeviceData();
|
2014-06-10 15:25:25 +00:00
|
|
|
config->readSettings(&device_data);
|
2014-05-30 06:56:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::configMessage(QString msg)
|
|
|
|
{
|
|
|
|
ui->statusLabel->setText(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::configError(QString err)
|
|
|
|
{
|
2014-07-31 15:43:52 +00:00
|
|
|
ui->statusLabel->setText("");
|
2014-05-30 06:56:27 +00:00
|
|
|
ui->errorLabel->setText(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::getDeviceData()
|
|
|
|
{
|
|
|
|
device_data.devname = strdup(ui->device->currentText().toUtf8().data());
|
2014-06-11 08:47:25 +00:00
|
|
|
device_data.vendor = strdup(selected_vendor.toUtf8().data());
|
|
|
|
device_data.product = strdup(selected_product.toUtf8().data());
|
2014-05-30 06:56:27 +00:00
|
|
|
|
2014-06-11 08:47:25 +00:00
|
|
|
device_data.descriptor = descriptorLookup[selected_vendor + selected_product];
|
2014-05-30 06:56:27 +00:00
|
|
|
device_data.deviceid = device_data.diveid = 0;
|
|
|
|
|
|
|
|
set_default_dive_computer_device(device_data.devname);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::on_cancel_clicked()
|
|
|
|
{
|
|
|
|
this->close();
|
|
|
|
}
|
2014-05-30 07:49:58 +00:00
|
|
|
|
2014-06-10 12:03:26 +00:00
|
|
|
void ConfigureDiveComputerDialog::deviceReadFinished()
|
2014-05-30 07:49:58 +00:00
|
|
|
{
|
2014-06-20 04:51:32 +00:00
|
|
|
ui->statusLabel->setText(tr("Dive computer details read successfully."));
|
2014-05-30 07:49:58 +00:00
|
|
|
}
|
|
|
|
|
2014-06-10 12:03:26 +00:00
|
|
|
void ConfigureDiveComputerDialog::on_saveSettingsPushButton_clicked()
|
2014-05-30 07:49:58 +00:00
|
|
|
{
|
2014-06-10 16:19:28 +00:00
|
|
|
populateDeviceDetails();
|
2014-06-10 15:25:25 +00:00
|
|
|
getDeviceData();
|
|
|
|
config->saveDeviceDetails(deviceDetails, &device_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::deviceDetailsReceived(DeviceDetails *newDeviceDetails)
|
|
|
|
{
|
|
|
|
deviceDetails = newDeviceDetails;
|
|
|
|
reloadValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::reloadValues()
|
|
|
|
{
|
|
|
|
ui->serialNoLineEdit->setText(deviceDetails->serialNo());
|
|
|
|
ui->firmwareVersionLineEdit->setText(deviceDetails->firmwareVersion());
|
|
|
|
ui->customTextLlineEdit->setText(deviceDetails->customText());
|
2014-06-13 14:10:10 +00:00
|
|
|
ui->diveModeComboBox->setCurrentIndex(deviceDetails->diveMode());
|
|
|
|
ui->saturationSpinBox->setValue(deviceDetails->saturation());
|
2014-06-20 04:51:32 +00:00
|
|
|
ui->desaturationSpinBox->setValue(deviceDetails->desaturation());
|
2014-06-11 08:09:01 +00:00
|
|
|
ui->lastDecoSpinBox->setValue(deviceDetails->lastDeco());
|
2014-06-10 15:25:25 +00:00
|
|
|
ui->brightnessComboBox->setCurrentIndex(deviceDetails->brightness());
|
2014-06-11 08:09:01 +00:00
|
|
|
ui->unitsComboBox->setCurrentIndex(deviceDetails->units());
|
|
|
|
ui->samplingRateComboBox->setCurrentIndex(deviceDetails->samplingRate());
|
|
|
|
ui->salinitySpinBox->setValue(deviceDetails->salinity());
|
|
|
|
ui->diveModeColour->setCurrentIndex(deviceDetails->diveModeColor());
|
2014-06-10 15:25:25 +00:00
|
|
|
ui->languageComboBox->setCurrentIndex(deviceDetails->language());
|
|
|
|
ui->dateFormatComboBox->setCurrentIndex(deviceDetails->dateFormat());
|
2014-06-11 08:09:01 +00:00
|
|
|
ui->compassGainComboBox->setCurrentIndex(deviceDetails->compassGain());
|
2014-06-20 04:51:32 +00:00
|
|
|
|
|
|
|
//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)));
|
2014-06-21 05:46:57 +00:00
|
|
|
|
|
|
|
//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)));
|
|
|
|
|
|
|
|
//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)));
|
|
|
|
|
|
|
|
//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)));
|
|
|
|
|
|
|
|
//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)));
|
2014-06-21 06:53:05 +00:00
|
|
|
|
|
|
|
//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)));
|
|
|
|
|
|
|
|
//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)));
|
|
|
|
|
|
|
|
//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)));
|
|
|
|
|
|
|
|
//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)));
|
|
|
|
|
|
|
|
//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)));
|
2014-06-21 07:22:47 +00:00
|
|
|
|
|
|
|
//load set point 1 values
|
|
|
|
ui->ostc3SetPointTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->sp1().sp)));
|
|
|
|
ui->ostc3SetPointTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->sp1().depth)));
|
|
|
|
|
|
|
|
//load set point 2 values
|
|
|
|
ui->ostc3SetPointTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->sp2().sp)));
|
|
|
|
ui->ostc3SetPointTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->sp2().depth)));
|
|
|
|
|
|
|
|
//load set point 3 values
|
|
|
|
ui->ostc3SetPointTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->sp3().sp)));
|
|
|
|
ui->ostc3SetPointTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->sp3().depth)));
|
|
|
|
|
|
|
|
//load set point 4 values
|
|
|
|
ui->ostc3SetPointTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->sp4().sp)));
|
|
|
|
ui->ostc3SetPointTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->sp4().depth)));
|
|
|
|
|
|
|
|
//load set point 5 values
|
|
|
|
ui->ostc3SetPointTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->sp5().sp)));
|
|
|
|
ui->ostc3SetPointTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->sp5().depth)));
|
2014-05-30 07:49:58 +00:00
|
|
|
}
|
2014-06-07 18:56:44 +00:00
|
|
|
|
2014-06-10 16:19:28 +00:00
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::on_backupButton_clicked()
|
|
|
|
{
|
|
|
|
QString filename = existing_filename ?: prefs.default_filename;
|
|
|
|
QFileInfo fi(filename);
|
|
|
|
filename = fi.absolutePath().append(QDir::separator()).append("Backup.xml");
|
|
|
|
QString backupPath = QFileDialog::getSaveFileName(this, tr("Backup Dive Computer Settings"),
|
2014-06-11 08:47:25 +00:00
|
|
|
filename, tr("Backup files (*.xml)")
|
|
|
|
);
|
2014-06-10 16:19:28 +00:00
|
|
|
if (!backupPath.isEmpty()) {
|
|
|
|
populateDeviceDetails();
|
|
|
|
getDeviceData();
|
2014-07-31 15:51:38 +00:00
|
|
|
if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data)) {
|
2014-06-10 16:19:28 +00:00
|
|
|
QMessageBox::critical(this, tr("XML Backup Error"),
|
2014-06-11 06:37:27 +00:00
|
|
|
tr("An error occurred while saving the backup file.\n%1")
|
2014-07-31 15:51:38 +00:00
|
|
|
.arg(config->lastError)
|
2014-06-10 16:19:28 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
QMessageBox::information(this, tr("Backup succeeded"),
|
|
|
|
tr("Your settings have been saved to: %1")
|
2014-08-21 16:26:18 +00:00
|
|
|
.arg(backupPath)
|
2014-06-10 16:19:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-11 06:37:27 +00:00
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked()
|
|
|
|
{
|
|
|
|
QString filename = existing_filename ?: prefs.default_filename;
|
|
|
|
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)")
|
|
|
|
);
|
|
|
|
if (!restorePath.isEmpty()) {
|
2014-07-31 15:51:38 +00:00
|
|
|
if (!config->restoreXMLBackup(restorePath, deviceDetails)) {
|
2014-06-11 06:37:27 +00:00
|
|
|
QMessageBox::critical(this, tr("XML Restore Error"),
|
|
|
|
tr("An error occurred while restoring the backup file.\n%1")
|
2014-07-31 15:51:38 +00:00
|
|
|
.arg(config->lastError)
|
2014-06-11 06:37:27 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
reloadValues();
|
|
|
|
//getDeviceData();
|
|
|
|
//config->saveDeviceDetails(deviceDetails, &device_data);
|
|
|
|
QMessageBox::information(this, tr("Restore succeeded"),
|
|
|
|
tr("Your settings have been restored successfully.")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-11 08:47:25 +00:00
|
|
|
|
2014-06-23 15:16:27 +00:00
|
|
|
void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked()
|
|
|
|
{
|
|
|
|
QString filename = existing_filename ?: prefs.default_filename;
|
|
|
|
QFileInfo fi(filename);
|
|
|
|
filename = fi.absolutePath();
|
|
|
|
QString firmwarePath = QFileDialog::getOpenFileName(this, tr("Select firmware file"),
|
|
|
|
filename, tr("All files (*.*)")
|
|
|
|
);
|
|
|
|
if (!firmwarePath.isEmpty()) {
|
|
|
|
getDeviceData();
|
2014-07-31 15:51:38 +00:00
|
|
|
config->startFirmwareUpdate(firmwarePath, &device_data);
|
2014-06-23 15:16:27 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-16 09:04:54 +00:00
|
|
|
|
|
|
|
void ConfigureDiveComputerDialog::on_DiveComputerList_currentRowChanged(int currentRow)
|
|
|
|
{
|
|
|
|
switch (currentRow) {
|
|
|
|
case 0:
|
|
|
|
selected_vendor = "Heinrichs Weikamp";
|
|
|
|
selected_product = "OSTC 3";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dcType = DC_TYPE_SERIAL;
|
|
|
|
|
|
|
|
|
|
|
|
if (selected_vendor == QString("Uemis"))
|
|
|
|
dcType = DC_TYPE_UEMIS;
|
|
|
|
fill_device_list(dcType);
|
|
|
|
}
|