summaryrefslogtreecommitdiff
path: root/noncore/net/mail/viewmail.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index a64a168..5206220 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -193,23 +193,23 @@ void ViewMail::setBody(const RecBodyP&body )
193} 193}
194 194
195 195
196void ViewMail::slotShowHtml( bool state ) 196void ViewMail::slotShowHtml( bool state )
197{ 197{
198 m_showHtml = state; 198 m_showHtml = state;
199 setText(); 199 setMainText();
200} 200}
201 201
202void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 202void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
203{ 203{
204 if (!item ) 204 if (!item )
205 return; 205 return;
206 206
207 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 207 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
208 { 208 {
209 setText(); 209 setMainText();
210 return; 210 return;
211 } 211 }
212 QPopupMenu *menu = new QPopupMenu(); 212 QPopupMenu *menu = new QPopupMenu();
213 int ret=0; 213 int ret=0;
214 214
215 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 215 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
@@ -247,12 +247,21 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
247 } 247 }
248 } 248 }
249 break ; 249 break ;
250 250
251 case 2: 251 case 2:
252 { 252 {
253 if (m_lastimagepart== (( AttachItem* )item )->Partnumber()) {
254 if (m_lastdlg) {
255 setUpdatesEnabled(false);
256 browser->hide();
257 m_lastdlg->show();
258 setUpdatesEnabled(true);
259 return;
260 }
261 }
253 QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++); 262 QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++);
254 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 263 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
255 if (content && content->Length()) { 264 if (content && content->Length()) {
256 QFile output(tmpfile); 265 QFile output(tmpfile);
257 output.open(IO_WriteOnly); 266 output.open(IO_WriteOnly);
258 output.writeBlock(content->Content(),content->Length()); 267 output.writeBlock(content->Content(),content->Length());
@@ -273,24 +282,35 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
273 m_lastdlg->show(); 282 m_lastdlg->show();
274 } 283 }
275 output.remove(); 284 output.remove();
276 } else { 285 } else {
277 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment")); 286 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment"));
278 } 287 }
288 m_lastimagepart=(( AttachItem* )item )->Partnumber();
279 } 289 }
280 break; 290 break;
281 case 1: 291 case 1:
282 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 292 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
283 { 293 {
284 setText(); 294 setMainText();
285 } 295 }
286 else 296 else
287 { 297 {
288 if ( m_recMail->Wrapper() != 0l ) 298 if ( m_recMail->Wrapper() != 0l )
289 { // make sure that there is a wrapper , even after delete or simular actions 299 { // make sure that there is a wrapper , even after delete or simular actions
290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 300 if (m_lastdlg) {
301 m_lastdlg->hide();
302 browser->show();
303 }
304 if (m_lasttextpart == ( ( AttachItem* )item )->Partnumber() ) return;
305 m_lasttextpart = ( ( AttachItem* )item )->Partnumber();
306 QString s = m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );;
307 if (item->text(0).right(4)!="html") {
308 s = QString("<html><body>\n<font face=fixed>%1</font></body></html>").arg(QStyleSheet::convertFromPlainText(s));
309 }
310 browser->setText(s);
291 } 311 }
292 } 312 }
293 break; 313 break;
294 } 314 }
295 delete menu; 315 delete menu;
296} 316}
@@ -308,13 +328,13 @@ void ViewMail::setMail(const RecMailP&mail )
308 328
309 m_mail2[0] = mail->To(); 329 m_mail2[0] = mail->To();
310 m_mail2[1] = mail->CC(); 330 m_mail2[1] = mail->CC();
311 m_mail2[2] = mail->Bcc(); 331 m_mail2[2] = mail->Bcc();
312 332
313 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); 333 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) );
314 setText(); 334 setMainText();
315} 335}
316 336
317 337
318 338
319ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 339ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
320 : ViewMailBase(parent, name, fl), _inLoop(false) 340 : ViewMailBase(parent, name, fl), _inLoop(false)
@@ -329,12 +349,14 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
329 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) ); 349 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) );
330 350
331 attachments->setEnabled(m_gotBody); 351 attachments->setEnabled(m_gotBody);
332 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 352 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
333 m_lastdlg = 0; 353 m_lastdlg = 0;
334 _icounter = 0; 354 _icounter = 0;
355 m_lastimagepart = -1;
356 m_lasttextpart = -2;
335 357
336 readConfig(); 358 readConfig();
337 attachments->setSorting(-1); 359 attachments->setSorting(-1);
338} 360}
339 361
340void ViewMail::slotImageInline(bool how) 362void ViewMail::slotImageInline(bool how)
@@ -345,12 +367,13 @@ void ViewMail::slotImageInline(bool how)
345 if (m_lastdlg&&!how) { 367 if (m_lastdlg&&!how) {
346 browser->show(); 368 browser->show();
347 m_lastdlg->hide(); 369 m_lastdlg->hide();
348 m_lastdlg->reparent(0,QPoint(0,0),false); 370 m_lastdlg->reparent(0,QPoint(0,0),false);
349 delete m_lastdlg; 371 delete m_lastdlg;
350 m_lastdlg = 0; 372 m_lastdlg = 0;
373 m_lastimagepart = -1;
351 } 374 }
352} 375}
353 376
354void ViewMail::readConfig() 377void ViewMail::readConfig()
355{ 378{
356 Config cfg( "mail" ); 379 Config cfg( "mail" );
@@ -358,23 +381,25 @@ void ViewMail::readConfig()
358 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 381 m_showHtml = cfg.readBoolEntry( "showHtml", false );
359 m_PicsInline = cfg.readBoolEntry( "showPicsInline", true ); 382 m_PicsInline = cfg.readBoolEntry( "showPicsInline", true );
360 showPicsInline->setOn(m_PicsInline); 383 showPicsInline->setOn(m_PicsInline);
361 showHtml->setOn( m_showHtml ); 384 showHtml->setOn( m_showHtml );
362} 385}
363 386
364void ViewMail::setText() 387void ViewMail::setMainText()
365{ 388{
366 QString toString; 389 QString toString;
367 QString ccString; 390 QString ccString;
368 QString bccString; 391 QString bccString;
369 QString mailHtml; 392 QString mailHtml;
370 393
371 if (m_lastdlg) { 394 if (m_lastdlg) {
372 m_lastdlg->hide(); 395 m_lastdlg->hide();
373 } 396 }
374 browser->show(); 397 browser->show();
398 if (m_lasttextpart == -1) return;
399 m_lasttextpart = -1;
375 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 400 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
376 { 401 {
377 toString += (*it); 402 toString += (*it);
378 } 403 }
379 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 404 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
380 { 405 {