-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 | |||
@@ -583,261 +583,289 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
583 | m_abView -> addEntry( cnt ); | 583 | m_abView -> addEntry( cnt ); |
584 | 584 | ||
585 | // :SXm_abView()->init( cnt ); | 585 | // :SXm_abView()->init( cnt ); |
586 | editEntry( EditEntry ); | 586 | editEntry( EditEntry ); |
587 | 587 | ||
588 | // Categories might have changed, so reload | 588 | // Categories might have changed, so reload |
589 | reloadCategories(); | 589 | reloadCategories(); |
590 | } else if ( msg == "beamBusinessCard()" ) { | 590 | } else if ( msg == "beamBusinessCard()" ) { |
591 | QString beamFilename = addressbookPersonalVCardName(); | 591 | QString beamFilename = addressbookPersonalVCardName(); |
592 | if ( !QFile::exists( beamFilename ) ) | 592 | if ( !QFile::exists( beamFilename ) ) |
593 | return; // can't beam a non-existent file | 593 | return; // can't beam a non-existent file |
594 | 594 | ||
595 | Ir *ir = new Ir( this ); | 595 | Ir *ir = new Ir( this ); |
596 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 596 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
597 | QString description = "mycard.vcf"; | 597 | QString description = "mycard.vcf"; |
598 | ir->send( beamFilename, description, "text/x-vCard" ); | 598 | ir->send( beamFilename, description, "text/x-vCard" ); |
599 | } else if ( msg == "show(int)" ) { | 599 | } else if ( msg == "show(int)" ) { |
600 | raise(); | 600 | raise(); |
601 | QDataStream stream(data,IO_ReadOnly); | 601 | QDataStream stream(data,IO_ReadOnly); |
602 | int uid; | 602 | int uid; |
603 | stream >> uid; | 603 | stream >> uid; |
604 | 604 | ||
605 | odebug << "Showing uid: " << uid << oendl; | 605 | odebug << "Showing uid: " << uid << oendl; |
606 | 606 | ||
607 | // Deactivate Personal View.. | 607 | // Deactivate Personal View.. |
608 | if ( m_actionPersonal->isOn() ){ | 608 | if ( m_actionPersonal->isOn() ){ |
609 | m_actionPersonal->setOn( false ); | 609 | m_actionPersonal->setOn( false ); |
610 | slotPersonalView(); | 610 | slotPersonalView(); |
611 | } | 611 | } |
612 | 612 | ||
613 | // Reset category and show as card.. | 613 | // Reset category and show as card.. |
614 | m_abView -> setShowByCategory( QString::null ); | 614 | m_abView -> setShowByCategory( QString::null ); |
615 | m_abView -> setCurrentUid( uid ); | 615 | m_abView -> setCurrentUid( uid ); |
616 | slotViewSwitched ( AbView::CardView ); | 616 | slotViewSwitched ( AbView::CardView ); |
617 | 617 | ||
618 | needShow = true; | 618 | needShow = true; |
619 | 619 | ||
620 | 620 | ||
621 | } else if ( msg == "edit(int)" ) { | 621 | } else if ( msg == "edit(int)" ) { |
622 | QDataStream stream(data,IO_ReadOnly); | 622 | QDataStream stream(data,IO_ReadOnly); |
623 | int uid; | 623 | int uid; |
624 | stream >> uid; | 624 | stream >> uid; |
625 | 625 | ||
626 | // Deactivate Personal View.. | 626 | // Deactivate Personal View.. |
627 | if ( m_actionPersonal->isOn() ){ | 627 | if ( m_actionPersonal->isOn() ){ |
628 | m_actionPersonal->setOn( false ); | 628 | m_actionPersonal->setOn( false ); |
629 | slotPersonalView(); | 629 | slotPersonalView(); |
630 | } | 630 | } |
631 | 631 | ||
632 | // Reset category and edit.. | 632 | // Reset category and edit.. |
633 | m_abView -> setShowByCategory( QString::null ); | 633 | m_abView -> setShowByCategory( QString::null ); |
634 | m_abView -> setCurrentUid( uid ); | 634 | m_abView -> setCurrentUid( uid ); |
635 | slotItemEdit(); | 635 | slotItemEdit(); |
636 | 636 | ||
637 | // Categories might have changed, so reload | 637 | // Categories might have changed, so reload |
638 | reloadCategories(); | 638 | reloadCategories(); |
639 | } | 639 | } |
640 | 640 | ||
641 | if (needShow) | 641 | if (needShow) |
642 | QPEApplication::setKeepRunning(); | 642 | QPEApplication::setKeepRunning(); |
643 | } | 643 | } |
644 | 644 | ||
645 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 645 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
646 | { | 646 | { |
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 | ||
809 | void AddressbookWindow::slotSetCategory( const QString &category ) | 837 | void AddressbookWindow::slotSetCategory( const QString &category ) |
810 | { | 838 | { |
811 | odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl; | 839 | odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl; |
812 | 840 | ||
813 | // Tell the view about the selected category | 841 | // Tell the view about the selected category |
814 | m_config.setCategory( category ); | 842 | m_config.setCategory( category ); |
815 | m_abView -> setShowByCategory( category ); | 843 | m_abView -> setShowByCategory( category ); |
816 | } | 844 | } |
817 | 845 | ||
818 | void AddressbookWindow::slotViewSwitched( int view ) | 846 | void AddressbookWindow::slotViewSwitched( int view ) |
819 | { | 847 | { |
820 | odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl; | 848 | odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl; |
821 | 849 | ||
822 | // Tell the view about the selected view | 850 | // Tell the view about the selected view |
823 | m_abView -> setShowToView ( (AbView::Views) view ); | 851 | m_abView -> setShowToView ( (AbView::Views) view ); |
824 | active_view = view; | 852 | active_view = view; |
825 | } | 853 | } |
826 | 854 | ||
827 | 855 | ||
828 | void AddressbookWindow::slotListView() | 856 | void AddressbookWindow::slotListView() |
829 | { | 857 | { |
830 | slotViewSwitched( AbView::TableView ); | 858 | slotViewSwitched( AbView::TableView ); |
831 | } | 859 | } |
832 | 860 | ||
833 | void AddressbookWindow::slotCardView() | 861 | void AddressbookWindow::slotCardView() |
834 | { | 862 | { |
835 | slotViewSwitched( AbView::CardView ); | 863 | slotViewSwitched( AbView::CardView ); |
836 | } | 864 | } |
837 | 865 | ||
838 | void AddressbookWindow::slotSetLetter( char c ) { | 866 | void AddressbookWindow::slotSetLetter( char c ) { |
839 | 867 | ||
840 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); | 868 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); |
841 | 869 | ||
842 | } | 870 | } |
843 | 871 | ||