summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show 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 @@
#include <qapplication.h>
+#include <qvaluelist.h>
@@ -20,5 +21,6 @@
AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
- const QString&fsize,int num)
+ const QString&fsize,int num,const QValueList<int>&path)
: QListViewItem(parent,after),_partNum(num)
{
+ _path=path;
setText(0, mime);
@@ -29,2 +31,35 @@ AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mi
+AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
+ const QString&fsize,int num,const QValueList<int>&path)
+ : QListViewItem(parent,after),_partNum(num)
+{
+ _path=path;
+ setText(0, mime);
+ setText(1, desc);
+ setText(2, file);
+ setText(3, fsize);
+}
+
+bool AttachItem::isParentof(const QValueList<int>&path)
+{
+ /* if not set, then no parent */
+ if (path.count()==0||_path.count()==0) return false;
+ /* the parent must have one digit less then a child */
+ if (path.count()!=_path.count()+1) return false;
+ for (unsigned int i=0; i < _path.count();++i) {
+ if (_path[i]!=path[i]) return false;
+ }
+ return true;
+}
+
+AttachItem* ViewMail::searchParent(const QValueList<int>&path)
+{
+ QListViewItemIterator it( attachments );
+ for ( ; it.current(); ++it ) {
+ AttachItem*ati = (AttachItem*)it.current();
+ if (ati->isParentof(path)) return ati;
+ }
+ return 0;
+}
+
void ViewMail::setBody( RecBody body ) {
@@ -39,2 +74,3 @@ if (body.Parts().count()==0) {
AttachItem * curItem=0;
+AttachItem * parentItem = 0;
QString type=body.Description().Type()+"/"+body.Description().Subtype();
@@ -75,4 +111,5 @@ default:
-curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1);
+curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
QString filename = "";
+
for (unsigned int i = 0; i < body.Parts().count();++i) {
@@ -109,3 +146,9 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
desc = body.Parts()[i].Description();
- curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i);
+ parentItem = searchParent(body.Parts()[i].Positionlist());
+ if (parentItem) {
+ curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
+ attachments->setRootIsDecorated(true);
+ } else {
+ curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
+ }
}
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 @@
#include <qstringlist.h>
+#include <qvaluelist.h>
@@ -14,4 +15,7 @@ public:
AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
- const QString&fsize,int num);
+ const QString&fsize,int num,const QValueList<int>&path);
+ AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
+ const QString&fsize,int num,const QValueList<int>&path);
int Partnumber() { return _partNum; }
+ bool isParentof(const QValueList<int>&path);
@@ -19,2 +23,4 @@ private:
int _partNum;
+ /* needed for a better display of attachments */
+ QValueList<int> _path;
};
@@ -37,2 +43,3 @@ protected:
QString deHtml(const QString &string);
+ AttachItem* searchParent(const QValueList<int>&path);