00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "showmaildialog.h"
00019
00020 ShowMailDialog::ShowMailDialog( QWidget * parent, QString caption, bool allowHTML, bool isHTML, QString sender, QString date, QString size, QString subject, QStringList body ) :
00021 KDialog( parent )
00022 {
00023
00024
00025
00026 setButtons( Ok | Cancel | User1 );
00027
00028
00029 setButtonText( User1, i18nc( "@action:button to reply a mail", "Reply") );
00030 setButtonIcon( User1, KIcon( "mail-reply-sender" ) );
00031 setButtonToolTip( User1, i18nc( "@info:tooltip", "Reply to sender" ) );
00032
00033
00034 m_subject = subject;
00035 m_sender = sender;
00036 m_body = body;
00037
00038
00039 QWidget* mainWidget = new QWidget( this );
00040 setMainWidget( mainWidget );
00041 setCaption( caption );
00042
00043
00044 QVBoxLayout* layMain = new QVBoxLayout();
00045 mainWidget->setLayout( layMain );
00046
00047
00048 QHBoxLayout* layMetaDatas = new QHBoxLayout();
00049 layMain->addLayout( layMetaDatas );
00050 QVBoxLayout* layLabels = new QVBoxLayout();
00051 layMetaDatas->addLayout( layLabels );
00052 QVBoxLayout* layLines = new QVBoxLayout();
00053 layMetaDatas->addLayout( layLines );
00054
00055
00056 QLabel* lblSender = new QLabel( i18nc( "@label:textbox sender of the mail", "Sender:" ), mainWidget );
00057 layLabels->addWidget( lblSender );
00058
00059 QLabel* lblDate = new QLabel( i18nc( "@label:textbox send date", "Date:" ), mainWidget );
00060 layLabels->addWidget( lblDate );
00061
00062 QLabel* lblSize = new QLabel( i18nc( "@label:textbox mail size", "Size:" ), mainWidget );
00063 layLabels->addWidget( lblSize );
00064
00065 QLabel* lblSubject = new QLabel( i18nc( "@label:textbox mail subject", "Subject:" ), mainWidget );
00066 layLabels->addWidget( lblSubject );
00067
00068
00069 KLineEdit* liSender = new KLineEdit( sender, mainWidget );
00070 liSender->setReadOnly( true );
00071 layLines->addWidget( liSender );
00072
00073 KLineEdit* liDate = new KLineEdit( date, mainWidget );
00074 liDate->setReadOnly( true );
00075 layLines->addWidget( liDate );
00076
00077 KLineEdit* liSize = new KLineEdit( size, mainWidget );
00078 liSize->setReadOnly( true );
00079 layLines->addWidget( liSize );
00080
00081 KLineEdit* liSubject = new KLineEdit( subject, mainWidget );
00082 liSubject->setReadOnly( true );
00083 layLines->addWidget( liSubject );
00084
00085
00086 KTextEdit* txtBody = new KTextEdit( mainWidget );
00087 txtBody->setReadOnly( true );
00088
00089 if( !allowHTML )
00090 txtBody->setPlainText( body.join( "\n" ) );
00091 else if( isHTML )
00092 txtBody->setHtml( body.join( "\n" ) );
00093 else
00094 txtBody->setText( body.join( "\n" ) );
00095 txtBody->setMinimumSize( WIDTH_VIEW_MAILBODY, HEIGHT_VIEW_MAILBODY );
00096
00097 layMain->addWidget( txtBody );
00098
00099 }
00100
00101 ShowMailDialog::~ShowMailDialog()
00102 {
00103 }
00104
00105 void ShowMailDialog::slotButtonClicked(int button)
00106 {
00107
00108
00109 if( button == User1 ) {
00110
00111 QStringList newBody;
00112 foreach( const QString& line, m_body ) {
00113 newBody.append( "> " + line );
00114 }
00115
00116 KToolInvocation::invokeMailer( m_sender,
00117 "",
00118 "",
00119 "Re: " + m_subject,
00120 newBody.join( "\n" )
00121 );
00122
00123
00124 }
00125
00126 KDialog::slotButtonClicked(button);
00127 }
00128
00129 #include "showmaildialog.moc"