summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp46
-rw-r--r--noncore/net/mail/viewmail.h9
-rw-r--r--noncore/net/mail/viewmailbase.cpp26
-rw-r--r--noncore/net/mail/viewmailbase.h2
4 files changed, 64 insertions, 19 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index d2f1584..a64a168 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -241,36 +241,49 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
241 QFile output(str); 241 QFile output(str);
242 output.open(IO_WriteOnly); 242 output.open(IO_WriteOnly);
243 output.writeBlock(content->Content(),content->Length()); 243 output.writeBlock(content->Content(),content->Length());
244 output.close(); 244 output.close();
245 delete content; 245 delete content;
246 } 246 }
247 } 247 }
248 } 248 }
249 break ; 249 break ;
250 250
251 case 2: 251 case 2:
252 { 252 {
253 QString tmpfile = "/tmp/opiemail-image"; 253 QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++);
254 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 254 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
255 if (content) { 255 if (content && content->Length()) {
256 QFile output(tmpfile); 256 QFile output(tmpfile);
257 output.open(IO_WriteOnly); 257 output.open(IO_WriteOnly);
258 output.writeBlock(content->Content(),content->Length()); 258 output.writeBlock(content->Content(),content->Length());
259 output.close(); 259 output.close();
260 delete content; 260 delete content;
261 MailImageDlg iview(""); 261 if (!m_PicsInline) {
262 iview.setName(tmpfile); 262 MailImageDlg iview("");
263 QPEApplication::execDialog(&iview); 263 iview.setName(tmpfile);
264 QPEApplication::execDialog(&iview);
265 } else {
266 if (!m_lastdlg) {
267 m_lastdlg=new Opie::MM::OImageScrollView("",browser->parentWidget(),false);
268 m_lastdlg->setAutoScale(true);
269 }
270 //m_lastdlg->setImage("");
271 m_lastdlg->setImage(tmpfile);
272 browser->hide();
273 m_lastdlg->show();
274 }
264 output.remove(); 275 output.remove();
276 } else {
277 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment"));
265 } 278 }
266 } 279 }
267 break; 280 break;
268 case 1: 281 case 1:
269 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 282 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
270 { 283 {
271 setText(); 284 setText();
272 } 285 }
273 else 286 else
274 { 287 {
275 if ( m_recMail->Wrapper() != 0l ) 288 if ( m_recMail->Wrapper() != 0l )
276 { // make sure that there is a wrapper , even after delete or simular actions 289 { // make sure that there is a wrapper , even after delete or simular actions
@@ -304,47 +317,70 @@ void ViewMail::setMail(const RecMailP&mail )
304 317
305 318
306ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 319ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
307 : ViewMailBase(parent, name, fl), _inLoop(false) 320 : ViewMailBase(parent, name, fl), _inLoop(false)
308{ 321{
309 m_gotBody = false; 322 m_gotBody = false;
310 deleted = false; 323 deleted = false;
311 324
312 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 325 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
313 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 326 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
314 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 327 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
315 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 328 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
329 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) );
316 330
317 attachments->setEnabled(m_gotBody); 331 attachments->setEnabled(m_gotBody);
318 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 332 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
333 m_lastdlg = 0;
334 _icounter = 0;
319 335
320 readConfig(); 336 readConfig();
321 attachments->setSorting(-1); 337 attachments->setSorting(-1);
322} 338}
323 339
340void ViewMail::slotImageInline(bool how)
341{
342 Config cfg( "mail" );
343 cfg.writeEntry( "showPicsInline", how);
344 m_PicsInline = how;
345 if (m_lastdlg&&!how) {
346 browser->show();
347 m_lastdlg->hide();
348 m_lastdlg->reparent(0,QPoint(0,0),false);
349 delete m_lastdlg;
350 m_lastdlg = 0;
351 }
352}
353
324void ViewMail::readConfig() 354void ViewMail::readConfig()
325{ 355{
326 Config cfg( "mail" ); 356 Config cfg( "mail" );
327 cfg.setGroup( "Settings" ); 357 cfg.setGroup( "Settings" );
328 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 358 m_showHtml = cfg.readBoolEntry( "showHtml", false );
359 m_PicsInline = cfg.readBoolEntry( "showPicsInline", true );
360 showPicsInline->setOn(m_PicsInline);
329 showHtml->setOn( m_showHtml ); 361 showHtml->setOn( m_showHtml );
330} 362}
331 363
332void ViewMail::setText() 364void ViewMail::setText()
333{ 365{
334 QString toString; 366 QString toString;
335 QString ccString; 367 QString ccString;
336 QString bccString; 368 QString bccString;
337 QString mailHtml; 369 QString mailHtml;
338 370
371 if (m_lastdlg) {
372 m_lastdlg->hide();
373 }
374 browser->show();
339 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 375 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
340 { 376 {
341 toString += (*it); 377 toString += (*it);
342 } 378 }
343 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 379 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
344 { 380 {
345 ccString += (*it); 381 ccString += (*it);
346 } 382 }
347 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 383 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
348 { 384 {
349 bccString += (*it); 385 bccString += (*it);
350 } 386 }
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index 297836b..f5033f0 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -2,24 +2,26 @@
2#define VIEWMAIL_H 2#define VIEWMAIL_H
3 3
4#include "viewmailbase.h" 4#include "viewmailbase.h"
5#include <libmailwrapper/mailtypes.h> 5#include <libmailwrapper/mailtypes.h>
6 6
7#include <opie2/odialog.h> 7#include <opie2/odialog.h>
8 8
9#include <qlistview.h> 9#include <qlistview.h>
10#include <qmap.h> 10#include <qmap.h>
11#include <qstringlist.h> 11#include <qstringlist.h>
12#include <qvaluelist.h> 12#include <qvaluelist.h>
13 13
14class MailImageDlg;
15
14namespace Opie { namespace MM { class OImageScrollView; } } 16namespace Opie { namespace MM { class OImageScrollView; } }
15 17
16class AttachItem : public QListViewItem 18class AttachItem : public QListViewItem
17{ 19{
18public: 20public:
19 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 21 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
20 const QString&fsize,int num,const QValueList<int>&path); 22 const QString&fsize,int num,const QValueList<int>&path);
21 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 23 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
22 const QString&fsize,int num,const QValueList<int>&path); 24 const QString&fsize,int num,const QValueList<int>&path);
23 int Partnumber() { return _partNum; } 25 int Partnumber() { return _partNum; }
24 bool isParentof(const QValueList<int>&path); 26 bool isParentof(const QValueList<int>&path);
25 27
@@ -39,41 +41,46 @@ public:
39 41
40 void hide(); 42 void hide();
41 void exec(); 43 void exec();
42 void setMail(const RecMailP&mail ); 44 void setMail(const RecMailP&mail );
43 void setBody(const RecBodyP&body); 45 void setBody(const RecBodyP&body);
44 bool deleted; 46 bool deleted;
45 47
46protected: 48protected:
47 QString deHtml(const QString &string); 49 QString deHtml(const QString &string);
48 AttachItem* searchParent(const QValueList<int>&path); 50 AttachItem* searchParent(const QValueList<int>&path);
49 AttachItem* lastChild(AttachItem*parent); 51 AttachItem* lastChild(AttachItem*parent);
50 52
53 Opie::MM::OImageScrollView*m_lastdlg;
54
51protected slots: 55protected slots:
52 void slotReply(); 56 void slotReply();
53 void slotForward(); 57 void slotForward();
54 void setText(); 58 void setText();
55 void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); 59 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
56 void slotDeleteMail( ); 60 void slotDeleteMail( );
57 void slotShowHtml( bool ); 61 void slotShowHtml( bool );
62 void slotImageInline(bool);
58 63
59private: 64private:
60 void readConfig(); 65 void readConfig();
61 66
62 bool _inLoop; 67 bool _inLoop;
63 QString m_mailHtml; 68 QString m_mailHtml;
64 bool m_gotBody; 69 bool m_gotBody;
65 RecBodyP m_body; 70 RecBodyP m_body;
66 RecMailP m_recMail; 71 RecMailP m_recMail;
67 bool m_showHtml; 72 bool m_showHtml:1;
73 bool m_PicsInline:1;
74 unsigned int _icounter;
68 75
69 // 0 from 1 subject 2 bodytext 3 date 76 // 0 from 1 subject 2 bodytext 3 date
70 QMap <int,QString> m_mail; 77 QMap <int,QString> m_mail;
71 // 0 to 1 cc 2 bcc 78 // 0 to 1 cc 2 bcc
72 QMap <int,QStringList> m_mail2; 79 QMap <int,QStringList> m_mail2;
73}; 80};
74 81
75class MailImageDlg:public Opie::Ui::ODialog 82class MailImageDlg:public Opie::Ui::ODialog
76{ 83{
77 Q_OBJECT 84 Q_OBJECT
78public: 85public:
79 MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0); 86 MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0);
diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp
index 49a0e6a..65ad0d6 100644
--- a/noncore/net/mail/viewmailbase.cpp
+++ b/noncore/net/mail/viewmailbase.cpp
@@ -1,85 +1,87 @@
1#include <qtextbrowser.h> 1#include <qtextbrowser.h>
2#include <qlistview.h> 2#include <qlistview.h>
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 <qlayout.h>
8#include <qmenubar.h> 9#include <qmenubar.h>
9#include <qpe/resource.h> 10#include <qpe/resource.h>
10 11
11#include "viewmailbase.h" 12#include "viewmailbase.h"
12//#include "opendiag.h" 13//#include "opendiag.h"
13 14
14ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) 15ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
15 : QMainWindow(parent, name, fl) 16 : QMainWindow(parent, name, fl)
16{ 17{
17 setCaption(tr("E-Mail view")); 18 setCaption(tr("E-Mail view"));
18 setToolBarsMovable(false); 19 setToolBarsMovable(false);
19 20
20 toolbar = new QToolBar(this); 21 toolbar = new QToolBar(this);
21 menubar = new QMenuBar( toolbar ); 22 menubar = new QMenuBar( toolbar );
22 mailmenu = new QPopupMenu( menubar ); 23 mailmenu = new QPopupMenu( menubar );
23 menubar->insertItem( tr( "Mail" ), mailmenu ); 24 menubar->insertItem( tr( "Mail" ), mailmenu );
24
25 toolbar->setHorizontalStretchable(true); 25 toolbar->setHorizontalStretchable(true);
26 addToolBar(toolbar); 26 addToolBar(toolbar);
27
28 QLabel *spacer = new QLabel(toolbar); 27 QLabel *spacer = new QLabel(toolbar);
29 spacer->setBackgroundMode(QWidget::PaletteButton); 28 spacer->setBackgroundMode(QWidget::PaletteButton);
30 toolbar->setStretchableWidget(spacer); 29 toolbar->setStretchableWidget(spacer);
31 30
32 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); 31 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this);
33 reply->addTo(toolbar); 32 reply->addTo(toolbar);
34 reply->addTo(mailmenu); 33 reply->addTo(mailmenu);
35 34
36 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); 35 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this);
37 forward->addTo(toolbar); 36 forward->addTo(toolbar);
38 forward->addTo(mailmenu); 37 forward->addTo(mailmenu);
39 38
40 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); 39 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
41 attachbutton->addTo(toolbar); 40 attachbutton->addTo(toolbar);
42 attachbutton->addTo(mailmenu); 41 attachbutton->addTo(mailmenu);
43 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); 42 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
44 43
45 44
46 showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true ); 45 showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true );
47 showHtml->addTo( toolbar ); 46 showHtml->addTo( toolbar );
48 showHtml->addTo( mailmenu ); 47 showHtml->addTo( mailmenu );
48
49 showPicsInline= new QAction(tr("Show image preview inline"), QIconSet(Resource::loadPixmap("pixmap")), 0, 0, this);
50 showPicsInline->setToggleAction(true);
51 showPicsInline->addTo(toolbar);
52 showPicsInline->addTo(mailmenu);
49 53
50 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this); 54 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this);
51 deleteMail->addTo(toolbar); 55 deleteMail->addTo(toolbar);
52 deleteMail->addTo(mailmenu); 56 deleteMail->addTo(mailmenu);
53 57
54 QVBox *view = new QVBox(this); 58 QVBox * view = new QVBox(this);
59 view->setSpacing(1);
60 view->setMargin(0);
55 setCentralWidget(view); 61 setCentralWidget(view);
56 62
57 attachments = new QListView(view); 63 attachments = new QListView(view);
58 attachments->setMinimumHeight(90); 64 attachments->setMinimumHeight(90);
59 attachments->setMaximumHeight(90); 65 attachments->setMaximumHeight(90);
60 attachments->setAllColumnsShowFocus(true); 66 attachments->setAllColumnsShowFocus(true);
61 attachments->addColumn("Mime Type", 60); 67 attachments->addColumn("Mime Type", 60);
62 attachments->addColumn(tr("Description"), 100); 68 attachments->addColumn(tr("Description"), 100);
63 attachments->addColumn(tr("Filename"), 80); 69 attachments->addColumn(tr("Filename"), 80);
64 attachments->addColumn(tr("Size"), 80); 70 attachments->addColumn(tr("Size"), 80);
65 attachments->setSorting(-1); 71 attachments->setSorting(-1);
66 attachments->hide();
67 72
68 //header = new QTextBrowser(view);
69 browser = new QTextBrowser(view); 73 browser = new QTextBrowser(view);
70 74 adjustSize();
71// openDiag = new OpenDiag(view); 75 attachments->hide();
72// openDiag->hide();
73
74} 76}
75 77
76void ViewMailBase::slotChangeAttachview(bool state) 78void ViewMailBase::slotChangeAttachview(bool state)
77{ 79{
78 if (state) attachments->show(); 80 if (state) attachments->show();
79 else attachments->hide(); 81 else attachments->hide();
80} 82}
81 83
82void ViewMailBase::keyPressEvent ( QKeyEvent * e ) 84void ViewMailBase::keyPressEvent ( QKeyEvent * e )
83{ 85{
84 if( e->key()==Qt::Key_Escape ) { 86 if( e->key()==Qt::Key_Escape ) {
85 close(); 87 close();
diff --git a/noncore/net/mail/viewmailbase.h b/noncore/net/mail/viewmailbase.h
index 583b1f6..59179a4 100644
--- a/noncore/net/mail/viewmailbase.h
+++ b/noncore/net/mail/viewmailbase.h
@@ -10,25 +10,25 @@ class 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,*showPicsInline;
23 QListView *attachments; 23 QListView *attachments;
24 QToolBar *toolbar; 24 QToolBar *toolbar;
25 QTextBrowser *browser;//,*header; 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