From cbc0dd0ad693e3444baff56fe37a930849ab2263 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Wed, 12 Mar 2025 14:26:40 +0100 Subject: [PATCH] Ticket: Use printer templates from config --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 5 +- src/ATBAPP/support/Ticket.cpp | 74 ++++++++++++++++++++---- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 3409d49..bae1ab3 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -726,10 +726,7 @@ void ATBDeviceControllerPlugin::onNewVoltage(uint32_t voltage) */ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::TICKET_VARIANT ticketVariant, const QHash & printingData) { - QList templateList; - - // TODO: read template list from .ini - + QList templateList = this->ticketTemplateList[ticketVariant]; // DEBUG qCritical() << "------------------------------------------------------------------------"; diff --git a/src/ATBAPP/support/Ticket.cpp b/src/ATBAPP/support/Ticket.cpp index fdab619..8dff45e 100644 --- a/src/ATBAPP/support/Ticket.cpp +++ b/src/ATBAPP/support/Ticket.cpp @@ -50,25 +50,42 @@ bool Ticket::initNew(TICKET_VARIANT ticketVariant, const QList & templat qCritical() << " -> " << ticketVariant; int multiplicatorInt = 1; // default + quint8 headerTemplate; + quint8 multiTemplate; + quint8 footerTemplate; switch (this->ticketVariant) { - case TICKET_VARIANT::PARKING_TICKET: - break; - case TICKET_VARIANT::RECEIPT: - break; - case TICKET_VARIANT::ERROR_RECEIPT: - break; case TICKET_VARIANT::START_RECEIPT: - this->_templateList << 21 << 22 << 23; + if (templateList.isEmpty()) { + this->_templateList << 21 << 22 << 23; + } + else { + this->_templateList = templateList; + } break; case TICKET_VARIANT::STOP_RECEIPT: - this->_templateList << 24 << 25 << 26; + if (templateList.isEmpty()) { + this->_templateList << 24 << 25 << 26; + } + else { + this->_templateList = templateList; + } break; case TICKET_VARIANT::FINE_PAYMENT: - this->_templateList << 24 << 25 << 26; + if (templateList.isEmpty()) { + this->_templateList << 24 << 25 << 26; + } + else { + this->_templateList = templateList; + } break; case TICKET_VARIANT::FREE_TICKET: - this->_templateList << 24 << 25 << 26; + if (templateList.isEmpty()) { + this->_templateList << 24 << 25 << 26; + } + else { + this->_templateList = templateList; + } break; case TICKET_VARIANT::FOOD_STAMP: if (printingData.contains("dyn1_list")) { @@ -78,19 +95,52 @@ bool Ticket::initNew(TICKET_VARIANT ticketVariant, const QList & templat this->dyn2List = printingData["dyn2_list"].toStringList(); } + if (templateList.isEmpty()) { + headerTemplate = 0; + multiTemplate = 1; + footerTemplate = 2; + } + else + if (templateList.size() == 2) { + headerTemplate = 0; + multiTemplate = templateList.at(0); + footerTemplate = templateList.at(1); + } + else + if (templateList.size() == 3) { + headerTemplate = templateList.at(0); + multiTemplate = templateList.at(1); + footerTemplate = templateList.at(2); + } + else { + headerTemplate = 0; + multiTemplate = 1; + footerTemplate = 2; + } + + // header is optional: + if (headerTemplate != 0) { + this->_templateList << headerTemplate; + } + if (printingData.contains("multiplicator")) { multiplicatorInt = printingData["multiplicator"].toInt(); for (int i = 1; i < multiplicatorInt; i++) { - this->_templateList << 1; + this->_templateList << multiTemplate; } // last template: - this->_templateList << 2; + this->_templateList << footerTemplate; + } + else { + this->_templateList = templateList; } // DEBUG FOOD_STAMP: qCritical() << " --> printingData[\"multiplicator\"]" << multiplicatorInt; break; + default: + this->_templateList = templateList; }