author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/net/mail/viewmail.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index f015228..8636957 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -192,197 +192,197 @@ void ViewMail::slotShowHtml( bool state ) | |||
192 | { | 192 | { |
193 | m_showHtml = state; | 193 | m_showHtml = state; |
194 | setText(); | 194 | setText(); |
195 | } | 195 | } |
196 | 196 | ||
197 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 197 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
198 | { | 198 | { |
199 | if (!item ) | 199 | if (!item ) |
200 | return; | 200 | return; |
201 | 201 | ||
202 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 202 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
203 | { | 203 | { |
204 | setText(); | 204 | setText(); |
205 | return; | 205 | return; |
206 | } | 206 | } |
207 | QPopupMenu *menu = new QPopupMenu(); | 207 | QPopupMenu *menu = new QPopupMenu(); |
208 | int ret=0; | 208 | int ret=0; |
209 | 209 | ||
210 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 210 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
211 | { | 211 | { |
212 | menu->insertItem( tr( "Show Text" ), 1 ); | 212 | menu->insertItem( tr( "Show Text" ), 1 ); |
213 | } | 213 | } |
214 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 214 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
215 | menu->insertSeparator(1); | 215 | menu->insertSeparator(1); |
216 | 216 | ||
217 | ret = menu->exec( point, 0 ); | 217 | ret = menu->exec( point, 0 ); |
218 | 218 | ||
219 | switch(ret) | 219 | switch(ret) |
220 | { | 220 | { |
221 | case 0: | 221 | case 0: |
222 | { | 222 | { |
223 | MimeTypes types; | 223 | MimeTypes types; |
224 | types.insert( "all", "*" ); | 224 | types.insert( "all", "*" ); |
225 | QString str = Opie::OFileDialog::getSaveFileName( 1, | 225 | QString str = Opie::OFileDialog::getSaveFileName( 1, |
226 | "/", item->text( 2 ) , types, 0 ); | 226 | "/", item->text( 2 ) , types, 0 ); |
227 | 227 | ||
228 | if( !str.isEmpty() ) | 228 | if( !str.isEmpty() ) |
229 | { | 229 | { |
230 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 230 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
231 | if (content) | 231 | if (content) |
232 | { | 232 | { |
233 | QFile output(str); | 233 | QFile output(str); |
234 | output.open(IO_WriteOnly); | 234 | output.open(IO_WriteOnly); |
235 | output.writeBlock(content->Content(),content->Length()); | 235 | output.writeBlock(content->Content(),content->Length()); |
236 | output.close(); | 236 | output.close(); |
237 | delete content; | 237 | delete content; |
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | break ; | 241 | break ; |
242 | 242 | ||
243 | case 1: | 243 | case 1: |
244 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 244 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
245 | { | 245 | { |
246 | setText(); | 246 | setText(); |
247 | } | 247 | } |
248 | else | 248 | else |
249 | { | 249 | { |
250 | if ( m_recMail.Wrapper() != 0l ) | 250 | if ( m_recMail.Wrapper() != 0l ) |
251 | { // make sure that there is a wrapper , even after delete or simular actions | 251 | { // make sure that there is a wrapper , even after delete or simular actions |
252 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 252 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | break; | 255 | break; |
256 | } | 256 | } |
257 | delete menu; | 257 | delete menu; |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void ViewMail::setMail( RecMail mail ) | 261 | void ViewMail::setMail( RecMail mail ) |
262 | { | 262 | { |
263 | 263 | ||
264 | m_recMail = mail; | 264 | m_recMail = mail; |
265 | 265 | ||
266 | m_mail[0] = mail.getFrom(); | 266 | m_mail[0] = mail.getFrom(); |
267 | m_mail[1] = mail.getSubject(); | 267 | m_mail[1] = mail.getSubject(); |
268 | m_mail[3] = mail.getDate(); | 268 | m_mail[3] = mail.getDate(); |
269 | m_mail[4] = mail.Msgid(); | 269 | m_mail[4] = mail.Msgid(); |
270 | 270 | ||
271 | m_mail2[0] = mail.To(); | 271 | m_mail2[0] = mail.To(); |
272 | m_mail2[1] = mail.CC(); | 272 | m_mail2[1] = mail.CC(); |
273 | m_mail2[2] = mail.Bcc(); | 273 | m_mail2[2] = mail.Bcc(); |
274 | 274 | ||
275 | setText(); | 275 | setText(); |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | 279 | ||
280 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 280 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
281 | : ViewMailBase(parent, name, fl), _inLoop(false) | 281 | : ViewMailBase(parent, name, fl), _inLoop(false) |
282 | { | 282 | { |
283 | m_gotBody = false; | 283 | m_gotBody = false; |
284 | deleted = false; | 284 | deleted = false; |
285 | 285 | ||
286 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 286 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
287 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 287 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
288 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); | 288 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
289 | connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); | 289 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
290 | 290 | ||
291 | attachments->setEnabled(m_gotBody); | 291 | attachments->setEnabled(m_gotBody); |
292 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); | 292 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
293 | 293 | ||
294 | readConfig(); | 294 | readConfig(); |
295 | attachments->setSorting(-1); | 295 | attachments->setSorting(-1); |
296 | } | 296 | } |
297 | 297 | ||
298 | void ViewMail::readConfig() | 298 | void ViewMail::readConfig() |
299 | { | 299 | { |
300 | Config cfg( "mail" ); | 300 | Config cfg( "mail" ); |
301 | cfg.setGroup( "Settings" ); | 301 | cfg.setGroup( "Settings" ); |
302 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 302 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
303 | showHtml->setOn( m_showHtml ); | 303 | showHtml->setOn( m_showHtml ); |
304 | } | 304 | } |
305 | 305 | ||
306 | void ViewMail::setText() | 306 | void ViewMail::setText() |
307 | { | 307 | { |
308 | 308 | ||
309 | QString toString; | 309 | QString toString; |
310 | QString ccString; | 310 | QString ccString; |
311 | QString bccString; | 311 | QString bccString; |
312 | 312 | ||
313 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 313 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
314 | { | 314 | { |
315 | toString += (*it); | 315 | toString += (*it); |
316 | } | 316 | } |
317 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 317 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
318 | { | 318 | { |
319 | ccString += (*it); | 319 | ccString += (*it); |
320 | } | 320 | } |
321 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 321 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
322 | { | 322 | { |
323 | bccString += (*it); | 323 | bccString += (*it); |
324 | } | 324 | } |
325 | 325 | ||
326 | setCaption( caption().arg( m_mail[0] ) ); | 326 | setCaption( caption().arg( m_mail[0] ) ); |
327 | 327 | ||
328 | m_mailHtml = "<html><body>" | 328 | m_mailHtml = "<html><body>" |
329 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 329 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
330 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 330 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
331 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 331 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
332 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 332 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
333 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 333 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
334 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 334 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
335 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 335 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
336 | "</td></tr></table><font face=fixed>"; | 336 | "</td></tr></table><font face=fixed>"; |
337 | 337 | ||
338 | if ( !m_showHtml ) | 338 | if ( !m_showHtml ) |
339 | { | 339 | { |
340 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 340 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
341 | } | 341 | } |
342 | else | 342 | else |
343 | { | 343 | { |
344 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 344 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
345 | } | 345 | } |
346 | // remove later in favor of a real handling | 346 | // remove later in favor of a real handling |
347 | m_gotBody = true; | 347 | m_gotBody = true; |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | ViewMail::~ViewMail() | 351 | ViewMail::~ViewMail() |
352 | { | 352 | { |
353 | m_recMail.Wrapper()->cleanMimeCache(); | 353 | m_recMail.Wrapper()->cleanMimeCache(); |
354 | hide(); | 354 | hide(); |
355 | } | 355 | } |
356 | 356 | ||
357 | void ViewMail::hide() | 357 | void ViewMail::hide() |
358 | { | 358 | { |
359 | QWidget::hide(); | 359 | QWidget::hide(); |
360 | 360 | ||
361 | if (_inLoop) | 361 | if (_inLoop) |
362 | { | 362 | { |
363 | _inLoop = false; | 363 | _inLoop = false; |
364 | qApp->exit_loop(); | 364 | qApp->exit_loop(); |
365 | 365 | ||
366 | } | 366 | } |
367 | 367 | ||
368 | } | 368 | } |
369 | 369 | ||
370 | void ViewMail::exec() | 370 | void ViewMail::exec() |
371 | { | 371 | { |
372 | show(); | 372 | show(); |
373 | 373 | ||
374 | if (!_inLoop) | 374 | if (!_inLoop) |
375 | { | 375 | { |
376 | _inLoop = true; | 376 | _inLoop = true; |
377 | qApp->enter_loop(); | 377 | qApp->enter_loop(); |
378 | } | 378 | } |
379 | 379 | ||
380 | } | 380 | } |
381 | 381 | ||
382 | QString ViewMail::deHtml(const QString &string) | 382 | QString ViewMail::deHtml(const QString &string) |
383 | { | 383 | { |
384 | QString string_ = string; | 384 | QString string_ = string; |
385 | string_.replace(QRegExp("&"), "&"); | 385 | string_.replace(QRegExp("&"), "&"); |
386 | string_.replace(QRegExp("<"), "<"); | 386 | string_.replace(QRegExp("<"), "<"); |
387 | string_.replace(QRegExp(">"), ">"); | 387 | string_.replace(QRegExp(">"), ">"); |
388 | string_.replace(QRegExp("\\n"), "<br>"); | 388 | string_.replace(QRegExp("\\n"), "<br>"); |