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_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
#include(InstallRequiredSystemLibraries)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include "basketmodel.h"
|
||||
#include <config.h>
|
||||
#include "pricedialog.h"
|
||||
#include "reportdialog.h"
|
||||
#include "salemodel.h"
|
||||
#include "sellerdialog.h"
|
||||
#include "settingsdialog.h"
|
||||
#include <config.h>
|
||||
|
||||
#include <core/csvreader.h>
|
||||
#include <core/excelreader.h>
|
||||
|
@ -40,11 +40,11 @@ MainWindow::MainWindow()
|
|||
QMessageBox(QMessageBox::Icon::Information, "Datenbankinformation",
|
||||
"Es wurde eine <b>veraltete</b> Datenbankdatei erkannt.<br />Diese wurde "
|
||||
"umbenannt und eine <b>neue</b> Datei wurde erstellt.")
|
||||
.exec();
|
||||
.exec();
|
||||
}
|
||||
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->setColumnHidden(0, true); // hide the uuid
|
||||
|
||||
|
@ -55,7 +55,7 @@ MainWindow::MainWindow()
|
|||
|
||||
connect(ui_.actionQuit, &QAction::triggered, qApp, QApplication::closeAllWindows,
|
||||
Qt::QueuedConnection);
|
||||
connect(ui_.newAction, &QAction::triggered, this, [=]() {
|
||||
connect(ui_.newAction, &QAction::triggered, this, [this]() {
|
||||
if (marketplace_->getSellers().size() == 0 && marketplace_->getSales().size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -63,13 +63,13 @@ 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;
|
||||
|
||||
delete ui_.salesView->model();
|
||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->cancelSale();
|
||||
dynamic_cast<BasketModel *>(ui_.basketView->model())->cancelSale();
|
||||
marketplace_->clear();
|
||||
setSaleModel();
|
||||
updateStatLabel();
|
||||
|
@ -105,7 +105,7 @@ MainWindow::MainWindow()
|
|||
}
|
||||
}
|
||||
});
|
||||
connect(ui_.licenseAction, &QAction::triggered, this, [=]() {
|
||||
connect(ui_.licenseAction, &QAction::triggered, this, [this]() {
|
||||
QString licenseText(
|
||||
"Copyright © 2018-2021 Martin Brodbeck\n\n"
|
||||
"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.");
|
||||
QMessageBox::information(this, "Lizenzinformation", licenseText);
|
||||
});
|
||||
connect(ui_.reportAction, &QAction::triggered, this, [=]() {
|
||||
ReportDialog(this).exec();
|
||||
});
|
||||
connect(ui_.configAction, &QAction::triggered, this, [=]() {
|
||||
connect(ui_.reportAction, &QAction::triggered, this, [this]() { ReportDialog(this).exec(); });
|
||||
connect(ui_.configAction, &QAction::triggered, this, [this]() {
|
||||
int result = SettingsDialog(this).exec();
|
||||
if (result == QDialog::Accepted) {
|
||||
delete ui_.salesView->model();
|
||||
|
@ -189,8 +187,8 @@ void MainWindow::setSaleModel()
|
|||
ui_.printSaleReceiptButton->setEnabled(false);
|
||||
ui_.cancelSaleButton->setEnabled(false);
|
||||
|
||||
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
||||
static_cast<SaleModel*>(ui_.salesView->model()), &SaleModel::onBasketDataChanged);
|
||||
connect(static_cast<BasketModel *>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
||||
static_cast<SaleModel *>(ui_.salesView->model()), &SaleModel::onBasketDataChanged);
|
||||
connect(ui_.salesView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&MainWindow::onSalesViewSelectionChanged);
|
||||
}
|
||||
|
@ -199,7 +197,7 @@ void MainWindow::onPaidButtonTriggered()
|
|||
{
|
||||
if (marketplace_->basketSize() > 0) {
|
||||
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_.lastPriceLabel1->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 (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->modifiers() & Qt::ControlModifier) {
|
||||
checkSellerNo(true);
|
||||
|
@ -229,7 +227,7 @@ bool MainWindow::eventFilter(QObject* target, QEvent* event)
|
|||
}
|
||||
} else if (target == ui_.givenSpinBox) {
|
||||
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->modifiers() & Qt::ControlModifier) {
|
||||
onPaidButtonTriggered();
|
||||
|
@ -282,7 +280,7 @@ void MainWindow::checkSellerNo(bool ctrlPressed)
|
|||
if (dialogResult == QDialog::Accepted) {
|
||||
int price = priceDialog.getPrice();
|
||||
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_.basketSumLabel->setText(marketplace_->getBasketSumAsString().c_str());
|
||||
}
|
||||
|
@ -299,8 +297,8 @@ void MainWindow::onGivenSpinBoxValueChanged(double value)
|
|||
ui_.drawbackLabel->setText(formatCentAsEuroString(drawback).c_str());
|
||||
}
|
||||
|
||||
void MainWindow::onBasketViewSelectionChanged(const QItemSelection& selected,
|
||||
[[maybe_unused]] const QItemSelection& deselected)
|
||||
void MainWindow::onBasketViewSelectionChanged(const QItemSelection &selected,
|
||||
[[maybe_unused]] const QItemSelection &deselected)
|
||||
{
|
||||
if (selected.size() > 0) {
|
||||
ui_.cancelArticleButton->setEnabled(true);
|
||||
|
@ -309,8 +307,8 @@ void MainWindow::onBasketViewSelectionChanged(const QItemSelection& selected,
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::onSalesViewSelectionChanged(const QItemSelection& selected,
|
||||
[[maybe_unused]] const QItemSelection& deselected)
|
||||
void MainWindow::onSalesViewSelectionChanged(const QItemSelection &selected,
|
||||
[[maybe_unused]] const QItemSelection &deselected)
|
||||
{
|
||||
if (selected.size() > 0) {
|
||||
ui_.cancelSaleButton->setEnabled(true);
|
||||
|
@ -335,7 +333,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;
|
||||
|
||||
|
@ -361,7 +359,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;
|
||||
|
||||
|
@ -397,7 +395,7 @@ void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
|
|||
QString posPrinterEndpoint = settings.value("global/posPrinterEndpoint", "").toString();
|
||||
|
||||
auto indexes = selModel->selectedRows();
|
||||
auto& sale = marketplace_->getSales().at(indexes[0].row());
|
||||
auto &sale = marketplace_->getSales().at(indexes[0].row());
|
||||
|
||||
auto printerDevice =
|
||||
convertToPosPrinterDevice(posPrinterDevice.toStdString(), posPrinterEndpoint.toStdString());
|
||||
|
@ -424,29 +422,27 @@ 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;
|
||||
|
||||
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_.sellerNoEdit->setFocus();
|
||||
}
|
||||
|
||||
void MainWindow::onAboutQt() {
|
||||
QMessageBox::aboutQt(this);
|
||||
}
|
||||
void MainWindow::onAboutQt() { QMessageBox::aboutQt(this); }
|
||||
|
||||
void MainWindow::onAbout()
|
||||
{
|
||||
QMessageBox::about(
|
||||
this, "Über",
|
||||
QString("<p style='text-align:center;'><b>KIMA2</b> - Version ") + PROJECT_VERSION +
|
||||
"</p>"
|
||||
"<p>KIMA2 ist ein kleines Kassenprogramm für Kindersachenmärkte.<p />"
|
||||
"<p>Copyright © Martin Brodbeck <<a href=mailto:martin@brodbeck-online.de"
|
||||
">info@rustysoft.de</a>></p>");
|
||||
"</p>"
|
||||
"<p>KIMA2 ist ein kleines Kassenprogramm für Kindersachenmärkte.<p />"
|
||||
"<p>Copyright © Martin Brodbeck <<a href=mailto:martin@brodbeck-online.de"
|
||||
">info@rustysoft.de</a>></p>");
|
||||
}
|
||||
|
||||
void MainWindow::onImportSellerExcelActionTriggered()
|
||||
|
@ -455,13 +451,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;
|
||||
|
@ -476,11 +472,12 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
|||
if (case_insensitive_match(filePath.extension().string(), std::string(".xlsx"))) {
|
||||
try {
|
||||
numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
||||
} catch (const std::exception& e) {
|
||||
} 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();
|
||||
QMessageBox::StandardButton::Ok, this)
|
||||
.exec();
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
@ -496,7 +493,7 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
|||
<< "</b> Verkäufer importiert.";
|
||||
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
|
||||
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
|
||||
.exec();
|
||||
.exec();
|
||||
}
|
||||
|
||||
void MainWindow::onImportSellerJsonActionTriggered()
|
||||
|
@ -505,12 +502,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;
|
||||
|
@ -532,13 +529,13 @@ void MainWindow::onImportSellerJsonActionTriggered()
|
|||
<< "</b> 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;
|
||||
|
@ -557,9 +554,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;
|
||||
|
@ -579,7 +576,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;
|
||||
|
@ -594,10 +591,10 @@ void MainWindow::onImportSalesJsonActionTriggered()
|
|||
try {
|
||||
JsonUtil::importSales(filePath, marketplace_.get(),
|
||||
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,
|
||||
this)
|
||||
.exec();
|
||||
.exec();
|
||||
}
|
||||
setSaleModel();
|
||||
updateStatLabel();
|
||||
|
@ -623,7 +620,7 @@ void MainWindow::readGeometry()
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* event)
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
writeGeometry();
|
||||
event->accept();
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include <core/database.h>
|
||||
#include <core/utils.h>
|
||||
#include <printer/posprinter.h>
|
||||
#include <printer/utils.h>
|
||||
#include <core/utils.h>
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
@ -13,7 +13,7 @@
|
|||
#include <QMessageBox>
|
||||
#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);
|
||||
|
||||
|
@ -26,7 +26,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
|||
int maxFeeInEuro = settings.value("global/maxFeeInEuro").toInt();
|
||||
|
||||
if (parent)
|
||||
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
||||
market_ = dynamic_cast<MainWindow *>(parent)->getMarketplace();
|
||||
|
||||
ui_.cashPointNoSpinBox->setValue(cashPointNo);
|
||||
ui_.communeEdit->setText(commune);
|
||||
|
@ -35,7 +35,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
|||
ui_.feePercentSpinBox->setValue(feeInPercent);
|
||||
ui_.maxFeeSpinBox->setValue(maxFeeInEuro);
|
||||
|
||||
connect(ui_.testPosPrinterButton, &QPushButton::clicked, this, [=]() {
|
||||
connect(ui_.testPosPrinterButton, &QPushButton::clicked, this, [this]() {
|
||||
using namespace std::string_literals;
|
||||
try {
|
||||
if (ui_.posPrinterDeviceEdit->text().isEmpty()) {
|
||||
|
@ -55,7 +55,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
|||
printer.printTest();
|
||||
}
|
||||
|
||||
} catch (std::exception&) {
|
||||
} catch (std::exception &) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Falsche Eingabe",
|
||||
QString("Eingabeformat für Device (hexadezimale IDs): "
|
||||
"<VendorID>:<ProductID>\nBeispiel: 0416:5011\n "
|
||||
|
@ -65,7 +65,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(par
|
|||
return;
|
||||
}
|
||||
}
|
||||
} catch (std::runtime_error& err) {
|
||||
} catch (std::runtime_error &err) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Bondrucker Fehler",
|
||||
QString("Test schlug fehl: ") + err.what(), QMessageBox::StandardButton::Ok,
|
||||
this)
|
||||
|
@ -103,7 +103,7 @@ void SettingsDialog::accept()
|
|||
if (result == QMessageBox::Yes) {
|
||||
try {
|
||||
Database().updateCashPointNo(oldCashPointNo, newCashPointNo);
|
||||
} catch (std::exception& ex) {
|
||||
} catch (std::exception &ex) {
|
||||
std::string errMsg("Das Ändern der Kassen-Nr. ist fehlgeschlagen: ");
|
||||
errMsg.append(ex.what());
|
||||
QMessageBox(QMessageBox::Icon::Critical, "Fehler", errMsg.c_str(),
|
||||
|
|
Loading…
Reference in a new issue