Diffstat (limited to 'noncore/unsupported/mail2/viewmail.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/mail2/viewmail.cpp | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/noncore/unsupported/mail2/viewmail.cpp b/noncore/unsupported/mail2/viewmail.cpp index ae1f5f3..3c88d99 100644 --- a/noncore/unsupported/mail2/viewmail.cpp +++ b/noncore/unsupported/mail2/viewmail.cpp @@ -1,38 +1,39 @@ #include <qtextbrowser.h> #include <qmessagebox.h> #include <qaction.h> +#include <qapplication.h> #include "mailfactory.h" #include "composer.h" #include "viewmail.h" AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) : QListViewItem(parent), _attachItemStore(attachItemStore) { setText(0, _attachItemStore.mimeType()); setText(1, _attachItemStore.fileName()); setText(2, _attachItemStore.description()); } AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) : QListViewItem(parent), _attachItemStore(attachItemStore) { setText(0, _attachItemStore.mimeType()); setText(1, _attachItemStore.fileName()); setText(2, _attachItemStore.description()); } ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) - : ViewMailBase(parent, name, fl), _mail(mail), _handler(handler) + : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) { setCaption(caption().arg(mail.envelope().from()[0].name())); _gotBody = false; _mailHtml = tr( "<html><body>" "<div align=center><b>%1</b></div>" "<b>From:</b> %2<br>" "<b>To:</b> %3<br>" "%4" "%5" "<b>Date:</b> %6<hr>" @@ -52,24 +53,49 @@ ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *paren .arg("%1"); connect(reply, SIGNAL(activated()), SLOT(slotReply())); connect(forward, SIGNAL(activated()), SLOT(slotForward())); attachments->setEnabled(_gotBody); browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); } +ViewMail::~ViewMail() +{ + hide(); +} + +void ViewMail::hide() +{ + QWidget::hide(); + + if (_inLoop) { + _inLoop = false; + qApp->exit_loop(); + } +} + +void ViewMail::exec() +{ + show(); + + if (!_inLoop) { + _inLoop = true; + qApp->enter_loop(); + } +} + QString ViewMail::deHtml(const QString &string) { QString string_ = string; string_.replace(QRegExp("&"), "&"); string_.replace(QRegExp("<"), "<"); string_.replace(QRegExp(">"), ">"); string_.replace(QRegExp("\\n"), "<br>"); return string_; } void ViewMail::slotReply() { @@ -92,28 +118,28 @@ void ViewMail::slotReply() rtext += "\n"; QString prefix; if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; else prefix = "Re: "; // no i18n on purpose SendMail sendMail; sendMail.setTo(_mail.envelope().from()[0].toString()); sendMail.setSubject(prefix + _mail.envelope().subject()); sendMail.setInReplyTo(_mail.envelope().messageId()); sendMail.setMessage(rtext); - Composer *composer = new Composer(0, 0, Qt::WType_Modal); - composer->setSendMail(sendMail); - composer->showMaximized(); - composer->show(); + Composer composer(this, 0, true); + composer.setSendMail(sendMail); + composer.showMaximized(); + composer.exec(); } void ViewMail::slotForward() { if (!_gotBody) { QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); return; } QString ftext; ftext += QString("\n----- Forwarded message from %1 -----\n\n") .arg(_mail.envelope().from()[0].toString()); @@ -136,28 +162,28 @@ void ViewMail::slotForward() ftext += QString("Subject: %1\n") .arg(_mail.envelope().subject()); ftext += QString("\n%1\n") .arg(_mail.bodyPart(1).data()); ftext += QString("----- End forwarded message -----\n"); SendMail sendMail; sendMail.setSubject("Fwd: " + _mail.envelope().subject()); sendMail.setMessage(ftext); - Composer *composer = new Composer(0, 0, Qt::WType_Modal); - composer->setSendMail(sendMail); - composer->showMaximized(); - composer->show(); + Composer composer(this, 0, true); + composer.setSendMail(sendMail); + composer.showMaximized(); + composer.exec(); } void ViewMail::slotIMAPUid(IMAPResponse &response) { disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); if (response.statusResponse().status() == IMAPResponseEnums::OK) { QValueList<IMAPResponseBodyPart> bodyParts; bodyParts.append(response.FETCH()[0].bodyPart(1)); _mail.setBodyParts(bodyParts); browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(1).data()))); |