rename filesystem namespace
This commit is contained in:
parent
a3d95101b3
commit
dac46935c7
3 changed files with 16 additions and 10 deletions
|
@ -3,7 +3,9 @@
|
||||||
#include <xlnt/xlnt.hpp>
|
#include <xlnt/xlnt.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
void ExcelReader::readSellersFromFile(const std::filesystem::path& filePath, Marketplace* market)
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
void ExcelReader::readSellersFromFile(const fs::path& filePath, Marketplace* market)
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
std::ifstream mystream(filePath, std::ios::binary);
|
std::ifstream mystream(filePath, std::ios::binary);
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
void JsonUtil::exportSellers(const std::filesystem::path& filePath, Marketplace* market)
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
void JsonUtil::exportSellers(const fs::path& filePath, Marketplace* market)
|
||||||
{
|
{
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
std::ofstream file(filePath);
|
std::ofstream file(filePath);
|
||||||
|
@ -29,7 +31,7 @@ void JsonUtil::exportSellers(const std::filesystem::path& filePath, Marketplace*
|
||||||
writer->write(root, &file);
|
writer->write(root, &file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonUtil::importSellers(const std::filesystem::path& filePath, Marketplace* market)
|
void JsonUtil::importSellers(const fs::path& filePath, Marketplace* market)
|
||||||
{
|
{
|
||||||
for (auto& seller : market->getSellers()) {
|
for (auto& seller : market->getSellers()) {
|
||||||
seller->setState(Seller::State::DELETE);
|
seller->setState(Seller::State::DELETE);
|
||||||
|
@ -67,7 +69,7 @@ void JsonUtil::importSellers(const std::filesystem::path& filePath, Marketplace*
|
||||||
market->storeToDb();
|
market->storeToDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonUtil::exportSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo)
|
void JsonUtil::exportSales(const fs::path& filePath, Marketplace* market, int cashPointNo)
|
||||||
{
|
{
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
std::ofstream file(filePath);
|
std::ofstream file(filePath);
|
||||||
|
@ -106,7 +108,7 @@ void JsonUtil::exportSales(const std::filesystem::path& filePath, Marketplace* m
|
||||||
writer->write(root, &file);
|
writer->write(root, &file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonUtil::importSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo)
|
void JsonUtil::importSales(const fs::path& filePath, Marketplace* market, int cashPointNo)
|
||||||
{
|
{
|
||||||
Json::Value jsonValues;
|
Json::Value jsonValues;
|
||||||
std::ifstream file(filePath);
|
std::ifstream file(filePath);
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QtGui/QDesktopServices>
|
#include <QtGui/QDesktopServices>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
constexpr int STATUSBAR_TIMEOUT = 5000;
|
constexpr int STATUSBAR_TIMEOUT = 5000;
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
|
@ -378,7 +380,7 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::filesystem::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
||||||
}
|
}
|
||||||
|
@ -399,7 +401,7 @@ void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::filesystem::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
JsonUtil::importSellers(filePath, marketplace_.get());
|
JsonUtil::importSellers(filePath, marketplace_.get());
|
||||||
}
|
}
|
||||||
|
@ -412,7 +414,7 @@ void MainWindow::onExportSellerJsonActionTriggered()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::filesystem::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
JsonUtil::exportSellers(filePath, marketplace_.get());
|
JsonUtil::exportSellers(filePath, marketplace_.get());
|
||||||
}
|
}
|
||||||
|
@ -427,7 +429,7 @@ void MainWindow::onExportSalesJsonActionTriggered()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::filesystem::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
JsonUtil::exportSales(filePath, marketplace_.get(),
|
JsonUtil::exportSales(filePath, marketplace_.get(),
|
||||||
settings.value("global/cashPointNo").toInt());
|
settings.value("global/cashPointNo").toInt());
|
||||||
|
@ -443,7 +445,7 @@ void MainWindow::onImportSalesJsonActionTriggered()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::filesystem::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
delete ui_.salesView->model();
|
delete ui_.salesView->model();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue