diff --git a/src/core/jsonutil.cpp b/src/core/jsonutil.cpp index a41f69b..a71168b 100644 --- a/src/core/jsonutil.cpp +++ b/src/core/jsonutil.cpp @@ -29,7 +29,7 @@ void JsonUtil::exportSellers(const std::string& filename, Marketplace* market) writer->write(root, &file); } -void JsonUtil::importSellers(const std::string& filename, Marketplace* market) +void JsonUtil::importSellers(const std::filesystem::path& filePath, Marketplace* market) { for (auto& seller : market->getSellers()) { seller->setState(Seller::State::DELETE); @@ -37,7 +37,7 @@ void JsonUtil::importSellers(const std::string& filename, Marketplace* market) market->storeToDb(true); Json::Value jsonValues; - std::ifstream file(filename); + std::ifstream file(filePath); file >> jsonValues; for (auto val : jsonValues["sellers"]) { diff --git a/src/core/jsonutil.h b/src/core/jsonutil.h index 1f0335d..50601bf 100644 --- a/src/core/jsonutil.h +++ b/src/core/jsonutil.h @@ -4,12 +4,13 @@ #include "marketplace.h" #include +#include class JsonUtil { public: static void exportSellers(const std::string& filename, Marketplace* market); - static void importSellers(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); }; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index abde041..4d4659f 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -15,8 +15,8 @@ #include #include -#include #include +#include #include #include @@ -377,9 +377,9 @@ void MainWindow::onImportSellerExcelActionTriggered() if (filename.isEmpty()) return; - + std::filesystem::path filePath(filename.toStdWString()); - + ExcelReader::readSellersFromFile(filePath, marketplace_.get()); } @@ -399,7 +399,9 @@ void MainWindow::onImportSellerJsonActionTriggered() if (filename.isEmpty()) return; - JsonUtil::importSellers(filename.toStdString(), marketplace_.get()); + std::filesystem::path filePath(filename.toStdWString()); + + JsonUtil::importSellers(filePath, marketplace_.get()); } void MainWindow::onExportSellerJsonActionTriggered()