summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp13
-rw-r--r--desktop-widgets/downloadfromdivecomputer.h1
2 files changed, 13 insertions, 1 deletions
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index c040575fc..561ff2998 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -121,6 +121,17 @@ void DownloadFromDCWidget::showRememberedDCs()
SETUPDC(4)
}
+int DownloadFromDCWidget::deviceIndex(QString deviceText)
+{
+ int rv = ui.device->findText(deviceText);
+ if (rv == -1) {
+ // we need to insert the device text into the model
+ ui.device->addItem(deviceText);
+ rv = ui.device->findText(deviceText);
+ }
+ return rv;
+}
+
// DC button slots
#define DCBUTTON(num) \
void DownloadFromDCWidget::DC##num##Clicked() \
@@ -128,7 +139,7 @@ void DownloadFromDCWidget::DC##num##Clicked() \
ui.vendor->setCurrentIndex(ui.vendor->findText(qPrefDiveComputer::vendor##num())); \
productModel.setStringList(productList[qPrefDiveComputer::vendor##num()]); \
ui.product->setCurrentIndex(ui.product->findText(qPrefDiveComputer::product##num())); \
- ui.device->setCurrentIndex(ui.device->findText(qPrefDiveComputer::device##num())); \
+ ui.device->setCurrentIndex(deviceIndex(qPrefDiveComputer::device##num())); \
if (QSysInfo::kernelType() == "darwin") { \
/* it makes no sense that this would be needed on macOS but not Linux */ \
QCoreApplication::processEvents(); \
diff --git a/desktop-widgets/downloadfromdivecomputer.h b/desktop-widgets/downloadfromdivecomputer.h
index da4f5d35a..bdaa3057a 100644
--- a/desktop-widgets/downloadfromdivecomputer.h
+++ b/desktop-widgets/downloadfromdivecomputer.h
@@ -54,6 +54,7 @@ slots:
void DC2Clicked();
void DC3Clicked();
void DC4Clicked();
+ int deviceIndex(QString deviceText);
#if defined(BT_SUPPORT)
void enableBluetoothMode(int state);