From 92d08a4798111b1108246a7077e31230f4014226 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 9 Aug 2018 08:36:45 +0200 Subject: [PATCH] using path instead of string --- src/core/excelreader.cpp | 4 ++-- src/core/excelreader.h | 6 +++--- src/gui/mainwindow.cpp | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/excelreader.cpp b/src/core/excelreader.cpp index 5d14584..14ee63c 100644 --- a/src/core/excelreader.cpp +++ b/src/core/excelreader.cpp @@ -2,7 +2,7 @@ #include -void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace* market) +void ExcelReader::readSellersFromFile(std::filesystem::path& filePath, Marketplace* market) { for (auto& seller : market->getSellers()) { seller->setState(Seller::State::DELETE); @@ -10,7 +10,7 @@ void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace* market->storeToDb(true); xlnt::workbook wb; - wb.load(filename); + wb.load(filePath); auto ws = wb.sheet_by_index(0); const int START_ROW = 5; diff --git a/src/core/excelreader.h b/src/core/excelreader.h index 9278441..1d8b945 100644 --- a/src/core/excelreader.h +++ b/src/core/excelreader.h @@ -1,9 +1,10 @@ #ifndef EXCEL_READER_H #define EXCEL_READER_H -#include "seller.h" #include "marketplace.h" +#include "seller.h" +#include #include #include #include @@ -11,8 +12,7 @@ class ExcelReader { public: - static void readSellersFromFile(const std::string& filename, - Marketplace* market); + static void readSellersFromFile(std::filesystem::path& filePath, Marketplace* market); }; #endif \ No newline at end of file diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 5fe2a88..689beb2 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -376,8 +377,10 @@ void MainWindow::onImportSellerExcelActionTriggered() if (filename.isEmpty()) return; - std::u16string fname16 = filename.toStdU16String(); - ExcelReader::readSellersFromFile(convertFromUtf16ToUtf8(fname16), marketplace_.get()); + + std::filesystem::path filePath(filename.toStdU16String()); + + ExcelReader::readSellersFromFile(filePath, marketplace_.get()); } void MainWindow::onImportSellerJsonActionTriggered()