Fix typo. Only have warning show for correct vehicle. Remove log screen when vehicle deleted.

This commit is contained in:
2020-08-22 19:47:44 -04:00
parent 43035181af
commit e20d6ce723
4 changed files with 9 additions and 8 deletions

View File

@@ -119,6 +119,7 @@ Kirigami.PageRoute {
iconName: "edit-delete" iconName: "edit-delete"
onTriggered: { onTriggered: {
vehicleModel.removeVehicle(index); vehicleModel.removeVehicle(index);
router.navigateToRoute(["main"]);
} }
} }
] ]

View File

@@ -10,7 +10,7 @@ Kirigami.PageRoute {
Kirigami.ScrollablePage { Kirigami.ScrollablePage {
property var vehicleId: Kirigami.PageRouter.data.id property var vehicleId: Kirigami.PageRouter.data.id
Component.onCompleted: { Component.onCompleted: {
recordModel.changeVehicleFilter(vehcileId); recordModel.changeVehicleFilter(vehicleId);
//Check vehicle warnings //Check vehicle warnings
dbAnalytics.checkOilChangeNeededForVehicle(vehicleId, appAnalyticsSettings.value("milesForOilChange",5000), appAnalyticsSettings.value("monthsForOilChange",6)); dbAnalytics.checkOilChangeNeededForVehicle(vehicleId, appAnalyticsSettings.value("milesForOilChange",5000), appAnalyticsSettings.value("monthsForOilChange",6));
} }
@@ -49,8 +49,10 @@ Kirigami.PageRoute {
text: qsTr("You are due for an oil change!") text: qsTr("You are due for an oil change!")
Connections { Connections {
target: dbAnalytics target: dbAnalytics
function onIsOilChangeNeeded(changeNeeded) { function onIsOilChangeNeeded(changeNeeded, vehicle) {
oilMessage.visible = changeNeeded; if(vehicle == vehicleId) {
oilMessage.visible = changeNeeded;
}
} }
} }
} }

View File

@@ -1,5 +1,4 @@
/* /*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2020 <Kevin Whitakerr> <eyecreate@eyecreate.org> * Copyright (C) 2020 <Kevin Whitakerr> <eyecreate@eyecreate.org>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@@ -47,9 +46,9 @@ void RecordAnalytics::checkOilChangeNeededForVehicle(int vehicleId, int milesFor
} }
} }
if(lastKnownMiles-lastOilMiles > milesForChange || lastOilMiles == 0 || !lastOilDate.isValid() || lastOilDate.daysTo(QDateTime::currentDateTime()) > 30*monthsForChange) { if(lastKnownMiles-lastOilMiles > milesForChange || lastOilMiles == 0 || !lastOilDate.isValid() || lastOilDate.daysTo(QDateTime::currentDateTime()) > 30*monthsForChange) {
emit this->isOilChangeNeeded(true); emit this->isOilChangeNeeded(true, vehicleId);
} else { } else {
emit this->isOilChangeNeeded(false); emit this->isOilChangeNeeded(false, vehicleId);
} }
}); });
} }

View File

@@ -1,5 +1,4 @@
/* /*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2020 <Kevin Whitaker> <eyecreate@eyecreate.org> * Copyright (C) 2020 <Kevin Whitaker> <eyecreate@eyecreate.org>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@@ -34,7 +33,7 @@ public:
Q_INVOKABLE void checkOilChangeNeededForVehicle(int vehicleId, int milesForChange=5000, int monthsForChange=6); Q_INVOKABLE void checkOilChangeNeededForVehicle(int vehicleId, int milesForChange=5000, int monthsForChange=6);
signals: signals:
void isOilChangeNeeded(bool changeNeeded); void isOilChangeNeeded(bool changeNeeded, int vehicleId);
private: private:
QSqlDatabase _db; QSqlDatabase _db;