Added warning message when Excel import fails.

This commit is contained in:
Martin Brodbeck 2020-10-15 16:43:00 +02:00
parent 9e6e2eb936
commit a156c5331a

View file

@ -126,7 +126,9 @@ MainWindow::MainWindow()
"SOFTWARE ODER SONSTIGER VERWENDUNG DER SOFTWARE ENTSTANDEN."); "SOFTWARE ODER SONSTIGER VERWENDUNG DER SOFTWARE ENTSTANDEN.");
QMessageBox::information(this, "Lizenzinformation", licenseText); 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, [=]() { connect(ui_.configAction, &QAction::triggered, this, [=]() {
int result = SettingsDialog(this).exec(); int result = SettingsDialog(this).exec();
if (result == QDialog::Accepted) { if (result == QDialog::Accepted) {
@ -432,7 +434,9 @@ void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
ui_.sellerNoEdit->setFocus(); ui_.sellerNoEdit->setFocus();
} }
void MainWindow::onAboutQt() { QMessageBox::aboutQt(this); } void MainWindow::onAboutQt() {
QMessageBox::aboutQt(this);
}
void MainWindow::onAbout() void MainWindow::onAbout()
{ {
@ -470,7 +474,16 @@ void MainWindow::onImportSellerExcelActionTriggered()
std::size_t numImported{}; std::size_t numImported{};
if (case_insensitive_match(filePath.extension().string(), std::string(".xlsx"))) { if (case_insensitive_match(filePath.extension().string(), std::string(".xlsx"))) {
try {
numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get()); 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 { } else {
numImported = CsvReader::readSellersFromFile(filePath, marketplace_.get()); numImported = CsvReader::readSellersFromFile(filePath, marketplace_.get());
} }