Diffstat (limited to 'noncore/unsupported/mail2/viewmail.cpp') (more/less context) (ignore 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,9 +1,10 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qapplication.h> | ||
4 | 5 | ||
5 | #include "mailfactory.h" | 6 | #include "mailfactory.h" |
6 | #include "composer.h" | 7 | #include "composer.h" |
7 | #include "viewmail.h" | 8 | #include "viewmail.h" |
8 | 9 | ||
9 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) | 10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) |
@@ -20,13 +21,13 @@ AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) | |||
20 | setText(0, _attachItemStore.mimeType()); | 21 | setText(0, _attachItemStore.mimeType()); |
21 | setText(1, _attachItemStore.fileName()); | 22 | setText(1, _attachItemStore.fileName()); |
22 | setText(2, _attachItemStore.description()); | 23 | setText(2, _attachItemStore.description()); |
23 | } | 24 | } |
24 | 25 | ||
25 | ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) | 26 | ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) |
26 | : ViewMailBase(parent, name, fl), _mail(mail), _handler(handler) | 27 | : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) |
27 | { | 28 | { |
28 | setCaption(caption().arg(mail.envelope().from()[0].name())); | 29 | setCaption(caption().arg(mail.envelope().from()[0].name())); |
29 | 30 | ||
30 | _gotBody = false; | 31 | _gotBody = false; |
31 | _mailHtml = tr( | 32 | _mailHtml = tr( |
32 | "<html><body>" | 33 | "<html><body>" |
@@ -58,12 +59,37 @@ ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *paren | |||
58 | browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); | 59 | browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); |
59 | 60 | ||
60 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); | 61 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); |
61 | connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); | 62 | connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); |
62 | } | 63 | } |
63 | 64 | ||
65 | ViewMail::~ViewMail() | ||
66 | { | ||
67 | hide(); | ||
68 | } | ||
69 | |||
70 | void ViewMail::hide() | ||
71 | { | ||
72 | QWidget::hide(); | ||
73 | |||
74 | if (_inLoop) { | ||
75 | _inLoop = false; | ||
76 | qApp->exit_loop(); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | void ViewMail::exec() | ||
81 | { | ||
82 | show(); | ||
83 | |||
84 | if (!_inLoop) { | ||
85 | _inLoop = true; | ||
86 | qApp->enter_loop(); | ||
87 | } | ||
88 | } | ||
89 | |||
64 | QString ViewMail::deHtml(const QString &string) | 90 | QString ViewMail::deHtml(const QString &string) |
65 | { | 91 | { |
66 | QString string_ = string; | 92 | QString string_ = string; |
67 | string_.replace(QRegExp("&"), "&"); | 93 | string_.replace(QRegExp("&"), "&"); |
68 | string_.replace(QRegExp("<"), "<"); | 94 | string_.replace(QRegExp("<"), "<"); |
69 | string_.replace(QRegExp(">"), ">"); | 95 | string_.replace(QRegExp(">"), ">"); |
@@ -98,16 +124,16 @@ void ViewMail::slotReply() | |||
98 | SendMail sendMail; | 124 | SendMail sendMail; |
99 | sendMail.setTo(_mail.envelope().from()[0].toString()); | 125 | sendMail.setTo(_mail.envelope().from()[0].toString()); |
100 | sendMail.setSubject(prefix + _mail.envelope().subject()); | 126 | sendMail.setSubject(prefix + _mail.envelope().subject()); |
101 | sendMail.setInReplyTo(_mail.envelope().messageId()); | 127 | sendMail.setInReplyTo(_mail.envelope().messageId()); |
102 | sendMail.setMessage(rtext); | 128 | sendMail.setMessage(rtext); |
103 | 129 | ||
104 | Composer *composer = new Composer(0, 0, Qt::WType_Modal); | 130 | Composer composer(this, 0, true); |
105 | composer->setSendMail(sendMail); | 131 | composer.setSendMail(sendMail); |
106 | composer->showMaximized(); | 132 | composer.showMaximized(); |
107 | composer->show(); | 133 | composer.exec(); |
108 | } | 134 | } |
109 | 135 | ||
110 | void ViewMail::slotForward() | 136 | void ViewMail::slotForward() |
111 | { | 137 | { |
112 | if (!_gotBody) { | 138 | if (!_gotBody) { |
113 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 139 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
@@ -142,16 +168,16 @@ void ViewMail::slotForward() | |||
142 | ftext += QString("----- End forwarded message -----\n"); | 168 | ftext += QString("----- End forwarded message -----\n"); |
143 | 169 | ||
144 | SendMail sendMail; | 170 | SendMail sendMail; |
145 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); | 171 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); |
146 | sendMail.setMessage(ftext); | 172 | sendMail.setMessage(ftext); |
147 | 173 | ||
148 | Composer *composer = new Composer(0, 0, Qt::WType_Modal); | 174 | Composer composer(this, 0, true); |
149 | composer->setSendMail(sendMail); | 175 | composer.setSendMail(sendMail); |
150 | composer->showMaximized(); | 176 | composer.showMaximized(); |
151 | composer->show(); | 177 | composer.exec(); |
152 | } | 178 | } |
153 | 179 | ||
154 | void ViewMail::slotIMAPUid(IMAPResponse &response) | 180 | void ViewMail::slotIMAPUid(IMAPResponse &response) |
155 | { | 181 | { |
156 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); | 182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); |
157 | 183 | ||