Add UI/code to make process of add/removing vehicles work.

This commit is contained in:
2020-06-09 13:25:46 -04:00
parent 5b8cd46e80
commit 5e749c454b
6 changed files with 38 additions and 2 deletions

View File

@@ -18,6 +18,6 @@
</screenshot> </screenshot>
</screenshots> </screenshots>
<releases> <releases>
<release version="1.0" date="2020-5-31" type="stable"/> <release version="1.0" date="2020-6-11" type="stable"/>
</releases> </releases>
</component> </component>

View File

@@ -4,7 +4,7 @@
"command": "vehiclevoyage", "command": "vehiclevoyage",
"finish-args": [ "finish-args": [
"--share=ipc", "--share=ipc",
"runtime-version": "5.13", "runtime-version": "5.14",
"sdk": "org.kde.Sdk", "sdk": "org.kde.Sdk",
"--share=network", "--share=network",
"--socket=x11", "--socket=x11",

View File

@@ -20,6 +20,7 @@ Kirigami.ApplicationWindow {
id: mainPage id: mainPage
mainAction: Kirigami.Action { mainAction: Kirigami.Action {
text: qsTr("Add Vehicle") text: qsTr("Add Vehicle")
iconName: "list-add"
onTriggered: { onTriggered: {
router.navigateToRoute(["main","addvehicle"]); router.navigateToRoute(["main","addvehicle"]);
} }
@@ -65,6 +66,24 @@ Kirigami.ApplicationWindow {
} }
} }
} }
actions: [
Kirigami.Action {
text: qsTr("Examine Logs")
iconName: "edit-find"
onTriggered: {
//
}
}
]
hiddenActions: [
Kirigami.Action {
text: qsTr("Delete")
iconName: "edit-delete"
onTriggered: {
vehicleModel.removeVehicle(index);
}
}
]
} }
Controls.ScrollBar.vertical: Controls.ScrollBar {} Controls.ScrollBar.vertical: Controls.ScrollBar {}
} }

View File

@@ -65,6 +65,7 @@ void SqlVehicle::addNewVehicle ( const QString name, const QString maker, const
if(this->submitAll()) { if(this->submitAll()) {
printf("inserted new vehicle record"); printf("inserted new vehicle record");
this->database().commit(); this->database().commit();
this->select();
} else { } else {
this->database().rollback(); this->database().rollback();
printf("database error"); printf("database error");
@@ -72,6 +73,20 @@ void SqlVehicle::addNewVehicle ( const QString name, const QString maker, const
} }
void SqlVehicle::removeVehicle(int index)
{
this->removeRow(index);
if(this->submitAll()) {
printf("inserted new vehicle record");
this->database().commit();
this->select();
} else {
this->database().rollback();
printf("database error");
}
}

View File

@@ -31,6 +31,7 @@ public:
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override; Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override;
Q_INVOKABLE void addNewVehicle(const QString name, const QString maker, const QString model, const int year, const QString image, const QString vin); Q_INVOKABLE void addNewVehicle(const QString name, const QString maker, const QString model, const int year, const QString image, const QString vin);
Q_INVOKABLE void removeVehicle(int index);
private: private:

View File

@@ -72,6 +72,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
SqlVehicle vehicles(nullptr, db); SqlVehicle vehicles(nullptr, db);
SqlServiceRecord records(nullptr, db); SqlServiceRecord records(nullptr, db);
//Fill model with inital data.
vehicles.select(); vehicles.select();
records.select(); records.select();