diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index e3c6683..1cf383c 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -40,7 +40,7 @@ MainWindow::MainWindow() QMessageBox(QMessageBox::Icon::Information, "Datenbankinformation", "Es wurde eine veraltete Datenbankdatei erkannt.
Diese wurde " "umbenannt und eine neue Datei wurde erstellt.") - .exec(); + .exec(); } statusBar()->showMessage("Gespeicherte Daten wurden geladen.", STATUSBAR_TIMEOUT); @@ -63,7 +63,7 @@ MainWindow::MainWindow() QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?", "Möchten Sie wirklich alle gespeicherten Daten verwerfen?", QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this) - .exec(); + .exec(); if (dlgResult == QMessageBox::No) return; @@ -126,7 +126,9 @@ MainWindow::MainWindow() "SOFTWARE ODER SONSTIGER VERWENDUNG DER SOFTWARE ENTSTANDEN."); QMessageBox::information(this, "Lizenzinformation", licenseText); }); - connect(ui_.reportAction, &QAction::triggered, this, [=]() { ReportDialog(this).exec(); }); + connect(ui_.reportAction, &QAction::triggered, this, [=]() { + ReportDialog(this).exec(); + }); connect(ui_.configAction, &QAction::triggered, this, [=]() { int result = SettingsDialog(this).exec(); if (result == QDialog::Accepted) { @@ -298,7 +300,7 @@ void MainWindow::onGivenSpinBoxValueChanged(double value) } void MainWindow::onBasketViewSelectionChanged(const QItemSelection& selected, - [[maybe_unused]] const QItemSelection& deselected) + [[maybe_unused]] const QItemSelection& deselected) { if (selected.size() > 0) { ui_.cancelArticleButton->setEnabled(true); @@ -308,7 +310,7 @@ void MainWindow::onBasketViewSelectionChanged(const QItemSelection& selected, } void MainWindow::onSalesViewSelectionChanged(const QItemSelection& selected, - [[maybe_unused]] const QItemSelection& deselected) + [[maybe_unused]] const QItemSelection& deselected) { if (selected.size() > 0) { ui_.cancelSaleButton->setEnabled(true); @@ -333,7 +335,7 @@ void MainWindow::onCancelArticleButtonClicked([[maybe_unused]] bool checked) QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?", "Möchten Sie wirklich den Artikel stornieren?", QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this) - .exec(); + .exec(); if (dlgResult == QMessageBox::No) return; @@ -359,7 +361,7 @@ void MainWindow::onCancelSaleButtonClicked([[maybe_unused]] bool checked) QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?", "Möchten Sie wirklich aus abgeschlossenen Verkäufen stornieren?", QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this) - .exec(); + .exec(); if (dlgResult == QMessageBox::No) return; @@ -422,7 +424,7 @@ void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked) QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?", "Möchten Sie wirklich *alle* Artikel des aktuellen Einkaufs stornieren?", QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this) - .exec(); + .exec(); if (dlgResult == QMessageBox::No) return; @@ -432,17 +434,19 @@ void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked) ui_.sellerNoEdit->setFocus(); } -void MainWindow::onAboutQt() { QMessageBox::aboutQt(this); } +void MainWindow::onAboutQt() { + QMessageBox::aboutQt(this); +} void MainWindow::onAbout() { QMessageBox::about( this, "Über", QString("

KIMA2 - Version ") + PROJECT_VERSION + - "

" - "

KIMA2 ist ein kleines Kassenprogramm für Kindersachenmärkte.

" - "

Copyright © Martin Brodbeck <info@rustysoft.de>

"); + "

" + "

KIMA2 ist ein kleines Kassenprogramm für Kindersachenmärkte.

" + "

Copyright © Martin Brodbeck <info@rustysoft.de>

"); } void MainWindow::onImportSellerExcelActionTriggered() @@ -451,13 +455,13 @@ void MainWindow::onImportSellerExcelActionTriggered() 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(); + .exec(); return; } auto filename = QFileDialog::getOpenFileName( - this, "Verkäufer importieren", QString(), - "Alle unterstützte Dateien (*.xlsx *.csv);;Excel Dateien (*.xlsx);;CSV Dateien (*.csv)"); + this, "Verkäufer importieren", QString(), + "Alle unterstützte Dateien (*.xlsx *.csv);;Excel Dateien (*.xlsx);;CSV Dateien (*.csv)"); if (filename.isEmpty()) return; @@ -470,7 +474,16 @@ void MainWindow::onImportSellerExcelActionTriggered() std::size_t numImported{}; if (case_insensitive_match(filePath.extension().string(), std::string(".xlsx"))) { - numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get()); + try { + numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get()); + } catch (const std::exception& e) { + QMessageBox(QMessageBox::Icon::Critical, "Fehler beim Importieren", + "Beim Import aus der Excel-Datei ist ein Fehler aufgetreten. " + "Sie könnten ggf. versuchen, die Daten aus einer .csv Datei zu imporieren.", + QMessageBox::StandardButton::Ok, this).exec(); + std::cerr << e.what() << std::endl; + return; + } } else { numImported = CsvReader::readSellersFromFile(filePath, marketplace_.get()); } @@ -483,7 +496,7 @@ void MainWindow::onImportSellerExcelActionTriggered() << " Verkäufer importiert."; QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert", msg.str().c_str(), QMessageBox::StandardButton::Ok, this) - .exec(); + .exec(); } void MainWindow::onImportSellerJsonActionTriggered() @@ -492,12 +505,12 @@ void MainWindow::onImportSellerJsonActionTriggered() 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(); + .exec(); return; } auto filename = QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(), - "JSON Dateien (*.json)"); + "JSON Dateien (*.json)"); if (filename.isEmpty()) return; @@ -519,13 +532,13 @@ void MainWindow::onImportSellerJsonActionTriggered() << " Verkäufer importiert."; QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert", msg.str().c_str(), QMessageBox::StandardButton::Ok, this) - .exec(); + .exec(); } void MainWindow::onExportSellerJsonActionTriggered() { auto filename = QFileDialog::getSaveFileName( - this, "Verkäufer exportieren", QString("kima2_verkaeufer.json"), "JSON Dateien (*.json)"); + this, "Verkäufer exportieren", QString("kima2_verkaeufer.json"), "JSON Dateien (*.json)"); if (filename.isEmpty()) return; @@ -544,9 +557,9 @@ void MainWindow::onExportSalesJsonActionTriggered() QSettings settings; auto filename = QFileDialog::getSaveFileName( - this, "Umsätze/Transaktionen exportieren", - QString("kima2_umsaetze_kasse") + settings.value("global/cashPointNo").toString() + ".json", - "JSON Dateien (*.json)"); + this, "Umsätze/Transaktionen exportieren", + QString("kima2_umsaetze_kasse") + settings.value("global/cashPointNo").toString() + ".json", + "JSON Dateien (*.json)"); if (filename.isEmpty()) return; @@ -566,7 +579,7 @@ void MainWindow::onImportSalesJsonActionTriggered() QSettings settings; auto filename = QFileDialog::getOpenFileName(this, "Umsätze/Transaktionen importieren", - QString(), "JSON Dateien (*.json)"); + QString(), "JSON Dateien (*.json)"); if (filename.isEmpty()) return; @@ -584,7 +597,7 @@ void MainWindow::onImportSalesJsonActionTriggered() } catch (std::runtime_error& err) { QMessageBox(QMessageBox::Icon::Warning, "Import nicht möglich", err.what(), QMessageBox::Ok, this) - .exec(); + .exec(); } setSaleModel(); updateStatLabel();