home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / examples / network / mail / composer.cpp next >
Encoding:
C/C++ Source or Header  |  2001-10-11  |  1.9 KB  |  67 lines

  1. /****************************************************************************
  2. ** $Id:  qt/composer.cpp   3.0.0   edited Jun 1 18:44 $
  3. **
  4. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  5. **
  6. ** This file is part of an example program for Qt.  This example
  7. ** program may be used, distributed and modified without limitation.
  8. **
  9. *****************************************************************************/
  10.  
  11. #include "composer.h"
  12. #include "smtp.h"
  13.  
  14. #include <qlineedit.h>
  15. #include <qmultilineedit.h>
  16. #include <qpushbutton.h>
  17. #include <qlabel.h>
  18. #include <qlayout.h>
  19.  
  20. Composer::Composer( QWidget *parent )
  21.     : QWidget( parent )
  22. {
  23.     QGridLayout * layout = new QGridLayout( this, 1, 1, 6 );
  24.  
  25.     layout->addWidget( new QLabel( tr( "From:" ), this ), 0, 0 );
  26.     from = new QLineEdit( this );
  27.     layout->addWidget( from, 0, 1 );
  28.  
  29.     layout->addWidget( new QLabel( tr( "To:" ), this ), 1, 0 );
  30.     to = new QLineEdit( this );
  31.     layout->addWidget( to, 1, 1 );
  32.  
  33.     layout->addWidget( new QLabel( tr( "Subject:" ), this ), 2, 0 );
  34.     subject = new QLineEdit( this );
  35.     layout->addWidget( subject, 2, 1 );
  36.  
  37.     message = new QMultiLineEdit( this );
  38.     layout->addMultiCellWidget( message, 3, 3, 0, 1 );
  39.  
  40.     send = new QPushButton( tr( "&Send" ), this );
  41.     layout->addWidget( send, 4, 0 );
  42.     connect( send, SIGNAL( clicked() ), this, SLOT( sendMessage() ) );
  43.  
  44.     sendStatus = new QLabel( this );
  45.     layout->addWidget( sendStatus, 4, 1 );
  46. }
  47.  
  48.  
  49. void Composer::sendMessage()
  50. {
  51.     send->setEnabled( FALSE );
  52.     sendStatus->setText( tr( "Looking up mail servers" ) );
  53.     Smtp *smtp = new Smtp( from->text(), to->text(),
  54.                subject->text(),
  55.                message->text() );
  56.     connect( smtp, SIGNAL(destroyed()),
  57.          this, SLOT(enableSend()) );
  58.     connect( smtp, SIGNAL(status(const QString &)),
  59.          sendStatus, SLOT(setText(const QString &)) );
  60. }
  61.  
  62.  
  63. void Composer::enableSend()
  64. {
  65.     send->setEnabled( TRUE );
  66. }
  67.