summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml/DownloadFromDiveComputer.qml
diff options
context:
space:
mode:
authorGravatar jan Iversen <jan@casacondor.com>2019-12-22 18:43:47 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-24 03:52:40 +0900
commit9d74b4dc826054b11ef8d71bf1892c008f3e95c8 (patch)
tree7ce1335c676ef335f7ca42a9c14481b70ba7399a /mobile-widgets/qml/DownloadFromDiveComputer.qml
parent636b26ff4b40c25171c46bb4d62d7f1eab313323 (diff)
downloadsubsurface-9d74b4dc826054b11ef8d71bf1892c008f3e95c8.tar.gz
mobile-widgets/qml: remove use of eval()
eval() cannot be used in combination with the Qt5 qml compiler, replace eval() with switch statements. Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'mobile-widgets/qml/DownloadFromDiveComputer.qml')
-rw-r--r--mobile-widgets/qml/DownloadFromDiveComputer.qml59
1 files changed, 51 insertions, 8 deletions
diff --git a/mobile-widgets/qml/DownloadFromDiveComputer.qml b/mobile-widgets/qml/DownloadFromDiveComputer.qml
index 423746d33..d71f90c70 100644
--- a/mobile-widgets/qml/DownloadFromDiveComputer.qml
+++ b/mobile-widgets/qml/DownloadFromDiveComputer.qml
@@ -162,21 +162,47 @@ Kirigami.Page {
elide: Text.ElideRight
}
onCurrentTextChanged: {
+ var curVendor
+ var curProduct
+ var curDevice
dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true
for (var i = 1; i < 5; i++) {
+ switch (i) {
+ case 1:
+ curVendor = PrefDiveComputer.vendor1
+ curProduct = PrefDiveComputer.product1
+ curDevice = PrefDiveComputer.device1
+ break
+ case 2:
+ curVendor = PrefDiveComputer.vendor2
+ curProduct = PrefDiveComputer.product2
+ curDevice = PrefDiveComputer.device2
+ break
+ case 3:
+ curVendor = PrefDiveComputer.vendor3
+ curProduct = PrefDiveComputer.product3
+ curDevice = PrefDiveComputer.device3
+ break
+ case 4:
+ curVendor = PrefDiveComputer.vendor4
+ curProduct = PrefDiveComputer.product4
+ curDevice = PrefDiveComputer.device4
+ break
+ }
+
if (comboProduct.currentIndex === -1 && currentText === "FTDI"){
- if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.device" + i).toUpperCase() === currentText)
- rememberedDCsGrid.setDC(eval("PrefDiveComputer.vendor" + i), eval("PrefDiveComputer.product" + i), ("PrefDiveComputer.device" + i))
+ if ( curVendor === comboVendor.currentText && curDevice.toUpperCase() === currentText)
+ rememberedDCsGrid.setDC(curVendor, curProduct, curDevice)
}else if (comboProduct.currentIndex !== -1 && currentText === "FTDI") {
- if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.product" + i) === comboProduct.currentText && eval("PrefDiveComputer.device" + i).toUpperCase() === currentText) {
- eval("dc"+ i + ".enabled = false")
+ if ( curVendor === comboVendor.currentText && cyrProduct === comboProduct.currentText && curDevice.toUpperCase() === currentText) {
+ disableDC(i)
break
}
- }else if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.product" + i) === comboProduct.currentText && eval("PrefDiveComputer.product" + i) +" " + eval("PrefDiveComputer.device" + i) === currentText) {
- eval("dc"+ i + ".enabled = false")
+ }else if ( curVendor === comboVendor.currentText && curProduct === comboProduct.currentText && curProduct +" " + curDevice === currentText) {
+ disableDC(i)
break
- }else if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.product" + i) === comboProduct.currentText && eval("PrefDiveComputer.device" + i) === currentText) {
- eval("dc"+ i + ".enabled = false")
+ }else if ( curVendor === comboVendor.currentText && curProduct === comboProduct.currentText && curDevice === currentText) {
+ disableDC(i)
break
}
}
@@ -202,6 +228,23 @@ Kirigami.Page {
comboProduct.currentIndex = comboProduct.find(product);
comboConnection.currentIndex = manager.getConnectionIndex(device);
}
+ function disableDC(inx) {
+ switch (inx) {
+ case 1:
+ dc1.enabled = false
+ break;
+ case 2:
+ dc2.enabled = false
+ break;
+ case 3:
+ dc3.enabled = false
+ break;
+ case 4:
+ dc4.enabled = false
+ break;
+ }
+ }
+
SsrfButton {
id: dc1
visible: PrefDiveComputer.vendor1 !== ""