Rearrange UI so messages are per-vehicle.

This commit is contained in:
2020-07-21 18:01:19 -04:00
parent 1dfc6e2f8e
commit 14662f5486

View File

@@ -71,89 +71,77 @@ Kirigami.ApplicationWindow {
} }
} }
} }
Layouts.ColumnLayout { Kirigami.CardsListView {
anchors.fill: parent anchors.fill: parent
Kirigami.InlineMessage { //TODO:connect to code to detect car alerts. id: vehicleView
Layouts.Layout.fillWidth: true model: vehicleModel
Layouts.Layout.leftMargin: 10 delegate: Kirigami.Card {
Layouts.Layout.rightMargin: 10 id: card
z: 9997 banner {
type: Kirigami.MessageType.Information title: name
id: infoMessage
showCloseButton: true
}
Kirigami.CardsListView {
anchors.fill: parent
id: vehicleView
model: vehicleModel
delegate: Kirigami.Card {
id: card
banner {
title: name
}
header: Row{
topPadding: 10.0
rightPadding: 10.0
leftPadding: 10.0
layoutDirection: Qt.RightToLeft
spacing: 5
Controls.Label {
text: vin
visible: root.wideScreen && mainPage.width > 550
anchors.verticalCenter: parent.verticalCenter
}
Image {
id: vinIcon
source: "qrc:/license.svg"
sourceSize.width: 32
sourceSize.height: 32
anchors.verticalCenter: parent.verticalCenter
MouseArea {
id: vinMouse
hoverEnabled: true
anchors.fill: vinIcon
}
Controls.ToolTip {
id: vinTip
text: vin
visible: vinMouse.containsMouse
}
}
}
contentItem: Item{
implicitHeight: Kirigami.Units.gridUnit * 4
Layouts.ColumnLayout {
Kirigami.Heading {
text: maker + " " + vmodel
level: 2
}
Kirigami.Heading {
text: year
level: 4
}
}
}
actions: [
Kirigami.Action {
text: qsTr("Examine Logs")
iconName: "edit-find"
onTriggered: {
router.navigateToRoute(["main", {"route": "servicerecords", "data": {"id": id, "name": name}}]);
}
}
]
hiddenActions: [
Kirigami.Action {
text: qsTr("Delete")
iconName: "edit-delete"
onTriggered: {
vehicleModel.removeVehicle(index);
}
}
]
} }
Controls.ScrollBar.vertical: Controls.ScrollBar {} header: Row{
} topPadding: 10.0
rightPadding: 10.0
leftPadding: 10.0
layoutDirection: Qt.RightToLeft
spacing: 5
Controls.Label {
text: vin
visible: root.wideScreen && mainPage.width > 550
anchors.verticalCenter: parent.verticalCenter
}
Image {
id: vinIcon
source: "qrc:/license.svg"
sourceSize.width: 32
sourceSize.height: 32
anchors.verticalCenter: parent.verticalCenter
MouseArea {
id: vinMouse
hoverEnabled: true
anchors.fill: vinIcon
}
Controls.ToolTip {
id: vinTip
text: vin
visible: vinMouse.containsMouse
}
}
}
contentItem: Item{
implicitHeight: Kirigami.Units.gridUnit * 4
Layouts.ColumnLayout {
Kirigami.Heading {
text: maker + " " + vmodel
level: 2
}
Kirigami.Heading {
text: year
level: 4
}
}
}
actions: [
Kirigami.Action {
text: qsTr("Examine Logs")
iconName: "edit-find"
onTriggered: {
router.navigateToRoute(["main", {"route": "servicerecords", "data": {"id": id, "name": name}}]);
}
}
]
hiddenActions: [
Kirigami.Action {
text: qsTr("Delete")
iconName: "edit-delete"
onTriggered: {
vehicleModel.removeVehicle(index);
}
}
]
}
Controls.ScrollBar.vertical: Controls.ScrollBar {}
} }
} }
} }
@@ -284,46 +272,61 @@ Kirigami.ApplicationWindow {
router.pushRoute({"route": "addrecord", "data": serviceId}); router.pushRoute({"route": "addrecord", "data": serviceId});
} }
} }
ListView { Layouts.ColumnLayout {
id: serviceView anchors.fill: parent
model: recordModel Kirigami.InlineMessage {
delegate: Kirigami.SwipeListItem { Layouts.Layout.fillWidth: true
contentItem: Layouts.ColumnLayout { Layouts.Layout.leftMargin: 10
Kirigami.Heading { Layouts.Layout.rightMargin: 10
text: serviceprovider z: 9997
level: 2 type: Kirigami.MessageType.Information
} id: oilMessage
Kirigami.Heading { showCloseButton: false
text: servicetypename Component.onCompleted: {
level: 2 //TODO: check if oil change is needed.
} }
Controls.Label { }
text: new Date(servicedate).toLocaleDateString(Qt.locale()) ListView {
} id: serviceView
Row { model: recordModel
Image { delegate: Kirigami.SwipeListItem {
source: "qrc:/speed.svg" contentItem: Layouts.ColumnLayout {
sourceSize.width: 16 Kirigami.Heading {
sourceSize.height: 16 text: serviceprovider
level: 2
}
Kirigami.Heading {
text: servicetypename
level: 2
} }
Controls.Label { Controls.Label {
text: miles text: new Date(servicedate).toLocaleDateString(Qt.locale())
}
Row {
Image {
source: "qrc:/speed.svg"
sourceSize.width: 16
sourceSize.height: 16
}
Controls.Label {
text: miles
}
}
Controls.Label {
text: notes
} }
} }
Controls.Label { actions: [
text: notes Kirigami.Action {
} text: qsTr("Remove")
iconName: "edit-delete"
onTriggered: {
recordModel.removeRecord(index);
}
}
]
} }
actions: [ }
Kirigami.Action {
text: qsTr("Remove")
iconName: "edit-delete"
onTriggered: {
recordModel.removeRecord(index);
}
}
]
}
} }
} }
} }
@@ -431,6 +434,7 @@ Kirigami.ApplicationWindow {
} }
if(milesField.acceptableInput) { if(milesField.acceptableInput) {
recordModel.addNewRecord(providerField.text, typeField.currentValue, typeText, dateObj.toISOString(), parseInt(milesField.text), notesField.text); recordModel.addNewRecord(providerField.text, typeField.currentValue, typeText, dateObj.toISOString(), parseInt(milesField.text), notesField.text);
//TODO: check if emit signal to car warnings.
router.popRoute(); router.popRoute();
} else { } else {
formError.text = qsTr("Invalid number of miles."); formError.text = qsTr("Invalid number of miles.");