68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
|
#include "ticket.h"
|
||
|
|
||
|
Ticket::Ticket()
|
||
|
: m_status(Ticket::s[NOT_INITIALIZED])
|
||
|
, m_validFrom()
|
||
|
, m_validUntil()
|
||
|
, m_durationMinutesNetto(0)
|
||
|
, m_durationMinutesBrutto(0)
|
||
|
, m_price() {
|
||
|
|
||
|
qDebug() << *this;
|
||
|
qDebug() << m_status;
|
||
|
}
|
||
|
|
||
|
Ticket::Status Ticket::setStatus(Status status) {
|
||
|
Status old = m_status;
|
||
|
m_status = status;
|
||
|
return old;
|
||
|
}
|
||
|
|
||
|
Ticket::Status Ticket::getStatus() const {
|
||
|
return m_status;
|
||
|
}
|
||
|
|
||
|
void Ticket::setValidFrom(QDateTime const &validFrom) {
|
||
|
m_validFrom = validFrom;
|
||
|
}
|
||
|
|
||
|
void Ticket::setValidUntil(QDateTime const &validUntil) {
|
||
|
m_validUntil = validUntil;
|
||
|
}
|
||
|
|
||
|
QDateTime Ticket::getValidFrom() const {
|
||
|
if (std::get<CODE>(m_status) == VALID) {
|
||
|
return m_validFrom;
|
||
|
}
|
||
|
return QDateTime();
|
||
|
}
|
||
|
|
||
|
QDateTime Ticket::getValidUntil() const {
|
||
|
if (std::get<CODE>(m_status) == VALID) {
|
||
|
return m_validFrom;
|
||
|
}
|
||
|
return QDateTime();
|
||
|
}
|
||
|
|
||
|
uint32_t Ticket::getPrice() const {
|
||
|
return m_price;
|
||
|
}
|
||
|
|
||
|
void Ticket::setPrice(uint32_t price) {
|
||
|
m_price = price;
|
||
|
}
|
||
|
|
||
|
Ticket::operator QString() {
|
||
|
QStringList status;
|
||
|
status << QString("Status .............. : %1 (%2)")
|
||
|
.arg(std::get<0>(m_status))
|
||
|
.arg(std::get<2>(m_status));
|
||
|
status << QString("Valid from ......... : %1").arg(m_validFrom.toString(Qt::ISODate));
|
||
|
status << QString("Valid until ........ : %1").arg(m_validUntil.toString(Qt::ISODate));
|
||
|
status << QString("Duration (netto) ... : %1").arg(m_durationMinutesNetto);
|
||
|
status << QString("Duration (brutto)... : %1").arg(m_durationMinutesBrutto);
|
||
|
status << QString("Price ......... : %1").arg(m_price);
|
||
|
|
||
|
return status.join('\n');;
|
||
|
}
|