json-import: show number of sellers
This commit is contained in:
parent
acc8408b0a
commit
9e2d377195
3 changed files with 19 additions and 4 deletions
|
@ -25,7 +25,7 @@ void JsonUtil::exportSellers(const std::filesystem::path& filePath, Marketplace*
|
||||||
file << root.dump(4) << std::endl;
|
file << root.dump(4) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonUtil::importSellers(const std::filesystem::path& filePath, Marketplace* market)
|
std::size_t 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);
|
||||||
|
@ -56,8 +56,9 @@ void JsonUtil::importSellers(const std::filesystem::path& filePath, Marketplace*
|
||||||
}
|
}
|
||||||
|
|
||||||
market->sortSellers();
|
market->sortSellers();
|
||||||
|
|
||||||
market->storeToDb();
|
market->storeToDb();
|
||||||
|
|
||||||
|
return market->getSellers().size() - 1; // minus 1 because we don't count the "special" seller
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonUtil::exportSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo)
|
void JsonUtil::exportSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo)
|
||||||
|
|
|
@ -10,7 +10,7 @@ class JsonUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void exportSellers(const std::filesystem::path& filePath, Marketplace* market);
|
static void exportSellers(const std::filesystem::path& filePath, Marketplace* market);
|
||||||
static void importSellers(const std::filesystem::path& filePath, Marketplace* market);
|
static std::size_t importSellers(const std::filesystem::path& filePath, Marketplace* market);
|
||||||
static void exportSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo);
|
static void exportSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo);
|
||||||
static void importSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo);
|
static void importSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo);
|
||||||
};
|
};
|
||||||
|
|
|
@ -508,8 +508,18 @@ void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
fs::path filePath(filename.toStdString());
|
fs::path filePath(filename.toStdString());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JsonUtil::importSellers(filePath, marketplace_.get());
|
std::size_t numImported{};
|
||||||
|
numImported = JsonUtil::importSellers(filePath, marketplace_.get());
|
||||||
|
|
||||||
updateStatLabel();
|
updateStatLabel();
|
||||||
|
|
||||||
|
using namespace std::string_literals;
|
||||||
|
std::ostringstream msg;
|
||||||
|
msg << "Aus der JSON-Datei wurden <b>"s << std::to_string(numImported)
|
||||||
|
<< "</b> Verkäufer importiert.";
|
||||||
|
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
|
||||||
|
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
|
||||||
|
.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onExportSellerJsonActionTriggered()
|
void MainWindow::onExportSellerJsonActionTriggered()
|
||||||
|
@ -520,7 +530,11 @@ void MainWindow::onExportSellerJsonActionTriggered()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if defined(_WIN64) || defined(_WIN32)
|
||||||
fs::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
#else
|
||||||
|
fs::path filePath(filename.toStdString());
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonUtil::exportSellers(filePath, marketplace_.get());
|
JsonUtil::exportSellers(filePath, marketplace_.get());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue