author | alwin <alwin> | 2003-12-13 03:51:21 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-13 03:51:21 (UTC) |
commit | 7f0861e63db74263ff286e09fbc4faf16d367a5b (patch) (unidiff) | |
tree | d97bd868343b179039c141fee3725f7781a0fca1 | |
parent | a170120c655169de904ff282e23461ba4eef2b47 (diff) | |
download | opie-7f0861e63db74263ff286e09fbc4faf16d367a5b.zip opie-7f0861e63db74263ff286e09fbc4faf16d367a5b.tar.gz opie-7f0861e63db74263ff286e09fbc4faf16d367a5b.tar.bz2 |
displaying list of attachments of a mail works. (Of course only if
the mail HAS attachments ;)
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 94 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 26 | ||||
-rw-r--r-- | noncore/net/mail/viewmailbase.cpp | 7 |
9 files changed, 120 insertions, 43 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 3941cec..11bf3b8 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -685,8 +685,9 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
685 | free(t); | 685 | free(t); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | target_part.setEncoding(encoding); | 688 | target_part.setEncoding(encoding); |
689 | target_part.setSize(which->bd_size); | ||
689 | } | 690 | } |
690 | 691 | ||
691 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | 692 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) |
692 | { | 693 | { |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 3941cec..11bf3b8 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -685,8 +685,9 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
685 | free(t); | 685 | free(t); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | target_part.setEncoding(encoding); | 688 | target_part.setEncoding(encoding); |
689 | target_part.setSize(which->bd_size); | ||
689 | } | 690 | } |
690 | 691 | ||
691 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | 692 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) |
692 | { | 693 | { |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 9c312e9..5cd45ed 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -67,9 +67,9 @@ const QStringList& RecMail::Bcc()const | |||
67 | return bcc; | 67 | return bcc; |
68 | } | 68 | } |
69 | 69 | ||
70 | RecPart::RecPart() | 70 | RecPart::RecPart() |
71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) | 71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0),m_size(0) |
72 | { | 72 | { |
73 | m_Parameters.clear(); | 73 | m_Parameters.clear(); |
74 | m_poslist.clear(); | 74 | m_poslist.clear(); |
75 | } | 75 | } |
@@ -77,8 +77,18 @@ RecPart::RecPart() | |||
77 | RecPart::~RecPart() | 77 | RecPart::~RecPart() |
78 | { | 78 | { |
79 | } | 79 | } |
80 | 80 | ||
81 | void RecPart::setSize(unsigned int size) | ||
82 | { | ||
83 | m_size = size; | ||
84 | } | ||
85 | |||
86 | const unsigned int RecPart::Size()const | ||
87 | { | ||
88 | return m_size; | ||
89 | } | ||
90 | |||
81 | void RecPart::setLines(unsigned int lines) | 91 | void RecPart::setLines(unsigned int lines) |
82 | { | 92 | { |
83 | m_lines = lines; | 93 | m_lines = lines; |
84 | } | 94 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index f308bc7..24518cf 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -75,9 +75,9 @@ typedef QMap<QString,QString> part_plist_t; | |||
75 | class RecPart | 75 | class RecPart |
76 | { | 76 | { |
77 | protected: | 77 | protected: |
78 | QString m_type,m_subtype,m_identifier,m_encoding; | 78 | QString m_type,m_subtype,m_identifier,m_encoding; |
79 | unsigned int m_lines; | 79 | unsigned int m_lines,m_size; |
80 | part_plist_t m_Parameters; | 80 | part_plist_t m_Parameters; |
81 | /* describes the position in the mail */ | 81 | /* describes the position in the mail */ |
82 | QValueList<int> m_poslist; | 82 | QValueList<int> m_poslist; |
83 | 83 | ||
@@ -94,8 +94,11 @@ public: | |||
94 | const QString&Encoding()const; | 94 | const QString&Encoding()const; |
95 | void setEncoding(const QString&encoding); | 95 | void setEncoding(const QString&encoding); |
96 | void setLines(unsigned int lines); | 96 | void setLines(unsigned int lines); |
97 | const unsigned int Lines()const; | 97 | const unsigned int Lines()const; |
98 | void setSize(unsigned int size); | ||
99 | const unsigned int Size()const; | ||
100 | |||
98 | 101 | ||
99 | void setParameters(const part_plist_t&list); | 102 | void setParameters(const part_plist_t&list); |
100 | const part_plist_t&Parameters()const; | 103 | const part_plist_t&Parameters()const; |
101 | void addParameter(const QString&key,const QString&value); | 104 | void addParameter(const QString&key,const QString&value); |
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp index 9c312e9..5cd45ed 100644 --- a/noncore/net/mail/mailtypes.cpp +++ b/noncore/net/mail/mailtypes.cpp | |||
@@ -67,9 +67,9 @@ const QStringList& RecMail::Bcc()const | |||
67 | return bcc; | 67 | return bcc; |
68 | } | 68 | } |
69 | 69 | ||
70 | RecPart::RecPart() | 70 | RecPart::RecPart() |
71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) | 71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0),m_size(0) |
72 | { | 72 | { |
73 | m_Parameters.clear(); | 73 | m_Parameters.clear(); |
74 | m_poslist.clear(); | 74 | m_poslist.clear(); |
75 | } | 75 | } |
@@ -77,8 +77,18 @@ RecPart::RecPart() | |||
77 | RecPart::~RecPart() | 77 | RecPart::~RecPart() |
78 | { | 78 | { |
79 | } | 79 | } |
80 | 80 | ||
81 | void RecPart::setSize(unsigned int size) | ||
82 | { | ||
83 | m_size = size; | ||
84 | } | ||
85 | |||
86 | const unsigned int RecPart::Size()const | ||
87 | { | ||
88 | return m_size; | ||
89 | } | ||
90 | |||
81 | void RecPart::setLines(unsigned int lines) | 91 | void RecPart::setLines(unsigned int lines) |
82 | { | 92 | { |
83 | m_lines = lines; | 93 | m_lines = lines; |
84 | } | 94 | } |
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h index f308bc7..24518cf 100644 --- a/noncore/net/mail/mailtypes.h +++ b/noncore/net/mail/mailtypes.h | |||
@@ -75,9 +75,9 @@ typedef QMap<QString,QString> part_plist_t; | |||
75 | class RecPart | 75 | class RecPart |
76 | { | 76 | { |
77 | protected: | 77 | protected: |
78 | QString m_type,m_subtype,m_identifier,m_encoding; | 78 | QString m_type,m_subtype,m_identifier,m_encoding; |
79 | unsigned int m_lines; | 79 | unsigned int m_lines,m_size; |
80 | part_plist_t m_Parameters; | 80 | part_plist_t m_Parameters; |
81 | /* describes the position in the mail */ | 81 | /* describes the position in the mail */ |
82 | QValueList<int> m_poslist; | 82 | QValueList<int> m_poslist; |
83 | 83 | ||
@@ -94,8 +94,11 @@ public: | |||
94 | const QString&Encoding()const; | 94 | const QString&Encoding()const; |
95 | void setEncoding(const QString&encoding); | 95 | void setEncoding(const QString&encoding); |
96 | void setLines(unsigned int lines); | 96 | void setLines(unsigned int lines); |
97 | const unsigned int Lines()const; | 97 | const unsigned int Lines()const; |
98 | void setSize(unsigned int size); | ||
99 | const unsigned int Size()const; | ||
100 | |||
98 | 101 | ||
99 | void setParameters(const part_plist_t&list); | 102 | void setParameters(const part_plist_t&list); |
100 | const part_plist_t&Parameters()const; | 103 | const part_plist_t&Parameters()const; |
101 | void addParameter(const QString&key,const QString&value); | 104 | void addParameter(const QString&key,const QString&value); |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 7b8494d..39c9820 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,34 +1,102 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qtextstream.h> | ||
3 | #include <qaction.h> | 4 | #include <qaction.h> |
4 | #include <qapplication.h> | 5 | #include <qapplication.h> |
5 | 6 | ||
6 | #include "settings.h" | 7 | #include "settings.h" |
7 | #include "composemail.h" | 8 | #include "composemail.h" |
8 | #include "viewmail.h" | 9 | #include "viewmail.h" |
9 | 10 | ||
10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) | 11 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) |
11 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 12 | : QListViewItem(parent,after),_partNum(num) |
12 | { | 13 | { |
13 | setText(0, _attachItemStore.mimeType()); | 14 | setText(0, mime); |
14 | setText(1, _attachItemStore.fileName()); | 15 | setText(1, file); |
15 | setText(2, _attachItemStore.description()); | 16 | setText(2, desc); |
16 | } | ||
17 | |||
18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) | ||
19 | : QListViewItem(parent), _attachItemStore(attachItemStore) | ||
20 | { | ||
21 | setText(0, _attachItemStore.mimeType()); | ||
22 | setText(1, _attachItemStore.fileName()); | ||
23 | setText(2, _attachItemStore.description()); | ||
24 | } | 17 | } |
25 | 18 | ||
26 | 19 | ||
27 | void ViewMail::setBody( RecBody body ) { | 20 | void ViewMail::setBody( RecBody body ) { |
28 | 21 | ||
29 | m_mail[2] = body.Bodytext(); | 22 | m_mail[2] = body.Bodytext(); |
23 | attachbutton->setEnabled(body.Parts().count()>0); | ||
24 | attachments->setEnabled(body.Parts().count()>0); | ||
25 | if (body.Parts().count()==0) { | ||
26 | return; | ||
27 | } | ||
28 | AttachItem * curItem=0; | ||
29 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | ||
30 | QString desc; | ||
31 | double s = body.Description().Size(); | ||
32 | int w; | ||
33 | w=0; | ||
34 | |||
35 | while (s>1024) { | ||
36 | s/=1024; | ||
37 | ++w; | ||
38 | if (w>=2) break; | ||
39 | } | ||
30 | 40 | ||
41 | QString q=""; | ||
42 | switch(w) { | ||
43 | case 1: | ||
44 | q="k"; | ||
45 | break; | ||
46 | case 2: | ||
47 | q="M"; | ||
48 | break; | ||
49 | default: | ||
50 | break; | ||
51 | } | ||
52 | |||
53 | { | ||
54 | /* I did not found a method to make a CONTENT reset on a QTextStream | ||
55 | so I use this construct that the stream will re-constructed in each | ||
56 | loop. To let it work, the textstream is packed into a own area of | ||
57 | code is it will be destructed after finishing its small job. | ||
58 | */ | ||
59 | QTextOStream o(&desc); | ||
60 | if (w>0) o.precision(2); else o.precision(0); | ||
61 | o.setf(QTextStream::fixed); | ||
62 | o << s << " " << q << "Byte"; | ||
63 | } | ||
64 | |||
65 | curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); | ||
66 | QString filename = ""; | ||
67 | for (unsigned int i = 0; i < body.Parts().count();++i) { | ||
68 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | ||
69 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | ||
70 | for (;it!=body.Parts()[i].Parameters().end();++it) { | ||
71 | if (it.key().lower()=="name") { | ||
72 | filename=it.data(); | ||
73 | } | ||
74 | } | ||
75 | s = body.Parts()[i].Size(); | ||
76 | w = 0; | ||
77 | while (s>1024) { | ||
78 | s/=1024; | ||
79 | ++w; | ||
80 | if (w>=2) break; | ||
81 | } | ||
82 | switch(w) { | ||
83 | case 1: | ||
84 | q="k"; | ||
85 | break; | ||
86 | case 2: | ||
87 | q="M"; | ||
88 | break; | ||
89 | default: | ||
90 | q=""; | ||
91 | break; | ||
92 | } | ||
93 | QTextOStream o(&desc); | ||
94 | if (w>0) o.precision(2); else o.precision(0); | ||
95 | o.setf(QTextStream::fixed); | ||
96 | o << s << " " << q << "Byte"; | ||
97 | curItem=new AttachItem(attachments,curItem,type,filename,desc,i); | ||
98 | } | ||
31 | } | 99 | } |
32 | 100 | ||
33 | void ViewMail::setMail( RecMail mail ) { | 101 | void ViewMail::setMail( RecMail mail ) { |
34 | 102 | ||
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index 61baa1d..b497434 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h | |||
@@ -7,36 +7,16 @@ | |||
7 | 7 | ||
8 | #include "viewmailbase.h" | 8 | #include "viewmailbase.h" |
9 | #include "mailtypes.h" | 9 | #include "mailtypes.h" |
10 | 10 | ||
11 | class AttachItemStore | ||
12 | { | ||
13 | public: | ||
14 | void setMimeType(QString mimeType) { _mimeType = mimeType; } | ||
15 | QString mimeType() { return _mimeType; } | ||
16 | void setFileName(QString fileName) { _fileName = fileName; } | ||
17 | QString fileName() { return _fileName; } | ||
18 | void setDescription(QString description) { _description = description; } | ||
19 | QString description() { return _description; } | ||
20 | void setPartNum(QString partNum) { _partNum = partNum; } | ||
21 | QString partNum() { return _partNum; } | ||
22 | |||
23 | private: | ||
24 | QString _mimeType, _fileName, _description, _partNum; | ||
25 | |||
26 | }; | ||
27 | |||
28 | class AttachItem : public QListViewItem | 11 | class AttachItem : public QListViewItem |
29 | { | 12 | { |
30 | public: | 13 | public: |
31 | AttachItem(QListView *parent, AttachItemStore &attachment); | 14 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num); |
32 | AttachItem(QListViewItem *parent, AttachItemStore &attachment); | 15 | int Partnumber() { return _partNum; } |
33 | |||
34 | AttachItemStore attachItemStore() { return _attachItemStore; } | ||
35 | 16 | ||
36 | private: | 17 | private: |
37 | AttachItemStore _attachItemStore; | 18 | int _partNum; |
38 | |||
39 | }; | 19 | }; |
40 | 20 | ||
41 | class ViewMail : public ViewMailBase | 21 | class ViewMail : public ViewMailBase |
42 | { | 22 | { |
diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp index 197a665..38f92b4 100644 --- a/noncore/net/mail/viewmailbase.cpp +++ b/noncore/net/mail/viewmailbase.cpp | |||
@@ -53,11 +53,12 @@ ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) | |||
53 | attachments = new QListView(view); | 53 | attachments = new QListView(view); |
54 | attachments->setMinimumHeight(90); | 54 | attachments->setMinimumHeight(90); |
55 | attachments->setMaximumHeight(90); | 55 | attachments->setMaximumHeight(90); |
56 | attachments->setAllColumnsShowFocus(true); | 56 | attachments->setAllColumnsShowFocus(true); |
57 | attachments->addColumn("Mime Type", 100); | 57 | attachments->addColumn("Mime Type", 60); |
58 | attachments->addColumn("Filename", 100); | 58 | attachments->addColumn(tr("Filename"), 100); |
59 | attachments->addColumn("Description", 100); | 59 | attachments->addColumn(tr("Size"), 80); |
60 | attachments->setSorting(-1); | ||
60 | attachments->hide(); | 61 | attachments->hide(); |
61 | 62 | ||
62 | browser = new QTextBrowser(view); | 63 | browser = new QTextBrowser(view); |
63 | 64 | ||