-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index cbcd11f..adea1a1 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -952,195 +952,195 @@ void ContactEditor::setNameFocus() { txtFullName->setFocus(); } bool ContactEditor::isEmpty() { // Test and see if the record should be saved. // More strict than the original qtopia, needs name or fileas to save QString t = txtFullName->text(); if ( !t.isEmpty() && containsAlphaNum( t ) ) return false; t = cmbFileAs->currentText(); if ( !t.isEmpty() && containsAlphaNum( t ) ) return false; return true; } QString ContactEditor::parseName( const QString fullName, int type ) { QString simplifiedName( fullName.simplifyWhiteSpace() ); QString strFirstName; QString strMiddleName; QString strLastName; QString strSuffix; QString strTitle; int commapos; int spCount; int spPos; int spPos2; commapos = simplifiedName.find( ',', 0, TRUE); spCount = simplifiedName.contains( ' ', TRUE ); if ( commapos == -1 ) { switch (spCount) { case 0: return simplifiedName; case 1: spPos = simplifiedName.find( ' ', 0, TRUE ); strFirstName = simplifiedName.left( spPos ); strLastName = simplifiedName.mid( spPos + 1 ); break; case 2: spPos = simplifiedName.find( ' ', 0, TRUE ); strFirstName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strLastName = simplifiedName.mid( spPos2 + 1 ); break; case 3: spPos = simplifiedName.find( ' ', 0, TRUE ); strFirstName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); - strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); + strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); strSuffix = simplifiedName.mid( spPos + 1 ); break; case 4: spPos = simplifiedName.find( ' ', 0, TRUE ); strTitle = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); - strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); + strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strSuffix = simplifiedName.mid( spPos2 + 1 ); break; default: spPos = simplifiedName.find( ' ', 0, TRUE ); strTitle = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); - strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); + strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strSuffix = simplifiedName.mid( spPos2 + 1 ); break; } } else { simplifiedName.replace( commapos, 1, " " ); simplifiedName = simplifiedName.simplifyWhiteSpace(); switch (spCount) { case 0: return simplifiedName; case 1: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); strFirstName = simplifiedName.mid( spPos + 1 ); break; case 2: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strMiddleName = simplifiedName.mid( spPos2 + 1 ); break; case 3: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); - strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); + strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); strSuffix = simplifiedName.mid( spPos + 1 ); break; case 4: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); - strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); + strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strSuffix = simplifiedName.mid( spPos2 + 1 ); break; default: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strSuffix = simplifiedName.mid( spPos2 + 1 ); break; } } switch (type) { case NAME_FL: return strFirstName + " " + strLastName; case NAME_LF: return strLastName + ", " + strFirstName; case NAME_LFM: return strLastName + ", " + strFirstName + " " + strMiddleName; case NAME_FMLS: return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; case NAME_F: return strFirstName; case NAME_M: return strMiddleName; case NAME_L: return strLastName; case NAME_S: return strSuffix; } } void ContactEditor::cleanupFields() { QStringList::Iterator it = slChooserValues->begin(); for ( int i = 0; it != slChooserValues->end(); i++, ++it ) { (*it) = ""; } for ( int i = 0; i < 7; i++ ) { (*slHomeAddress)[i] = ""; (*slBusinessAddress)[i] = ""; } QStringList::ConstIterator cit; QListIterator<QLineEdit> itLE( listValue ); for ( cit = slDynamicEntries->begin(); cit != slDynamicEntries->end(); ++cit, ++itLE) { (*itLE)->setText( "" ); } @@ -1318,128 +1318,129 @@ void ContactEditor::setEntry( const Contact &entry ) { *itV = ent.otherPhone(); */ if ( *it == "Business Pager" || *it == "Work Pager" ) *itV = ent.businessPager(); /* if ( *it == "Home Pager") *itV = ent.homePager(); if ( *it == "AIM IM" ) *itV = ent.AIMIM(); if ( *it == "ICQ IM" ) *itV = ent.ICQIM(); if ( *it == "Jabber IM" ) *itV = ent.jabberIM(); if ( *it == "MSN IM" ) *itV = ent.MSNIM(); if ( *it == "Yahoo IM" ) *itV = ent.yahooIM(); */ if ( *it == "Home Web Page" ) *itV = ent.homeWebpage(); if ( *it == "Business Web Page" || *it == "Work Web Page" ) *itV = ent.businessWebpage(); } cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); QString gender = ent.gender(); cmbGender->setCurrentItem( gender.toInt() ); txtNote->setText( ent.notes() ); slotCmbChooser1Change( cmbChooserField1->currentItem() ); slotCmbChooser2Change( cmbChooserField2->currentItem() ); slotCmbChooser3Change( cmbChooserField3->currentItem() ); slotAddressTypeChange( cmbAddress->currentItem() ); } void ContactEditor::saveEntry() { if ( useFullName == TRUE ) { 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; } /*if ( ent.firstName() != txtFirstName->text() || ent.lastName != txtLastName->text() || ent.middleName != txtMiddleName->text() ) { */ ent.setFirstName( txtFirstName->text() ); ent.setLastName( txtLastName->text() ); ent.setMiddleName( txtMiddleName->text() ); + ent.setSuffix( txtSuffix->text() ); //} ent.setFileAs( cmbFileAs->currentText() ); ent.setCategories( cmbCat->currentCategories() ); if (hasTitle) ent.setJobTitle( txtJobTitle->text() ); if (hasCompany) ent.setCompany( txtOrganization->text() ); if (hasNotes) ent.setNotes( txtNote->text() ); if (hasStreet) { ent.setHomeStreet( (*slHomeAddress)[0] ); ent.setBusinessStreet( (*slBusinessAddress)[0] ); } /* if (hasStreet2) { ent.setHomeStreet2( (*slHomeAddress)[1] ); ent.setBusinessStreet2( (*slBusinessAddress)[1] ); } if (hasPOBox) { ent.setHomePOBox( (*slHomeAddress)[2] ); ent.setBusinessPOBox( (*slBusinessAddress)[2] ); } */ if (hasCity) { ent.setHomeCity( (*slHomeAddress)[3] ); ent.setBusinessCity( (*slBusinessAddress)[3] ); } if (hasState) { ent.setHomeState( (*slHomeAddress)[4] ); ent.setBusinessState( (*slBusinessAddress)[4] ); } if (hasZip) { ent.setHomeZip( (*slHomeAddress)[5] ); ent.setBusinessZip( (*slBusinessAddress)[5] ); } if (hasCountry) { ent.setHomeCountry( (*slHomeAddress)[6] ); ent.setBusinessCountry( (*slBusinessAddress)[6] ); } QStringList::ConstIterator it; QListIterator<QLineEdit> itLE( listValue ); for ( it = slDynamicEntries->begin(); it != slDynamicEntries->end(); ++it, ++itLE) { if ( *it == "Department" ) ent.setDepartment( (*itLE)->text() ); if ( *it == "Company" ) ent.setCompany( (*itLE)->text() ); if ( *it == "Office" ) ent.setOffice( (*itLE)->text() ); if ( *it == "Profession" ) |