/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa * All rights reserved. * */ #include #include #include "ticketinfo.h" #include "core/error.h" namespace Ticket { TicketInfo::TicketInfo() { Clear(); } void TicketInfo::SetTDb(TDb * ptdb) { tdb = ptdb; } void TicketInfo::SetDb(Db * pdb) { db = pdb; } void TicketInfo::SetSystem(System * psystem) { system = psystem; } void TicketInfo::Clear() { item.Clear(); is_ticket = false; ticket.Clear(); ticket_tab.clear(); } void TicketInfo::ReadTicket(long dir_id) { if( tdb->GetTicketByDirId(dir_id, ticket) == WINIX_ERR_OK ) { is_ticket = true; db->GetItemById(ticket.item_id, item); } } bool TicketInfo::SortTicketsFun(const Ticket & t1, const Ticket & t2) { return t1.sort_id > t2.sort_id; } void TicketInfo::SortTickets() { std::vector::iterator i; for(i=ticket_tab.begin() ; i!=ticket_tab.end() ; ++i) { Item * dir = system->dirs.GetDir(i->dir_id); i->sort_id = ( dir ) ? (unsigned long)mktime(&dir->date_creation) : 0; } std::sort(ticket_tab.begin(), ticket_tab.end(), SortTicketsFun); } } // namespace