author | alwin <alwin> | 2004-01-03 13:04:52 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-03 13:04:52 (UTC) |
commit | 22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b (patch) (unidiff) | |
tree | 85847776be6743270b18f5e1df9fa6451288f7a6 /noncore/net/mail/viewmail.cpp | |
parent | 452aac36b77ed1f7e6db3a7952028bf6027e54b6 (diff) | |
download | opie-22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b.zip opie-22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b.tar.gz opie-22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b.tar.bz2 |
some more display beauty
Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 14 |
1 files changed, 14 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 | |||
@@ -41,48 +41,60 @@ AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QStrin | |||
41 | } | 41 | } |
42 | 42 | ||
43 | bool AttachItem::isParentof(const QValueList<int>&path) | 43 | bool AttachItem::isParentof(const QValueList<int>&path) |
44 | { | 44 | { |
45 | /* if not set, then no parent */ | 45 | /* if not set, then no parent */ |
46 | if (path.count()==0||_path.count()==0) return false; | 46 | if (path.count()==0||_path.count()==0) return false; |
47 | /* the parent must have one digit less then a child */ | 47 | /* the parent must have one digit less then a child */ |
48 | if (path.count()!=_path.count()+1) return false; | 48 | if (path.count()!=_path.count()+1) return false; |
49 | for (unsigned int i=0; i < _path.count();++i) { | 49 | for (unsigned int i=0; i < _path.count();++i) { |
50 | if (_path[i]!=path[i]) return false; | 50 | if (_path[i]!=path[i]) return false; |
51 | } | 51 | } |
52 | return true; | 52 | return true; |
53 | } | 53 | } |
54 | 54 | ||
55 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 55 | AttachItem* 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 | ||
65 | AttachItem* 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 | |||
65 | void ViewMail::setBody( RecBody body ) { | 77 | void ViewMail::setBody( RecBody body ) { |
66 | 78 | ||
67 | m_body = body; | 79 | m_body = body; |
68 | m_mail[2] = body.Bodytext(); | 80 | m_mail[2] = body.Bodytext(); |
69 | attachbutton->setEnabled(body.Parts().count()>0); | 81 | attachbutton->setEnabled(body.Parts().count()>0); |
70 | attachments->setEnabled(body.Parts().count()>0); | 82 | attachments->setEnabled(body.Parts().count()>0); |
71 | if (body.Parts().count()==0) { | 83 | if (body.Parts().count()==0) { |
72 | return; | 84 | return; |
73 | } | 85 | } |
74 | AttachItem * curItem=0; | 86 | AttachItem * curItem=0; |
75 | AttachItem * parentItem = 0; | 87 | AttachItem * parentItem = 0; |
76 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 88 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
77 | QString desc,fsize; | 89 | QString desc,fsize; |
78 | double s = body.Description().Size(); | 90 | double s = body.Description().Size(); |
79 | int w; | 91 | int w; |
80 | w=0; | 92 | w=0; |
81 | 93 | ||
82 | while (s>1024) { | 94 | while (s>1024) { |
83 | s/=1024; | 95 | s/=1024; |
84 | ++w; | 96 | ++w; |
85 | if (w>=2) break; | 97 | if (w>=2) break; |
86 | } | 98 | } |
87 | 99 | ||
88 | QString q=""; | 100 | QString q=""; |
@@ -125,48 +137,50 @@ for (unsigned int i = 0; i < body.Parts().count();++i) { | |||
125 | w = 0; | 137 | w = 0; |
126 | while (s>1024) { | 138 | while (s>1024) { |
127 | s/=1024; | 139 | s/=1024; |
128 | ++w; | 140 | ++w; |
129 | if (w>=2) break; | 141 | if (w>=2) break; |
130 | } | 142 | } |
131 | switch(w) { | 143 | switch(w) { |
132 | case 1: | 144 | case 1: |
133 | q="k"; | 145 | q="k"; |
134 | break; | 146 | break; |
135 | case 2: | 147 | case 2: |
136 | q="M"; | 148 | q="M"; |
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 | ||
159 | void ViewMail::slotShowHtml( bool state ) { | 173 | void ViewMail::slotShowHtml( bool state ) { |
160 | m_showHtml = state; | 174 | m_showHtml = state; |
161 | setText(); | 175 | setText(); |
162 | } | 176 | } |
163 | 177 | ||
164 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { | 178 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { |
165 | if (!item ) | 179 | if (!item ) |
166 | return; | 180 | return; |
167 | 181 | ||
168 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 182 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
169 | setText(); | 183 | setText(); |
170 | return; | 184 | return; |
171 | } | 185 | } |
172 | QPopupMenu *menu = new QPopupMenu(); | 186 | QPopupMenu *menu = new QPopupMenu(); |