-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 36 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 4 |
2 files changed, 14 insertions, 26 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 @@ -90,6 +90,4 @@ void ContactEditor::init() { qWarning("init() START"); - useFullName = true; - uint i = 0; @@ -1032,9 +1030,10 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) { cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) ); cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); - cmbFileAs->insertItem( parseName( textChanged, NAME_FMLS ) ); + cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) ); + if ( ! txtSuffix->text().isEmpty() ) + cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() ); cmbFileAs->setCurrentItem( index ); - useFullName = true; } @@ -1069,17 +1068,19 @@ void ContactEditor::slotName() { QString tmpName; - if (useFullName) { + txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); - } + dlgName->showMaximized(); if ( dlgName->exec() ) { - + if ( txtLastName->text().contains( ' ', TRUE ) ) + tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); + else tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); + txtFullName->setText( tmpName.simplifyWhiteSpace() ); slotFullNameChange( txtFullName->text() ); - useFullName = false; } @@ -1180,6 +1181,6 @@ QString ContactEditor::parseName( const QString fullName, int type ) { return strLastName + ", " + strFirstName + " " + strMiddleName; - case NAME_FMLS: - return strFirstName + " " + strMiddleName + " " + strLastName + " " + txtSuffix->text(); + case NAME_FML: + return strFirstName + " " + strMiddleName + " " + strLastName ; case NAME_F: @@ -1251,5 +1252,4 @@ void ContactEditor::setEntry( const OContact &entry ) { qDebug("default email=%s",defaultEmail.latin1()); - useFullName = false; txtFirstName->setText( ent.firstName() ); txtMiddleName->setText( ent.middleName() ); @@ -1262,4 +1262,5 @@ void ContactEditor::setEntry( const OContact &entry ) { // txtFullName->setText( tmpString->simplifyWhiteSpace() ); + if ( !ent.isEmpty() ){ // Lastnames with multiple words need to be protected by a comma ! if ( ent.lastName().contains( ' ', TRUE ) ) @@ -1267,4 +1268,5 @@ void ContactEditor::setEntry( const OContact &entry ) { else txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); + } cmbFileAs->setEditText( ent.fileAs() ); @@ -1426,12 +1428,4 @@ void ContactEditor::setEntry( const OContact &entry ) { slotAddressTypeChange( cmbAddress->currentItem() ); - // Calling "show()" to arrange all widgets. Otherwise we will get - // a wrong position of the textfields and are unable to put our - // default-email combo over it.. This is very ugly ! - // Does anybody has a better solution ? - // Basically we should rethink the strategy to hide - // a textfield with overwriting.. (se) - show(); - // Get combo-settings from contact and set preset.. contactfields.loadFromRecord( ent ); @@ -1473,5 +1467,4 @@ void ContactEditor::saveEntry() { contactfields.saveToRecord( ent ); - if ( useFullName ) { txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); @@ -1479,7 +1472,4 @@ void ContactEditor::saveEntry() { // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); - useFullName = false; - } - ent.setFirstName( txtFirstName->text() ); ent.setLastName( txtLastName->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 @@ -37,5 +37,5 @@ const int NAME_LF = 0; const int NAME_LFM = 1; const int NAME_FL = 2; -const int NAME_FMLS = 3; +const int NAME_FML = 3; const int NAME_F = 4; @@ -116,6 +116,4 @@ class ContactEditor : public QDialog { OContactFields contactfields; - bool useFullName; - OContact ent; |