author | alwin <alwin> | 2005-03-07 23:12:51 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-07 23:12:51 (UTC) |
commit | 2ba21de3fce9ca9fe9a70474a1927f0106d1d7ce (patch) (side-by-side diff) | |
tree | d0ff8c035e34a83fbc935c8f3f6ab926ed432559 /noncore/net/mail/viewmail.cpp | |
parent | a1fab1e1abd009a6a64c7ea3957bdb5587f4be81 (diff) | |
download | opie-2ba21de3fce9ca9fe9a70474a1927f0106d1d7ce.zip opie-2ba21de3fce9ca9fe9a70474a1927f0106d1d7ce.tar.gz opie-2ba21de3fce9ca9fe9a70474a1927f0106d1d7ce.tar.bz2 |
beauty
hopefull some speedups
obsolete stuff removed
fixed a crasher
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 37 |
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 ) } void ViewMail::slotShowHtml( bool state ) { m_showHtml = state; - setText(); + setMainText(); } void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { if (!item ) return; if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { - setText(); + setMainText(); return; } QPopupMenu *menu = new QPopupMenu(); int ret=0; 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 } } break ; case 2: { + if (m_lastimagepart== (( AttachItem* )item )->Partnumber()) { + if (m_lastdlg) { + setUpdatesEnabled(false); + browser->hide(); + m_lastdlg->show(); + setUpdatesEnabled(true); + return; + } + } QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++); encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); if (content && content->Length()) { QFile output(tmpfile); output.open(IO_WriteOnly); output.writeBlock(content->Content(),content->Length()); @@ -273,24 +282,35 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int m_lastdlg->show(); } output.remove(); } else { QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment")); } + m_lastimagepart=(( AttachItem* )item )->Partnumber(); } break; case 1: if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { - setText(); + setMainText(); } else { if ( m_recMail->Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions - browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); + if (m_lastdlg) { + m_lastdlg->hide(); + browser->show(); + } + if (m_lasttextpart == ( ( AttachItem* )item )->Partnumber() ) return; + m_lasttextpart = ( ( AttachItem* )item )->Partnumber(); + QString s = m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );; + if (item->text(0).right(4)!="html") { + s = QString("<html><body>\n<font face=fixed>%1</font></body></html>").arg(QStyleSheet::convertFromPlainText(s)); + } + browser->setText(s); } } break; } delete menu; } @@ -308,13 +328,13 @@ void ViewMail::setMail(const RecMailP&mail ) m_mail2[0] = mail->To(); m_mail2[1] = mail->CC(); m_mail2[2] = mail->Bcc(); setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); - setText(); + setMainText(); } ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) : ViewMailBase(parent, name, fl), _inLoop(false) @@ -329,12 +349,14 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) ); attachments->setEnabled(m_gotBody); connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); m_lastdlg = 0; _icounter = 0; + m_lastimagepart = -1; + m_lasttextpart = -2; readConfig(); attachments->setSorting(-1); } void ViewMail::slotImageInline(bool how) @@ -345,12 +367,13 @@ void ViewMail::slotImageInline(bool how) if (m_lastdlg&&!how) { browser->show(); m_lastdlg->hide(); m_lastdlg->reparent(0,QPoint(0,0),false); delete m_lastdlg; m_lastdlg = 0; + m_lastimagepart = -1; } } void ViewMail::readConfig() { Config cfg( "mail" ); @@ -358,23 +381,25 @@ void ViewMail::readConfig() m_showHtml = cfg.readBoolEntry( "showHtml", false ); m_PicsInline = cfg.readBoolEntry( "showPicsInline", true ); showPicsInline->setOn(m_PicsInline); showHtml->setOn( m_showHtml ); } -void ViewMail::setText() +void ViewMail::setMainText() { QString toString; QString ccString; QString bccString; QString mailHtml; if (m_lastdlg) { m_lastdlg->hide(); } browser->show(); + if (m_lasttextpart == -1) return; + m_lasttextpart = -1; for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { toString += (*it); } for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { |