author | tille <tille> | 2002-12-19 00:00:42 (UTC) |
---|---|---|
committer | tille <tille> | 2002-12-19 00:00:42 (UTC) |
commit | 4fc6648f5953d453a31edaf288480ff2458c431f (patch) (side-by-side diff) | |
tree | aff033c63297fef4c37e561c7ce961ce3f15421f | |
parent | 7f98b97ff4b112ddc7025b34649a4ed331b37548 (diff) | |
download | opie-4fc6648f5953d453a31edaf288480ff2458c431f.zip opie-4fc6648f5953d453a31edaf288480ff2458c431f.tar.gz opie-4fc6648f5953d453a31edaf288480ff2458c431f.tar.bz2 |
fix for email <-> default email bug
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 57 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 4 |
2 files changed, 44 insertions, 17 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index cc3908a..4e73114 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -27,87 +27,87 @@ #include <qpe/qpeapplication.h> #include <qpe/qpedialog.h> #include <qpe/timeconversion.h> #include <opie/ocontact.h> #include <qpe/resource.h> #include <qcombobox.h> #include <qlabel.h> #include <qtabwidget.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qscrollview.h> #include <qtoolbutton.h> #include <qpushbutton.h> #include <qmainwindow.h> #include <qvaluelist.h> #include <qpopupmenu.h> #include <qlistbox.h> #include <qhbox.h> #include <qaction.h> #include <qiconset.h> static inline bool containsAlphaNum( const QString &str ); static inline bool constainsWhiteSpace( const QString &str ); // helper functions, convert our comma delimited list to proper // file format... void parseEmailFrom( const QString &txt, QString &strDefaultEmail, QString &strAll ); // helper convert from file format to comma delimited... -//void parseEmailTo( const QString &strDefaultEmail, -// const QString &strOtherEmail, QString &strBack ); +void parseEmailTo( const QString &strDefaultEmail, + const QString &strOtherEmail, QString &strBack ); ContactEditor::ContactEditor( const OContact &entry, QWidget *parent, const char *name, WFlags fl ) : QDialog( parent, name, TRUE, fl ), m_personalView ( false ) { init(); setEntry( entry ); cmbDefaultEmail = 0; defaultEmailChooserPosition = -1; } ContactEditor::~ContactEditor() { } void ContactEditor::init() { - + useFullName = true; uint i = 0; QStringList trlChooserNames; for (i = 0; i <= 6; i++) { slHomeAddress.append( "" ); slBusinessAddress.append( "" ); } trlChooserNames = OContactFields::trphonefields(); slChooserNames = OContactFields::untrphonefields(); slDynamicEntries = OContactFields::untrdetailsfields(); trlDynamicEntries = OContactFields::trdetailsfields(); for (i = 0; i < slChooserNames.count(); i++) slChooserValues.append(""); QVBoxLayout *vb = new QVBoxLayout( this ); tabMain = new QTabWidget( this ); vb->addWidget( tabMain ); QWidget *tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); svGeneral = new QScrollView( tabViewport ); vb->addWidget( svGeneral, 0, 0 ); svGeneral->setResizePolicy( QScrollView::AutoOneFit ); svGeneral->setFrameStyle( QFrame::NoFrame ); @@ -567,120 +567,134 @@ void ContactEditor::init() { l = new QLabel( tr("Suffix"), dlgName ); gl->addWidget( l, 3, 0 ); txtSuffix = new QLineEdit( dlgName ); gl->addWidget( txtSuffix, 3, 1 ); space = new QSpacerItem(1,1, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ); gl->addItem( space, 4, 0 ); cmbChooserField1->insertStringList( trlChooserNames ); cmbChooserField2->insertStringList( trlChooserNames ); cmbChooserField3->insertStringList( trlChooserNames ); cmbChooserField4->insertStringList( trlChooserNames ); 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( txtChooserField4, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser4Change(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( cmbChooserField4, SIGNAL(activated(int)), this, SLOT(slotCmbChooser4Change(int)) ); connect( cmbAddress, SIGNAL(activated(int)), this, SLOT(slotAddressTypeChange(int)) ); new QPEDialogListener(this); setPersonalView ( m_personalView ); } void ContactEditor::defaultEmailChanged(int i){ qDebug("defaultEmailChanged"); int index = cmbChooserField1->currentItem(); slChooserValues[index] = cmbDefaultEmail->text(i); } -void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) { +void ContactEditor::populateDefaultEmailCmb(){ + cmbDefaultEmail->clear(); + cmbDefaultEmail->insertStringList(emails); + for ( int i = 0; i < cmbDefaultEmail->count(); i++){ + qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",cmbDefaultEmail->text( i ).latin1(),defaultEmail.latin1()); + if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ + cmbDefaultEmail->setCurrentItem( i ); + qDebug("set"); + } + } +} - qDebug("defaultEmailChooserPosition %i, widgetPos %i ",defaultEmailChooserPosition,widgetPos); - if (slChooserNames[index] == "Default Email"){ +void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) { + QString type = slChooserNames[index]; + qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",type.latin1(),textChanged.latin1(), index, widgetPos ); + if ( type == "Default Email"){ + defaultEmail = textChanged; if (cmbDefaultEmail) delete cmbDefaultEmail; cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); - cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); - cmbDefaultEmail->insertStringList(ent.emailList()); - connect(cmbDefaultEmail,SIGNAL(activated(int)), - SLOT(defaultEmailChanged(int))); - QString demail = ent.defaultEmail(); - for ( int i = 0; i < cmbDefaultEmail->count(); i++) - if ( cmbDefaultEmail->text( i ) == demail ) - cmbDefaultEmail->setCurrentItem( i ); - + cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); cmbDefaultEmail->show(); + populateDefaultEmailCmb(); + connect(cmbDefaultEmail,SIGNAL(activated(int)), + SLOT(defaultEmailChanged(int))); defaultEmailChooserPosition = widgetPos; }else if (defaultEmailChooserPosition == widgetPos){ qDebug("cmbDefaultEmail->hide()"); if (cmbDefaultEmail) cmbDefaultEmail->hide(); + widgetPos=-1; + }else if (type == "Emails"){ + qDebug("emails"); + QString de; + emails = QStringList::split (",", textChanged ); + + populateDefaultEmailCmb(); } + slChooserValues[index] = textChanged; } void ContactEditor::slotChooser1Change( const QString &textChanged ) { chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); } void ContactEditor::slotChooser2Change( const QString &textChanged ) { chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); } void ContactEditor::slotChooser3Change( const QString &textChanged ) { chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); } void ContactEditor::slotChooser4Change( const QString &textChanged ) { chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); } void ContactEditor::slotAddressChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[0] = textChanged; } else { slHomeAddress[0] = textChanged; } } @@ -710,64 +724,65 @@ void ContactEditor::slotCityChange( const QString &textChanged ) { slHomeAddress[3] = textChanged; } } void ContactEditor::slotStateChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[4] = textChanged; } else { slHomeAddress[4] = textChanged; } } void ContactEditor::slotZipChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[5] = textChanged; } else { slHomeAddress[5] = textChanged; } } void ContactEditor::slotCountryChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[6] = textChanged; } else { slHomeAddress[6] = textChanged; } } + void ContactEditor::slotCmbChooser1Change( int index ) { txtChooserField1->setText( slChooserValues[index] ); txtChooserField1->setFocus(); } void ContactEditor::slotCmbChooser2Change( int index ) { txtChooserField2->setText( slChooserValues[index] ); txtChooserField2->setFocus(); } void ContactEditor::slotCmbChooser3Change( int index ) { txtChooserField3->setText( slChooserValues[index] ); txtChooserField3->setFocus(); } void ContactEditor::slotCmbChooser4Change( int index ) { txtChooserField4->setText( slChooserValues[index] ); txtChooserField4->setFocus(); } void ContactEditor::slotAddressTypeChange( int index ) { if ( index == 0 ) { txtAddress->setText( slBusinessAddress[0] ); //txtAddress2->setText( (*slBusinessAddress)[1] ); @@ -1031,106 +1046,114 @@ QString ContactEditor::parseName( const QString fullName, int type ) { } 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; } 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] = ""; } QListIterator<QLineEdit> itLV( listValue ); for ( ; itLV.current(); ++itLV ) { (*itLV)->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(""); txtCity->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; + + + 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() ); 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 (hasCity) { slHomeAddress[3] = ent.homeCity(); slBusinessAddress[3] = ent.businessCity(); //} diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index 63257f8..bcef679 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h @@ -75,84 +75,88 @@ class ContactEditor : public QDialog { void init(); void saveEntry(); bool isEmpty(); void cleanupFields(); void updateDatePicker(); QString parseName( QString fullName, int type ); private slots: void slotChooser1Change( const QString &textChanged ); void slotChooser2Change( const QString &textChanged ); void slotChooser3Change( const QString &textChanged ); void slotChooser4Change( const QString &textChanged ); void slotCmbChooser1Change( int index ); void slotCmbChooser2Change( int index ); void slotCmbChooser3Change( int index ); void slotCmbChooser4Change( int index ); void slotAddressTypeChange( int index ); void slotAddressChange( const QString &textChanged ); void slotAddress2Change( const QString &textChanged ); void slotPOBoxChange( const QString &textChanged ); void slotCityChange( const QString &textChanged ); void slotStateChange( const QString &textChanged ); void slotZipChange( const QString &textChanged ); void slotCountryChange( const QString &textChanged ); void slotFullNameChange( const QString &textChanged ); void slotAnniversaryDateChanged( int year, int month, int day); void slotBirthdayDateChanged( int year, int month, int day); void slotRemoveBirthday(); void slotRemoveAnniversary(); void defaultEmailChanged(int); private: int defaultEmailChooserPosition; + void populateDefaultEmailCmb(); void chooserChange( const QString&, int , QLineEdit*, int ); + bool useFullName; OContact ent; QDialog *dlgNote; QDialog *dlgName; QList<QLineEdit> listValue; QList<QLabel> listName; QStringList slDynamicEntries; QStringList trlDynamicEntries; bool m_personalView; QStringList slHomeAddress; QStringList slBusinessAddress; QStringList slChooserNames; QStringList slChooserValues; + QStringList emails; + QString defaultEmail; QMultiLineEdit *txtNote; QLabel *lblNote; //QLineEdit *txtTitle; QLineEdit *txtFirstName; QLineEdit *txtMiddleName; QLineEdit *txtLastName; QLineEdit *txtSuffix; QTabWidget *tabMain; QScrollView *svGeneral; QPushButton *btnFullName; QPushButton *btnNote; QLineEdit *txtFullName; QLineEdit *txtJobTitle; QLineEdit *txtOrganization; QLineEdit *txtChooserField1; QLineEdit *txtChooserField2; QLineEdit *txtChooserField3; QLineEdit *txtChooserField4; QComboBox *cmbChooserField1; QComboBox *cmbChooserField2; QComboBox *cmbChooserField3; QComboBox *cmbChooserField4; QComboBox *cmbDefaultEmail; QComboBox *cmbFileAs; CategorySelect *cmbCat; QLabel *labCat; QScrollView *svAddress; QLineEdit *txtAddress; |