TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.1KB

  1. #include "maildlg.h"
  2. #include <tqlayout.h>
  3. #include<kdebug.h>
  4. #include<tdelocale.h>
  5. #include<tqapplication.h>
  6. #include "mailsubject.h"
  7. #include <tqprogressdialog.h>
  8. #include "maildrop.h"
  9. KornMailDlg::KornMailDlg( TQWidget *parent )
  10. : KDialogBase( parent, "maildialog", true, i18n("Mail Details"), User1|Close, Close, true, KGuiItem(i18n("&Full Message"))),
  11. _progress( 0 )
  12. {
  13. TQWidget * page = new TQWidget( this );
  14. setMainWidget(page);
  15. TQVBoxLayout * topLayout = new TQVBoxLayout( page, 0, spacingHint() );
  16. _editCtrl = new KEdit(page);
  17. topLayout->addWidget(_editCtrl, 10);
  18. _editCtrl->setReadOnly(true);
  19. connect(this, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(showFullMessage()));
  20. setInitialSize(TQSize(TQApplication::desktop()->width()*9/10, TQApplication::desktop()->height()/2));
  21. }
  22. KornMailDlg::~KornMailDlg()
  23. {
  24. }
  25. void KornMailDlg::loadMailCanceled()
  26. {
  27. _loadMailCanceled = true;
  28. }
  29. void KornMailDlg::showFullMessage()
  30. {
  31. _loadMailCanceled = false;
  32. // create progress dialog
  33. _progress = new TQProgressDialog(this, "bla", TRUE);
  34. _progress->setMinimumDuration(0);
  35. _progress->setLabelText(i18n("Loading full mail. Please wait..."));
  36. // this should show it even if the mailbox does not support progress bars
  37. _progress->setTotalSteps(1000);
  38. _progress->setProgress(1);
  39. tqApp->processEvents();
  40. // connect the mailbox with the progress dialog in case it supports progress bars
  41. connect(_mailDrop, TQT_SIGNAL(readMailTotalSteps(int)), _progress, TQT_SLOT(setTotalSteps(int)));
  42. connect(_mailDrop, TQT_SIGNAL(readMailProgress(int)), _progress, TQT_SLOT(setProgress(int)));
  43. tqApp->processEvents();
  44. // connect the mailbox's cancel button
  45. connect(_progress, TQT_SIGNAL(canceled()), this, TQT_SLOT(loadMailCanceled()));
  46. connect(_mailDrop, TQT_SIGNAL(readMailReady(TQString*)), this, TQT_SLOT(readMailReady(TQString*)));
  47. // now load the mail fully
  48. if( _mailDrop->synchrone() )
  49. {
  50. TQString mail = _mailDrop->readMail(_mailSubject->getId(), &_loadMailCanceled);
  51. readMailReady( &mail );
  52. }
  53. else
  54. _mailDrop->readMail(_mailSubject->getId(), &_loadMailCanceled);
  55. }
  56. void KornMailDlg::setMailSubject( KornMailSubject * mailSubject )
  57. {
  58. _mailSubject = mailSubject;
  59. _mailDrop = mailSubject->getMailDrop();
  60. // show mail
  61. _editCtrl->setText(_mailSubject->getHeader());
  62. // disable "Full Message" button if mail is already loaded fully
  63. enableButton(User1, !_mailSubject->isHeaderFullMessage() && _mailDrop->canReadMail());
  64. }
  65. void KornMailDlg::readMailReady( TQString* mail )
  66. {
  67. deleteProgress();
  68. // if loading was not canceled and did not fail
  69. if ( mail->length() > 0)
  70. {
  71. // store full mail in KornMailSubject instance (so that it has not to be loaded again next time)
  72. _mailSubject->setHeader(*mail, true);
  73. // show fully loaded mail
  74. _editCtrl->setText(*mail);
  75. // disable "Full Message" button
  76. enableButton(User1, false);
  77. }
  78. }
  79. void KornMailDlg::deleteProgress()
  80. {
  81. _progress->setProgress(_progress->totalSteps());
  82. _progress->hide();
  83. disconnect( _mailDrop, TQT_SIGNAL(readMailReady(TQString*)), this, TQT_SLOT(readMailReady(TQString*)));
  84. delete _progress;
  85. _progress = 0;
  86. }
  87. #include "maildlg.moc"