summaryrefslogtreecommitdiffstats
path: root/qt-ui/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Benjamin <nystire@gmail.com>2013-12-27 12:50:13 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-27 11:04:35 -0800
commit31854f50a46b0c0ff0914653eece10af24e91698 (patch)
tree8d18e2c065f0133616bce3e99e26aba04c99e3ab /qt-ui/downloadfromdivecomputer.cpp
parent55da333881673b40ef774e4d5ae5c0815fcb47fb (diff)
downloadsubsurface-31854f50a46b0c0ff0914653eece10af24e91698.tar.gz
Disable DC device node if it is not needed
This patch disables/enables the DC device node based on what type of transport the selected DC uses. The only time the device node field is used is if the selected DC uses a serial transport type. IrDA and USB type transports do not use the device node. Signed-off-by: Benjamin Fogel <nystire@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index 57415fac5..b7eb520c4 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -70,6 +70,7 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) :
if (default_dive_computer_product)
ui.product->setCurrentIndex(ui.product->findText(default_dive_computer_product));
}
+ connect(ui.product, SIGNAL(currentIndexChanged(int)), this, SLOT(on_product_currentIndexChanged()), Qt::UniqueConnection);
if (default_dive_computer_device)
ui.device->setEditText(default_dive_computer_device);
@@ -168,6 +169,22 @@ void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor)
//currentModel->deleteLater();
}
+void DownloadFromDCWidget::on_product_currentIndexChanged()
+{
+ // Set up the DC descriptor
+ dc_descriptor_t *descriptor = NULL;
+ descriptor = descriptorLookup[ui.vendor->currentText() + ui.product->currentText()];
+
+ // call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL
+ if (dc_descriptor_get_transport(descriptor) == DC_TRANSPORT_SERIAL) {
+ // if the dc_transport_t is DC_TRANSPORT_SERIAL, then enable the device node box.
+ ui.device->setEnabled(true);
+ } else {
+ // otherwise disable the device node box
+ ui.device->setEnabled(false);
+ }
+}
+
void DownloadFromDCWidget::fill_computer_list()
{
dc_iterator_t *iterator = NULL;