author | alwin <alwin> | 2004-01-02 01:10:54 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-02 01:10:54 (UTC) |
commit | afca439e790b2a6261679fffa42c7eaa2b295824 (patch) (unidiff) | |
tree | 3c22f4e3cd5d210f1c2f6554f3c8673450550fa1 | |
parent | 6bde04710d84fe2c5369c895bd784e9d81754550 (diff) | |
download | opie-afca439e790b2a6261679fffa42c7eaa2b295824.zip opie-afca439e790b2a6261679fffa42c7eaa2b295824.tar.gz opie-afca439e790b2a6261679fffa42c7eaa2b295824.tar.bz2 |
rfc822 messages are displayed as text, too.
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 0ad7359..d2e5e29 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,371 +1,371 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qapplication.h> | 7 | #include <qapplication.h> |
8 | 8 | ||
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | 10 | ||
11 | #include <opie/ofiledialog.h> | 11 | #include <opie/ofiledialog.h> |
12 | 12 | ||
13 | #include "settings.h" | 13 | #include "settings.h" |
14 | #include "composemail.h" | 14 | #include "composemail.h" |
15 | #include "viewmail.h" | 15 | #include "viewmail.h" |
16 | #include "abstractmail.h" | 16 | #include "abstractmail.h" |
17 | #include "accountview.h" | 17 | #include "accountview.h" |
18 | #include "mailtypes.h" | 18 | #include "mailtypes.h" |
19 | 19 | ||
20 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 20 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
21 | const QString&fsize,int num) | 21 | const QString&fsize,int num) |
22 | : QListViewItem(parent,after),_partNum(num) | 22 | : QListViewItem(parent,after),_partNum(num) |
23 | { | 23 | { |
24 | setText(0, mime); | 24 | setText(0, mime); |
25 | setText(1, desc); | 25 | setText(1, desc); |
26 | setText(2, file); | 26 | setText(2, file); |
27 | setText(3, fsize); | 27 | setText(3, fsize); |
28 | } | 28 | } |
29 | 29 | ||
30 | void ViewMail::setBody( RecBody body ) { | 30 | void ViewMail::setBody( RecBody body ) { |
31 | 31 | ||
32 | m_body = body; | 32 | m_body = body; |
33 | m_mail[2] = body.Bodytext(); | 33 | m_mail[2] = body.Bodytext(); |
34 | attachbutton->setEnabled(body.Parts().count()>0); | 34 | attachbutton->setEnabled(body.Parts().count()>0); |
35 | attachments->setEnabled(body.Parts().count()>0); | 35 | attachments->setEnabled(body.Parts().count()>0); |
36 | if (body.Parts().count()==0) { | 36 | if (body.Parts().count()==0) { |
37 | return; | 37 | return; |
38 | } | 38 | } |
39 | AttachItem * curItem=0; | 39 | AttachItem * curItem=0; |
40 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 40 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
41 | QString desc,fsize; | 41 | QString desc,fsize; |
42 | double s = body.Description().Size(); | 42 | double s = body.Description().Size(); |
43 | int w; | 43 | int w; |
44 | w=0; | 44 | w=0; |
45 | 45 | ||
46 | while (s>1024) { | 46 | while (s>1024) { |
47 | s/=1024; | 47 | s/=1024; |
48 | ++w; | 48 | ++w; |
49 | if (w>=2) break; | 49 | if (w>=2) break; |
50 | } | 50 | } |
51 | 51 | ||
52 | QString q=""; | 52 | QString q=""; |
53 | switch(w) { | 53 | switch(w) { |
54 | case 1: | 54 | case 1: |
55 | q="k"; | 55 | q="k"; |
56 | break; | 56 | break; |
57 | case 2: | 57 | case 2: |
58 | q="M"; | 58 | q="M"; |
59 | break; | 59 | break; |
60 | default: | 60 | default: |
61 | break; | 61 | break; |
62 | } | 62 | } |
63 | 63 | ||
64 | { | 64 | { |
65 | /* I did not found a method to make a CONTENT reset on a QTextStream | 65 | /* I did not found a method to make a CONTENT reset on a QTextStream |
66 | so I use this construct that the stream will re-constructed in each | 66 | so I use this construct that the stream will re-constructed in each |
67 | loop. To let it work, the textstream is packed into a own area of | 67 | loop. To let it work, the textstream is packed into a own area of |
68 | code is it will be destructed after finishing its small job. | 68 | code is it will be destructed after finishing its small job. |
69 | */ | 69 | */ |
70 | QTextOStream o(&fsize); | 70 | QTextOStream o(&fsize); |
71 | if (w>0) o.precision(2); else o.precision(0); | 71 | if (w>0) o.precision(2); else o.precision(0); |
72 | o.setf(QTextStream::fixed); | 72 | o.setf(QTextStream::fixed); |
73 | o << s << " " << q << "Byte"; | 73 | o << s << " " << q << "Byte"; |
74 | } | 74 | } |
75 | 75 | ||
76 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1); | 76 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1); |
77 | QString filename = ""; | 77 | QString filename = ""; |
78 | for (unsigned int i = 0; i < body.Parts().count();++i) { | 78 | for (unsigned int i = 0; i < body.Parts().count();++i) { |
79 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 79 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
80 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 80 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
81 | for (;it!=body.Parts()[i].Parameters().end();++it) { | 81 | for (;it!=body.Parts()[i].Parameters().end();++it) { |
82 | qDebug(it.key()); | 82 | qDebug(it.key()); |
83 | if (it.key().lower()=="name") { | 83 | if (it.key().lower()=="name") { |
84 | filename=it.data(); | 84 | filename=it.data(); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | s = body.Parts()[i].Size(); | 87 | s = body.Parts()[i].Size(); |
88 | w = 0; | 88 | w = 0; |
89 | while (s>1024) { | 89 | while (s>1024) { |
90 | s/=1024; | 90 | s/=1024; |
91 | ++w; | 91 | ++w; |
92 | if (w>=2) break; | 92 | if (w>=2) break; |
93 | } | 93 | } |
94 | switch(w) { | 94 | switch(w) { |
95 | case 1: | 95 | case 1: |
96 | q="k"; | 96 | q="k"; |
97 | break; | 97 | break; |
98 | case 2: | 98 | case 2: |
99 | q="M"; | 99 | q="M"; |
100 | break; | 100 | break; |
101 | default: | 101 | default: |
102 | q=""; | 102 | q=""; |
103 | break; | 103 | break; |
104 | } | 104 | } |
105 | QTextOStream o(&fsize); | 105 | QTextOStream o(&fsize); |
106 | if (w>0) o.precision(2); else o.precision(0); | 106 | if (w>0) o.precision(2); else o.precision(0); |
107 | o.setf(QTextStream::fixed); | 107 | o.setf(QTextStream::fixed); |
108 | o << s << " " << q << "Byte"; | 108 | o << s << " " << q << "Byte"; |
109 | desc = body.Parts()[i].Description(); | 109 | desc = body.Parts()[i].Description(); |
110 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i); | 110 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | void ViewMail::slotShowHtml( bool state ) { | 115 | void ViewMail::slotShowHtml( bool state ) { |
116 | m_showHtml = state; | 116 | m_showHtml = state; |
117 | setText(); | 117 | setText(); |
118 | } | 118 | } |
119 | 119 | ||
120 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { | 120 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { |
121 | if (!item ) | 121 | if (!item ) |
122 | return; | 122 | return; |
123 | 123 | ||
124 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 124 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
125 | setText(); | 125 | setText(); |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | QPopupMenu *menu = new QPopupMenu(); | 128 | QPopupMenu *menu = new QPopupMenu(); |
129 | int ret=0; | 129 | int ret=0; |
130 | 130 | ||
131 | if ( item->text( 0 ).left( 5 ) == "text/" ) { | 131 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { |
132 | menu->insertItem( tr( "Show Text" ), 1 ); | 132 | menu->insertItem( tr( "Show Text" ), 1 ); |
133 | } | 133 | } |
134 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 134 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
135 | menu->insertSeparator(1); | 135 | menu->insertSeparator(1); |
136 | 136 | ||
137 | ret = menu->exec( point, 0 ); | 137 | ret = menu->exec( point, 0 ); |
138 | 138 | ||
139 | switch(ret) { | 139 | switch(ret) { |
140 | case 0: | 140 | case 0: |
141 | { MimeTypes types; | 141 | { MimeTypes types; |
142 | types.insert( "all", "*" ); | 142 | types.insert( "all", "*" ); |
143 | QString str = OFileDialog::getSaveFileName( 1, | 143 | QString str = OFileDialog::getSaveFileName( 1, |
144 | "/", item->text( 2 ) , types, 0 ); | 144 | "/", item->text( 2 ) , types, 0 ); |
145 | 145 | ||
146 | if( !str.isEmpty() ) { | 146 | if( !str.isEmpty() ) { |
147 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 147 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
148 | if (content) { | 148 | if (content) { |
149 | QFile output(str); | 149 | QFile output(str); |
150 | output.open(IO_WriteOnly); | 150 | output.open(IO_WriteOnly); |
151 | output.writeBlock(content->Content(),content->Length()); | 151 | output.writeBlock(content->Content(),content->Length()); |
152 | output.close(); | 152 | output.close(); |
153 | delete content; | 153 | delete content; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | break ; | 157 | break ; |
158 | 158 | ||
159 | case 1: | 159 | case 1: |
160 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 160 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
161 | setText(); | 161 | setText(); |
162 | } else { | 162 | } else { |
163 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions | 163 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions |
164 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 164 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | break; | 167 | break; |
168 | } | 168 | } |
169 | delete menu; | 169 | delete menu; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | void ViewMail::setMail( RecMail mail ) { | 173 | void ViewMail::setMail( RecMail mail ) { |
174 | 174 | ||
175 | m_recMail = mail; | 175 | m_recMail = mail; |
176 | 176 | ||
177 | m_mail[0] = mail.getFrom(); | 177 | m_mail[0] = mail.getFrom(); |
178 | m_mail[1] = mail.getSubject(); | 178 | m_mail[1] = mail.getSubject(); |
179 | m_mail[3] = mail.getDate(); | 179 | m_mail[3] = mail.getDate(); |
180 | m_mail[4] = mail.Msgid(); | 180 | m_mail[4] = mail.Msgid(); |
181 | 181 | ||
182 | m_mail2[0] = mail.To(); | 182 | m_mail2[0] = mail.To(); |
183 | m_mail2[1] = mail.CC(); | 183 | m_mail2[1] = mail.CC(); |
184 | m_mail2[2] = mail.Bcc(); | 184 | m_mail2[2] = mail.Bcc(); |
185 | 185 | ||
186 | setText(); | 186 | setText(); |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | 190 | ||
191 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 191 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
192 | : ViewMailBase(parent, name, fl), _inLoop(false) | 192 | : ViewMailBase(parent, name, fl), _inLoop(false) |
193 | { | 193 | { |
194 | m_gotBody = false; | 194 | m_gotBody = false; |
195 | deleted = false; | 195 | deleted = false; |
196 | 196 | ||
197 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 197 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
198 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 198 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
199 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); | 199 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); |
200 | connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); | 200 | connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); |
201 | 201 | ||
202 | attachments->setEnabled(m_gotBody); | 202 | attachments->setEnabled(m_gotBody); |
203 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); | 203 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); |
204 | 204 | ||
205 | readConfig(); | 205 | readConfig(); |
206 | 206 | ||
207 | } | 207 | } |
208 | 208 | ||
209 | void ViewMail::readConfig() { | 209 | void ViewMail::readConfig() { |
210 | Config cfg( "mail" ); | 210 | Config cfg( "mail" ); |
211 | cfg.setGroup( "Settings" ); | 211 | cfg.setGroup( "Settings" ); |
212 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 212 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
213 | showHtml->setOn( m_showHtml ); | 213 | showHtml->setOn( m_showHtml ); |
214 | } | 214 | } |
215 | 215 | ||
216 | void ViewMail::setText() | 216 | void ViewMail::setText() |
217 | { | 217 | { |
218 | 218 | ||
219 | QString toString; | 219 | QString toString; |
220 | QString ccString; | 220 | QString ccString; |
221 | QString bccString; | 221 | QString bccString; |
222 | 222 | ||
223 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | 223 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { |
224 | toString += (*it); | 224 | toString += (*it); |
225 | } | 225 | } |
226 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | 226 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { |
227 | ccString += (*it); | 227 | ccString += (*it); |
228 | } | 228 | } |
229 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | 229 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { |
230 | bccString += (*it); | 230 | bccString += (*it); |
231 | } | 231 | } |
232 | 232 | ||
233 | setCaption( caption().arg( m_mail[0] ) ); | 233 | setCaption( caption().arg( m_mail[0] ) ); |
234 | 234 | ||
235 | m_mailHtml = "<html><body>" | 235 | m_mailHtml = "<html><body>" |
236 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 236 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
237 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 237 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
238 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 238 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
239 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 239 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
240 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 240 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
241 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 241 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
242 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 242 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
243 | "</td></tr></table><font face=fixed>"; | 243 | "</td></tr></table><font face=fixed>"; |
244 | 244 | ||
245 | if ( !m_showHtml ) { | 245 | if ( !m_showHtml ) { |
246 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 246 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
247 | } else { | 247 | } else { |
248 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 248 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
249 | } | 249 | } |
250 | // remove later in favor of a real handling | 250 | // remove later in favor of a real handling |
251 | m_gotBody = true; | 251 | m_gotBody = true; |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | ViewMail::~ViewMail() | 255 | ViewMail::~ViewMail() |
256 | { | 256 | { |
257 | m_recMail.Wrapper()->cleanMimeCache(); | 257 | m_recMail.Wrapper()->cleanMimeCache(); |
258 | hide(); | 258 | hide(); |
259 | } | 259 | } |
260 | 260 | ||
261 | void ViewMail::hide() | 261 | void ViewMail::hide() |
262 | { | 262 | { |
263 | QWidget::hide(); | 263 | QWidget::hide(); |
264 | 264 | ||
265 | if (_inLoop) { | 265 | if (_inLoop) { |
266 | _inLoop = false; | 266 | _inLoop = false; |
267 | qApp->exit_loop(); | 267 | qApp->exit_loop(); |
268 | 268 | ||
269 | } | 269 | } |
270 | 270 | ||
271 | } | 271 | } |
272 | 272 | ||
273 | void ViewMail::exec() | 273 | void ViewMail::exec() |
274 | { | 274 | { |
275 | show(); | 275 | show(); |
276 | 276 | ||
277 | if (!_inLoop) { | 277 | if (!_inLoop) { |
278 | _inLoop = true; | 278 | _inLoop = true; |
279 | qApp->enter_loop(); | 279 | qApp->enter_loop(); |
280 | } | 280 | } |
281 | 281 | ||
282 | } | 282 | } |
283 | 283 | ||
284 | QString ViewMail::deHtml(const QString &string) | 284 | QString ViewMail::deHtml(const QString &string) |
285 | { | 285 | { |
286 | QString string_ = string; | 286 | QString string_ = string; |
287 | string_.replace(QRegExp("&"), "&"); | 287 | string_.replace(QRegExp("&"), "&"); |
288 | string_.replace(QRegExp("<"), "<"); | 288 | string_.replace(QRegExp("<"), "<"); |
289 | string_.replace(QRegExp(">"), ">"); | 289 | string_.replace(QRegExp(">"), ">"); |
290 | string_.replace(QRegExp("\\n"), "<br>"); | 290 | string_.replace(QRegExp("\\n"), "<br>"); |
291 | return string_; | 291 | return string_; |
292 | } | 292 | } |
293 | 293 | ||
294 | void ViewMail::slotReply() | 294 | void ViewMail::slotReply() |
295 | { | 295 | { |
296 | if (!m_gotBody) { | 296 | if (!m_gotBody) { |
297 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 297 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
298 | return; | 298 | return; |
299 | } | 299 | } |
300 | 300 | ||
301 | QString rtext; | 301 | QString rtext; |
302 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 302 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
303 | .arg( m_mail[0] ) | 303 | .arg( m_mail[0] ) |
304 | .arg( m_mail[3] ); | 304 | .arg( m_mail[3] ); |
305 | 305 | ||
306 | QString text = m_mail[2]; | 306 | QString text = m_mail[2]; |
307 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 307 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
308 | QStringList::Iterator it; | 308 | QStringList::Iterator it; |
309 | for (it = lines.begin(); it != lines.end(); it++) { | 309 | for (it = lines.begin(); it != lines.end(); it++) { |
310 | rtext += "> " + *it + "\n"; | 310 | rtext += "> " + *it + "\n"; |
311 | } | 311 | } |
312 | rtext += "\n"; | 312 | rtext += "\n"; |
313 | 313 | ||
314 | QString prefix; | 314 | QString prefix; |
315 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; | 315 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; |
316 | else prefix = "Re: "; // no i18n on purpose | 316 | else prefix = "Re: "; // no i18n on purpose |
317 | 317 | ||
318 | Settings *settings = new Settings(); | 318 | Settings *settings = new Settings(); |
319 | ComposeMail composer( settings ,this, 0, true); | 319 | ComposeMail composer( settings ,this, 0, true); |
320 | composer.setTo( m_mail[0] ); | 320 | composer.setTo( m_mail[0] ); |
321 | composer.setSubject( "Re: " + m_mail[1] ); | 321 | composer.setSubject( "Re: " + m_mail[1] ); |
322 | composer.setMessage( rtext ); | 322 | composer.setMessage( rtext ); |
323 | composer.showMaximized(); | 323 | composer.showMaximized(); |
324 | if ( QDialog::Accepted==composer.exec()) { | 324 | if ( QDialog::Accepted==composer.exec()) { |
325 | m_recMail.Wrapper()->answeredMail(m_recMail); | 325 | m_recMail.Wrapper()->answeredMail(m_recMail); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | 328 | ||
329 | void ViewMail::slotForward() | 329 | void ViewMail::slotForward() |
330 | { | 330 | { |
331 | if (!m_gotBody) { | 331 | if (!m_gotBody) { |
332 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 332 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | 335 | ||
336 | QString ftext; | 336 | QString ftext; |
337 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 337 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
338 | .arg( m_mail[0] ); | 338 | .arg( m_mail[0] ); |
339 | if (!m_mail[3].isNull()) | 339 | if (!m_mail[3].isNull()) |
340 | ftext += QString("Date: %1\n") | 340 | ftext += QString("Date: %1\n") |
341 | .arg( m_mail[3] ); | 341 | .arg( m_mail[3] ); |
342 | if (!m_mail[0].isNull()) | 342 | if (!m_mail[0].isNull()) |
343 | ftext += QString("From: %1\n") | 343 | ftext += QString("From: %1\n") |
344 | .arg( m_mail[0] ); | 344 | .arg( m_mail[0] ); |
345 | if (!m_mail[1].isNull()) | 345 | if (!m_mail[1].isNull()) |
346 | ftext += QString("Subject: %1\n") | 346 | ftext += QString("Subject: %1\n") |
347 | .arg( m_mail[1] ); | 347 | .arg( m_mail[1] ); |
348 | 348 | ||
349 | ftext += QString("\n%1\n") | 349 | ftext += QString("\n%1\n") |
350 | .arg( m_mail[2]); | 350 | .arg( m_mail[2]); |
351 | 351 | ||
352 | ftext += QString("----- End forwarded message -----\n"); | 352 | ftext += QString("----- End forwarded message -----\n"); |
353 | 353 | ||
354 | Settings *settings = new Settings(); | 354 | Settings *settings = new Settings(); |
355 | ComposeMail composer( settings ,this, 0, true); | 355 | ComposeMail composer( settings ,this, 0, true); |
356 | composer.setSubject( "Fwd: " + m_mail[1] ); | 356 | composer.setSubject( "Fwd: " + m_mail[1] ); |
357 | composer.setMessage( ftext ); | 357 | composer.setMessage( ftext ); |
358 | composer.showMaximized(); | 358 | composer.showMaximized(); |
359 | if ( QDialog::Accepted==composer.exec()) { | 359 | if ( QDialog::Accepted==composer.exec()) { |
360 | 360 | ||
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | void ViewMail::slotDeleteMail( ) | 364 | void ViewMail::slotDeleteMail( ) |
365 | { | 365 | { |
366 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { | 366 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { |
367 | m_recMail.Wrapper()->deleteMail( m_recMail ); | 367 | m_recMail.Wrapper()->deleteMail( m_recMail ); |
368 | hide(); | 368 | hide(); |
369 | deleted = true; | 369 | deleted = true; |
370 | } | 370 | } |
371 | } | 371 | } |