From edb48c6802d4da59d0edd19b2dfded4638a812db Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Thu, 23 Jul 2020 11:25:03 -0400 Subject: [PATCH] Change file handling code to open file depending on url type. --- src/jsonio.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/jsonio.cpp b/src/jsonio.cpp index 4c8e8d7..032a240 100644 --- a/src/jsonio.cpp +++ b/src/jsonio.cpp @@ -32,11 +32,17 @@ JsonIO::JsonIO(SqlVehicle* vehicles, SqlServiceRecord* records, QObject* parent) bool JsonIO::importCarfaxJsonToDB(QString fileLocation) { - QFile file(QUrl(fileLocation).toLocalFile()); - file.open(QIODevice::ReadOnly); + QUrl url(fileLocation); + QFile *file; + if(url.scheme() == "file") { + file = new QFile(url.toLocalFile()); + } else { + file = new QFile(url.toString()); + } + file->open(QIODevice::ReadOnly); QString jsonContent; - jsonContent = file.readAll(); - file.close(); + jsonContent = file->readAll(); + file->close(); QJsonDocument doc = QJsonDocument::fromJson(jsonContent.toUtf8()); QJsonObject root = doc.object(); if(root.contains("vehicle")) { -- GitLab