summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/TODO2
-rw-r--r--core/pim/addressbook/contacteditor.cpp235
-rw-r--r--core/pim/addressbook/version.h4
3 files changed, 79 insertions, 162 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index a0d50a3..106747e 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -31,3 +31,2 @@ Urgent:
31 31
32- Fix handling of 3 Firstnames
33 32
@@ -116 +115,2 @@ Fixed/Ready:
116- Default Email-Button: Sometimes not hiding the textfields completely 115- Default Email-Button: Sometimes not hiding the textfields completely
116- Fix handling of 3 Firstnames
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index d1338f6..7bc5bde 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -159,6 +159,11 @@ void ContactEditor::init() {
159 159
160 l = new QLabel( tr( "Organization" ), container ); 160 l = new QLabel( tr("Suffix"), container );
161 gl->addWidget( l, 2, 0 ); 161 gl->addWidget( l, 2, 0 );
162 txtSuffix = new QLineEdit( container );
163 gl->addWidget( txtSuffix, 2, 1 );
164
165 l = new QLabel( tr( "Organization" ), container );
166 gl->addWidget( l, 3, 0 );
162 txtOrganization = new QLineEdit( container ); 167 txtOrganization = new QLineEdit( container );
163 gl->addWidget( txtOrganization, 2, 1 ); 168 gl->addWidget( txtOrganization, 3, 1 );
164 169
@@ -167,3 +172,3 @@ void ContactEditor::init() {
167 cmbChooserField1->setMaximumWidth( 90 ); 172 cmbChooserField1->setMaximumWidth( 90 );
168 gl->addWidget( cmbChooserField1, 3, 0 ); 173 gl->addWidget( cmbChooserField1, 4, 0 );
169 // Textfield for chooser 1. 174 // Textfield for chooser 1.
@@ -173,3 +178,3 @@ void ContactEditor::init() {
173 m_widgetStack1 -> addWidget( txtChooserField1, TextField ); 178 m_widgetStack1 -> addWidget( txtChooserField1, TextField );
174 gl->addWidget( m_widgetStack1, 3, 1 ); 179 gl->addWidget( m_widgetStack1, 4, 1 );
175 m_widgetStack1 -> raiseWidget( TextField ); 180 m_widgetStack1 -> raiseWidget( TextField );
@@ -179,3 +184,3 @@ void ContactEditor::init() {
179 cmbChooserField2->setMaximumWidth( 90 ); 184 cmbChooserField2->setMaximumWidth( 90 );
180 gl->addWidget( cmbChooserField2, 4, 0 ); 185 gl->addWidget( cmbChooserField2, 5, 0 );
181 // Textfield for chooser 2 186 // Textfield for chooser 2
@@ -185,3 +190,3 @@ void ContactEditor::init() {
185 m_widgetStack2 -> addWidget( txtChooserField2, TextField ); 190 m_widgetStack2 -> addWidget( txtChooserField2, TextField );
186 gl->addWidget( m_widgetStack2, 4, 1 ); 191 gl->addWidget( m_widgetStack2, 5, 1 );
187 m_widgetStack2 -> raiseWidget( TextField ); 192 m_widgetStack2 -> raiseWidget( TextField );
@@ -191,3 +196,3 @@ void ContactEditor::init() {
191 cmbChooserField3->setMaximumWidth( 90 ); 196 cmbChooserField3->setMaximumWidth( 90 );
192 gl->addWidget( cmbChooserField3, 5, 0 ); 197 gl->addWidget( cmbChooserField3, 6, 0 );
193 // Textfield for chooser 2 198 // Textfield for chooser 2
@@ -197,3 +202,3 @@ void ContactEditor::init() {
197 m_widgetStack3 -> addWidget( txtChooserField3, TextField ); 202 m_widgetStack3 -> addWidget( txtChooserField3, TextField );
198 gl->addWidget( m_widgetStack3, 5, 1 ); 203 gl->addWidget( m_widgetStack3, 6, 1 );
199 m_widgetStack3 -> raiseWidget( TextField ); 204 m_widgetStack3 -> raiseWidget( TextField );
@@ -201,10 +206,10 @@ void ContactEditor::init() {
201 l = new QLabel( tr( "File As" ), container ); 206 l = new QLabel( tr( "File As" ), container );
202 gl->addWidget( l, 6, 0 ); 207 gl->addWidget( l, 7, 0 );
203 cmbFileAs = new QComboBox( TRUE, container ); 208 cmbFileAs = new QComboBox( TRUE, container );
204 gl->addWidget( cmbFileAs, 6, 1 ); 209 gl->addWidget( cmbFileAs, 7, 1 );
205 210
206 labCat = new QLabel( tr( "Category" ), container ); 211 labCat = new QLabel( tr( "Category" ), container );
207 gl->addWidget( labCat, 7, 0 ); 212 gl->addWidget( labCat, 8, 0 );
208 cmbCat = new CategorySelect( container ); 213 cmbCat = new CategorySelect( container );
209 gl->addWidget( cmbCat, 7, 1 ); 214 gl->addWidget( cmbCat, 8, 1 );
210 labCat->show(); 215 labCat->show();
@@ -213,3 +218,3 @@ void ContactEditor::init() {
213 btnNote = new QPushButton( tr( "Notes..." ), container ); 218 btnNote = new QPushButton( tr( "Notes..." ), container );
214 gl->addWidget( btnNote, 8, 1 ); 219 gl->addWidget( btnNote, 9, 1 );
215 220
@@ -620,6 +625,6 @@ void ContactEditor::init() {
620 625
621 l = new QLabel( tr("Suffix"), dlgName ); 626 // l = new QLabel( tr("Suffix"), dlgName );
622 gl->addWidget( l, 3, 0 ); 627 // gl->addWidget( l, 3, 0 );
623 txtSuffix = new QLineEdit( dlgName ); 628 // txtSuffix = new QLineEdit( dlgName );
624 gl->addWidget( txtSuffix, 3, 1 ); 629 // gl->addWidget( txtSuffix, 3, 1 );
625 space = new QSpacerItem(1,1, 630 space = new QSpacerItem(1,1,
@@ -1017,2 +1022,4 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1017 1022
1023 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() );
1024
1018 int index = cmbFileAs->currentItem(); 1025 int index = cmbFileAs->currentItem();
@@ -1021,6 +1028,6 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1021 1028
1022 cmbFileAs->insertItem( parseName( textChanged, 0 ) ); 1029 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) );
1023 cmbFileAs->insertItem( parseName( textChanged, 1 ) ); 1030 cmbFileAs->insertItem( parseName( textChanged, NAME_FMLS ) );
1024 cmbFileAs->insertItem( parseName( textChanged, 2 ) ); 1031 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) );
1025 cmbFileAs->insertItem( parseName( textChanged, 3 ) ); 1032 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) );
1026 1033
@@ -1060,3 +1067,3 @@ void ContactEditor::slotName() {
1060 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1067 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1061 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1068 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1062 } 1069 }
@@ -1104,149 +1111,54 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1104 int commapos; 1111 int commapos;
1105 int spCount; 1112 bool haveLastName = false;
1106 int spPos;
1107 int spPos2;
1108 1113
1114 qWarning("Fullname: %s", simplifiedName.latin1());
1109 1115
1110 commapos = simplifiedName.find( ',', 0, TRUE); 1116 commapos = simplifiedName.find( ',', 0, TRUE);
1111 spCount = simplifiedName.contains( ' ', TRUE ); 1117 if ( commapos >= 0 ) {
1118 qWarning(" Commapos: %d", commapos );
1112 1119
1113 if ( commapos == -1 ) { 1120 // A comma (",") separates the lastname from one or
1114 1121 // many first names. Thus, remove the lastname from the
1115 switch (spCount) { 1122 // String and parse the firstnames.
1116 case 0:
1117 //return simplifiedName;
1118 if (txtLastName->text() != "") {
1119 strLastName = simplifiedName;
1120 break;
1121 }
1122 if (txtMiddleName->text() != "") {
1123 strMiddleName = simplifiedName;
1124 break;
1125 }
1126 if (txtSuffix->text() != "") {
1127 strSuffix = simplifiedName;
1128 break;
1129 }
1130 strFirstName = simplifiedName;
1131 break;
1132 1123
1133 case 1: 1124 strLastName = simplifiedName.left( commapos );
1134 spPos = simplifiedName.find( ' ', 0, TRUE ); 1125 simplifiedName= simplifiedName.mid( commapos + 1 );
1135 strFirstName = simplifiedName.left( spPos ); 1126 haveLastName = true;
1136 strLastName = simplifiedName.mid( spPos + 1 ); 1127 qWarning("Fullname without ',': %s", simplifiedName.latin1());
1137 break;
1138 1128
1139 case 2: 1129 // If we have any lastname, we should now split all first names.
1140 spPos = simplifiedName.find( ' ', 0, TRUE ); 1130 // The first one will be the used as first, the rest as "middle names"
1141 strFirstName = simplifiedName.left( spPos );
1142 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1143 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1144 strLastName = simplifiedName.mid( spPos2 + 1 );
1145 break;
1146 1131
1147 case 3: 1132 QStringList allFirstNames = QStringList::split(" ", simplifiedName);
1148 spPos = simplifiedName.find( ' ', 0, TRUE ); 1133 QStringList::Iterator it = allFirstNames.begin();
1149 strFirstName = simplifiedName.left( spPos ); 1134 strFirstName = *it++;
1150 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1135 QStringList allSecondNames;
1151 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1136 for ( ; it != allFirstNames.end(); ++it )
1152 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1137 allSecondNames.append( *it );
1153 strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1154 strSuffix = simplifiedName.mid( spPos + 1 );
1155 break;
1156 1138
1157 case 4: 1139 strMiddleName = allSecondNames.join(" ");
1158 spPos = simplifiedName.find( ' ', 0, TRUE );
1159 strTitle = simplifiedName.left( spPos );
1160 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1161 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1162 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1163 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1164 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1165 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1166 strSuffix = simplifiedName.mid( spPos2 + 1 );
1167 break;
1168 1140
1169 default:
1170 spPos = simplifiedName.find( ' ', 0, TRUE );
1171 strTitle = simplifiedName.left( spPos );
1172 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1173 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1174 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1175 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1176 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1177 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1178 strSuffix = simplifiedName.mid( spPos2 + 1 );
1179 break;
1180 }
1181 } else { 1141 } else {
1182 simplifiedName.replace( commapos, 1, " " );
1183 simplifiedName = simplifiedName.simplifyWhiteSpace();
1184
1185 switch (spCount) {
1186 case 0:
1187 //return simplifiedName;
1188 if (txtLastName->text() != "") {
1189 strLastName = simplifiedName;
1190 break;
1191 }
1192 if (txtMiddleName->text() != "") {
1193 strMiddleName = simplifiedName;
1194 break;
1195 }
1196 if (txtSuffix->text() != "") {
1197 strSuffix = simplifiedName;
1198 break;
1199 }
1200 strFirstName = simplifiedName;
1201 break;
1202
1203 case 1:
1204 spPos = simplifiedName.find( ' ', 0, TRUE );
1205 strLastName = simplifiedName.left( spPos );
1206 strFirstName = simplifiedName.mid( spPos + 1 );
1207 break;
1208 1142
1209 case 2: 1143 // No comma separator used: We use the first word as firstname, the
1210 spPos = simplifiedName.find( ' ', 0, TRUE ); 1144 // last as second/lastname and everything in the middle as middlename
1211 strLastName = simplifiedName.left( spPos );
1212 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1213 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1214 strMiddleName = simplifiedName.mid( spPos2 + 1 );
1215 break;
1216 1145
1217 case 3: 1146 QStringList allNames = QStringList::split(" ", simplifiedName);
1218 spPos = simplifiedName.find( ' ', 0, TRUE ); 1147 QStringList::Iterator it = allNames.begin();
1219 strLastName = simplifiedName.left( spPos ); 1148 strFirstName = *it++;
1220 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1149 QStringList allSecondNames;
1221 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1150 for ( ; it != --allNames.end(); ++it )
1222 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1151 allSecondNames.append( *it );
1223 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1224 strSuffix = simplifiedName.mid( spPos + 1 );
1225 break;
1226 1152
1227 case 4: 1153 strMiddleName = allSecondNames.join(" ");
1228 spPos = simplifiedName.find( ' ', 0, TRUE ); 1154 strLastName = *(--allNames.end());
1229 strLastName = simplifiedName.left( spPos );
1230 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1231 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1232 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1233 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
1234 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1235 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1236 strSuffix = simplifiedName.mid( spPos2 + 1 );
1237 break;
1238 1155
1239 default:
1240 spPos = simplifiedName.find( ' ', 0, TRUE );
1241 strLastName = simplifiedName.left( spPos );
1242 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1243 strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1244 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
1245 strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos );
1246 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
1247 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
1248 strSuffix = simplifiedName.mid( spPos2 + 1 );
1249 break;
1250 }
1251 } 1156 }
1157
1158 qWarning(" strFirstName: %s", strFirstName.latin1());
1159 qWarning(" strMiddleName: %s", strMiddleName.latin1());
1160 qWarning(" strLastName: %s", strLastName.latin1());
1161 qWarning(" strSuffix: %s", strSuffix.latin1());
1162 qWarning(" strTitle: %s", strTitle.latin1());
1163
1252 switch (type) { 1164 switch (type) {
@@ -1338,7 +1250,12 @@ void ContactEditor::setEntry( const OContact &entry ) {
1338 1250
1339 QString *tmpString = new QString; 1251 // QString *tmpString = new QString;
1340 *tmpString = ent.firstName() + " " + ent.middleName() + 1252 // *tmpString = ent.firstName() + " " + ent.middleName() +
1341 + " " + ent.lastName() + " " + ent.suffix(); 1253 // + " " + ent.lastName() + " " + ent.suffix();
1254 //txtFullName->setText( tmpString->simplifyWhiteSpace() );
1342 1255
1343 txtFullName->setText( tmpString->simplifyWhiteSpace() ); 1256 // Lastnames with multiple words need to be protected by a comma !
1257 if ( ent.lastName().contains( ' ', TRUE ) )
1258 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
1259 else
1260 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
1344 1261
@@ -1553,3 +1470,3 @@ void ContactEditor::saveEntry() {
1553 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); 1470 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) );
1554 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); 1471 // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) );
1555 1472
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h
index 3becfdc..c2ead05 100644
--- a/core/pim/addressbook/version.h
+++ b/core/pim/addressbook/version.h
@@ -4,4 +4,4 @@
4#define MAINVERSION "0" 4#define MAINVERSION "0"
5#define SUBVERSION "2" 5#define SUBVERSION "3"
6#define PATCHVERSION "2" 6#define PATCHVERSION "0"
7 7