1
0
Fork 0
flightgear/src/GUI/qml/FlightPlan.qml

499 lines
16 KiB
QML
Raw Normal View History

2018-07-05 08:02:02 +00:00
import QtQuick 2.4
import FlightGear.Launcher 1.0
2018-07-18 10:32:47 +00:00
import FlightGear 1.0
2018-07-05 08:02:02 +00:00
import "."
Item {
id: root
// same name as Summary page
signal showSelectedLocation();
2018-07-05 08:02:02 +00:00
Flickable {
id: flick
height: parent.height
width: parent.width - scrollbar.width
flickableDirection: Flickable.VerticalFlick
contentHeight: contents.childrenRect.height + Style.margin * 2
Component.onCompleted: {
if (_launcher.flightPlan.cruiseSpeed.value === 0.0) {
_launcher.flightPlan.cruiseSpeed = _launcher.selectedAircraftInfo.cruiseSpeed
}
if (_launcher.flightPlan.cruiseAltitude.value === 0.0) {
_launcher.flightPlan.cruiseAltitude = _launcher.selectedAircraftInfo.cruiseAltitude
}
_launcher.flightPlan.aircraftType = _launcher.selectedAircraftInfo.icaoType
route.text = _launcher.flightPlan.icaoRoute
}
2018-07-05 08:02:02 +00:00
Column
{
id: contents
width: parent.width - (Style.margin * 2)
x: Style.margin
y: Style.margin
2018-07-05 08:02:02 +00:00
spacing: Style.margin
Row {
width: parent.width
spacing: Style.margin
height: loadButton.height
ToggleSwitch {
label: qsTr("Fly with a flight-plan")
checked: _launcher.flightPlan.enabled
function toggle(newChecked) {
_launcher.flightPlan.enabled = newChecked
}
anchors.verticalCenter: parent.verticalCenter
}
Button {
id: loadButton
text: qsTr("Load");
onClicked: {
var ok = _launcher.flightPlan.loadPlan();
if (ok) {
route.text = _launcher.flightPlan.icaoRoute;
// we don't use a binding here, manually synchronise
// these values
departureEntry.selectAirport(_launcher.flightPlan.departure.guid);
destinationICAO.selectAirport(_launcher.flightPlan.destination.guid);
}
}
}
Button {
text: qsTr("Save");
onClicked: _launcher.flightPlan.savePlan();
}
Button {
text: qsTr("Clear");
onClicked: {
_launcher.flightPlan.clearPlan();
route.text = "";
}
}
}
2018-07-05 08:02:02 +00:00
HeaderBox {
title: qsTr("Aircraft & flight information")
width: parent.width
}
// date of flight << omit for now
Row {
height: aircraftIdent.height
width: parent.width
spacing: Style.margin
StyledText {
text: qsTr("Callsign / Flight No.")
anchors.verticalCenter: parent.verticalCenter
}
LineEdit {
2018-07-05 08:02:02 +00:00
id: aircraftIdent
placeholder: "D-FGFS"
suggestedWidthString: "XXXXXX";
anchors.verticalCenter: parent.verticalCenter
text: _launcher.flightPlan.callsign
onTextChanged: {
_launcher.flightPlan.callsign = text
}
2018-07-05 08:02:02 +00:00
}
Item { width: Style.strutSize; height: 1 }
StyledText {
text: qsTr("Aircraft type:")
anchors.verticalCenter: parent.verticalCenter
}
LineEdit {
placeholder: "B738"
suggestedWidthString: "XXXX";
anchors.verticalCenter: parent.verticalCenter
text: _launcher.flightPlan.aircraftType
onTextChanged: {
_launcher.flightPlan.aircraftType = text
}
2018-07-05 08:02:02 +00:00
}
}
Row {
height: childrenRect.height
width: parent.width
spacing: Style.margin
PopupChoice {
id: flightRules
label: qsTr("Flight rules:")
model: ["VFR", "IFR"] // initially IFR (Y), initially VFR (Z)
Component.onCompleted: {
select(_launcher.flightPlan.flightRules);
}
onCurrentIndexChanged: {
_launcher.flightPlan.flightRules = currentIndex;
}
2018-07-05 08:02:02 +00:00
}
Item { width: Style.strutSize; height: 1 }
PopupChoice {
id: flightType
label: qsTr("Flight type:")
model: [qsTr("Scheduled"),
qsTr("Non-scheduled"),
qsTr("General aviation"),
qsTr("Military"),
qsTr("Other")]
Component.onCompleted: {
select(_launcher.flightPlan.flightType);
}
onCurrentIndexChanged: {
_launcher.flightPlan.flightType = currentIndex;
}
2018-07-05 08:02:02 +00:00
}
}
Row {
height: childrenRect.height
width: parent.width
spacing: Style.margin
PopupChoice {
id: wakeTurbulenceCategory
label: qsTr("Wake turbulence category:")
model: [qsTr("Light"),
qsTr("Medium"),
qsTr("Heavy"),
qsTr("Jumbo")]
}
// equipment
// - ideally prefill from acft
}
HeaderBox {
title: qsTr("Route")
width: parent.width
}
Row {
height: childrenRect.height
width: parent.width
spacing: Style.margin
AirportEntry {
id: departureEntry
2018-07-05 08:02:02 +00:00
label: qsTr("Departure airport:")
Component.onCompleted: {
selectAirport(_launcher.flightPlan.departure.guid)
}
onPickAirport: {
selectAirport(guid)
_launcher.flightPlan.departure = airport
}
onClickedName: {
detailLoader.airportGuid = airport.guid
detailLoader.sourceComponent = airportDetails;
}
KeyNavigation.tab: departureTime
2018-07-05 08:02:02 +00:00
}
// padding
Item { width: Style.strutSize; height: 1 }
TimeEdit {
id: departureTime
label: qsTr("Departure time:")
}
}
2018-07-05 08:02:02 +00:00
Row {
height: childrenRect.height
width: parent.width
spacing: Style.margin
ClickableText {
width: parent.width
text: qsTr("The flight-plan departure airport (%1) is different to the " +
"initial location (%2). Click here to set the initial location to " +
"the flight-plan's airport.").
arg(_launcher.flightPlan.departure.name).arg(_launcher.location.description)
visible: _launcher.flightPlan.departure.valid &&
(_launcher.flightPlan.departure.guid !== _location.base.guid)
onClicked: {
_location.setBaseLocation(_launcher.flightPlan.departure)
root.showSelectedLocation();
}
}
2018-07-05 08:02:02 +00:00
}
// cruising speed + level
Row {
height: childrenRect.height
width: parent.width
spacing: Style.margin
2018-07-18 10:32:47 +00:00
NumericalEdit {
2018-07-05 08:02:02 +00:00
label: qsTr("Cruise speed:")
2018-07-18 10:32:47 +00:00
unitsMode: Units.Speed
quantity: _launcher.flightPlan.cruiseSpeed
onCommit: {
_launcher.flightPlan.cruiseSpeed = newValue
}
KeyNavigation.tab: cruiseAltitude
2018-07-05 08:02:02 +00:00
}
// padding
Item { width: Style.strutSize; height: 1 }
2018-07-18 10:32:47 +00:00
NumericalEdit {
id: cruiseAltitude
2018-07-18 10:32:47 +00:00
label: qsTr("Cruise altitude:")
unitsMode: Units.AltitudeIncludingMeters
quantity: _launcher.flightPlan.cruiseAltitude
onCommit: _launcher.flightPlan.cruiseAltitude = newValue
2018-07-05 08:02:02 +00:00
}
}
StyledText {
width: parent.width
text: qsTr("Route")
}
PlainTextEditBox {
id: route
width: parent.width
enabled: _launcher.flightPlan.departure.valid && _launcher.flightPlan.destination.valid
2018-07-05 08:02:02 +00:00
onEditingFinished: {
var ok = _launcher.flightPlan.tryParseRoute(text);
}
}
Row {
height: generateRouteButton.height
width: parent.width
spacing: Style.margin
Button {
id: generateRouteButton
text: qsTr("Generate route")
enabled: route.enabled
onClicked: {
var ok = _launcher.flightPlan.tryGenerateRoute();
if (ok) {
route.text = _launcher.flightPlan.icaoRoute;
}
}
anchors.verticalCenter: parent.verticalCenter
}
PopupChoice {
id: routeNetwork
label: qsTr("Using")
model: [qsTr("High-level (Jet) airways"),
qsTr("Low-level (Victor) airways"),
qsTr("High- & low-level airways")]
anchors.verticalCenter: parent.verticalCenter
}
Button {
text: qsTr("View route")
onClicked: {
detailLoader.airportGuid = 0
detailLoader.sourceComponent = routeDetails;
}
anchors.verticalCenter: parent.verticalCenter
}
Button {
text: qsTr("Clear route")
onClicked: {
_launcher.flightPlan.clearRoute();
route.text = "";
}
anchors.verticalCenter: parent.verticalCenter
}
}
RouteLegsView
{
id: legsView
width: parent.width
onClickedLeg: {
detailLoader.airportGuid = 0
detailLoader.legIndex = index
detailLoader.sourceComponent = routeDetails;
}
2018-07-05 08:02:02 +00:00
}
Row {
height: childrenRect.height
width: parent.width
spacing: Style.margin
AirportEntry {
id: destinationICAO
label: qsTr("Destination airport:")
Component.onCompleted: {
selectAirport(_launcher.flightPlan.destination.guid)
}
onPickAirport: {
selectAirport(guid)
_launcher.flightPlan.destination = airport
}
onClickedName: {
detailLoader.airportGuid = airport.guid
detailLoader.sourceComponent = airportDetails;
}
2018-07-05 08:02:02 +00:00
}
Item { width: Style.strutSize; height: 1 }
TimeEdit {
id: enrouteEstimate
2018-07-18 10:32:47 +00:00
label: qsTr("Estimated enroute time:")
Component.onCompleted: {
setDurationMinutes(_launcher.flightPlan.estimatedDurationMinutes)
}
onValueChanged: {
_launcher.flightPlan.estimatedDurationMinutes = value.getHours() * 60 + value.getMinutes();
}
2018-07-05 08:02:02 +00:00
}
Item { width: Style.strutSize; height: 1 }
StyledText
{
text: qsTr("Total distance: %1").arg(_launcher.flightPlan.totalDistanceNm);
}
}
Row {
height: childrenRect.height
width: parent.width
spacing: Style.margin
2018-07-05 08:02:02 +00:00
AirportEntry {
id: alternate1
label: qsTr("Alternate airport:")
Component.onCompleted: {
selectAirport(_launcher.flightPlan.alternate.guid)
}
onPickAirport: {
selectAirport(guid)
_launcher.flightPlan.alternate = airport
}
onClickedName: {
detailLoader.airportGuid = airport.guid
detailLoader.sourceComponent = airportDetails;
}
}
2018-07-05 08:02:02 +00:00
}
HeaderBox {
title: qsTr("Additional information")
width: parent.width
}
StyledText {
width: parent.width
text: qsTr("Remarks")
}
PlainTextEditBox {
id: remarks
width: parent.width
text: _launcher.flightPlan.remarks
2018-07-05 08:02:02 +00:00
onEditingFinished: {
_launcher.flightPlan.remarks = text;
}
2018-07-05 08:02:02 +00:00
}
} // of main column
} // of flickable
Scrollbar {
id: scrollbar
anchors.right: parent.right
height: parent.height
flickable: flick
visible: flick.contentHeight > flick.height
}
Component {
id: airportDetails
PlanAirportView {
id: airportView
}
}
Component {
id: routeDetails
PlanRouteDetails {
id: routeView
}
}
Loader {
id: detailLoader
anchors.fill: parent
visible: sourceComponent != null
property var airportGuid
property int legIndex
onStatusChanged: {
if (status == Loader.Ready) {
if (item.hasOwnProperty("location")) {
item.location = airportGuid
}
if (item.hasOwnProperty("legIndex")) {
item.legIndex = legIndex
}
}
}
}
Button {
id: backButton
anchors { left: parent.left; top: parent.top; margins: Style.margin }
width: Style.strutSize
visible: detailLoader.visible
text: "< Back"
onClicked: {
detailLoader.sourceComponent = null
}
}
2018-07-05 08:02:02 +00:00
}