-rw-r--r-- | noncore/net/mail/viewmail.cpp | 151 |
1 files changed, 97 insertions, 54 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 99965d4..f015228 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,26 +1,29 @@ | |||
1 | #include "composemail.h" | ||
2 | #include "viewmail.h" | ||
3 | #include "accountview.h" | ||
4 | |||
5 | /* OPIE */ | ||
6 | #include <libmailwrapper/settings.h> | ||
7 | #include <libmailwrapper/abstractmail.h> | ||
8 | #include <libmailwrapper/mailtypes.h> | ||
9 | |||
10 | #include <opie2/ofiledialog.h> | ||
11 | #include <qpe/config.h> | ||
12 | #include <qpe/qpeapplication.h> | ||
13 | |||
14 | /* QT */ | ||
1 | #include <qtextbrowser.h> | 15 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
3 | #include <qtextstream.h> | 17 | #include <qtextstream.h> |
4 | #include <qaction.h> | 18 | #include <qaction.h> |
5 | #include <qpopupmenu.h> | 19 | #include <qpopupmenu.h> |
6 | #include <qfile.h> | 20 | #include <qfile.h> |
7 | #include <qapplication.h> | 21 | #include <qapplication.h> |
8 | #include <qvaluelist.h> | 22 | #include <qvaluelist.h> |
9 | 23 | ||
10 | #include <qpe/config.h> | ||
11 | |||
12 | #include <opie2/ofiledialog.h> | ||
13 | |||
14 | #include <libmailwrapper/settings.h> | ||
15 | #include "composemail.h" | ||
16 | #include "viewmail.h" | ||
17 | #include <libmailwrapper/abstractmail.h> | ||
18 | #include "accountview.h" | ||
19 | #include <libmailwrapper/mailtypes.h> | ||
20 | |||
21 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 24 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
22 | const QString&fsize,int num,const QValueList<int>&path) | 25 | const QString&fsize,int num,const QValueList<int>&path) |
23 | : QListViewItem(parent,after),_partNum(num) | 26 | : QListViewItem(parent,after),_partNum(num) |
24 | { | 27 | { |
25 | _path=path; | 28 | _path=path; |
26 | setText(0, mime); | 29 | setText(0, mime); |
@@ -43,65 +46,72 @@ AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QStrin | |||
43 | bool AttachItem::isParentof(const QValueList<int>&path) | 46 | bool AttachItem::isParentof(const QValueList<int>&path) |
44 | { | 47 | { |
45 | /* if not set, then no parent */ | 48 | /* if not set, then no parent */ |
46 | if (path.count()==0||_path.count()==0) return false; | 49 | if (path.count()==0||_path.count()==0) return false; |
47 | /* the parent must have one digit less then a child */ | 50 | /* the parent must have one digit less then a child */ |
48 | if (path.count()!=_path.count()+1) return false; | 51 | if (path.count()!=_path.count()+1) return false; |
49 | for (unsigned int i=0; i < _path.count();++i) { | 52 | for (unsigned int i=0; i < _path.count();++i) |
53 | { | ||
50 | if (_path[i]!=path[i]) return false; | 54 | if (_path[i]!=path[i]) return false; |
51 | } | 55 | } |
52 | return true; | 56 | return true; |
53 | } | 57 | } |
54 | 58 | ||
55 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 59 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
56 | { | 60 | { |
57 | QListViewItemIterator it( attachments ); | 61 | QListViewItemIterator it( attachments ); |
58 | for ( ; it.current(); ++it ) { | 62 | for ( ; it.current(); ++it ) |
63 | { | ||
59 | AttachItem*ati = (AttachItem*)it.current(); | 64 | AttachItem*ati = (AttachItem*)it.current(); |
60 | if (ati->isParentof(path)) return ati; | 65 | if (ati->isParentof(path)) return ati; |
61 | } | 66 | } |
62 | return 0; | 67 | return 0; |
63 | } | 68 | } |
64 | 69 | ||
65 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 70 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
66 | { | 71 | { |
67 | if (!parent) return 0; | 72 | if (!parent) return 0; |
68 | AttachItem* item = (AttachItem*)parent->firstChild(); | 73 | AttachItem* item = (AttachItem*)parent->firstChild(); |
69 | if (!item) return item; | 74 | if (!item) return item; |
70 | AttachItem*temp=0; | 75 | AttachItem*temp=0; |
71 | while( (temp=(AttachItem*)item->nextSibling())) { | 76 | while( (temp=(AttachItem*)item->nextSibling())) |
77 | { | ||
72 | item = temp; | 78 | item = temp; |
73 | } | 79 | } |
74 | return item; | 80 | return item; |
75 | } | 81 | } |
76 | 82 | ||
77 | void ViewMail::setBody( RecBody body ) { | 83 | void ViewMail::setBody( RecBody body ) |
84 | { | ||
78 | 85 | ||
79 | m_body = body; | 86 | m_body = body; |
80 | m_mail[2] = body.Bodytext(); | 87 | m_mail[2] = body.Bodytext(); |
81 | attachbutton->setEnabled(body.Parts().count()>0); | 88 | attachbutton->setEnabled(body.Parts().count()>0); |
82 | attachments->setEnabled(body.Parts().count()>0); | 89 | attachments->setEnabled(body.Parts().count()>0); |
83 | if (body.Parts().count()==0) { | 90 | if (body.Parts().count()==0) |
91 | { | ||
84 | return; | 92 | return; |
85 | } | 93 | } |
86 | AttachItem * curItem=0; | 94 | AttachItem * curItem=0; |
87 | AttachItem * parentItem = 0; | 95 | AttachItem * parentItem = 0; |
88 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 96 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
89 | QString desc,fsize; | 97 | QString desc,fsize; |
90 | double s = body.Description().Size(); | 98 | double s = body.Description().Size(); |
91 | int w; | 99 | int w; |
92 | w=0; | 100 | w=0; |
93 | 101 | ||
94 | while (s>1024) { | 102 | while (s>1024) |
103 | { | ||
95 | s/=1024; | 104 | s/=1024; |
96 | ++w; | 105 | ++w; |
97 | if (w>=2) break; | 106 | if (w>=2) break; |
98 | } | 107 | } |
99 | 108 | ||
100 | QString q=""; | 109 | QString q=""; |
101 | switch(w) { | 110 | switch(w) |
111 | { | ||
102 | case 1: | 112 | case 1: |
103 | q="k"; | 113 | q="k"; |
104 | break; | 114 | break; |
105 | case 2: | 115 | case 2: |
106 | q="M"; | 116 | q="M"; |
107 | break; | 117 | break; |
@@ -121,29 +131,34 @@ default: | |||
121 | o << s << " " << q << "Byte"; | 131 | o << s << " " << q << "Byte"; |
122 | } | 132 | } |
123 | 133 | ||
124 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); | 134 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); |
125 | QString filename = ""; | 135 | QString filename = ""; |
126 | 136 | ||
127 | for (unsigned int i = 0; i < body.Parts().count();++i) { | 137 | for (unsigned int i = 0; i < body.Parts().count();++i) |
138 | { | ||
128 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 139 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
129 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 140 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
130 | for (;it!=body.Parts()[i].Parameters().end();++it) { | 141 | for (;it!=body.Parts()[i].Parameters().end();++it) |
142 | { | ||
131 | qDebug(it.key()); | 143 | qDebug(it.key()); |
132 | if (it.key().lower()=="name") { | 144 | if (it.key().lower()=="name") |
145 | { | ||
133 | filename=it.data(); | 146 | filename=it.data(); |
134 | } | 147 | } |
135 | } | 148 | } |
136 | s = body.Parts()[i].Size(); | 149 | s = body.Parts()[i].Size(); |
137 | w = 0; | 150 | w = 0; |
138 | while (s>1024) { | 151 | while (s>1024) |
152 | { | ||
139 | s/=1024; | 153 | s/=1024; |
140 | ++w; | 154 | ++w; |
141 | if (w>=2) break; | 155 | if (w>=2) break; |
142 | } | 156 | } |
143 | switch(w) { | 157 | switch(w) |
158 | { | ||
144 | case 1: | 159 | case 1: |
145 | q="k"; | 160 | q="k"; |
146 | break; | 161 | break; |
147 | case 2: | 162 | case 2: |
148 | q="M"; | 163 | q="M"; |
149 | break; | 164 | break; |
@@ -154,84 +169,100 @@ for (unsigned int i = 0; i < body.Parts().count();++i) { | |||
154 | QTextOStream o(&fsize); | 169 | QTextOStream o(&fsize); |
155 | if (w>0) o.precision(2); else o.precision(0); | 170 | if (w>0) o.precision(2); else o.precision(0); |
156 | o.setf(QTextStream::fixed); | 171 | o.setf(QTextStream::fixed); |
157 | o << s << " " << q << "Byte"; | 172 | o << s << " " << q << "Byte"; |
158 | desc = body.Parts()[i].Description(); | 173 | desc = body.Parts()[i].Description(); |
159 | parentItem = searchParent(body.Parts()[i].Positionlist()); | 174 | parentItem = searchParent(body.Parts()[i].Positionlist()); |
160 | if (parentItem) { | 175 | if (parentItem) |
176 | { | ||
161 | AttachItem*temp = lastChild(parentItem); | 177 | AttachItem*temp = lastChild(parentItem); |
162 | if (temp) curItem = temp; | 178 | if (temp) curItem = temp; |
163 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 179 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); |
164 | attachments->setRootIsDecorated(true); | 180 | attachments->setRootIsDecorated(true); |
165 | curItem = parentItem; | 181 | curItem = parentItem; |
166 | } else { | 182 | } |
183 | else | ||
184 | { | ||
167 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 185 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); |
168 | } | 186 | } |
169 | } | 187 | } |
170 | } | 188 | } |
171 | 189 | ||
172 | 190 | ||
173 | void ViewMail::slotShowHtml( bool state ) { | 191 | void ViewMail::slotShowHtml( bool state ) |
192 | { | ||
174 | m_showHtml = state; | 193 | m_showHtml = state; |
175 | setText(); | 194 | setText(); |
176 | } | 195 | } |
177 | 196 | ||
178 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { | 197 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
198 | { | ||
179 | if (!item ) | 199 | if (!item ) |
180 | return; | 200 | return; |
181 | 201 | ||
182 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 202 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
203 | { | ||
183 | setText(); | 204 | setText(); |
184 | return; | 205 | return; |
185 | } | 206 | } |
186 | QPopupMenu *menu = new QPopupMenu(); | 207 | QPopupMenu *menu = new QPopupMenu(); |
187 | int ret=0; | 208 | int ret=0; |
188 | 209 | ||
189 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { | 210 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
211 | { | ||
190 | menu->insertItem( tr( "Show Text" ), 1 ); | 212 | menu->insertItem( tr( "Show Text" ), 1 ); |
191 | } | 213 | } |
192 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 214 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
193 | menu->insertSeparator(1); | 215 | menu->insertSeparator(1); |
194 | 216 | ||
195 | ret = menu->exec( point, 0 ); | 217 | ret = menu->exec( point, 0 ); |
196 | 218 | ||
197 | switch(ret) { | 219 | switch(ret) |
220 | { | ||
198 | case 0: | 221 | case 0: |
199 | { MimeTypes types; | 222 | { |
223 | MimeTypes types; | ||
200 | types.insert( "all", "*" ); | 224 | types.insert( "all", "*" ); |
201 | QString str = Opie::OFileDialog::getSaveFileName( 1, | 225 | QString str = Opie::OFileDialog::getSaveFileName( 1, |
202 | "/", item->text( 2 ) , types, 0 ); | 226 | "/", item->text( 2 ) , types, 0 ); |
203 | 227 | ||
204 | if( !str.isEmpty() ) { | 228 | if( !str.isEmpty() ) |
229 | { | ||
205 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 230 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
206 | if (content) { | 231 | if (content) |
232 | { | ||
207 | QFile output(str); | 233 | QFile output(str); |
208 | output.open(IO_WriteOnly); | 234 | output.open(IO_WriteOnly); |
209 | output.writeBlock(content->Content(),content->Length()); | 235 | output.writeBlock(content->Content(),content->Length()); |
210 | output.close(); | 236 | output.close(); |
211 | delete content; | 237 | delete content; |
212 | } | 238 | } |
213 | } | 239 | } |
214 | } | 240 | } |
215 | break ; | 241 | break ; |
216 | 242 | ||
217 | case 1: | 243 | case 1: |
218 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 244 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
245 | { | ||
219 | setText(); | 246 | setText(); |
220 | } else { | 247 | } |
221 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions | 248 | else |
249 | { | ||
250 | if ( m_recMail.Wrapper() != 0l ) | ||
251 | { // make sure that there is a wrapper , even after delete or simular actions | ||
222 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 252 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
223 | } | 253 | } |
224 | } | 254 | } |
225 | break; | 255 | break; |
226 | } | 256 | } |
227 | delete menu; | 257 | delete menu; |
228 | } | 258 | } |
229 | 259 | ||
230 | 260 | ||
231 | void ViewMail::setMail( RecMail mail ) { | 261 | void ViewMail::setMail( RecMail mail ) |
262 | { | ||
232 | 263 | ||
233 | m_recMail = mail; | 264 | m_recMail = mail; |
234 | 265 | ||
235 | m_mail[0] = mail.getFrom(); | 266 | m_mail[0] = mail.getFrom(); |
236 | m_mail[1] = mail.getSubject(); | 267 | m_mail[1] = mail.getSubject(); |
237 | m_mail[3] = mail.getDate(); | 268 | m_mail[3] = mail.getDate(); |
@@ -261,13 +292,14 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | |||
261 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); | 292 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); |
262 | 293 | ||
263 | readConfig(); | 294 | readConfig(); |
264 | attachments->setSorting(-1); | 295 | attachments->setSorting(-1); |
265 | } | 296 | } |
266 | 297 | ||
267 | void ViewMail::readConfig() { | 298 | void ViewMail::readConfig() |
299 | { | ||
268 | Config cfg( "mail" ); | 300 | Config cfg( "mail" ); |
269 | cfg.setGroup( "Settings" ); | 301 | cfg.setGroup( "Settings" ); |
270 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 302 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
271 | showHtml->setOn( m_showHtml ); | 303 | showHtml->setOn( m_showHtml ); |
272 | } | 304 | } |
273 | 305 | ||
@@ -275,19 +307,22 @@ void ViewMail::setText() | |||
275 | { | 307 | { |
276 | 308 | ||
277 | QString toString; | 309 | QString toString; |
278 | QString ccString; | 310 | QString ccString; |
279 | QString bccString; | 311 | QString bccString; |
280 | 312 | ||
281 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | 313 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
314 | { | ||
282 | toString += (*it); | 315 | toString += (*it); |
283 | } | 316 | } |
284 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | 317 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
318 | { | ||
285 | ccString += (*it); | 319 | ccString += (*it); |
286 | } | 320 | } |
287 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | 321 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
322 | { | ||
288 | bccString += (*it); | 323 | bccString += (*it); |
289 | } | 324 | } |
290 | 325 | ||
291 | setCaption( caption().arg( m_mail[0] ) ); | 326 | setCaption( caption().arg( m_mail[0] ) ); |
292 | 327 | ||
293 | m_mailHtml = "<html><body>" | 328 | m_mailHtml = "<html><body>" |
@@ -297,15 +332,18 @@ void ViewMail::setText() | |||
297 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 332 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
298 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 333 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
299 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 334 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
300 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 335 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
301 | "</td></tr></table><font face=fixed>"; | 336 | "</td></tr></table><font face=fixed>"; |
302 | 337 | ||
303 | if ( !m_showHtml ) { | 338 | if ( !m_showHtml ) |
339 | { | ||
304 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 340 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
305 | } else { | 341 | } |
342 | else | ||
343 | { | ||
306 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 344 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
307 | } | 345 | } |
308 | // remove later in favor of a real handling | 346 | // remove later in favor of a real handling |
309 | m_gotBody = true; | 347 | m_gotBody = true; |
310 | } | 348 | } |
311 | 349 | ||
@@ -317,25 +355,27 @@ ViewMail::~ViewMail() | |||
317 | } | 355 | } |
318 | 356 | ||
319 | void ViewMail::hide() | 357 | void ViewMail::hide() |
320 | { | 358 | { |
321 | QWidget::hide(); | 359 | QWidget::hide(); |
322 | 360 | ||
323 | if (_inLoop) { | 361 | if (_inLoop) |
362 | { | ||
324 | _inLoop = false; | 363 | _inLoop = false; |
325 | qApp->exit_loop(); | 364 | qApp->exit_loop(); |
326 | 365 | ||
327 | } | 366 | } |
328 | 367 | ||
329 | } | 368 | } |
330 | 369 | ||
331 | void ViewMail::exec() | 370 | void ViewMail::exec() |
332 | { | 371 | { |
333 | show(); | 372 | show(); |
334 | 373 | ||
335 | if (!_inLoop) { | 374 | if (!_inLoop) |
375 | { | ||
336 | _inLoop = true; | 376 | _inLoop = true; |
337 | qApp->enter_loop(); | 377 | qApp->enter_loop(); |
338 | } | 378 | } |
339 | 379 | ||
340 | } | 380 | } |
341 | 381 | ||
@@ -348,26 +388,28 @@ QString ViewMail::deHtml(const QString &string) | |||
348 | string_.replace(QRegExp("\\n"), "<br>"); | 388 | string_.replace(QRegExp("\\n"), "<br>"); |
349 | return string_; | 389 | return string_; |
350 | } | 390 | } |
351 | 391 | ||
352 | void ViewMail::slotReply() | 392 | void ViewMail::slotReply() |
353 | { | 393 | { |
354 | if (!m_gotBody) { | 394 | if (!m_gotBody) |
395 | { | ||
355 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 396 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
356 | return; | 397 | return; |
357 | } | 398 | } |
358 | 399 | ||
359 | QString rtext; | 400 | QString rtext; |
360 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 401 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
361 | .arg( m_mail[0] ) | 402 | .arg( m_mail[0] ) |
362 | .arg( m_mail[3] ); | 403 | .arg( m_mail[3] ); |
363 | 404 | ||
364 | QString text = m_mail[2]; | 405 | QString text = m_mail[2]; |
365 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 406 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
366 | QStringList::Iterator it; | 407 | QStringList::Iterator it; |
367 | for (it = lines.begin(); it != lines.end(); it++) { | 408 | for (it = lines.begin(); it != lines.end(); it++) |
409 | { | ||
368 | rtext += "> " + *it + "\n"; | 410 | rtext += "> " + *it + "\n"; |
369 | } | 411 | } |
370 | rtext += "\n"; | 412 | rtext += "\n"; |
371 | 413 | ||
372 | QString prefix; | 414 | QString prefix; |
373 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; | 415 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; |
@@ -375,21 +417,22 @@ void ViewMail::slotReply() | |||
375 | 417 | ||
376 | Settings *settings = new Settings(); | 418 | Settings *settings = new Settings(); |
377 | ComposeMail composer( settings ,this, 0, true); | 419 | ComposeMail composer( settings ,this, 0, true); |
378 | composer.setTo( m_mail[0] ); | 420 | composer.setTo( m_mail[0] ); |
379 | composer.setSubject( "Re: " + m_mail[1] ); | 421 | composer.setSubject( "Re: " + m_mail[1] ); |
380 | composer.setMessage( rtext ); | 422 | composer.setMessage( rtext ); |
381 | composer.showMaximized(); | 423 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) |
382 | if ( QDialog::Accepted==composer.exec()) { | 424 | { |
383 | m_recMail.Wrapper()->answeredMail(m_recMail); | 425 | m_recMail.Wrapper()->answeredMail(m_recMail); |
384 | } | 426 | } |
385 | } | 427 | } |
386 | 428 | ||
387 | void ViewMail::slotForward() | 429 | void ViewMail::slotForward() |
388 | { | 430 | { |
389 | if (!m_gotBody) { | 431 | if (!m_gotBody) |
432 | { | ||
390 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 433 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
391 | return; | 434 | return; |
392 | } | 435 | } |
393 | 436 | ||
394 | QString ftext; | 437 | QString ftext; |
395 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 438 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
@@ -410,20 +453,20 @@ void ViewMail::slotForward() | |||
410 | ftext += QString("----- End forwarded message -----\n"); | 453 | ftext += QString("----- End forwarded message -----\n"); |
411 | 454 | ||
412 | Settings *settings = new Settings(); | 455 | Settings *settings = new Settings(); |
413 | ComposeMail composer( settings ,this, 0, true); | 456 | ComposeMail composer( settings ,this, 0, true); |
414 | composer.setSubject( "Fwd: " + m_mail[1] ); | 457 | composer.setSubject( "Fwd: " + m_mail[1] ); |
415 | composer.setMessage( ftext ); | 458 | composer.setMessage( ftext ); |
416 | composer.showMaximized(); | 459 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) |
417 | if ( QDialog::Accepted==composer.exec()) { | 460 | { |
418 | |||
419 | } | 461 | } |
420 | } | 462 | } |
421 | 463 | ||
422 | void ViewMail::slotDeleteMail( ) | 464 | void ViewMail::slotDeleteMail( ) |
423 | { | 465 | { |
424 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { | 466 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
467 | { | ||
425 | m_recMail.Wrapper()->deleteMail( m_recMail ); | 468 | m_recMail.Wrapper()->deleteMail( m_recMail ); |
426 | hide(); | 469 | hide(); |
427 | deleted = true; | 470 | deleted = true; |
428 | } | 471 | } |
429 | } | 472 | } |