summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-06 15:55:15 (UTC)
committer zautrix <zautrix>2004-07-06 15:55:15 (UTC)
commit45e2744074e876a74919b340efc320bdadadcb25 (patch) (unidiff)
tree5fac15064970f378dc59284b451491d924c7e5b2
parent60ec860b41d2af2444955e5cc3d04d132c76dbbb (diff)
downloadkdepimpi-45e2744074e876a74919b340efc320bdadadcb25.zip
kdepimpi-45e2744074e876a74919b340efc320bdadadcb25.tar.gz
kdepimpi-45e2744074e876a74919b340efc320bdadadcb25.tar.bz2
Fixed a crash
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7cba9aa..3ae23e8 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -645,287 +645,286 @@ void KABCore::setCategories()
645 addr.setCategories( addrCategories ); 645 addr.setCategories( addrCategories );
646 } 646 }
647 647
648 mAddressBook->insertAddressee( addr ); 648 mAddressBook->insertAddressee( addr );
649 } 649 }
650 } 650 }
651 651
652 if ( uids.count() > 0 ) 652 if ( uids.count() > 0 )
653 setModified( true ); 653 setModified( true );
654} 654}
655 655
656void KABCore::setSearchFields( const KABC::Field::List &fields ) 656void KABCore::setSearchFields( const KABC::Field::List &fields )
657{ 657{
658 mIncSearchWidget->setFields( fields ); 658 mIncSearchWidget->setFields( fields );
659} 659}
660 660
661void KABCore::incrementalSearch( const QString& text ) 661void KABCore::incrementalSearch( const QString& text )
662{ 662{
663 mViewManager->setSelected( QString::null, false ); 663 mViewManager->setSelected( QString::null, false );
664 664
665 if ( !text.isEmpty() ) { 665 if ( !text.isEmpty() ) {
666 KABC::Field *field = mIncSearchWidget->currentField(); 666 KABC::Field *field = mIncSearchWidget->currentField();
667 667
668 QString pattern = text.lower(); 668 QString pattern = text.lower();
669 669
670#if 1 //KDE_VERSION >= 319 670#if 1 //KDE_VERSION >= 319
671 KABC::AddresseeList list( mAddressBook->allAddressees() ); 671 KABC::AddresseeList list( mAddressBook->allAddressees() );
672 if ( field ) { 672 if ( field ) {
673 list.sortByField( field ); 673 list.sortByField( field );
674 KABC::AddresseeList::Iterator it; 674 KABC::AddresseeList::Iterator it;
675 for ( it = list.begin(); it != list.end(); ++it ) { 675 for ( it = list.begin(); it != list.end(); ++it ) {
676 if ( field->value( *it ).lower().startsWith( pattern ) ) { 676 if ( field->value( *it ).lower().startsWith( pattern ) ) {
677 mViewManager->setSelected( (*it).uid(), true ); 677 mViewManager->setSelected( (*it).uid(), true );
678 return; 678 return;
679 } 679 }
680 } 680 }
681 } else { 681 } else {
682 KABC::AddresseeList::Iterator it; 682 KABC::AddresseeList::Iterator it;
683 for ( it = list.begin(); it != list.end(); ++it ) { 683 for ( it = list.begin(); it != list.end(); ++it ) {
684 KABC::Field::List fieldList = mIncSearchWidget->fields(); 684 KABC::Field::List fieldList = mIncSearchWidget->fields();
685 KABC::Field::List::ConstIterator fieldIt; 685 KABC::Field::List::ConstIterator fieldIt;
686 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 686 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
687 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 687 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
688 mViewManager->setSelected( (*it).uid(), true ); 688 mViewManager->setSelected( (*it).uid(), true );
689 return; 689 return;
690 } 690 }
691 } 691 }
692 } 692 }
693 } 693 }
694#else 694#else
695 KABC::AddressBook::Iterator it; 695 KABC::AddressBook::Iterator it;
696 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 696 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
697 if ( field ) { 697 if ( field ) {
698 if ( field->value( *it ).lower().startsWith( pattern ) ) { 698 if ( field->value( *it ).lower().startsWith( pattern ) ) {
699 mViewManager->setSelected( (*it).uid(), true ); 699 mViewManager->setSelected( (*it).uid(), true );
700 return; 700 return;
701 } 701 }
702 } else { 702 } else {
703 KABC::Field::List fieldList = mIncSearchWidget->fields(); 703 KABC::Field::List fieldList = mIncSearchWidget->fields();
704 KABC::Field::List::ConstIterator fieldIt; 704 KABC::Field::List::ConstIterator fieldIt;
705 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 705 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
706 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 706 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
707 mViewManager->setSelected( (*it).uid(), true ); 707 mViewManager->setSelected( (*it).uid(), true );
708 return; 708 return;
709 } 709 }
710 } 710 }
711 } 711 }
712 } 712 }
713#endif 713#endif
714 } 714 }
715} 715}
716 716
717void KABCore::setModified() 717void KABCore::setModified()
718{ 718{
719 setModified( true ); 719 setModified( true );
720} 720}
721 721
722void KABCore::setModifiedWOrefresh() 722void KABCore::setModifiedWOrefresh()
723{ 723{
724 // qDebug("KABCore::setModifiedWOrefresh() "); 724 // qDebug("KABCore::setModifiedWOrefresh() ");
725 mModified = true; 725 mModified = true;
726 mActionSave->setEnabled( mModified ); 726 mActionSave->setEnabled( mModified );
727#ifdef DESKTOP_VERSION 727#ifdef DESKTOP_VERSION
728 mDetails->refreshView(); 728 mDetails->refreshView();
729#endif 729#endif
730 730
731} 731}
732void KABCore::setModified( bool modified ) 732void KABCore::setModified( bool modified )
733{ 733{
734 mModified = modified; 734 mModified = modified;
735 mActionSave->setEnabled( mModified ); 735 mActionSave->setEnabled( mModified );
736 736
737 if ( modified ) 737 if ( modified )
738 mJumpButtonBar->recreateButtons(); 738 mJumpButtonBar->recreateButtons();
739 739
740 mViewManager->refreshView(); 740 mViewManager->refreshView();
741 mDetails->refreshView(); 741 mDetails->refreshView();
742 742
743} 743}
744 744
745bool KABCore::modified() const 745bool KABCore::modified() const
746{ 746{
747 return mModified; 747 return mModified;
748} 748}
749 749
750void KABCore::contactModified( const KABC::Addressee &addr ) 750void KABCore::contactModified( const KABC::Addressee &addr )
751{ 751{
752 752
753 Command *command = 0; 753 Command *command = 0;
754 QString uid; 754 QString uid;
755 755
756 // check if it exists already 756 // check if it exists already
757 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 757 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
758 if ( origAddr.isEmpty() ) 758 if ( origAddr.isEmpty() )
759 command = new PwNewCommand( mAddressBook, addr ); 759 command = new PwNewCommand( mAddressBook, addr );
760 else { 760 else {
761 command = new PwEditCommand( mAddressBook, origAddr, addr ); 761 command = new PwEditCommand( mAddressBook, origAddr, addr );
762 uid = addr.uid(); 762 uid = addr.uid();
763 } 763 }
764 764
765 UndoStack::instance()->push( command ); 765 UndoStack::instance()->push( command );
766 RedoStack::instance()->clear(); 766 RedoStack::instance()->clear();
767 767
768 setModified( true ); 768 setModified( true );
769} 769}
770 770
771void KABCore::newContact() 771void KABCore::newContact()
772{ 772{
773 AddresseeEditorDialog *dialog = 0; 773
774 774
775 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 775 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
776 776
777 QPtrList<KRES::Resource> kresResources; 777 QPtrList<KRES::Resource> kresResources;
778 QPtrListIterator<KABC::Resource> it( kabcResources ); 778 QPtrListIterator<KABC::Resource> it( kabcResources );
779 KABC::Resource *resource; 779 KABC::Resource *resource;
780 while ( ( resource = it.current() ) != 0 ) { 780 while ( ( resource = it.current() ) != 0 ) {
781 ++it; 781 ++it;
782 if ( !resource->readOnly() ) { 782 if ( !resource->readOnly() ) {
783 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 783 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
784 if ( res ) 784 if ( res )
785 kresResources.append( res ); 785 kresResources.append( res );
786 } 786 }
787 } 787 }
788 788
789 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 789 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
790 resource = static_cast<KABC::Resource*>( res ); 790 resource = static_cast<KABC::Resource*>( res );
791 791
792 if ( resource ) { 792 if ( resource ) {
793 KABC::Addressee addr; 793 KABC::Addressee addr;
794 addr.setResource( resource ); 794 addr.setResource( resource );
795 mEditorDialog->setAddressee( addr ); 795 mEditorDialog->setAddressee( addr );
796 KApplication::execDialog ( mEditorDialog ); 796 KApplication::execDialog ( mEditorDialog );
797 797
798 } else 798 } else
799 return; 799 return;
800 800
801 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 801 // mEditorDict.insert( dialog->addressee().uid(), dialog );
802 802
803 dialog->show();
804 803
805} 804}
806 805
807void KABCore::addEmail( QString aStr ) 806void KABCore::addEmail( QString aStr )
808{ 807{
809#ifndef KAB_EMBEDDED 808#ifndef KAB_EMBEDDED
810 QString fullName, email; 809 QString fullName, email;
811 810
812 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 811 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
813 812
814 // Try to lookup the addressee matching the email address 813 // Try to lookup the addressee matching the email address
815 bool found = false; 814 bool found = false;
816 QStringList emailList; 815 QStringList emailList;
817 KABC::AddressBook::Iterator it; 816 KABC::AddressBook::Iterator it;
818 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 817 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
819 emailList = (*it).emails(); 818 emailList = (*it).emails();
820 if ( emailList.contains( email ) > 0 ) { 819 if ( emailList.contains( email ) > 0 ) {
821 found = true; 820 found = true;
822 (*it).setNameFromString( fullName ); 821 (*it).setNameFromString( fullName );
823 editContact( (*it).uid() ); 822 editContact( (*it).uid() );
824 } 823 }
825 } 824 }
826 825
827 if ( !found ) { 826 if ( !found ) {
828 KABC::Addressee addr; 827 KABC::Addressee addr;
829 addr.setNameFromString( fullName ); 828 addr.setNameFromString( fullName );
830 addr.insertEmail( email, true ); 829 addr.insertEmail( email, true );
831 830
832 mAddressBook->insertAddressee( addr ); 831 mAddressBook->insertAddressee( addr );
833 mViewManager->refreshView( addr.uid() ); 832 mViewManager->refreshView( addr.uid() );
834 editContact( addr.uid() ); 833 editContact( addr.uid() );
835 } 834 }
836#else //KAB_EMBEDDED 835#else //KAB_EMBEDDED
837 qDebug("KABCore::addEmail finsih method"); 836 qDebug("KABCore::addEmail finsih method");
838#endif //KAB_EMBEDDED 837#endif //KAB_EMBEDDED
839} 838}
840 839
841void KABCore::importVCard( const KURL &url, bool showPreview ) 840void KABCore::importVCard( const KURL &url, bool showPreview )
842{ 841{
843 mXXPortManager->importVCard( url, showPreview ); 842 mXXPortManager->importVCard( url, showPreview );
844} 843}
845 844
846void KABCore::importVCard( const QString &vCard, bool showPreview ) 845void KABCore::importVCard( const QString &vCard, bool showPreview )
847{ 846{
848 mXXPortManager->importVCard( vCard, showPreview ); 847 mXXPortManager->importVCard( vCard, showPreview );
849} 848}
850 849
851//US added a second method without defaultparameter 850//US added a second method without defaultparameter
852void KABCore::editContact2() { 851void KABCore::editContact2() {
853 editContact( QString::null ); 852 editContact( QString::null );
854} 853}
855 854
856void KABCore::editContact( const QString &uid ) 855void KABCore::editContact( const QString &uid )
857{ 856{
858 857
859 if ( mExtensionManager->isQuickEditVisible() ) 858 if ( mExtensionManager->isQuickEditVisible() )
860 return; 859 return;
861 860
862 // First, locate the contact entry 861 // First, locate the contact entry
863 QString localUID = uid; 862 QString localUID = uid;
864 if ( localUID.isNull() ) { 863 if ( localUID.isNull() ) {
865 QStringList uidList = mViewManager->selectedUids(); 864 QStringList uidList = mViewManager->selectedUids();
866 if ( uidList.count() > 0 ) 865 if ( uidList.count() > 0 )
867 localUID = *( uidList.at( 0 ) ); 866 localUID = *( uidList.at( 0 ) );
868 } 867 }
869 868
870 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 869 KABC::Addressee addr = mAddressBook->findByUid( localUID );
871 if ( !addr.isEmpty() ) { 870 if ( !addr.isEmpty() ) {
872 mEditorDialog->setAddressee( addr ); 871 mEditorDialog->setAddressee( addr );
873 KApplication::execDialog ( mEditorDialog ); 872 KApplication::execDialog ( mEditorDialog );
874 } 873 }
875} 874}
876 875
877void KABCore::save() 876void KABCore::save()
878{ 877{
879 if ( !mModified ) 878 if ( !mModified )
880 return; 879 return;
881 QString text = i18n( "There was an error while attempting to save\n the " 880 QString text = i18n( "There was an error while attempting to save\n the "
882 "address book. Please check that some \nother application is " 881 "address book. Please check that some \nother application is "
883 "not using it. " ); 882 "not using it. " );
884 statusMessage(i18n("Saving addressbook ... ")); 883 statusMessage(i18n("Saving addressbook ... "));
885#ifndef KAB_EMBEDDED 884#ifndef KAB_EMBEDDED
886 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 885 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
887 if ( !b || !b->save() ) { 886 if ( !b || !b->save() ) {
888 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 887 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
889 } 888 }
890#else //KAB_EMBEDDED 889#else //KAB_EMBEDDED
891 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 890 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
892 if ( !b || !b->save() ) { 891 if ( !b || !b->save() ) {
893 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 892 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
894 } 893 }
895#endif //KAB_EMBEDDED 894#endif //KAB_EMBEDDED
896 895
897 statusMessage(i18n("Addressbook saved!")); 896 statusMessage(i18n("Addressbook saved!"));
898 setModified( false ); 897 setModified( false );
899} 898}
900 899
901void KABCore::statusMessage(QString mess , int time ) 900void KABCore::statusMessage(QString mess , int time )
902{ 901{
903 //topLevelWidget()->setCaption( mess ); 902 //topLevelWidget()->setCaption( mess );
904 // pending setting timer to revome message 903 // pending setting timer to revome message
905} 904}
906void KABCore::undo() 905void KABCore::undo()
907{ 906{
908 UndoStack::instance()->undo(); 907 UndoStack::instance()->undo();
909 908
910 // Refresh the view 909 // Refresh the view
911 mViewManager->refreshView(); 910 mViewManager->refreshView();
912} 911}
913 912
914void KABCore::redo() 913void KABCore::redo()
915{ 914{
916 RedoStack::instance()->redo(); 915 RedoStack::instance()->redo();
917 916
918 // Refresh the view 917 // Refresh the view
919 mViewManager->refreshView(); 918 mViewManager->refreshView();
920} 919}
921 920
922void KABCore::setJumpButtonBarVisible( bool visible ) 921void KABCore::setJumpButtonBarVisible( bool visible )
923{ 922{
924 if ( visible ) 923 if ( visible )
925 mJumpButtonBar->show(); 924 mJumpButtonBar->show();
926 else 925 else
927 mJumpButtonBar->hide(); 926 mJumpButtonBar->hide();
928} 927}
929void KABCore::setDetailsToState() 928void KABCore::setDetailsToState()
930{ 929{
931 setDetailsVisible( mActionDetails->isChecked() ); 930 setDetailsVisible( mActionDetails->isChecked() );