Mobile download from DC: improve selection logic

Improve the logic when auto selecting a DC for download.
Some USB cables only supply vendor information  but we can select the correct
model if we have downloaded from it before.
For BT/BLE our discovery process adds the device name to the address, so we need to keep that in mind when we try to match against what we seen before.
When we have a positive match for a DC we have seen before we deactivate the
corresponding button of our saved DCs.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
This commit is contained in:
Jocke 2018-09-30 17:43:59 +02:00 committed by Dirk Hohndel
parent 9b199602c6
commit c504c08097

View file

@ -179,6 +179,20 @@ Kirigami.Page {
else
manager.DC_bluetoothMode = false
manager.DC_devName = currentText
dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true
for (var i = 1; i < 5; i++) {
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))
}
}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")
}
}else if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.product" + i) === comboProduct.currentText && eval("PrefDiveComputer.product" + i) +" " + eval("PrefDiveComputer.device" + i).toUpperCase() === currentText){
eval("dc"+ i + ".enabled = false")
}
}
}
}
}
@ -380,9 +394,12 @@ Kirigami.Page {
onVisibleChanged: {
comboVendor.currentIndex = comboProduct.currentIndex = comboConnection.currentIndex = -1
if (visible && PrefDiveComputer.vendor !== "" ) {
rememberedDCsGrid.setDC(PrefDiveComputer.vendor1, PrefDiveComputer.product1, PrefDiveComputer.device1)
dc1.enabled = false
dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true
if (visible) {
comboVendor.currentIndex = manager.getDetectedVendorIndex()
comboProduct.currentIndex = manager.getDetectedProductIndex(comboVendor.currentText)
comboConnection.currentIndex = manager.getMatchingAddress(comboVendor.currentText, comboProduct.currentText)
}
}
}