From 7227cdc8a34635ce9e569acd768e4f51cc9cdd65 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 9 Aug 2018 13:00:51 +0200 Subject: [PATCH 1/2] use path to open json file (sales) --- src/core/jsonutil.cpp | 4 ++-- src/core/jsonutil.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/jsonutil.cpp b/src/core/jsonutil.cpp index a71168b..9d3bde3 100644 --- a/src/core/jsonutil.cpp +++ b/src/core/jsonutil.cpp @@ -106,10 +106,10 @@ void JsonUtil::exportSales(const std::string& filename, Marketplace* market, int writer->write(root, &file); } -void JsonUtil::importSales(const std::string& filename, Marketplace* market, int cashPointNo) +void JsonUtil::importSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo) { Json::Value jsonValues; - std::ifstream file(filename); + std::ifstream file(filePath); file >> jsonValues; int source_no = jsonValues["source_no"].asInt(); diff --git a/src/core/jsonutil.h b/src/core/jsonutil.h index 50601bf..9ec6ddc 100644 --- a/src/core/jsonutil.h +++ b/src/core/jsonutil.h @@ -12,7 +12,7 @@ class JsonUtil static void exportSellers(const std::string& filename, Marketplace* market); static void importSellers(const std::filesystem::path& filePath, Marketplace* market); static void exportSales(const std::string& filename, Marketplace* market, int cashPointNo); - static void importSales(const std::string& filename, Marketplace* market, int cashPointNo); + static void importSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo); }; #endif \ No newline at end of file From be1d731de3aa4430c1b06a6e52d44df77a55183b Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 9 Aug 2018 13:02:33 +0200 Subject: [PATCH 2/2] use path to open json file (sales) --- src/gui/mainwindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 4d4659f..280ca62 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -439,9 +439,11 @@ void MainWindow::onImportSalesJsonActionTriggered() if (filename.isEmpty()) return; + std::filesystem::path filePath(filename.toStdWString()); + delete ui_.salesView->model(); try { - JsonUtil::importSales(filename.toStdString(), marketplace_.get(), + JsonUtil::importSales(filePath, marketplace_.get(), settings.value("global/cashPointNo").toInt()); } catch (std::runtime_error& err) { QMessageBox(QMessageBox::Icon::Warning, "Import nicht möglich", err.what(), QMessageBox::Ok,