Minor: overload constructor
This commit is contained in:
		@@ -21,7 +21,10 @@ public:
 | 
			
		||||
    using Status = std::tuple<int, char const*, char const*>;
 | 
			
		||||
 | 
			
		||||
    explicit Ticket();
 | 
			
		||||
   
 | 
			
		||||
    explicit Ticket(QDateTime const &s, QDateTime const &e,
 | 
			
		||||
                    int durationMinutesNetto, int durationMinutesBrutto,
 | 
			
		||||
                    uint32_t price, Status status);
 | 
			
		||||
 | 
			
		||||
    explicit operator bool() { return std::get<CODE>(m_status) == VALID; }
 | 
			
		||||
    operator QString();
 | 
			
		||||
 | 
			
		||||
@@ -35,6 +38,15 @@ public:
 | 
			
		||||
    void setValidUntil(QDateTime const &validUnil);
 | 
			
		||||
    void setPrice(uint32_t price);
 | 
			
		||||
 | 
			
		||||
    bool isValid() { return operator bool(); }
 | 
			
		||||
 | 
			
		||||
    static constexpr const Status s[STATUS_END] = {
 | 
			
		||||
        {NOT_INITIALIZED       , "NOT_INITIALIZED"       , "Ticket not initialized"           },
 | 
			
		||||
        {VALID                 , "VALID"                 , "Ticket is valid"                  },
 | 
			
		||||
        {INVALID_FROM_DATETIME , "INVALID_FROM_DATETIME" , "Ticket has invalid start datetime"},
 | 
			
		||||
        {INVALID_UNTIL_DATETIME, "INVALID_UNTIL_DATETIME", "Ticket has invalid end datetime"  }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Status m_status;
 | 
			
		||||
 | 
			
		||||
@@ -45,20 +57,8 @@ private:
 | 
			
		||||
    int m_durationMinutesBrutto;
 | 
			
		||||
 | 
			
		||||
    uint32_t m_price;
 | 
			
		||||
 | 
			
		||||
    static constexpr const Status s[STATUS_END] = {
 | 
			
		||||
        {NOT_INITIALIZED       , "NOT_INITIALIZED"       , "Ticket not initialized"           },
 | 
			
		||||
        {VALID                 , "VALID"                 , "Ticket is valid"                  },
 | 
			
		||||
        {INVALID_FROM_DATETIME , "INVALID_FROM_DATETIME" , "Ticket has invalid start datetime"},
 | 
			
		||||
        {INVALID_UNTIL_DATETIME, "INVALID_UNTIL_DATETIME", "Ticket has invalid end datetime"  }
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
    
 | 
			
		||||
QDebug operator<<(QDebug debug, Ticket::Status const &status) {
 | 
			
		||||
    QDebugStateSaver saver(debug);
 | 
			
		||||
    debug << "Ticket-Status: " << std::get<1>(status) 
 | 
			
		||||
          << "(" << std::get<2>(status) << ")";
 | 
			
		||||
    return debug;
 | 
			
		||||
}
 | 
			
		||||
QDebug operator<<(QDebug debug, Ticket::Status const &status);
 | 
			
		||||
 | 
			
		||||
#endif // TICKET_H_INCLUDED
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user