summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 9b196b5..5774c36 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -685,442 +685,453 @@ bool AddressBook::saveAB()
685 .arg( (*it)->resourceName() ) ); 685 .arg( (*it)->resourceName() ) );
686 return false; 686 return false;
687 } 687 }
688 688
689 //if ( !save( ticket ) ) 689 //if ( !save( ticket ) )
690 if ( ticket->resource() ) { 690 if ( ticket->resource() ) {
691 QString name = ticket->resource()->resourceName(); 691 QString name = ticket->resource()->resourceName();
692 if ( ! ticket->resource()->save( ticket ) ) 692 if ( ! ticket->resource()->save( ticket ) )
693 ok = false; 693 ok = false;
694 else 694 else
695 qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); 695 qDebug("StdAddressBook::resource saved '%s'", name.latin1() );
696 696
697 } else 697 } else
698 ok = false; 698 ok = false;
699 699
700 } 700 }
701 } 701 }
702 return ok; 702 return ok;
703} 703}
704 704
705AddressBook::Iterator AddressBook::begin() 705AddressBook::Iterator AddressBook::begin()
706{ 706{
707 Iterator it = Iterator(); 707 Iterator it = Iterator();
708 it.d->mIt = d->mAddressees.begin(); 708 it.d->mIt = d->mAddressees.begin();
709 return it; 709 return it;
710} 710}
711 711
712AddressBook::ConstIterator AddressBook::begin() const 712AddressBook::ConstIterator AddressBook::begin() const
713{ 713{
714 ConstIterator it = ConstIterator(); 714 ConstIterator it = ConstIterator();
715 it.d->mIt = d->mAddressees.begin(); 715 it.d->mIt = d->mAddressees.begin();
716 return it; 716 return it;
717} 717}
718 718
719AddressBook::Iterator AddressBook::end() 719AddressBook::Iterator AddressBook::end()
720{ 720{
721 Iterator it = Iterator(); 721 Iterator it = Iterator();
722 it.d->mIt = d->mAddressees.end(); 722 it.d->mIt = d->mAddressees.end();
723 return it; 723 return it;
724} 724}
725 725
726AddressBook::ConstIterator AddressBook::end() const 726AddressBook::ConstIterator AddressBook::end() const
727{ 727{
728 ConstIterator it = ConstIterator(); 728 ConstIterator it = ConstIterator();
729 it.d->mIt = d->mAddressees.end(); 729 it.d->mIt = d->mAddressees.end();
730 return it; 730 return it;
731} 731}
732 732
733void AddressBook::clear() 733void AddressBook::clear()
734{ 734{
735 d->mAddressees.clear(); 735 d->mAddressees.clear();
736} 736}
737 737
738Ticket *AddressBook::requestSaveTicket( Resource *resource ) 738Ticket *AddressBook::requestSaveTicket( Resource *resource )
739{ 739{
740 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 740 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
741 741
742 if ( !resource ) 742 if ( !resource )
743 { 743 {
744 qDebug("AddressBook::requestSaveTicket no resource" ); 744 qDebug("AddressBook::requestSaveTicket no resource" );
745 resource = standardResource(); 745 resource = standardResource();
746 } 746 }
747 747
748 KRES::Manager<Resource>::ActiveIterator it; 748 KRES::Manager<Resource>::ActiveIterator it;
749 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 749 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
750 if ( (*it) == resource ) { 750 if ( (*it) == resource ) {
751 if ( (*it)->readOnly() || !(*it)->isOpen() ) 751 if ( (*it)->readOnly() || !(*it)->isOpen() )
752 return 0; 752 return 0;
753 else 753 else
754 return (*it)->requestSaveTicket(); 754 return (*it)->requestSaveTicket();
755 } 755 }
756 } 756 }
757 757
758 return 0; 758 return 0;
759} 759}
760//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 760//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
761void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 761void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
762{ 762{
763 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 763 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
764 //qDebug("block insert "); 764 //qDebug("block insert ");
765 return; 765 return;
766 } 766 }
767 //qDebug("inserting.... %s ",a.uid().latin1() ); 767 //qDebug("inserting.... %s ",a.uid().latin1() );
768 bool found = false; 768 bool found = false;
769 Addressee::List::Iterator it; 769 Addressee::List::Iterator it;
770 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 770 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
771 if ( a.uid() == (*it).uid() ) { 771 if ( a.uid() == (*it).uid() ) {
772 772
773 bool changed = false; 773 bool changed = false;
774 Addressee addr = a; 774 Addressee addr = a;
775 if ( addr != (*it) ) 775 if ( addr != (*it) )
776 changed = true; 776 changed = true;
777 777
778 if ( takeResource ) { 778 if ( takeResource ) {
779 Resource * res = (*it).resource(); 779 Resource * res = (*it).resource();
780 (*it) = a; 780 (*it) = a;
781 (*it).setResource( res ); 781 (*it).setResource( res );
782 } else { 782 } else {
783 (*it) = a; 783 (*it) = a;
784 if ( (*it).resource() == 0 ) 784 if ( (*it).resource() == 0 )
785 (*it).setResource( standardResource() ); 785 (*it).setResource( standardResource() );
786 } 786 }
787 if ( changed ) { 787 if ( changed ) {
788 if ( setRev ) { 788 if ( setRev ) {
789 789
790 // get rid of micro seconds 790 // get rid of micro seconds
791 QDateTime dt = QDateTime::currentDateTime(); 791 QDateTime dt = QDateTime::currentDateTime();
792 QTime t = dt.time(); 792 QTime t = dt.time();
793 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 793 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
794 (*it).setRevision( dt ); 794 (*it).setRevision( dt );
795 } 795 }
796 (*it).setChanged( true ); 796 (*it).setChanged( true );
797 } 797 }
798 798
799 found = true; 799 found = true;
800 } else { 800 } else {
801 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 801 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
802 QString name = (*it).uid().mid( 19 ); 802 QString name = (*it).uid().mid( 19 );
803 Addressee b = a; 803 Addressee b = a;
804 QString id = b.getID( name ); 804 QString id = b.getID( name );
805 if ( ! id.isEmpty() ) { 805 if ( ! id.isEmpty() ) {
806 QString des = (*it).note(); 806 QString des = (*it).note();
807 int startN; 807 int startN;
808 if( (startN = des.find( id ) ) >= 0 ) { 808 if( (startN = des.find( id ) ) >= 0 ) {
809 int endN = des.find( ",", startN+1 ); 809 int endN = des.find( ",", startN+1 );
810 des = des.left( startN ) + des.mid( endN+1 ); 810 des = des.left( startN ) + des.mid( endN+1 );
811 (*it).setNote( des ); 811 (*it).setNote( des );
812 } 812 }
813 } 813 }
814 } 814 }
815 } 815 }
816 } 816 }
817 if ( found ) 817 if ( found )
818 return; 818 return;
819 d->mAddressees.append( a ); 819 d->mAddressees.append( a );
820 Addressee& addr = d->mAddressees.last(); 820 Addressee& addr = d->mAddressees.last();
821 if ( addr.resource() == 0 ) 821 if ( addr.resource() == 0 )
822 addr.setResource( standardResource() ); 822 addr.setResource( standardResource() );
823 823
824 addr.setChanged( true ); 824 addr.setChanged( true );
825} 825}
826 826
827void AddressBook::removeAddressee( const Addressee &a ) 827void AddressBook::removeAddressee( const Addressee &a )
828{ 828{
829 Iterator it; 829 Iterator it;
830 Iterator it2; 830 Iterator it2;
831 bool found = false; 831 bool found = false;
832 for ( it = begin(); it != end(); ++it ) { 832 for ( it = begin(); it != end(); ++it ) {
833 if ( a.uid() == (*it).uid() ) { 833 if ( a.uid() == (*it).uid() ) {
834 found = true; 834 found = true;
835 it2 = it; 835 it2 = it;
836 } else { 836 } else {
837 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 837 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
838 QString name = (*it).uid().mid( 19 ); 838 QString name = (*it).uid().mid( 19 );
839 Addressee b = a; 839 Addressee b = a;
840 QString id = b.getID( name ); 840 QString id = b.getID( name );
841 if ( ! id.isEmpty() ) { 841 if ( ! id.isEmpty() ) {
842 QString des = (*it).note(); 842 QString des = (*it).note();
843 if( des.find( id ) < 0 ) { 843 if( des.find( id ) < 0 ) {
844 des += id + ","; 844 des += id + ",";
845 (*it).setNote( des ); 845 (*it).setNote( des );
846 } 846 }
847 } 847 }
848 } 848 }
849 849
850 } 850 }
851 } 851 }
852 852
853 if ( found ) 853 if ( found )
854 removeAddressee( it2 ); 854 removeAddressee( it2 );
855 855
856} 856}
857 857
858void AddressBook::removeSyncAddressees( bool removeDeleted ) 858void AddressBook::removeSyncAddressees( bool removeDeleted )
859{ 859{
860 Iterator it = begin(); 860 Iterator it = begin();
861 Iterator it2 ; 861 Iterator it2 ;
862 QDateTime dt ( QDate( 2004,1,1) ); 862 QDateTime dt ( QDate( 2004,1,1) );
863 while ( it != end() ) { 863 while ( it != end() ) {
864 (*it).setRevision( dt ); 864 (*it).setRevision( dt );
865 if (( *it).IDStr() != "changed" ) { 865 if (( *it).IDStr() != "changed" ) {
866 // "changed" is used for tagging changed addressees when syncing with KDE or OL 866 // "changed" is used for tagging changed addressees when syncing with KDE or OL
867 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 867 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
868 (*it).setIDStr(""); 868 (*it).setIDStr("");
869 } 869 }
870 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 870 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
871 it2 = it; 871 it2 = it;
872 //qDebug("removing %s ",(*it).uid().latin1() ); 872 //qDebug("removing %s ",(*it).uid().latin1() );
873 ++it; 873 ++it;
874 removeAddressee( it2 ); 874 removeAddressee( it2 );
875 } else { 875 } else {
876 //qDebug("skipping %s ",(*it).uid().latin1() ); 876 //qDebug("skipping %s ",(*it).uid().latin1() );
877 if ( removeDeleted ) {
878 // we have no postprocessing in the resource, we have to do it here
879 // we have to compute csum for all, because it could be the first sync
880 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
881
882
883 }
877 ++it; 884 ++it;
878 } 885 }
879 } 886 }
880 deleteRemovedAddressees(); 887 deleteRemovedAddressees();
881} 888}
882 889
883void AddressBook::removeAddressee( const Iterator &it ) 890void AddressBook::removeAddressee( const Iterator &it )
884{ 891{
885 d->mRemovedAddressees.append( (*it) ); 892 d->mRemovedAddressees.append( (*it) );
886 d->mAddressees.remove( it.d->mIt ); 893 d->mAddressees.remove( it.d->mIt );
887} 894}
888 895
889AddressBook::Iterator AddressBook::find( const Addressee &a ) 896AddressBook::Iterator AddressBook::find( const Addressee &a )
890{ 897{
891 Iterator it; 898 Iterator it;
892 for ( it = begin(); it != end(); ++it ) { 899 for ( it = begin(); it != end(); ++it ) {
893 if ( a.uid() == (*it).uid() ) { 900 if ( a.uid() == (*it).uid() ) {
894 return it; 901 return it;
895 } 902 }
896 } 903 }
897 return end(); 904 return end();
898} 905}
899 906
900Addressee AddressBook::findByUid( const QString &uid ) 907Addressee AddressBook::findByUid( const QString &uid )
901{ 908{
902 Iterator it; 909 Iterator it;
903 for ( it = begin(); it != end(); ++it ) { 910 for ( it = begin(); it != end(); ++it ) {
904 if ( uid == (*it).uid() ) { 911 if ( uid == (*it).uid() ) {
905 return *it; 912 return *it;
906 } 913 }
907 } 914 }
908 return Addressee(); 915 return Addressee();
909} 916}
910void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 917void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
911{ 918{
912 //qDebug("AddressBook::preExternSync "); 919 //qDebug("AddressBook::preExternSync ");
913 AddressBook::Iterator it; 920 AddressBook::Iterator it;
914 for ( it = begin(); it != end(); ++it ) { 921 for ( it = begin(); it != end(); ++it ) {
915 (*it).setID( csd, (*it).externalUID() ); 922 (*it).setID( csd, (*it).externalUID() );
916 (*it).computeCsum( csd ); 923 (*it).computeCsum( csd );
917 } 924 }
918 mergeAB( aBook ,csd, isSubset ); 925 mergeAB( aBook ,csd, isSubset );
919} 926}
920void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 927void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
921{ 928{
922 //qDebug("AddressBook::postExternSync "); 929 //qDebug("AddressBook::postExternSync ");
923 AddressBook::Iterator it; 930 AddressBook::Iterator it;
924 for ( it = begin(); it != end(); ++it ) { 931 for ( it = begin(); it != end(); ++it ) {
925 // qDebug("check uid %s ", (*it).uid().latin1() ); 932 //qDebug("check uid %s ", (*it).uid().latin1() );
926 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 933 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
927 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 934 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
928 Addressee ad = aBook->findByUid( ( (*it).uid() )); 935 Addressee ad = aBook->findByUid( ( (*it).uid() ));
929 if ( ad.isEmpty() ) { 936 if ( ad.isEmpty() ) {
930 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 937 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
931 } else { 938 } else {
939 (*it).setIDStr(":");
932 (*it).computeCsum( csd ); 940 (*it).computeCsum( csd );
933 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 941 if ( setID ) {
934 ad.setID( csd, (*it).externalUID() ); 942 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
943 ad.setID( csd, (*it).externalUID() );
944 } else
945 ad.setID( csd, "_" );
935 ad.setCsum( csd, (*it).getCsum( csd ) ); 946 ad.setCsum( csd, (*it).getCsum( csd ) );
936 aBook->insertAddressee( ad ); 947 aBook->insertAddressee( ad );
937 } 948 }
938 } 949 }
939 } 950 }
940} 951}
941 952
942bool AddressBook::containsExternalUid( const QString& uid ) 953bool AddressBook::containsExternalUid( const QString& uid )
943{ 954{
944 Iterator it; 955 Iterator it;
945 for ( it = begin(); it != end(); ++it ) { 956 for ( it = begin(); it != end(); ++it ) {
946 if ( uid == (*it).externalUID( ) ) 957 if ( uid == (*it).externalUID( ) )
947 return true; 958 return true;
948 } 959 }
949 return false; 960 return false;
950} 961}
951Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 962Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
952{ 963{
953 Iterator it; 964 Iterator it;
954 for ( it = begin(); it != end(); ++it ) { 965 for ( it = begin(); it != end(); ++it ) {
955 if ( uid == (*it).getID( profile ) ) 966 if ( uid == (*it).getID( profile ) )
956 return (*it); 967 return (*it);
957 } 968 }
958 return Addressee(); 969 return Addressee();
959} 970}
960void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) 971void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
961{ 972{
962 Iterator it; 973 Iterator it;
963 Addressee ad; 974 Addressee ad;
964 for ( it = begin(); it != end(); ++it ) { 975 for ( it = begin(); it != end(); ++it ) {
965 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 976 ad = aBook->findByExternUid( (*it).externalUID(), profile );
966 if ( !ad.isEmpty() ) { 977 if ( !ad.isEmpty() ) {
967 (*it).mergeContact( ad ,isSubset); 978 (*it).mergeContact( ad ,isSubset);
968 } 979 }
969 } 980 }
970#if 0 981#if 0
971 // test only 982 // test only
972 for ( it = begin(); it != end(); ++it ) { 983 for ( it = begin(); it != end(); ++it ) {
973 984
974 qDebug("uid %s ", (*it).uid().latin1()); 985 qDebug("uid %s ", (*it).uid().latin1());
975 } 986 }
976#endif 987#endif
977} 988}
978 989
979#if 0 990#if 0
980Addressee::List AddressBook::getExternLastSyncAddressees() 991Addressee::List AddressBook::getExternLastSyncAddressees()
981{ 992{
982 Addressee::List results; 993 Addressee::List results;
983 994
984 Iterator it; 995 Iterator it;
985 for ( it = begin(); it != end(); ++it ) { 996 for ( it = begin(); it != end(); ++it ) {
986 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 997 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
987 if ( (*it).familyName().left(4) == "!E: " ) 998 if ( (*it).familyName().left(4) == "!E: " )
988 results.append( *it ); 999 results.append( *it );
989 } 1000 }
990 } 1001 }
991 1002
992 return results; 1003 return results;
993} 1004}
994#endif 1005#endif
995void AddressBook::resetTempSyncStat() 1006void AddressBook::resetTempSyncStat()
996{ 1007{
997 Iterator it; 1008 Iterator it;
998 for ( it = begin(); it != end(); ++it ) { 1009 for ( it = begin(); it != end(); ++it ) {
999 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 1010 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
1000 } 1011 }
1001 1012
1002} 1013}
1003 1014
1004QStringList AddressBook:: uidList() 1015QStringList AddressBook:: uidList()
1005{ 1016{
1006 QStringList results; 1017 QStringList results;
1007 Iterator it; 1018 Iterator it;
1008 for ( it = begin(); it != end(); ++it ) { 1019 for ( it = begin(); it != end(); ++it ) {
1009 results.append( (*it).uid() ); 1020 results.append( (*it).uid() );
1010 } 1021 }
1011 return results; 1022 return results;
1012} 1023}
1013 1024
1014 1025
1015Addressee::List AddressBook::allAddressees() 1026Addressee::List AddressBook::allAddressees()
1016{ 1027{
1017 return d->mAddressees; 1028 return d->mAddressees;
1018 1029
1019} 1030}
1020 1031
1021Addressee::List AddressBook::findByName( const QString &name ) 1032Addressee::List AddressBook::findByName( const QString &name )
1022{ 1033{
1023 Addressee::List results; 1034 Addressee::List results;
1024 1035
1025 Iterator it; 1036 Iterator it;
1026 for ( it = begin(); it != end(); ++it ) { 1037 for ( it = begin(); it != end(); ++it ) {
1027 if ( name == (*it).realName() ) { 1038 if ( name == (*it).realName() ) {
1028 results.append( *it ); 1039 results.append( *it );
1029 } 1040 }
1030 } 1041 }
1031 1042
1032 return results; 1043 return results;
1033} 1044}
1034 1045
1035Addressee::List AddressBook::findByEmail( const QString &email ) 1046Addressee::List AddressBook::findByEmail( const QString &email )
1036{ 1047{
1037 Addressee::List results; 1048 Addressee::List results;
1038 QStringList mailList; 1049 QStringList mailList;
1039 1050
1040 Iterator it; 1051 Iterator it;
1041 for ( it = begin(); it != end(); ++it ) { 1052 for ( it = begin(); it != end(); ++it ) {
1042 mailList = (*it).emails(); 1053 mailList = (*it).emails();
1043 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 1054 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1044 if ( email == (*ite) ) { 1055 if ( email == (*ite) ) {
1045 results.append( *it ); 1056 results.append( *it );
1046 } 1057 }
1047 } 1058 }
1048 } 1059 }
1049 1060
1050 return results; 1061 return results;
1051} 1062}
1052 1063
1053Addressee::List AddressBook::findByCategory( const QString &category ) 1064Addressee::List AddressBook::findByCategory( const QString &category )
1054{ 1065{
1055 Addressee::List results; 1066 Addressee::List results;
1056 1067
1057 Iterator it; 1068 Iterator it;
1058 for ( it = begin(); it != end(); ++it ) { 1069 for ( it = begin(); it != end(); ++it ) {
1059 if ( (*it).hasCategory( category) ) { 1070 if ( (*it).hasCategory( category) ) {
1060 results.append( *it ); 1071 results.append( *it );
1061 } 1072 }
1062 } 1073 }
1063 1074
1064 return results; 1075 return results;
1065} 1076}
1066 1077
1067void AddressBook::dump() const 1078void AddressBook::dump() const
1068{ 1079{
1069 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 1080 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
1070 1081
1071 ConstIterator it; 1082 ConstIterator it;
1072 for( it = begin(); it != end(); ++it ) { 1083 for( it = begin(); it != end(); ++it ) {
1073 (*it).dump(); 1084 (*it).dump();
1074 } 1085 }
1075 1086
1076 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 1087 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
1077} 1088}
1078 1089
1079QString AddressBook::identifier() 1090QString AddressBook::identifier()
1080{ 1091{
1081 QStringList identifier; 1092 QStringList identifier;
1082 1093
1083 1094
1084 KRES::Manager<Resource>::ActiveIterator it; 1095 KRES::Manager<Resource>::ActiveIterator it;
1085 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1096 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1086 if ( !(*it)->identifier().isEmpty() ) 1097 if ( !(*it)->identifier().isEmpty() )
1087 identifier.append( (*it)->identifier() ); 1098 identifier.append( (*it)->identifier() );
1088 } 1099 }
1089 1100
1090 return identifier.join( ":" ); 1101 return identifier.join( ":" );
1091} 1102}
1092 1103
1093Field::List AddressBook::fields( int category ) 1104Field::List AddressBook::fields( int category )
1094{ 1105{
1095 if ( d->mAllFields.isEmpty() ) { 1106 if ( d->mAllFields.isEmpty() ) {
1096 d->mAllFields = Field::allFields(); 1107 d->mAllFields = Field::allFields();
1097 } 1108 }
1098 1109
1099 if ( category == Field::All ) return d->mAllFields; 1110 if ( category == Field::All ) return d->mAllFields;
1100 1111
1101 Field::List result; 1112 Field::List result;
1102 Field::List::ConstIterator it; 1113 Field::List::ConstIterator it;
1103 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 1114 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
1104 if ( (*it)->category() & category ) result.append( *it ); 1115 if ( (*it)->category() & category ) result.append( *it );
1105 } 1116 }
1106 1117
1107 return result; 1118 return result;
1108} 1119}
1109 1120
1110bool AddressBook::addCustomField( const QString &label, int category, 1121bool AddressBook::addCustomField( const QString &label, int category,
1111 const QString &key, const QString &app ) 1122 const QString &key, const QString &app )
1112{ 1123{
1113 if ( d->mAllFields.isEmpty() ) { 1124 if ( d->mAllFields.isEmpty() ) {
1114 d->mAllFields = Field::allFields(); 1125 d->mAllFields = Field::allFields();
1115 } 1126 }
1116//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 1127//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
1117 QString a = app.isNull() ? KGlobal::getAppName() : app; 1128 QString a = app.isNull() ? KGlobal::getAppName() : app;
1118 1129
1119 QString k = key.isNull() ? label : key; 1130 QString k = key.isNull() ? label : key;
1120 1131
1121 Field *field = Field::createCustomField( label, category, k, a ); 1132 Field *field = Field::createCustomField( label, category, k, a );
1122 1133
1123 if ( !field ) return false; 1134 if ( !field ) return false;
1124 1135
1125 d->mAllFields.append( field ); 1136 d->mAllFields.append( field );
1126 1137