summaryrefslogtreecommitdiffabout
path: root/kmicromail
authorzautrix <zautrix>2005-02-24 11:19:48 (UTC)
committer zautrix <zautrix>2005-02-24 11:19:48 (UTC)
commitff8a2f593fae5ffe82f889ab70d32bf02a45f4fb (patch) (unidiff)
treeb3b4c6ee66b7ae39fad43622a2badacdbe9ed4e1 /kmicromail
parent66ea8a0023a2a58e7887a41c265f2a7112b6b625 (diff)
downloadkdepimpi-ff8a2f593fae5ffe82f889ab70d32bf02a45f4fb.zip
kdepimpi-ff8a2f593fae5ffe82f889ab70d32bf02a45f4fb.tar.gz
kdepimpi-ff8a2f593fae5ffe82f889ab70d32bf02a45f4fb.tar.bz2
ompi html fixes
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/viewmail.cpp23
-rw-r--r--kmicromail/viewmail.h2
2 files changed, 22 insertions, 3 deletions
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 726f540..685b4e4 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -70,64 +70,76 @@ bool AttachItem::isParentof(const QValueList<int>&path)
70 return true; 70 return true;
71} 71}
72 72
73AttachItem* ViewMail::searchParent(const QValueList<int>&path) 73AttachItem* ViewMail::searchParent(const QValueList<int>&path)
74{ 74{
75 QListViewItemIterator it( attachments ); 75 QListViewItemIterator it( attachments );
76 for ( ; it.current(); ++it ) 76 for ( ; it.current(); ++it )
77 { 77 {
78 AttachItem*ati = (AttachItem*)it.current(); 78 AttachItem*ati = (AttachItem*)it.current();
79 if (ati->isParentof(path)) return ati; 79 if (ati->isParentof(path)) return ati;
80 } 80 }
81 return 0; 81 return 0;
82} 82}
83 83
84AttachItem* ViewMail::lastChild(AttachItem*parent) 84AttachItem* ViewMail::lastChild(AttachItem*parent)
85{ 85{
86 if (!parent) return 0; 86 if (!parent) return 0;
87 AttachItem* item = (AttachItem*)parent->firstChild(); 87 AttachItem* item = (AttachItem*)parent->firstChild();
88 if (!item) return item; 88 if (!item) return item;
89 AttachItem*temp=0; 89 AttachItem*temp=0;
90 while( (temp=(AttachItem*)item->nextSibling())) 90 while( (temp=(AttachItem*)item->nextSibling()))
91 { 91 {
92 item = temp; 92 item = temp;
93 } 93 }
94 return item; 94 return item;
95} 95}
96 96
97void ViewMail::setBody(const RecBodyP&body ) 97void ViewMail::setBody(const RecBodyP&body )
98{ 98{
99 99
100 m_body = body; 100 m_body = body;
101 m_mail[2] = body->Bodytext(); 101 m_mail[2] = body->Bodytext();
102 m_showHtml = KOPrefs::instance()->mViewAsHtml;
103 if ( m_showHtml ) {
104 if ( m_mail[2].find ("<html>",0,false ) > -1 ) {
105 qDebug("html mail ");
106 } else {
107 qDebug("no html mail ");
108 m_showHtml = false;
109 }
110 }
111 showHtml->blockSignals( true );
112 showHtml->setOn( m_showHtml );
113 showHtml->blockSignals( false );
102 // qDebug("********text %s ",m_mail[2].latin1() ); 114 // qDebug("********text %s ",m_mail[2].latin1() );
103 attachbutton->setEnabled(body->Parts().count()>0); 115 attachbutton->setEnabled(body->Parts().count()>0);
104 attachments->setEnabled(body->Parts().count()>0); 116 attachments->setEnabled(body->Parts().count()>0);
105 if (body->Parts().count()==0) 117 if (body->Parts().count()==0)
106 { 118 {
107 return; 119 return;
108 } 120 }
109 AttachItem * curItem=0; 121 AttachItem * curItem=0;
110 AttachItem * parentItem = 0; 122 AttachItem * parentItem = 0;
111 QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); 123 QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
112 QString desc,fsize; 124 QString desc,fsize;
113 double s = body->Description()->Size(); 125 double s = body->Description()->Size();
114 int w; 126 int w;
115 w=0; 127 w=0;
116 128
117 while (s>1024) 129 while (s>1024)
118 { 130 {
119 s/=1024; 131 s/=1024;
120 ++w; 132 ++w;
121 if (w>=2) break; 133 if (w>=2) break;
122 } 134 }
123 135
124 QString q=""; 136 QString q="";
125 switch(w) 137 switch(w)
126 { 138 {
127 case 1: 139 case 1:
128 q="k"; 140 q="k";
129 break; 141 break;
130 case 2: 142 case 2:
131 q="M"; 143 q="M";
132 break; 144 break;
133 default: 145 default:
@@ -302,85 +314,92 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
302 setText(); 314 setText();
303 } 315 }
304 else 316 else
305 { 317 {
306 if ( m_recMail->Wrapper() != 0l ) 318 if ( m_recMail->Wrapper() != 0l )
307 { // make sure that there is a wrapper , even after delete or simular actions 319 { // make sure that there is a wrapper , even after delete or simular actions
308 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 320 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
309 } 321 }
310 } 322 }
311 break; 323 break;
312 } 324 }
313 delete menu; 325 delete menu;
314} 326}
315 327
316 328
317void ViewMail::setMail(const RecMailP&mail ) 329void ViewMail::setMail(const RecMailP&mail )
318{ 330{
319 331
320 m_recMail = mail; 332 m_recMail = mail;
321 333
322 m_mail[0] = mail->getFrom(); 334 m_mail[0] = mail->getFrom();
323 m_mail[1] = mail->getSubject(); 335 m_mail[1] = mail->getSubject();
324 m_mail[3] = mail->getDate(); 336 m_mail[3] = mail->getDate();
325 m_mail[4] = mail->Msgid(); 337 m_mail[4] = mail->Msgid();
326 338
327 m_mail2[0] = mail->To(); 339 m_mail2[0] = mail->To();
328 m_mail2[1] = mail->CC(); 340 m_mail2[1] = mail->CC();
329 m_mail2[2] = mail->Bcc(); 341 m_mail2[2] = mail->Bcc();
330 342
331 setText(); 343 setText();
332} 344}
333 345
334 346void ViewMail::slotNextMail()
347{
348 nextMail->blockSignals( true );
349 setCaption(i18n("Displaying next mail...please wait!"));
350 qApp->processEvents();
351 emit showNextMail(this);
352 nextMail->blockSignals( false );
353}
335 354
336ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 355ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
337 : ViewMailBase(parent, name, fl), _inLoop(false) 356 : ViewMailBase(parent, name, fl), _inLoop(false)
338{ 357{
339 m_gotBody = false; 358 m_gotBody = false;
340 deleted = false; 359 deleted = false;
341 sourceOn = false; 360 sourceOn = false;
361 readConfig();
342 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 362 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
343 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 363 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
344 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 364 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
345 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 365 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
346 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 366 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
347 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) ); 367 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) );
348 connect( viewSource, SIGNAL( activated() ), SLOT( slotViewSource() ) ); 368 connect( viewSource, SIGNAL( activated() ), SLOT( slotViewSource() ) );
349 connect( downloadMail, SIGNAL( activated() ), SIGNAL( signalDownloadMail() ) ); 369 connect( downloadMail, SIGNAL( activated() ), SIGNAL( signalDownloadMail() ) );
350 370
351 attachments->setEnabled(m_gotBody); 371 attachments->setEnabled(m_gotBody);
352 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 372 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
353 373
354 readConfig();
355 attachments->setSorting(-1); 374 attachments->setSorting(-1);
356} 375}
357 376
358void ViewMail::readConfig() 377void ViewMail::readConfig()
359{ 378{
360 379
361 setFont ( KOPrefs::instance()->mReadFont ); 380 setFont ( KOPrefs::instance()->mReadFont );
362 m_showHtml = KOPrefs::instance()->mViewAsHtml; 381 m_showHtml = KOPrefs::instance()->mViewAsHtml;
363 showHtml->setOn( m_showHtml ); 382 showHtml->setOn( m_showHtml );
364} 383}
365 384
366void ViewMail::setText() 385void ViewMail::setText()
367{ 386{
368 387
369 viewSource->setText(i18n("View Source")); 388 viewSource->setText(i18n("View Source"));
370 sourceOn = false; 389 sourceOn = false;
371 QString toString; 390 QString toString;
372 QString ccString; 391 QString ccString;
373 QString bccString; 392 QString bccString;
374 393
375 394
376 toString = m_mail2[0].join(","); 395 toString = m_mail2[0].join(",");
377 ccString = m_mail2[1].join(","); 396 ccString = m_mail2[1].join(",");
378 bccString = m_mail2[2].join(","); 397 bccString = m_mail2[2].join(",");
379 398
380#ifdef DESKTOP_VERSION 399#ifdef DESKTOP_VERSION
381 setCaption( i18n("Size: ")+m_recMail->MsgsizeString()+" - "+i18n("E-Mail by %1").arg( m_mail[0] ) ); 400 setCaption( i18n("Size: ")+m_recMail->MsgsizeString()+" - "+i18n("E-Mail by %1").arg( m_mail[0] ) );
382#else 401#else
383 setCaption( m_recMail->MsgsizeString()+" - "+m_mail[0] ); 402 setCaption( m_recMail->MsgsizeString()+" - "+m_mail[0] );
384#endif 403#endif
385 404
386 m_mailHtml = "<html><body>" 405 m_mailHtml = "<html><body>"
diff --git a/kmicromail/viewmail.h b/kmicromail/viewmail.h
index fc5edcf..bb5b685 100644
--- a/kmicromail/viewmail.h
+++ b/kmicromail/viewmail.h
@@ -25,65 +25,65 @@ public:
25 int Partnumber() { return _partNum; } 25 int Partnumber() { return _partNum; }
26 bool isParentof(const QValueList<int>&path); 26 bool isParentof(const QValueList<int>&path);
27 27
28private: 28private:
29 int _partNum; 29 int _partNum;
30 /* needed for a better display of attachments */ 30 /* needed for a better display of attachments */
31 QValueList<int> _path; 31 QValueList<int> _path;
32}; 32};
33 33
34class ViewMail : public ViewMailBase 34class ViewMail : public ViewMailBase
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38public: 38public:
39 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); 39 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
40 ~ViewMail(); 40 ~ViewMail();
41 41
42 void hide(); 42 void hide();
43 void exec(); 43 void exec();
44 void setMail(const RecMailP&mail ); 44 void setMail(const RecMailP&mail );
45 void setBody(const RecBodyP&body); 45 void setBody(const RecBodyP&body);
46 bool deleted; 46 bool deleted;
47 signals: 47 signals:
48 void showNextMail(ViewMail*); 48 void showNextMail(ViewMail*);
49 void deleteAndDisplayNextMail(ViewMail *); 49 void deleteAndDisplayNextMail(ViewMail *);
50 void signalDownloadMail(); 50 void signalDownloadMail();
51protected: 51protected:
52 QString deHtml(const QString &string); 52 QString deHtml(const QString &string);
53 AttachItem* searchParent(const QValueList<int>&path); 53 AttachItem* searchParent(const QValueList<int>&path);
54 AttachItem* lastChild(AttachItem*parent); 54 AttachItem* lastChild(AttachItem*parent);
55 55
56protected slots: 56protected slots:
57 void slotNextMail() { setCaption(i18n("Displaying next mail...please wait!")); qApp->processEvents();emit showNextMail(this); }; 57 void slotNextMail();
58 void slotReply(); 58 void slotReply();
59 void slotForward(); 59 void slotForward();
60 void setText(); 60 void setText();
61 void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); 61 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
62 void slotDeleteMail( ); 62 void slotDeleteMail( );
63 void slotShowHtml( bool ); 63 void slotShowHtml( bool );
64 void slotViewSource(); 64 void slotViewSource();
65 65
66private: 66private:
67 void readConfig(); 67 void readConfig();
68 bool sourceOn;; 68 bool sourceOn;;
69 bool _inLoop; 69 bool _inLoop;
70 QString m_mailHtml; 70 QString m_mailHtml;
71 bool m_gotBody; 71 bool m_gotBody;
72 RecBodyP m_body; 72 RecBodyP m_body;
73 RecMailP m_recMail; 73 RecMailP m_recMail;
74 bool m_showHtml; 74 bool m_showHtml;
75 75
76 // 0 from 1 subject 2 bodytext 3 date 76 // 0 from 1 subject 2 bodytext 3 date
77 QMap <int,QString> m_mail; 77 QMap <int,QString> m_mail;
78 // 0 to 1 cc 2 bcc 78 // 0 to 1 cc 2 bcc
79 QMap <int,QStringList> m_mail2; 79 QMap <int,QStringList> m_mail2;
80}; 80};
81 81
82class MailImageDlg:public QDialog 82class MailImageDlg:public QDialog
83{ 83{
84 Q_OBJECT 84 Q_OBJECT
85public: 85public:
86 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);
87 ~MailImageDlg(); 87 ~MailImageDlg();
88 void setName(const QString&); 88 void setName(const QString&);
89protected: 89protected: