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>
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;

View file

@ -1,9 +1,10 @@
#ifndef EXCEL_READER_H
#define EXCEL_READER_H
#include "seller.h"
#include "marketplace.h"
#include "seller.h"
#include <filesystem>
#include <memory>
#include <string>
#include <vector>
@ -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

View file

@ -16,6 +16,7 @@
#include <exception>
#include <regex>
#include <filesystem>
#include <QFileDialog>
#include <QMessageBox>
@ -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()