the Grid component used to display a dash selection was moved into its own widget. This allows us to define it once and reuse it as many times as we want (4x currently), reducing the code footprint by about 150 lines
the code used to select the qml to display based on the combobox selection was moved to its own function getDashByIndex() which is now called from the new widget, reducing the code footprint by another 150 lines
the dash_sel qml file was renamed to DashSelector so we can use it as a standalone widget in QML unit tests, like so:
import QtQuick 2.7
import QtTest 1.0
Item {
width: 800; height: 480
DashSelector {
id: dash_selector
anchors.centerIn: parent
}
TestCase {
name: "TestDashConfig"; when: windowShown
function test_mapping_function(){
verify(dash_selector.getDashByIndex(1) === "qrc:/Gauges/GPS.qml")
}
function test_dashselection() {
var settings = findChild(dash_selector, "settings1")
var number_of_dashes = settings.numberofdash
verify(number_of_dashes == -1, "No dash defined")
}
function test_adding_dash() {
var dash1 = findChild(dash_selector, "dash1")
compare(dash1.text, undefined)
// We should probably use the following call, but currently
// it depends on DashView which is defined outside of the QML file we are testing
// dash_selector.adremove()
}
}
A few changes are included in this PR:
getDashByIndex()
which is now called from the new widget, reducing the code footprint by another 150 linesdash_sel
qml file was renamed toDashSelector
so we can use it as a standalone widget in QML unit tests, like so:Item { width: 800; height: 480
}