-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index a4c2c6e..7c52ef2 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -647,162 +647,190 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) | |||
647 | Opie::OPimContact entry; | 647 | Opie::OPimContact entry; |
648 | if ( !abEditor ) { | 648 | if ( !abEditor ) { |
649 | abEditor = new ContactEditor( entry, this, "editor" ); | 649 | abEditor = new ContactEditor( entry, this, "editor" ); |
650 | } | 650 | } |
651 | if ( entryMode == EditEntry ) | 651 | if ( entryMode == EditEntry ) |
652 | abEditor->setEntry( m_abView -> currentEntry() ); | 652 | abEditor->setEntry( m_abView -> currentEntry() ); |
653 | else if ( entryMode == NewEntry ) | 653 | else if ( entryMode == NewEntry ) |
654 | abEditor->setEntry( entry ); | 654 | abEditor->setEntry( entry ); |
655 | // other things may change the caption. | 655 | // other things may change the caption. |
656 | abEditor->setCaption( tr("Edit Address") ); | 656 | abEditor->setCaption( tr("Edit Address") ); |
657 | 657 | ||
658 | // fix the focus... | 658 | // fix the focus... |
659 | abEditor->setNameFocus(); | 659 | abEditor->setNameFocus(); |
660 | if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) { | 660 | if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) { |
661 | setFocus(); | 661 | setFocus(); |
662 | if ( entryMode == NewEntry ) { | 662 | if ( entryMode == NewEntry ) { |
663 | Opie::OPimContact insertEntry = abEditor->entry(); | 663 | Opie::OPimContact insertEntry = abEditor->entry(); |
664 | insertEntry.assignUid(); | 664 | insertEntry.assignUid(); |
665 | m_abView -> addEntry( insertEntry ); | 665 | m_abView -> addEntry( insertEntry ); |
666 | m_abView -> setCurrentUid( insertEntry.uid() ); | 666 | m_abView -> setCurrentUid( insertEntry.uid() ); |
667 | } else { | 667 | } else { |
668 | Opie::OPimContact replEntry = abEditor->entry(); | 668 | Opie::OPimContact replEntry = abEditor->entry(); |
669 | 669 | ||
670 | if ( !replEntry.isValidUid() ) | 670 | if ( !replEntry.isValidUid() ) |
671 | replEntry.assignUid(); | 671 | replEntry.assignUid(); |
672 | 672 | ||
673 | m_abView -> replaceEntry( replEntry ); | 673 | m_abView -> replaceEntry( replEntry ); |
674 | } | 674 | } |
675 | 675 | ||
676 | // Categories might have changed, so reload | 676 | // Categories might have changed, so reload |
677 | reloadCategories(); | 677 | reloadCategories(); |
678 | } | 678 | } |
679 | } | 679 | } |
680 | 680 | ||
681 | void AddressbookWindow::editPersonal() | 681 | void AddressbookWindow::editPersonal() |
682 | { | 682 | { |
683 | Opie::OPimContact entry; | 683 | Opie::OPimContact entry; |
684 | 684 | ||
685 | // Switch to personal view if not selected | 685 | // Switch to personal view if not selected |
686 | // but take care of the menu, too | 686 | // but take care of the menu, too |
687 | if ( ! m_actionPersonal->isOn() ){ | 687 | if ( ! m_actionPersonal->isOn() ){ |
688 | odebug << "*** ++++" << oendl; | 688 | odebug << "*** ++++" << oendl; |
689 | m_actionPersonal->setOn( true ); | 689 | m_actionPersonal->setOn( true ); |
690 | slotPersonalView(); | 690 | slotPersonalView(); |
691 | } | 691 | } |
692 | 692 | ||
693 | if ( !abEditor ) { | 693 | if ( !abEditor ) { |
694 | abEditor = new ContactEditor( entry, this, "editor" ); | 694 | abEditor = new ContactEditor( entry, this, "editor" ); |
695 | } | 695 | } |
696 | 696 | ||
697 | abEditor->setCaption(tr("Edit My Personal Details")); | 697 | abEditor->setCaption(tr("Edit My Personal Details")); |
698 | abEditor->setPersonalView( true ); | 698 | abEditor->setPersonalView( true ); |
699 | editEntry( EditEntry ); | 699 | editEntry( EditEntry ); |
700 | abEditor->setPersonalView( false ); | 700 | abEditor->setPersonalView( false ); |
701 | 701 | ||
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | void AddressbookWindow::slotPersonalView() | 705 | void AddressbookWindow::slotPersonalView() |
706 | { | 706 | { |
707 | odebug << "slotPersonalView()" << oendl; | 707 | odebug << "slotPersonalView()" << oendl; |
708 | 708 | ||
709 | bool personal = m_actionPersonal->isOn(); | 709 | bool personal = m_actionPersonal->isOn(); |
710 | 710 | ||
711 | // Disable certain menu items when showing personal details | 711 | // Disable actions when showing personal details |
712 | setItemNewEnabled( !personal ); | 712 | setItemNewEnabled( !personal ); |
713 | setItemDuplicateEnabled( !personal ); | 713 | setItemDuplicateEnabled( !personal ); |
714 | setItemDeleteEnabled( !personal ); | 714 | setItemDeleteEnabled( !personal ); |
715 | m_actionMail->setEnabled( !personal ); | 715 | m_actionMail->setEnabled( !personal ); |
716 | setShowCategories( !personal ); | ||
716 | 717 | ||
717 | // Display appropriate view | 718 | // Display appropriate view |
718 | m_abView->showPersonal( personal ); | 719 | m_abView->showPersonal( personal ); |
719 | 720 | ||
720 | // Set application caption | 721 | if ( personal ) |
721 | personal ? setCaption( tr( "Contacts - My Personal Details") ) | 722 | { |
722 | : setCaption( tr( "Contacts") ); | 723 | setCaption( tr( "Contacts - My Personal Details") ); |
724 | |||
725 | // Set category to 'All' to make sure personal details is visible | ||
726 | setViewCategory( "All" ); | ||
727 | m_abView->setShowByCategory( "All" ); | ||
728 | |||
729 | // Temporarily disable letter picker | ||
730 | pLabel->hide(); | ||
731 | } | ||
732 | else | ||
733 | { | ||
734 | setCaption( tr( "Contacts") ); | ||
735 | |||
736 | // Re-enable letter picker | ||
737 | pLabel->show(); | ||
738 | } | ||
723 | } | 739 | } |
724 | 740 | ||
725 | void AddressbookWindow::reload() | 741 | void AddressbookWindow::reload() |
726 | { | 742 | { |
727 | syncing = false; | 743 | syncing = false; |
728 | m_abView->clear(); | 744 | m_abView->clear(); |
729 | m_abView->reload(); | 745 | m_abView->reload(); |
730 | } | 746 | } |
731 | 747 | ||
732 | void AddressbookWindow::flush() | 748 | void AddressbookWindow::flush() |
733 | { | 749 | { |
734 | syncing = true; | 750 | syncing = true; |
735 | m_abView->save(); | 751 | m_abView->save(); |
736 | } | 752 | } |
737 | 753 | ||
738 | 754 | ||
739 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 755 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
740 | { | 756 | { |
741 | if(active_view == AbView::CardView){ | 757 | if ( active_view == AbView::CardView ) |
742 | slotViewSwitched( AbView::TableView ); | 758 | { |
743 | e->ignore(); | 759 | if ( !m_actionPersonal->isOn() ) |
744 | return; | 760 | { |
761 | // Switch to table view only if not editing personal details | ||
762 | slotViewSwitched( AbView::TableView ); | ||
763 | } | ||
764 | else | ||
765 | { | ||
766 | // If currently editing personal details, switch off personal view | ||
767 | m_actionPersonal->setOn( false ); | ||
768 | slotPersonalView(); | ||
769 | } | ||
770 | |||
771 | e->ignore(); | ||
772 | return; | ||
745 | } | 773 | } |
746 | if(syncing) { | 774 | if(syncing) { |
747 | /* shouldn't we save, I hear you say? well its already been set | 775 | /* shouldn't we save, I hear you say? well its already been set |
748 | so that an edit can not occur during a sync, and we flushed | 776 | so that an edit can not occur during a sync, and we flushed |
749 | at the start of the sync, so there is no need to save | 777 | at the start of the sync, so there is no need to save |
750 | Saving however itself would cause problems. */ | 778 | Saving however itself would cause problems. */ |
751 | e->accept(); | 779 | e->accept(); |
752 | return; | 780 | return; |
753 | } | 781 | } |
754 | //################## shouldn't always save | 782 | //################## shouldn't always save |
755 | // True, but the database handles this automatically ! (se) | 783 | // True, but the database handles this automatically ! (se) |
756 | if ( save() ) | 784 | if ( save() ) |
757 | e->accept(); | 785 | e->accept(); |
758 | else | 786 | else |
759 | e->ignore(); | 787 | e->ignore(); |
760 | } | 788 | } |
761 | 789 | ||
762 | /* | 790 | /* |
763 | Returns true if it is OK to exit | 791 | Returns true if it is OK to exit |
764 | */ | 792 | */ |
765 | 793 | ||
766 | bool AddressbookWindow::save() | 794 | bool AddressbookWindow::save() |
767 | { | 795 | { |
768 | if ( !m_abView->save() ) { | 796 | if ( !m_abView->save() ) { |
769 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 797 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
770 | tr("Unable to save information.\n" | 798 | tr("Unable to save information.\n" |
771 | "Free up some space\n" | 799 | "Free up some space\n" |
772 | "and try again.\n" | 800 | "and try again.\n" |
773 | "\nQuit anyway?"), | 801 | "\nQuit anyway?"), |
774 | QMessageBox::Yes|QMessageBox::Escape, | 802 | QMessageBox::Yes|QMessageBox::Escape, |
775 | QMessageBox::No|QMessageBox::Default ) | 803 | QMessageBox::No|QMessageBox::Default ) |
776 | != QMessageBox::No ) | 804 | != QMessageBox::No ) |
777 | return true; | 805 | return true; |
778 | else | 806 | else |
779 | return false; | 807 | return false; |
780 | } | 808 | } |
781 | return true; | 809 | return true; |
782 | } | 810 | } |
783 | 811 | ||
784 | #ifdef __DEBUG_RELEASE | 812 | #ifdef __DEBUG_RELEASE |
785 | void AddressbookWindow::slotSave() | 813 | void AddressbookWindow::slotSave() |
786 | { | 814 | { |
787 | save(); | 815 | save(); |
788 | } | 816 | } |
789 | #endif | 817 | #endif |
790 | 818 | ||
791 | 819 | ||
792 | void AddressbookWindow::slotNotFound() | 820 | void AddressbookWindow::slotNotFound() |
793 | { | 821 | { |
794 | odebug << "Got not found signal!" << oendl; | 822 | odebug << "Got not found signal!" << oendl; |
795 | QMessageBox::information( this, tr( "Not Found" ), | 823 | QMessageBox::information( this, tr( "Not Found" ), |
796 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); | 824 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); |
797 | 825 | ||
798 | 826 | ||
799 | } | 827 | } |
800 | void AddressbookWindow::slotWrapAround() | 828 | void AddressbookWindow::slotWrapAround() |
801 | { | 829 | { |
802 | odebug << "Got wrap signal!" << oendl; | 830 | odebug << "Got wrap signal!" << oendl; |
803 | // if ( doNotifyWrapAround ) | 831 | // if ( doNotifyWrapAround ) |
804 | // QMessageBox::information( this, tr( "End of list" ), | 832 | // QMessageBox::information( this, tr( "End of list" ), |
805 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 833 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
806 | 834 | ||
807 | } | 835 | } |
808 | 836 | ||