author | zautrix <zautrix> | 2004-12-13 12:35:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-13 12:35:00 (UTC) |
commit | 7ac6c21e832b7d16bd0888d0b66252b6e152005a (patch) (unidiff) | |
tree | c7610e0e25020f19af82ac6257c2debab2638316 /kmicromail/opiemail.cpp | |
parent | 17b25691f0332e648dd1d800e89ccf4e1da8955d (diff) | |
download | kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.zip kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.gz kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.bz2 |
many bugfixes
-rw-r--r-- | kmicromail/opiemail.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index ec192ea..915b3e8 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -238,158 +238,185 @@ void OpieMail::slotEditSettings() | |||
238 | #endif | 238 | #endif |
239 | settingsDialog.exec(); | 239 | settingsDialog.exec(); |
240 | 240 | ||
241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
242 | // KApplication::execDialog(settingsDialog); | 242 | // KApplication::execDialog(settingsDialog); |
243 | } | 243 | } |
244 | 244 | ||
245 | void OpieMail::slotEditAccounts() | 245 | void OpieMail::slotEditAccounts() |
246 | { | 246 | { |
247 | EditAccounts eaDialog( settings, this, 0, true ); | 247 | EditAccounts eaDialog( settings, this, 0, true ); |
248 | eaDialog.slotAdjustColumns(); | 248 | eaDialog.slotAdjustColumns(); |
249 | #ifndef DESKTOP_VERSION | 249 | #ifndef DESKTOP_VERSION |
250 | eaDialog.showMaximized(); | 250 | eaDialog.showMaximized(); |
251 | #endif | 251 | #endif |
252 | eaDialog.exec(); | 252 | eaDialog.exec(); |
253 | if ( settings ) delete settings; | 253 | if ( settings ) delete settings; |
254 | settings = new Settings(); | 254 | settings = new Settings(); |
255 | 255 | ||
256 | folderView->populate( settings->getAccounts() ); | 256 | folderView->populate( settings->getAccounts() ); |
257 | } | 257 | } |
258 | void OpieMail::replyMail() | 258 | void OpieMail::replyMail() |
259 | { | 259 | { |
260 | 260 | ||
261 | QListViewItem*item = mailView->currentItem(); | 261 | QListViewItem*item = mailView->currentItem(); |
262 | if (!item) return; | 262 | if (!item) return; |
263 | RecMailP mail = ((MailListViewItem*)item)->data(); | 263 | RecMailP mail = ((MailListViewItem*)item)->data(); |
264 | RecBodyP body = folderView->fetchBody(mail); | 264 | RecBodyP body = folderView->fetchBody(mail); |
265 | 265 | ||
266 | QString rtext; | 266 | QString rtext; |
267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
268 | .arg( mail->getFrom()) | 268 | .arg( mail->getFrom()) |
269 | .arg( mail->getDate()); | 269 | .arg( mail->getDate()); |
270 | 270 | ||
271 | QString text = body->Bodytext(); | 271 | QString text = body->Bodytext(); |
272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
273 | QStringList::Iterator it; | 273 | QStringList::Iterator it; |
274 | for (it = lines.begin(); it != lines.end(); it++) | 274 | for (it = lines.begin(); it != lines.end(); it++) |
275 | { | 275 | { |
276 | rtext += "> " + *it + "\n"; | 276 | rtext += "> " + *it + "\n"; |
277 | } | 277 | } |
278 | rtext += "\n"; | 278 | rtext += "\n"; |
279 | 279 | ||
280 | QString prefix; | 280 | QString prefix; |
281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
282 | else prefix = "Re: "; // no i18n on purpose | 282 | else prefix = "Re: "; // no i18n on purpose |
283 | 283 | ||
284 | Settings *settings = new Settings(); | 284 | Settings *settings = new Settings(); |
285 | ComposeMail composer( settings ,this, 0, true); | 285 | ComposeMail composer( settings ,this, 0, true); |
286 | if (mail->Replyto().isEmpty()) { | 286 | if (mail->Replyto().isEmpty()) { |
287 | composer.setTo( mail->getFrom()); | 287 | composer.setTo( mail->getFrom()); |
288 | } else { | 288 | } else { |
289 | composer.setTo( mail->Replyto()); | 289 | composer.setTo( mail->Replyto()); |
290 | } | 290 | } |
291 | composer.setSubject( prefix + mail->getSubject()); | 291 | composer.setSubject( prefix + mail->getSubject()); |
292 | composer.setMessage( rtext ); | 292 | composer.setMessage( rtext ); |
293 | composer.setInReplyTo( mail->Msgid()); | 293 | composer.setInReplyTo( mail->Msgid()); |
294 | composer.setCharset( body->getCharset() ); | 294 | composer.setCharset( body->getCharset() ); |
295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
296 | { | 296 | { |
297 | mail->Wrapper()->answeredMail(mail); | 297 | mail->Wrapper()->answeredMail(mail); |
298 | } | 298 | } |
299 | delete settings; | 299 | delete settings; |
300 | 300 | ||
301 | } | 301 | } |
302 | void OpieMail::closeViewMail(ViewMail * vm) | ||
303 | { | ||
304 | vm->hide(); | ||
305 | } | ||
306 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) | ||
307 | { | ||
308 | QListViewItem*item = mailView->currentItem(); | ||
309 | if (!item ) { | ||
310 | closeViewMail(vm); | ||
311 | return; | ||
312 | } | ||
313 | RecMailP mail = ((MailListViewItem*)item)->data(); | ||
314 | mail->Wrapper()->deleteMail( mail ); | ||
315 | item = item->itemBelow(); | ||
316 | if (!item ) { | ||
317 | closeViewMail(vm); | ||
318 | return; | ||
319 | } | ||
320 | mailView->setCurrentItem(item); | ||
321 | mail = ((MailListViewItem*)item)->data(); | ||
322 | RecBodyP body = folderView->fetchBody(mail); | ||
323 | vm->setBody( body ); | ||
324 | vm->setMail( mail ); | ||
325 | } | ||
302 | void OpieMail::displayNextMail(ViewMail * vm) | 326 | void OpieMail::displayNextMail(ViewMail * vm) |
303 | { | 327 | { |
304 | QListViewItem*item = mailView->currentItem(); | 328 | QListViewItem*item = mailView->currentItem(); |
305 | if (!item) return; | 329 | if (!item) return; |
330 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | ||
306 | item = item->itemBelow(); | 331 | item = item->itemBelow(); |
307 | if (!item) { | 332 | if (!item) { |
308 | vm->setCaption(i18n("End of List" )); | 333 | vm->setCaption(i18n("End of List" )); |
309 | return; | 334 | return; |
310 | } | 335 | } |
311 | mailView->setCurrentItem(item); | 336 | mailView->setCurrentItem(item); |
312 | RecMailP mail = ((MailListViewItem*)item)->data(); | 337 | RecMailP mail = ((MailListViewItem*)item)->data(); |
313 | RecBodyP body = folderView->fetchBody(mail); | 338 | RecBodyP body = folderView->fetchBody(mail); |
314 | vm->setBody( body ); | 339 | vm->setBody( body ); |
315 | vm->setMail( mail ); | 340 | vm->setMail( mail ); |
316 | } | 341 | } |
317 | void OpieMail::displayMail() | 342 | void OpieMail::displayMail() |
318 | { | 343 | { |
319 | QListViewItem*item = mailView->currentItem(); | 344 | QListViewItem*item = mailView->currentItem(); |
320 | if (!item) return; | 345 | if (!item) return; |
321 | RecMailP mail = ((MailListViewItem*)item)->data(); | 346 | RecMailP mail = ((MailListViewItem*)item)->data(); |
322 | RecBodyP body = folderView->fetchBody(mail); | 347 | RecBodyP body = folderView->fetchBody(mail); |
323 | ViewMail readMail( this,"", Qt::WType_Modal ); | 348 | ViewMail readMail( this,"", Qt::WType_Modal ); |
324 | readMail.setBody( body ); | 349 | readMail.setBody( body ); |
325 | readMail.setMail( mail ); | 350 | readMail.setMail( mail ); |
326 | #ifndef DESKTOP_VERSION | 351 | #ifndef DESKTOP_VERSION |
327 | readMail.showMaximized(); | 352 | readMail.showMaximized(); |
328 | #else | 353 | #else |
329 | readMail.resize( 640, 480); | 354 | readMail.resize( 640, 480); |
330 | #endif | 355 | #endif |
331 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); | 356 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); |
357 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); | ||
358 | |||
332 | readMail.exec(); | 359 | readMail.exec(); |
333 | 360 | ||
334 | if ( readMail.deleted ) | 361 | if ( readMail.deleted ) |
335 | { | 362 | { |
336 | folderView->refreshCurrent(); | 363 | folderView->refreshCurrent(); |
337 | } | 364 | } |
338 | else | 365 | else |
339 | { | 366 | { |
340 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 367 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
341 | } | 368 | } |
342 | } | 369 | } |
343 | void OpieMail::slotGetAllMail() | 370 | void OpieMail::slotGetAllMail() |
344 | { | 371 | { |
345 | QListViewItem * item = folderView->firstChild(); | 372 | QListViewItem * item = folderView->firstChild(); |
346 | while ( item ){ | 373 | while ( item ){ |
347 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 374 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
348 | item = item->nextSibling (); | 375 | item = item->nextSibling (); |
349 | } | 376 | } |
350 | } | 377 | } |
351 | void OpieMail::slotGetMail() | 378 | void OpieMail::slotGetMail() |
352 | { | 379 | { |
353 | QListViewItem * item = folderView->currentItem(); | 380 | QListViewItem * item = folderView->currentItem(); |
354 | if ( ! item ) return; | 381 | if ( ! item ) return; |
355 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 382 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
356 | } | 383 | } |
357 | void OpieMail::slotDeleteMail() | 384 | void OpieMail::slotDeleteMail() |
358 | { | 385 | { |
359 | if (!mailView->currentItem()) return; | 386 | if (!mailView->currentItem()) return; |
360 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 387 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
361 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 388 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
362 | { | 389 | { |
363 | mail->Wrapper()->deleteMail( mail ); | 390 | mail->Wrapper()->deleteMail( mail ); |
364 | folderView->refreshCurrent(); | 391 | folderView->refreshCurrent(); |
365 | } | 392 | } |
366 | } | 393 | } |
367 | void OpieMail::slotDeleteAllMail() | 394 | void OpieMail::slotDeleteAllMail() |
368 | { | 395 | { |
369 | 396 | ||
370 | QValueList<RecMailP> t; | 397 | QValueList<RecMailP> t; |
371 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 398 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
372 | { | 399 | { |
373 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 400 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
374 | while ( item ) { | 401 | while ( item ) { |
375 | if ( item->isSelected() ) { | 402 | if ( item->isSelected() ) { |
376 | t.append( item->data() ); | 403 | t.append( item->data() ); |
377 | } | 404 | } |
378 | item = (MailListViewItem*)item->nextSibling(); | 405 | item = (MailListViewItem*)item->nextSibling(); |
379 | } | 406 | } |
380 | } | 407 | } |
381 | else | 408 | else |
382 | return; | 409 | return; |
383 | if ( t.count() == 0 ) | 410 | if ( t.count() == 0 ) |
384 | return; | 411 | return; |
385 | RecMailP mail = t.first(); | 412 | RecMailP mail = t.first(); |
386 | mail->Wrapper()->deleteMailList(t); | 413 | mail->Wrapper()->deleteMailList(t); |
387 | folderView->refreshCurrent(); | 414 | folderView->refreshCurrent(); |
388 | 415 | ||
389 | 416 | ||
390 | } | 417 | } |
391 | void OpieMail::clearSelection() | 418 | void OpieMail::clearSelection() |
392 | { | 419 | { |
393 | mailView->clearSelection(); | 420 | mailView->clearSelection(); |
394 | 421 | ||
395 | } | 422 | } |