summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp14
-rw-r--r--noncore/net/mail/viewmail.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index d4c5150..ed77eb5 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -53,24 +53,36 @@ bool AttachItem::isParentof(const QValueList<int>&path)
53} 53}
54 54
55AttachItem* ViewMail::searchParent(const QValueList<int>&path) 55AttachItem* ViewMail::searchParent(const QValueList<int>&path)
56{ 56{
57 QListViewItemIterator it( attachments ); 57 QListViewItemIterator it( attachments );
58 for ( ; it.current(); ++it ) { 58 for ( ; it.current(); ++it ) {
59 AttachItem*ati = (AttachItem*)it.current(); 59 AttachItem*ati = (AttachItem*)it.current();
60 if (ati->isParentof(path)) return ati; 60 if (ati->isParentof(path)) return ati;
61 } 61 }
62 return 0; 62 return 0;
63} 63}
64 64
65AttachItem* ViewMail::lastChild(AttachItem*parent)
66{
67 if (!parent) return 0;
68 AttachItem* item = (AttachItem*)parent->firstChild();
69 if (!item) return item;
70 AttachItem*temp=0;
71 while( (temp=(AttachItem*)item->nextSibling())) {
72 item = temp;
73 }
74 return item;
75}
76
65void ViewMail::setBody( RecBody body ) { 77void ViewMail::setBody( RecBody body ) {
66 78
67m_body = body; 79m_body = body;
68m_mail[2] = body.Bodytext(); 80m_mail[2] = body.Bodytext();
69attachbutton->setEnabled(body.Parts().count()>0); 81attachbutton->setEnabled(body.Parts().count()>0);
70attachments->setEnabled(body.Parts().count()>0); 82attachments->setEnabled(body.Parts().count()>0);
71if (body.Parts().count()==0) { 83if (body.Parts().count()==0) {
72 return; 84 return;
73} 85}
74AttachItem * curItem=0; 86AttachItem * curItem=0;
75AttachItem * parentItem = 0; 87AttachItem * parentItem = 0;
76QString type=body.Description().Type()+"/"+body.Description().Subtype(); 88QString type=body.Description().Type()+"/"+body.Description().Subtype();
@@ -137,24 +149,26 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
137 break; 149 break;
138 default: 150 default:
139 q=""; 151 q="";
140 break; 152 break;
141 } 153 }
142 QTextOStream o(&fsize); 154 QTextOStream o(&fsize);
143 if (w>0) o.precision(2); else o.precision(0); 155 if (w>0) o.precision(2); else o.precision(0);
144 o.setf(QTextStream::fixed); 156 o.setf(QTextStream::fixed);
145 o << s << " " << q << "Byte"; 157 o << s << " " << q << "Byte";
146 desc = body.Parts()[i].Description(); 158 desc = body.Parts()[i].Description();
147 parentItem = searchParent(body.Parts()[i].Positionlist()); 159 parentItem = searchParent(body.Parts()[i].Positionlist());
148 if (parentItem) { 160 if (parentItem) {
161 AttachItem*temp = lastChild(parentItem);
162 if (temp) curItem = temp;
149 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 163 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
150 attachments->setRootIsDecorated(true); 164 attachments->setRootIsDecorated(true);
151 curItem = parentItem; 165 curItem = parentItem;
152 } else { 166 } else {
153 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 167 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
154 } 168 }
155} 169}
156} 170}
157 171
158 172
159void ViewMail::slotShowHtml( bool state ) { 173void ViewMail::slotShowHtml( bool state ) {
160 m_showHtml = state; 174 m_showHtml = state;
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index b3d3b4e..29681cc 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -33,24 +33,25 @@ public:
33 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);
34 ~ViewMail(); 34 ~ViewMail();
35 35
36 void hide(); 36 void hide();
37 void exec(); 37 void exec();
38 void setMail( RecMail mail ); 38 void setMail( RecMail mail );
39 void setBody( RecBody body ); 39 void setBody( RecBody body );
40 bool deleted; 40 bool deleted;
41 41
42protected: 42protected:
43 QString deHtml(const QString &string); 43 QString deHtml(const QString &string);
44 AttachItem* searchParent(const QValueList<int>&path); 44 AttachItem* searchParent(const QValueList<int>&path);
45 AttachItem* lastChild(AttachItem*parent);
45 46
46protected slots: 47protected slots:
47 void slotReply(); 48 void slotReply();
48 void slotForward(); 49 void slotForward();
49 void setText(); 50 void setText();
50 void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); 51 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
51 void slotDeleteMail( ); 52 void slotDeleteMail( );
52 void slotShowHtml( bool ); 53 void slotShowHtml( bool );
53 54
54private: 55private:
55 void readConfig(); 56 void readConfig();
56 57