mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
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>
This commit is contained in:
parent
636b26ff4b
commit
9d74b4dc82
1 changed files with 51 additions and 8 deletions
|
@ -162,21 +162,47 @@ Kirigami.Page {
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
onCurrentTextChanged: {
|
onCurrentTextChanged: {
|
||||||
|
var curVendor
|
||||||
|
var curProduct
|
||||||
|
var curDevice
|
||||||
dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true
|
dc1.enabled = dc2.enabled = dc3.enabled = dc4.enabled = true
|
||||||
for (var i = 1; i < 5; i++) {
|
for (var i = 1; i < 5; i++) {
|
||||||
if (comboProduct.currentIndex === -1 && currentText === "FTDI"){
|
switch (i) {
|
||||||
if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.device" + i).toUpperCase() === currentText)
|
case 1:
|
||||||
rememberedDCsGrid.setDC(eval("PrefDiveComputer.vendor" + i), eval("PrefDiveComputer.product" + i), ("PrefDiveComputer.device" + i))
|
curVendor = PrefDiveComputer.vendor1
|
||||||
}else if (comboProduct.currentIndex !== -1 && currentText === "FTDI") {
|
curProduct = PrefDiveComputer.product1
|
||||||
if ( eval("PrefDiveComputer.vendor" + i) === comboVendor.currentText && eval("PrefDiveComputer.product" + i) === comboProduct.currentText && eval("PrefDiveComputer.device" + i).toUpperCase() === currentText) {
|
curDevice = PrefDiveComputer.device1
|
||||||
eval("dc"+ i + ".enabled = false")
|
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
|
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")
|
if (comboProduct.currentIndex === -1 && currentText === "FTDI"){
|
||||||
|
if ( curVendor === comboVendor.currentText && curDevice.toUpperCase() === currentText)
|
||||||
|
rememberedDCsGrid.setDC(curVendor, curProduct, curDevice)
|
||||||
|
}else if (comboProduct.currentIndex !== -1 && currentText === "FTDI") {
|
||||||
|
if ( curVendor === comboVendor.currentText && cyrProduct === comboProduct.currentText && curDevice.toUpperCase() === currentText) {
|
||||||
|
disableDC(i)
|
||||||
break
|
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 && curProduct +" " + curDevice === currentText) {
|
||||||
|
disableDC(i)
|
||||||
|
break
|
||||||
|
}else if ( curVendor === comboVendor.currentText && curProduct === comboProduct.currentText && curDevice === currentText) {
|
||||||
|
disableDC(i)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,6 +228,23 @@ Kirigami.Page {
|
||||||
comboProduct.currentIndex = comboProduct.find(product);
|
comboProduct.currentIndex = comboProduct.find(product);
|
||||||
comboConnection.currentIndex = manager.getConnectionIndex(device);
|
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 {
|
SsrfButton {
|
||||||
id: dc1
|
id: dc1
|
||||||
visible: PrefDiveComputer.vendor1 !== ""
|
visible: PrefDiveComputer.vendor1 !== ""
|
||||||
|
|
Loading…
Reference in a new issue