diff --git a/CMakeLists.txt b/CMakeLists.txt index d17a094..3d12d32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.8) -project(kima2 VERSION 1.7.1) +project(kima2 VERSION 1.7.0) set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake") diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 4874700..3563d6e 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -138,6 +138,10 @@ MainWindow::MainWindow() }); connect(m_ui.importSellerAction, &QAction::triggered, this, &MainWindow::onImportSellerActionTriggered); + connect(m_ui.importSellerJsonAction, &QAction::triggered, this, + &MainWindow::onImportSellerJsonActionTriggered); + connect(m_ui.exportSellerJsonAction, &QAction::triggered, this, + &MainWindow::onExportSellerJsonActionTriggered); connect(m_ui.exportSalesJsonAction, &QAction::triggered, this, &MainWindow::onExportSalesJsonActionTriggered); connect(m_ui.importSalesJsonAction, &QAction::triggered, this, @@ -479,6 +483,59 @@ void MainWindow::onImportSellerActionTriggered() .exec(); } +void MainWindow::onImportSellerJsonActionTriggered() +{ + if (!m_marketplace->getSales().empty()) { + QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich", + "Der Import ist nicht möglich, da schon Verkäufe getätigt wurden.", + QMessageBox::StandardButton::Ok, this) + .exec(); + return; + } + + auto filename = QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(), + "JSON Dateien (*.json)"); + + if (filename.isEmpty()) + return; + +#if defined(_WIN64) || defined(_WIN32) + fs::path filePath(filename.toStdWString()); +#else + fs::path filePath(filename.toStdString()); +#endif + + std::size_t numImported{}; + numImported = JsonUtil::importSellers(filePath, m_marketplace.get()); + + updateStatLabel(); + + using namespace std::string_literals; + std::ostringstream msg; + msg << "Aus der JSON-Datei wurden "s << std::to_string(numImported) + << " Verkäufer importiert."; + QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert", + msg.str().c_str(), QMessageBox::StandardButton::Ok, this) + .exec(); +} + +void MainWindow::onExportSellerJsonActionTriggered() +{ + auto filename = QFileDialog::getSaveFileName( + this, "Verkäufer exportieren", QString("kima2_verkaeufer.json"), "JSON Dateien (*.json)"); + + if (filename.isEmpty()) + return; + +#if defined(_WIN64) || defined(_WIN32) + fs::path filePath(filename.toStdWString()); +#else + fs::path filePath(filename.toStdString()); +#endif + + JsonUtil::exportSellers(filePath, m_marketplace.get()); +} + void MainWindow::onExportSalesJsonActionTriggered() { QSettings settings; diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 42ac25f..39f8c37 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -40,6 +40,8 @@ class MainWindow : public QMainWindow void onPaidButtonTriggered(); void onGivenSpinBoxValueChanged(double value); void onImportSellerActionTriggered(); + void onImportSellerJsonActionTriggered(); + void onExportSellerJsonActionTriggered(); void onExportSalesJsonActionTriggered(); void onImportSalesJsonActionTriggered(); void setSaleModel(); diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui index 49ba0fc..d409caa 100644 --- a/src/gui/mainwindow.ui +++ b/src/gui/mainwindow.ui @@ -440,8 +440,16 @@ drucken &Verkäufer + + + Importieren + + + + - + + @@ -505,7 +513,7 @@ drucken Exportieren für andere Kasse (JSON) - + Aus CSV-Datei (initial) @@ -540,11 +548,6 @@ drucken Lizenz - - - Importieren (aus CSV-Datei) - -