summaryrefslogtreecommitdiffabout
path: root/kmicromail/viewmail.cpp
Unidiff
Diffstat (limited to 'kmicromail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/viewmail.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 67b77f8..6e560d7 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -1,92 +1,92 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2#include "composemail.h" 2#include "composemail.h"
3#include "viewmail.h" 3#include "viewmail.h"
4 4
5#include <libmailwrapper/settings.h> 5#include <libmailwrapper/settings.h>
6#include <libmailwrapper/abstractmail.h> 6#include <libmailwrapper/abstractmail.h>
7#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
8#include <kapplication.h> 8#include <kapplication.h>
9 9
10/* OPIE */ 10/* OPIE */
11//#include <opie2/odebug.h> 11//#include <opie2/odebug.h>
12//#include <opie2/ofiledialog.h> 12//#include <opie2/ofiledialog.h>
13//#include <opie2/oimagescrollview.h> 13//#include <opie2/oimagescrollview.h>
14 14
15#include <kfiledialog.h> 15#include <kfiledialog.h>
16#include <kdialog.h> 16#include <kdialog.h>
17 17
18#include <qpe/config.h>
19#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
20 19
21/* QT */ 20/* QT */
22#include <qtextbrowser.h> 21#include <qtextbrowser.h>
23#include <qmessagebox.h> 22#include <qmessagebox.h>
24#include <qtextstream.h> 23#include <qtextstream.h>
25#include <qaction.h> 24#include <qaction.h>
26#include <qpopupmenu.h> 25#include <qpopupmenu.h>
27#include <qfile.h> 26#include <qfile.h>
28#include <qlayout.h> 27#include <qlayout.h>
28#include "koprefs.h"
29 29
30//using namespace Opie::Ui; 30//using namespace Opie::Ui;
31//using namespace Opie::Core; 31//using namespace Opie::Core;
32 32
33AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 33AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
34 const QString&fsize,int num,const QValueList<int>&path) 34 const QString&fsize,int num,const QValueList<int>&path)
35 : QListViewItem(parent,after),_partNum(num) 35 : QListViewItem(parent,after),_partNum(num)
36{ 36{
37 _path=path; 37 _path=path;
38 setText(0, mime); 38 setText(0, mime);
39 setText(1, desc); 39 setText(1, desc);
40 setText(2, file); 40 setText(2, file);
41 setText(3, fsize); 41 setText(3, fsize);
42} 42}
43 43
44AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 44AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
45 const QString&fsize,int num,const QValueList<int>&path) 45 const QString&fsize,int num,const QValueList<int>&path)
46 : QListViewItem(parent,after),_partNum(num) 46 : QListViewItem(parent,after),_partNum(num)
47{ 47{
48 _path=path; 48 _path=path;
49 setText(0, mime); 49 setText(0, mime);
50 setText(1, desc); 50 setText(1, desc);
51 setText(2, file); 51 setText(2, file);
52 setText(3, fsize); 52 setText(3, fsize);
53} 53}
54 54
55bool AttachItem::isParentof(const QValueList<int>&path) 55bool AttachItem::isParentof(const QValueList<int>&path)
56{ 56{
57 /* if not set, then no parent */ 57 /* if not set, then no parent */
58 if (path.count()==0||_path.count()==0) return false; 58 if (path.count()==0||_path.count()==0) return false;
59 /* the parent must have one digit less then a child */ 59 /* the parent must have one digit less then a child */
60 if (path.count()!=_path.count()+1) return false; 60 if (path.count()!=_path.count()+1) return false;
61 for (unsigned int i=0; i < _path.count();++i) 61 for (unsigned int i=0; i < _path.count();++i)
62 { 62 {
63 if (_path[i]!=path[i]) return false; 63 if (_path[i]!=path[i]) return false;
64 } 64 }
65 return true; 65 return true;
66} 66}
67 67
68AttachItem* ViewMail::searchParent(const QValueList<int>&path) 68AttachItem* ViewMail::searchParent(const QValueList<int>&path)
69{ 69{
70 QListViewItemIterator it( attachments ); 70 QListViewItemIterator it( attachments );
71 for ( ; it.current(); ++it ) 71 for ( ; it.current(); ++it )
72 { 72 {
73 AttachItem*ati = (AttachItem*)it.current(); 73 AttachItem*ati = (AttachItem*)it.current();
74 if (ati->isParentof(path)) return ati; 74 if (ati->isParentof(path)) return ati;
75 } 75 }
76 return 0; 76 return 0;
77} 77}
78 78
79AttachItem* ViewMail::lastChild(AttachItem*parent) 79AttachItem* ViewMail::lastChild(AttachItem*parent)
80{ 80{
81 if (!parent) return 0; 81 if (!parent) return 0;
82 AttachItem* item = (AttachItem*)parent->firstChild(); 82 AttachItem* item = (AttachItem*)parent->firstChild();
83 if (!item) return item; 83 if (!item) return item;
84 AttachItem*temp=0; 84 AttachItem*temp=0;
85 while( (temp=(AttachItem*)item->nextSibling())) 85 while( (temp=(AttachItem*)item->nextSibling()))
86 { 86 {
87 item = temp; 87 item = temp;
88 } 88 }
89 return item; 89 return item;
90} 90}
91 91
92void ViewMail::setBody(const RecBodyP&body ) 92void ViewMail::setBody(const RecBodyP&body )
@@ -265,165 +265,165 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
265 iview.setName(tmpfile); 265 iview.setName(tmpfile);
266 KApplication::execDialog(&iview); 266 KApplication::execDialog(&iview);
267 output.remove(); 267 output.remove();
268 } 268 }
269 } 269 }
270 break; 270 break;
271 case 1: 271 case 1:
272 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 272 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
273 { 273 {
274 setText(); 274 setText();
275 } 275 }
276 else 276 else
277 { 277 {
278 if ( m_recMail->Wrapper() != 0l ) 278 if ( m_recMail->Wrapper() != 0l )
279 { // make sure that there is a wrapper , even after delete or simular actions 279 { // make sure that there is a wrapper , even after delete or simular actions
280 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 280 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
281 } 281 }
282 } 282 }
283 break; 283 break;
284 } 284 }
285 delete menu; 285 delete menu;
286} 286}
287 287
288 288
289void ViewMail::setMail(const RecMailP&mail ) 289void ViewMail::setMail(const RecMailP&mail )
290{ 290{
291 291
292 m_recMail = mail; 292 m_recMail = mail;
293 293
294 m_mail[0] = mail->getFrom(); 294 m_mail[0] = mail->getFrom();
295 m_mail[1] = mail->getSubject(); 295 m_mail[1] = mail->getSubject();
296 m_mail[3] = mail->getDate(); 296 m_mail[3] = mail->getDate();
297 m_mail[4] = mail->Msgid(); 297 m_mail[4] = mail->Msgid();
298 298
299 m_mail2[0] = mail->To(); 299 m_mail2[0] = mail->To();
300 m_mail2[1] = mail->CC(); 300 m_mail2[1] = mail->CC();
301 m_mail2[2] = mail->Bcc(); 301 m_mail2[2] = mail->Bcc();
302 302
303 setText(); 303 setText();
304} 304}
305 305
306 306
307 307
308ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 308ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
309 : ViewMailBase(parent, name, fl), _inLoop(false) 309 : ViewMailBase(parent, name, fl), _inLoop(false)
310{ 310{
311 m_gotBody = false; 311 m_gotBody = false;
312 deleted = false; 312 deleted = false;
313 313
314 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 314 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
315 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 315 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
316 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 316 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
317 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 317 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
318 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 318 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
319 319
320 attachments->setEnabled(m_gotBody); 320 attachments->setEnabled(m_gotBody);
321 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 321 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
322 322
323 readConfig(); 323 readConfig();
324 attachments->setSorting(-1); 324 attachments->setSorting(-1);
325} 325}
326 326
327void ViewMail::readConfig() 327void ViewMail::readConfig()
328{ 328{
329 Config cfg( "mail" ); 329
330 cfg.setGroup( "Settings" ); 330 setFont ( KOPrefs::instance()->mReadFont );
331 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 331 m_showHtml = KOPrefs::instance()->mViewAsHtml;
332 showHtml->setOn( m_showHtml ); 332 showHtml->setOn( m_showHtml );
333} 333}
334 334
335void ViewMail::setText() 335void ViewMail::setText()
336{ 336{
337 337
338 QString toString; 338 QString toString;
339 QString ccString; 339 QString ccString;
340 QString bccString; 340 QString bccString;
341 341
342 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 342 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
343 { 343 {
344 toString += (*it); 344 toString += (*it);
345 } 345 }
346 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 346 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
347 { 347 {
348 ccString += (*it); 348 ccString += (*it);
349 } 349 }
350 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 350 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
351 { 351 {
352 bccString += (*it); 352 bccString += (*it);
353 } 353 }
354 354
355 setCaption( tr("E-Mail by %1").arg( m_mail[0] ) ); 355 setCaption( tr("E-Mail by %1").arg( m_mail[0] ) );
356 356
357 m_mailHtml = "<html><body>" 357 m_mailHtml = "<html><body>"
358 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 358 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
359 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 359 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
360 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 360 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
361 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 361 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
362 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 362 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
363 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 363 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
364 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 364 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
365 "</td></tr></table><font face=fixed>"; 365 "</td></tr></table><font>";
366 366
367 if ( !m_showHtml ) 367 if ( !m_showHtml )
368 { 368 {
369 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 369 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
370 } 370 }
371 else 371 else
372 { 372 {
373 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 373 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
374 } 374 }
375 // remove later in favor of a real handling 375 // remove later in favor of a real handling
376 m_gotBody = true; 376 m_gotBody = true;
377} 377}
378 378
379 379
380ViewMail::~ViewMail() 380ViewMail::~ViewMail()
381{ 381{
382 m_recMail->Wrapper()->cleanMimeCache(); 382 m_recMail->Wrapper()->cleanMimeCache();
383 hide(); 383 hide();
384} 384}
385 385
386void ViewMail::hide() 386void ViewMail::hide()
387{ 387{
388 QWidget::hide(); 388 QWidget::hide();
389 389
390 if (_inLoop) 390 if (_inLoop)
391 { 391 {
392 _inLoop = false; 392 _inLoop = false;
393 qApp->exit_loop(); 393 qApp->exit_loop();
394 394
395 } 395 }
396 396
397} 397}
398 398
399void ViewMail::exec() 399void ViewMail::exec()
400{ 400{
401 show(); 401 show();
402 402
403 if (!_inLoop) 403 if (!_inLoop)
404 { 404 {
405 _inLoop = true; 405 _inLoop = true;
406 qApp->enter_loop(); 406 qApp->enter_loop();
407 } 407 }
408 408
409} 409}
410 410
411QString ViewMail::deHtml(const QString &string) 411QString ViewMail::deHtml(const QString &string)
412{ 412{
413 QString string_ = string; 413 QString string_ = string;
414 string_.replace(QRegExp("&"), "&amp;"); 414 string_.replace(QRegExp("&"), "&amp;");
415 string_.replace(QRegExp("<"), "&lt;"); 415 string_.replace(QRegExp("<"), "&lt;");
416 string_.replace(QRegExp(">"), "&gt;"); 416 string_.replace(QRegExp(">"), "&gt;");
417 string_.replace(QRegExp("\\n"), "<br>"); 417 string_.replace(QRegExp("\\n"), "<br>");
418 return string_; 418 return string_;
419} 419}
420 420
421void ViewMail::slotReply() 421void ViewMail::slotReply()
422{ 422{
423 if (!m_gotBody) 423 if (!m_gotBody)
424 { 424 {
425 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 425 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
426 return; 426 return;
427 } 427 }
428 428
429 QString rtext; 429 QString rtext;