00001 /**************************************************************************** 00002 ** ui.h extension file, included from the uic-generated form implementation. 00003 ** 00004 ** If you wish to add, delete or rename functions or slots use 00005 ** Qt Designer which will update this file, preserving your code. Create an 00006 ** init() function in place of a constructor, and a destroy() function in 00007 ** place of a destructor. 00008 *****************************************************************************/ 00009 00010 void TicketHistory::init() 00011 { 00012 refer = new QSqlQuery() ; 00013 detailTable->setFilter( "recid=-1" ) ; 00014 detailTable->refresh() ; 00015 00016 } 00017 00018 void TicketHistory::ticketChanged( int row, int col ) 00019 { 00020 detailTable->setFilter( QString( "ticket_num='%1-%2-%3-%4 %5" ) 00021 .arg( listTable->text( row, 0 ) ) 00022 .arg( listTable->text( row, 1 ) ) 00023 .arg( listTable->text( row, 2 ) ) 00024 .arg( listTable->text( row, 3 ) ) 00025 .arg( listTable->text( row, 4 ) ) ) ; 00026 detailTable->refresh() ; 00027 } 00028 00029 00030 00031 void TicketHistory::fillTable() 00032 { 00033 int row = 0 ; 00034 QString entry ; 00035 listTable->setNumRows( 0 ) ; 00036 while ( refer->next() ) { 00037 entry = refer->value( 0 ).toString() ; 00038 listTable->insertRows( row, 1 ) ; 00039 listTable->setText( row, 0, entry.section( "-", 0, 0 ) ) ; 00040 listTable->setText( row, 1, entry.section( "-", 1, 1 ) ) ; 00041 listTable->setText( row, 2, entry.section( "-", 2, 2 ) ) ; 00042 QString dt = entry.section( "-", 3, 3 ) ; 00043 listTable->setText( row, 3, dt.section( " ", 0, 0 ) ) ; 00044 listTable->setText( row, 4, dt.section( " ", 1, 1 ) ) ; 00045 row++ ; 00046 } 00047 if ( listTable->numRows() > 0 ) { 00048 listTable->setCurrentCell( 0, 0 ) ; 00049 listTable->selectRow( 0 ) ; 00050 ticketChanged( 0, 0 ) ; 00051 } else { 00052 applyButton->setEnabled( FALSE ) ; 00053 messageline->setText( tr( "No ticket means your criteria. Sorry" ) ) ; 00054 } 00055 } 00056 00057 00058 void TicketHistory::setDateValues( const QDate & dt ) 00059 { 00060 QString filter = QString( "received >= UNIX_TIMESTAMP( '%1' ) AND " 00061 "received <= '%2'" ) 00062 .arg( dt.toString( "yyyy-MM-dd 00:00:00" ) ) 00063 .arg( dt.toString( "yyyy-MM-dd 23:59:59" ) ) ; 00064 refer->exec( QString( "SELECT DISTINCT ticket_num WHERE %1 ;" ) 00065 .arg( filter ) ) ; 00066 dateLabel->setText( dt.toString( "dd MM yyyy" ) ) ; 00067 fillTable() ; 00068 } 00069 00070 00071 void TicketHistory::setMessage( const QString & msg ) 00072 { 00073 messageline->setText( msg ) ; 00074 } 00075 00076 00077 QString TicketHistory::getResult() 00078 { 00079 int row = listTable->currentRow() ; 00080 return QString( "ticket_num='%1-%2-%3-%4 %5" ) 00081 .arg( listTable->text( row, 0 ) ) 00082 .arg( listTable->text( row, 1 ) ) 00083 .arg( listTable->text( row, 2 ) ) 00084 .arg( listTable->text( row, 3 ) ) 00085 .arg( listTable->text( row, 4 ) ) ; 00086 }