Rearrange pages as separate qml files.
This commit is contained in:
138
src/contents/ui/AddRecord.qml
Normal file
138
src/contents/ui/AddRecord.qml
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
import QtQuick 2.14
|
||||||
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
import QtQuick.Controls 2.14 as Controls
|
||||||
|
import QtQuick.Layouts 1.14 as Layouts
|
||||||
|
import QtQuick.Controls 1.4 as Old
|
||||||
|
import QtQuick.Dialogs 1.3 as Dialogs
|
||||||
|
|
||||||
|
Kirigami.PageRoute {
|
||||||
|
name: "addrecord"
|
||||||
|
Component {
|
||||||
|
Kirigami.Page {
|
||||||
|
id: recordAddPage
|
||||||
|
title: qsTr("Add Service Record")
|
||||||
|
Layouts.ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
Kirigami.InlineMessage {
|
||||||
|
Layouts.Layout.fillWidth: true
|
||||||
|
Layouts.Layout.leftMargin: 10
|
||||||
|
Layouts.Layout.rightMargin: 10
|
||||||
|
z: 9997
|
||||||
|
type: Kirigami.MessageType.Error
|
||||||
|
showCloseButton: true
|
||||||
|
id: formError
|
||||||
|
}
|
||||||
|
Kirigami.FormLayout {
|
||||||
|
Layouts.Layout.alignment: Qt.AlignHCenter
|
||||||
|
Layouts.Layout.fillWidth: true
|
||||||
|
width: recordAddPage.width
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Kirigami.FormData.isSection: true
|
||||||
|
Kirigami.FormData.label: "Service Information"
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextField {
|
||||||
|
id: providerField
|
||||||
|
selectByMouse: true
|
||||||
|
Kirigami.FormData.label: qsTr("Service Provider")+":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.ComboBox {
|
||||||
|
id: typeField
|
||||||
|
model: serviceTypeModel
|
||||||
|
textRole: "text"
|
||||||
|
valueRole: "value"
|
||||||
|
onActivated: {
|
||||||
|
if(currentValue == -1) {
|
||||||
|
customTypeField.visible = true;
|
||||||
|
} else {
|
||||||
|
customTypeField.visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Kirigami.FormData.label: qsTr("Service Type")+":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextField {
|
||||||
|
id: customTypeField
|
||||||
|
visible: false
|
||||||
|
Kirigami.FormData.label: qsTr("Custom Service Type")+":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Layouts.RowLayout {
|
||||||
|
Kirigami.FormData.label: qsTr("Date")+":"
|
||||||
|
Controls.TextField {
|
||||||
|
id: dateField
|
||||||
|
text: new Date().toLocaleDateString(Qt.locale())
|
||||||
|
readOnly: true
|
||||||
|
}
|
||||||
|
Controls.Button {
|
||||||
|
icon.name: "office-calendar"
|
||||||
|
text: qsTr("Select Date")
|
||||||
|
display: Controls.AbstractButton.IconOnly
|
||||||
|
onClicked: {
|
||||||
|
calendarPopup.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextField {
|
||||||
|
id: milesField
|
||||||
|
selectByMouse: true
|
||||||
|
Kirigami.FormData.label: qsTr("Miles")+":"
|
||||||
|
inputMethodHints: Qt.ImhDigitsOnly
|
||||||
|
validator: IntValidator {
|
||||||
|
bottom: 0
|
||||||
|
top: 500000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextArea {
|
||||||
|
id: notesField
|
||||||
|
placeholderText: qsTr("Notes about service")
|
||||||
|
selectByMouse: true
|
||||||
|
Kirigami.FormData.label: qsTr("Notes")+":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Layouts.RowLayout {
|
||||||
|
|
||||||
|
Controls.Button {
|
||||||
|
text: qsTr("Add")
|
||||||
|
highlighted: true
|
||||||
|
onClicked: {
|
||||||
|
var dateObj = Date.fromLocaleDateString(Qt.locale(), dateField.text);
|
||||||
|
var typeText = typeField.currentText;
|
||||||
|
if(typeField.currentValue == -1) {
|
||||||
|
typeText = customTypeField.text;
|
||||||
|
}
|
||||||
|
if(milesField.acceptableInput) {
|
||||||
|
recordModel.addNewRecord(providerField.text, typeField.currentValue, typeText, dateObj.toISOString(), parseInt(milesField.text), notesField.text);
|
||||||
|
router.popRoute();
|
||||||
|
} else {
|
||||||
|
formError.text = qsTr("Invalid number of miles.");
|
||||||
|
formError.visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controls.Button {
|
||||||
|
text: qsTr("Cancel")
|
||||||
|
onClicked: {
|
||||||
|
router.popRoute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Kirigami.OverlaySheet {
|
||||||
|
id: calendarPopup
|
||||||
|
Old.Calendar {
|
||||||
|
selectedDate: Date.fromLocaleDateString(Qt.locale(), dateField.text)
|
||||||
|
onClicked: {
|
||||||
|
dateField.text = date.toLocaleDateString(Qt.locale());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
95
src/contents/ui/AddVehicle.qml
Normal file
95
src/contents/ui/AddVehicle.qml
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import QtQuick 2.14
|
||||||
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
import QtQuick.Controls 2.14 as Controls
|
||||||
|
import QtQuick.Layouts 1.14 as Layouts
|
||||||
|
|
||||||
|
Kirigami.PageRoute {
|
||||||
|
name: "addvehicle"
|
||||||
|
Component {
|
||||||
|
Kirigami.Page {
|
||||||
|
id: vehicleAddPage
|
||||||
|
title: qsTr("Add Vehicle")
|
||||||
|
Layouts.ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
Kirigami.InlineMessage {
|
||||||
|
Layouts.Layout.fillWidth: true
|
||||||
|
Layouts.Layout.leftMargin: 10
|
||||||
|
Layouts.Layout.rightMargin: 10
|
||||||
|
z: 9997
|
||||||
|
type: Kirigami.MessageType.Error
|
||||||
|
showCloseButton: true
|
||||||
|
id: formError
|
||||||
|
}
|
||||||
|
Kirigami.FormLayout {
|
||||||
|
Layouts.Layout.alignment: Qt.AlignHCenter
|
||||||
|
Layouts.Layout.fillWidth: true
|
||||||
|
width: vehicleAddPage.width
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Kirigami.FormData.isSection: true
|
||||||
|
Kirigami.FormData.label: "Vehicle Information"
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextField {
|
||||||
|
id: nameField
|
||||||
|
selectByMouse: true
|
||||||
|
Kirigami.FormData.label: qsTr("Vehicle Name")+":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextField {
|
||||||
|
id: makeField
|
||||||
|
selectByMouse: true
|
||||||
|
Kirigami.FormData.label: qsTr("Make")+":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextField {
|
||||||
|
id: modelField
|
||||||
|
selectByMouse: true
|
||||||
|
Kirigami.FormData.label: qsTr("Model")+":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextField {
|
||||||
|
id: yearField
|
||||||
|
selectByMouse: true
|
||||||
|
Kirigami.FormData.label: qsTr("Year")+":"
|
||||||
|
inputMethodHints: Qt.ImhDigitsOnly
|
||||||
|
validator: IntValidator {
|
||||||
|
bottom: 1900
|
||||||
|
top: 4000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.TextField {
|
||||||
|
id: vinField
|
||||||
|
selectByMouse: true
|
||||||
|
Kirigami.FormData.label: qsTr("VIN")+":"
|
||||||
|
}
|
||||||
|
|
||||||
|
Layouts.RowLayout {
|
||||||
|
|
||||||
|
Controls.Button {
|
||||||
|
text: qsTr("Add")
|
||||||
|
highlighted: true
|
||||||
|
onClicked: {
|
||||||
|
if(yearField.acceptableInput) {
|
||||||
|
vehicleModel.addNewVehicle(nameField.text, makeField.text, modelField.text, parseInt(yearField.text), "", vinField.text);
|
||||||
|
router.popRoute();
|
||||||
|
} else {
|
||||||
|
formError.text = qsTr("Year is invalid!");
|
||||||
|
formError.visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.Button {
|
||||||
|
text: qsTr("Cancel")
|
||||||
|
onClicked: {
|
||||||
|
router.popRoute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
123
src/contents/ui/MainPage.qml
Normal file
123
src/contents/ui/MainPage.qml
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
import QtQuick 2.14
|
||||||
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
import QtQuick.Controls 2.14 as Controls
|
||||||
|
import QtQuick.Layouts 1.14 as Layouts
|
||||||
|
import QtQuick.Controls 1.4 as Old
|
||||||
|
import QtQuick.Dialogs 1.3 as Dialogs
|
||||||
|
|
||||||
|
Kirigami.PageRoute {
|
||||||
|
name: "main"
|
||||||
|
Component {
|
||||||
|
Kirigami.Page {
|
||||||
|
id: mainPage
|
||||||
|
mainAction: Kirigami.Action {
|
||||||
|
text: qsTr("Add Vehicle")
|
||||||
|
iconName: "list-add"
|
||||||
|
onTriggered: {
|
||||||
|
router.navigateToRoute(["main","addvehicle"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contextualActions: [
|
||||||
|
Kirigami.Action {
|
||||||
|
iconName: "application-javascript"
|
||||||
|
text: qsTr("Import From Carfax JSON")
|
||||||
|
onTriggered: {
|
||||||
|
importDialog.visible = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Kirigami.Action {
|
||||||
|
iconName: "help-about"
|
||||||
|
text: qsTr("About")
|
||||||
|
onTriggered: {
|
||||||
|
router.navigateToRoute("about");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
title: "Vehicles"
|
||||||
|
Dialogs.FileDialog {
|
||||||
|
id: importDialog
|
||||||
|
title: qsTr("Select Carfax Json file to import...")
|
||||||
|
nameFilters: ["Carfax Vehicle Json (*.json)"]
|
||||||
|
onAccepted: {
|
||||||
|
if(jsonConverter.importCarfaxJsonToDB(importDialog.fileUrl)) {
|
||||||
|
//
|
||||||
|
} else {
|
||||||
|
root.showPassiveNotification(qsTr("Failed to parse file."),"short");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
99
src/contents/ui/ServiceRecords.qml
Normal file
99
src/contents/ui/ServiceRecords.qml
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
import QtQuick 2.14
|
||||||
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
import QtQuick.Controls 2.14 as Controls
|
||||||
|
import QtQuick.Layouts 1.14 as Layouts
|
||||||
|
|
||||||
|
Kirigami.PageRoute {
|
||||||
|
name: "servicerecords"
|
||||||
|
|
||||||
|
Component {
|
||||||
|
Kirigami.ScrollablePage {
|
||||||
|
property var serviceId: Kirigami.PageRouter.data.id
|
||||||
|
Component.onCompleted: {
|
||||||
|
recordModel.changeVehicleFilter(serviceId);
|
||||||
|
//Check vehicle warnings
|
||||||
|
dbAnalytics.checkOilChangeNeededForVehicle(serviceId, appAnalyticsSettings.value("milesForOilChange",5000), appAnalyticsSettings.value("monthsForOilChange",6));
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: recordModel
|
||||||
|
function onVehicleUpdated(vehicleId) {
|
||||||
|
//Check vehicle warnings
|
||||||
|
if(vehicleId == serviceId) {
|
||||||
|
dbAnalytics.checkOilChangeNeededForVehicle(vehicleId, appAnalyticsSettings.value("milesForOilChange",5000), appAnalyticsSettings.value("monthsForOilChange",6));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
id: serviceRecordPage
|
||||||
|
title: qsTr("Service Records for ") + Kirigami.PageRouter.data.name
|
||||||
|
mainAction: Kirigami.Action {
|
||||||
|
text: qsTr("Add Service Record")
|
||||||
|
iconName: "list-add"
|
||||||
|
onTriggered: {
|
||||||
|
router.pushRoute({"route": "addrecord", "data": serviceId});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: serviceView
|
||||||
|
Layouts.Layout.fillHeight: true
|
||||||
|
Layouts.Layout.fillWidth: true
|
||||||
|
model: recordModel
|
||||||
|
headerPositioning: ListView.OverlayHeader
|
||||||
|
header: Kirigami.ListSectionHeader {
|
||||||
|
z: 9997
|
||||||
|
contentItem: Layouts.ColumnLayout {
|
||||||
|
Kirigami.InlineMessage {
|
||||||
|
Layouts.Layout.fillWidth: true
|
||||||
|
type: Kirigami.MessageType.Information
|
||||||
|
id: oilMessage
|
||||||
|
showCloseButton: false
|
||||||
|
text: qsTr("You are due for an oil change!")
|
||||||
|
Connections {
|
||||||
|
target: dbAnalytics
|
||||||
|
function onIsOilChangeNeeded(changeNeeded) {
|
||||||
|
oilMessage.visible = changeNeeded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delegate: Kirigami.SwipeListItem {
|
||||||
|
contentItem: Layouts.ColumnLayout {
|
||||||
|
Kirigami.Heading {
|
||||||
|
text: serviceprovider
|
||||||
|
level: 2
|
||||||
|
}
|
||||||
|
Kirigami.Heading {
|
||||||
|
text: servicetypename
|
||||||
|
level: 2
|
||||||
|
}
|
||||||
|
Controls.Label {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
actions: [
|
||||||
|
Kirigami.Action {
|
||||||
|
text: qsTr("Remove")
|
||||||
|
iconName: "edit-delete"
|
||||||
|
onTriggered: {
|
||||||
|
recordModel.removeRecord(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,122 +36,7 @@ Kirigami.ApplicationWindow {
|
|||||||
initialRoute: "main"
|
initialRoute: "main"
|
||||||
pageStack: root.pageStack.columnView
|
pageStack: root.pageStack.columnView
|
||||||
|
|
||||||
Kirigami.PageRoute {
|
MainPage{}
|
||||||
name: "main"
|
|
||||||
Component {
|
|
||||||
Kirigami.Page {
|
|
||||||
id: mainPage
|
|
||||||
mainAction: Kirigami.Action {
|
|
||||||
text: qsTr("Add Vehicle")
|
|
||||||
iconName: "list-add"
|
|
||||||
onTriggered: {
|
|
||||||
router.navigateToRoute(["main","addvehicle"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
contextualActions: [
|
|
||||||
Kirigami.Action {
|
|
||||||
iconName: "application-javascript"
|
|
||||||
text: qsTr("Import From Carfax JSON")
|
|
||||||
onTriggered: {
|
|
||||||
importDialog.visible = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Kirigami.Action {
|
|
||||||
iconName: "help-about"
|
|
||||||
text: qsTr("About")
|
|
||||||
onTriggered: {
|
|
||||||
router.navigateToRoute("about");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
title: "Vehicles"
|
|
||||||
Dialogs.FileDialog {
|
|
||||||
id: importDialog
|
|
||||||
title: qsTr("Select Carfax Json file to import...")
|
|
||||||
nameFilters: ["Carfax Vehicle Json (*.json)"]
|
|
||||||
onAccepted: {
|
|
||||||
if(jsonConverter.importCarfaxJsonToDB(importDialog.fileUrl)) {
|
|
||||||
//
|
|
||||||
} else {
|
|
||||||
root.showPassiveNotification(qsTr("Failed to parse file."),"short");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Kirigami.PageRoute {
|
Kirigami.PageRoute {
|
||||||
name: "about"
|
name: "about"
|
||||||
@@ -170,322 +55,10 @@ Kirigami.ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Kirigami.PageRoute {
|
AddVehicle{}
|
||||||
name: "addvehicle"
|
|
||||||
Component {
|
|
||||||
Kirigami.Page {
|
|
||||||
id: vehicleAddPage
|
|
||||||
title: qsTr("Add Vehicle")
|
|
||||||
Layouts.ColumnLayout {
|
|
||||||
anchors.fill: parent
|
|
||||||
Kirigami.InlineMessage {
|
|
||||||
Layouts.Layout.fillWidth: true
|
|
||||||
Layouts.Layout.leftMargin: 10
|
|
||||||
Layouts.Layout.rightMargin: 10
|
|
||||||
z: 9997
|
|
||||||
type: Kirigami.MessageType.Error
|
|
||||||
showCloseButton: true
|
|
||||||
id: formError
|
|
||||||
}
|
|
||||||
Kirigami.FormLayout {
|
|
||||||
Layouts.Layout.alignment: Qt.AlignHCenter
|
|
||||||
Layouts.Layout.fillWidth: true
|
|
||||||
width: vehicleAddPage.width
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Kirigami.FormData.isSection: true
|
|
||||||
Kirigami.FormData.label: "Vehicle Information"
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextField {
|
|
||||||
id: nameField
|
|
||||||
selectByMouse: true
|
|
||||||
Kirigami.FormData.label: qsTr("Vehicle Name")+":"
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextField {
|
|
||||||
id: makeField
|
|
||||||
selectByMouse: true
|
|
||||||
Kirigami.FormData.label: qsTr("Make")+":"
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextField {
|
|
||||||
id: modelField
|
|
||||||
selectByMouse: true
|
|
||||||
Kirigami.FormData.label: qsTr("Model")+":"
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextField {
|
|
||||||
id: yearField
|
|
||||||
selectByMouse: true
|
|
||||||
Kirigami.FormData.label: qsTr("Year")+":"
|
|
||||||
inputMethodHints: Qt.ImhDigitsOnly
|
|
||||||
validator: IntValidator {
|
|
||||||
bottom: 1900
|
|
||||||
top: 4000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextField {
|
|
||||||
id: vinField
|
|
||||||
selectByMouse: true
|
|
||||||
Kirigami.FormData.label: qsTr("VIN")+":"
|
|
||||||
}
|
|
||||||
|
|
||||||
Layouts.RowLayout {
|
|
||||||
|
|
||||||
Controls.Button {
|
|
||||||
text: qsTr("Add")
|
|
||||||
highlighted: true
|
|
||||||
onClicked: {
|
|
||||||
if(yearField.acceptableInput) {
|
|
||||||
vehicleModel.addNewVehicle(nameField.text, makeField.text, modelField.text, parseInt(yearField.text), "", vinField.text);
|
|
||||||
router.popRoute();
|
|
||||||
} else {
|
|
||||||
formError.text = qsTr("Year is invalid!");
|
|
||||||
formError.visible = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.Button {
|
|
||||||
text: qsTr("Cancel")
|
|
||||||
onClicked: {
|
|
||||||
router.popRoute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Kirigami.PageRoute {
|
ServiceRecords{}
|
||||||
name: "servicerecords"
|
|
||||||
|
|
||||||
Component {
|
|
||||||
Kirigami.ScrollablePage {
|
|
||||||
property var serviceId: Kirigami.PageRouter.data.id
|
|
||||||
Component.onCompleted: {
|
|
||||||
recordModel.changeVehicleFilter(serviceId);
|
|
||||||
//Check vehicle warnings
|
|
||||||
dbAnalytics.checkOilChangeNeededForVehicle(serviceId, appAnalyticsSettings.value("milesForOilChange",5000), appAnalyticsSettings.value("monthsForOilChange",6));
|
|
||||||
}
|
|
||||||
Connections {
|
|
||||||
target: recordModel
|
|
||||||
function onVehicleUpdated(vehicleId) {
|
|
||||||
//Check vehicle warnings
|
|
||||||
if(vehicleId == serviceId) {
|
|
||||||
dbAnalytics.checkOilChangeNeededForVehicle(vehicleId, appAnalyticsSettings.value("milesForOilChange",5000), appAnalyticsSettings.value("monthsForOilChange",6));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
id: serviceRecordPage
|
|
||||||
title: qsTr("Service Records for ") + Kirigami.PageRouter.data.name
|
|
||||||
mainAction: Kirigami.Action {
|
|
||||||
text: qsTr("Add Service Record")
|
|
||||||
iconName: "list-add"
|
|
||||||
onTriggered: {
|
|
||||||
router.pushRoute({"route": "addrecord", "data": serviceId});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ListView {
|
|
||||||
id: serviceView
|
|
||||||
Layouts.Layout.fillHeight: true
|
|
||||||
Layouts.Layout.fillWidth: true
|
|
||||||
model: recordModel
|
|
||||||
headerPositioning: ListView.OverlayHeader
|
|
||||||
header: Kirigami.ListSectionHeader {
|
|
||||||
z: 9997
|
|
||||||
contentItem: Layouts.ColumnLayout {
|
|
||||||
Kirigami.InlineMessage {
|
|
||||||
Layouts.Layout.fillWidth: true
|
|
||||||
type: Kirigami.MessageType.Information
|
|
||||||
id: oilMessage
|
|
||||||
showCloseButton: false
|
|
||||||
text: qsTr("You are due for an oil change!")
|
|
||||||
Connections {
|
|
||||||
target: dbAnalytics
|
|
||||||
function onIsOilChangeNeeded(changeNeeded) {
|
|
||||||
oilMessage.visible = changeNeeded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delegate: Kirigami.SwipeListItem {
|
|
||||||
contentItem: Layouts.ColumnLayout {
|
|
||||||
Kirigami.Heading {
|
|
||||||
text: serviceprovider
|
|
||||||
level: 2
|
|
||||||
}
|
|
||||||
Kirigami.Heading {
|
|
||||||
text: servicetypename
|
|
||||||
level: 2
|
|
||||||
}
|
|
||||||
Controls.Label {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
actions: [
|
|
||||||
Kirigami.Action {
|
|
||||||
text: qsTr("Remove")
|
|
||||||
iconName: "edit-delete"
|
|
||||||
onTriggered: {
|
|
||||||
recordModel.removeRecord(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Kirigami.PageRoute {
|
AddRecord{}
|
||||||
name: "addrecord"
|
|
||||||
Component {
|
|
||||||
Kirigami.Page {
|
|
||||||
id: recordAddPage
|
|
||||||
title: qsTr("Add Service Record")
|
|
||||||
Layouts.ColumnLayout {
|
|
||||||
anchors.fill: parent
|
|
||||||
Kirigami.InlineMessage {
|
|
||||||
Layouts.Layout.fillWidth: true
|
|
||||||
Layouts.Layout.leftMargin: 10
|
|
||||||
Layouts.Layout.rightMargin: 10
|
|
||||||
z: 9997
|
|
||||||
type: Kirigami.MessageType.Error
|
|
||||||
showCloseButton: true
|
|
||||||
id: formError
|
|
||||||
}
|
|
||||||
Kirigami.FormLayout {
|
|
||||||
Layouts.Layout.alignment: Qt.AlignHCenter
|
|
||||||
Layouts.Layout.fillWidth: true
|
|
||||||
width: recordAddPage.width
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Kirigami.FormData.isSection: true
|
|
||||||
Kirigami.FormData.label: "Service Information"
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextField {
|
|
||||||
id: providerField
|
|
||||||
selectByMouse: true
|
|
||||||
Kirigami.FormData.label: qsTr("Service Provider")+":"
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.ComboBox {
|
|
||||||
id: typeField
|
|
||||||
model: serviceTypeModel
|
|
||||||
textRole: "text"
|
|
||||||
valueRole: "value"
|
|
||||||
onActivated: {
|
|
||||||
if(currentValue == -1) {
|
|
||||||
customTypeField.visible = true;
|
|
||||||
} else {
|
|
||||||
customTypeField.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Kirigami.FormData.label: qsTr("Service Type")+":"
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextField {
|
|
||||||
id: customTypeField
|
|
||||||
visible: false
|
|
||||||
Kirigami.FormData.label: qsTr("Custom Service Type")+":"
|
|
||||||
}
|
|
||||||
|
|
||||||
Layouts.RowLayout {
|
|
||||||
Kirigami.FormData.label: qsTr("Date")+":"
|
|
||||||
Controls.TextField {
|
|
||||||
id: dateField
|
|
||||||
text: new Date().toLocaleDateString(Qt.locale())
|
|
||||||
readOnly: true
|
|
||||||
}
|
|
||||||
Controls.Button {
|
|
||||||
icon.name: "office-calendar"
|
|
||||||
text: qsTr("Select Date")
|
|
||||||
display: Controls.AbstractButton.IconOnly
|
|
||||||
onClicked: {
|
|
||||||
calendarPopup.open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextField {
|
|
||||||
id: milesField
|
|
||||||
selectByMouse: true
|
|
||||||
Kirigami.FormData.label: qsTr("Miles")+":"
|
|
||||||
inputMethodHints: Qt.ImhDigitsOnly
|
|
||||||
validator: IntValidator {
|
|
||||||
bottom: 0
|
|
||||||
top: 500000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls.TextArea {
|
|
||||||
id: notesField
|
|
||||||
placeholderText: qsTr("Notes about service")
|
|
||||||
selectByMouse: true
|
|
||||||
Kirigami.FormData.label: qsTr("Notes")+":"
|
|
||||||
}
|
|
||||||
|
|
||||||
Layouts.RowLayout {
|
|
||||||
|
|
||||||
Controls.Button {
|
|
||||||
text: qsTr("Add")
|
|
||||||
highlighted: true
|
|
||||||
onClicked: {
|
|
||||||
var dateObj = Date.fromLocaleDateString(Qt.locale(), dateField.text);
|
|
||||||
var typeText = typeField.currentText;
|
|
||||||
if(typeField.currentValue == -1) {
|
|
||||||
typeText = customTypeField.text;
|
|
||||||
}
|
|
||||||
if(milesField.acceptableInput) {
|
|
||||||
recordModel.addNewRecord(providerField.text, typeField.currentValue, typeText, dateObj.toISOString(), parseInt(milesField.text), notesField.text);
|
|
||||||
router.popRoute();
|
|
||||||
} else {
|
|
||||||
formError.text = qsTr("Invalid number of miles.");
|
|
||||||
formError.visible = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Controls.Button {
|
|
||||||
text: qsTr("Cancel")
|
|
||||||
onClicked: {
|
|
||||||
router.popRoute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Kirigami.OverlaySheet {
|
|
||||||
id: calendarPopup
|
|
||||||
Old.Calendar {
|
|
||||||
selectedDate: Date.fromLocaleDateString(Qt.locale(), dateField.text)
|
|
||||||
onClicked: {
|
|
||||||
dateField.text = date.toLocaleDateString(Qt.locale());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file alias="main.qml">contents/ui/main.qml</file>
|
<file alias="main.qml">contents/ui/main.qml</file>
|
||||||
|
<file alias="MainPage.qml">contents/ui/MainPage.qml</file>
|
||||||
|
<file alias="AddVehicle.qml">contents/ui/AddVehicle.qml</file>
|
||||||
|
<file alias="ServiceRecords.qml">contents/ui/ServiceRecords.qml</file>
|
||||||
|
<file alias="AddRecord.qml">contents/ui/AddRecord.qml</file>
|
||||||
<file alias="speed.svg">contents/speed.svg</file>
|
<file alias="speed.svg">contents/speed.svg</file>
|
||||||
<file alias="license.svg">contents/license.svg</file>
|
<file alias="license.svg">contents/license.svg</file>
|
||||||
<file alias="logo.svg">../packaging/org.eyecreate.vehiclevoyage.svg</file>
|
<file alias="logo.svg">../packaging/org.eyecreate.vehiclevoyage.svg</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user