summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp49
-rw-r--r--noncore/net/mail/viewmail.h9
2 files changed, 54 insertions, 4 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index d2e5e29..5e7ffeb 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -7,2 +7,3 @@
7#include <qapplication.h> 7#include <qapplication.h>
8#include <qvaluelist.h>
8 9
@@ -20,5 +21,6 @@
20AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 21AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
21 const QString&fsize,int num) 22 const QString&fsize,int num,const QValueList<int>&path)
22 : QListViewItem(parent,after),_partNum(num) 23 : QListViewItem(parent,after),_partNum(num)
23{ 24{
25 _path=path;
24 setText(0, mime); 26 setText(0, mime);
@@ -29,2 +31,35 @@ AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mi
29 31
32AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
33 const QString&fsize,int num,const QValueList<int>&path)
34 : QListViewItem(parent,after),_partNum(num)
35{
36 _path=path;
37 setText(0, mime);
38 setText(1, desc);
39 setText(2, file);
40 setText(3, fsize);
41}
42
43bool AttachItem::isParentof(const QValueList<int>&path)
44{
45 /* if not set, then no parent */
46 if (path.count()==0||_path.count()==0) return false;
47 /* the parent must have one digit less then a child */
48 if (path.count()!=_path.count()+1) return false;
49 for (unsigned int i=0; i < _path.count();++i) {
50 if (_path[i]!=path[i]) return false;
51 }
52 return true;
53}
54
55AttachItem* ViewMail::searchParent(const QValueList<int>&path)
56{
57 QListViewItemIterator it( attachments );
58 for ( ; it.current(); ++it ) {
59 AttachItem*ati = (AttachItem*)it.current();
60 if (ati->isParentof(path)) return ati;
61 }
62 return 0;
63}
64
30void ViewMail::setBody( RecBody body ) { 65void ViewMail::setBody( RecBody body ) {
@@ -39,2 +74,3 @@ if (body.Parts().count()==0) {
39AttachItem * curItem=0; 74AttachItem * curItem=0;
75AttachItem * parentItem = 0;
40QString type=body.Description().Type()+"/"+body.Description().Subtype(); 76QString type=body.Description().Type()+"/"+body.Description().Subtype();
@@ -75,4 +111,5 @@ default:
75 111
76curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1); 112curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
77QString filename = ""; 113QString filename = "";
114
78for (unsigned int i = 0; i < body.Parts().count();++i) { 115for (unsigned int i = 0; i < body.Parts().count();++i) {
@@ -109,3 +146,9 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
109 desc = body.Parts()[i].Description(); 146 desc = body.Parts()[i].Description();
110 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i); 147 parentItem = searchParent(body.Parts()[i].Positionlist());
148 if (parentItem) {
149 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
150 attachments->setRootIsDecorated(true);
151 } else {
152 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
153 }
111} 154}
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index bf7a4dd..b3d3b4e 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -6,2 +6,3 @@
6#include <qstringlist.h> 6#include <qstringlist.h>
7#include <qvaluelist.h>
7 8
@@ -14,4 +15,7 @@ public:
14 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 15 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
15 const QString&fsize,int num); 16 const QString&fsize,int num,const QValueList<int>&path);
17 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
18 const QString&fsize,int num,const QValueList<int>&path);
16 int Partnumber() { return _partNum; } 19 int Partnumber() { return _partNum; }
20 bool isParentof(const QValueList<int>&path);
17 21
@@ -19,2 +23,4 @@ private:
19 int _partNum; 23 int _partNum;
24 /* needed for a better display of attachments */
25 QValueList<int> _path;
20}; 26};
@@ -37,2 +43,3 @@ protected:
37 QString deHtml(const QString &string); 43 QString deHtml(const QString &string);
44 AttachItem* searchParent(const QValueList<int>&path);
38 45