Debian Codegraph @

src/GUI/qml/FlightPlan.qml

raw
1 import QtQuick 2.4
2 import QtQuick.Controls 2.2
3 import FlightGear.Launcher 1.0
4 import FlightGear 1.0
5
6 Item {
7 id: root
8
9 // same name as Summary page
10 signal showSelectedLocation();
11
12 Flickable {
13 id: flick
14 height: parent.height
15 width: parent.width
16 flickableDirection: Flickable.VerticalFlick
17 contentHeight: contents.childrenRect.height + Style.margin * 2
18 ScrollBar.vertical: ScrollBar {}
19
20 Component.onCompleted: {
21 if (_launcher.flightPlan.cruiseSpeed.value === 0.0) {
22 _launcher.flightPlan.cruiseSpeed = _launcher.selectedAircraftInfo.cruiseSpeed
23 }
24
25 if (_launcher.flightPlan.cruiseAltitude.value === 0.0) {
26 _launcher.flightPlan.cruiseAltitude = _launcher.selectedAircraftInfo.cruiseAltitude
27 }
28
29 _launcher.flightPlan.aircraftType = _launcher.selectedAircraftInfo.icaoType
30 route.text = _launcher.flightPlan.icaoRoute
31 }
32
33 Column
34 {
35 id: contents
36 width: parent.width - (Style.margin * 2)
37 x: Style.margin
38 y: Style.margin
39 spacing: Style.margin
40
41 Row {
42 width: parent.width
43 spacing: Style.margin
44 height: loadButton.height
45
46 ToggleSwitch {
47 label: qsTr("Fly with a flight-plan")
48 checked: _launcher.flightPlan.enabled
49 function toggle(newChecked) {
50 _launcher.flightPlan.enabled = newChecked
51 }
52 anchors.verticalCenter: parent.verticalCenter
53 }
54
55 Button {
56 id: loadButton
57 text: qsTr("Load");
58 onClicked: {
59 var ok = _launcher.flightPlan.loadPlan();
60 if (ok) {
61 route.text = _launcher.flightPlan.icaoRoute;
62
63 // we don't use a binding here, manually synchronise
64 // these values
65 departureEntry.selectAirport(_launcher.flightPlan.departure.guid);
66 destinationICAO.selectAirport(_launcher.flightPlan.destination.guid);
67 }
68 }
69 }
70
71 Button {
72 text: qsTr("Save");
73 onClicked: _launcher.flightPlan.savePlan();
74 }
75
76 Button {
77 text: qsTr("Clear");
78 onClicked: {
79 _launcher.flightPlan.clearPlan();
80 route.text = "";
81 }
82 }
83 }
84
85 HeaderBox {
86 title: qsTr("Aircraft & flight information")
87 width: parent.width
88 }
89
90 // date of flight << omit for now
91
92 Row {
93 height: aircraftIdent.height
94 width: parent.width
95 spacing: Style.margin
96
97 StyledText {
98 text: qsTr("Callsign / Flight No.")
99 anchors.verticalCenter: parent.verticalCenter
100 }
101
102 LineEdit {
103 id: aircraftIdent
104 placeholder: "D-FGFS"
105 suggestedWidthString: "XXXXXX";
106 anchors.verticalCenter: parent.verticalCenter
107 text: _launcher.flightPlan.callsign
108
109 onTextChanged: {
110 _launcher.flightPlan.callsign = text
111 }
112 }
113
114 Item { width: Style.strutSize; height: 1 }
115
116 StyledText {
117 text: qsTr("Aircraft type:")
118 anchors.verticalCenter: parent.verticalCenter
119 }
120 LineEdit {
121 placeholder: "B738"
122 suggestedWidthString: "XXXX";
123 anchors.verticalCenter: parent.verticalCenter
124 text: _launcher.flightPlan.aircraftType
125
126 onTextChanged: {
127 _launcher.flightPlan.aircraftType = text
128 }
129 }
130 }
131
132 Row {
133 height: childrenRect.height
134 width: parent.width
135 spacing: Style.margin
136
137 PopupChoice {
138 id: flightRules
139 label: qsTr("Flight rules:")
140 model: StringListModel{
141 values: [qsTr("VFR"), qsTr("IFR")] // initially IFR (Y), initially VFR (Z)
142 }
143
144 Component.onCompleted: {
145 select(_launcher.flightPlan.flightRules);
146 }
147
148 onCurrentIndexChanged: {
149 _launcher.flightPlan.flightRules = currentIndex;
150 }
151 }
152
153 Item { width: Style.strutSize; height: 1 }
154
155 PopupChoice {
156 id: flightType
157 label: qsTr("Flight type:")
158 model: StringListModel{
159 values: [
160 qsTr("Scheduled"),
161 qsTr("Non-scheduled"),
162 qsTr("General aviation"),
163 qsTr("Military"),
164 qsTr("Other")]
165 }
166
167 Component.onCompleted: {
168 select(_launcher.flightPlan.flightType);
169 }
170
171 onCurrentIndexChanged: {
172 _launcher.flightPlan.flightType = currentIndex;
173 }
174 }
175 }
176
177 Row {
178 height: childrenRect.height
179 width: parent.width
180 spacing: Style.margin
181
182 PopupChoice {
183 id: wakeTurbulenceCategory
184 label: qsTr("Wake turbulence category:")
185 model: StringListModel{
186 values:[
187 qsTr("Light"),
188 qsTr("Medium"),
189 qsTr("Heavy"),
190 qsTr("Jumbo")]
191 }
192 }
193
194 // equipment
195 // - ideally prefill from acft
196 }
197
198 HeaderBox {
199 title: qsTr("Route")
200 width: parent.width
201 }
202
203 Row {
204 height: childrenRect.height
205 width: parent.width
206 spacing: Style.margin
207
208 AirportEntry {
209 id: departureEntry
210 label: qsTr("Departure airport:")
211
212 Component.onCompleted: {
213 selectAirport(_launcher.flightPlan.departure.guid)
214 }
215
216 onPickAirport: {
217 selectAirport(guid)
218 _launcher.flightPlan.departure = airport
219 }
220
221 onClickedName: {
222 detailLoader.airportGuid = airport.guid
223 detailLoader.sourceComponent = airportDetails;
224 }
225
226 KeyNavigation.tab: departureTime
227 }
228
229 // padding
230 Item { width: Style.strutSize; height: 1 }
231
232 TimeEdit {
233 id: departureTime
234 label: qsTr("Departure time:")
235 }
236 }
237
238 Row {
239 height: childrenRect.height
240 width: parent.width
241 spacing: Style.margin
242 visible: _launcher.flightPlan.departure.valid &&
243 (_launcher.flightPlan.departure.guid !== _location.base.guid)
244
245 ClickableText {
246 width: parent.width
247 color: Style.destructiveActionColor
248 text: qsTr("The flight-plan departure airport (%1) is different to the " +
249 "initial location (%2). Click here to set the initial location to " +
250 "the flight-plan's airport.").
251 arg(_launcher.flightPlan.departure.name).arg(_launcher.location.description)
252
253 onClicked: {
254 _location.setBaseLocation(_launcher.flightPlan.departure)
255 root.showSelectedLocation();
256 }
257 }
258 }
259
260 // cruising speed + level
261 Row {
262 height: childrenRect.height
263 width: parent.width
264 spacing: Style.margin
265
266 NumericalEdit {
267 label: qsTr("Cruise speed:")
268 unitsMode: Units.Speed
269 quantity: _launcher.flightPlan.cruiseSpeed
270 onCommit: {
271 _launcher.flightPlan.cruiseSpeed = newValue
272 }
273 KeyNavigation.tab: cruiseAltitude
274
275 }
276
277 // padding
278 Item { width: Style.strutSize; height: 1 }
279
280 NumericalEdit {
281 id: cruiseAltitude
282 label: qsTr("Cruise altitude:")
283 unitsMode: Units.AltitudeIncludingMeters
284 quantity: _launcher.flightPlan.cruiseAltitude
285 onCommit: _launcher.flightPlan.cruiseAltitude = newValue
286 }
287 }
288
289 StyledText {
290 width: parent.width
291 text: qsTr("Route")
292 }
293
294 PlainTextEditBox {
295 id: route
296 width: parent.width
297 enabled: _launcher.flightPlan.departure.valid && _launcher.flightPlan.destination.valid
298
299 onEditingFinished: {
300 var ok = _launcher.flightPlan.tryParseRoute(text);
301 }
302 }
303
304 Row {
305 height: generateRouteButton.height
306 width: parent.width
307 spacing: Style.margin
308
309 Button {
310 id: generateRouteButton
311 text: qsTr("Generate route")
312 enabled: route.enabled
313 onClicked: {
314 var ok = _launcher.flightPlan.tryGenerateRoute();
315 if (ok) {
316 route.text = _launcher.flightPlan.icaoRoute;
317 }
318 }
319 anchors.verticalCenter: parent.verticalCenter
320 }
321
322 PopupChoice {
323 id: routeNetwork
324 label: qsTr("Using")
325 model: StringListModel{
326 values:[
327 qsTr("High-level (Jet) airways"),
328 qsTr("Low-level (Victor) airways"),
329 qsTr("High- & low-level airways")]
330 }
331 anchors.verticalCenter: parent.verticalCenter
332 }
333
334 Button {
335 text: qsTr("View route")
336 enabled: _launcher.flightPlan.legs.numLegs > 0
337 onClicked: {
338 detailLoader.airportGuid = 0
339 detailLoader.sourceComponent = routeDetails;
340 }
341 anchors.verticalCenter: parent.verticalCenter
342 }
343
344 Button {
345 text: qsTr("Clear route")
346 onClicked: {
347 _launcher.flightPlan.clearRoute();
348 route.text = "";
349 }
350 anchors.verticalCenter: parent.verticalCenter
351 }
352 }
353
354 RouteLegsView
355 {
356 id: legsView
357 width: parent.width
358
359 onClickedLeg: {
360 detailLoader.airportGuid = 0
361 detailLoader.legIndex = index
362 detailLoader.sourceComponent = routeDetails;
363 }
364 }
365
366 Row {
367 height: childrenRect.height
368 width: parent.width
369 spacing: Style.margin
370
371 AirportEntry {
372 id: destinationICAO
373 label: qsTr("Destination airport:")
374
375 Component.onCompleted: {
376 selectAirport(_launcher.flightPlan.destination.guid)
377 }
378
379 onPickAirport: {
380 selectAirport(guid)
381 _launcher.flightPlan.destination = airport
382 }
383
384 onClickedName: {
385 detailLoader.airportGuid = airport.guid
386 detailLoader.sourceComponent = airportDetails;
387 }
388 }
389
390 Item { width: Style.strutSize; height: 1 }
391
392 TimeEdit {
393 id: enrouteEstimate
394 isDuration: true
395
396 label: qsTr("Estimated enroute time:")
397
398 Component.onCompleted: {
399 setDurationMinutes(_launcher.flightPlan.estimatedDurationMinutes)
400 }
401
402 onValueChanged: {
403 _launcher.flightPlan.estimatedDurationMinutes = value.getHours() * 60 + value.getMinutes();
404 }
405 }
406
407 Item { width: Style.strutSize; height: 1 }
408
409 StyledText
410 {
411 text: qsTr("Total distance: %1").arg(_launcher.flightPlan.totalDistanceNm);
412 }
413 }
414
415 Row {
416 height: childrenRect.height
417 width: parent.width
418 spacing: Style.margin
419
420 AirportEntry {
421 id: alternate1
422 label: qsTr("Alternate airport:")
423
424 Component.onCompleted: {
425 selectAirport(_launcher.flightPlan.alternate.guid)
426 }
427
428 onPickAirport: {
429 selectAirport(guid)
430 _launcher.flightPlan.alternate = airport
431 }
432
433 onClickedName: {
434 detailLoader.airportGuid = airport.guid
435 detailLoader.sourceComponent = airportDetails;
436 }
437 }
438 }
439
440 HeaderBox {
441 title: qsTr("Additional information")
442 width: parent.width
443 }
444
445 StyledText {
446 width: parent.width
447 text: qsTr("Remarks")
448 }
449
450 PlainTextEditBox {
451 id: remarks
452 width: parent.width
453 text: _launcher.flightPlan.remarks
454
455 onEditingFinished: {
456 _launcher.flightPlan.remarks = text;
457 }
458 }
459 } // of main column
460
461 } // of flickable
462
463 Component {
464 id: airportDetails
465 PlanAirportView {
466 id: airportView
467 }
468 }
469
470 Component {
471 id: routeDetails
472 PlanRouteDetails {
473 id: routeView
474 }
475 }
476
477 Loader {
478 id: detailLoader
479 anchors.fill: parent
480 visible: sourceComponent != null
481
482 property var airportGuid
483 property int legIndex
484
485 onStatusChanged: {
486 if (status == Loader.Ready) {
487 if (item.hasOwnProperty("location")) {
488 item.location = airportGuid
489 }
490
491 if (item.hasOwnProperty("legIndex")) {
492 item.legIndex = legIndex
493 }
494 }
495 }
496 }
497
498 BackButton {
499 id: backButton
500 anchors { left: parent.left; top: parent.top; margins: Style.margin }
501 visible: detailLoader.visible
502 onClicked: {
503 detailLoader.sourceComponent = null
504 }
505 }
506 }