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);
|
||||
}
|
||||
|
||||
void JsonUtil::importSellers(const std::string& filename, Marketplace* market)
|
||||
void JsonUtil::importSellers(const std::filesystem::path& filePath, Marketplace* market)
|
||||
{
|
||||
for (auto& seller : market->getSellers()) {
|
||||
seller->setState(Seller::State::DELETE);
|
||||
|
@ -37,7 +37,7 @@ void JsonUtil::importSellers(const std::string& filename, Marketplace* market)
|
|||
market->storeToDb(true);
|
||||
|
||||
Json::Value jsonValues;
|
||||
std::ifstream file(filename);
|
||||
std::ifstream file(filePath);
|
||||
file >> jsonValues;
|
||||
|
||||
for (auto val : jsonValues["sellers"]) {
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
#include "marketplace.h"
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
class JsonUtil
|
||||
{
|
||||
public:
|
||||
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 importSales(const std::string& filename, Marketplace* market, int cashPointNo);
|
||||
};
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include <posprinter.h>
|
||||
|
||||
#include <exception>
|
||||
#include <regex>
|
||||
#include <filesystem>
|
||||
#include <regex>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
@ -399,7 +399,9 @@ void MainWindow::onImportSellerJsonActionTriggered()
|
|||
if (filename.isEmpty())
|
||||
return;
|
||||
|
||||
JsonUtil::importSellers(filename.toStdString(), marketplace_.get());
|
||||
std::filesystem::path filePath(filename.toStdWString());
|
||||
|
||||
JsonUtil::importSellers(filePath, marketplace_.get());
|
||||
}
|
||||
|
||||
void MainWindow::onExportSellerJsonActionTriggered()
|
||||
|
|
Loading…
Reference in a new issue