Add UI/code to make process of add/removing vehicles work.
This commit is contained in:
@@ -18,6 +18,6 @@
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
<releases>
|
||||
<release version="1.0" date="2020-5-31" type="stable"/>
|
||||
<release version="1.0" date="2020-6-11" type="stable"/>
|
||||
</releases>
|
||||
</component>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"command": "vehiclevoyage",
|
||||
"finish-args": [
|
||||
"--share=ipc",
|
||||
"runtime-version": "5.13",
|
||||
"runtime-version": "5.14",
|
||||
"sdk": "org.kde.Sdk",
|
||||
"--share=network",
|
||||
"--socket=x11",
|
||||
|
||||
@@ -20,6 +20,7 @@ Kirigami.ApplicationWindow {
|
||||
id: mainPage
|
||||
mainAction: Kirigami.Action {
|
||||
text: qsTr("Add Vehicle")
|
||||
iconName: "list-add"
|
||||
onTriggered: {
|
||||
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 {}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ void SqlVehicle::addNewVehicle ( const QString name, const QString maker, const
|
||||
if(this->submitAll()) {
|
||||
printf("inserted new vehicle record");
|
||||
this->database().commit();
|
||||
this->select();
|
||||
} else {
|
||||
this->database().rollback();
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
QHash<int, QByteArray> roleNames() 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 removeVehicle(int index);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
|
||||
SqlVehicle vehicles(nullptr, db);
|
||||
SqlServiceRecord records(nullptr, db);
|
||||
//Fill model with inital data.
|
||||
vehicles.select();
|
||||
records.select();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user