QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PowerComponentSummary.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.FactControls
7import QGroundControl.Controls
8
9Item {
10 implicitWidth: mainLayout.implicitWidth
11 implicitHeight: mainLayout.implicitHeight
12 width: parent.width // grows when Loader is wider than implicitWidth
13
14 property string _naString: qsTr("N/A")
15
16 FactPanelController { id: controller; }
17
18 property int _indexedBatteryParamCount: {
19 var batteryIndex = 1
20 while (controller.parameterExists(-1, "BAT" + batteryIndex + "_SOURCE")) {
21 batteryIndex++
22 }
23 return batteryIndex - 1
24 }
25
26 ColumnLayout {
27 id: mainLayout
28 width: parent.width
29 spacing: 0
30
31 Repeater {
32 model: _indexedBatteryParamCount
33
34 Loader {
35 Layout.fillWidth: true
36 sourceComponent: batterySummaryComponent
37
38 property int batteryIndex: index + 1
39 property bool showBatteryIndex: _indexedBatteryParamCount > 1
40 }
41 }
42 }
43
44 Component {
45 id: batterySummaryComponent
46
47 ColumnLayout {
48 width: parent.width
49 spacing: 0
50
51 property var _controller: controller
52 property int _batteryIndex: batteryIndex
53
54 BatteryParams {
55 id: battParams
56 controller: _controller
57 batteryIndex: _batteryIndex
58 }
59
60 VehicleSummaryRow {
61 labelText: showBatteryIndex ? qsTr("Battery %1 Source").arg(batteryIndex) : qsTr("Battery Source")
62 valueText: battParams.battSource.enumStringValue
63 }
64
65 VehicleSummaryRow {
66 labelText: showBatteryIndex ? qsTr("Battery %1 Full").arg(batteryIndex) : qsTr("Battery Full")
67 valueText: battParams.battHighVoltAvailable ? battParams.battHighVolt.valueString + " " + battParams.battHighVolt.units : _naString
68 }
69
70 VehicleSummaryRow {
71 labelText: showBatteryIndex ? qsTr("Battery %1 Empty").arg(batteryIndex) : qsTr("Battery Empty")
72 valueText: battParams.battLowVoltAvailable ? battParams.battLowVolt.valueString + " " + battParams.battLowVolt.units : _naString
73 }
74
75 VehicleSummaryRow {
76 labelText: showBatteryIndex ? qsTr("Battery %1 Number of Cells").arg(batteryIndex) : qsTr("Number of Cells")
77 valueText: battParams.battNumCellsAvailable ? battParams.battNumCells.valueString : _naString
78 }
79 }
80 }
81}