summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp51
-rw-r--r--core/pim/addressbook/contacteditor.h4
2 files changed, 41 insertions, 14 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
@@ -53,14 +53,14 @@ 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 ),
@@ -593,14 +593,12 @@ void ContactEditor::init() {
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 &)) );
@@ -628,35 +626,51 @@ 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());
+ cmbDefaultEmail->show();
+ populateDefaultEmailCmb();
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->show();
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);
@@ -736,12 +750,13 @@ void ContactEditor::slotCountryChange( const QString &textChanged ) {
slBusinessAddress[6] = textChanged;
} else {
slHomeAddress[6] = textChanged;
}
}
+
void ContactEditor::slotCmbChooser1Change( int index ) {
txtChooserField1->setText( slChooserValues[index] );
txtChooserField1->setFocus();
}
@@ -1057,12 +1072,13 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
}
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] = "";
@@ -1099,12 +1115,19 @@ void ContactEditor::cleanupFields() {
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() );
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
@@ -101,13 +101,15 @@ class ContactEditor : public QDialog {
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;
@@ -121,12 +123,14 @@ class ContactEditor : public QDialog {
bool m_personalView;
QStringList slHomeAddress;
QStringList slBusinessAddress;
QStringList slChooserNames;
QStringList slChooserValues;
+ QStringList emails;
+ QString defaultEmail;
QMultiLineEdit *txtNote;
QLabel *lblNote;
//QLineEdit *txtTitle;
QLineEdit *txtFirstName;