-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 @@ -84,18 +84,16 @@ ContactEditor::ContactEditor( const OContact &entry, } ContactEditor::~ContactEditor() { } void ContactEditor::init() { qWarning("init() START"); - useFullName = true; - uint i = 0; QStringList trlChooserNames; for (i = 0; i <= 6; i++) { slHomeAddress.append( "" ); slBusinessAddress.append( "" ); } @@ -1026,21 +1024,22 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) { int index = cmbFileAs->currentItem(); cmbFileAs->clear(); cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) ); 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; } void ContactEditor::slotSuffixChange( const QString& ) { // Just want to update the FileAs combo if the suffix was changed.. slotFullNameChange( txtFullName->text() ); } @@ -1063,29 +1062,31 @@ void ContactEditor::slotNote() { if ( !dlgNote->exec() ) { txtNote->setText( ent.notes() ); } } 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; } } void ContactEditor::setNameFocus() { txtFullName->setFocus(); @@ -1174,18 +1175,18 @@ QString ContactEditor::parseName( const QString fullName, int type ) { return strFirstName + " " + strLastName; case NAME_LF: return strLastName + ", " + strFirstName; case NAME_LFM: return strLastName + ", " + strFirstName + " " + strMiddleName; - case NAME_FMLS: - return strFirstName + " " + strMiddleName + " " + strLastName + " " + txtSuffix->text(); + case NAME_FML: + return strFirstName + " " + strMiddleName + " " + strLastName ; case NAME_F: return strFirstName; case NAME_M: return strMiddleName; case NAME_L: @@ -1245,32 +1246,33 @@ void ContactEditor::setEntry( const OContact &entry ) { ent = entry; emails = QStringList(ent.emailList()); defaultEmail = ent.defaultEmail(); if (defaultEmail.isEmpty()) defaultEmail = emails[0]; qDebug("default email=%s",defaultEmail.latin1()); - useFullName = false; txtFirstName->setText( ent.firstName() ); txtMiddleName->setText( ent.middleName() ); txtLastName->setText( ent.lastName() ); txtSuffix->setText( ent.suffix() ); // QString *tmpString = new QString; // *tmpString = ent.firstName() + " " + ent.middleName() + // + " " + ent.lastName() + " " + ent.suffix(); // txtFullName->setText( tmpString->simplifyWhiteSpace() ); + if ( !ent.isEmpty() ){ // Lastnames with multiple words need to be protected by a comma ! if ( ent.lastName().contains( ' ', TRUE ) ) txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); else txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); + } cmbFileAs->setEditText( ent.fileAs() ); // if (hasTitle) txtJobTitle->setText( ent.jobTitle() ); // if (hasCompany) txtOrganization->setText( ent.company() ); @@ -1420,24 +1422,16 @@ void ContactEditor::setEntry( const OContact &entry ) { QString gender = ent.gender(); cmbGender->setCurrentItem( gender.toInt() ); txtNote->setText( ent.notes() ); 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 ); cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) ); cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) ); cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) ); cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) ); cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) ); slotCmbChooser1Change( cmbChooserField1->currentItem() ); @@ -1467,25 +1461,21 @@ void ContactEditor::updateDatePicker() } void ContactEditor::saveEntry() { // Store current combo into contact contactfields.saveToRecord( ent ); - 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 ) ); - useFullName = false; - } - ent.setFirstName( txtFirstName->text() ); ent.setLastName( txtLastName->text() ); ent.setMiddleName( txtMiddleName->text() ); ent.setSuffix( txtSuffix->text() ); ent.setFileAs( cmbFileAs->currentText() ); ent.setCategories( cmbCat->currentCategories() ); 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 @@ -31,17 +31,17 @@ #include <qstringlist.h> #include <qwidgetstack.h> #include "ocontactfields.h" 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; const int NAME_M = 5; const int NAME_L = 6; const int NAME_S = 7; class QScrollView; @@ -110,18 +110,16 @@ class ContactEditor : public QDialog { private: enum StackWidgets { TextField = 1, Combo }; int defaultEmailChooserPosition; void populateDefaultEmailCmb(); void chooserChange( const QString&, int , QLineEdit*, int ); bool cmbChooserChange( int , QWidgetStack*, int ); OContactFields contactfields; - bool useFullName; - OContact ent; QDialog *dlgNote; QDialog *dlgName; QList<QLineEdit> listValue; QList<QLabel> listName; |