Build system changed to Cmake, ORM changed to QxORM, Qt6 compatibility.
This commit is contained in:
+29
-28
@@ -18,9 +18,7 @@
|
||||
#include "data/favorititem.h"
|
||||
#include "favbutton.h"
|
||||
|
||||
#include "shop-odb.hxx"
|
||||
|
||||
void payVoucherFromUI(VoucherPtr voucher, PayDialog *dialog, ShopForm *form)
|
||||
void payVoucherFromUI(const VoucherPtr& voucher, PayDialog *dialog, ShopForm *form)
|
||||
{
|
||||
ShopService srv;
|
||||
srv.pay(voucher);
|
||||
@@ -43,11 +41,11 @@ void payVoucherFromUI(VoucherPtr voucher, PayDialog *dialog, ShopForm *form)
|
||||
|
||||
errMsg += QObject::tr("Switch to offline?");
|
||||
|
||||
if (srv.isEetOnline() && QMessageBox::question(NULL, QObject::tr("EET error"), errMsg) == QMessageBox::Yes)
|
||||
if (srv.isEetOnline() && QMessageBox::question(nullptr, QObject::tr("EET error"), errMsg) == QMessageBox::Yes)
|
||||
{
|
||||
srv.setEetOnline(false);
|
||||
|
||||
if (form != NULL)
|
||||
if (form != nullptr)
|
||||
{
|
||||
form->setEetStatusText(srv.isEetOnline() ? QObject::tr("<a href=\"#eet\">Online</a>") : QObject::tr("<a href=\"#eet\">Offline</a>"));
|
||||
}
|
||||
@@ -65,8 +63,8 @@ ShopForm::ShopForm(QWidget *parent) :
|
||||
ui(new Ui::ShopForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_itemsModel = NULL;
|
||||
m_commodityModel = NULL;
|
||||
m_itemsModel = nullptr;
|
||||
m_commodityModel = nullptr;
|
||||
m_itemFound = false;
|
||||
|
||||
ui->temporarySaveButton->setEnabled(false);
|
||||
@@ -89,7 +87,7 @@ ShopForm::~ShopForm()
|
||||
|
||||
void ShopForm::loadLast()
|
||||
{
|
||||
if (m_itemsModel == NULL)
|
||||
if (m_itemsModel == nullptr)
|
||||
{
|
||||
m_itemsModel = new AutoTableModel<VoucherItem>(this);
|
||||
m_itemsModel->setEditableCols(QList<int>() << 2);
|
||||
@@ -118,7 +116,7 @@ void ShopForm::loadLast()
|
||||
if (!receipt.isEmpty())
|
||||
{
|
||||
m_voucher = receipt[0];
|
||||
srv.loadItems(m_voucher);
|
||||
srv.load(m_voucher);
|
||||
m_itemsModel->setData(m_voucher->items());
|
||||
connectItemSignals();
|
||||
|
||||
@@ -133,9 +131,9 @@ void ShopForm::loadLast()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_commodityModel == NULL)
|
||||
if (m_commodityModel == nullptr)
|
||||
{
|
||||
m_commodityModel = new AutoTableModel<ShopItem>(this);
|
||||
m_commodityModel = new AutoTableModel<IShopItem>(this);
|
||||
m_commodityModel->setTranslations(Context::instance().plugin("SHOP")->translations());
|
||||
ui->commodityTable->setModel(m_commodityModel);
|
||||
|
||||
@@ -218,7 +216,7 @@ void ShopForm::loadButtons(const ShopSettingsPtr& settings)
|
||||
ui->commoditySearch->setFocus();
|
||||
}
|
||||
|
||||
void ShopForm::fillRaceiptCombo()
|
||||
void ShopForm::fillReceiptCombo()
|
||||
{
|
||||
bool oldState = ui->receiptCombo->blockSignals(true);
|
||||
|
||||
@@ -229,7 +227,7 @@ void ShopForm::fillRaceiptCombo()
|
||||
ui->receiptCombo->addItem(tr("<< empty >>"));
|
||||
|
||||
foreach (QSharedPointer<Voucher> voucher, receipts) {
|
||||
ui->receiptCombo->addItem(voucher->name(), voucher->id());
|
||||
ui->receiptCombo->addItem(voucher->name(), (qlonglong)voucher->id());
|
||||
}
|
||||
|
||||
ui->receiptCombo->blockSignals(oldState);
|
||||
@@ -249,7 +247,7 @@ void ShopForm::setupForm()
|
||||
ui->lblCount->setVisible(settings->showCount());
|
||||
|
||||
loadLast();
|
||||
fillRaceiptCombo();
|
||||
fillReceiptCombo();
|
||||
loadButtons(settings);
|
||||
}
|
||||
|
||||
@@ -285,7 +283,7 @@ void ShopForm::on_saveButton_clicked()
|
||||
{
|
||||
m_voucher->setStatus(Voucher::NOT_PAID);
|
||||
m_voucher->setSaveDateTime(QDateTime::currentDateTime());
|
||||
srv.updateVoucher(m_voucher);
|
||||
srv.update(m_voucher);
|
||||
createEmptyVoucher();
|
||||
}
|
||||
else
|
||||
@@ -293,7 +291,7 @@ void ShopForm::on_saveButton_clicked()
|
||||
VoucherPtr selVoucher = form->selectedVoucher();
|
||||
srv.moveItems(m_voucher->items(), m_voucher, selVoucher);
|
||||
srv.calculate(selVoucher);
|
||||
srv.updateVoucher(selVoucher);
|
||||
srv.update(selVoucher);
|
||||
createEmptyVoucher();
|
||||
}
|
||||
|
||||
@@ -365,13 +363,13 @@ void ShopForm::doTempSave(bool comboChanged)
|
||||
TemporaryReceiptSaveForm *form = new TemporaryReceiptSaveForm(m_voucher, this);
|
||||
form->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(form, &QDialog::accepted, [this, form, comboChanged](){
|
||||
connect(form, &QDialog::accepted, [this, comboChanged](){
|
||||
ShopService srv;
|
||||
|
||||
if (!m_voucher->items().isEmpty())
|
||||
{
|
||||
m_voucher->setStatus(Voucher::TEMPORARY);
|
||||
srv.updateVoucher(m_voucher);
|
||||
srv.update(m_voucher);
|
||||
}
|
||||
|
||||
if (comboChanged && ui->receiptCombo->currentIndex() > 0)
|
||||
@@ -383,7 +381,7 @@ void ShopForm::doTempSave(bool comboChanged)
|
||||
createEmptyVoucher();
|
||||
}
|
||||
|
||||
fillRaceiptCombo();
|
||||
fillReceiptCombo();
|
||||
|
||||
m_itemsModel->setData(m_voucher->items());
|
||||
});
|
||||
@@ -396,10 +394,13 @@ void ShopForm::changeReceipt()
|
||||
ShopService srv;
|
||||
|
||||
m_voucher = srv.loadById(ui->receiptCombo->currentData().toInt());
|
||||
srv.loadItems(m_voucher);
|
||||
if (m_voucher->items().isEmpty()) {
|
||||
srv.load(m_voucher);
|
||||
}
|
||||
|
||||
connectItemSignals();
|
||||
m_voucher->setStatus(Voucher::NEW);
|
||||
srv.updateVoucher(m_voucher);
|
||||
srv.update(m_voucher);
|
||||
|
||||
m_itemsModel->setData(m_voucher->items());
|
||||
//ui->total->setText(m_voucher->totalPrice().toString());
|
||||
@@ -409,7 +410,7 @@ void ShopForm::changeReceipt()
|
||||
ui->saveButton->setEnabled(true);
|
||||
ui->payButton->setEnabled(true);
|
||||
|
||||
fillRaceiptCombo();
|
||||
fillReceiptCombo();
|
||||
}
|
||||
|
||||
void ShopForm::connectItemSignals()
|
||||
@@ -430,7 +431,7 @@ void ShopForm::createEmptyVoucher()
|
||||
ui->payButton->setEnabled(false);
|
||||
}
|
||||
|
||||
void ShopForm::addItem(QSharedPointer<IShopItem> item, int count)
|
||||
void ShopForm::addItem(const QSharedPointer<IShopItem>& item, int count)
|
||||
{
|
||||
if (m_voucher.isNull())
|
||||
{
|
||||
@@ -517,7 +518,7 @@ void ShopForm::recalculate()
|
||||
}
|
||||
else
|
||||
{
|
||||
srv.updateVoucher(m_voucher);
|
||||
srv.update(m_voucher);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,7 +559,7 @@ void ShopForm::on_payButton_clicked()
|
||||
|
||||
}
|
||||
|
||||
void ShopForm::on_showPaiedButton_clicked()
|
||||
void ShopForm::on_showPaidButton_clicked()
|
||||
{
|
||||
PaydVouchersDialog *dialog = new PaydVouchersDialog(this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
@@ -567,7 +568,7 @@ void ShopForm::on_showPaiedButton_clicked()
|
||||
|
||||
void ShopForm::on_btnAddItem_clicked()
|
||||
{
|
||||
ShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex());
|
||||
IShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex());
|
||||
addItem(item, ui->spnCount->value());
|
||||
}
|
||||
|
||||
@@ -631,7 +632,7 @@ void ShopForm::on_commoditySearch_returnPressed()
|
||||
{
|
||||
if (m_itemFound)
|
||||
{
|
||||
ShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex());
|
||||
IShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex());
|
||||
addItem(item, ui->spnCount->value());
|
||||
}
|
||||
ui->commoditySearch->clear();
|
||||
@@ -639,7 +640,7 @@ void ShopForm::on_commoditySearch_returnPressed()
|
||||
|
||||
void ShopForm::on_actionDelete_items_triggered()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Delete items"), tr("Realy delete selected voucher items?")) == QMessageBox::Yes) {
|
||||
if (QMessageBox::question(this, tr("Delete items"), tr("Really delete selected voucher items?")) == QMessageBox::Yes) {
|
||||
QList<VoucherItemPtr> forDelete;
|
||||
|
||||
for (const auto& row : ui->actualReceipt->selectionModel()->selectedIndexes()) {
|
||||
|
||||
Reference in New Issue
Block a user