summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index f861c20..9f07f56 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -302,195 +302,197 @@ void IMAPfolderItem::refresh(QList<RecMail>&target)
302 if (folder->may_select()) { 302 if (folder->may_select()) {
303 imap->getWrapper()->listMessages( folder->getName(),target ); 303 imap->getWrapper()->listMessages( folder->getName(),target );
304 } else { 304 } else {
305 target.clear(); 305 target.clear();
306 } 306 }
307} 307}
308 308
309RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 309RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
310{ 310{
311 return imap->getWrapper()->fetchBody(aMail); 311 return imap->getWrapper()->fetchBody(aMail);
312} 312}
313 313
314QPopupMenu * IMAPfolderItem::getContextMenu() 314QPopupMenu * IMAPfolderItem::getContextMenu()
315{ 315{
316 QPopupMenu *m = new QPopupMenu(0); 316 QPopupMenu *m = new QPopupMenu(0);
317 if (m) { 317 if (m) {
318 if (folder->may_select()) { 318 if (folder->may_select()) {
319 m->insertItem(QObject::tr("Refresh header list",contextName),0); 319 m->insertItem(QObject::tr("Refresh header list",contextName),0);
320 m->insertItem(QObject::tr("Delete all mails",contextName),1); 320 m->insertItem(QObject::tr("Delete all mails",contextName),1);
321 } 321 }
322 if (folder->no_inferior()==false) { 322 if (folder->no_inferior()==false) {
323 m->insertItem(QObject::tr("Create new subfolder",contextName),2); 323 m->insertItem(QObject::tr("Create new subfolder",contextName),2);
324 } 324 }
325 if (folder->getDisplayName().lower()!="inbox") { 325 if (folder->getDisplayName().lower()!="inbox") {
326 m->insertItem(QObject::tr("Delete folder",contextName),3); 326 m->insertItem(QObject::tr("Delete folder",contextName),3);
327 } 327 }
328 } 328 }
329 return m; 329 return m;
330} 330}
331 331
332void IMAPfolderItem::createNewFolder() 332void IMAPfolderItem::createNewFolder()
333{ 333{
334 Newmdirdlg ndirdlg; 334 Newmdirdlg ndirdlg;
335 ndirdlg.showMaximized(); 335 ndirdlg.showMaximized();
336 if (ndirdlg.exec()) { 336 if (ndirdlg.exec()) {
337 QString ndir = ndirdlg.Newdir(); 337 QString ndir = ndirdlg.Newdir();
338 bool makesubs = ndirdlg.subpossible(); 338 bool makesubs = ndirdlg.subpossible();
339 QString delemiter = Delemiter(); 339 QString delemiter = Delemiter();
340 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { 340 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) {
341 imap->refreshFolders(true); 341 imap->refreshFolders(true);
342 } 342 }
343 } 343 }
344} 344}
345 345
346void IMAPfolderItem::deleteFolder() 346void IMAPfolderItem::deleteFolder()
347{ 347{
348 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 348 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
349 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 349 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
350 QObject::tr("Yes",contextName), 350 QObject::tr("Yes",contextName),
351 QObject::tr("No",contextName),QString::null,1,1); 351 QObject::tr("No",contextName),QString::null,1,1);
352 qDebug("Auswahl: %i",yesno); 352 qDebug("Auswahl: %i",yesno);
353 if (yesno == 0) { 353 if (yesno == 0) {
354 if (imap->getWrapper()->deleteMbox(folder)) { 354 if (imap->getWrapper()->deleteMbox(folder)) {
355 QListView*v=listView(); 355 QListView*v=listView();
356 IMAPviewItem * box = imap; 356 IMAPviewItem * box = imap;
357 /* be carefull - after that this object is destroyd so don't use 357 /* be carefull - after that this object is destroyd so don't use
358 * any member of it after that call!!*/ 358 * any member of it after that call!!*/
359 imap->refreshFolders(true); 359 imap->refreshFolders(true);
360 if (v) { 360 if (v) {
361 v->setSelected(box,true); 361 v->setSelected(box,true);
362 } 362 }
363 } 363 }
364 } 364 }
365} 365}
366 366
367void IMAPfolderItem::contextMenuSelected(int id) 367void IMAPfolderItem::contextMenuSelected(int id)
368{ 368{
369 qDebug("Selected id: %i",id); 369 qDebug("Selected id: %i",id);
370 AccountView * view = (AccountView*)listView(); 370 AccountView * view = (AccountView*)listView();
371 switch(id) { 371 switch(id) {
372 case 0: 372 case 0:
373 view->refreshCurrent(); 373 view->refreshCurrent();
374 break; 374 break;
375 case 1: 375 case 1:
376 deleteAllMail(imap->getWrapper(),folder); 376 deleteAllMail(imap->getWrapper(),folder);
377 break; 377 break;
378 case 2: 378 case 2:
379 createNewFolder(); 379 createNewFolder();
380 break; 380 break;
381 case 3: 381 case 3:
382 deleteFolder(); 382 deleteFolder();
383 break; 383 break;
384 default: 384 default:
385 break; 385 break;
386 } 386 }
387} 387}
388 388
389/** 389/**
390 * Generic stuff 390 * Generic stuff
391 */ 391 */
392 392
393const QString AccountViewItem::contextName="AccountViewItem"; 393const QString AccountViewItem::contextName="AccountViewItem";
394 394
395void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) 395void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
396{ 396{
397 if (!wrapper) return; 397 if (!wrapper) return;
398 QString fname="";
399 if (folder) fname = folder->getDisplayName();
398 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 400 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
399 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 401 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
400 arg((folder?folder->getDisplayName():"")), 402 arg(fname),
401 QObject::tr("Yes",contextName), 403 QObject::tr("Yes",contextName),
402 QObject::tr("No",contextName),QString::null,1,1); 404 QObject::tr("No",contextName),QString::null,1,1);
403 qDebug("Auswahl: %i",yesno); 405 qDebug("Auswahl: %i",yesno);
404 if (yesno == 0) { 406 if (yesno == 0) {
405 if (wrapper->deleteAllMail(folder)) { 407 if (wrapper->deleteAllMail(folder)) {
406 AccountView * view = (AccountView*)listView(); 408 AccountView * view = (AccountView*)listView();
407 if (view) view->refreshCurrent(); 409 if (view) view->refreshCurrent();
408 } 410 }
409 } 411 }
410} 412}
411 413
412AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 414AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
413 : QListView( parent, name, flags ) 415 : QListView( parent, name, flags )
414{ 416{
415 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), 417 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
416 SLOT( refresh( QListViewItem * ) ) ); 418 SLOT( refresh( QListViewItem * ) ) );
417 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 419 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
418 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); 420 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) );
419 421
420 setSorting(0); 422 setSorting(0);
421} 423}
422 424
423void AccountView::slotContextMenu(int id) 425void AccountView::slotContextMenu(int id)
424{ 426{
425 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 427 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
426 if (!view) return; 428 if (!view) return;
427 view->contextMenuSelected(id); 429 view->contextMenuSelected(id);
428} 430}
429 431
430void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 432void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
431{ 433{
432 if (button==1) {return;} 434 if (button==1) {return;}
433 if (!item) return; 435 if (!item) return;
434 AccountViewItem *view = static_cast<AccountViewItem *>(item); 436 AccountViewItem *view = static_cast<AccountViewItem *>(item);
435 QPopupMenu*m = view->getContextMenu(); 437 QPopupMenu*m = view->getContextMenu();
436 if (!m) return; 438 if (!m) return;
437 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 439 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
438 m->setFocus(); 440 m->setFocus();
439 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 441 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
440 delete m; 442 delete m;
441} 443}
442 444
443void AccountView::populate( QList<Account> list ) 445void AccountView::populate( QList<Account> list )
444{ 446{
445 clear(); 447 clear();
446 448
447 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 449 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
448 (void) new MBOXviewItem(localfolders,this); 450 (void) new MBOXviewItem(localfolders,this);
449 451
450 Account *it; 452 Account *it;
451 for ( it = list.first(); it; it = list.next() ) { 453 for ( it = list.first(); it; it = list.next() ) {
452 if ( it->getType().compare( "IMAP" ) == 0 ) { 454 if ( it->getType().compare( "IMAP" ) == 0 ) {
453 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 455 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
454 qDebug( "added IMAP " + imap->getAccountName() ); 456 qDebug( "added IMAP " + imap->getAccountName() );
455 (void) new IMAPviewItem( imap, this ); 457 (void) new IMAPviewItem( imap, this );
456 } else if ( it->getType().compare( "POP3" ) == 0 ) { 458 } else if ( it->getType().compare( "POP3" ) == 0 ) {
457 POP3account *pop3 = static_cast<POP3account *>(it); 459 POP3account *pop3 = static_cast<POP3account *>(it);
458 qDebug( "added POP3 " + pop3->getAccountName() ); 460 qDebug( "added POP3 " + pop3->getAccountName() );
459 (void) new POP3viewItem( pop3, this ); 461 (void) new POP3viewItem( pop3, this );
460 } 462 }
461 } 463 }
462} 464}
463 465
464void AccountView::refresh(QListViewItem *item) { 466void AccountView::refresh(QListViewItem *item) {
465 467
466 qDebug("AccountView refresh..."); 468 qDebug("AccountView refresh...");
467 if ( item ) { 469 if ( item ) {
468 m_currentItem = item; 470 m_currentItem = item;
469 QList<RecMail> headerlist; 471 QList<RecMail> headerlist;
470 headerlist.setAutoDelete(true); 472 headerlist.setAutoDelete(true);
471 AccountViewItem *view = static_cast<AccountViewItem *>(item); 473 AccountViewItem *view = static_cast<AccountViewItem *>(item);
472 view->refresh(headerlist); 474 view->refresh(headerlist);
473 emit refreshMailview(&headerlist); 475 emit refreshMailview(&headerlist);
474 } 476 }
475} 477}
476 478
477void AccountView::refreshCurrent() 479void AccountView::refreshCurrent()
478{ 480{
479 m_currentItem = currentItem(); 481 m_currentItem = currentItem();
480 if ( !m_currentItem ) return; 482 if ( !m_currentItem ) return;
481 QList<RecMail> headerlist; 483 QList<RecMail> headerlist;
482 headerlist.setAutoDelete(true); 484 headerlist.setAutoDelete(true);
483 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 485 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
484 view->refresh(headerlist); 486 view->refresh(headerlist);
485 emit refreshMailview(&headerlist); 487 emit refreshMailview(&headerlist);
486} 488}
487 489
488void AccountView::refreshAll() 490void AccountView::refreshAll()
489{ 491{
490 492
491} 493}
492 494
493RecBody AccountView::fetchBody(const RecMail&aMail) 495RecBody AccountView::fetchBody(const RecMail&aMail)
494{ 496{
495 QListViewItem*item = selectedItem (); 497 QListViewItem*item = selectedItem ();
496 if (!item) return RecBody(); 498 if (!item) return RecBody();