Adopt to C++20
This commit is contained in:
parent
acc3095e60
commit
2b7c099f5e
3 changed files with 56 additions and 59 deletions
|
@ -4,7 +4,7 @@ project(kima2 VERSION 1.5.3)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake")
|
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
#include(InstallRequiredSystemLibraries)
|
#include(InstallRequiredSystemLibraries)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include "basketmodel.h"
|
#include "basketmodel.h"
|
||||||
#include <config.h>
|
|
||||||
#include "pricedialog.h"
|
#include "pricedialog.h"
|
||||||
#include "reportdialog.h"
|
#include "reportdialog.h"
|
||||||
#include "salemodel.h"
|
#include "salemodel.h"
|
||||||
#include "sellerdialog.h"
|
#include "sellerdialog.h"
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <core/csvreader.h>
|
#include <core/csvreader.h>
|
||||||
#include <core/excelreader.h>
|
#include <core/excelreader.h>
|
||||||
|
@ -40,11 +40,11 @@ MainWindow::MainWindow()
|
||||||
QMessageBox(QMessageBox::Icon::Information, "Datenbankinformation",
|
QMessageBox(QMessageBox::Icon::Information, "Datenbankinformation",
|
||||||
"Es wurde eine <b>veraltete</b> Datenbankdatei erkannt.<br />Diese wurde "
|
"Es wurde eine <b>veraltete</b> Datenbankdatei erkannt.<br />Diese wurde "
|
||||||
"umbenannt und eine <b>neue</b> Datei wurde erstellt.")
|
"umbenannt und eine <b>neue</b> Datei wurde erstellt.")
|
||||||
.exec();
|
.exec();
|
||||||
}
|
}
|
||||||
statusBar()->showMessage("Gespeicherte Daten wurden geladen.", STATUSBAR_TIMEOUT);
|
statusBar()->showMessage("Gespeicherte Daten wurden geladen.", STATUSBAR_TIMEOUT);
|
||||||
|
|
||||||
BasketModel* model = new BasketModel(getMarketplace(), ui_.basketView);
|
BasketModel *model = new BasketModel(getMarketplace(), ui_.basketView);
|
||||||
ui_.basketView->setModel(model);
|
ui_.basketView->setModel(model);
|
||||||
ui_.basketView->setColumnHidden(0, true); // hide the uuid
|
ui_.basketView->setColumnHidden(0, true); // hide the uuid
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ MainWindow::MainWindow()
|
||||||
|
|
||||||
connect(ui_.actionQuit, &QAction::triggered, qApp, QApplication::closeAllWindows,
|
connect(ui_.actionQuit, &QAction::triggered, qApp, QApplication::closeAllWindows,
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
connect(ui_.newAction, &QAction::triggered, this, [=]() {
|
connect(ui_.newAction, &QAction::triggered, this, [this]() {
|
||||||
if (marketplace_->getSellers().size() == 0 && marketplace_->getSales().size() == 0) {
|
if (marketplace_->getSellers().size() == 0 && marketplace_->getSales().size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -63,13 +63,13 @@ MainWindow::MainWindow()
|
||||||
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
||||||
"Möchten Sie wirklich alle gespeicherten Daten verwerfen?",
|
"Möchten Sie wirklich alle gespeicherten Daten verwerfen?",
|
||||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
if (dlgResult == QMessageBox::No)
|
if (dlgResult == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
delete ui_.salesView->model();
|
delete ui_.salesView->model();
|
||||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->cancelSale();
|
dynamic_cast<BasketModel *>(ui_.basketView->model())->cancelSale();
|
||||||
marketplace_->clear();
|
marketplace_->clear();
|
||||||
setSaleModel();
|
setSaleModel();
|
||||||
updateStatLabel();
|
updateStatLabel();
|
||||||
|
@ -105,7 +105,7 @@ MainWindow::MainWindow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(ui_.licenseAction, &QAction::triggered, this, [=]() {
|
connect(ui_.licenseAction, &QAction::triggered, this, [this]() {
|
||||||
QString licenseText(
|
QString licenseText(
|
||||||
"Copyright © 2018-2021 Martin Brodbeck\n\n"
|
"Copyright © 2018-2021 Martin Brodbeck\n\n"
|
||||||
"Hiermit wird unentgeltlich jeder Person, die eine Kopie der Software und der "
|
"Hiermit wird unentgeltlich jeder Person, die eine Kopie der Software und der "
|
||||||
|
@ -126,10 +126,8 @@ 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, [=]() {
|
connect(ui_.reportAction, &QAction::triggered, this, [this]() { ReportDialog(this).exec(); });
|
||||||
ReportDialog(this).exec();
|
connect(ui_.configAction, &QAction::triggered, this, [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) {
|
||||||
delete ui_.salesView->model();
|
delete ui_.salesView->model();
|
||||||
|
@ -189,8 +187,8 @@ void MainWindow::setSaleModel()
|
||||||
ui_.printSaleReceiptButton->setEnabled(false);
|
ui_.printSaleReceiptButton->setEnabled(false);
|
||||||
ui_.cancelSaleButton->setEnabled(false);
|
ui_.cancelSaleButton->setEnabled(false);
|
||||||
|
|
||||||
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
connect(static_cast<BasketModel *>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
||||||
static_cast<SaleModel*>(ui_.salesView->model()), &SaleModel::onBasketDataChanged);
|
static_cast<SaleModel *>(ui_.salesView->model()), &SaleModel::onBasketDataChanged);
|
||||||
connect(ui_.salesView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
connect(ui_.salesView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||||
&MainWindow::onSalesViewSelectionChanged);
|
&MainWindow::onSalesViewSelectionChanged);
|
||||||
}
|
}
|
||||||
|
@ -199,7 +197,7 @@ void MainWindow::onPaidButtonTriggered()
|
||||||
{
|
{
|
||||||
if (marketplace_->basketSize() > 0) {
|
if (marketplace_->basketSize() > 0) {
|
||||||
QString lastPrice{marketplace_->getBasketSumAsString().c_str()};
|
QString lastPrice{marketplace_->getBasketSumAsString().c_str()};
|
||||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->finishSale();
|
dynamic_cast<BasketModel *>(ui_.basketView->model())->finishSale();
|
||||||
ui_.salesView->resizeColumnToContents(0);
|
ui_.salesView->resizeColumnToContents(0);
|
||||||
ui_.lastPriceLabel1->setText(lastPrice);
|
ui_.lastPriceLabel1->setText(lastPrice);
|
||||||
ui_.lastPriceLabel2->setText(lastPrice);
|
ui_.lastPriceLabel2->setText(lastPrice);
|
||||||
|
@ -212,11 +210,11 @@ void MainWindow::onPaidButtonTriggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::eventFilter(QObject* target, QEvent* event)
|
bool MainWindow::eventFilter(QObject *target, QEvent *event)
|
||||||
{
|
{
|
||||||
if (target == ui_.sellerNoEdit) {
|
if (target == ui_.sellerNoEdit) {
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
if (keyEvent->key() == Qt::Key::Key_Enter || keyEvent->key() == Qt::Key::Key_Return) {
|
if (keyEvent->key() == Qt::Key::Key_Enter || keyEvent->key() == Qt::Key::Key_Return) {
|
||||||
if (keyEvent->modifiers() & Qt::ControlModifier) {
|
if (keyEvent->modifiers() & Qt::ControlModifier) {
|
||||||
checkSellerNo(true);
|
checkSellerNo(true);
|
||||||
|
@ -229,7 +227,7 @@ bool MainWindow::eventFilter(QObject* target, QEvent* event)
|
||||||
}
|
}
|
||||||
} else if (target == ui_.givenSpinBox) {
|
} else if (target == ui_.givenSpinBox) {
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
if (keyEvent->key() == Qt::Key::Key_Enter || keyEvent->key() == Qt::Key::Key_Return) {
|
if (keyEvent->key() == Qt::Key::Key_Enter || keyEvent->key() == Qt::Key::Key_Return) {
|
||||||
if (keyEvent->modifiers() & Qt::ControlModifier) {
|
if (keyEvent->modifiers() & Qt::ControlModifier) {
|
||||||
onPaidButtonTriggered();
|
onPaidButtonTriggered();
|
||||||
|
@ -282,7 +280,7 @@ void MainWindow::checkSellerNo(bool ctrlPressed)
|
||||||
if (dialogResult == QDialog::Accepted) {
|
if (dialogResult == QDialog::Accepted) {
|
||||||
int price = priceDialog.getPrice();
|
int price = priceDialog.getPrice();
|
||||||
std::string desc = priceDialog.getDescription();
|
std::string desc = priceDialog.getDescription();
|
||||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->addArticle(seller, price, desc);
|
dynamic_cast<BasketModel *>(ui_.basketView->model())->addArticle(seller, price, desc);
|
||||||
ui_.basketView->resizeColumnToContents(1);
|
ui_.basketView->resizeColumnToContents(1);
|
||||||
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str());
|
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str());
|
||||||
}
|
}
|
||||||
|
@ -299,8 +297,8 @@ void MainWindow::onGivenSpinBoxValueChanged(double value)
|
||||||
ui_.drawbackLabel->setText(formatCentAsEuroString(drawback).c_str());
|
ui_.drawbackLabel->setText(formatCentAsEuroString(drawback).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onBasketViewSelectionChanged(const QItemSelection& selected,
|
void MainWindow::onBasketViewSelectionChanged(const QItemSelection &selected,
|
||||||
[[maybe_unused]] const QItemSelection& deselected)
|
[[maybe_unused]] const QItemSelection &deselected)
|
||||||
{
|
{
|
||||||
if (selected.size() > 0) {
|
if (selected.size() > 0) {
|
||||||
ui_.cancelArticleButton->setEnabled(true);
|
ui_.cancelArticleButton->setEnabled(true);
|
||||||
|
@ -309,8 +307,8 @@ void MainWindow::onBasketViewSelectionChanged(const QItemSelection& selected,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onSalesViewSelectionChanged(const QItemSelection& selected,
|
void MainWindow::onSalesViewSelectionChanged(const QItemSelection &selected,
|
||||||
[[maybe_unused]] const QItemSelection& deselected)
|
[[maybe_unused]] const QItemSelection &deselected)
|
||||||
{
|
{
|
||||||
if (selected.size() > 0) {
|
if (selected.size() > 0) {
|
||||||
ui_.cancelSaleButton->setEnabled(true);
|
ui_.cancelSaleButton->setEnabled(true);
|
||||||
|
@ -335,7 +333,7 @@ void MainWindow::onCancelArticleButtonClicked([[maybe_unused]] bool checked)
|
||||||
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
||||||
"Möchten Sie wirklich den Artikel stornieren?",
|
"Möchten Sie wirklich den Artikel stornieren?",
|
||||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
||||||
.exec();
|
.exec();
|
||||||
if (dlgResult == QMessageBox::No)
|
if (dlgResult == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -361,7 +359,7 @@ void MainWindow::onCancelSaleButtonClicked([[maybe_unused]] bool checked)
|
||||||
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
||||||
"Möchten Sie wirklich aus abgeschlossenen Verkäufen stornieren?",
|
"Möchten Sie wirklich aus abgeschlossenen Verkäufen stornieren?",
|
||||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
||||||
.exec();
|
.exec();
|
||||||
if (dlgResult == QMessageBox::No)
|
if (dlgResult == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -397,7 +395,7 @@ void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
|
||||||
QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint", "").toString();
|
QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint", "").toString();
|
||||||
|
|
||||||
auto indexes = selModel->selectedRows();
|
auto indexes = selModel->selectedRows();
|
||||||
auto& sale = marketplace_->getSales().at(indexes[0].row());
|
auto &sale = marketplace_->getSales().at(indexes[0].row());
|
||||||
|
|
||||||
auto printerDevice =
|
auto printerDevice =
|
||||||
convertToPosPrinterDevice(posPrinterDevice.toStdString(), posPrinterEndpoint.toStdString());
|
convertToPosPrinterDevice(posPrinterDevice.toStdString(), posPrinterEndpoint.toStdString());
|
||||||
|
@ -424,29 +422,27 @@ void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
||||||
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
||||||
"Möchten Sie wirklich *alle* Artikel des aktuellen Einkaufs stornieren?",
|
"Möchten Sie wirklich *alle* Artikel des aktuellen Einkaufs stornieren?",
|
||||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
|
||||||
.exec();
|
.exec();
|
||||||
if (dlgResult == QMessageBox::No)
|
if (dlgResult == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->cancelSale();
|
dynamic_cast<BasketModel *>(ui_.basketView->model())->cancelSale();
|
||||||
|
|
||||||
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str()); // Update basket sum
|
ui_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str()); // Update basket sum
|
||||||
ui_.sellerNoEdit->setFocus();
|
ui_.sellerNoEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAboutQt() {
|
void MainWindow::onAboutQt() { QMessageBox::aboutQt(this); }
|
||||||
QMessageBox::aboutQt(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onAbout()
|
void MainWindow::onAbout()
|
||||||
{
|
{
|
||||||
QMessageBox::about(
|
QMessageBox::about(
|
||||||
this, "Über",
|
this, "Über",
|
||||||
QString("<p style='text-align:center;'><b>KIMA2</b> - Version ") + PROJECT_VERSION +
|
QString("<p style='text-align:center;'><b>KIMA2</b> - Version ") + PROJECT_VERSION +
|
||||||
"</p>"
|
"</p>"
|
||||||
"<p>KIMA2 ist ein kleines Kassenprogramm für Kindersachenmärkte.<p />"
|
"<p>KIMA2 ist ein kleines Kassenprogramm für Kindersachenmärkte.<p />"
|
||||||
"<p>Copyright © Martin Brodbeck <<a href=mailto:martin@brodbeck-online.de"
|
"<p>Copyright © Martin Brodbeck <<a href=mailto:martin@brodbeck-online.de"
|
||||||
">info@rustysoft.de</a>></p>");
|
">info@rustysoft.de</a>></p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onImportSellerExcelActionTriggered()
|
void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
|
@ -455,13 +451,13 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich",
|
QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich",
|
||||||
"Der Import ist nicht möglich, da schon Verkäufe getätigt wurden.",
|
"Der Import ist nicht möglich, da schon Verkäufe getätigt wurden.",
|
||||||
QMessageBox::StandardButton::Ok, this)
|
QMessageBox::StandardButton::Ok, this)
|
||||||
.exec();
|
.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto filename = QFileDialog::getOpenFileName(
|
auto filename = QFileDialog::getOpenFileName(
|
||||||
this, "Verkäufer importieren", QString(),
|
this, "Verkäufer importieren", QString(),
|
||||||
"Alle unterstützte Dateien (*.xlsx *.csv);;Excel Dateien (*.xlsx);;CSV Dateien (*.csv)");
|
"Alle unterstützte Dateien (*.xlsx *.csv);;Excel Dateien (*.xlsx);;CSV Dateien (*.csv)");
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -476,11 +472,12 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
if (case_insensitive_match(filePath.extension().string(), std::string(".xlsx"))) {
|
if (case_insensitive_match(filePath.extension().string(), std::string(".xlsx"))) {
|
||||||
try {
|
try {
|
||||||
numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception &e) {
|
||||||
QMessageBox(QMessageBox::Icon::Critical, "Fehler beim Importieren",
|
QMessageBox(QMessageBox::Icon::Critical, "Fehler beim Importieren",
|
||||||
"Beim Import aus der Excel-Datei ist ein Fehler aufgetreten. "
|
"Beim Import aus der Excel-Datei ist ein Fehler aufgetreten. "
|
||||||
"Sie könnten ggf. versuchen, die Daten aus einer .csv Datei zu imporieren.",
|
"Sie könnten ggf. versuchen, die Daten aus einer .csv Datei zu imporieren.",
|
||||||
QMessageBox::StandardButton::Ok, this).exec();
|
QMessageBox::StandardButton::Ok, this)
|
||||||
|
.exec();
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +493,7 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
<< "</b> Verkäufer importiert.";
|
<< "</b> Verkäufer importiert.";
|
||||||
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
|
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
|
||||||
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
|
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
|
||||||
.exec();
|
.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onImportSellerJsonActionTriggered()
|
void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
|
@ -505,12 +502,12 @@ void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich",
|
QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich",
|
||||||
"Der Import ist nicht möglich, da schon Verkäufe getätigt wurden.",
|
"Der Import ist nicht möglich, da schon Verkäufe getätigt wurden.",
|
||||||
QMessageBox::StandardButton::Ok, this)
|
QMessageBox::StandardButton::Ok, this)
|
||||||
.exec();
|
.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto filename = QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(),
|
auto filename = QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(),
|
||||||
"JSON Dateien (*.json)");
|
"JSON Dateien (*.json)");
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -532,13 +529,13 @@ void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
<< "</b> Verkäufer importiert.";
|
<< "</b> Verkäufer importiert.";
|
||||||
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
|
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
|
||||||
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
|
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
|
||||||
.exec();
|
.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onExportSellerJsonActionTriggered()
|
void MainWindow::onExportSellerJsonActionTriggered()
|
||||||
{
|
{
|
||||||
auto filename = QFileDialog::getSaveFileName(
|
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())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -557,9 +554,9 @@ void MainWindow::onExportSalesJsonActionTriggered()
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
auto filename = QFileDialog::getSaveFileName(
|
auto filename = QFileDialog::getSaveFileName(
|
||||||
this, "Umsätze/Transaktionen exportieren",
|
this, "Umsätze/Transaktionen exportieren",
|
||||||
QString("kima2_umsaetze_kasse") + settings.value("global/cashPointNo").toString() + ".json",
|
QString("kima2_umsaetze_kasse") + settings.value("global/cashPointNo").toString() + ".json",
|
||||||
"JSON Dateien (*.json)");
|
"JSON Dateien (*.json)");
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -579,7 +576,7 @@ void MainWindow::onImportSalesJsonActionTriggered()
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
auto filename = QFileDialog::getOpenFileName(this, "Umsätze/Transaktionen importieren",
|
auto filename = QFileDialog::getOpenFileName(this, "Umsätze/Transaktionen importieren",
|
||||||
QString(), "JSON Dateien (*.json)");
|
QString(), "JSON Dateien (*.json)");
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -594,10 +591,10 @@ void MainWindow::onImportSalesJsonActionTriggered()
|
||||||
try {
|
try {
|
||||||
JsonUtil::importSales(filePath, marketplace_.get(),
|
JsonUtil::importSales(filePath, marketplace_.get(),
|
||||||
settings.value("global/cashPointNo").toInt());
|
settings.value("global/cashPointNo").toInt());
|
||||||
} catch (std::runtime_error& err) {
|
} catch (std::runtime_error &err) {
|
||||||
QMessageBox(QMessageBox::Icon::Warning, "Import nicht möglich", err.what(), QMessageBox::Ok,
|
QMessageBox(QMessageBox::Icon::Warning, "Import nicht möglich", err.what(), QMessageBox::Ok,
|
||||||
this)
|
this)
|
||||||
.exec();
|
.exec();
|
||||||
}
|
}
|
||||||
setSaleModel();
|
setSaleModel();
|
||||||
updateStatLabel();
|
updateStatLabel();
|
||||||
|
@ -623,7 +620,7 @@ void MainWindow::readGeometry()
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
writeGeometry();
|
writeGeometry();
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <core/database.h>
|
#include <core/database.h>
|
||||||
|
#include <core/utils.h>
|
||||||
#include <printer/posprinter.h>
|
#include <printer/posprinter.h>
|
||||||
#include <printer/utils.h>
|
#include <printer/utils.h>
|
||||||
#include <core/utils.h>
|
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
|
SettingsDialog::SettingsDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
|
||||||
{
|
{
|
||||||
ui_.setupUi(this);
|
ui_.setupUi(this);
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
||||||
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
market_ = dynamic_cast<MainWindow *>(parent)->getMarketplace();
|
||||||
|
|
||||||
ui_.cashPointNoSpinBox->setValue(cashPointNo);
|
ui_.cashPointNoSpinBox->setValue(cashPointNo);
|
||||||
ui_.communeEdit->setText(commune);
|
ui_.communeEdit->setText(commune);
|
||||||
|
@ -35,7 +35,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
||||||
ui_.feePercentSpinBox->setValue(feeInPercent);
|
ui_.feePercentSpinBox->setValue(feeInPercent);
|
||||||
ui_.maxFeeSpinBox->setValue(maxFeeInEuro);
|
ui_.maxFeeSpinBox->setValue(maxFeeInEuro);
|
||||||
|
|
||||||
connect(ui_.testPosPrinterButton, &QPushButton::clicked, this, [=]() {
|
connect(ui_.testPosPrinterButton, &QPushButton::clicked, this, [this]() {
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
try {
|
try {
|
||||||
if (ui_.posPrinterDeviceEdit->text().isEmpty()) {
|
if (ui_.posPrinterDeviceEdit->text().isEmpty()) {
|
||||||
|
@ -55,7 +55,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
||||||
printer.printTest();
|
printer.printTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (std::exception&) {
|
} catch (std::exception &) {
|
||||||
QMessageBox(QMessageBox::Icon::Warning, "Falsche Eingabe",
|
QMessageBox(QMessageBox::Icon::Warning, "Falsche Eingabe",
|
||||||
QString("Eingabeformat für Device (hexadezimale IDs): "
|
QString("Eingabeformat für Device (hexadezimale IDs): "
|
||||||
"<VendorID>:<ProductID>\nBeispiel: 0416:5011\n "
|
"<VendorID>:<ProductID>\nBeispiel: 0416:5011\n "
|
||||||
|
@ -65,7 +65,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (std::runtime_error& err) {
|
} catch (std::runtime_error &err) {
|
||||||
QMessageBox(QMessageBox::Icon::Warning, "Bondrucker Fehler",
|
QMessageBox(QMessageBox::Icon::Warning, "Bondrucker Fehler",
|
||||||
QString("Test schlug fehl: ") + err.what(), QMessageBox::StandardButton::Ok,
|
QString("Test schlug fehl: ") + err.what(), QMessageBox::StandardButton::Ok,
|
||||||
this)
|
this)
|
||||||
|
@ -103,7 +103,7 @@ void SettingsDialog::accept()
|
||||||
if (result == QMessageBox::Yes) {
|
if (result == QMessageBox::Yes) {
|
||||||
try {
|
try {
|
||||||
Database().updateCashPointNo(oldCashPointNo, newCashPointNo);
|
Database().updateCashPointNo(oldCashPointNo, newCashPointNo);
|
||||||
} catch (std::exception& ex) {
|
} catch (std::exception &ex) {
|
||||||
std::string errMsg("Das Ändern der Kassen-Nr. ist fehlgeschlagen: ");
|
std::string errMsg("Das Ändern der Kassen-Nr. ist fehlgeschlagen: ");
|
||||||
errMsg.append(ex.what());
|
errMsg.append(ex.what());
|
||||||
QMessageBox(QMessageBox::Icon::Critical, "Fehler", errMsg.c_str(),
|
QMessageBox(QMessageBox::Icon::Critical, "Fehler", errMsg.c_str(),
|
||||||
|
|
Loading…
Reference in a new issue