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 spacing: 0
29
30 Repeater {
31 model: _indexedBatteryParamCount
32
33 Loader {
34 sourceComponent: batterySummaryComponent
35
36 property int batteryIndex: index + 1
37 property bool showBatteryIndex: _indexedBatteryParamCount > 1
38 }
39 }
40 }
41
42 Component {
43 id: batterySummaryComponent
44
45 ColumnLayout {
46 spacing: 0
47
48 property var _controller: controller
49 property int _batteryIndex: batteryIndex
50
51 BatteryParams {
52 id: battParams
53 controller: _controller
54 batteryIndex: _batteryIndex
55 }
56
57 VehicleSummaryRow {
58 labelText: showBatteryIndex ? qsTr("Battery %1 Source").arg(batteryIndex) : qsTr("Battery Source")
59 valueText: battParams.battSource.enumStringValue
60 }
61
62 VehicleSummaryRow {
63 labelText: showBatteryIndex ? qsTr("Battery %1 Full").arg(batteryIndex) : qsTr("Battery Full")
64 valueText: battParams.battHighVoltAvailable ? battParams.battHighVolt.valueString + " " + battParams.battHighVolt.units : _naString
65 }
66
67 VehicleSummaryRow {
68 labelText: showBatteryIndex ? qsTr("Battery %1 Empty").arg(batteryIndex) : qsTr("Battery Empty")
69 valueText: battParams.battLowVoltAvailable ? battParams.battLowVolt.valueString + " " + battParams.battLowVolt.units : _naString
70 }
71
72 VehicleSummaryRow {
73 labelText: showBatteryIndex ? qsTr("Battery %1 Number of Cells").arg(batteryIndex) : qsTr("Number of Cells")
74 valueText: battParams.battNumCellsAvailable ? battParams.battNumCells.valueString : _naString
75 }
76 }
77 }
78}