summaryrefslogtreecommitdiffstats
path: root/qt-ui/configuredivecomputerdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/configuredivecomputerdialog.cpp')
-rw-r--r--qt-ui/configuredivecomputerdialog.cpp48
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();
+}