-rw-r--r-- | noncore/net/mail/viewmail.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 84f8a90..aa8f37a 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -289,183 +289,187 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | |||
289 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 289 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
290 | 290 | ||
291 | readConfig(); | 291 | readConfig(); |
292 | attachments->setSorting(-1); | 292 | attachments->setSorting(-1); |
293 | } | 293 | } |
294 | 294 | ||
295 | void ViewMail::readConfig() | 295 | void ViewMail::readConfig() |
296 | { | 296 | { |
297 | Config cfg( "mail" ); | 297 | Config cfg( "mail" ); |
298 | cfg.setGroup( "Settings" ); | 298 | cfg.setGroup( "Settings" ); |
299 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 299 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
300 | showHtml->setOn( m_showHtml ); | 300 | showHtml->setOn( m_showHtml ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void ViewMail::setText() | 303 | void ViewMail::setText() |
304 | { | 304 | { |
305 | 305 | ||
306 | QString toString; | 306 | QString toString; |
307 | QString ccString; | 307 | QString ccString; |
308 | QString bccString; | 308 | QString bccString; |
309 | 309 | ||
310 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 310 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
311 | { | 311 | { |
312 | toString += (*it); | 312 | toString += (*it); |
313 | } | 313 | } |
314 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 314 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
315 | { | 315 | { |
316 | ccString += (*it); | 316 | ccString += (*it); |
317 | } | 317 | } |
318 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 318 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
319 | { | 319 | { |
320 | bccString += (*it); | 320 | bccString += (*it); |
321 | } | 321 | } |
322 | 322 | ||
323 | setCaption( caption().arg( m_mail[0] ) ); | 323 | setCaption( caption().arg( m_mail[0] ) ); |
324 | 324 | ||
325 | m_mailHtml = "<html><body>" | 325 | m_mailHtml = "<html><body>" |
326 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 326 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
327 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 327 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
328 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 328 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
329 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 329 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
330 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 330 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
331 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 331 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
332 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 332 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
333 | "</td></tr></table><font face=fixed>"; | 333 | "</td></tr></table><font face=fixed>"; |
334 | 334 | ||
335 | if ( !m_showHtml ) | 335 | if ( !m_showHtml ) |
336 | { | 336 | { |
337 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 337 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
338 | } | 338 | } |
339 | else | 339 | else |
340 | { | 340 | { |
341 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 341 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
342 | } | 342 | } |
343 | // remove later in favor of a real handling | 343 | // remove later in favor of a real handling |
344 | m_gotBody = true; | 344 | m_gotBody = true; |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | ViewMail::~ViewMail() | 348 | ViewMail::~ViewMail() |
349 | { | 349 | { |
350 | m_recMail.Wrapper()->cleanMimeCache(); | 350 | m_recMail.Wrapper()->cleanMimeCache(); |
351 | hide(); | 351 | hide(); |
352 | } | 352 | } |
353 | 353 | ||
354 | void ViewMail::hide() | 354 | void ViewMail::hide() |
355 | { | 355 | { |
356 | QWidget::hide(); | 356 | QWidget::hide(); |
357 | 357 | ||
358 | if (_inLoop) | 358 | if (_inLoop) |
359 | { | 359 | { |
360 | _inLoop = false; | 360 | _inLoop = false; |
361 | qApp->exit_loop(); | 361 | qApp->exit_loop(); |
362 | 362 | ||
363 | } | 363 | } |
364 | 364 | ||
365 | } | 365 | } |
366 | 366 | ||
367 | void ViewMail::exec() | 367 | void ViewMail::exec() |
368 | { | 368 | { |
369 | show(); | 369 | show(); |
370 | 370 | ||
371 | if (!_inLoop) | 371 | if (!_inLoop) |
372 | { | 372 | { |
373 | _inLoop = true; | 373 | _inLoop = true; |
374 | qApp->enter_loop(); | 374 | qApp->enter_loop(); |
375 | } | 375 | } |
376 | 376 | ||
377 | } | 377 | } |
378 | 378 | ||
379 | QString ViewMail::deHtml(const QString &string) | 379 | QString ViewMail::deHtml(const QString &string) |
380 | { | 380 | { |
381 | QString string_ = string; | 381 | QString string_ = string; |
382 | string_.replace(QRegExp("&"), "&"); | 382 | string_.replace(QRegExp("&"), "&"); |
383 | string_.replace(QRegExp("<"), "<"); | 383 | string_.replace(QRegExp("<"), "<"); |
384 | string_.replace(QRegExp(">"), ">"); | 384 | string_.replace(QRegExp(">"), ">"); |
385 | string_.replace(QRegExp("\\n"), "<br>"); | 385 | string_.replace(QRegExp("\\n"), "<br>"); |
386 | return string_; | 386 | return string_; |
387 | } | 387 | } |
388 | 388 | ||
389 | void ViewMail::slotReply() | 389 | void ViewMail::slotReply() |
390 | { | 390 | { |
391 | if (!m_gotBody) | 391 | if (!m_gotBody) |
392 | { | 392 | { |
393 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 393 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | 396 | ||
397 | QString rtext; | 397 | QString rtext; |
398 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 398 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
399 | .arg( m_mail[0] ) | 399 | .arg( m_mail[0] ) |
400 | .arg( m_mail[3] ); | 400 | .arg( m_mail[3] ); |
401 | 401 | ||
402 | QString text = m_mail[2]; | 402 | QString text = m_mail[2]; |
403 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 403 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
404 | QStringList::Iterator it; | 404 | QStringList::Iterator it; |
405 | for (it = lines.begin(); it != lines.end(); it++) | 405 | for (it = lines.begin(); it != lines.end(); it++) |
406 | { | 406 | { |
407 | rtext += "> " + *it + "\n"; | 407 | rtext += "> " + *it + "\n"; |
408 | } | 408 | } |
409 | rtext += "\n"; | 409 | rtext += "\n"; |
410 | 410 | ||
411 | QString prefix; | 411 | QString prefix; |
412 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 412 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
413 | else prefix = "Re: "; // no i18n on purpose | 413 | else prefix = "Re: "; // no i18n on purpose |
414 | 414 | ||
415 | Settings *settings = new Settings(); | 415 | Settings *settings = new Settings(); |
416 | ComposeMail composer( settings ,this, 0, true); | 416 | ComposeMail composer( settings ,this, 0, true); |
417 | composer.setTo( m_mail[0] ); | 417 | if (m_recMail.Replyto().isEmpty()) { |
418 | composer.setTo( m_recMail.getFrom()); | ||
419 | } else { | ||
420 | composer.setTo( m_recMail.Replyto()); | ||
421 | } | ||
418 | composer.setSubject( prefix + m_mail[1] ); | 422 | composer.setSubject( prefix + m_mail[1] ); |
419 | composer.setMessage( rtext ); | 423 | composer.setMessage( rtext ); |
420 | composer.setInReplyTo(m_recMail.Msgid()); | 424 | composer.setInReplyTo(m_recMail.Msgid()); |
421 | 425 | ||
422 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) | 426 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) |
423 | { | 427 | { |
424 | m_recMail.Wrapper()->answeredMail(m_recMail); | 428 | m_recMail.Wrapper()->answeredMail(m_recMail); |
425 | } | 429 | } |
426 | } | 430 | } |
427 | 431 | ||
428 | void ViewMail::slotForward() | 432 | void ViewMail::slotForward() |
429 | { | 433 | { |
430 | if (!m_gotBody) | 434 | if (!m_gotBody) |
431 | { | 435 | { |
432 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 436 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
433 | return; | 437 | return; |
434 | } | 438 | } |
435 | 439 | ||
436 | QString ftext; | 440 | QString ftext; |
437 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 441 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
438 | .arg( m_mail[0] ); | 442 | .arg( m_mail[0] ); |
439 | if (!m_mail[3].isNull()) | 443 | if (!m_mail[3].isNull()) |
440 | ftext += QString("Date: %1\n") | 444 | ftext += QString("Date: %1\n") |
441 | .arg( m_mail[3] ); | 445 | .arg( m_mail[3] ); |
442 | if (!m_mail[0].isNull()) | 446 | if (!m_mail[0].isNull()) |
443 | ftext += QString("From: %1\n") | 447 | ftext += QString("From: %1\n") |
444 | .arg( m_mail[0] ); | 448 | .arg( m_mail[0] ); |
445 | if (!m_mail[1].isNull()) | 449 | if (!m_mail[1].isNull()) |
446 | ftext += QString("Subject: %1\n") | 450 | ftext += QString("Subject: %1\n") |
447 | .arg( m_mail[1] ); | 451 | .arg( m_mail[1] ); |
448 | 452 | ||
449 | ftext += QString("\n%1\n") | 453 | ftext += QString("\n%1\n") |
450 | .arg( m_mail[2]); | 454 | .arg( m_mail[2]); |
451 | 455 | ||
452 | ftext += QString("----- End forwarded message -----\n"); | 456 | ftext += QString("----- End forwarded message -----\n"); |
453 | 457 | ||
454 | Settings *settings = new Settings(); | 458 | Settings *settings = new Settings(); |
455 | ComposeMail composer( settings ,this, 0, true); | 459 | ComposeMail composer( settings ,this, 0, true); |
456 | composer.setSubject( "Fwd: " + m_mail[1] ); | 460 | composer.setSubject( "Fwd: " + m_mail[1] ); |
457 | composer.setMessage( ftext ); | 461 | composer.setMessage( ftext ); |
458 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) | 462 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) |
459 | { | 463 | { |
460 | } | 464 | } |
461 | } | 465 | } |
462 | 466 | ||
463 | void ViewMail::slotDeleteMail( ) | 467 | void ViewMail::slotDeleteMail( ) |
464 | { | 468 | { |
465 | 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 ) | 469 | 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 | { | 470 | { |
467 | m_recMail.Wrapper()->deleteMail( m_recMail ); | 471 | m_recMail.Wrapper()->deleteMail( m_recMail ); |
468 | hide(); | 472 | hide(); |
469 | deleted = true; | 473 | deleted = true; |
470 | } | 474 | } |
471 | } | 475 | } |