Hello!

I wrote a class to send mail using Qxt, it works but I am sure lots of things could be done better. Any suggestions?
Qt Code:
  1. Mailsender::Mailsender()
  2. {
  3. ...
  4. connect(smtp, SIGNAL(mailSent (int)), this, SLOT(sendingMailSucceeded ( int )));
  5. connect(smtp, SIGNAL(mailFailed (int,int)), this, SLOT(sendingMailFailed ( int , int )));
  6. ...
  7. int rv = smtp->send(*message); //send mail
  8.  
  9. rvMailSend = 1; //private variable to set mail status
  10.  
  11. //private QProgressBar*
  12. progress = new QProgressDialog("Sending mail...","abort" ,0 , 0, this);
  13. progress->setWindowModality(Qt::ApplicationModal);
  14. progress->setCancelButton (0); //do not show
  15.  
  16. //private QTimer*
  17. Timer1 = new QTimer(this);
  18. Timer1->start(1000);
  19. connect(Timer1, SIGNAL(timeout()), this, SLOT(mailSendingLoop()));
  20.  
  21. Timer2 = new QTimer(this);
  22. Timer2->setSingleShot(true);
  23. Timer2->setInterval(10000);
  24. Timer2->start();
  25. connect(Timer2, SIGNAL(timeout()), this, SLOT(mailSendingTimeout()));
  26.  
  27. progress->exec(); //show progressbar
  28.  
  29. } //end of constructor
  30.  
  31.  
  32. void MailSender::sendingMailFailed ( int mailID, int errorCode )
  33. {
  34. rvMailSend = 1; //set via signal if mail failed
  35. }
  36.  
  37. void MailSender::sendingMailSucceeded ( int mailID )
  38. {
  39. rvMailSend = 0; //set via signal if mail succeeded
  40. }
  41.  
  42.  
  43. int MailSender::mailSendingLoop() //called regular by a QTimer
  44. {
  45. if(rvMailSend == 0)
  46. {
  47. progress->close();
  48. QMessageBox msgBox;
  49. msgBox.setText("Mail send!");
  50. msgBox.setStandardButtons(QMessageBox::Ok);
  51. msgBox.setDefaultButton( QMessageBox::Ok);
  52. Timer1->stop();
  53. Timer2->stop();
  54. int ret = msgBox.exec();
  55.  
  56. if (ret == QMessageBox::Ok)
  57. {
  58. this->close();
  59. return 0;
  60. }
  61.  
  62. }
  63.  
  64.  
  65. }
  66.  
  67. int MailSender:: mailSendingTimeout() //Timeout, called on Timer2
  68. {
  69. progress->close();
  70. QMessageBox msgBox;
  71. msgBox.setText("Sending mail failed!");
  72. msgBox.setStandardButtons(QMessageBox::Ok);
  73. msgBox.setDefaultButton( QMessageBox::Ok);
  74. Timer1->stop();
  75. Timer2->stop();
  76. int ret = msgBox.exec();
  77.  
  78. if (ret == QMessageBox::Ok)
  79. {
  80. this->close();
  81. return 1;
  82. }
  83.  
  84. }
To copy to clipboard, switch view to plain text mode 
Kind regards,
HomeR[/CODE]