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 DirectEntry::init() 00011 { 00012 okButton->setEnabled( FALSE ) ; 00013 inInit = TRUE ; 00014 qty->setText( "1" ) ; 00015 total->setText( "0.00" ) ; 00016 inInit = FALSE ; 00017 message->setText( "" ) ; 00018 } 00019 00020 void DirectEntry::recalc() 00021 { 00022 bool mustleave = FALSE ; 00023 QString sender = QObject::sender()->name() ; 00024 if ( sender == "okButton" ) { 00025 mustleave = TRUE ; 00026 } 00027 if ( !inInit ) { 00028 inInit = TRUE ; 00029 int q = qty->text().toInt() ; 00030 double ret = 0.0 ; 00031 if ( !retail->text().stripWhiteSpace().isEmpty() ) { 00032 ret = retail->text().toDouble() ; 00033 } 00034 total->setText( QString( "%1" ).arg( ret * (double)q, 0, 'f', 2 ) ) ; 00035 if ( total->text() == "0.00" ) { 00036 message->setText( tr( "Invalid. You cannot validate a Zero value line." ) ) ; 00037 mustleave = FALSE ; 00038 okButton->setEnabled( FALSE ) ; 00039 } else { 00040 message->setText( "" ) ; 00041 checkLabel( designation->text() ) ; 00042 } 00043 retail->setText( QString( "%1" ).arg( ret, 0, 'f', 2 ) ) ; 00044 inInit = FALSE ; 00045 } 00046 if ( mustleave ) { 00047 accept() ; 00048 } 00049 } 00050 00051 00052 void DirectEntry::checkRebate( bool reb ) 00053 { 00054 if ( reb ) { 00055 message->setText( tr( "Warning ! You define a manual rebate. You will have to check\n" 00056 "the validity by yourself." ) ) ; 00057 } 00058 } 00059 00060 00061 void DirectEntry::checkLabel( const QString & str ) 00062 { 00063 okButton->setEnabled( !str.stripWhiteSpace().isEmpty() && 00064 total->text() != "0.00" ) ; 00065 if ( okButton->isEnabled() ) { 00066 message->setText( "" ) ; 00067 } else { 00068 message->setText( tr( "Designation cannot be left empty." ) ) ; 00069 } 00070 } 00071 00072 00073 bool DirectEntry::rebateSet() 00074 { 00075 return isRebate->isChecked() ; 00076 }