-rw-r--r-- | noncore/net/mail/viewmail.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index d5f9b7f..d2f1584 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -11,24 +11,25 @@ | |||
11 | #include <opie2/oimagescrollview.h> | 11 | #include <opie2/oimagescrollview.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | 14 | ||
15 | /* QT */ | 15 | /* QT */ |
16 | #include <qtextbrowser.h> | 16 | #include <qtextbrowser.h> |
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | #include <qtextstream.h> | 18 | #include <qtextstream.h> |
19 | #include <qaction.h> | 19 | #include <qaction.h> |
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qstylesheet.h> | ||
23 | 24 | ||
24 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
25 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
26 | 27 | ||
27 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 28 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
28 | const QString&fsize,int num,const QValueList<int>&path) | 29 | const QString&fsize,int num,const QValueList<int>&path) |
29 | : QListViewItem(parent,after),_partNum(num) | 30 | : QListViewItem(parent,after),_partNum(num) |
30 | { | 31 | { |
31 | _path=path; | 32 | _path=path; |
32 | setText(0, mime); | 33 | setText(0, mime); |
33 | setText(1, desc); | 34 | setText(1, desc); |
34 | setText(2, file); | 35 | setText(2, file); |
@@ -287,24 +288,25 @@ void ViewMail::setMail(const RecMailP&mail ) | |||
287 | 288 | ||
288 | m_recMail = mail; | 289 | m_recMail = mail; |
289 | 290 | ||
290 | m_mail[0] = mail->getFrom(); | 291 | m_mail[0] = mail->getFrom(); |
291 | m_mail[1] = mail->getSubject(); | 292 | m_mail[1] = mail->getSubject(); |
292 | m_mail[3] = mail->getStringDate(); | 293 | m_mail[3] = mail->getStringDate(); |
293 | m_mail[4] = mail->Msgid(); | 294 | m_mail[4] = mail->Msgid(); |
294 | 295 | ||
295 | m_mail2[0] = mail->To(); | 296 | m_mail2[0] = mail->To(); |
296 | m_mail2[1] = mail->CC(); | 297 | m_mail2[1] = mail->CC(); |
297 | m_mail2[2] = mail->Bcc(); | 298 | m_mail2[2] = mail->Bcc(); |
298 | 299 | ||
300 | setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); | ||
299 | setText(); | 301 | setText(); |
300 | } | 302 | } |
301 | 303 | ||
302 | 304 | ||
303 | 305 | ||
304 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 306 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
305 | : ViewMailBase(parent, name, fl), _inLoop(false) | 307 | : ViewMailBase(parent, name, fl), _inLoop(false) |
306 | { | 308 | { |
307 | m_gotBody = false; | 309 | m_gotBody = false; |
308 | deleted = false; | 310 | deleted = false; |
309 | 311 | ||
310 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 312 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
@@ -320,61 +322,55 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | |||
320 | } | 322 | } |
321 | 323 | ||
322 | void ViewMail::readConfig() | 324 | void ViewMail::readConfig() |
323 | { | 325 | { |
324 | Config cfg( "mail" ); | 326 | Config cfg( "mail" ); |
325 | cfg.setGroup( "Settings" ); | 327 | cfg.setGroup( "Settings" ); |
326 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 328 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
327 | showHtml->setOn( m_showHtml ); | 329 | showHtml->setOn( m_showHtml ); |
328 | } | 330 | } |
329 | 331 | ||
330 | void ViewMail::setText() | 332 | void ViewMail::setText() |
331 | { | 333 | { |
332 | |||
333 | QString toString; | 334 | QString toString; |
334 | QString ccString; | 335 | QString ccString; |
335 | QString bccString; | 336 | QString bccString; |
337 | QString mailHtml; | ||
336 | 338 | ||
337 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 339 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
338 | { | 340 | { |
339 | toString += (*it); | 341 | toString += (*it); |
340 | } | 342 | } |
341 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 343 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
342 | { | 344 | { |
343 | ccString += (*it); | 345 | ccString += (*it); |
344 | } | 346 | } |
345 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 347 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
346 | { | 348 | { |
347 | bccString += (*it); | 349 | bccString += (*it); |
348 | } | 350 | } |
349 | 351 | browser->setTextFormat(Qt::RichText); | |
350 | setCaption( caption().arg( m_mail[0] ) ); | 352 | mailHtml = "<html><body>" |
351 | |||
352 | m_mailHtml = "<html><body>" | ||
353 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 353 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
354 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 354 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
355 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 355 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
356 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 356 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
357 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 357 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
358 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 358 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
359 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 359 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
360 | "</td></tr></table><font face=fixed>"; | 360 | "</td></tr></table>"; |
361 | 361 | if ( !m_showHtml ) { | |
362 | if ( !m_showHtml ) | 362 | browser->setText( mailHtml+"<font face=fixed>" + QStyleSheet::convertFromPlainText(m_mail[2]) + "</font></body></html>" ); |
363 | { | 363 | } else { |
364 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 364 | browser->setText(mailHtml+m_mail[2].simplifyWhiteSpace()+"</html>"); |
365 | } | ||
366 | else | ||
367 | { | ||
368 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | ||
369 | } | 365 | } |
370 | // remove later in favor of a real handling | 366 | // remove later in favor of a real handling |
371 | m_gotBody = true; | 367 | m_gotBody = true; |
372 | } | 368 | } |
373 | 369 | ||
374 | 370 | ||
375 | ViewMail::~ViewMail() | 371 | ViewMail::~ViewMail() |
376 | { | 372 | { |
377 | m_recMail->Wrapper()->cleanMimeCache(); | 373 | m_recMail->Wrapper()->cleanMimeCache(); |
378 | hide(); | 374 | hide(); |
379 | } | 375 | } |
380 | 376 | ||
@@ -394,27 +390,27 @@ void ViewMail::hide() | |||
394 | void ViewMail::exec() | 390 | void ViewMail::exec() |
395 | { | 391 | { |
396 | show(); | 392 | show(); |
397 | 393 | ||
398 | if (!_inLoop) | 394 | if (!_inLoop) |
399 | { | 395 | { |
400 | _inLoop = true; | 396 | _inLoop = true; |
401 | qApp->enter_loop(); | 397 | qApp->enter_loop(); |
402 | } | 398 | } |
403 | 399 | ||
404 | } | 400 | } |
405 | 401 | ||
406 | QString ViewMail::deHtml(const QString &string) | 402 | QString ViewMail::deHtml(const QString &aString) |
407 | { | 403 | { |
408 | QString string_ = string; | 404 | QString string_ = aString; |
409 | string_.replace(QRegExp("&"), "&"); | 405 | string_.replace(QRegExp("&"), "&"); |
410 | string_.replace(QRegExp("<"), "<"); | 406 | string_.replace(QRegExp("<"), "<"); |
411 | string_.replace(QRegExp(">"), ">"); | 407 | string_.replace(QRegExp(">"), ">"); |
412 | string_.replace(QRegExp("\\n"), "<br>"); | 408 | string_.replace(QRegExp("\\n"), "<br>"); |
413 | return string_; | 409 | return string_; |
414 | } | 410 | } |
415 | 411 | ||
416 | void ViewMail::slotReply() | 412 | void ViewMail::slotReply() |
417 | { | 413 | { |
418 | if (!m_gotBody) | 414 | if (!m_gotBody) |
419 | { | 415 | { |
420 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 416 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |