using path instead of string

This commit is contained in:
Martin Brodbeck 2018-08-09 08:36:45 +02:00
parent fe6b858f32
commit 92d08a4798
3 changed files with 10 additions and 7 deletions

View File

@ -2,7 +2,7 @@
#include <xlnt/xlnt.hpp> #include <xlnt/xlnt.hpp>
void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace* market) void ExcelReader::readSellersFromFile(std::filesystem::path& filePath, Marketplace* market)
{ {
for (auto& seller : market->getSellers()) { for (auto& seller : market->getSellers()) {
seller->setState(Seller::State::DELETE); seller->setState(Seller::State::DELETE);
@ -10,7 +10,7 @@ void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace*
market->storeToDb(true); market->storeToDb(true);
xlnt::workbook wb; xlnt::workbook wb;
wb.load(filename); wb.load(filePath);
auto ws = wb.sheet_by_index(0); auto ws = wb.sheet_by_index(0);
const int START_ROW = 5; const int START_ROW = 5;

View File

@ -1,9 +1,10 @@
#ifndef EXCEL_READER_H #ifndef EXCEL_READER_H
#define EXCEL_READER_H #define EXCEL_READER_H
#include "seller.h"
#include "marketplace.h" #include "marketplace.h"
#include "seller.h"
#include <filesystem>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
@ -11,8 +12,7 @@
class ExcelReader class ExcelReader
{ {
public: public:
static void readSellersFromFile(const std::string& filename, static void readSellersFromFile(std::filesystem::path& filePath, Marketplace* market);
Marketplace* market);
}; };
#endif #endif

View File

@ -16,6 +16,7 @@
#include <exception> #include <exception>
#include <regex> #include <regex>
#include <filesystem>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
@ -376,8 +377,10 @@ void MainWindow::onImportSellerExcelActionTriggered()
if (filename.isEmpty()) if (filename.isEmpty())
return; 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() void MainWindow::onImportSellerJsonActionTriggered()