author | eilers <eilers> | 2003-03-05 09:27:33 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-03-05 09:27:33 (UTC) |
commit | a1b76d948b7d45e8813181396ed83c002587feb9 (patch) (unidiff) | |
tree | 95e4da6aa2c6b6b3b8d8d834dcff76e1fb42b42e | |
parent | caad9c7b3e7fc0c9046993f6a152cd37f91fdceb (diff) | |
download | opie-a1b76d948b7d45e8813181396ed83c002587feb9.zip opie-a1b76d948b7d45e8813181396ed83c002587feb9.tar.gz opie-a1b76d948b7d45e8813181396ed83c002587feb9.tar.bz2 |
Bugfix: Fullname Dialogbox had problems with lastnames out of multiple words
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 62 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 8 |
2 files changed, 29 insertions, 41 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 75dd2c1..7682399 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -88,10 +88,8 @@ ContactEditor::~ContactEditor() { | |||
88 | 88 | ||
89 | void ContactEditor::init() { | 89 | void ContactEditor::init() { |
90 | qWarning("init() START"); | 90 | qWarning("init() START"); |
91 | 91 | ||
92 | useFullName = true; | ||
93 | |||
94 | uint i = 0; | 92 | uint i = 0; |
95 | 93 | ||
96 | QStringList trlChooserNames; | 94 | QStringList trlChooserNames; |
97 | 95 | ||
@@ -1030,13 +1028,14 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) { | |||
1030 | 1028 | ||
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 ) ); |
1033 | cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); | 1031 | cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); |
1034 | cmbFileAs->insertItem( parseName( textChanged, NAME_FMLS ) ); | 1032 | cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) ); |
1033 | if ( ! txtSuffix->text().isEmpty() ) | ||
1034 | cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() ); | ||
1035 | 1035 | ||
1036 | cmbFileAs->setCurrentItem( index ); | 1036 | cmbFileAs->setCurrentItem( index ); |
1037 | 1037 | ||
1038 | useFullName = true; | ||
1039 | 1038 | ||
1040 | } | 1039 | } |
1041 | 1040 | ||
1042 | void ContactEditor::slotSuffixChange( const QString& ) { | 1041 | void ContactEditor::slotSuffixChange( const QString& ) { |
@@ -1067,21 +1066,23 @@ void ContactEditor::slotNote() { | |||
1067 | 1066 | ||
1068 | void ContactEditor::slotName() { | 1067 | void ContactEditor::slotName() { |
1069 | 1068 | ||
1070 | QString tmpName; | 1069 | QString tmpName; |
1071 | if (useFullName) { | 1070 | |
1072 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); | 1071 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); |
1073 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); | 1072 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); |
1074 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); | 1073 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); |
1075 | // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); | 1074 | // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); |
1076 | } | 1075 | |
1077 | dlgName->showMaximized(); | 1076 | dlgName->showMaximized(); |
1078 | if ( dlgName->exec() ) { | 1077 | if ( dlgName->exec() ) { |
1078 | if ( txtLastName->text().contains( ' ', TRUE ) ) | ||
1079 | tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); | ||
1080 | else | ||
1081 | tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); | ||
1079 | 1082 | ||
1080 | tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); | ||
1081 | txtFullName->setText( tmpName.simplifyWhiteSpace() ); | 1083 | txtFullName->setText( tmpName.simplifyWhiteSpace() ); |
1082 | slotFullNameChange( txtFullName->text() ); | 1084 | slotFullNameChange( txtFullName->text() ); |
1083 | useFullName = false; | ||
1084 | } | 1085 | } |
1085 | 1086 | ||
1086 | } | 1087 | } |
1087 | 1088 | ||
@@ -1178,10 +1179,10 @@ QString ContactEditor::parseName( const QString fullName, int type ) { | |||
1178 | 1179 | ||
1179 | case NAME_LFM: | 1180 | case NAME_LFM: |
1180 | return strLastName + ", " + strFirstName + " " + strMiddleName; | 1181 | return strLastName + ", " + strFirstName + " " + strMiddleName; |
1181 | 1182 | ||
1182 | case NAME_FMLS: | 1183 | case NAME_FML: |
1183 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + txtSuffix->text(); | 1184 | return strFirstName + " " + strMiddleName + " " + strLastName ; |
1184 | 1185 | ||
1185 | case NAME_F: | 1186 | case NAME_F: |
1186 | return strFirstName; | 1187 | return strFirstName; |
1187 | 1188 | ||
@@ -1249,9 +1250,8 @@ void ContactEditor::setEntry( const OContact &entry ) { | |||
1249 | defaultEmail = ent.defaultEmail(); | 1250 | defaultEmail = ent.defaultEmail(); |
1250 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; | 1251 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; |
1251 | qDebug("default email=%s",defaultEmail.latin1()); | 1252 | qDebug("default email=%s",defaultEmail.latin1()); |
1252 | 1253 | ||
1253 | useFullName = false; | ||
1254 | txtFirstName->setText( ent.firstName() ); | 1254 | txtFirstName->setText( ent.firstName() ); |
1255 | txtMiddleName->setText( ent.middleName() ); | 1255 | txtMiddleName->setText( ent.middleName() ); |
1256 | txtLastName->setText( ent.lastName() ); | 1256 | txtLastName->setText( ent.lastName() ); |
1257 | txtSuffix->setText( ent.suffix() ); | 1257 | txtSuffix->setText( ent.suffix() ); |
@@ -1260,13 +1260,15 @@ void ContactEditor::setEntry( const OContact &entry ) { | |||
1260 | // *tmpString = ent.firstName() + " " + ent.middleName() + | 1260 | // *tmpString = ent.firstName() + " " + ent.middleName() + |
1261 | // + " " + ent.lastName() + " " + ent.suffix(); | 1261 | // + " " + ent.lastName() + " " + ent.suffix(); |
1262 | //txtFullName->setText( tmpString->simplifyWhiteSpace() ); | 1262 | //txtFullName->setText( tmpString->simplifyWhiteSpace() ); |
1263 | 1263 | ||
1264 | // Lastnames with multiple words need to be protected by a comma ! | 1264 | if ( !ent.isEmpty() ){ |
1265 | if ( ent.lastName().contains( ' ', TRUE ) ) | 1265 | // Lastnames with multiple words need to be protected by a comma ! |
1266 | txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); | 1266 | if ( ent.lastName().contains( ' ', TRUE ) ) |
1267 | else | 1267 | txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); |
1268 | txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); | 1268 | else |
1269 | txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); | ||
1270 | } | ||
1269 | 1271 | ||
1270 | cmbFileAs->setEditText( ent.fileAs() ); | 1272 | cmbFileAs->setEditText( ent.fileAs() ); |
1271 | 1273 | ||
1272 | //if (hasTitle) | 1274 | //if (hasTitle) |
@@ -1424,16 +1426,8 @@ void ContactEditor::setEntry( const OContact &entry ) { | |||
1424 | txtNote->setText( ent.notes() ); | 1426 | txtNote->setText( ent.notes() ); |
1425 | 1427 | ||
1426 | slotAddressTypeChange( cmbAddress->currentItem() ); | 1428 | slotAddressTypeChange( cmbAddress->currentItem() ); |
1427 | 1429 | ||
1428 | // Calling "show()" to arrange all widgets. Otherwise we will get | ||
1429 | // a wrong position of the textfields and are unable to put our | ||
1430 | // default-email combo over it.. This is very ugly ! | ||
1431 | // Does anybody has a better solution ? | ||
1432 | // Basically we should rethink the strategy to hide | ||
1433 | // a textfield with overwriting.. (se) | ||
1434 | show(); | ||
1435 | |||
1436 | // Get combo-settings from contact and set preset.. | 1430 | // Get combo-settings from contact and set preset.. |
1437 | contactfields.loadFromRecord( ent ); | 1431 | contactfields.loadFromRecord( ent ); |
1438 | cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) ); | 1432 | cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) ); |
1439 | cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) ); | 1433 | cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) ); |
@@ -1471,16 +1465,12 @@ void ContactEditor::saveEntry() { | |||
1471 | 1465 | ||
1472 | // Store current combo into contact | 1466 | // Store current combo into contact |
1473 | contactfields.saveToRecord( ent ); | 1467 | contactfields.saveToRecord( ent ); |
1474 | 1468 | ||
1475 | if ( useFullName ) { | 1469 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); |
1476 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); | 1470 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); |
1477 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); | 1471 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); |
1478 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); | 1472 | // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); |
1479 | // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); | ||
1480 | |||
1481 | useFullName = false; | ||
1482 | } | ||
1483 | 1473 | ||
1484 | ent.setFirstName( txtFirstName->text() ); | 1474 | ent.setFirstName( txtFirstName->text() ); |
1485 | ent.setLastName( txtLastName->text() ); | 1475 | ent.setLastName( txtLastName->text() ); |
1486 | ent.setMiddleName( txtMiddleName->text() ); | 1476 | ent.setMiddleName( txtMiddleName->text() ); |
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index 954c77e..c6fa48f 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h | |||
@@ -32,12 +32,12 @@ | |||
32 | #include <qwidgetstack.h> | 32 | #include <qwidgetstack.h> |
33 | 33 | ||
34 | #include "ocontactfields.h" | 34 | #include "ocontactfields.h" |
35 | 35 | ||
36 | const int NAME_LF = 0; | 36 | const int NAME_LF = 0; |
37 | const int NAME_LFM = 1; | 37 | const int NAME_LFM = 1; |
38 | const int NAME_FL = 2; | 38 | const int NAME_FL = 2; |
39 | const int NAME_FMLS = 3; | 39 | const int NAME_FML = 3; |
40 | 40 | ||
41 | const int NAME_F = 4; | 41 | const int NAME_F = 4; |
42 | const int NAME_M = 5; | 42 | const int NAME_M = 5; |
43 | const int NAME_L = 6; | 43 | const int NAME_L = 6; |
@@ -114,10 +114,8 @@ class ContactEditor : public QDialog { | |||
114 | void chooserChange( const QString&, int , QLineEdit*, int ); | 114 | void chooserChange( const QString&, int , QLineEdit*, int ); |
115 | bool cmbChooserChange( int , QWidgetStack*, int ); | 115 | bool cmbChooserChange( int , QWidgetStack*, int ); |
116 | OContactFields contactfields; | 116 | OContactFields contactfields; |
117 | 117 | ||
118 | bool useFullName; | ||
119 | |||
120 | OContact ent; | 118 | OContact ent; |
121 | 119 | ||
122 | QDialog *dlgNote; | 120 | QDialog *dlgNote; |
123 | QDialog *dlgName; | 121 | QDialog *dlgName; |