summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-12-13 13:45:40 (UTC)
committer harlekin <harlekin>2003-12-13 13:45:40 (UTC)
commite1dc235a829398482dddc66b931d6eec840382ec (patch) (unidiff)
treeb4a93390a382eb9ce2f9c9a3703e4f03c3e475e0
parent865b023c57f657c8eff26baa670fc76bbcd548e4 (diff)
downloadopie-e1dc235a829398482dddc66b931d6eec840382ec.zip
opie-e1dc235a829398482dddc66b931d6eec840382ec.tar.gz
opie-e1dc235a829398482dddc66b931d6eec840382ec.tar.bz2
beginning of attachment handling ( user side )
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp6
-rw-r--r--noncore/net/mail/viewmail.cpp56
-rw-r--r--noncore/net/mail/viewmail.h2
3 files changed, 59 insertions, 5 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index f0a915d..560715c 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -162,14 +162,14 @@ void MainWindow::displayMail(QListViewItem*item)
162 readMail.setMail( mail ); 162 readMail.setMail( mail );
163 readMail.showMaximized(); 163 readMail.showMaximized();
164 readMail.exec(); 164 readMail.exec();
165 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 165 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
166} 166}
167 167
168MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after ) 168MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
169 :QListViewItem(parent,after),mail_data() 169 :QListViewItem(parent,item),mail_data()
170{ 170{
171} 171}
172 172
173void MailListViewItem::showEntry() 173void MailListViewItem::showEntry()
174{ 174{
175 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 175 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
@@ -188,6 +188,8 @@ void MailListViewItem::storeData(const RecMail&data)
188} 188}
189 189
190const RecMail& MailListViewItem::data()const 190const RecMail& MailListViewItem::data()const
191{ 191{
192 return mail_data; 192 return mail_data;
193} 193}
194
195
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 39c9820..c24d5d3 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1,27 +1,30 @@
1#include <qtextbrowser.h> 1#include <qtextbrowser.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qaction.h> 4#include <qaction.h>
5#include <qpopupmenu.h>
5#include <qapplication.h> 6#include <qapplication.h>
6 7
8#include <opie/ofiledialog.h>
9
7#include "settings.h" 10#include "settings.h"
8#include "composemail.h" 11#include "composemail.h"
9#include "viewmail.h" 12#include "viewmail.h"
10 13
11AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) 14AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num)
12 : QListViewItem(parent,after),_partNum(num) 15 : QListViewItem(parent,after),_partNum(num)
13{ 16{
14 setText(0, mime); 17 setText(0, mime);
15 setText(1, file); 18 setText(1, file);
16 setText(2, desc); 19 setText(2, desc);
17} 20}
18 21
19
20void ViewMail::setBody( RecBody body ) { 22void ViewMail::setBody( RecBody body ) {
21 23
24m_body = body;
22m_mail[2] = body.Bodytext(); 25m_mail[2] = body.Bodytext();
23attachbutton->setEnabled(body.Parts().count()>0); 26attachbutton->setEnabled(body.Parts().count()>0);
24attachments->setEnabled(body.Parts().count()>0); 27attachments->setEnabled(body.Parts().count()>0);
25if (body.Parts().count()==0) { 28if (body.Parts().count()==0) {
26 return; 29 return;
27} 30}
@@ -49,13 +52,13 @@ case 2:
49default: 52default:
50 break; 53 break;
51} 54}
52 55
53{ 56{
54 /* I did not found a method to make a CONTENT reset on a QTextStream 57 /* 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 58 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 59 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. 60 code is it will be destructed after finishing its small job.
58 */ 61 */
59 QTextOStream o(&desc); 62 QTextOStream o(&desc);
60 if (w>0) o.precision(2); else o.precision(0); 63 if (w>0) o.precision(2); else o.precision(0);
61 o.setf(QTextStream::fixed); 64 o.setf(QTextStream::fixed);
@@ -95,12 +98,54 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
95 o.setf(QTextStream::fixed); 98 o.setf(QTextStream::fixed);
96 o << s << " " << q << "Byte"; 99 o << s << " " << q << "Byte";
97 curItem=new AttachItem(attachments,curItem,type,filename,desc,i); 100 curItem=new AttachItem(attachments,curItem,type,filename,desc,i);
98} 101}
99} 102}
100 103
104void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) {
105 if (!item )
106 return;
107
108 QPopupMenu *menu = new QPopupMenu();
109 int ret=0;
110
111 if ( item->text( 0 ).left( 4 ) == "text" ) {
112 menu->insertItem( tr( "Show Text" ), 1 );
113 }
114 menu->insertItem( tr( "Save Attachemt" ), 0 );
115 menu->insertSeparator(1);
116
117 ret = menu->exec( point, 0 );
118
119 switch(ret) {
120 case 0:
121 { MimeTypes types;
122 types.insert( "all", "*" );
123 QString str = OFileDialog::getSaveFileName( 1,
124 "/", item->text( 1 ) , types, 0 );
125
126 if( !str.isEmpty() ) {
127 qDebug( " first we will need a MIME wrapper" );
128 }
129 }
130 break ;
131
132 case 1:
133
134 qDebug( QString( "Test selected" ).arg( ( ( AttachItem* )item )->Partnumber() ) );
135 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) {
136 setText();
137 } else {
138 browser->setText( ( m_body.Parts()[( ( AttachItem* )item )->Partnumber() ] ).Identifier() );
139 }
140 break;
141 }
142 delete menu;
143}
144
145
101void ViewMail::setMail( RecMail mail ) { 146void ViewMail::setMail( RecMail mail ) {
102 147
103m_mail[0] = mail.getFrom(); 148m_mail[0] = mail.getFrom();
104m_mail[1] = mail.getSubject(); 149m_mail[1] = mail.getSubject();
105m_mail[3] = mail.getDate(); 150m_mail[3] = mail.getDate();
106m_mail[4] = mail.Msgid(); 151m_mail[4] = mail.Msgid();
@@ -120,12 +165,14 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
120 m_gotBody = false; 165 m_gotBody = false;
121 166
122 connect(reply, SIGNAL(activated()), SLOT(slotReply())); 167 connect(reply, SIGNAL(activated()), SLOT(slotReply()));
123 connect(forward, SIGNAL(activated()), SLOT(slotForward())); 168 connect(forward, SIGNAL(activated()), SLOT(slotForward()));
124 169
125 attachments->setEnabled(m_gotBody); 170 attachments->setEnabled(m_gotBody);
171 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) );
172
126} 173}
127 174
128void ViewMail::setText() 175void ViewMail::setText()
129{ 176{
130 177
131 QString toString; 178 QString toString;
@@ -169,23 +216,26 @@ void ViewMail::hide()
169{ 216{
170 QWidget::hide(); 217 QWidget::hide();
171 218
172 if (_inLoop) { 219 if (_inLoop) {
173 _inLoop = false; 220 _inLoop = false;
174 qApp->exit_loop(); 221 qApp->exit_loop();
175 } 222
223 }
224
176} 225}
177 226
178void ViewMail::exec() 227void ViewMail::exec()
179{ 228{
180 show(); 229 show();
181 230
182 if (!_inLoop) { 231 if (!_inLoop) {
183 _inLoop = true; 232 _inLoop = true;
184 qApp->enter_loop(); 233 qApp->enter_loop();
185 } 234 }
235
186} 236}
187 237
188QString ViewMail::deHtml(const QString &string) 238QString ViewMail::deHtml(const QString &string)
189{ 239{
190 QString string_ = string; 240 QString string_ = string;
191 string_.replace(QRegExp("&"), "&amp;"); 241 string_.replace(QRegExp("&"), "&amp;");
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index b497434..0e85839 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -35,17 +35,19 @@ protected:
35 QString deHtml(const QString &string); 35 QString deHtml(const QString &string);
36 36
37protected slots: 37protected slots:
38 void slotReply(); 38 void slotReply();
39 void slotForward(); 39 void slotForward();
40 void setText(); 40 void setText();
41 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
41 42
42private: 43private:
43 bool _inLoop; 44 bool _inLoop;
44 QString m_mailHtml; 45 QString m_mailHtml;
45 bool m_gotBody; 46 bool m_gotBody;
47 RecBody m_body;
46 48
47 // 0 from 1 subject 2 bodytext 3 date 49 // 0 from 1 subject 2 bodytext 3 date
48 QMap <int,QString> m_mail; 50 QMap <int,QString> m_mail;
49 // 0 to 1 cc 2 bcc 51 // 0 to 1 cc 2 bcc
50 QMap <int,QStringList> m_mail2; 52 QMap <int,QStringList> m_mail2;
51 53