summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 7bc5bde..c4a7b10 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -773,641 +773,644 @@ bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int w
773 // Something else was selected: Hide combo.. 773 // Something else was selected: Hide combo..
774 qWarning(" Hiding default-email combo" ); 774 qWarning(" Hiding default-email combo" );
775 if ( defaultEmailChooserPosition == widgetPos ){ 775 if ( defaultEmailChooserPosition == widgetPos ){
776 defaultEmailChooserPosition = -1; 776 defaultEmailChooserPosition = -1;
777 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); 777 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
778 if ( cmbo ){ 778 if ( cmbo ){
779 inputStack->raiseWidget( TextField ); 779 inputStack->raiseWidget( TextField );
780 inputStack -> removeWidget( cmbo ); 780 inputStack -> removeWidget( cmbo );
781 cmbDefaultEmail = 0l; 781 cmbDefaultEmail = 0l;
782 delete cmbo; 782 delete cmbo;
783 } 783 }
784 784
785 } 785 }
786 786
787 // Caller should initialize the responsible textfield, therefore 787 // Caller should initialize the responsible textfield, therefore
788 // "false" is returned 788 // "false" is returned
789 return false; 789 return false;
790 } 790 }
791 791
792 // Everything is worked off .. 792 // Everything is worked off ..
793 return true; 793 return true;
794 794
795} 795}
796 796
797// Currently accessed when we select default-email more than once ! 797// Currently accessed when we select default-email more than once !
798void ContactEditor::chooserError( int index ) 798void ContactEditor::chooserError( int index )
799{ 799{
800 qWarning("ContactEditor::chooserError( %d )", index); 800 qWarning("ContactEditor::chooserError( %d )", index);
801 QMessageBox::warning( this, "Chooser Error", 801 QMessageBox::warning( this, "Chooser Error",
802 "Multiple selection of this\n" 802 "Multiple selection of this\n"
803 "Item is not allowed !\n\n" 803 "Item is not allowed !\n\n"
804 "First deselect the previous one !", 804 "First deselect the previous one !",
805 "&OK", 0, 0, 805 "&OK", 0, 0,
806 0, 0 ); 806 0, 0 );
807 807
808 // Reset the selected Chooser. Unfortunately the chooser 808 // Reset the selected Chooser. Unfortunately the chooser
809 // generates no signal, therfore we have to 809 // generates no signal, therfore we have to
810 // call the cmbChooserChange function manually.. 810 // call the cmbChooserChange function manually..
811 switch( index ){ 811 switch( index ){
812 case 1: 812 case 1:
813 cmbChooserField1 -> setCurrentItem( 0 ); 813 cmbChooserField1 -> setCurrentItem( 0 );
814 slotCmbChooser1Change( 0 ); 814 slotCmbChooser1Change( 0 );
815 break; 815 break;
816 case 2: 816 case 2:
817 cmbChooserField2 -> setCurrentItem( 0 ); 817 cmbChooserField2 -> setCurrentItem( 0 );
818 slotCmbChooser2Change( 0 ); 818 slotCmbChooser2Change( 0 );
819 break; 819 break;
820 case 3: 820 case 3:
821 cmbChooserField3 -> setCurrentItem( 0 ); 821 cmbChooserField3 -> setCurrentItem( 0 );
822 slotCmbChooser3Change( 0 ); 822 slotCmbChooser3Change( 0 );
823 break; 823 break;
824 case 4: 824 case 4:
825 cmbChooserField4 -> setCurrentItem( 0 ); 825 cmbChooserField4 -> setCurrentItem( 0 );
826 slotCmbChooser4Change( 0 ); 826 slotCmbChooser4Change( 0 );
827 break; 827 break;
828 } 828 }
829} 829}
830 830
831// Called when something was changed in a textfield (shouldn't it called textchanged? (se)) 831// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
832void ContactEditor::chooserChange( const QString &textChanged, int index, 832void ContactEditor::chooserChange( const QString &textChanged, int index,
833 QLineEdit* , int widgetPos ) { 833 QLineEdit* , int widgetPos ) {
834 834
835 QString type = slChooserNames[index]; // :SX 835 QString type = slChooserNames[index]; // :SX
836 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", 836 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",
837 type.latin1(),textChanged.latin1(), index, widgetPos ); 837 type.latin1(),textChanged.latin1(), index, widgetPos );
838 838
839 if ( type == "Default Email"){ 839 if ( type == "Default Email"){
840 qWarning ("??? Wozu??: %s", textChanged.latin1()); 840 qWarning ("??? Wozu??: %s", textChanged.latin1());
841 defaultEmail = textChanged; 841 defaultEmail = textChanged;
842 842
843 populateDefaultEmailCmb(); 843 populateDefaultEmailCmb();
844 844
845 }else if (type == "Emails"){ 845 }else if (type == "Emails"){
846 qDebug("emails"); 846 qDebug("emails");
847 847
848 QString de; 848 QString de;
849 emails = QStringList::split (",", textChanged ); 849 emails = QStringList::split (",", textChanged );
850 850
851 populateDefaultEmailCmb(); 851 populateDefaultEmailCmb();
852 } 852 }
853 853
854 slChooserValues[index] = textChanged; 854 slChooserValues[index] = textChanged;
855 855
856} 856}
857 857
858void ContactEditor::slotChooser1Change( const QString &textChanged ) { 858void ContactEditor::slotChooser1Change( const QString &textChanged ) {
859 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); 859 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1());
860 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); 860 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
861} 861}
862 862
863void ContactEditor::slotChooser2Change( const QString &textChanged ) { 863void ContactEditor::slotChooser2Change( const QString &textChanged ) {
864 qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1()); 864 qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1());
865 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); 865 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
866 866
867} 867}
868 868
869void ContactEditor::slotChooser3Change( const QString &textChanged ) { 869void ContactEditor::slotChooser3Change( const QString &textChanged ) {
870 qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1()); 870 qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1());
871 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); 871 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
872} 872}
873 873
874void ContactEditor::slotChooser4Change( const QString &textChanged ) { 874void ContactEditor::slotChooser4Change( const QString &textChanged ) {
875 qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1()); 875 qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1());
876 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); 876 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4);
877} 877}
878 878
879void ContactEditor::slotAddressChange( const QString &textChanged ) { 879void ContactEditor::slotAddressChange( const QString &textChanged ) {
880 880
881 if ( cmbAddress->currentItem() == 0 ) { 881 if ( cmbAddress->currentItem() == 0 ) {
882 slBusinessAddress[0] = textChanged; 882 slBusinessAddress[0] = textChanged;
883 } else { 883 } else {
884 slHomeAddress[0] = textChanged; 884 slHomeAddress[0] = textChanged;
885 } 885 }
886} 886}
887 887
888void ContactEditor::slotAddress2Change( const QString &textChanged ) { 888void ContactEditor::slotAddress2Change( const QString &textChanged ) {
889 889
890 if ( cmbAddress->currentItem() == 0 ) { 890 if ( cmbAddress->currentItem() == 0 ) {
891 slBusinessAddress[1] = textChanged; 891 slBusinessAddress[1] = textChanged;
892 } else { 892 } else {
893 slHomeAddress[1] = textChanged; 893 slHomeAddress[1] = textChanged;
894 } 894 }
895} 895}
896 896
897void ContactEditor::slotPOBoxChange( const QString &textChanged ) { 897void ContactEditor::slotPOBoxChange( const QString &textChanged ) {
898 898
899 if ( cmbAddress->currentItem() == 0 ) { 899 if ( cmbAddress->currentItem() == 0 ) {
900 slBusinessAddress[2] = textChanged; 900 slBusinessAddress[2] = textChanged;
901 } else { 901 } else {
902 slHomeAddress[2] = textChanged; 902 slHomeAddress[2] = textChanged;
903 } 903 }
904} 904}
905 905
906void ContactEditor::slotCityChange( const QString &textChanged ) { 906void ContactEditor::slotCityChange( const QString &textChanged ) {
907 907
908 if ( cmbAddress->currentItem() == 0 ) { 908 if ( cmbAddress->currentItem() == 0 ) {
909 slBusinessAddress[3] = textChanged; 909 slBusinessAddress[3] = textChanged;
910 } else { 910 } else {
911 slHomeAddress[3] = textChanged; 911 slHomeAddress[3] = textChanged;
912 } 912 }
913} 913}
914 914
915void ContactEditor::slotStateChange( const QString &textChanged ) { 915void ContactEditor::slotStateChange( const QString &textChanged ) {
916 916
917 917
918 if ( cmbAddress->currentItem() == 0 ) { 918 if ( cmbAddress->currentItem() == 0 ) {
919 slBusinessAddress[4] = textChanged; 919 slBusinessAddress[4] = textChanged;
920 } else { 920 } else {
921 slHomeAddress[4] = textChanged; 921 slHomeAddress[4] = textChanged;
922 } 922 }
923} 923}
924 924
925void ContactEditor::slotZipChange( const QString &textChanged ) { 925void ContactEditor::slotZipChange( const QString &textChanged ) {
926 926
927 if ( cmbAddress->currentItem() == 0 ) { 927 if ( cmbAddress->currentItem() == 0 ) {
928 slBusinessAddress[5] = textChanged; 928 slBusinessAddress[5] = textChanged;
929 } else { 929 } else {
930 slHomeAddress[5] = textChanged; 930 slHomeAddress[5] = textChanged;
931 } 931 }
932} 932}
933 933
934void ContactEditor::slotCountryChange( const QString &textChanged ) { 934void ContactEditor::slotCountryChange( const QString &textChanged ) {
935 935
936 if ( cmbAddress->currentItem() == 0 ) { 936 if ( cmbAddress->currentItem() == 0 ) {
937 slBusinessAddress[6] = textChanged; 937 slBusinessAddress[6] = textChanged;
938 } else { 938 } else {
939 slHomeAddress[6] = textChanged; 939 slHomeAddress[6] = textChanged;
940 } 940 }
941} 941}
942 942
943 943
944void ContactEditor::slotCmbChooser1Change( int index ) { 944void ContactEditor::slotCmbChooser1Change( int index ) {
945 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); 945 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index);
946 if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){ 946 if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){
947 947
948 txtChooserField1->setText( slChooserValues[index] ); 948 txtChooserField1->setText( slChooserValues[index] );
949 txtChooserField1->setFocus(); 949 txtChooserField1->setFocus();
950 950
951 } 951 }
952 952
953} 953}
954 954
955void ContactEditor::slotCmbChooser2Change( int index ) { 955void ContactEditor::slotCmbChooser2Change( int index ) {
956 qWarning("ContactEditor::slotCmbChooser2Change( %d )", index); 956 qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
957 957
958 if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){ 958 if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){
959 959
960 txtChooserField2->setText( slChooserValues[index] ); 960 txtChooserField2->setText( slChooserValues[index] );
961 txtChooserField2->setFocus(); 961 txtChooserField2->setFocus();
962 962
963 } 963 }
964} 964}
965 965
966void ContactEditor::slotCmbChooser3Change( int index ) { 966void ContactEditor::slotCmbChooser3Change( int index ) {
967 qWarning("ContactEditor::slotCmbChooser3Change( %d )", index); 967 qWarning("ContactEditor::slotCmbChooser3Change( %d )", index);
968 968
969 if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){ 969 if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){
970 970
971 txtChooserField3->setText( slChooserValues[index] ); 971 txtChooserField3->setText( slChooserValues[index] );
972 txtChooserField3->setFocus(); 972 txtChooserField3->setFocus();
973 973
974 } 974 }
975} 975}
976 976
977void ContactEditor::slotCmbChooser4Change( int index ) { 977void ContactEditor::slotCmbChooser4Change( int index ) {
978 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); 978 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
979 979
980 if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){ 980 if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){
981 981
982 txtChooserField4->setText( slChooserValues[index] ); 982 txtChooserField4->setText( slChooserValues[index] );
983 txtChooserField4->setFocus(); 983 txtChooserField4->setFocus();
984 984
985 } 985 }
986} 986}
987 987
988void ContactEditor::slotAddressTypeChange( int index ) { 988void ContactEditor::slotAddressTypeChange( int index ) {
989 989
990 990
991 if ( !initializing ) 991 if ( !initializing )
992 contactfields.setFieldOrder( 4, index ); 992 contactfields.setFieldOrder( 4, index );
993 993
994 994
995 if ( index == 0 ) { 995 if ( index == 0 ) {
996 996
997 txtAddress->setText( slBusinessAddress[0] ); 997 txtAddress->setText( slBusinessAddress[0] );
998 //txtAddress2->setText( (*slBusinessAddress)[1] ); 998 //txtAddress2->setText( (*slBusinessAddress)[1] );
999 //txtPOBox->setText( (*slBusinessAddress)[2] ); 999 //txtPOBox->setText( (*slBusinessAddress)[2] );
1000 txtCity->setText( slBusinessAddress[3] ); 1000 txtCity->setText( slBusinessAddress[3] );
1001 txtState->setText( slBusinessAddress[4] ); 1001 txtState->setText( slBusinessAddress[4] );
1002 txtZip->setText( slBusinessAddress[5] ); 1002 txtZip->setText( slBusinessAddress[5] );
1003 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1003 QLineEdit *txtTmp = cmbCountry->lineEdit();
1004 txtTmp->setText( slBusinessAddress[6] ); 1004 txtTmp->setText( slBusinessAddress[6] );
1005 1005
1006 } else { 1006 } else {
1007 1007
1008 txtAddress->setText( slHomeAddress[0] ); 1008 txtAddress->setText( slHomeAddress[0] );
1009 //txtAddress2->setText( (*slHomeAddress)[1] ); 1009 //txtAddress2->setText( (*slHomeAddress)[1] );
1010 //txtPOBox->setText( (*slHomeAddress)[2] ); 1010 //txtPOBox->setText( (*slHomeAddress)[2] );
1011 txtCity->setText( slHomeAddress[3] ); 1011 txtCity->setText( slHomeAddress[3] );
1012 txtState->setText( slHomeAddress[4] ); 1012 txtState->setText( slHomeAddress[4] );
1013 txtZip->setText( slHomeAddress[5] ); 1013 txtZip->setText( slHomeAddress[5] );
1014 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1014 QLineEdit *txtTmp = cmbCountry->lineEdit();
1015 txtTmp->setText( slHomeAddress[6] ); 1015 txtTmp->setText( slHomeAddress[6] );
1016 1016
1017 } 1017 }
1018 1018
1019} 1019}
1020 1020
1021void ContactEditor::slotFullNameChange( const QString &textChanged ) { 1021void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1022 1022
1023 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() ); 1023 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() );
1024 1024
1025 int index = cmbFileAs->currentItem(); 1025 int index = cmbFileAs->currentItem();
1026 1026
1027 cmbFileAs->clear(); 1027 cmbFileAs->clear();
1028 1028
1029 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) );
1030 cmbFileAs->insertItem( parseName( textChanged, NAME_FMLS ) );
1031 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) ); 1029 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) );
1032 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) ); 1030 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) );
1031 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) );
1032 cmbFileAs->insertItem( parseName( textChanged, NAME_FMLS ) );
1033 1033
1034 cmbFileAs->setCurrentItem( index ); 1034 cmbFileAs->setCurrentItem( index );
1035 1035
1036 useFullName = true; 1036 useFullName = true;
1037 1037
1038} 1038}
1039 1039
1040void ContactEditor::accept() { 1040void ContactEditor::accept() {
1041 1041
1042 if ( isEmpty() ) { 1042 if ( isEmpty() ) {
1043 cleanupFields(); 1043 cleanupFields();
1044 reject(); 1044 reject();
1045 } else { 1045 } else {
1046 saveEntry(); 1046 saveEntry();
1047 cleanupFields(); 1047 cleanupFields();
1048 QDialog::accept(); 1048 QDialog::accept();
1049 } 1049 }
1050 1050
1051} 1051}
1052 1052
1053void ContactEditor::slotNote() { 1053void ContactEditor::slotNote() {
1054 1054
1055 dlgNote->showMaximized(); 1055 dlgNote->showMaximized();
1056 if ( !dlgNote->exec() ) { 1056 if ( !dlgNote->exec() ) {
1057 txtNote->setText( ent.notes() ); 1057 txtNote->setText( ent.notes() );
1058 } 1058 }
1059} 1059}
1060 1060
1061void ContactEditor::slotName() { 1061void ContactEditor::slotName() {
1062 1062
1063 QString tmpName; 1063 QString tmpName;
1064 if (useFullName) { 1064 if (useFullName) {
1065 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 1065 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
1066 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 1066 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
1067 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1067 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1068 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1068 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1069 } 1069 }
1070 dlgName->showMaximized(); 1070 dlgName->showMaximized();
1071 if ( dlgName->exec() ) { 1071 if ( dlgName->exec() ) {
1072 1072
1073 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); 1073 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text();
1074 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 1074 txtFullName->setText( tmpName.simplifyWhiteSpace() );
1075 slotFullNameChange( txtFullName->text() ); 1075 slotFullNameChange( txtFullName->text() );
1076 useFullName = false; 1076 useFullName = false;
1077 } 1077 }
1078 1078
1079} 1079}
1080 1080
1081void ContactEditor::setNameFocus() { 1081void ContactEditor::setNameFocus() {
1082 1082
1083 txtFullName->setFocus(); 1083 txtFullName->setFocus();
1084 1084
1085} 1085}
1086 1086
1087bool ContactEditor::isEmpty() { 1087bool ContactEditor::isEmpty() {
1088 // Test and see if the record should be saved. 1088 // Test and see if the record should be saved.
1089 // More strict than the original qtopia, needs name or fileas to save 1089 // More strict than the original qtopia, needs name or fileas to save
1090 1090
1091 QString t = txtFullName->text(); 1091 QString t = txtFullName->text();
1092 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1092 if ( !t.isEmpty() && containsAlphaNum( t ) )
1093 return false; 1093 return false;
1094 1094
1095 t = cmbFileAs->currentText(); 1095 t = cmbFileAs->currentText();
1096 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1096 if ( !t.isEmpty() && containsAlphaNum( t ) )
1097 return false; 1097 return false;
1098 1098
1099 return true; 1099 return true;
1100 1100
1101} 1101}
1102 1102
1103QString ContactEditor::parseName( const QString fullName, int type ) { 1103QString ContactEditor::parseName( const QString fullName, int type ) {
1104 1104
1105 QString simplifiedName( fullName.simplifyWhiteSpace() ); 1105 QString simplifiedName( fullName.simplifyWhiteSpace() );
1106 QString strFirstName; 1106 QString strFirstName;
1107 QString strMiddleName; 1107 QString strMiddleName;
1108 QString strLastName; 1108 QString strLastName;
1109 QString strSuffix; 1109 QString strSuffix;
1110 QString strTitle; 1110 QString strTitle;
1111 int commapos; 1111 int commapos;
1112 bool haveLastName = false; 1112 bool haveLastName = false;
1113 1113
1114 qWarning("Fullname: %s", simplifiedName.latin1()); 1114 qWarning("Fullname: %s", simplifiedName.latin1());
1115 1115
1116 commapos = simplifiedName.find( ',', 0, TRUE); 1116 commapos = simplifiedName.find( ',', 0, TRUE);
1117 if ( commapos >= 0 ) { 1117 if ( commapos >= 0 ) {
1118 qWarning(" Commapos: %d", commapos ); 1118 qWarning(" Commapos: %d", commapos );
1119 1119
1120 // A comma (",") separates the lastname from one or 1120 // A comma (",") separates the lastname from one or
1121 // many first names. Thus, remove the lastname from the 1121 // many first names. Thus, remove the lastname from the
1122 // String and parse the firstnames. 1122 // String and parse the firstnames.
1123 1123
1124 strLastName = simplifiedName.left( commapos ); 1124 strLastName = simplifiedName.left( commapos );
1125 simplifiedName= simplifiedName.mid( commapos + 1 ); 1125 simplifiedName= simplifiedName.mid( commapos + 1 );
1126 haveLastName = true; 1126 haveLastName = true;
1127 qWarning("Fullname without ',': %s", simplifiedName.latin1()); 1127 qWarning("Fullname without ',': %s", simplifiedName.latin1());
1128 1128
1129 // If we have any lastname, we should now split all first names. 1129 // If we have any lastname, we should now split all first names.
1130 // The first one will be the used as first, the rest as "middle names" 1130 // The first one will be the used as first, the rest as "middle names"
1131 1131
1132 QStringList allFirstNames = QStringList::split(" ", simplifiedName); 1132 QStringList allFirstNames = QStringList::split(" ", simplifiedName);
1133 QStringList::Iterator it = allFirstNames.begin(); 1133 QStringList::Iterator it = allFirstNames.begin();
1134 strFirstName = *it++; 1134 strFirstName = *it++;
1135 QStringList allSecondNames; 1135 QStringList allSecondNames;
1136 for ( ; it != allFirstNames.end(); ++it ) 1136 for ( ; it != allFirstNames.end(); ++it )
1137 allSecondNames.append( *it ); 1137 allSecondNames.append( *it );
1138 1138
1139 strMiddleName = allSecondNames.join(" "); 1139 strMiddleName = allSecondNames.join(" ");
1140 1140
1141 } else { 1141 } else {
1142 1142
1143 // No comma separator used: We use the first word as firstname, the 1143 // No comma separator used: We use the first word as firstname, the
1144 // last as second/lastname and everything in the middle as middlename 1144 // last as second/lastname and everything in the middle as middlename
1145 1145
1146 QStringList allNames = QStringList::split(" ", simplifiedName); 1146 QStringList allNames = QStringList::split(" ", simplifiedName);
1147 QStringList::Iterator it = allNames.begin(); 1147 QStringList::Iterator it = allNames.begin();
1148 strFirstName = *it++; 1148 strFirstName = *it++;
1149 QStringList allSecondNames; 1149 QStringList allSecondNames;
1150 for ( ; it != --allNames.end(); ++it ) 1150 for ( ; it != --allNames.end(); ++it )
1151 allSecondNames.append( *it ); 1151 allSecondNames.append( *it );
1152 1152
1153 strMiddleName = allSecondNames.join(" "); 1153 strMiddleName = allSecondNames.join(" ");
1154 strLastName = *(--allNames.end()); 1154 strLastName = *(--allNames.end());
1155 1155
1156 } 1156 }
1157 1157
1158 if ( strFirstName == strLastName )
1159 strFirstName = "";
1160
1158 qWarning(" strFirstName: %s", strFirstName.latin1()); 1161 qWarning(" strFirstName: %s", strFirstName.latin1());
1159 qWarning(" strMiddleName: %s", strMiddleName.latin1()); 1162 qWarning(" strMiddleName: %s", strMiddleName.latin1());
1160 qWarning(" strLastName: %s", strLastName.latin1()); 1163 qWarning(" strLastName: %s", strLastName.latin1());
1161 qWarning(" strSuffix: %s", strSuffix.latin1()); 1164 qWarning(" strSuffix: %s", strSuffix.latin1());
1162 qWarning(" strTitle: %s", strTitle.latin1()); 1165 qWarning(" strTitle: %s", strTitle.latin1());
1163 1166
1164 switch (type) { 1167 switch (type) {
1165 case NAME_FL: 1168 case NAME_FL:
1166 return strFirstName + " " + strLastName; 1169 return strFirstName + " " + strLastName;
1167 1170
1168 case NAME_LF: 1171 case NAME_LF:
1169 return strLastName + ", " + strFirstName; 1172 return strLastName + ", " + strFirstName;
1170 1173
1171 case NAME_LFM: 1174 case NAME_LFM:
1172 return strLastName + ", " + strFirstName + " " + strMiddleName; 1175 return strLastName + ", " + strFirstName + " " + strMiddleName;
1173 1176
1174 case NAME_FMLS: 1177 case NAME_FMLS:
1175 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; 1178 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix;
1176 1179
1177 case NAME_F: 1180 case NAME_F:
1178 return strFirstName; 1181 return strFirstName;
1179 1182
1180 case NAME_M: 1183 case NAME_M:
1181 return strMiddleName; 1184 return strMiddleName;
1182 1185
1183 case NAME_L: 1186 case NAME_L:
1184 return strLastName; 1187 return strLastName;
1185 1188
1186 case NAME_S: 1189 case NAME_S:
1187 return strSuffix; 1190 return strSuffix;
1188 1191
1189 } 1192 }
1190 return QString::null; 1193 return QString::null;
1191} 1194}
1192 1195
1193void ContactEditor::cleanupFields() { 1196void ContactEditor::cleanupFields() {
1194 QStringList::Iterator it = slChooserValues.begin(); 1197 QStringList::Iterator it = slChooserValues.begin();
1195 1198
1196 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { 1199 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
1197 (*it) = ""; 1200 (*it) = "";
1198 } 1201 }
1199 1202
1200 for ( int i = 0; i < 7; i++ ) { 1203 for ( int i = 0; i < 7; i++ ) {
1201 slHomeAddress[i] = ""; 1204 slHomeAddress[i] = "";
1202 slBusinessAddress[i] = ""; 1205 slBusinessAddress[i] = "";
1203 } 1206 }
1204 1207
1205 QListIterator<QLineEdit> itLV( listValue ); 1208 QListIterator<QLineEdit> itLV( listValue );
1206 for ( ; itLV.current(); ++itLV ) { 1209 for ( ; itLV.current(); ++itLV ) {
1207 (*itLV)->setText( "" ); 1210 (*itLV)->setText( "" );
1208 } 1211 }
1209 1212
1210 txtFirstName->setText(""); 1213 txtFirstName->setText("");
1211 txtMiddleName->setText(""); 1214 txtMiddleName->setText("");
1212 txtLastName->setText(""); 1215 txtLastName->setText("");
1213 txtSuffix->setText(""); 1216 txtSuffix->setText("");
1214 txtNote->setText(""); 1217 txtNote->setText("");
1215 txtFullName->setText(""); 1218 txtFullName->setText("");
1216 txtJobTitle->setText(""); 1219 txtJobTitle->setText("");
1217 txtOrganization->setText(""); 1220 txtOrganization->setText("");
1218 txtChooserField1->setText(""); 1221 txtChooserField1->setText("");
1219 txtChooserField2->setText(""); 1222 txtChooserField2->setText("");
1220 txtChooserField3->setText(""); 1223 txtChooserField3->setText("");
1221 txtAddress->setText(""); 1224 txtAddress->setText("");
1222 txtCity->setText(""); 1225 txtCity->setText("");
1223 txtState->setText(""); 1226 txtState->setText("");
1224 txtZip->setText(""); 1227 txtZip->setText("");
1225 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1228 QLineEdit *txtTmp = cmbCountry->lineEdit();
1226 txtTmp->setText(""); 1229 txtTmp->setText("");
1227 txtTmp = cmbFileAs->lineEdit(); 1230 txtTmp = cmbFileAs->lineEdit();
1228 txtTmp->setText(""); 1231 txtTmp->setText("");
1229 1232
1230} 1233}
1231 1234
1232void ContactEditor::setEntry( const OContact &entry ) { 1235void ContactEditor::setEntry( const OContact &entry ) {
1233 1236
1234 initializing = true; 1237 initializing = true;
1235 1238
1236 cleanupFields(); 1239 cleanupFields();
1237 1240
1238 ent = entry; 1241 ent = entry;
1239 1242
1240 emails = QStringList(ent.emailList()); 1243 emails = QStringList(ent.emailList());
1241 defaultEmail = ent.defaultEmail(); 1244 defaultEmail = ent.defaultEmail();
1242 if (defaultEmail.isEmpty()) defaultEmail = emails[0]; 1245 if (defaultEmail.isEmpty()) defaultEmail = emails[0];
1243 qDebug("default email=%s",defaultEmail.latin1()); 1246 qDebug("default email=%s",defaultEmail.latin1());
1244 1247
1245 useFullName = false; 1248 useFullName = false;
1246 txtFirstName->setText( ent.firstName() ); 1249 txtFirstName->setText( ent.firstName() );
1247 txtMiddleName->setText( ent.middleName() ); 1250 txtMiddleName->setText( ent.middleName() );
1248 txtLastName->setText( ent.lastName() ); 1251 txtLastName->setText( ent.lastName() );
1249 txtSuffix->setText( ent.suffix() ); 1252 txtSuffix->setText( ent.suffix() );
1250 1253
1251 // QString *tmpString = new QString; 1254 // QString *tmpString = new QString;
1252 // *tmpString = ent.firstName() + " " + ent.middleName() + 1255 // *tmpString = ent.firstName() + " " + ent.middleName() +
1253 // + " " + ent.lastName() + " " + ent.suffix(); 1256 // + " " + ent.lastName() + " " + ent.suffix();
1254 //txtFullName->setText( tmpString->simplifyWhiteSpace() ); 1257 //txtFullName->setText( tmpString->simplifyWhiteSpace() );
1255 1258
1256 // Lastnames with multiple words need to be protected by a comma ! 1259 // Lastnames with multiple words need to be protected by a comma !
1257 if ( ent.lastName().contains( ' ', TRUE ) ) 1260 if ( ent.lastName().contains( ' ', TRUE ) )
1258 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); 1261 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
1259 else 1262 else
1260 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); 1263 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
1261 1264
1262 cmbFileAs->setEditText( ent.fileAs() ); 1265 cmbFileAs->setEditText( ent.fileAs() );
1263 1266
1264 //if (hasTitle) 1267 //if (hasTitle)
1265 txtJobTitle->setText( ent.jobTitle() ); 1268 txtJobTitle->setText( ent.jobTitle() );
1266 1269
1267 //if (hasCompany) 1270 //if (hasCompany)
1268 txtOrganization->setText( ent.company() ); 1271 txtOrganization->setText( ent.company() );
1269 1272
1270 //if (hasNotes) 1273 //if (hasNotes)
1271 txtNote->setText( ent.notes() ); 1274 txtNote->setText( ent.notes() );
1272 1275
1273 //if (hasStreet) { 1276 //if (hasStreet) {
1274 slHomeAddress[0] = ent.homeStreet(); 1277 slHomeAddress[0] = ent.homeStreet();
1275 slBusinessAddress[0] = ent.businessStreet(); 1278 slBusinessAddress[0] = ent.businessStreet();
1276 //} 1279 //}
1277 1280
1278 //if (hasCity) { 1281 //if (hasCity) {
1279 slHomeAddress[3] = ent.homeCity(); 1282 slHomeAddress[3] = ent.homeCity();
1280 slBusinessAddress[3] = ent.businessCity(); 1283 slBusinessAddress[3] = ent.businessCity();
1281 //} 1284 //}
1282 1285
1283 //if (hasState) { 1286 //if (hasState) {
1284 slHomeAddress[4] = ent.homeState(); 1287 slHomeAddress[4] = ent.homeState();
1285 slBusinessAddress[4] = ent.businessState(); 1288 slBusinessAddress[4] = ent.businessState();
1286 //} 1289 //}
1287 1290
1288 //if (hasZip) { 1291 //if (hasZip) {
1289 slHomeAddress[5] = ent.homeZip(); 1292 slHomeAddress[5] = ent.homeZip();
1290 slBusinessAddress[5] = ent.businessZip(); 1293 slBusinessAddress[5] = ent.businessZip();
1291 //} 1294 //}
1292 1295
1293 //if (hasCountry) { 1296 //if (hasCountry) {
1294 slHomeAddress[6] = ent.homeCountry(); 1297 slHomeAddress[6] = ent.homeCountry();
1295 slBusinessAddress[6] = ent.businessCountry(); 1298 slBusinessAddress[6] = ent.businessCountry();
1296 //} 1299 //}
1297 1300
1298 QStringList::ConstIterator it; 1301 QStringList::ConstIterator it;
1299 QListIterator<QLineEdit> itLE( listValue ); 1302 QListIterator<QLineEdit> itLE( listValue );
1300 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { 1303 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
1301 1304
1302 qWarning(" Filling dynamic Field: %s", (*it).latin1() ); 1305 qWarning(" Filling dynamic Field: %s", (*it).latin1() );
1303 1306
1304 if ( *it == "Department" ) 1307 if ( *it == "Department" )
1305 (*itLE)->setText( ent.department() ); 1308 (*itLE)->setText( ent.department() );
1306 1309
1307 if ( *it == "Company" ) 1310 if ( *it == "Company" )
1308 (*itLE)->setText( ent.company() ); 1311 (*itLE)->setText( ent.company() );
1309 1312
1310 if ( *it == "Office" ) 1313 if ( *it == "Office" )
1311 (*itLE)->setText( ent.office() ); 1314 (*itLE)->setText( ent.office() );
1312 1315
1313 if ( *it == "Profession" ) 1316 if ( *it == "Profession" )
1314 (*itLE)->setText( ent.profession() ); 1317 (*itLE)->setText( ent.profession() );
1315 1318
1316 if ( *it == "Assistant" ) 1319 if ( *it == "Assistant" )
1317 (*itLE)->setText( ent.assistant() ); 1320 (*itLE)->setText( ent.assistant() );
1318 1321
1319 if ( *it == "Manager" ) 1322 if ( *it == "Manager" )
1320 (*itLE)->setText( ent.manager() ); 1323 (*itLE)->setText( ent.manager() );
1321 1324
1322 if ( *it == "Spouse" ) 1325 if ( *it == "Spouse" )
1323 (*itLE)->setText( ent.spouse() ); 1326 (*itLE)->setText( ent.spouse() );
1324 1327
1325 if ( *it == "Nickname" ){ 1328 if ( *it == "Nickname" ){
1326 qWarning("**** Nichname: %s", ent.nickname().latin1() ); 1329 qWarning("**** Nichname: %s", ent.nickname().latin1() );
1327 (*itLE)->setText( ent.nickname() ); 1330 (*itLE)->setText( ent.nickname() );
1328 } 1331 }
1329 1332
1330 if ( *it == "Children" ) 1333 if ( *it == "Children" )
1331 (*itLE)->setText( ent.children() ); 1334 (*itLE)->setText( ent.children() );
1332 1335
1333 } 1336 }
1334 1337
1335 QStringList::Iterator itV; 1338 QStringList::Iterator itV;
1336 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1339 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1337 1340
1338 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) 1341 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) )
1339 *itV = ent.businessPhone(); 1342 *itV = ent.businessPhone();
1340 /* 1343 /*
1341 if ( *it == "Business 2 Phone" ) 1344 if ( *it == "Business 2 Phone" )
1342 *itV = ent.business2Phone(); 1345 *itV = ent.business2Phone();
1343 */ 1346 */
1344 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) 1347 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) )
1345 *itV = ent.businessFax(); 1348 *itV = ent.businessFax();
1346 1349
1347 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) 1350 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) )
1348 *itV = ent.businessMobile(); 1351 *itV = ent.businessMobile();
1349 /* 1352 /*
1350 if ( *it == "Company Phone" ) 1353 if ( *it == "Company Phone" )
1351 *itV = ent.companyPhone(); 1354 *itV = ent.companyPhone();
1352 */ 1355 */
1353 if ( *it == "Default Email" ) 1356 if ( *it == "Default Email" )
1354 *itV = ent.defaultEmail(); 1357 *itV = ent.defaultEmail();
1355 1358
1356 if ( *it == "Emails" ) 1359 if ( *it == "Emails" )
1357 *itV = ent.emailList().join(", "); // :SX 1360 *itV = ent.emailList().join(", "); // :SX
1358 1361
1359 if ( *it == "Home Phone" ) 1362 if ( *it == "Home Phone" )
1360 *itV = ent.homePhone(); 1363 *itV = ent.homePhone();
1361 /* 1364 /*
1362 if ( *it == "Home 2 Phone" ) 1365 if ( *it == "Home 2 Phone" )
1363 *itV = ent.home2Phone(); 1366 *itV = ent.home2Phone();
1364 */ 1367 */
1365 if ( *it == "Home Fax" ) 1368 if ( *it == "Home Fax" )
1366 *itV = ent.homeFax(); 1369 *itV = ent.homeFax();
1367 1370
1368 if ( *it == "Home Mobile" ) 1371 if ( *it == "Home Mobile" )
1369 *itV = ent.homeMobile(); 1372 *itV = ent.homeMobile();
1370 /* 1373 /*
1371 if ( *it == "Car Phone" ) 1374 if ( *it == "Car Phone" )
1372 *itV = ent.carPhone(); 1375 *itV = ent.carPhone();
1373 1376
1374 if ( *it == "ISDN Phone" ) 1377 if ( *it == "ISDN Phone" )
1375 *itV = ent.ISDNPhone(); 1378 *itV = ent.ISDNPhone();
1376 1379
1377 if ( *it == "Other Phone" ) 1380 if ( *it == "Other Phone" )
1378 *itV = ent.otherPhone(); 1381 *itV = ent.otherPhone();
1379 */ 1382 */
1380 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1383 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1381 *itV = ent.businessPager(); 1384 *itV = ent.businessPager();
1382 /* 1385 /*
1383 if ( *it == "Home Pager") 1386 if ( *it == "Home Pager")
1384 *itV = ent.homePager(); 1387 *itV = ent.homePager();
1385 1388
1386 if ( *it == "AIM IM" ) 1389 if ( *it == "AIM IM" )
1387 *itV = ent.AIMIM(); 1390 *itV = ent.AIMIM();
1388 1391
1389 if ( *it == "ICQ IM" ) 1392 if ( *it == "ICQ IM" )
1390 *itV = ent.ICQIM(); 1393 *itV = ent.ICQIM();
1391 1394
1392 if ( *it == "Jabber IM" ) 1395 if ( *it == "Jabber IM" )
1393 *itV = ent.jabberIM(); 1396 *itV = ent.jabberIM();
1394 1397
1395 if ( *it == "MSN IM" ) 1398 if ( *it == "MSN IM" )
1396 *itV = ent.MSNIM(); 1399 *itV = ent.MSNIM();
1397 1400
1398 if ( *it == "Yahoo IM" ) 1401 if ( *it == "Yahoo IM" )
1399 *itV = ent.yahooIM(); 1402 *itV = ent.yahooIM();
1400 */ 1403 */
1401 if ( *it == "Home Web Page" ) 1404 if ( *it == "Home Web Page" )
1402 *itV = ent.homeWebpage(); 1405 *itV = ent.homeWebpage();
1403 1406
1404 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1407 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1405 *itV = ent.businessWebpage(); 1408 *itV = ent.businessWebpage();
1406 1409
1407 1410
1408 } 1411 }
1409 1412
1410 1413
1411 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); 1414 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
1412 1415
1413 QString gender = ent.gender(); 1416 QString gender = ent.gender();