Commit 58c298ac authored by DonLakeFlyer's avatar DonLakeFlyer

Much better ui

parent 9b7cfd25
...@@ -134,7 +134,7 @@ Column { ...@@ -134,7 +134,7 @@ Column {
QGCFlickable { QGCFlickable {
anchors.fill: parent anchors.fill: parent
contentHeight: _loader.y + _loader.height contentHeight: column.height
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
clip: true clip: true
...@@ -169,13 +169,26 @@ Column { ...@@ -169,13 +169,26 @@ Column {
} }
Loader { Loader {
id: _loader
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
sourceComponent: factGroupList sourceComponent: factGroupList
property var factGroup: _activeVehicle property var factGroup: _activeVehicle
property string factGroupName: "Vehicle" property string factGroupName: qsTr("Vehicle")
}
Repeater {
model: _activeVehicle.factGroupNames
Loader {
anchors.left: parent.left
anchors.right: parent.right
sourceComponent: factGroupList
property var factGroup: _activeVehicle.getFactGroup(modelData)
property string factGroupName: modelData
}
} }
} }
} }
...@@ -190,91 +203,92 @@ Column { ...@@ -190,91 +203,92 @@ Column {
// property string factGroupName // property string factGroupName
Column { Column {
id: _root
spacing: _margins spacing: _margins
QGCLabel { SectionHeader {
width: parent.width id: header
wrapMode: Text.WordWrap anchors.left: parent.left
text: factGroup ? factGroupName : qsTr("Vehicle must be connected to assign values.") anchors.right: parent.right
text: factGroupName.charAt(0).toUpperCase() + factGroupName.slice(1)
checked: false
} }
Repeater { Column {
model: factGroup ? factGroup.factNames : 0 spacing: _margins
visible: header.checked
Repeater {
model: factGroup ? factGroup.factNames : 0
RowLayout { RowLayout {
spacing: _margins spacing: _margins
property string propertyName: factGroupName + "." + modelData property string propertyName: factGroupName + "." + modelData
function removeFromList(list, value) { function removeFromList(list, value) {
var newList = [] var newList = []
for (var i=0; i<list.length; i++) { for (var i=0; i<list.length; i++) {
if (list[i] !== value) { if (list[i] !== value) {
newList.push(list[i]) newList.push(list[i])
}
} }
return newList
} }
return newList
}
function addToList(list, value) { function addToList(list, value) {
var found = false var found = false
for (var i=0; i<list.length; i++) { for (var i=0; i<list.length; i++) {
if (list[i] === value) { if (list[i] === value) {
found = true found = true
break break
}
} }
if (!found) {
list.push(value)
}
return list
} }
if (!found) {
list.push(value)
}
return list
}
function updateValues() { function updateValues() {
if (_addCheckBox.checked) { if (_addCheckBox.checked) {
if (_largeCheckBox.checked) { if (_largeCheckBox.checked) {
controller.largeValues = addToList(controller.largeValues, propertyName) controller.largeValues = addToList(controller.largeValues, propertyName)
controller.smallValues = removeFromList(controller.smallValues, propertyName) controller.smallValues = removeFromList(controller.smallValues, propertyName)
} else {
controller.smallValues = addToList(controller.smallValues, propertyName)
controller.largeValues = removeFromList(controller.largeValues, propertyName)
}
} else { } else {
controller.smallValues = addToList(controller.smallValues, propertyName)
controller.largeValues = removeFromList(controller.largeValues, propertyName) controller.largeValues = removeFromList(controller.largeValues, propertyName)
controller.smallValues = removeFromList(controller.smallValues, propertyName)
} }
} else {
controller.largeValues = removeFromList(controller.largeValues, propertyName)
controller.smallValues = removeFromList(controller.smallValues, propertyName)
} }
}
QGCCheckBox { QGCCheckBox {
id: _addCheckBox id: _addCheckBox
text: factGroup.getFact(modelData).shortDescription text: factGroup.getFact(modelData).shortDescription
checked: listContains(controller.smallValues, propertyName) || _largeCheckBox.checked checked: listContains(controller.smallValues, propertyName) || _largeCheckBox.checked
onClicked: updateValues() onClicked: updateValues()
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 20 Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 20
}
Component.onCompleted: {
if (checked) {
header.checked = true
}
}
}
QGCCheckBox { QGCCheckBox {
id: _largeCheckBox id: _largeCheckBox
text: qsTr("Large") text: qsTr("Large")
checked: listContains(controller.largeValues, propertyName) checked: listContains(controller.largeValues, propertyName)
enabled: _addCheckBox.checked enabled: _addCheckBox.checked
onClicked: updateValues() onClicked: updateValues()
}
} }
} }
} }
Item { height: 1; width: 1 }
Repeater {
model: factGroup ? factGroup.factGroupNames : 0
Loader {
sourceComponent: factGroupList
property var factGroup: _root ? _root.parent.factGroup.getFactGroup(modelData) : undefined
property string factGroupName: _root ? _root.parent.factGroupName + "." + modelData : ""
}
}
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment