summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp46
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
@@ -31,24 +31,25 @@
31#endif 31#endif
32#include <libmailwrapper/smtpwrapper.h> 32#include <libmailwrapper/smtpwrapper.h>
33#include <libmailwrapper/mailtypes.h> 33#include <libmailwrapper/mailtypes.h>
34#include <libmailwrapper/abstractmail.h> 34#include <libmailwrapper/abstractmail.h>
35 35
36//using namespace Opie::Core; 36//using namespace Opie::Core;
37 37
38OpieMail::OpieMail( QWidget *parent, const char *name ) 38OpieMail::OpieMail( QWidget *parent, const char *name )
39 : MainWindow( parent, name) //, WStyle_ContextHelp ) 39 : MainWindow( parent, name) //, WStyle_ContextHelp )
40{ 40{
41 settings = new Settings(); 41 settings = new Settings();
42 42
43 setIcon(SmallIcon( "kmicromail" ) );
43 folderView->populate( settings->getAccounts() ); 44 folderView->populate( settings->getAccounts() );
44 45
45} 46}
46 47
47OpieMail::~OpieMail() 48OpieMail::~OpieMail()
48{ 49{
49 if (settings) delete settings; 50 if (settings) delete settings;
50} 51}
51 52
52void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 53void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
53{ 54{
54 55
@@ -231,25 +232,68 @@ void OpieMail::slotEditAccounts()
231{ 232{
232 EditAccounts eaDialog( settings, this, 0, true ); 233 EditAccounts eaDialog( settings, this, 0, true );
233 eaDialog.slotAdjustColumns(); 234 eaDialog.slotAdjustColumns();
234#ifndef DESKTOP_VERSION 235#ifndef DESKTOP_VERSION
235 eaDialog.showMaximized(); 236 eaDialog.showMaximized();
236#endif 237#endif
237 eaDialog.exec(); 238 eaDialog.exec();
238 if ( settings ) delete settings; 239 if ( settings ) delete settings;
239 settings = new Settings(); 240 settings = new Settings();
240 241
241 folderView->populate( settings->getAccounts() ); 242 folderView->populate( settings->getAccounts() );
242} 243}
244void OpieMail::replyMail()
245{
246
247 QListViewItem*item = mailView->currentItem();
248 if (!item) return;
249 RecMailP mail = ((MailListViewItem*)item)->data();
250 RecBodyP body = folderView->fetchBody(mail);
251
252 QString rtext;
253 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
254 .arg( QString::fromUtf8( mail->getFrom().latin1()))
255 .arg( QString::fromUtf8( mail->getDate().latin1() ));
256
257 QString text = QString::fromUtf8( body->Bodytext().latin1() );
258 QStringList lines = QStringList::split(QRegExp("\\n"), text);
259 QStringList::Iterator it;
260 for (it = lines.begin(); it != lines.end(); it++)
261 {
262 rtext += "> " + *it + "\n";
263 }
264 rtext += "\n";
243 265
266 QString prefix;
267 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
268 else prefix = "Re: "; // no i18n on purpose
269
270 Settings *settings = new Settings();
271 ComposeMail composer( settings ,this, 0, true);
272 if (mail->Replyto().isEmpty()) {
273 composer.setTo( QString::fromUtf8( mail->getFrom().latin1()));
274 } else {
275 composer.setTo( QString::fromUtf8(mail->Replyto().latin1()));
276 }
277 composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) );
278 composer.setMessage( rtext );
279 composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1()));
280
281 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
282 {
283 mail->Wrapper()->answeredMail(mail);
284 }
285 delete settings;
286
287}
244void OpieMail::displayMail() 288void OpieMail::displayMail()
245{ 289{
246 QListViewItem*item = mailView->currentItem(); 290 QListViewItem*item = mailView->currentItem();
247 if (!item) return; 291 if (!item) return;
248 RecMailP mail = ((MailListViewItem*)item)->data(); 292 RecMailP mail = ((MailListViewItem*)item)->data();
249 RecBodyP body = folderView->fetchBody(mail); 293 RecBodyP body = folderView->fetchBody(mail);
250 ViewMail readMail( this,"", Qt::WType_Modal ); 294 ViewMail readMail( this,"", Qt::WType_Modal );
251 readMail.setBody( body ); 295 readMail.setBody( body );
252 readMail.setMail( mail ); 296 readMail.setMail( mail );
253#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
254 readMail.showMaximized(); 298 readMail.showMaximized();
255#else 299#else
@@ -331,24 +375,26 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
331 if (m) 375 if (m)
332 { 376 {
333 if (mailtype==MAILLIB::A_NNTP) { 377 if (mailtype==MAILLIB::A_NNTP) {
334 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); 378 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail()));
335 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); 379 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail()));
336 m->insertSeparator(); 380 m->insertSeparator();
337 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); 381 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail()));
338 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 382 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
339 } else { 383 } else {
340 if (folderView->currentisDraft()) { 384 if (folderView->currentisDraft()) {
341 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); 385 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail()));
342 } 386 }
387 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail()));
388 m->insertSeparator();
343 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); 389 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail()));
344 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 390 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
345 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); 391 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail()));
346 m->insertSeparator(); 392 m->insertSeparator();
347 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 393 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
348 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 394 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
349 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 395 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
350 } 396 }
351 m->setFocus(); 397 m->setFocus();
352 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 398 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
353 delete m; 399 delete m;
354 } 400 }