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