From 168bd17302daf96d6d922f0fd5aa024900d2f212 Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Tue, 30 Jun 2020 18:03:54 -0400 Subject: [PATCH] Show message if failed to import json. Have android builds use different pathing if possible. --- src/contents/ui/main.qml | 8 ++++++-- src/jsonio.cpp | 1 + src/main.cpp | 12 ++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/contents/ui/main.qml b/src/contents/ui/main.qml index 82dbe8e..4b2a2aa 100644 --- a/src/contents/ui/main.qml +++ b/src/contents/ui/main.qml @@ -64,9 +64,13 @@ Kirigami.ApplicationWindow { title: qsTr("Select Carfax Json file to import...") nameFilters: ["Carfax Vehicle Json (*.json)"] onAccepted: { - jsonConverter.importCarfaxJsonToDB(importDialog.fileUrl); + if(jsonConverter.importCarfaxJsonToDB(importDialog.fileUrl)) { + // + } else { + root.showPassiveNotification(qsTr("Failed to parse file."),"short"); + } } - } + } Kirigami.CardsListView { anchors.fill: parent id: vehicleView diff --git a/src/jsonio.cpp b/src/jsonio.cpp index 3512a26..4c8e8d7 100644 --- a/src/jsonio.cpp +++ b/src/jsonio.cpp @@ -72,3 +72,4 @@ bool JsonIO::importCarfaxJsonToDB(QString fileLocation) return false; } + diff --git a/src/main.cpp b/src/main.cpp index 4d35c91..ada77d0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,7 +56,19 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) app.setWindowIcon(QIcon::fromTheme("org.eyecreate.vehiclevoyage")); 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")); +#endif if(!QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).exists()) { QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); -- GitLab