QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
OnboardLogPage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4import Qt.labs.qmlmodels
5
6import QGroundControl
7import QGroundControl.Controls
8
9AnalyzePage {
10 id: onboardLogPage
11 pageComponent: pageComponent
12 pageDescription: qsTr("Onboard Logs allows you to download binary log files from your vehicle. Click Refresh to get list of available logs.")
13
14 Component {
15 id: pageComponent
16
17 RowLayout {
18 width: availableWidth
19 height: availableHeight
20
21 Component.onCompleted: OnboardLogController.refresh()
22
23 QGCFlickable {
24 Layout.fillWidth: true
25 Layout.fillHeight: true
26 contentWidth: gridLayout.width
27 contentHeight: gridLayout.height
28
29 GridLayout {
30 id: gridLayout
31 rows: OnboardLogController.model.count + 1
32 columns: 5
33 flow: GridLayout.TopToBottom
34 columnSpacing: ScreenTools.defaultFontPixelWidth
35 rowSpacing: 0
36
37 Item { } // First column is for checkboxes, so add empty item to align headers with log entries
38
39 Repeater {
40 model: OnboardLogController.model
41
42 QGCCheckBox {
43 Binding on checkState {
44 value: object.selected ? Qt.Checked : Qt.Unchecked
45 }
46
47 onClicked: object.selected = checked
48 }
49 }
50
51 QGCLabel { text: qsTr("Id") }
52
53 Repeater {
54 model: OnboardLogController.model
55
56 QGCLabel { text: object.id }
57 }
58
59 QGCLabel { text: qsTr("Date") }
60
61 Repeater {
62 model: OnboardLogController.model
63
64 QGCLabel {
65 text: {
66 if (!object.received) {
67 return ""
68 }
69
70 if (object.time.getUTCFullYear() < 2010) {
71 return qsTr("Date Unknown")
72 }
73
74 return object.time.toLocaleString(undefined)
75 }
76 }
77 }
78
79 QGCLabel { text: qsTr("Size") }
80
81 Repeater {
82 model: OnboardLogController.model
83
84 QGCLabel { text: object.sizeStr }
85 }
86
87 QGCLabel { text: qsTr("Status") }
88
89 Repeater {
90 model: OnboardLogController.model
91
92 QGCLabel { text: object.status }
93 }
94 }
95 }
96
97 ColumnLayout {
98 spacing: ScreenTools.defaultFontPixelWidth
99 Layout.alignment: Qt.AlignTop
100 Layout.fillWidth: false
101
102 QGCButton {
103 Layout.fillWidth: true
104 enabled: !OnboardLogController.requestingList && !OnboardLogController.downloadingLogs
105 text: qsTr("Refresh")
106
107 onClicked: {
108 if (!QGroundControl.multiVehicleManager.activeVehicle || QGroundControl.multiVehicleManager.activeVehicle.isOfflineEditingVehicle) {
109 QGroundControl.showMessageDialog(onboardLogPage, qsTr("Onboard Log Refresh"), qsTr("You must be connected to a vehicle in order to download onboard logs."))
110 return
111 }
112
113 OnboardLogController.refresh()
114 }
115 }
116
117 QGCButton {
118 Layout.fillWidth: true
119 enabled: !OnboardLogController.requestingList && !OnboardLogController.downloadingLogs && (OnboardLogController.model.count > 0)
120 text: OnboardLogController.allLogsSelected ? qsTr("Deselect All") : qsTr("Select All")
121 onClicked: OnboardLogController.selectAll(!OnboardLogController.allLogsSelected)
122 }
123
124 QGCButton {
125 Layout.fillWidth: true
126 enabled: !OnboardLogController.requestingList && !OnboardLogController.downloadingLogs
127 text: qsTr("Download")
128
129 onClicked: {
130 var logsSelected = false
131 for (var i = 0; i < OnboardLogController.model.count; i++) {
132 if (OnboardLogController.model.get(i).selected) {
133 logsSelected = true
134 break
135 }
136 }
137
138 if (!logsSelected) {
139 QGroundControl.showMessageDialog(onboardLogPage, qsTr("Onboard Log"), qsTr("You must select at least one onboard log file to download."))
140 return
141 }
142
143 if (ScreenTools.isMobile) {
144 OnboardLogController.download()
145 return
146 }
147
148 fileDialog.title = qsTr("Select save directory")
149 fileDialog.folder = QGroundControl.settingsManager.appSettings.logSavePath
150 fileDialog.selectFolder = true
151 fileDialog.openForLoad()
152 }
153
154 QGCFileDialog {
155 id: fileDialog
156 onAcceptedForLoad: (file) => {
157 OnboardLogController.download(file)
158 close()
159 }
160 }
161 }
162
163 QGCButton {
164 Layout.fillWidth: true
165 enabled: !OnboardLogController.requestingList && !OnboardLogController.downloadingLogs && (OnboardLogController.model.count > 1)
166 text: OnboardLogController.sortAscending ? qsTr("Sort Descending") : qsTr("Sort Ascending")
167 onClicked: OnboardLogController.toggleSortByDate()
168 }
169
170 QGCButton {
171 Layout.fillWidth: true
172 enabled: !OnboardLogController.requestingList && !OnboardLogController.downloadingLogs && (OnboardLogController.model.count > 0)
173 text: qsTr("Erase All")
174 onClicked: QGroundControl.showMessageDialog(
175 onboardLogPage,
176 qsTr("Delete All Onboard Log Files"),
177 qsTr("All onboard log files will be erased permanently. Is this really what you want?"),
178 Dialog.Yes | Dialog.No,
179 function() { OnboardLogController.eraseAll() }
180 )
181 }
182
183 QGCButton {
184 Layout.fillWidth: true
185 text: qsTr("Cancel")
186 enabled: OnboardLogController.requestingList || OnboardLogController.downloadingLogs
187 onClicked: OnboardLogController.cancel()
188 }
189 }
190 }
191 }
192}