diff options
author | Joseph W. Joshua <joejoshw@gmail.com> | 2014-05-30 09:56:27 +0300 |
---|---|---|
committer | Thiago Macieira <thiago@macieira.org> | 2014-08-09 12:01:54 -0300 |
commit | a7c9b25b053ee77a816e1555f1c00c3e4b996396 (patch) | |
tree | 463cade2b4ceffd63f2f9ca4bd00cb5b34e8b306 /qt-ui/configuredivecomputerdialog.cpp | |
parent | 791fbee260b3b0884963b8ff0e2e2968ef130792 (diff) | |
download | subsurface-a7c9b25b053ee77a816e1555f1c00c3e4b996396.tar.gz |
Read basic details from dive computer
Added classes for reading data from dive computer. This is
at the basic level and I will expand it as I go along.
Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com>
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Diffstat (limited to 'qt-ui/configuredivecomputerdialog.cpp')
-rw-r--r-- | qt-ui/configuredivecomputerdialog.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 0af50b755..53544575c 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -6,6 +6,7 @@ #include "../helpers.h" #include "../display.h" #include "../divelist.h" +#include "configuredivecomputer.h" struct product { const char *product; dc_descriptor_t *descriptor; @@ -28,11 +29,17 @@ struct mydescriptor { ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ConfigureDiveComputerDialog), + config(0), vendorModel(0), productModel(0) { ui->setupUi(this); + config = new ConfigureDiveComputer(this); + connect (config, SIGNAL(error(QString)), this, SLOT(configError(QString))); + connect (config, SIGNAL(message(QString)), this, SLOT(configMessage(QString))); + connect (config, SIGNAL(deviceSettings(QString)), ui->availableDetails, SLOT(setText(QString))); + fill_computer_list(); vendorModel = new QStringListModel(vendorList); @@ -46,6 +53,10 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : } if (default_dive_computer_device) ui->device->setEditText(default_dive_computer_device); + + memset(&device_data, 0, sizeof(device_data)); + + connect (ui->retrieveDetails, SIGNAL(clicked()), this, SLOT(readSettings())); } ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog() @@ -137,3 +148,40 @@ void ConfigureDiveComputerDialog::on_product_currentIndexChanged(const QString & ui->device->setEnabled(false); } } + +void ConfigureDiveComputerDialog::readSettings() +{ + ui->statusLabel->clear(); + ui->errorLabel->clear(); + + getDeviceData(); + config->readSettings(&device_data); +} + +void ConfigureDiveComputerDialog::configMessage(QString msg) +{ + ui->statusLabel->setText(msg); +} + +void ConfigureDiveComputerDialog::configError(QString err) +{ + ui->errorLabel->setText(err); +} + +void ConfigureDiveComputerDialog::getDeviceData() +{ + device_data.devname = strdup(ui->device->currentText().toUtf8().data()); + device_data.vendor = strdup(ui->vendor->currentText().toUtf8().data()); + device_data.product = strdup(ui->product->currentText().toUtf8().data()); + + device_data.descriptor = descriptorLookup[ui->vendor->currentText() + ui->product->currentText()]; + device_data.deviceid = device_data.diveid = 0; + + set_default_dive_computer(device_data.vendor, device_data.product); + set_default_dive_computer_device(device_data.devname); +} + +void ConfigureDiveComputerDialog::on_cancel_clicked() +{ + this->close(); +} |