-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 66e94ef..6d92ac3 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -404,99 +404,99 @@ void ContactEditor::init() { gl->addWidget( e, i, 1); } l = new QLabel( tr("Gender"), container ); gl->addWidget( l, slDynamicEntries->count(), 0 ); cmbGender = new QComboBox( container ); cmbGender->insertItem( "", 0 ); cmbGender->insertItem( tr("Male"), 1); cmbGender->insertItem( tr("Female"), 2); gl->addWidget( cmbGender, slDynamicEntries->count(), 1 ); tabMain->insertTab( tabViewport, tr( "Details" ) ); dlgNote = new QDialog( this, "Note Dialog", TRUE ); dlgNote->setCaption( tr("Enter Note") ); QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); txtNote = new QMultiLineEdit( dlgNote ); vbNote->addWidget( txtNote ); connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); dlgName = new QDialog( this, "Name Dialog", TRUE ); dlgName->setCaption( tr("Edit Name") ); gl = new QGridLayout( dlgName, 4, 2, 2, 3 ); l = new QLabel( tr("First Name"), dlgName ); gl->addWidget( l, 0, 0 ); txtFirstName = new QLineEdit( dlgName ); gl->addWidget( txtFirstName, 0, 1 ); l = new QLabel( tr("Middle Name"), dlgName ); gl->addWidget( l, 1, 0 ); txtMiddleName = new QLineEdit( dlgName ); gl->addWidget( txtMiddleName, 1, 1 ); l = new QLabel( tr("Last Name"), dlgName ); gl->addWidget( l, 2, 0 ); txtLastName = new QLineEdit( dlgName ); gl->addWidget( txtLastName, 2, 1 ); l = new QLabel( tr("Suffix"), dlgName ); gl->addWidget( l, 3, 0 ); txtSuffix = new QLineEdit( dlgName ); gl->addWidget( txtSuffix, 3, 1 ); cmbChooserField1->insertStringList( *slChooserNames ); cmbChooserField2->insertStringList( *slChooserNames ); cmbChooserField3->insertStringList( *slChooserNames ); - cmbChooserField1->setCurrentItem( 1 ); - cmbChooserField2->setCurrentItem( 2 ); - cmbChooserField3->setCurrentItem( 3 ); + cmbChooserField1->setCurrentItem( 0 ); + cmbChooserField2->setCurrentItem( 1 ); + cmbChooserField3->setCurrentItem( 2 ); connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); connect( txtChooserField1, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser1Change(const QString &)) ); connect( txtChooserField2, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser2Change(const QString &)) ); connect( txtChooserField3, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser3Change(const QString &)) ); connect( txtAddress, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddressChange(const QString &)) ); //connect( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) ); //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(const QString &)) ); connect( txtCity, SIGNAL(textChanged(const QString &)), this, SLOT(slotCityChange(const QString &)) ); connect( txtState, SIGNAL(textChanged(const QString &)), this, SLOT(slotStateChange(const QString &)) ); connect( txtZip, SIGNAL(textChanged(const QString &)), this, SLOT(slotZipChange(const QString &)) ); connect( cmbCountry, SIGNAL(textChanged(const QString &)), this, SLOT(slotCountryChange(const QString &)) ); connect( cmbCountry, SIGNAL(activated(const QString &)), this, SLOT(slotCountryChange(const QString &)) ); connect( cmbChooserField1, SIGNAL(activated(int)), this, SLOT(slotCmbChooser1Change(int)) ); connect( cmbChooserField2, SIGNAL(activated(int)), this, SLOT(slotCmbChooser2Change(int)) ); connect( cmbChooserField3, SIGNAL(activated(int)), this, SLOT(slotCmbChooser3Change(int)) ); connect( cmbAddress, SIGNAL(activated(int)), this, SLOT(slotAddressTypeChange(int)) ); new QPEDialogListener(this); } void ContactEditor::initMap() { /* // since the fields and the XML fields exist, create a map // between them... Config cfg1( "AddressBook" ); Config cfg2( "AddressBook" ); QString strCfg1, strCfg2; int i; // This stuff better exist... cfg1.setGroup( "AddressFields" ); o cfg2.setGroup( "XMLFields" ); i = 0; strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), QString::null ); while ( !strCfg1.isNull() && !strCfg2.isNull() ) { mapField.insert( strCfg1, strCfg2 ); strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), QString::null ); } @@ -914,443 +914,465 @@ QString ContactEditor::parseName( const QString fullName, int type ) { } 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 Contact &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.homeCity(); } 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 == "Department" ) (*itLE)->setText( ent.department() ); if ( *it == "Company" ) (*itLE)->setText( ent.company() ); if ( *it == "Office" ) (*itLE)->setText( ent.office() ); if ( *it == "Profession" ) (*itLE)->setText( ent.profession() ); if ( *it == "Assistant" ) (*itLE)->setText( ent.assistant() ); if ( *it == "Manager" ) (*itLE)->setText( ent.manager() ); if ( *it == "Spouse" ) (*itLE)->setText( ent.spouse() ); if ( *it == "Birthday" ) (*itLE)->setText( ent.birthday() ); if ( *it == "Anniversary" ) (*itLE)->setText( ent.anniversary() ); if ( *it == "Nickname" ) (*itLE)->setText( ent.nickname() ); if ( *it == "Children" ) (*itLE)->setText( ent.children() ); } QStringList::Iterator itV; for ( it = slChooserNames->begin(), itV = slChooserValues->begin(); it != slChooserNames->end(); ++it, ++itV ) { - if ( *it == "Business Phone" ) + if ( *it == "Business Phone" || *it == "Work Phone" ) *itV = ent.businessPhone(); /* if ( *it == "Business 2 Phone" ) *itV = ent.business2Phone(); */ - if ( *it == "Business Fax" ) + if ( *it == "Business Fax" || *it == "Work Fax" ) *itV = ent.businessFax(); - if ( *it == "Business Mobile" ) + if ( *it == "Business Mobile" || *it == "work Mobile" ) *itV = ent.businessMobile(); /* if ( *it == "Company Phone" ) *itV = ent.companyPhone(); */ if ( *it == "Default Email" ) *itV = ent.defaultEmail(); if ( *it == "Emails" ) *itV = ent.emails(); if ( *it == "Home Phone" ) *itV = ent.homePhone(); /* if ( *it == "Home 2 Phone" ) *itV = ent.home2Phone(); */ if ( *it == "Home Fax" ) *itV = ent.homeFax(); if ( *it == "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" ) + 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" ) + 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.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" ) ent.setProfession( (*itLE)->text() ); if ( *it == "Assistant" ) ent.setAssistant( (*itLE)->text() ); if ( *it == "Manager" ) ent.setManager( (*itLE)->text() ); if ( *it == "Spouse" ) ent.setSpouse( (*itLE)->text() ); if ( *it == "Birthday" ) ent.setBirthday( (*itLE)->text() ); if ( *it == "Anniversary" ) ent.setAnniversary( (*itLE)->text() ); if ( *it == "Nickname" ) ent.setNickname( (*itLE)->text() ); if ( *it == "Children" ) ent.setChildren( (*itLE)->text() ); } QStringList::ConstIterator itV; for ( it = slChooserNames->begin(), itV = slChooserValues->begin(); it != slChooserNames->end(); ++it, ++itV ) { - if ( *it == "Business Phone" ) + if ( *it == "Business Phone" || *it == "Work Phone" ) ent.setBusinessPhone( *itV ); /* if ( *it == "Business 2 Phone" ) ent.setBusiness2Phone( *itV ); */ - if ( *it == "Business Fax" ) + if ( *it == "Business Fax" || *it == "Work Fax" ) ent.setBusinessFax( *itV ); - if ( *it == "Business Mobile" ) + if ( *it == "Business Mobile" || *it == "Work Mobile" ) ent.setBusinessMobile( *itV ); /* if ( *it == "Company Phone" ) ent.setCompanyPhone( *itV ); */ - if ( *it == "Default Email" ) - ent.setDefaultEmail( *itV ); - - if ( *it == "Emails" ) + //if ( *it == "Default Email" ) + //ent.setDefaultEmail( *itV ); + + if ( *it == "Emails" ) { + QString allemail; + QString defaultmail; + parseEmailFrom( *itV, defaultmail, allemail ); + ent.setDefaultEmail( defaultmail ); ent.setEmails( *itV ); + } if ( *it == "Home Phone" ) ent.setHomePhone( *itV ); /* if ( *it == "Home 2 Phone" ) ent.setHome2Phone( *itV ); */ if ( *it == "Home Fax" ) ent.setHomeFax( *itV ); if ( *it == "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" ) + if ( *it == "Business Pager" || *it == "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" ) ent.setHomeWebpage( *itV ); - if ( *it == "Business Web Page" ) + if ( *it == "Business Web Page" || *it == "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; |