summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp15
-rw-r--r--core/pim/addressbook/contacteditor.h1
2 files changed, 11 insertions, 5 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index c4a7b10..75dd2c1 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -624,48 +624,50 @@ void ContactEditor::init() {
624 gl->addWidget( txtLastName, 2, 1 ); 624 gl->addWidget( txtLastName, 2, 1 );
625 625
626 // l = new QLabel( tr("Suffix"), dlgName ); 626 // l = new QLabel( tr("Suffix"), dlgName );
627 // gl->addWidget( l, 3, 0 ); 627 // gl->addWidget( l, 3, 0 );
628 // txtSuffix = new QLineEdit( dlgName ); 628 // txtSuffix = new QLineEdit( dlgName );
629 // gl->addWidget( txtSuffix, 3, 1 ); 629 // gl->addWidget( txtSuffix, 3, 1 );
630 space = new QSpacerItem(1,1, 630 space = new QSpacerItem(1,1,
631 QSizePolicy::Maximum, 631 QSizePolicy::Maximum,
632 QSizePolicy::MinimumExpanding ); 632 QSizePolicy::MinimumExpanding );
633 gl->addItem( space, 4, 0 ); 633 gl->addItem( space, 4, 0 );
634 634
635 cmbChooserField1->insertStringList( trlChooserNames ); 635 cmbChooserField1->insertStringList( trlChooserNames );
636 cmbChooserField2->insertStringList( trlChooserNames ); 636 cmbChooserField2->insertStringList( trlChooserNames );
637 cmbChooserField3->insertStringList( trlChooserNames ); 637 cmbChooserField3->insertStringList( trlChooserNames );
638 cmbChooserField4->insertStringList( trlChooserNames ); 638 cmbChooserField4->insertStringList( trlChooserNames );
639 639
640 cmbChooserField1->setCurrentItem( 0 ); 640 cmbChooserField1->setCurrentItem( 0 );
641 cmbChooserField2->setCurrentItem( 1 ); 641 cmbChooserField2->setCurrentItem( 1 );
642 cmbChooserField3->setCurrentItem( 2 ); 642 cmbChooserField3->setCurrentItem( 2 );
643 643
644 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 644 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
645 645
646 connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); 646 connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) );
647 647
648 connect( txtSuffix, SIGNAL(textChanged(const QString &)), this, SLOT(slotSuffixChange(const QString &)) );
649
648 connect( txtChooserField1, SIGNAL(textChanged(const QString &)), 650 connect( txtChooserField1, SIGNAL(textChanged(const QString &)),
649 this, SLOT(slotChooser1Change(const QString &)) ); 651 this, SLOT(slotChooser1Change(const QString &)) );
650 connect( txtChooserField2, SIGNAL(textChanged(const QString &)), 652 connect( txtChooserField2, SIGNAL(textChanged(const QString &)),
651 this, SLOT(slotChooser2Change(const QString &)) ); 653 this, SLOT(slotChooser2Change(const QString &)) );
652 connect( txtChooserField3, SIGNAL(textChanged(const QString &)), 654 connect( txtChooserField3, SIGNAL(textChanged(const QString &)),
653 this, SLOT(slotChooser3Change(const QString &)) ); 655 this, SLOT(slotChooser3Change(const QString &)) );
654 connect( txtChooserField4, SIGNAL(textChanged(const QString &)), 656 connect( txtChooserField4, SIGNAL(textChanged(const QString &)),
655 this, SLOT(slotChooser4Change(const QString &)) ); 657 this, SLOT(slotChooser4Change(const QString &)) );
656 connect( txtAddress, SIGNAL(textChanged(const QString &)), 658 connect( txtAddress, SIGNAL(textChanged(const QString &)),
657 this, SLOT(slotAddressChange(const QString &)) ); 659 this, SLOT(slotAddressChange(const QString &)) );
658 connect( txtCity, SIGNAL(textChanged(const QString &)), 660 connect( txtCity, SIGNAL(textChanged(const QString &)),
659 this, SLOT(slotCityChange(const QString &)) ); 661 this, SLOT(slotCityChange(const QString &)) );
660 connect( txtState, SIGNAL(textChanged(const QString &)), 662 connect( txtState, SIGNAL(textChanged(const QString &)),
661 this, SLOT(slotStateChange(const QString &)) ); 663 this, SLOT(slotStateChange(const QString &)) );
662 connect( txtZip, SIGNAL(textChanged(const QString &)), 664 connect( txtZip, SIGNAL(textChanged(const QString &)),
663 this, SLOT(slotZipChange(const QString &)) ); 665 this, SLOT(slotZipChange(const QString &)) );
664 connect( cmbCountry, SIGNAL(textChanged(const QString &)), 666 connect( cmbCountry, SIGNAL(textChanged(const QString &)),
665 this, SLOT(slotCountryChange(const QString &)) ); 667 this, SLOT(slotCountryChange(const QString &)) );
666 connect( cmbCountry, SIGNAL(activated(const QString &)), 668 connect( cmbCountry, SIGNAL(activated(const QString &)),
667 this, SLOT(slotCountryChange(const QString &)) ); 669 this, SLOT(slotCountryChange(const QString &)) );
668 connect( cmbChooserField1, SIGNAL(activated(int)), 670 connect( cmbChooserField1, SIGNAL(activated(int)),
669 this, SLOT(slotCmbChooser1Change(int)) ); 671 this, SLOT(slotCmbChooser1Change(int)) );
670 connect( cmbChooserField2, SIGNAL(activated(int)), 672 connect( cmbChooserField2, SIGNAL(activated(int)),
671 this, SLOT(slotCmbChooser2Change(int)) ); 673 this, SLOT(slotCmbChooser2Change(int)) );
@@ -1016,118 +1018,122 @@ void ContactEditor::slotAddressTypeChange( int index ) {
1016 1018
1017 } 1019 }
1018 1020
1019} 1021}
1020 1022
1021void ContactEditor::slotFullNameChange( const QString &textChanged ) { 1023void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1022 1024
1023 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() ); 1025 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() );
1024 1026
1025 int index = cmbFileAs->currentItem(); 1027 int index = cmbFileAs->currentItem();
1026 1028
1027 cmbFileAs->clear(); 1029 cmbFileAs->clear();
1028 1030
1029 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) ); 1031 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) );
1030 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) ); 1032 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) );
1031 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); 1033 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) );
1032 cmbFileAs->insertItem( parseName( textChanged, NAME_FMLS ) ); 1034 cmbFileAs->insertItem( parseName( textChanged, NAME_FMLS ) );
1033 1035
1034 cmbFileAs->setCurrentItem( index ); 1036 cmbFileAs->setCurrentItem( index );
1035 1037
1036 useFullName = true; 1038 useFullName = true;
1037 1039
1038} 1040}
1039 1041
1042void ContactEditor::slotSuffixChange( const QString& ) {
1043 // Just want to update the FileAs combo if the suffix was changed..
1044 slotFullNameChange( txtFullName->text() );
1045}
1046
1040void ContactEditor::accept() { 1047void ContactEditor::accept() {
1041 1048
1042 if ( isEmpty() ) { 1049 if ( isEmpty() ) {
1043 cleanupFields(); 1050 cleanupFields();
1044 reject(); 1051 reject();
1045 } else { 1052 } else {
1046 saveEntry(); 1053 saveEntry();
1047 cleanupFields(); 1054 cleanupFields();
1048 QDialog::accept(); 1055 QDialog::accept();
1049 } 1056 }
1050 1057
1051} 1058}
1052 1059
1053void ContactEditor::slotNote() { 1060void ContactEditor::slotNote() {
1054 1061
1055 dlgNote->showMaximized(); 1062 dlgNote->showMaximized();
1056 if ( !dlgNote->exec() ) { 1063 if ( !dlgNote->exec() ) {
1057 txtNote->setText( ent.notes() ); 1064 txtNote->setText( ent.notes() );
1058 } 1065 }
1059} 1066}
1060 1067
1061void ContactEditor::slotName() { 1068void ContactEditor::slotName() {
1062 1069
1063 QString tmpName; 1070 QString tmpName;
1064 if (useFullName) { 1071 if (useFullName) {
1065 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 1072 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
1066 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 1073 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
1067 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1074 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1068 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1075 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1069 } 1076 }
1070 dlgName->showMaximized(); 1077 dlgName->showMaximized();
1071 if ( dlgName->exec() ) { 1078 if ( dlgName->exec() ) {
1072 1079
1073 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); 1080 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text();
1074 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 1081 txtFullName->setText( tmpName.simplifyWhiteSpace() );
1075 slotFullNameChange( txtFullName->text() ); 1082 slotFullNameChange( txtFullName->text() );
1076 useFullName = false; 1083 useFullName = false;
1077 } 1084 }
1078 1085
1079} 1086}
1080 1087
1081void ContactEditor::setNameFocus() { 1088void ContactEditor::setNameFocus() {
1082 1089
1083 txtFullName->setFocus(); 1090 txtFullName->setFocus();
1084 1091
1085} 1092}
1086 1093
1087bool ContactEditor::isEmpty() { 1094bool ContactEditor::isEmpty() {
1088 // Test and see if the record should be saved. 1095 // Test and see if the record should be saved.
1089 // More strict than the original qtopia, needs name or fileas to save 1096 // More strict than the original qtopia, needs name or fileas to save
1090 1097
1091 QString t = txtFullName->text(); 1098 QString t = txtFullName->text();
1092 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1099 if ( !t.isEmpty() && containsAlphaNum( t ) )
1093 return false; 1100 return false;
1094 1101
1095 t = cmbFileAs->currentText(); 1102 t = cmbFileAs->currentText();
1096 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1103 if ( !t.isEmpty() && containsAlphaNum( t ) )
1097 return false; 1104 return false;
1098 1105
1099 return true; 1106 return true;
1100 1107
1101} 1108}
1102 1109
1103QString ContactEditor::parseName( const QString fullName, int type ) { 1110QString ContactEditor::parseName( const QString fullName, int type ) {
1104 1111
1105 QString simplifiedName( fullName.simplifyWhiteSpace() ); 1112 QString simplifiedName( fullName.simplifyWhiteSpace() );
1106 QString strFirstName; 1113 QString strFirstName;
1107 QString strMiddleName; 1114 QString strMiddleName;
1108 QString strLastName; 1115 QString strLastName;
1109 QString strSuffix;
1110 QString strTitle; 1116 QString strTitle;
1111 int commapos; 1117 int commapos;
1112 bool haveLastName = false; 1118 bool haveLastName = false;
1113 1119
1114 qWarning("Fullname: %s", simplifiedName.latin1()); 1120 qWarning("Fullname: %s", simplifiedName.latin1());
1115 1121
1116 commapos = simplifiedName.find( ',', 0, TRUE); 1122 commapos = simplifiedName.find( ',', 0, TRUE);
1117 if ( commapos >= 0 ) { 1123 if ( commapos >= 0 ) {
1118 qWarning(" Commapos: %d", commapos ); 1124 qWarning(" Commapos: %d", commapos );
1119 1125
1120 // A comma (",") separates the lastname from one or 1126 // A comma (",") separates the lastname from one or
1121 // many first names. Thus, remove the lastname from the 1127 // many first names. Thus, remove the lastname from the
1122 // String and parse the firstnames. 1128 // String and parse the firstnames.
1123 1129
1124 strLastName = simplifiedName.left( commapos ); 1130 strLastName = simplifiedName.left( commapos );
1125 simplifiedName= simplifiedName.mid( commapos + 1 ); 1131 simplifiedName= simplifiedName.mid( commapos + 1 );
1126 haveLastName = true; 1132 haveLastName = true;
1127 qWarning("Fullname without ',': %s", simplifiedName.latin1()); 1133 qWarning("Fullname without ',': %s", simplifiedName.latin1());
1128 1134
1129 // If we have any lastname, we should now split all first names. 1135 // 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" 1136 // The first one will be the used as first, the rest as "middle names"
1131 1137
1132 QStringList allFirstNames = QStringList::split(" ", simplifiedName); 1138 QStringList allFirstNames = QStringList::split(" ", simplifiedName);
1133 QStringList::Iterator it = allFirstNames.begin(); 1139 QStringList::Iterator it = allFirstNames.begin();
@@ -1140,75 +1146,74 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1140 1146
1141 } else { 1147 } else {
1142 1148
1143 // No comma separator used: We use the first word as firstname, the 1149 // No comma separator used: We use the first word as firstname, the
1144 // last as second/lastname and everything in the middle as middlename 1150 // last as second/lastname and everything in the middle as middlename
1145 1151
1146 QStringList allNames = QStringList::split(" ", simplifiedName); 1152 QStringList allNames = QStringList::split(" ", simplifiedName);
1147 QStringList::Iterator it = allNames.begin(); 1153 QStringList::Iterator it = allNames.begin();
1148 strFirstName = *it++; 1154 strFirstName = *it++;
1149 QStringList allSecondNames; 1155 QStringList allSecondNames;
1150 for ( ; it != --allNames.end(); ++it ) 1156 for ( ; it != --allNames.end(); ++it )
1151 allSecondNames.append( *it ); 1157 allSecondNames.append( *it );
1152 1158
1153 strMiddleName = allSecondNames.join(" "); 1159 strMiddleName = allSecondNames.join(" ");
1154 strLastName = *(--allNames.end()); 1160 strLastName = *(--allNames.end());
1155 1161
1156 } 1162 }
1157 1163
1158 if ( strFirstName == strLastName ) 1164 if ( strFirstName == strLastName )
1159 strFirstName = ""; 1165 strFirstName = "";
1160 1166
1161 qWarning(" strFirstName: %s", strFirstName.latin1()); 1167 qWarning(" strFirstName: %s", strFirstName.latin1());
1162 qWarning(" strMiddleName: %s", strMiddleName.latin1()); 1168 qWarning(" strMiddleName: %s", strMiddleName.latin1());
1163 qWarning(" strLastName: %s", strLastName.latin1()); 1169 qWarning(" strLastName: %s", strLastName.latin1());
1164 qWarning(" strSuffix: %s", strSuffix.latin1());
1165 qWarning(" strTitle: %s", strTitle.latin1()); 1170 qWarning(" strTitle: %s", strTitle.latin1());
1166 1171
1167 switch (type) { 1172 switch (type) {
1168 case NAME_FL: 1173 case NAME_FL:
1169 return strFirstName + " " + strLastName; 1174 return strFirstName + " " + strLastName;
1170 1175
1171 case NAME_LF: 1176 case NAME_LF:
1172 return strLastName + ", " + strFirstName; 1177 return strLastName + ", " + strFirstName;
1173 1178
1174 case NAME_LFM: 1179 case NAME_LFM:
1175 return strLastName + ", " + strFirstName + " " + strMiddleName; 1180 return strLastName + ", " + strFirstName + " " + strMiddleName;
1176 1181
1177 case NAME_FMLS: 1182 case NAME_FMLS:
1178 return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; 1183 return strFirstName + " " + strMiddleName + " " + strLastName + " " + txtSuffix->text();
1179 1184
1180 case NAME_F: 1185 case NAME_F:
1181 return strFirstName; 1186 return strFirstName;
1182 1187
1183 case NAME_M: 1188 case NAME_M:
1184 return strMiddleName; 1189 return strMiddleName;
1185 1190
1186 case NAME_L: 1191 case NAME_L:
1187 return strLastName; 1192 return strLastName;
1188 1193
1189 case NAME_S: 1194 case NAME_S:
1190 return strSuffix; 1195 return txtSuffix->text();
1191 1196
1192 } 1197 }
1193 return QString::null; 1198 return QString::null;
1194} 1199}
1195 1200
1196void ContactEditor::cleanupFields() { 1201void ContactEditor::cleanupFields() {
1197 QStringList::Iterator it = slChooserValues.begin(); 1202 QStringList::Iterator it = slChooserValues.begin();
1198 1203
1199 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { 1204 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
1200 (*it) = ""; 1205 (*it) = "";
1201 } 1206 }
1202 1207
1203 for ( int i = 0; i < 7; i++ ) { 1208 for ( int i = 0; i < 7; i++ ) {
1204 slHomeAddress[i] = ""; 1209 slHomeAddress[i] = "";
1205 slBusinessAddress[i] = ""; 1210 slBusinessAddress[i] = "";
1206 } 1211 }
1207 1212
1208 QListIterator<QLineEdit> itLV( listValue ); 1213 QListIterator<QLineEdit> itLV( listValue );
1209 for ( ; itLV.current(); ++itLV ) { 1214 for ( ; itLV.current(); ++itLV ) {
1210 (*itLV)->setText( "" ); 1215 (*itLV)->setText( "" );
1211 } 1216 }
1212 1217
1213 txtFirstName->setText(""); 1218 txtFirstName->setText("");
1214 txtMiddleName->setText(""); 1219 txtMiddleName->setText("");
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index 703e702..954c77e 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -79,48 +79,49 @@ class ContactEditor : public QDialog {
79 void saveEntry(); 79 void saveEntry();
80 bool isEmpty(); 80 bool isEmpty();
81 void cleanupFields(); 81 void cleanupFields();
82 void updateDatePicker(); 82 void updateDatePicker();
83 QString parseName( QString fullName, int type ); 83 QString parseName( QString fullName, int type );
84 void chooserError( int index ); 84 void chooserError( int index );
85 private slots: 85 private slots:
86 void slotChooser1Change( const QString &textChanged ); 86 void slotChooser1Change( const QString &textChanged );
87 void slotChooser2Change( const QString &textChanged ); 87 void slotChooser2Change( const QString &textChanged );
88 void slotChooser3Change( const QString &textChanged ); 88 void slotChooser3Change( const QString &textChanged );
89 void slotChooser4Change( const QString &textChanged ); 89 void slotChooser4Change( const QString &textChanged );
90 void slotCmbChooser1Change( int index ); 90 void slotCmbChooser1Change( int index );
91 void slotCmbChooser2Change( int index ); 91 void slotCmbChooser2Change( int index );
92 void slotCmbChooser3Change( int index ); 92 void slotCmbChooser3Change( int index );
93 void slotCmbChooser4Change( int index ); 93 void slotCmbChooser4Change( int index );
94 void slotAddressTypeChange( int index ); 94 void slotAddressTypeChange( int index );
95 void slotAddressChange( const QString &textChanged ); 95 void slotAddressChange( const QString &textChanged );
96 void slotAddress2Change( const QString &textChanged ); 96 void slotAddress2Change( const QString &textChanged );
97 void slotPOBoxChange( const QString &textChanged ); 97 void slotPOBoxChange( const QString &textChanged );
98 void slotCityChange( const QString &textChanged ); 98 void slotCityChange( const QString &textChanged );
99 void slotStateChange( const QString &textChanged ); 99 void slotStateChange( const QString &textChanged );
100 void slotZipChange( const QString &textChanged ); 100 void slotZipChange( const QString &textChanged );
101 void slotCountryChange( const QString &textChanged ); 101 void slotCountryChange( const QString &textChanged );
102 void slotFullNameChange( const QString &textChanged ); 102 void slotFullNameChange( const QString &textChanged );
103 void slotSuffixChange( const QString &textChanged );
103 void slotAnniversaryDateChanged( int year, int month, int day); 104 void slotAnniversaryDateChanged( int year, int month, int day);
104 void slotBirthdayDateChanged( int year, int month, int day); 105 void slotBirthdayDateChanged( int year, int month, int day);
105 void slotRemoveBirthday(); 106 void slotRemoveBirthday();
106 void slotRemoveAnniversary(); 107 void slotRemoveAnniversary();
107 void defaultEmailChanged(int); 108 void defaultEmailChanged(int);
108 109
109 private: 110 private:
110 enum StackWidgets { TextField = 1, Combo }; 111 enum StackWidgets { TextField = 1, Combo };
111 int defaultEmailChooserPosition; 112 int defaultEmailChooserPosition;
112 void populateDefaultEmailCmb(); 113 void populateDefaultEmailCmb();
113 void chooserChange( const QString&, int , QLineEdit*, int ); 114 void chooserChange( const QString&, int , QLineEdit*, int );
114 bool cmbChooserChange( int , QWidgetStack*, int ); 115 bool cmbChooserChange( int , QWidgetStack*, int );
115 OContactFields contactfields; 116 OContactFields contactfields;
116 117
117 bool useFullName; 118 bool useFullName;
118 119
119 OContact ent; 120 OContact ent;
120 121
121 QDialog *dlgNote; 122 QDialog *dlgNote;
122 QDialog *dlgName; 123 QDialog *dlgName;
123 124
124 QList<QLineEdit> listValue; 125 QList<QLineEdit> listValue;
125 QList<QLabel> listName; 126 QList<QLabel> listName;
126 127