-rw-r--r-- | noncore/net/mail/accountitem.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index 4869df8..10db2c6 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -406,747 +406,747 @@ void NNTPfolderItem::contextMenuSelected(int which) | |||
406 | break; | 406 | break; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | /** | 410 | /** |
411 | * IMAP Account stuff | 411 | * IMAP Account stuff |
412 | */ | 412 | */ |
413 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 413 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
414 | : AccountViewItem( parent ) | 414 | : AccountViewItem( parent ) |
415 | { | 415 | { |
416 | account = a; | 416 | account = a; |
417 | wrapper = AbstractMail::getWrapper( account ); | 417 | wrapper = AbstractMail::getWrapper( account ); |
418 | SETPIX(PIXMAP_IMAPFOLDER); | 418 | SETPIX(PIXMAP_IMAPFOLDER); |
419 | setText( 0, account->getAccountName() ); | 419 | setText( 0, account->getAccountName() ); |
420 | setOpen( true ); | 420 | setOpen( true ); |
421 | } | 421 | } |
422 | 422 | ||
423 | IMAPviewItem::~IMAPviewItem() | 423 | IMAPviewItem::~IMAPviewItem() |
424 | { | 424 | { |
425 | delete wrapper; | 425 | delete wrapper; |
426 | } | 426 | } |
427 | 427 | ||
428 | AbstractMail *IMAPviewItem::getWrapper() | 428 | AbstractMail *IMAPviewItem::getWrapper() |
429 | { | 429 | { |
430 | return wrapper; | 430 | return wrapper; |
431 | } | 431 | } |
432 | 432 | ||
433 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 433 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
434 | { | 434 | { |
435 | refreshFolders(false); | 435 | refreshFolders(false); |
436 | } | 436 | } |
437 | 437 | ||
438 | const QStringList&IMAPviewItem::subFolders() | 438 | const QStringList&IMAPviewItem::subFolders() |
439 | { | 439 | { |
440 | return currentFolders; | 440 | return currentFolders; |
441 | } | 441 | } |
442 | 442 | ||
443 | void IMAPviewItem::refreshFolders(bool force) | 443 | void IMAPviewItem::refreshFolders(bool force) |
444 | { | 444 | { |
445 | if (childCount()>0 && force==false) return; | 445 | if (childCount()>0 && force==false) return; |
446 | if (account->getOffline()) return; | 446 | if (account->getOffline()) return; |
447 | 447 | ||
448 | removeChilds(); | 448 | removeChilds(); |
449 | currentFolders.clear(); | 449 | currentFolders.clear(); |
450 | QValueList<FolderP> * folders = wrapper->listFolders(); | 450 | QValueList<FolderP> * folders = wrapper->listFolders(); |
451 | 451 | ||
452 | QValueList<FolderP>::Iterator it; | 452 | QValueList<FolderP>::Iterator it; |
453 | QListViewItem*item = 0; | 453 | QListViewItem*item = 0; |
454 | QListViewItem*titem = 0; | 454 | QListViewItem*titem = 0; |
455 | QString fname,del,search; | 455 | QString fname,del,search; |
456 | int pos; | 456 | int pos; |
457 | 457 | ||
458 | for ( it = folders->begin(); it!=folders->end(); ++it) | 458 | for ( it = folders->begin(); it!=folders->end(); ++it) |
459 | { | 459 | { |
460 | if ((*it)->getDisplayName().lower()=="inbox") | 460 | if ((*it)->getDisplayName().lower()=="inbox") |
461 | { | 461 | { |
462 | item = new IMAPfolderItem( (*it), this , item ); | 462 | item = new IMAPfolderItem( (*it), this , item ); |
463 | folders->remove(it); | 463 | folders->remove(it); |
464 | odebug << "inbox found" << oendl; | 464 | odebug << "inbox found" << oendl; |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | for ( it = folders->begin(); it!=folders->end(); ++it) | 468 | for ( it = folders->begin(); it!=folders->end(); ++it) |
469 | { | 469 | { |
470 | fname = (*it)->getDisplayName(); | 470 | fname = (*it)->getDisplayName(); |
471 | currentFolders.append((*it)->getName()); | 471 | currentFolders.append((*it)->getName()); |
472 | pos = fname.findRev((*it)->Separator()); | 472 | pos = fname.findRev((*it)->Separator()); |
473 | if (pos != -1) | 473 | if (pos != -1) |
474 | { | 474 | { |
475 | fname = fname.left(pos); | 475 | fname = fname.left(pos); |
476 | } | 476 | } |
477 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 477 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
478 | if (pitem) | 478 | if (pitem) |
479 | { | 479 | { |
480 | titem = item; | 480 | titem = item; |
481 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 481 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
482 | /* setup the short name */ | 482 | /* setup the short name */ |
483 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 483 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
484 | item = titem; | 484 | item = titem; |
485 | } | 485 | } |
486 | else | 486 | else |
487 | { | 487 | { |
488 | item = new IMAPfolderItem( (*it), this , item ); | 488 | item = new IMAPfolderItem( (*it), this , item ); |
489 | } | 489 | } |
490 | } | 490 | } |
491 | delete folders; | 491 | delete folders; |
492 | } | 492 | } |
493 | 493 | ||
494 | QPopupMenu * IMAPviewItem::getContextMenu() | 494 | QPopupMenu * IMAPviewItem::getContextMenu() |
495 | { | 495 | { |
496 | QPopupMenu *m = new QPopupMenu(0); | 496 | QPopupMenu *m = new QPopupMenu(0); |
497 | if (m) | 497 | if (m) |
498 | { | 498 | { |
499 | if (!account->getOffline()) | 499 | if (!account->getOffline()) |
500 | { | 500 | { |
501 | m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); | 501 | m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); |
502 | m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); | 502 | m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); |
503 | m->insertSeparator(); | 503 | m->insertSeparator(); |
504 | m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); | 504 | m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); |
505 | m->insertItem(QObject::tr("Create new folder",contextName),SERVER_MENU_CREATE_FOLDER); | 505 | m->insertItem(QObject::tr("Create new folder",contextName),SERVER_MENU_CREATE_FOLDER); |
506 | } | 506 | } |
507 | else | 507 | else |
508 | { | 508 | { |
509 | m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); | 509 | m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | return m; | 512 | return m; |
513 | } | 513 | } |
514 | 514 | ||
515 | void IMAPviewItem::createNewFolder() | 515 | void IMAPviewItem::createNewFolder() |
516 | { | 516 | { |
517 | Newmdirdlg ndirdlg; | 517 | Newmdirdlg ndirdlg; |
518 | if ( QPEApplication::execDialog( &ndirdlg )) | 518 | if ( QPEApplication::execDialog( &ndirdlg )) |
519 | { | 519 | { |
520 | QString ndir = ndirdlg.Newdir(); | 520 | QString ndir = ndirdlg.Newdir(); |
521 | bool makesubs = ndirdlg.subpossible(); | 521 | bool makesubs = ndirdlg.subpossible(); |
522 | QString delemiter = "/"; | 522 | QString delemiter = "/"; |
523 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 523 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
524 | if (item) | 524 | if (item) |
525 | { | 525 | { |
526 | delemiter = item->Delemiter(); | 526 | delemiter = item->Delemiter(); |
527 | } | 527 | } |
528 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 528 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
529 | { | 529 | { |
530 | refreshFolders(true); | 530 | refreshFolders(true); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | void IMAPviewItem::contextMenuSelected(int id) | 535 | void IMAPviewItem::contextMenuSelected(int id) |
536 | { | 536 | { |
537 | odebug << "Id selected: " << id << "" << oendl; | 537 | odebug << "Id selected: " << id << "" << oendl; |
538 | switch (id) | 538 | switch (id) |
539 | { | 539 | { |
540 | case SERVER_MENU_REFRESH_FOLDER: | 540 | case SERVER_MENU_REFRESH_FOLDER: |
541 | refreshFolders(true); | 541 | refreshFolders(true); |
542 | break; | 542 | break; |
543 | case SERVER_MENU_CREATE_FOLDER: | 543 | case SERVER_MENU_CREATE_FOLDER: |
544 | createNewFolder(); | 544 | createNewFolder(); |
545 | break; | 545 | break; |
546 | case SERVER_MENU_DISCONNECT: | 546 | case SERVER_MENU_DISCONNECT: |
547 | removeChilds(); | 547 | removeChilds(); |
548 | wrapper->logout(); | 548 | wrapper->logout(); |
549 | break; | 549 | break; |
550 | case SERVER_MENU_OFFLINE: | 550 | case SERVER_MENU_OFFLINE: |
551 | if (account->getOffline()==false) | 551 | if (account->getOffline()==false) |
552 | { | 552 | { |
553 | removeChilds(); | 553 | removeChilds(); |
554 | wrapper->logout(); | 554 | wrapper->logout(); |
555 | } | 555 | } |
556 | account->setOffline(!account->getOffline()); | 556 | account->setOffline(!account->getOffline()); |
557 | account->save(); | 557 | account->save(); |
558 | SETPIX(PIXMAP_IMAPFOLDER); | 558 | SETPIX(PIXMAP_IMAPFOLDER); |
559 | refreshFolders(false); | 559 | refreshFolders(false); |
560 | break; | 560 | break; |
561 | default: | 561 | default: |
562 | break; | 562 | break; |
563 | } | 563 | } |
564 | } | 564 | } |
565 | 565 | ||
566 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 566 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
567 | { | 567 | { |
568 | return new RecBody(); | 568 | return new RecBody(); |
569 | } | 569 | } |
570 | 570 | ||
571 | bool IMAPviewItem::offline() | 571 | bool IMAPviewItem::offline() |
572 | { | 572 | { |
573 | return account->getOffline(); | 573 | return account->getOffline(); |
574 | } | 574 | } |
575 | 575 | ||
576 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 576 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
577 | : AccountViewItem( folderInit, parent , after ) | 577 | : AccountViewItem( folderInit, parent , after ) |
578 | { | 578 | { |
579 | imap = parent; | 579 | imap = parent; |
580 | if (folder->getDisplayName().lower()!="inbox") | 580 | if (folder->getDisplayName().lower()!="inbox") |
581 | { | 581 | { |
582 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 582 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
583 | } | 583 | } |
584 | else | 584 | else |
585 | { | 585 | { |
586 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 586 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
587 | } | 587 | } |
588 | setText( 0, folder->getDisplayName() ); | 588 | setText( 0, folder->getDisplayName() ); |
589 | } | 589 | } |
590 | 590 | ||
591 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 591 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
592 | : AccountViewItem(folderInit, parent,after ) | 592 | : AccountViewItem(folderInit, parent,after ) |
593 | { | 593 | { |
594 | imap = master; | 594 | imap = master; |
595 | if (folder->getDisplayName().lower()!="inbox") | 595 | if (folder->getDisplayName().lower()!="inbox") |
596 | { | 596 | { |
597 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 597 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
598 | } | 598 | } |
599 | else | 599 | else |
600 | { | 600 | { |
601 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 601 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
602 | } | 602 | } |
603 | setText( 0, folder->getDisplayName() ); | 603 | setText( 0, folder->getDisplayName() ); |
604 | } | 604 | } |
605 | 605 | ||
606 | IMAPfolderItem::~IMAPfolderItem() | 606 | IMAPfolderItem::~IMAPfolderItem() |
607 | {} | 607 | {} |
608 | 608 | ||
609 | const QString& IMAPfolderItem::Delemiter()const | 609 | const QString& IMAPfolderItem::Delemiter()const |
610 | { | 610 | { |
611 | return folder->Separator(); | 611 | return folder->Separator(); |
612 | } | 612 | } |
613 | 613 | ||
614 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 614 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
615 | { | 615 | { |
616 | if (folder->may_select()) | 616 | if (folder->may_select()) |
617 | { | 617 | { |
618 | imap->getWrapper()->listMessages( folder->getName(),target ); | 618 | imap->getWrapper()->listMessages( folder->getName(),target ); |
619 | } | 619 | } |
620 | else | 620 | else |
621 | { | 621 | { |
622 | target.clear(); | 622 | target.clear(); |
623 | } | 623 | } |
624 | } | 624 | } |
625 | 625 | ||
626 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 626 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
627 | { | 627 | { |
628 | return imap->getWrapper()->fetchBody(aMail); | 628 | return imap->getWrapper()->fetchBody(aMail); |
629 | } | 629 | } |
630 | 630 | ||
631 | QPopupMenu * IMAPfolderItem::getContextMenu() | 631 | QPopupMenu * IMAPfolderItem::getContextMenu() |
632 | { | 632 | { |
633 | QPopupMenu *m = new QPopupMenu(0); | 633 | QPopupMenu *m = new QPopupMenu(0); |
634 | if (m) | 634 | if (m) |
635 | { | 635 | { |
636 | if (folder->may_select()) | 636 | if (folder->may_select()) |
637 | { | 637 | { |
638 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); | 638 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
639 | m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS); | 639 | m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
640 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); | 640 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
641 | } | 641 | } |
642 | if (folder->no_inferior()==false) | 642 | if (folder->no_inferior()==false) |
643 | { | 643 | { |
644 | m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); | 644 | m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
645 | } | 645 | } |
646 | if (folder->getDisplayName().lower()!="inbox") | 646 | if (folder->getDisplayName().lower()!="inbox") |
647 | { | 647 | { |
648 | m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); | 648 | m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | return m; | 651 | return m; |
652 | } | 652 | } |
653 | 653 | ||
654 | void IMAPfolderItem::createNewFolder() | 654 | void IMAPfolderItem::createNewFolder() |
655 | { | 655 | { |
656 | Newmdirdlg ndirdlg; | 656 | Newmdirdlg ndirdlg; |
657 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 657 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
658 | { | 658 | { |
659 | QString ndir = ndirdlg.Newdir(); | 659 | QString ndir = ndirdlg.Newdir(); |
660 | bool makesubs = ndirdlg.subpossible(); | 660 | bool makesubs = ndirdlg.subpossible(); |
661 | QString delemiter = Delemiter(); | 661 | QString delemiter = Delemiter(); |
662 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 662 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
663 | { | 663 | { |
664 | imap->refreshFolders(true); | 664 | imap->refreshFolders(true); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | } | 667 | } |
668 | 668 | ||
669 | void IMAPfolderItem::deleteFolder() | 669 | void IMAPfolderItem::deleteFolder() |
670 | { | 670 | { |
671 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 671 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
672 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 672 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
673 | QObject::tr("Yes",contextName), | 673 | QObject::tr("Yes",contextName), |
674 | QObject::tr("No",contextName),QString::null,1,1); | 674 | QObject::tr("No",contextName),QString::null,1,1); |
675 | odebug << "Auswahl: " << yesno << "" << oendl; | 675 | odebug << "Auswahl: " << yesno << "" << oendl; |
676 | if (yesno == 0) | 676 | if (yesno == 0) |
677 | { | 677 | { |
678 | if (imap->getWrapper()->deleteMbox(folder)) | 678 | if (imap->getWrapper()->deleteMbox(folder)) |
679 | { | 679 | { |
680 | QListView*v=listView(); | 680 | QListView*v=listView(); |
681 | IMAPviewItem * box = imap; | 681 | IMAPviewItem * box = imap; |
682 | /* be carefull - after that this object is destroyd so don't use | 682 | /* be carefull - after that this object is destroyd so don't use |
683 | * any member of it after that call!!*/ | 683 | * any member of it after that call!!*/ |
684 | imap->refreshFolders(true); | 684 | imap->refreshFolders(true); |
685 | if (v) | 685 | if (v) |
686 | { | 686 | { |
687 | v->setSelected(box,true); | 687 | v->setSelected(box,true); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | } | 690 | } |
691 | } | 691 | } |
692 | 692 | ||
693 | void IMAPfolderItem::downloadMails() | 693 | void IMAPfolderItem::downloadMails() |
694 | { | 694 | { |
695 | AccountView*bl = imap->accountView(); | 695 | AccountView*bl = imap->accountView(); |
696 | if (!bl) return; | 696 | if (!bl) return; |
697 | bl->downloadMails(folder,imap->getWrapper()); | 697 | bl->downloadMails(folder,imap->getWrapper()); |
698 | } | 698 | } |
699 | 699 | ||
700 | void IMAPfolderItem::contextMenuSelected(int id) | 700 | void IMAPfolderItem::contextMenuSelected(int id) |
701 | { | 701 | { |
702 | odebug << "Selected id: " << id << "" << oendl; | 702 | odebug << "Selected id: " << id << "" << oendl; |
703 | AccountView * view = (AccountView*)listView(); | 703 | AccountView * view = (AccountView*)listView(); |
704 | switch(id) | 704 | switch(id) |
705 | { | 705 | { |
706 | case FOLDER_MENU_REFRESH_HEADER: | 706 | case FOLDER_MENU_REFRESH_HEADER: |
707 | view->refreshCurrent(); | 707 | view->refreshCurrent(); |
708 | break; | 708 | break; |
709 | case FOLDER_MENU_DELETE_ALL_MAILS: | 709 | case FOLDER_MENU_DELETE_ALL_MAILS: |
710 | deleteAllMail(imap->getWrapper(),folder); | 710 | deleteAllMail(imap->getWrapper(),folder); |
711 | break; | 711 | break; |
712 | case FOLDER_MENU_NEW_SUBFOLDER: | 712 | case FOLDER_MENU_NEW_SUBFOLDER: |
713 | if (folder->no_inferior()==false) { | 713 | if (folder->no_inferior()==false) { |
714 | createNewFolder(); | 714 | createNewFolder(); |
715 | } | 715 | } |
716 | break; | 716 | break; |
717 | case FOLDER_MENU_DELETE_FOLDER: | 717 | case FOLDER_MENU_DELETE_FOLDER: |
718 | if (folder->getDisplayName().lower()!="inbox") { | 718 | if (folder->getDisplayName().lower()!="inbox") { |
719 | deleteFolder(); | 719 | deleteFolder(); |
720 | } | 720 | } |
721 | break; | 721 | break; |
722 | case FOLDER_MENU_MOVE_MAILS: | 722 | case FOLDER_MENU_MOVE_MAILS: |
723 | downloadMails(); | 723 | downloadMails(); |
724 | break; | 724 | break; |
725 | default: | 725 | default: |
726 | break; | 726 | break; |
727 | } | 727 | } |
728 | } | 728 | } |
729 | 729 | ||
730 | /** | 730 | /** |
731 | * MH Account stuff | 731 | * MH Account stuff |
732 | */ | 732 | */ |
733 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 733 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
734 | POP3 and MBOX */ | 734 | POP3 and MBOX */ |
735 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 735 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
736 | : AccountViewItem( parent ) | 736 | : AccountViewItem( parent ) |
737 | { | 737 | { |
738 | m_Path = aPath; | 738 | m_Path = aPath; |
739 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 739 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
740 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 740 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
741 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 741 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
742 | setText( 0, " Local Folders" ); | 742 | setText( 0, " Local Folders" ); |
743 | setOpen( true ); | 743 | setOpen( true ); |
744 | folder = 0; | 744 | folder = 0; |
745 | } | 745 | } |
746 | 746 | ||
747 | MHviewItem::~MHviewItem() | 747 | MHviewItem::~MHviewItem() |
748 | { | 748 | { |
749 | delete wrapper; | 749 | delete wrapper; |
750 | } | 750 | } |
751 | 751 | ||
752 | AbstractMail *MHviewItem::getWrapper() | 752 | AbstractMail *MHviewItem::getWrapper() |
753 | { | 753 | { |
754 | return wrapper; | 754 | return wrapper; |
755 | } | 755 | } |
756 | 756 | ||
757 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 757 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
758 | { | 758 | { |
759 | refresh(false); | 759 | refresh(false); |
760 | getWrapper()->listMessages( "",target ); | 760 | getWrapper()->listMessages( "",target ); |
761 | } | 761 | } |
762 | 762 | ||
763 | void MHviewItem::refresh(bool force) | 763 | void MHviewItem::refresh(bool force) |
764 | { | 764 | { |
765 | if (childCount()>0 && force==false) return; | 765 | if (childCount()>0 && force==false) return; |
766 | odebug << "Refresh mh folders" << oendl; | 766 | odebug << "Refresh mh folders" << oendl; |
767 | removeChilds(); | 767 | removeChilds(); |
768 | currentFolders.clear(); | 768 | currentFolders.clear(); |
769 | QValueList<FolderP> *folders = wrapper->listFolders(); | 769 | QValueList<FolderP> *folders = wrapper->listFolders(); |
770 | QValueList<FolderP>::ConstIterator it; | 770 | QValueList<FolderP>::ConstIterator it; |
771 | MHfolderItem*item = 0; | 771 | MHfolderItem*item = 0; |
772 | MHfolderItem*pmaster = 0; | 772 | MHfolderItem*pmaster = 0; |
773 | QString fname = ""; | 773 | QString fname = ""; |
774 | int pos; | 774 | int pos; |
775 | for ( it = folders->begin(); it!=folders->end(); ++it) | 775 | for ( it = folders->begin(); it!=folders->end(); ++it) |
776 | { | 776 | { |
777 | fname = (*it)->getDisplayName(); | 777 | fname = (*it)->getDisplayName(); |
778 | /* this folder itself */ | 778 | /* this folder itself */ |
779 | if (fname=="/") | 779 | if (fname=="/") |
780 | { | 780 | { |
781 | currentFolders.append(fname); | 781 | currentFolders.append(fname); |
782 | folder = (*it); | 782 | folder = (*it); |
783 | continue; | 783 | continue; |
784 | } | 784 | } |
785 | currentFolders.append(fname); | 785 | currentFolders.append(fname); |
786 | pos = fname.findRev("/"); | 786 | pos = fname.findRev("/"); |
787 | if (pos > 0) | 787 | if (pos > 0) |
788 | { | 788 | { |
789 | fname = fname.left(pos); | 789 | fname = fname.left(pos); |
790 | pmaster = (MHfolderItem*)findSubItem(fname); | 790 | pmaster = (MHfolderItem*)findSubItem(fname); |
791 | } | 791 | } |
792 | else | 792 | else |
793 | { | 793 | { |
794 | pmaster = 0; | 794 | pmaster = 0; |
795 | } | 795 | } |
796 | if (pmaster) | 796 | if (pmaster) |
797 | { | 797 | { |
798 | item = new MHfolderItem( (*it), pmaster, item, this ); | 798 | item = new MHfolderItem( (*it), pmaster, item, this ); |
799 | } | 799 | } |
800 | else | 800 | else |
801 | { | 801 | { |
802 | item = new MHfolderItem( (*it), this , item ); | 802 | item = new MHfolderItem( (*it), this , item ); |
803 | } | 803 | } |
804 | item->setSelectable((*it)->may_select()); | 804 | item->setSelectable((*it)->may_select()); |
805 | } | 805 | } |
806 | delete folders; | 806 | delete folders; |
807 | } | 807 | } |
808 | 808 | ||
809 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) | 809 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
810 | { | 810 | { |
811 | odebug << "MH fetchBody" << oendl; | 811 | odebug << "MH fetchBody" << oendl; |
812 | return wrapper->fetchBody( mail ); | 812 | return wrapper->fetchBody( mail ); |
813 | } | 813 | } |
814 | 814 | ||
815 | QPopupMenu * MHviewItem::getContextMenu() | 815 | QPopupMenu * MHviewItem::getContextMenu() |
816 | { | 816 | { |
817 | QPopupMenu *m = new QPopupMenu(0); | 817 | QPopupMenu *m = new QPopupMenu(0); |
818 | if (m) | 818 | if (m) |
819 | { | 819 | { |
820 | m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); | 820 | m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); |
821 | m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER); | 821 | m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
822 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); | 822 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
823 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); | 823 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
824 | } | 824 | } |
825 | return m; | 825 | return m; |
826 | } | 826 | } |
827 | 827 | ||
828 | void MHviewItem::createFolder() | 828 | void MHviewItem::createFolder() |
829 | { | 829 | { |
830 | Newmdirdlg ndirdlg(0,0,true); | 830 | Newmdirdlg ndirdlg(0,0,true); |
831 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 831 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
832 | { | 832 | { |
833 | QString ndir = ndirdlg.Newdir(); | 833 | QString ndir = ndirdlg.Newdir(); |
834 | if (wrapper->createMbox(ndir)) | 834 | if (wrapper->createMbox(ndir)) |
835 | { | 835 | { |
836 | refresh(true); | 836 | refresh(true); |
837 | } | 837 | } |
838 | } | 838 | } |
839 | } | 839 | } |
840 | 840 | ||
841 | void MHviewItem::downloadMails() | 841 | void MHviewItem::downloadMails() |
842 | { | 842 | { |
843 | AccountView*bl = accountView(); | 843 | AccountView*bl = accountView(); |
844 | if (!bl) return; | 844 | if (!bl) return; |
845 | bl->downloadMails(folder,getWrapper()); | 845 | bl->downloadMails(folder,getWrapper()); |
846 | } | 846 | } |
847 | 847 | ||
848 | QStringList MHviewItem::subFolders() | 848 | QStringList MHviewItem::subFolders() |
849 | { | 849 | { |
850 | return currentFolders; | 850 | return currentFolders; |
851 | } | 851 | } |
852 | 852 | ||
853 | void MHviewItem::contextMenuSelected(int which) | 853 | void MHviewItem::contextMenuSelected(int which) |
854 | { | 854 | { |
855 | AccountView*view = 0; | 855 | AccountView*view = 0; |
856 | 856 | ||
857 | switch (which) | 857 | switch (which) |
858 | { | 858 | { |
859 | case SERVER_MENU_REFRESH_FOLDER: | 859 | case SERVER_MENU_REFRESH_FOLDER: |
860 | refresh(true); | 860 | refresh(true); |
861 | break; | 861 | break; |
862 | case FOLDER_MENU_NEW_SUBFOLDER: | 862 | case FOLDER_MENU_NEW_SUBFOLDER: |
863 | createFolder(); | 863 | createFolder(); |
864 | break; | 864 | break; |
865 | case FOLDER_MENU_DELETE_ALL_MAILS: | 865 | case FOLDER_MENU_DELETE_ALL_MAILS: |
866 | deleteAllMail(getWrapper(),folder); | 866 | deleteAllMail(getWrapper(),folder); |
867 | break; | 867 | break; |
868 | case FOLDER_MENU_MOVE_MAILS: | 868 | case FOLDER_MENU_MOVE_MAILS: |
869 | downloadMails(); | 869 | downloadMails(); |
870 | break; | 870 | break; |
871 | case FOLDER_MENU_REFRESH_HEADER: | 871 | case FOLDER_MENU_REFRESH_HEADER: |
872 | view = (AccountView*)listView(); | 872 | view = (AccountView*)listView(); |
873 | if (view) view->refreshCurrent(); | 873 | if (view) view->refreshCurrent(); |
874 | break; | 874 | break; |
875 | default: | 875 | default: |
876 | break; | 876 | break; |
877 | } | 877 | } |
878 | } | 878 | } |
879 | 879 | ||
880 | MHfolderItem::~MHfolderItem() | 880 | MHfolderItem::~MHfolderItem() |
881 | {} | 881 | {} |
882 | 882 | ||
883 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 883 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
884 | : AccountViewItem(folderInit, parent,after ) | 884 | : AccountViewItem(folderInit, parent,after ) |
885 | { | 885 | { |
886 | mbox = parent; | 886 | mbox = parent; |
887 | initName(); | 887 | initName(); |
888 | } | 888 | } |
889 | 889 | ||
890 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 890 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
891 | : AccountViewItem(folderInit, parent,after ) | 891 | : AccountViewItem(folderInit, parent,after ) |
892 | { | 892 | { |
893 | folder = folderInit; | 893 | folder = folderInit; |
894 | mbox = master; | 894 | mbox = master; |
895 | initName(); | 895 | initName(); |
896 | } | 896 | } |
897 | 897 | ||
898 | void MHfolderItem::initName() | 898 | void MHfolderItem::initName() |
899 | { | 899 | { |
900 | QString bName = folder->getDisplayName(); | 900 | QString bName = folder->getDisplayName(); |
901 | if (bName.startsWith("/")&&bName.length()>1) | 901 | if (bName.startsWith("/")&&bName.length()>1) |
902 | { | 902 | { |
903 | bName.replace(0,1,""); | 903 | bName.replace(0,1,""); |
904 | } | 904 | } |
905 | int pos = bName.findRev("/"); | 905 | int pos = bName.findRev("/"); |
906 | if (pos > 0) | 906 | if (pos > 0) |
907 | { | 907 | { |
908 | bName.replace(0,pos+1,""); | 908 | bName.replace(0,pos+1,""); |
909 | } | 909 | } |
910 | if (bName.lower() == "outgoing") | 910 | if (bName.lower() == "outgoing") |
911 | { | 911 | { |
912 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 912 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
913 | } | 913 | } |
914 | else if (bName.lower() == "inbox") | 914 | else if (bName.lower() == "inbox") |
915 | { | 915 | { |
916 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 916 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
917 | } else if (bName.lower() == "drafts") { | 917 | } else if (bName.lower() == "drafts") { |
918 | setPixmap(0, Resource::loadPixmap("inline/edit")); | 918 | setPixmap(0, Resource::loadPixmap("edit")); |
919 | } else { | 919 | } else { |
920 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 920 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
921 | } | 921 | } |
922 | setText( 0, bName ); | 922 | setText( 0, bName ); |
923 | } | 923 | } |
924 | 924 | ||
925 | const FolderP&MHfolderItem::getFolder()const | 925 | const FolderP&MHfolderItem::getFolder()const |
926 | { | 926 | { |
927 | return folder; | 927 | return folder; |
928 | } | 928 | } |
929 | 929 | ||
930 | void MHfolderItem::refresh(QValueList<RecMailP>&target) | 930 | void MHfolderItem::refresh(QValueList<RecMailP>&target) |
931 | { | 931 | { |
932 | if (folder->may_select()) | 932 | if (folder->may_select()) |
933 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 933 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
934 | } | 934 | } |
935 | 935 | ||
936 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) | 936 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) |
937 | { | 937 | { |
938 | return mbox->getWrapper()->fetchBody(aMail); | 938 | return mbox->getWrapper()->fetchBody(aMail); |
939 | } | 939 | } |
940 | 940 | ||
941 | void MHfolderItem::deleteFolder() | 941 | void MHfolderItem::deleteFolder() |
942 | { | 942 | { |
943 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 943 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
944 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 944 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
945 | QObject::tr("Yes",contextName), | 945 | QObject::tr("Yes",contextName), |
946 | QObject::tr("No",contextName),QString::null,1,1); | 946 | QObject::tr("No",contextName),QString::null,1,1); |
947 | odebug << "Auswahl: " << yesno << "" << oendl; | 947 | odebug << "Auswahl: " << yesno << "" << oendl; |
948 | if (yesno == 0) | 948 | if (yesno == 0) |
949 | { | 949 | { |
950 | if (mbox->getWrapper()->deleteMbox(folder)) | 950 | if (mbox->getWrapper()->deleteMbox(folder)) |
951 | { | 951 | { |
952 | QListView*v=listView(); | 952 | QListView*v=listView(); |
953 | MHviewItem * box = mbox; | 953 | MHviewItem * box = mbox; |
954 | /* be carefull - after that this object is destroyd so don't use | 954 | /* be carefull - after that this object is destroyd so don't use |
955 | * any member of it after that call!!*/ | 955 | * any member of it after that call!!*/ |
956 | mbox->refresh(true); | 956 | mbox->refresh(true); |
957 | if (v) | 957 | if (v) |
958 | { | 958 | { |
959 | v->setSelected(box,true); | 959 | v->setSelected(box,true); |
960 | } | 960 | } |
961 | } | 961 | } |
962 | } | 962 | } |
963 | } | 963 | } |
964 | 964 | ||
965 | QPopupMenu * MHfolderItem::getContextMenu() | 965 | QPopupMenu * MHfolderItem::getContextMenu() |
966 | { | 966 | { |
967 | QPopupMenu *m = new QPopupMenu(0); | 967 | QPopupMenu *m = new QPopupMenu(0); |
968 | if (m) | 968 | if (m) |
969 | { | 969 | { |
970 | m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); | 970 | m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
971 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); | 971 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
972 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); | 972 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
973 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); | 973 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
974 | m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); | 974 | m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); |
975 | } | 975 | } |
976 | return m; | 976 | return m; |
977 | } | 977 | } |
978 | 978 | ||
979 | void MHfolderItem::downloadMails() | 979 | void MHfolderItem::downloadMails() |
980 | { | 980 | { |
981 | AccountView*bl = mbox->accountView(); | 981 | AccountView*bl = mbox->accountView(); |
982 | if (!bl) return; | 982 | if (!bl) return; |
983 | bl->downloadMails(folder,mbox->getWrapper()); | 983 | bl->downloadMails(folder,mbox->getWrapper()); |
984 | } | 984 | } |
985 | 985 | ||
986 | void MHfolderItem::createFolder() | 986 | void MHfolderItem::createFolder() |
987 | { | 987 | { |
988 | Newmdirdlg ndirdlg(0,0,true); | 988 | Newmdirdlg ndirdlg(0,0,true); |
989 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 989 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
990 | { | 990 | { |
991 | QString ndir = ndirdlg.Newdir(); | 991 | QString ndir = ndirdlg.Newdir(); |
992 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 992 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
993 | { | 993 | { |
994 | QListView*v=listView(); | 994 | QListView*v=listView(); |
995 | MHviewItem * box = mbox; | 995 | MHviewItem * box = mbox; |
996 | /* be carefull - after that this object is destroyd so don't use | 996 | /* be carefull - after that this object is destroyd so don't use |
997 | * any member of it after that call!!*/ | 997 | * any member of it after that call!!*/ |
998 | mbox->refresh(true); | 998 | mbox->refresh(true); |
999 | if (v) | 999 | if (v) |
1000 | { | 1000 | { |
1001 | v->setSelected(box,true); | 1001 | v->setSelected(box,true); |
1002 | } | 1002 | } |
1003 | } | 1003 | } |
1004 | } | 1004 | } |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | void MHfolderItem::contextMenuSelected(int which) | 1007 | void MHfolderItem::contextMenuSelected(int which) |
1008 | { | 1008 | { |
1009 | AccountView*view = 0; | 1009 | AccountView*view = 0; |
1010 | switch(which) | 1010 | switch(which) |
1011 | { | 1011 | { |
1012 | case FOLDER_MENU_DELETE_ALL_MAILS: | 1012 | case FOLDER_MENU_DELETE_ALL_MAILS: |
1013 | deleteAllMail(mbox->getWrapper(),folder); | 1013 | deleteAllMail(mbox->getWrapper(),folder); |
1014 | break; | 1014 | break; |
1015 | case FOLDER_MENU_DELETE_FOLDER: | 1015 | case FOLDER_MENU_DELETE_FOLDER: |
1016 | deleteFolder(); | 1016 | deleteFolder(); |
1017 | break; | 1017 | break; |
1018 | case FOLDER_MENU_MOVE_MAILS: | 1018 | case FOLDER_MENU_MOVE_MAILS: |
1019 | downloadMails(); | 1019 | downloadMails(); |
1020 | break; | 1020 | break; |
1021 | case FOLDER_MENU_NEW_SUBFOLDER: | 1021 | case FOLDER_MENU_NEW_SUBFOLDER: |
1022 | createFolder(); | 1022 | createFolder(); |
1023 | break; | 1023 | break; |
1024 | case FOLDER_MENU_REFRESH_HEADER: | 1024 | case FOLDER_MENU_REFRESH_HEADER: |
1025 | view = (AccountView*)listView(); | 1025 | view = (AccountView*)listView(); |
1026 | if (view) view->refreshCurrent(); | 1026 | if (view) view->refreshCurrent(); |
1027 | break; | 1027 | break; |
1028 | default: | 1028 | default: |
1029 | break; | 1029 | break; |
1030 | } | 1030 | } |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | bool MHfolderItem::isDraftfolder() | 1033 | bool MHfolderItem::isDraftfolder() |
1034 | { | 1034 | { |
1035 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1035 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1036 | return false; | 1036 | return false; |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | /** | 1039 | /** |
1040 | * Generic stuff | 1040 | * Generic stuff |
1041 | */ | 1041 | */ |
1042 | 1042 | ||
1043 | const QString AccountViewItem::contextName="AccountViewItem"; | 1043 | const QString AccountViewItem::contextName="AccountViewItem"; |
1044 | 1044 | ||
1045 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1045 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1046 | : QListViewItem( parent ) | 1046 | : QListViewItem( parent ) |
1047 | { | 1047 | { |
1048 | init(); | 1048 | init(); |
1049 | m_Backlink = parent; | 1049 | m_Backlink = parent; |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1052 | AccountViewItem::AccountViewItem( QListViewItem *parent) |
1053 | : QListViewItem( parent),folder(0) | 1053 | : QListViewItem( parent),folder(0) |
1054 | { | 1054 | { |
1055 | init(); | 1055 | init(); |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1058 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) |
1059 | :QListViewItem( parent,after ),folder(0) | 1059 | :QListViewItem( parent,after ),folder(0) |
1060 | { | 1060 | { |
1061 | init(); | 1061 | init(); |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) | 1064 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) |
1065 | :QListViewItem( parent,after ),folder(folderInit) | 1065 | :QListViewItem( parent,after ),folder(folderInit) |
1066 | { | 1066 | { |
1067 | init(); | 1067 | init(); |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | void AccountViewItem::init() | 1070 | void AccountViewItem::init() |
1071 | { | 1071 | { |
1072 | m_Backlink = 0; | 1072 | m_Backlink = 0; |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | AccountViewItem::~AccountViewItem() | 1075 | AccountViewItem::~AccountViewItem() |
1076 | { | 1076 | { |
1077 | folder = 0; | 1077 | folder = 0; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | AccountView*AccountViewItem::accountView() | 1080 | AccountView*AccountViewItem::accountView() |
1081 | { | 1081 | { |
1082 | return m_Backlink; | 1082 | return m_Backlink; |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) | 1085 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) |
1086 | { | 1086 | { |
1087 | if (!wrapper) return; | 1087 | if (!wrapper) return; |
1088 | QString fname=""; | 1088 | QString fname=""; |
1089 | if (folder) fname = folder->getDisplayName(); | 1089 | if (folder) fname = folder->getDisplayName(); |
1090 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 1090 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
1091 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | 1091 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). |
1092 | arg(fname), | 1092 | arg(fname), |
1093 | QObject::tr("Yes",contextName), | 1093 | QObject::tr("Yes",contextName), |
1094 | QObject::tr("No",contextName),QString::null,1,1); | 1094 | QObject::tr("No",contextName),QString::null,1,1); |
1095 | odebug << "Auswahl: " << yesno << "" << oendl; | 1095 | odebug << "Auswahl: " << yesno << "" << oendl; |
1096 | if (yesno == 0) | 1096 | if (yesno == 0) |
1097 | { | 1097 | { |
1098 | if (wrapper->deleteAllMail(folder)) | 1098 | if (wrapper->deleteAllMail(folder)) |
1099 | { | 1099 | { |
1100 | AccountView * view = (AccountView*)listView(); | 1100 | AccountView * view = (AccountView*)listView(); |
1101 | if (view) view->refreshCurrent(); | 1101 | if (view) view->refreshCurrent(); |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void AccountViewItem::removeChilds() | 1106 | void AccountViewItem::removeChilds() |
1107 | { | 1107 | { |
1108 | QListViewItem *child = firstChild(); | 1108 | QListViewItem *child = firstChild(); |
1109 | while ( child ) | 1109 | while ( child ) |
1110 | { | 1110 | { |
1111 | QListViewItem *tmp = child; | 1111 | QListViewItem *tmp = child; |
1112 | child = child->nextSibling(); | 1112 | child = child->nextSibling(); |
1113 | delete tmp; | 1113 | delete tmp; |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | bool AccountViewItem::matchName(const QString&name)const | 1117 | bool AccountViewItem::matchName(const QString&name)const |
1118 | { | 1118 | { |
1119 | if (!folder) return false; | 1119 | if (!folder) return false; |
1120 | return folder->getDisplayName()==name; | 1120 | return folder->getDisplayName()==name; |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | 1123 | ||
1124 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | 1124 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) |
1125 | { | 1125 | { |
1126 | AccountViewItem*pitem,*sitem; | 1126 | AccountViewItem*pitem,*sitem; |
1127 | if (!start) pitem = (AccountViewItem*)firstChild(); | 1127 | if (!start) pitem = (AccountViewItem*)firstChild(); |
1128 | else pitem = (AccountViewItem*)start->firstChild(); | 1128 | else pitem = (AccountViewItem*)start->firstChild(); |
1129 | while (pitem) | 1129 | while (pitem) |
1130 | { | 1130 | { |
1131 | if (pitem->matchName(path)) | 1131 | if (pitem->matchName(path)) |
1132 | { | 1132 | { |
1133 | break; | 1133 | break; |
1134 | } | 1134 | } |
1135 | if (pitem->childCount()>0) | 1135 | if (pitem->childCount()>0) |
1136 | { | 1136 | { |
1137 | sitem = findSubItem(path,pitem); | 1137 | sitem = findSubItem(path,pitem); |
1138 | if (sitem) | 1138 | if (sitem) |
1139 | { | 1139 | { |
1140 | pitem = sitem; | 1140 | pitem = sitem; |
1141 | break; | 1141 | break; |
1142 | } | 1142 | } |
1143 | } | 1143 | } |
1144 | pitem=(AccountViewItem*)pitem->nextSibling(); | 1144 | pitem=(AccountViewItem*)pitem->nextSibling(); |
1145 | } | 1145 | } |
1146 | return pitem; | 1146 | return pitem; |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | bool AccountViewItem::isDraftfolder() | 1149 | bool AccountViewItem::isDraftfolder() |
1150 | { | 1150 | { |
1151 | return false; | 1151 | return false; |
1152 | } | 1152 | } |