108 lines
4.1 KiB
QML
108 lines
4.1 KiB
QML
import QtQuick 2.6
|
|
import QtQuick.Controls 2.0 as Controls
|
|
import QtQuick.Layouts 1.2
|
|
import org.kde.kirigami 2.13 as Kirigami
|
|
|
|
// Base element, provides basic features needed for all kirigami applications
|
|
Kirigami.ApplicationWindow {
|
|
// ID provides unique identifier to reference this element
|
|
id: root
|
|
title: "Metar Weather"
|
|
|
|
// Initial page to be loaded on app load
|
|
pageStack.initialPage: Kirigami.Page {
|
|
actions {
|
|
main: Kirigami.Action {
|
|
icon.name: "refresh"
|
|
text: "Refresh"
|
|
onTriggered: logic.refresh()
|
|
}
|
|
right: Kirigami.Action {
|
|
icon.name: "plus"
|
|
text: "Add Airport"
|
|
onTriggered: addAirport.open()
|
|
}
|
|
}
|
|
Kirigami.CardsListView {
|
|
anchors.fill: parent
|
|
id: cardLayout
|
|
model: logic.metarList
|
|
delegate: metarListDelegate
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: metarListDelegate
|
|
Kirigami.AbstractCard {
|
|
contentItem: Item {
|
|
implicitWidth: delegateLayout.implicitWidth
|
|
implicitHeight: delegateLayout.implicitHeight
|
|
ColumnLayout {
|
|
id: delegateLayout
|
|
anchors {
|
|
left: parent.left
|
|
top: parent.top
|
|
right: parent.right
|
|
}
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Kirigami.Heading {
|
|
text: stationId
|
|
}
|
|
Kirigami.Heading {
|
|
text: flightCategory
|
|
|
|
// Dynamically set the color based on the flight category
|
|
Component.onCompleted: {
|
|
color = Qt.binding(function() {
|
|
if (flightCategory == "VFR") {
|
|
return "green";
|
|
} else if (flightCategory == "MVFR") {
|
|
return "blue";
|
|
} else if (flightCategory == "IFR") {
|
|
return "red";
|
|
} else if (flightCategory == "LIFR") {
|
|
return "fuchsia";
|
|
} else {
|
|
return "white";
|
|
}
|
|
});
|
|
}
|
|
}
|
|
Controls.Button {
|
|
Layout.alignment: Qt.AlignRight
|
|
icon.name: "edit-delete"
|
|
onClicked: logic.deleteAirport(stationId)
|
|
}
|
|
}
|
|
Controls.Label {
|
|
text: rawMetar
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.WordWrap
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Kirigami.OverlaySheet {
|
|
id: addAirport
|
|
|
|
Kirigami.FormLayout {
|
|
Controls.TextField {
|
|
id: airportCode
|
|
Kirigami.FormData.label: "airport code"
|
|
}
|
|
Controls.Button {
|
|
text: "Add"
|
|
onClicked: {
|
|
logic.addAirport(airportCode.text)
|
|
addAirport.close()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|