forked from mavlink/qgroundcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataStationPage.qml
343 lines (320 loc) · 14.2 KB
/
DataStationPage.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import QGroundControl 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.ScreenTools 1.0
AnalyzePage {
id: dataStationPage
pageComponent: pageComponent
pageName: qsTr("Data Station Page")
pageDescription: qsTr("Use this page to manage data stations and select them for missions")
property real _margin: ScreenTools.defaultFontPixelWidth
property real _butttonWidth: ScreenTools.defaultFontPixelWidth * 10
QGCPalette { id: palette; colorGroupEnabled: enabled }
Component {
id: pageComponent
RowLayout {
width: availableWidth
height: availableHeight
Connections {
target: QGroundControl.dataStationManager//.dataStations
onTestPassed : testPassedDialog.open()
onTestFailed : testFailedDialog.open()
}
Dialog {
id: testPassedDialog
visible: false
standardButtons: StandardButton.Ok
onAccepted: testPassedDialog.close()
ColumnLayout {
id: columnTP
width: parent ? parent.width : 100
Label {
text: "Test Passed"
Layout.columnSpan: 2
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
}
}
Dialog {
id: testFailedDialog
visible: false
standardButtons: StandardButton.Ok
onAccepted: testFailedDialog.close()
ColumnLayout {
id: columnTF
width: parent ? parent.width : 100
Label {
text: "Test Failed"
Layout.columnSpan: 2
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
}
}
TableView {
id: tableView
anchors.top: parent.top
anchors.bottom: parent.bottom
model: QGroundControl.dataStationManager.dataStations
selectionMode: SelectionMode.SingleSelection
Layout.fillWidth: true
onActivated: QGroundControl.dataStationManager.toggleActive(tableView.currentRow)
TableViewColumn {
title: qsTr("ID")
width: ScreenTools.defaultFontPixelWidth * 6
horizontalAlignment: Text.AlignHCenter
delegate : Text {
horizontalAlignment: Text.AlignHCenter
text: {
var o = QGroundControl.dataStationManager.dataStations[styleData.row]
return o ? o.id : ""
}
}
}
TableViewColumn {
title: qsTr("Latitude")
width: ScreenTools.defaultFontPixelWidth * 18
horizontalAlignment: Text.AlignHCenter
delegate : Text {
text: QGroundControl.dataStationManager.dataStations[styleData.row].lat;
}
}
TableViewColumn {
title: qsTr("Longitude")
width: ScreenTools.defaultFontPixelWidth * 18
horizontalAlignment: Text.AlignHCenter
delegate : Text {
text: {
var o = QGroundControl.dataStationManager.dataStations[styleData.row]
return o ? o.lon : ""
}
}
}
TableViewColumn {
title: qsTr("Active")
width: ScreenTools.defaultFontPixelWidth * 6
horizontalAlignment: Text.AlignHCenter
delegate : Text {
horizontalAlignment: Text.AlignHCenter
text: {
return QGroundControl.dataStationManager.dataStations[styleData.row].active;
}
}
}
}
Column {
spacing: _margin
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
QGCButton {
enabled: tableView.currentRow>=0 && tableView.currentRow < QGroundControl.dataStationManager.dataStations.length
text: qsTr("Toggle")
width: _butttonWidth
onClicked: {
QGroundControl.dataStationManager.toggleActive(tableView.currentRow)
}
}
QGCButton {
enabled: true
text: qsTr("Deploy DS")
width: _butttonWidth
onClicked: {
deployDialog.open()
}
Dialog {
id: deployDialog
visible: false
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: QGroundControl.dataStationManager.deployDS(answerDep.text, testStatus.checked)
ColumnLayout {
id: columnDep
width: parent ? parent.width : 100
Label {
text: "Enter the ID of the Data Station to be deployed."
Layout.columnSpan: 2
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
Label {
text: "ID"
Layout.alignment: Qt.AlignBaseline | Qt.AlignLeft
}
TextField {
id: answerDep
}
CheckBox {
id: testStatus
text: "Is this a test?"
checked: false
}
}
}
}
}
QGCButton {
enabled: true
text: qsTr("Initialize DS")
width: _butttonWidth
onClicked: {
initDialog.open()
}
Dialog {
id: initDialog
visible: false
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {QGroundControl.dataStationManager.initializeDS(answerInit.text)}
ColumnLayout {
id: columnInit
width: parent ? parent.width : 100
Label {
text: "Enter the ID of the Data Station to be initialized."
Layout.columnSpan: 2
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
Label {
text: "ID"
Layout.alignment: Qt.AlignBaseline | Qt.AlignLeft
}
TextField {
id: answerInit
//onEditingFinished: initDialog.click(StandardButton.Ok)
}
}
}
}
}
QGCButton {
enabled: tableView.currentRow>=0
text: qsTr("Delete DS")
width: _butttonWidth
onClicked: {
deleteDialog.open()
}
Dialog {
id: deleteDialog
visible: false
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {QGroundControl.dataStationManager.deleteStation(tableView.currentRow)
deleteDialog.close()}
onRejected: deleteDialog.close()
ColumnLayout {
id: columnDel
width: parent ? parent.width : 100
Label {
text: "Are you sure you want to delete Data Station "+QGroundControl.dataStationManager.dataStations[tableView.currentRow].id+"?"
Layout.columnSpan: 2
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
}
}
}
QGCButton {
enabled: true
text: qsTr("Load File")
width: _butttonWidth
onClicked: {
loadDialog.open()
}
Dialog {
id: loadDialog
visible: false
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {QGroundControl.dataStationManager.loadFromFile("/QGroundControl/datastations.json")
loadDialog.close()}
onRejected: loadDialog.close()
ColumnLayout {
id: columnLoad
width: parent ? parent.width : 100
Label {
text: "Are you sure you want to load from file? This will delete any changes."
Layout.columnSpan: 2
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
}
}
}
QGCButton {
enabled: true
text: qsTr("Save File")
width: _butttonWidth
onClicked: {
saveDialog.open()
}
Dialog {
id: saveDialog
visible: false
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {QGroundControl.dataStationManager.saveToFile("/QGroundControl/datastations.json")
saveDialog.close()}
onRejected: saveDialog.close()
ColumnLayout {
id: columnSave
width: parent ? parent.width : 100
Label {
text: "Are you sure you want to save to file? This will overwrite the file."
Layout.columnSpan: 2
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
}
}
}
QGCButton {
enabled: true
text: qsTr("Turn On DS")
width: _butttonWidth
onClicked: {
turnOnDialog.open()
}
Dialog {
id: turnOnDialog
visible: false
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {QGroundControl.dataStationManager.turnOnDS(answerTurnOn.text)}
ColumnLayout {
id: columnTurnOn
width: parent ? parent.width : 100
Label {
text: "Enter the ID of the Data Station to be turned on."
Layout.columnSpan: 2
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
Label {
text: "ID"
Layout.alignment: Qt.AlignBaseline | Qt.AlignLeft
}
TextField {
id: answerTurnOn
//onEditingFinished: initDialog.click(StandardButton.Ok)
}
}
}
}
}
} // Column - Buttons
} // RowLayout
} // Component
} // AnalyzePage