summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp30
-rw-r--r--noncore/net/mail/viewmail.h1
-rw-r--r--noncore/net/mail/viewmailbase.cpp81
-rw-r--r--noncore/net/mail/viewmailbase.h20
4 files changed, 65 insertions, 67 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index d5f9b7f..d2f1584 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -11,24 +11,25 @@
11#include <opie2/oimagescrollview.h> 11#include <opie2/oimagescrollview.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14 14
15/* QT */ 15/* QT */
16#include <qtextbrowser.h> 16#include <qtextbrowser.h>
17#include <qmessagebox.h> 17#include <qmessagebox.h>
18#include <qtextstream.h> 18#include <qtextstream.h>
19#include <qaction.h> 19#include <qaction.h>
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qlayout.h> 22#include <qlayout.h>
23#include <qstylesheet.h>
23 24
24using namespace Opie::Ui; 25using namespace Opie::Ui;
25using namespace Opie::Core; 26using namespace Opie::Core;
26 27
27AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 28AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
28 const QString&fsize,int num,const QValueList<int>&path) 29 const QString&fsize,int num,const QValueList<int>&path)
29 : QListViewItem(parent,after),_partNum(num) 30 : QListViewItem(parent,after),_partNum(num)
30{ 31{
31 _path=path; 32 _path=path;
32 setText(0, mime); 33 setText(0, mime);
33 setText(1, desc); 34 setText(1, desc);
34 setText(2, file); 35 setText(2, file);
@@ -287,24 +288,25 @@ void ViewMail::setMail(const RecMailP&mail )
287 288
288 m_recMail = mail; 289 m_recMail = mail;
289 290
290 m_mail[0] = mail->getFrom(); 291 m_mail[0] = mail->getFrom();
291 m_mail[1] = mail->getSubject(); 292 m_mail[1] = mail->getSubject();
292 m_mail[3] = mail->getStringDate(); 293 m_mail[3] = mail->getStringDate();
293 m_mail[4] = mail->Msgid(); 294 m_mail[4] = mail->Msgid();
294 295
295 m_mail2[0] = mail->To(); 296 m_mail2[0] = mail->To();
296 m_mail2[1] = mail->CC(); 297 m_mail2[1] = mail->CC();
297 m_mail2[2] = mail->Bcc(); 298 m_mail2[2] = mail->Bcc();
298 299
300 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) );
299 setText(); 301 setText();
300} 302}
301 303
302 304
303 305
304ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 306ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
305 : ViewMailBase(parent, name, fl), _inLoop(false) 307 : ViewMailBase(parent, name, fl), _inLoop(false)
306{ 308{
307 m_gotBody = false; 309 m_gotBody = false;
308 deleted = false; 310 deleted = false;
309 311
310 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 312 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
@@ -320,61 +322,55 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
320} 322}
321 323
322void ViewMail::readConfig() 324void ViewMail::readConfig()
323{ 325{
324 Config cfg( "mail" ); 326 Config cfg( "mail" );
325 cfg.setGroup( "Settings" ); 327 cfg.setGroup( "Settings" );
326 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 328 m_showHtml = cfg.readBoolEntry( "showHtml", false );
327 showHtml->setOn( m_showHtml ); 329 showHtml->setOn( m_showHtml );
328} 330}
329 331
330void ViewMail::setText() 332void ViewMail::setText()
331{ 333{
332
333 QString toString; 334 QString toString;
334 QString ccString; 335 QString ccString;
335 QString bccString; 336 QString bccString;
337 QString mailHtml;
336 338
337 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 339 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
338 { 340 {
339 toString += (*it); 341 toString += (*it);
340 } 342 }
341 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 343 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
342 { 344 {
343 ccString += (*it); 345 ccString += (*it);
344 } 346 }
345 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 347 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
346 { 348 {
347 bccString += (*it); 349 bccString += (*it);
348 } 350 }
349 351 browser->setTextFormat(Qt::RichText);
350 setCaption( caption().arg( m_mail[0] ) ); 352 mailHtml = "<html><body>"
351
352 m_mailHtml = "<html><body>"
353 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 353 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
354 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 354 "<div align=left><b>" + deHtml(m_mail[1]) + "</b></div>"
355 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 355 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
356 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 356 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
357 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 357 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
358 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 358 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
359 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 359 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
360 "</td></tr></table><font face=fixed>"; 360 "</td></tr></table>";
361 361 if ( !m_showHtml ) {
362 if ( !m_showHtml ) 362 browser->setText( mailHtml+"<font face=fixed>" + QStyleSheet::convertFromPlainText(m_mail[2]) + "</font></body></html>" );
363 { 363 } else {
364 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 364 browser->setText(mailHtml+m_mail[2].simplifyWhiteSpace()+"</html>");
365 }
366 else
367 {
368 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
369 } 365 }
370 // remove later in favor of a real handling 366 // remove later in favor of a real handling
371 m_gotBody = true; 367 m_gotBody = true;
372} 368}
373 369
374 370
375ViewMail::~ViewMail() 371ViewMail::~ViewMail()
376{ 372{
377 m_recMail->Wrapper()->cleanMimeCache(); 373 m_recMail->Wrapper()->cleanMimeCache();
378 hide(); 374 hide();
379} 375}
380 376
@@ -394,27 +390,27 @@ void ViewMail::hide()
394void ViewMail::exec() 390void ViewMail::exec()
395{ 391{
396 show(); 392 show();
397 393
398 if (!_inLoop) 394 if (!_inLoop)
399 { 395 {
400 _inLoop = true; 396 _inLoop = true;
401 qApp->enter_loop(); 397 qApp->enter_loop();
402 } 398 }
403 399
404} 400}
405 401
406QString ViewMail::deHtml(const QString &string) 402QString ViewMail::deHtml(const QString &aString)
407{ 403{
408 QString string_ = string; 404 QString string_ = aString;
409 string_.replace(QRegExp("&"), "&amp;"); 405 string_.replace(QRegExp("&"), "&amp;");
410 string_.replace(QRegExp("<"), "&lt;"); 406 string_.replace(QRegExp("<"), "&lt;");
411 string_.replace(QRegExp(">"), "&gt;"); 407 string_.replace(QRegExp(">"), "&gt;");
412 string_.replace(QRegExp("\\n"), "<br>"); 408 string_.replace(QRegExp("\\n"), "<br>");
413 return string_; 409 return string_;
414} 410}
415 411
416void ViewMail::slotReply() 412void ViewMail::slotReply()
417{ 413{
418 if (!m_gotBody) 414 if (!m_gotBody)
419 { 415 {
420 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 416 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index 297836b..560453a 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -43,24 +43,25 @@ public:
43 void setBody(const RecBodyP&body); 43 void setBody(const RecBodyP&body);
44 bool deleted; 44 bool deleted;
45 45
46protected: 46protected:
47 QString deHtml(const QString &string); 47 QString deHtml(const QString &string);
48 AttachItem* searchParent(const QValueList<int>&path); 48 AttachItem* searchParent(const QValueList<int>&path);
49 AttachItem* lastChild(AttachItem*parent); 49 AttachItem* lastChild(AttachItem*parent);
50 50
51protected slots: 51protected slots:
52 void slotReply(); 52 void slotReply();
53 void slotForward(); 53 void slotForward();
54 void setText(); 54 void setText();
55 void setHeader();
55 void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); 56 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
56 void slotDeleteMail( ); 57 void slotDeleteMail( );
57 void slotShowHtml( bool ); 58 void slotShowHtml( bool );
58 59
59private: 60private:
60 void readConfig(); 61 void readConfig();
61 62
62 bool _inLoop; 63 bool _inLoop;
63 QString m_mailHtml; 64 QString m_mailHtml;
64 bool m_gotBody; 65 bool m_gotBody;
65 RecBodyP m_body; 66 RecBodyP m_body;
66 RecMailP m_recMail; 67 RecMailP m_recMail;
diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp
index cbb98cc..49a0e6a 100644
--- a/noncore/net/mail/viewmailbase.cpp
+++ b/noncore/net/mail/viewmailbase.cpp
@@ -3,87 +3,88 @@
3#include <qaction.h> 3#include <qaction.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qvbox.h> 5#include <qvbox.h>
6 6
7#include <qtoolbar.h> 7#include <qtoolbar.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qpe/resource.h> 9#include <qpe/resource.h>
10 10
11#include "viewmailbase.h" 11#include "viewmailbase.h"
12//#include "opendiag.h" 12//#include "opendiag.h"
13 13
14ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) 14ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
15 : QMainWindow(parent, name, fl) 15 : QMainWindow(parent, name, fl)
16{ 16{
17 setCaption(tr("E-Mail by %1")); 17 setCaption(tr("E-Mail view"));
18 setToolBarsMovable(false); 18 setToolBarsMovable(false);
19 19
20 toolbar = new QToolBar(this); 20 toolbar = new QToolBar(this);
21 menubar = new QMenuBar( toolbar ); 21 menubar = new QMenuBar( toolbar );
22 mailmenu = new QPopupMenu( menubar ); 22 mailmenu = new QPopupMenu( menubar );
23 menubar->insertItem( tr( "Mail" ), mailmenu ); 23 menubar->insertItem( tr( "Mail" ), mailmenu );
24 24
25 toolbar->setHorizontalStretchable(true); 25 toolbar->setHorizontalStretchable(true);
26 addToolBar(toolbar); 26 addToolBar(toolbar);
27 27
28 QLabel *spacer = new QLabel(toolbar); 28 QLabel *spacer = new QLabel(toolbar);
29 spacer->setBackgroundMode(QWidget::PaletteButton); 29 spacer->setBackgroundMode(QWidget::PaletteButton);
30 toolbar->setStretchableWidget(spacer); 30 toolbar->setStretchableWidget(spacer);
31 31
32 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); 32 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this);
33 reply->addTo(toolbar); 33 reply->addTo(toolbar);
34 reply->addTo(mailmenu); 34 reply->addTo(mailmenu);
35 35
36 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); 36 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this);
37 forward->addTo(toolbar); 37 forward->addTo(toolbar);
38 forward->addTo(mailmenu); 38 forward->addTo(mailmenu);
39 39
40 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); 40 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
41 attachbutton->addTo(toolbar); 41 attachbutton->addTo(toolbar);
42 attachbutton->addTo(mailmenu); 42 attachbutton->addTo(mailmenu);
43 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); 43 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
44 44
45 45
46 showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true ); 46 showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true );
47 showHtml->addTo( toolbar ); 47 showHtml->addTo( toolbar );
48 showHtml->addTo( mailmenu ); 48 showHtml->addTo( mailmenu );
49 49
50 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this); 50 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this);
51 deleteMail->addTo(toolbar); 51 deleteMail->addTo(toolbar);
52 deleteMail->addTo(mailmenu); 52 deleteMail->addTo(mailmenu);
53 53
54 QVBox *view = new QVBox(this); 54 QVBox *view = new QVBox(this);
55 setCentralWidget(view); 55 setCentralWidget(view);
56 56
57 attachments = new QListView(view); 57 attachments = new QListView(view);
58 attachments->setMinimumHeight(90); 58 attachments->setMinimumHeight(90);
59 attachments->setMaximumHeight(90); 59 attachments->setMaximumHeight(90);
60 attachments->setAllColumnsShowFocus(true); 60 attachments->setAllColumnsShowFocus(true);
61 attachments->addColumn("Mime Type", 60); 61 attachments->addColumn("Mime Type", 60);
62 attachments->addColumn(tr("Description"), 100); 62 attachments->addColumn(tr("Description"), 100);
63 attachments->addColumn(tr("Filename"), 80); 63 attachments->addColumn(tr("Filename"), 80);
64 attachments->addColumn(tr("Size"), 80); 64 attachments->addColumn(tr("Size"), 80);
65 attachments->setSorting(-1); 65 attachments->setSorting(-1);
66 attachments->hide(); 66 attachments->hide();
67 67
68 browser = new QTextBrowser(view); 68 //header = new QTextBrowser(view);
69 browser = new QTextBrowser(view);
69 70
70 //openDiag = new OpenDiag(view); 71// openDiag = new OpenDiag(view);
71 //openDiag->hide(); 72// openDiag->hide();
72 73
73} 74}
74 75
75void ViewMailBase::slotChangeAttachview(bool state) 76void ViewMailBase::slotChangeAttachview(bool state)
76{ 77{
77 if (state) attachments->show(); 78 if (state) attachments->show();
78 else attachments->hide(); 79 else attachments->hide();
79} 80}
80 81
81void ViewMailBase::keyPressEvent ( QKeyEvent * e ) 82void ViewMailBase::keyPressEvent ( QKeyEvent * e )
82{ 83{
83 if( e->key()==Qt::Key_Escape ) { 84 if( e->key()==Qt::Key_Escape ) {
84 close(); 85 close();
85 e->accept(); 86 e->accept();
86 return; 87 return;
87 } 88 }
88 QWidget::keyPressEvent(e); 89 QWidget::keyPressEvent(e);
89} 90}
diff --git a/noncore/net/mail/viewmailbase.h b/noncore/net/mail/viewmailbase.h
index fdaad2a..583b1f6 100644
--- a/noncore/net/mail/viewmailbase.h
+++ b/noncore/net/mail/viewmailbase.h
@@ -4,35 +4,35 @@
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5 5
6class QAction; 6class QAction;
7class OpenDiag; 7class OpenDiag;
8class QListView; 8class QListView;
9class QToolBar; 9class QToolBar;
10class QTextBrowser; 10class QTextBrowser;
11class QMenuBar; 11class QMenuBar;
12class QPopupMenu; 12class QPopupMenu;
13 13
14class ViewMailBase : public QMainWindow 14class ViewMailBase : public QMainWindow
15{ 15{
16 Q_OBJECT 16 Q_OBJECT
17 17
18public: 18public:
19 ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); 19 ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
20 20
21protected: 21protected:
22 QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml; 22 QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml;
23 QListView *attachments; 23 QListView *attachments;
24 QToolBar *toolbar; 24 QToolBar *toolbar;
25 QTextBrowser *browser; 25 QTextBrowser *browser;//,*header;
26 OpenDiag *openDiag; 26 OpenDiag *openDiag;
27 QMenuBar *menubar; 27 QMenuBar *menubar;
28 QPopupMenu *mailmenu; 28 QPopupMenu *mailmenu;
29 29
30protected slots: 30protected slots:
31 void slotChangeAttachview(bool state); 31 void slotChangeAttachview(bool state);
32 virtual void keyPressEvent ( QKeyEvent * e ); 32 virtual void keyPressEvent ( QKeyEvent * e );
33 33
34 34
35}; 35};
36 36
37#endif 37#endif
38 38