QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PreVehicleCheckList.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQml.Models
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.Controls
8import QGroundControl.FlyView
9
10/// Shows the pre-vehicle checks. Unlike PreFlightCheckList it is not tied to a vehicle, so its progress survives
11/// vehicle connect and disconnect.
12ColumnLayout {
13 objectName: "preVehicleCheckList"
14 spacing: 0.8 * ScreenTools.defaultFontPixelWidth
15
16 property Item _firstHeader: null ///< SectionHeader of the first group
17 readonly property real _headerLineGap: 2
18
19 readonly property var _model: modelContainer.item ? modelContainer.item.model : null
20 readonly property bool hasGroups: !!_model && _model.count > 0
21 property bool allChecksPassed: !hasGroups
22
23 Loader {
24 id: modelContainer
25 source: "qrc:/qml/QGroundControl/FlyView/PreVehicleChecks.qml"
26 }
27
28 function reset() {
29 if (checkListRepeater.model) {
30 checkListRepeater.model.reset()
31 }
32 }
33
34 function groupPassedChanged() {
35 const model = checkListRepeater.model
36 if (!model) {
37 return
38 }
39 model.updateGroupLocks()
40 allChecksPassed = model.isPassed()
41 }
42
43 // Zero-height row so the Reset button floats over the first group header's empty right side
44 Item {
45 Layout.fillWidth: true
46 Layout.preferredHeight: 0
47 Layout.bottomMargin: -parent.spacing
48 visible: hasGroups
49 z: 1
50
51 QGCButton {
52 objectName: "preVehicleCheckListResetButton"
53 small: true
54 anchors.right: parent.right
55 y: _firstHeader ? Math.max(0, _firstHeader.height - _firstHeader.bottomPadding - height - _headerLineGap) : 0
56 text: qsTr("Reset")
57 onClicked: reset()
58 }
59 }
60
61 Repeater {
62 id: checkListRepeater
63 model: _model
64
65 onItemAdded: (index, item) => {
66 if (index === 0 && item.headerItem) {
67 _firstHeader = item.headerItem
68 _firstHeader.showSpacer = false
69 _firstHeader.topPadding = 0
70 }
71 // Automatic checks can pass before the group gets a parent to notify, so count them now
72 groupPassedChanged()
73 }
74 }
75}