Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 91 |
1 files changed, 56 insertions, 35 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index d86454c..e11fe1f 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,20 +1,22 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qapplication.h> | 7 | #include <qapplication.h> |
8 | 8 | ||
9 | #include <qpe/config.h> | ||
10 | |||
9 | #include <opie/ofiledialog.h> | 11 | #include <opie/ofiledialog.h> |
10 | 12 | ||
11 | #include "settings.h" | 13 | #include "settings.h" |
12 | #include "composemail.h" | 14 | #include "composemail.h" |
13 | #include "viewmail.h" | 15 | #include "viewmail.h" |
14 | #include "abstractmail.h" | 16 | #include "abstractmail.h" |
15 | #include "accountview.h" | 17 | #include "accountview.h" |
16 | #include "mailtypes.h" | 18 | #include "mailtypes.h" |
17 | 19 | ||
18 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 20 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
19 | const QString&fsize,int num) | 21 | const QString&fsize,int num) |
20 | : QListViewItem(parent,after),_partNum(num) | 22 | : QListViewItem(parent,after),_partNum(num) |
@@ -100,24 +102,30 @@ for (unsigned int i = 0; i < body.Parts().count();++i) { | |||
100 | q=""; | 102 | q=""; |
101 | break; | 103 | break; |
102 | } | 104 | } |
103 | QTextOStream o(&fsize); | 105 | QTextOStream o(&fsize); |
104 | if (w>0) o.precision(2); else o.precision(0); | 106 | if (w>0) o.precision(2); else o.precision(0); |
105 | o.setf(QTextStream::fixed); | 107 | o.setf(QTextStream::fixed); |
106 | o << s << " " << q << "Byte"; | 108 | o << s << " " << q << "Byte"; |
107 | desc = body.Parts()[i].Description(); | 109 | desc = body.Parts()[i].Description(); |
108 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i); | 110 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i); |
109 | } | 111 | } |
110 | } | 112 | } |
111 | 113 | ||
114 | |||
115 | void ViewMail::slotShowHtml( bool state ) { | ||
116 | m_showHtml = state; | ||
117 | setText(); | ||
118 | } | ||
119 | |||
112 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { | 120 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { |
113 | if (!item ) | 121 | if (!item ) |
114 | return; | 122 | return; |
115 | 123 | ||
116 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 124 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
117 | setText(); | 125 | setText(); |
118 | return; | 126 | return; |
119 | } | 127 | } |
120 | QPopupMenu *menu = new QPopupMenu(); | 128 | QPopupMenu *menu = new QPopupMenu(); |
121 | int ret=0; | 129 | int ret=0; |
122 | 130 | ||
123 | if ( item->text( 0 ).left( 5 ) == "text/" ) { | 131 | if ( item->text( 0 ).left( 5 ) == "text/" ) { |
@@ -155,88 +163,101 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int | |||
155 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions | 163 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions |
156 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 164 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
157 | } | 165 | } |
158 | } | 166 | } |
159 | break; | 167 | break; |
160 | } | 168 | } |
161 | delete menu; | 169 | delete menu; |
162 | } | 170 | } |
163 | 171 | ||
164 | 172 | ||
165 | void ViewMail::setMail( RecMail mail ) { | 173 | void ViewMail::setMail( RecMail mail ) { |
166 | 174 | ||
167 | m_recMail = mail; | 175 | m_recMail = mail; |
168 | 176 | ||
169 | m_mail[0] = mail.getFrom(); | 177 | m_mail[0] = mail.getFrom(); |
170 | m_mail[1] = mail.getSubject(); | 178 | m_mail[1] = mail.getSubject(); |
171 | m_mail[3] = mail.getDate(); | 179 | m_mail[3] = mail.getDate(); |
172 | m_mail[4] = mail.Msgid(); | 180 | m_mail[4] = mail.Msgid(); |
173 | 181 | ||
174 | m_mail2[0] = mail.To(); | 182 | m_mail2[0] = mail.To(); |
175 | m_mail2[1] = mail.CC(); | 183 | m_mail2[1] = mail.CC(); |
176 | m_mail2[2] = mail.Bcc(); | 184 | m_mail2[2] = mail.Bcc(); |
177 | 185 | ||
178 | setText(); | 186 | setText(); |
179 | } | 187 | } |
180 | 188 | ||
181 | 189 | ||
182 | 190 | ||
183 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 191 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
184 | : ViewMailBase(parent, name, fl), _inLoop(false) | 192 | : ViewMailBase(parent, name, fl), _inLoop(false) |
185 | { | 193 | { |
186 | m_gotBody = false; | 194 | m_gotBody = false; |
187 | deleted = false; | 195 | deleted = false; |
188 | 196 | ||
189 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 197 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
190 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 198 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
191 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); | 199 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); |
200 | connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); | ||
192 | 201 | ||
193 | attachments->setEnabled(m_gotBody); | 202 | attachments->setEnabled(m_gotBody); |
194 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); | 203 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); |
195 | 204 | ||
205 | readConfig(); | ||
196 | 206 | ||
197 | } | 207 | } |
198 | 208 | ||
209 | void ViewMail::readConfig() { | ||
210 | Config cfg( "mail" ); | ||
211 | cfg.setGroup( "Settings" ); | ||
212 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | ||
213 | showHtml->setOn( m_showHtml ); | ||
214 | } | ||
215 | |||
199 | void ViewMail::setText() | 216 | void ViewMail::setText() |
200 | { | 217 | { |
201 | 218 | ||
202 | QString toString; | 219 | QString toString; |
203 | QString ccString; | 220 | QString ccString; |
204 | QString bccString; | 221 | QString bccString; |
205 | 222 | ||
206 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | 223 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { |
207 | toString += (*it); | 224 | toString += (*it); |
208 | } | 225 | } |
209 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | 226 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { |
210 | ccString += (*it); | 227 | ccString += (*it); |
211 | } | 228 | } |
212 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | 229 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { |
213 | bccString += (*it); | 230 | bccString += (*it); |
214 | } | 231 | } |
215 | 232 | ||
216 | setCaption( caption().arg( m_mail[0] ) ); | 233 | setCaption( caption().arg( m_mail[0] ) ); |
217 | 234 | ||
218 | m_mailHtml = "<html><body>" | 235 | m_mailHtml = "<html><body>" |
219 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 236 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
220 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 237 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
221 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 238 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
222 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 239 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
223 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 240 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
224 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 241 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
225 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 242 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
226 | "</td></tr></table><font face=fixed>"; | 243 | "</td></tr></table><font face=fixed>"; |
227 | 244 | ||
245 | if ( !m_showHtml ) { | ||
228 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 246 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
229 | // remove later in favor of a real handling | 247 | } else { |
230 | m_gotBody = true; | 248 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
249 | } | ||
250 | // remove later in favor of a real handling | ||
251 | m_gotBody = true; | ||
231 | } | 252 | } |
232 | 253 | ||
233 | 254 | ||
234 | ViewMail::~ViewMail() | 255 | ViewMail::~ViewMail() |
235 | { | 256 | { |
236 | hide(); | 257 | hide(); |
237 | } | 258 | } |
238 | 259 | ||
239 | void ViewMail::hide() | 260 | void ViewMail::hide() |
240 | { | 261 | { |
241 | QWidget::hide(); | 262 | QWidget::hide(); |
242 | 263 | ||