Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 68d3c51..48b71eb 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -10,18 +10,20 @@ | |||
10 | #include "settings.h" | 10 | #include "settings.h" |
11 | #include "composemail.h" | 11 | #include "composemail.h" |
12 | #include "viewmail.h" | 12 | #include "viewmail.h" |
13 | #include "abstractmail.h" | 13 | #include "abstractmail.h" |
14 | #include "accountview.h" | 14 | #include "accountview.h" |
15 | 15 | ||
16 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) | 16 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
17 | const QString&fsize,int num) | ||
17 | : QListViewItem(parent,after),_partNum(num) | 18 | : QListViewItem(parent,after),_partNum(num) |
18 | { | 19 | { |
19 | setText(0, mime); | 20 | setText(0, mime); |
20 | setText(1, file); | 21 | setText(1, desc); |
21 | setText(2, desc); | 22 | setText(2, file); |
23 | setText(3, fsize); | ||
22 | } | 24 | } |
23 | 25 | ||
24 | void ViewMail::setBody( RecBody body ) { | 26 | void ViewMail::setBody( RecBody body ) { |
25 | 27 | ||
26 | m_body = body; | 28 | m_body = body; |
27 | m_mail[2] = body.Bodytext(); | 29 | m_mail[2] = body.Bodytext(); |
@@ -29,13 +31,13 @@ attachbutton->setEnabled(body.Parts().count()>0); | |||
29 | attachments->setEnabled(body.Parts().count()>0); | 31 | attachments->setEnabled(body.Parts().count()>0); |
30 | if (body.Parts().count()==0) { | 32 | if (body.Parts().count()==0) { |
31 | return; | 33 | return; |
32 | } | 34 | } |
33 | AttachItem * curItem=0; | 35 | AttachItem * curItem=0; |
34 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 36 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
35 | QString desc; | 37 | QString desc,fsize; |
36 | double s = body.Description().Size(); | 38 | double s = body.Description().Size(); |
37 | int w; | 39 | int w; |
38 | w=0; | 40 | w=0; |
39 | 41 | ||
40 | while (s>1024) { | 42 | while (s>1024) { |
41 | s/=1024; | 43 | s/=1024; |
@@ -58,24 +60,25 @@ default: | |||
58 | { | 60 | { |
59 | /* I did not found a method to make a CONTENT reset on a QTextStream | 61 | /* I did not found a method to make a CONTENT reset on a QTextStream |
60 | so I use this construct that the stream will re-constructed in each | 62 | so I use this construct that the stream will re-constructed in each |
61 | loop. To let it work, the textstream is packed into a own area of | 63 | loop. To let it work, the textstream is packed into a own area of |
62 | code is it will be destructed after finishing its small job. | 64 | code is it will be destructed after finishing its small job. |
63 | */ | 65 | */ |
64 | QTextOStream o(&desc); | 66 | QTextOStream o(&fsize); |
65 | if (w>0) o.precision(2); else o.precision(0); | 67 | if (w>0) o.precision(2); else o.precision(0); |
66 | o.setf(QTextStream::fixed); | 68 | o.setf(QTextStream::fixed); |
67 | o << s << " " << q << "Byte"; | 69 | o << s << " " << q << "Byte"; |
68 | } | 70 | } |
69 | 71 | ||
70 | curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); | 72 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1); |
71 | QString filename = ""; | 73 | QString filename = ""; |
72 | for (unsigned int i = 0; i < body.Parts().count();++i) { | 74 | for (unsigned int i = 0; i < body.Parts().count();++i) { |
73 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 75 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
74 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 76 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
75 | for (;it!=body.Parts()[i].Parameters().end();++it) { | 77 | for (;it!=body.Parts()[i].Parameters().end();++it) { |
78 | qDebug(it.key()); | ||
76 | if (it.key().lower()=="name") { | 79 | if (it.key().lower()=="name") { |
77 | filename=it.data(); | 80 | filename=it.data(); |
78 | } | 81 | } |
79 | } | 82 | } |
80 | s = body.Parts()[i].Size(); | 83 | s = body.Parts()[i].Size(); |
81 | w = 0; | 84 | w = 0; |
@@ -92,41 +95,46 @@ for (unsigned int i = 0; i < body.Parts().count();++i) { | |||
92 | q="M"; | 95 | q="M"; |
93 | break; | 96 | break; |
94 | default: | 97 | default: |
95 | q=""; | 98 | q=""; |
96 | break; | 99 | break; |
97 | } | 100 | } |
98 | QTextOStream o(&desc); | 101 | QTextOStream o(&fsize); |
99 | if (w>0) o.precision(2); else o.precision(0); | 102 | if (w>0) o.precision(2); else o.precision(0); |
100 | o.setf(QTextStream::fixed); | 103 | o.setf(QTextStream::fixed); |
101 | o << s << " " << q << "Byte"; | 104 | o << s << " " << q << "Byte"; |
102 | curItem=new AttachItem(attachments,curItem,type,filename,desc,i); | 105 | desc = body.Parts()[i].Description(); |
106 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i); | ||
103 | } | 107 | } |
104 | } | 108 | } |
105 | 109 | ||
106 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { | 110 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { |
107 | if (!item ) | 111 | if (!item ) |
108 | return; | 112 | return; |
109 | 113 | ||
110 | QPopupMenu *menu = new QPopupMenu(); | 114 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
115 | setText(); | ||
116 | return; | ||
117 | } | ||
118 | QPopupMenu *menu = new QPopupMenu(); | ||
111 | int ret=0; | 119 | int ret=0; |
112 | 120 | ||
113 | if ( item->text( 0 ).left( 4 ) == "text" ) { | 121 | if ( item->text( 0 ).left( 5 ) == "text/" ) { |
114 | menu->insertItem( tr( "Show Text" ), 1 ); | 122 | menu->insertItem( tr( "Show Text" ), 1 ); |
115 | } | 123 | } |
116 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 124 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
117 | menu->insertSeparator(1); | 125 | menu->insertSeparator(1); |
118 | 126 | ||
119 | ret = menu->exec( point, 0 ); | 127 | ret = menu->exec( point, 0 ); |
120 | 128 | ||
121 | switch(ret) { | 129 | switch(ret) { |
122 | case 0: | 130 | case 0: |
123 | { MimeTypes types; | 131 | { MimeTypes types; |
124 | types.insert( "all", "*" ); | 132 | types.insert( "all", "*" ); |
125 | QString str = OFileDialog::getSaveFileName( 1, | 133 | QString str = OFileDialog::getSaveFileName( 1, |
126 | "/", item->text( 1 ) , types, 0 ); | 134 | "/", item->text( 2 ) , types, 0 ); |
127 | 135 | ||
128 | if( !str.isEmpty() ) { | 136 | if( !str.isEmpty() ) { |
129 | qDebug( "first we will need a MIME wrapper" ); | 137 | qDebug( "first we will need a MIME wrapper" ); |
130 | } | 138 | } |
131 | } | 139 | } |
132 | break ; | 140 | break ; |