-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 216 |
1 files changed, 155 insertions, 61 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index fa60f98..d419142 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -96,80 +96,114 @@ void ContactEditor::init() { hasNotes = FALSE; hasStreet = FALSE; hasStreet2 = FALSE; hasPOBox = FALSE; hasCity = FALSE; hasState = FALSE; hasZip = FALSE; hasCountry = FALSE; QStringList::ConstIterator it = slOrdered.begin(); for ( i = 0; it != slOrdered.end(); i++, ++it ) { - if ( (*it).right( 3 ) == tr( "Fax" ) ) { + if ( (*it) == tr( "Business Fax" ) ) { slChooserNames.append( *it ); slChooserValues.append("" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it).right( 5 ) == tr( "Phone" ) ) { + if ( (*it) == tr( "Home Fax" ) ) { slChooserNames.append( *it ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } + + if ( (*it) == tr( "Business Phone" ) ) { + slChooserNames.append( *it ); + slChooserValues.append( "" ); + //slDynamicEntries->remove( it ); + continue; + } + + if ( (*it) == tr( "Home Phone" ) ) { + slChooserNames.append( *it ); + slChooserValues.append( "" ); + //slDynamicEntries->remove( it ); + continue; + } + +/* if ( (*it).right( 2 ) == tr( "IM" ) ) { slChooserNames.append( *it ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; + } */ + + if ( (*it) == tr( "Business Mobile" ) ) { + slChooserNames.append( *it ); + slChooserValues.append( "" ); + //slDynamicEntries->remove( it ); + continue; } - if ( (*it).right( 6 ) == tr( "Mobile" ) ) { + if ( (*it) == tr( "Home Mobile" ) ) { slChooserNames.append( *it ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it).right( 4 ) == tr( "Page" ) ) { + + if ( (*it) == tr( "Business WebPage" ) ) { slChooserNames.append( *it ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it).right( 5 ) == tr( "Pager" ) ) { + if ( (*it) == tr( "Home Web Page" ) ) { + slChooserNames.append( *it ); + slChooserValues.append( "" ); + //slDynamicEntries->remove( it ); + continue; + } + + if ( (*it) == tr( "Business Pager" ) ) { slChooserNames.append( *it ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } if ( *it == tr( "Default Email" ) ) { slChooserNames.append( *it ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } if ( *it == tr( "Emails" ) ) { slChooserNames.append( *it ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } + if ( *it == "Name Title" || *it == "First Name" || *it == "Middle Name" || *it == "Last Name" || *it == "File As" || *it == "Default Email" || *it == "Emails" || *it == "Groups" ) + continue; + if ( *it == tr( "Name Title" ) ) { //slDynamicEntries->remove( it ); continue; } if ( *it == tr( "First Name" ) ) { // slDynamicEntries->remove( it ); continue; } if ( *it == tr( "Middle Name" ) ) { // slDynamicEntries->remove( it ); @@ -194,83 +228,114 @@ void ContactEditor::init() { if ( *it == tr( "Gender" ) ) { hasGender = TRUE; // slDynamicEntries->remove( it ); continue; } if ( *it == tr( "Job Title" ) ) { hasTitle = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Company" ) ) { + if ( *it == tr( "Company") || *it == tr( "Organization" ) ) { hasCompany = TRUE; // slDynamicEntries->remove( it ); continue; } if ( *it == tr( "Notes" ) ) { hasNotes = TRUE; // slDynamicEntries->remove( it ); continue; } if ( *it == tr( "Groups" ) ) { // slDynamicEntries->remove( it ); continue; } - if ( (*it).right( 6 ) == tr( "Street" ) ) { + if ( (*it) == tr( "Business Street" ) ) { hasStreet = TRUE; // slDynamicEntries->remove( it ); continue; } + if ( (*it) == tr( "Home Street" ) ) { + hasStreet = TRUE; + // slDynamicEntries->remove( it ); + continue; + } +/* if ( (*it).right( 8 ) == tr( "Street 2" ) ) { hasStreet2 = TRUE; // slDynamicEntries->remove( it ); continue; } if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) { hasPOBox = TRUE; // slDynamicEntries->remove( it ); continue; + } */ + + if ( (*it) == tr( "Business City" ) ) { + hasCity = TRUE; + // slDynamicEntries->remove( it ); + continue; } - if ( (*it).right( 4 ) == tr( "City" ) ) { + if ( (*it) == tr( "Business State" ) ) { + hasState = TRUE; + // slDynamicEntries->remove( it ); + continue; + } + + if ( (*it) == tr( "Business Zip" ) ) { + hasZip = TRUE; + // slDynamicEntries->remove( it ); + continue; + } + + if ( (*it) == tr( "Business Country" ) ) { + hasCountry = TRUE; + // slDynamicEntries->remove( it ); + continue; + } + + if ( (*it) == tr( "Home City" ) ) { hasCity = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it).right( 5 ) == tr( "State" ) ) { + if ( (*it) == tr( "Home State" ) ) { hasState = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it).right( 3 ) == tr( "Zip" ) ) { + if ( (*it) == tr( "Home Zip" ) ) { hasZip = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it).right( 7 ) == tr( "Country" ) ) { + if ( (*it) == tr( "Home Country" ) ) { hasCountry = TRUE; // slDynamicEntries->remove( it ); continue; } + slDynamicEntries.append( *it ); } } QVBoxLayout *vb = new QVBoxLayout( this ); tabMain = new QTabWidget( this ); vb->addWidget( tabMain ); QWidget *tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); @@ -951,34 +1016,36 @@ void ContactEditor::accept() { } void ContactEditor::slotNote() { dlgNote->showMaximized(); if ( !dlgNote->exec() ) { txtNote->setText( ent.notes() ); } } void ContactEditor::slotName() { - if (useFullName = TRUE) { + QString tmpName; + 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) ); } - dlgName->showMaximized(); if ( dlgName->exec() ) { - txtFullName->setText( txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text() ); + + tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); + txtFullName->setText( tmpName.simplifyWhiteSpace() ); slotFullNameChange( txtFullName->text() ); useFullName = FALSE; } } void ContactEditor::setNameFocus() { txtFullName->setFocus(); } @@ -1010,25 +1077,39 @@ QString ContactEditor::parseName( const QString fullName, int type ) { int spCount; int spPos; int spPos2; commapos = simplifiedName.find( ',', 0, TRUE); spCount = simplifiedName.contains( ' ', TRUE ); if ( commapos == -1 ) { switch (spCount) { case 0: - return simplifiedName; + //return simplifiedName; + if (txtLastName->text() != "") { + strLastName = simplifiedName; + break; + } + if (txtMiddleName->text() != "") { + strMiddleName = simplifiedName; + break; + } + if (txtSuffix->text() != "") { + strSuffix = simplifiedName; + break; + } + strFirstName = simplifiedName; + break; 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 ); @@ -1066,25 +1147,39 @@ QString ContactEditor::parseName( const QString fullName, int type ) { 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; + //return simplifiedName; + if (txtLastName->text() != "") { + strLastName = simplifiedName; + break; + } + if (txtMiddleName->text() != "") { + strMiddleName = simplifiedName; + break; + } + if (txtSuffix->text() != "") { + strSuffix = simplifiedName; + break; + } + strFirstName = simplifiedName; + break; 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 ); @@ -1117,25 +1212,24 @@ QString ContactEditor::parseName( const QString fullName, int type ) { 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; @@ -1257,128 +1351,128 @@ void ContactEditor::setEntry( const Contact &entry ) { slHomeAddress[5] = ent.homeZip(); slBusinessAddress[5] = ent.businessZip(); } if (hasCountry) { slHomeAddress[6] = ent.homeCountry(); slBusinessAddress[6] = ent.businessCountry(); } QStringList::ConstIterator it; QListIterator<QLineEdit> itLE( listValue ); for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { - if ( *it == "Department" ) + if ( *it == tr("Department") ) (*itLE)->setText( ent.department() ); - if ( *it == "Company" ) + if ( *it == tr("Company" )) (*itLE)->setText( ent.company() ); - if ( *it == "Office" ) + if ( *it == tr("Office" )) (*itLE)->setText( ent.office() ); - if ( *it == "Profession" ) + if ( *it == tr("Profession" )) (*itLE)->setText( ent.profession() ); - if ( *it == "Assistant" ) + if ( *it == tr("Assistant" )) (*itLE)->setText( ent.assistant() ); - if ( *it == "Manager" ) + if ( *it == tr("Manager" )) (*itLE)->setText( ent.manager() ); - if ( *it == "Spouse" ) + if ( *it == tr("Spouse" )) (*itLE)->setText( ent.spouse() ); - if ( *it == "Birthday" ) + if ( *it == tr("Birthday" )) (*itLE)->setText( ent.birthday() ); - if ( *it == "Anniversary" ) + if ( *it == tr("Anniversary" )) (*itLE)->setText( ent.anniversary() ); - if ( *it == "Nickname" ) + if ( *it == tr("Nickname" )) (*itLE)->setText( ent.nickname() ); - if ( *it == "Children" ) + if ( *it == tr("Children" )) (*itLE)->setText( ent.children() ); } QStringList::Iterator itV; for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { - if ( *it == "Business Phone" || *it == "Work Phone" ) + if ( *it == tr("Business Phone") || *it == tr("Work Phone" )) *itV = ent.businessPhone(); /* if ( *it == "Business 2 Phone" ) *itV = ent.business2Phone(); */ - if ( *it == "Business Fax" || *it == "Work Fax" ) + if ( *it == tr("Business Fax") || *it == tr("Work Fax" )) *itV = ent.businessFax(); - if ( *it == "Business Mobile" || *it == "work Mobile" ) + if ( *it == tr("Business Mobile") || *it == tr("work Mobile" )) *itV = ent.businessMobile(); /* if ( *it == "Company Phone" ) *itV = ent.companyPhone(); */ - if ( *it == "Default Email" ) + if ( *it == tr("Default Email" )) *itV = ent.defaultEmail(); - if ( *it == "Emails" ) + if ( *it == tr("Emails" )) *itV = ent.emails(); - if ( *it == "Home Phone" ) + if ( *it == tr("Home Phone" )) *itV = ent.homePhone(); /* if ( *it == "Home 2 Phone" ) *itV = ent.home2Phone(); */ - if ( *it == "Home Fax" ) + if ( *it == tr("Home Fax" )) *itV = ent.homeFax(); - if ( *it == "Home Mobile" ) + if ( *it == tr("Home Mobile" )) *itV = ent.homeMobile(); /* if ( *it == "Car Phone" ) *itV = ent.carPhone(); if ( *it == "ISDN Phone" ) *itV = ent.ISDNPhone(); if ( *it == "Other Phone" ) *itV = ent.otherPhone(); */ - if ( *it == "Business Pager" || *it == "Work Pager" ) + if ( *it == tr("Business Pager") || *it == tr("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" ) + if ( *it == tr("Home Web Page") ) *itV = ent.homeWebpage(); - if ( *it == "Business Web Page" || *it == "Work Web Page" ) + if ( *it == tr("Business WebPage") || *it == tr("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() ); @@ -1454,133 +1548,133 @@ void ContactEditor::saveEntry() { 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" ) + if ( *it == tr("Department" )) ent.setDepartment( (*itLE)->text() ); - if ( *it == "Company" ) + if ( *it == tr("Company" )) ent.setCompany( (*itLE)->text() ); - if ( *it == "Office" ) + if ( *it == tr("Office" )) ent.setOffice( (*itLE)->text() ); - if ( *it == "Profession" ) + if ( *it == tr("Profession" )) ent.setProfession( (*itLE)->text() ); - if ( *it == "Assistant" ) + if ( *it == tr("Assistant" )) ent.setAssistant( (*itLE)->text() ); - if ( *it == "Manager" ) + if ( *it == tr("Manager" )) ent.setManager( (*itLE)->text() ); - if ( *it == "Spouse" ) + if ( *it == tr("Spouse" )) ent.setSpouse( (*itLE)->text() ); - if ( *it == "Birthday" ) + if ( *it == tr("Birthday" )) ent.setBirthday( (*itLE)->text() ); - if ( *it == "Anniversary" ) + if ( *it == tr("Anniversary" )) ent.setAnniversary( (*itLE)->text() ); - if ( *it == "Nickname" ) + if ( *it == tr("Nickname" )) ent.setNickname( (*itLE)->text() ); - if ( *it == "Children" ) + if ( *it == tr("Children" )) ent.setChildren( (*itLE)->text() ); } QStringList::ConstIterator itV; for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { - if ( *it == "Business Phone" || *it == "Work Phone" ) + if ( *it == tr("Business Phone") || *it == tr("Work Phone" )) ent.setBusinessPhone( *itV ); /* - if ( *it == "Business 2 Phone" ) + if ( *it == tr("Business 2 Phone" ) ent.setBusiness2Phone( *itV ); */ - if ( *it == "Business Fax" || *it == "Work Fax" ) + if ( *it == tr("Business Fax") || *it == tr("Work Fax" )) ent.setBusinessFax( *itV ); - if ( *it == "Business Mobile" || *it == "Work Mobile" ) + if ( *it == tr("Business Mobile") || *it == tr("Work Mobile" )) ent.setBusinessMobile( *itV ); /* if ( *it == "Company Phone" ) ent.setCompanyPhone( *itV ); */ //if ( *it == "Default Email" ) //ent.setDefaultEmail( *itV ); - if ( *it == "Emails" ) { + if ( *it == tr("Emails" )) { QString allemail; QString defaultmail; parseEmailFrom( *itV, defaultmail, allemail ); ent.setDefaultEmail( defaultmail ); ent.setEmails( *itV ); } - if ( *it == "Home Phone" ) + if ( *it == tr("Home Phone" )) ent.setHomePhone( *itV ); /* if ( *it == "Home 2 Phone" ) ent.setHome2Phone( *itV ); */ - if ( *it == "Home Fax" ) + if ( *it == tr("Home Fax" )) ent.setHomeFax( *itV ); - if ( *it == "Home Mobile" ) + if ( *it == tr("Home Mobile" )) ent.setHomeMobile( *itV ); /* if ( *it == "Car Phone" ) ent.setCarPhone( *itV ); if ( *it == "ISDN Phone" ) ent.setISDNPhone( *itV ); if ( *it == "Other Phone" ) ent.setOtherPhone( *itV ); */ - if ( *it == "Business Pager" || *it == "Work Pager" ) + if ( *it == tr("Business Pager") || *it == tr("Work Pager") ) ent.setBusinessPager( *itV ); /* if ( *it == "Home Pager" ) ent.setHomePager( *itV ); if ( *it == "AIM IM" ) ent.setAIMIM( *itV ); if ( *it == "ICQ IM" ) ent.setICQIM( *itV ); if ( *it == "Jabber IM" ) ent.setJabberIM( *itV ); if ( *it == "MSN IM" ) ent.setMSNIM( *itV ); if ( *it == "Yahoo IM" ) ent.setYahooIM( *itV ); */ - if ( *it == "Home Web Page" ) + if ( *it == tr("Home Web Page") ) ent.setHomeWebpage( *itV ); - if ( *it == "Business Web Page" || *it == "Work Web Page" ) + if ( *it == tr("Business WebPage") || *it == tr("Work Web Page" )) ent.setBusinessWebpage( *itV ); } int gender = cmbGender->currentItem(); ent.setGender( QString::number( gender ) ); QString str = txtNote->text(); if ( !str.isNull() ) ent.setNotes( str ); |