Show message if failed to import json. Have android builds use different pathing if possible.

This commit is contained in:
2020-06-30 18:03:54 -04:00
parent 96cc336063
commit 168bd17302
3 changed files with 19 additions and 2 deletions

View File

@@ -64,9 +64,13 @@ Kirigami.ApplicationWindow {
title: qsTr("Select Carfax Json file to import...") title: qsTr("Select Carfax Json file to import...")
nameFilters: ["Carfax Vehicle Json (*.json)"] nameFilters: ["Carfax Vehicle Json (*.json)"]
onAccepted: { onAccepted: {
jsonConverter.importCarfaxJsonToDB(importDialog.fileUrl); if(jsonConverter.importCarfaxJsonToDB(importDialog.fileUrl)) {
//
} else {
root.showPassiveNotification(qsTr("Failed to parse file."),"short");
}
} }
} }
Kirigami.CardsListView { Kirigami.CardsListView {
anchors.fill: parent anchors.fill: parent
id: vehicleView id: vehicleView

View File

@@ -72,3 +72,4 @@ bool JsonIO::importCarfaxJsonToDB(QString fileLocation)
return false; return false;
} }

View File

@@ -56,7 +56,19 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
app.setWindowIcon(QIcon::fromTheme("org.eyecreate.vehiclevoyage")); app.setWindowIcon(QIcon::fromTheme("org.eyecreate.vehiclevoyage"));
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
#ifdef Q_OS_ANDROID
if(QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).length > 1)
{
db.setDatabaseName(QDir(QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)[1]).filePath("servicerecords.sqlite")); //Use second appdata path on
android for shared storage.
}
else
{
db.setDatabaseName(QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("servicerecords.sqlite"));
}
#else
db.setDatabaseName(QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("servicerecords.sqlite")); db.setDatabaseName(QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("servicerecords.sqlite"));
#endif
if(!QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).exists()) if(!QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).exists())
{ {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));