-rw-r--r-- | kmicromail/opiemail.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index ca3faaf..fe9df87 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -27,32 +27,33 @@ #ifdef DESKTOP_VERSION #include <qapplication.h> #else #include <qpe/qpeapplication.h> #endif #include <libmailwrapper/smtpwrapper.h> #include <libmailwrapper/mailtypes.h> #include <libmailwrapper/abstractmail.h> //using namespace Opie::Core; OpieMail::OpieMail( QWidget *parent, const char *name ) : MainWindow( parent, name) //, WStyle_ContextHelp ) { settings = new Settings(); + setIcon(SmallIcon( "kmicromail" ) ); folderView->populate( settings->getAccounts() ); } OpieMail::~OpieMail() { if (settings) delete settings; } void OpieMail::appMessage(const QCString &msg, const QByteArray &data) { } #include <stdlib.h> void OpieMail::message(const QCString &msg, const QByteArray &data) { @@ -227,33 +228,76 @@ void OpieMail::slotEditSettings() // KApplication::execDialog(settingsDialog); } void OpieMail::slotEditAccounts() { EditAccounts eaDialog( settings, this, 0, true ); eaDialog.slotAdjustColumns(); #ifndef DESKTOP_VERSION eaDialog.showMaximized(); #endif eaDialog.exec(); if ( settings ) delete settings; settings = new Settings(); folderView->populate( settings->getAccounts() ); } +void OpieMail::replyMail() +{ + + QListViewItem*item = mailView->currentItem(); + if (!item) return; + RecMailP mail = ((MailListViewItem*)item)->data(); + RecBodyP body = folderView->fetchBody(mail); + + QString rtext; + rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose + .arg( QString::fromUtf8( mail->getFrom().latin1())) + .arg( QString::fromUtf8( mail->getDate().latin1() )); + + QString text = QString::fromUtf8( body->Bodytext().latin1() ); + QStringList lines = QStringList::split(QRegExp("\\n"), text); + QStringList::Iterator it; + for (it = lines.begin(); it != lines.end(); it++) + { + rtext += "> " + *it + "\n"; + } + rtext += "\n"; + QString prefix; + if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; + else prefix = "Re: "; // no i18n on purpose + + Settings *settings = new Settings(); + ComposeMail composer( settings ,this, 0, true); + if (mail->Replyto().isEmpty()) { + composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); + } else { + composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); + } + composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); + composer.setMessage( rtext ); + composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); + + if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) + { + mail->Wrapper()->answeredMail(mail); + } + delete settings; + +} void OpieMail::displayMail() { QListViewItem*item = mailView->currentItem(); if (!item) return; RecMailP mail = ((MailListViewItem*)item)->data(); RecBodyP body = folderView->fetchBody(mail); ViewMail readMail( this,"", Qt::WType_Modal ); readMail.setBody( body ); readMail.setMail( mail ); #ifndef DESKTOP_VERSION readMail.showMaximized(); #else readMail.resize( 640, 480); #endif readMail.exec(); @@ -327,32 +371,34 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) /* just the RIGHT button - or hold on pda */ if (button!=2) {return;} if (!item) return; QPopupMenu *m = new QPopupMenu(0); if (m) { if (mailtype==MAILLIB::A_NNTP) { m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); m->insertSeparator(); m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); } else { if (folderView->currentisDraft()) { m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); } + m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); + m->insertSeparator(); m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); m->insertSeparator(); m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); } m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; } } void OpieMail::slotShowFolders( bool show ) { |