#include "Ticket.h" #include Ticket::Ticket(TICKET_VARIANT ticketVariant, QObject *parent ) : QObject(parent) , ticketVariant(ticketVariant) , _hasTemplateDynData(false) { } TICKET_VARIANT Ticket::variant() { return this->ticketVariant; } QList * Ticket::templateList() { return &(this->_templateList); } bool Ticket::hasTemplateDynData() { return this->_hasTemplateDynData; } quint8 Ticket::getCurrentProcessedTemplateNumber() { return this->currentProcessedTemplateNumber; } void Ticket::setCurrentTemplateProcessed() { this->currentProcessedTemplateNumber++; } bool Ticket::initNew(TICKET_VARIANT ticketVariant, const QList & templateList, const QHash & printingData) { this->clear(); this->ticketVariant = ticketVariant; this->printingData = printingData; this->_templateList = templateList; this->currentProcessedTemplateNumber = 0; // DEBUG qCritical() << "Ticket::initNew():"; qCritical() << " -> " << ticketVariant; int multiplicatorInt = 1; // default 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; break; case TICKET_VARIANT::STOP_RECEIPT: this->_templateList << 24 << 25 << 26; break; case TICKET_VARIANT::FOOD_STAMP: if (printingData.contains("dyn1_list")) { this->_hasTemplateDynData = true; this->dyn1List = printingData["dyn1_list"].toStringList(); this->dyn2List = printingData["dyn2_list"].toStringList(); } if (printingData.contains("multiplicator")) { multiplicatorInt = printingData["multiplicator"].toInt(); for (int i = 1; i < multiplicatorInt; i++) { this->_templateList << 1; } // last template: this->_templateList << 2; } // DEBUG FOOD_STAMP: qCritical() << " --> printingData[\"multiplicator\"]" << multiplicatorInt; break; } // DEBUG QString templateListString; for (int i =0; i < this->_templateList.size(); ++i) { templateListString.append(QString(" %1").arg(this->_templateList.at(i))); } qCritical() << " -> templates: " << templateListString; return true; } void Ticket::clear() { this->ticketVariant = TICKET_VARIANT::PARKING_TICKET; this->printingData.clear(); this->_templateList.clear(); this->errorCode.clear(); this->errorDescription.clear(); this->_hasTemplateDynData = false; this->dyn1List.clear(); this->dyn1List.clear(); } QString Ticket::getErrorCode() { return this->errorCode; } QString Ticket::getErrorDescription() { return this->errorDescription; } /** */ QStringList Ticket::getDyn1List() { return this->dyn1List; } QStringList Ticket::getDyn2List() { return this->dyn2List; } QHash & Ticket::getPrintingData() { return this->printingData; } /************************************************************************************************ * operator * */ QDebug operator<<(QDebug debug, TICKET_VARIANT ticketVariant) { switch (ticketVariant) { case TICKET_VARIANT::PARKING_TICKET: debug << "TICKET_VARIANT::PARKING_TICKET"; break; case TICKET_VARIANT::RECEIPT: debug << "TICKET_VARIANT::RECEIPT"; break; case TICKET_VARIANT::ERROR_RECEIPT: debug << "TICKET_VARIANT::ERROR_RECEIPT"; break; case TICKET_VARIANT::START_RECEIPT: debug << "TICKET_VARIANT::START_RECEIPT"; break; case TICKET_VARIANT::STOP_RECEIPT: debug << "TICKET_VARIANT::STOP_RECEIPT"; break; case TICKET_VARIANT::FOOD_STAMP: debug << "TICKET_VARIANT::FOOD_STAMP"; break; } return debug; }