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