use path to open json file (sellers)
This commit is contained in:
parent
a04e8ad837
commit
7d98033c4a
3 changed files with 10 additions and 7 deletions
|
@ -29,7 +29,7 @@ void JsonUtil::exportSellers(const std::string& filename, Marketplace* market)
|
||||||
writer->write(root, &file);
|
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()) {
|
for (auto& seller : market->getSellers()) {
|
||||||
seller->setState(Seller::State::DELETE);
|
seller->setState(Seller::State::DELETE);
|
||||||
|
@ -37,7 +37,7 @@ void JsonUtil::importSellers(const std::string& filename, Marketplace* market)
|
||||||
market->storeToDb(true);
|
market->storeToDb(true);
|
||||||
|
|
||||||
Json::Value jsonValues;
|
Json::Value jsonValues;
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filePath);
|
||||||
file >> jsonValues;
|
file >> jsonValues;
|
||||||
|
|
||||||
for (auto val : jsonValues["sellers"]) {
|
for (auto val : jsonValues["sellers"]) {
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
#include "marketplace.h"
|
#include "marketplace.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
class JsonUtil
|
class JsonUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void exportSellers(const std::string& filename, Marketplace* market);
|
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 exportSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
||||||
static void importSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
static void importSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include <posprinter.h>
|
#include <posprinter.h>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <regex>
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -399,7 +399,9 @@ void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
JsonUtil::importSellers(filename.toStdString(), marketplace_.get());
|
std::filesystem::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
|
JsonUtil::importSellers(filePath, marketplace_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onExportSellerJsonActionTriggered()
|
void MainWindow::onExportSellerJsonActionTriggered()
|
||||||
|
|
Loading…
Reference in a new issue