summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index fd7f009..5c1391b 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1228,530 +1228,531 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
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;
}
return QString::null;
}
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( "" );
}
txtFirstName->setText("");
txtMiddleName->setText("");
txtLastName->setText("");
txtSuffix->setText("");
txtNote->setText("");
txtFullName->setText("");
txtJobTitle->setText("");
txtOrganization->setText("");
txtChooserField1->setText("");
txtChooserField2->setText("");
txtChooserField3->setText("");
txtAddress->setText("");
//txtAddress2->setText("");
txtCity->setText("");
//txtPOBox->setText("");
txtState->setText("");
txtZip->setText("");
QLineEdit *txtTmp = cmbCountry->lineEdit();
txtTmp->setText("");
txtTmp = cmbFileAs->lineEdit();
txtTmp->setText("");
}
void ContactEditor::setEntry( const OContact &entry ) {
cleanupFields();
ent = entry;
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() );
cmbFileAs->setEditText( ent.fileAs() );
if (hasTitle)
txtJobTitle->setText( ent.jobTitle() );
if (hasCompany)
txtOrganization->setText( ent.company() );
if (hasNotes)
txtNote->setText( ent.notes() );
if (hasStreet) {
slHomeAddress[0] = ent.homeStreet();
slBusinessAddress[0] = ent.businessStreet();
}
/*
if (hasStreet2) {
(*slHomeAddress)[1] = ent.homeStreet2();
(*slBusinessAddress)[1] = ent.businessStreet2();
}
if (hasPOBox) {
(*slHomeAddress)[2] = ent.homePOBox();
(*slBusinessAddress)[2] = ent.businessPOBox();
}
*/
if (hasCity) {
slHomeAddress[3] = ent.homeCity();
slBusinessAddress[3] = ent.businessCity();
}
if (hasState) {
slHomeAddress[4] = ent.homeState();
slBusinessAddress[4] = ent.businessState();
}
if (hasZip) {
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 == tr("Department") )
(*itLE)->setText( ent.department() );
if ( *it == tr("Company" ))
(*itLE)->setText( ent.company() );
if ( *it == tr("Office" ))
(*itLE)->setText( ent.office() );
if ( *it == tr("Profession" ))
(*itLE)->setText( ent.profession() );
if ( *it == tr("Assistant" ))
(*itLE)->setText( ent.assistant() );
if ( *it == tr("Manager" ))
(*itLE)->setText( ent.manager() );
if ( *it == tr("Spouse" ))
(*itLE)->setText( ent.spouse() );
if ( *it == tr("Birthday" ))
(*itLE)->setText( ent.birthday() );
if ( *it == tr("Anniversary" ))
(*itLE)->setText( ent.anniversary() );
if ( *it == tr("Nickname" ))
(*itLE)->setText( ent.nickname() );
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 == tr("Business Phone") || *it == tr("Work Phone" ))
*itV = ent.businessPhone();
/*
if ( *it == "Business 2 Phone" )
*itV = ent.business2Phone();
*/
if ( *it == tr("Business Fax") || *it == tr("Work Fax" ))
*itV = ent.businessFax();
if ( *it == tr("Business Mobile") || *it == tr("work Mobile" ))
*itV = ent.businessMobile();
/*
if ( *it == "Company Phone" )
*itV = ent.companyPhone();
*/
if ( *it == tr("Default Email" ))
*itV = ent.defaultEmail();
if ( *it == tr("Emails" ))
- *itV = ent.emailList().join(";");
+ *itV = ent.emailList().join(","); // :SX
if ( *it == tr("Home Phone" ))
*itV = ent.homePhone();
/*
if ( *it == "Home 2 Phone" )
*itV = ent.home2Phone();
*/
if ( *it == tr("Home Fax" ))
*itV = ent.homeFax();
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 == 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 == tr("Home Web Page") )
*itV = ent.homeWebpage();
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() );
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 == tr("Department" ))
ent.setDepartment( (*itLE)->text() );
if ( *it == tr("Company" ))
ent.setCompany( (*itLE)->text() );
if ( *it == tr("Office" ))
ent.setOffice( (*itLE)->text() );
if ( *it == tr("Profession" ))
ent.setProfession( (*itLE)->text() );
if ( *it == tr("Assistant" ))
ent.setAssistant( (*itLE)->text() );
if ( *it == tr("Manager" ))
ent.setManager( (*itLE)->text() );
if ( *it == tr("Spouse" ))
ent.setSpouse( (*itLE)->text() );
if ( *it == tr("Birthday" ))
ent.setBirthday( (*itLE)->text() );
if ( *it == tr("Anniversary" ))
ent.setAnniversary( (*itLE)->text() );
if ( *it == tr("Nickname" ))
ent.setNickname( (*itLE)->text() );
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 == tr("Business Phone") || *it == tr("Work Phone" ))
ent.setBusinessPhone( *itV );
/*
if ( *it == tr("Business 2 Phone" )
ent.setBusiness2Phone( *itV );
*/
if ( *it == tr("Business Fax") || *it == tr("Work Fax" ))
ent.setBusinessFax( *itV );
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 == tr("Emails" )) {
QString allemail;
QString defaultmail;
parseEmailFrom( *itV, defaultmail, allemail );
+ ent.clearEmails();
ent.setDefaultEmail( defaultmail );
ent.insertEmails( *itV );
}
if ( *it == tr("Home Phone" ))
ent.setHomePhone( *itV );
/*
if ( *it == "Home 2 Phone" )
ent.setHome2Phone( *itV );
*/
if ( *it == tr("Home Fax" ))
ent.setHomeFax( *itV );
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 == 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 == tr("Home Web Page") )
ent.setHomeWebpage( *itV );
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 );
}
void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
QString &strAll )
{
int where,
start;
if ( txt.isEmpty() )
return;
// find the first
where = txt.find( ',' );
if ( where < 0 ) {
strDefaultEmail = txt;
strAll = txt;
} else {
strDefaultEmail = txt.left( where ).stripWhiteSpace();
strAll = strDefaultEmail;
while ( where > -1 ) {
strAll.append(" ");
start = where;
where = txt.find( ',', where + 1 );
if ( where > - 1 )
strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
else // grab until the end...
strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
}
}
}
void parseEmailTo( const QString &strDefaultEmail,
const QString &strOtherEmail, QString &strBack )
{
// create a comma dilimeted set of emails...
// use the power of short circuiting...
bool foundDefault = false;
QString strTmp;
int start = 0;
int where;
// start at the beginng.
strBack = strDefaultEmail;
where = 0;
while ( where > -1 ) {
start = where;
where = strOtherEmail.find( ' ', where + 1 );
if ( where > 0 ) {
strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
} else
strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
if ( foundDefault || strTmp != strDefaultEmail ) {
strBack.append( ", " );
strBack.append( strTmp );
} else
foundDefault = true;
}
}
static inline bool containsAlphaNum( const QString &str )
{
int i,
count = str.length();
for ( i = 0; i < count; i++ )
if ( !str[i].isSpace() )
return TRUE;
return FALSE;
}
static inline bool constainsWhiteSpace( const QString &str )
{
int i,
count = str.length();
for (i = 0; i < count; i++ )
if ( str[i].isSpace() )
return TRUE;
return FALSE;
}