summaryrefslogtreecommitdiff
authortille <tille>2002-12-19 00:00:42 (UTC)
committer tille <tille>2002-12-19 00:00:42 (UTC)
commit4fc6648f5953d453a31edaf288480ff2458c431f (patch) (unidiff)
treeaff033c63297fef4c37e561c7ce961ce3f15421f
parent7f98b97ff4b112ddc7025b34649a4ed331b37548 (diff)
downloadopie-4fc6648f5953d453a31edaf288480ff2458c431f.zip
opie-4fc6648f5953d453a31edaf288480ff2458c431f.tar.gz
opie-4fc6648f5953d453a31edaf288480ff2458c431f.tar.bz2
fix for email <-> default email bug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp57
-rw-r--r--core/pim/addressbook/contacteditor.h4
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
@@ -53,14 +53,14 @@ static inline bool constainsWhiteSpace( const QString &str );
53// helper functions, convert our comma delimited list to proper 53// helper functions, convert our comma delimited list to proper
54// file format... 54// file format...
55void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 55void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
56 QString &strAll ); 56 QString &strAll );
57 57
58// helper convert from file format to comma delimited... 58// helper convert from file format to comma delimited...
59//void parseEmailTo( const QString &strDefaultEmail, 59void parseEmailTo( const QString &strDefaultEmail,
60 // const QString &strOtherEmail, QString &strBack ); 60 const QString &strOtherEmail, QString &strBack );
61 61
62 ContactEditor::ContactEditor(const OContact &entry, 62 ContactEditor::ContactEditor(const OContact &entry,
63 QWidget *parent, 63 QWidget *parent,
64 const char *name, 64 const char *name,
65 WFlags fl ) 65 WFlags fl )
66 : QDialog( parent, name, TRUE, fl ), 66 : QDialog( parent, name, TRUE, fl ),
@@ -75,13 +75,13 @@ ContactEditor::ContactEditor( const OContact &entry,
75} 75}
76 76
77ContactEditor::~ContactEditor() { 77ContactEditor::~ContactEditor() {
78} 78}
79 79
80void ContactEditor::init() { 80void ContactEditor::init() {
81 81
82 useFullName = true; 82 useFullName = true;
83 83
84 uint i = 0; 84 uint i = 0;
85 85
86 QStringList trlChooserNames; 86 QStringList trlChooserNames;
87 87
@@ -593,14 +593,12 @@ void ContactEditor::init() {
593 connect( txtChooserField3, SIGNAL(textChanged(const QString &)), 593 connect( txtChooserField3, SIGNAL(textChanged(const QString &)),
594 this, SLOT(slotChooser3Change(const QString &)) ); 594 this, SLOT(slotChooser3Change(const QString &)) );
595 connect( txtChooserField4, SIGNAL(textChanged(const QString &)), 595 connect( txtChooserField4, SIGNAL(textChanged(const QString &)),
596 this, SLOT(slotChooser4Change(const QString &)) ); 596 this, SLOT(slotChooser4Change(const QString &)) );
597 connect( txtAddress, SIGNAL(textChanged(const QString &)), 597 connect( txtAddress, SIGNAL(textChanged(const QString &)),
598 this, SLOT(slotAddressChange(const QString &)) ); 598 this, SLOT(slotAddressChange(const QString &)) );
599 //connect( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) );
600 //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(const QString &)) );
601 connect( txtCity, SIGNAL(textChanged(const QString &)), 599 connect( txtCity, SIGNAL(textChanged(const QString &)),
602 this, SLOT(slotCityChange(const QString &)) ); 600 this, SLOT(slotCityChange(const QString &)) );
603 connect( txtState, SIGNAL(textChanged(const QString &)), 601 connect( txtState, SIGNAL(textChanged(const QString &)),
604 this, SLOT(slotStateChange(const QString &)) ); 602 this, SLOT(slotStateChange(const QString &)) );
605 connect( txtZip, SIGNAL(textChanged(const QString &)), 603 connect( txtZip, SIGNAL(textChanged(const QString &)),
606 this, SLOT(slotZipChange(const QString &)) ); 604 this, SLOT(slotZipChange(const QString &)) );
@@ -628,33 +626,49 @@ void ContactEditor::defaultEmailChanged(int i){
628 qDebug("defaultEmailChanged"); 626 qDebug("defaultEmailChanged");
629 int index = cmbChooserField1->currentItem(); 627 int index = cmbChooserField1->currentItem();
630 slChooserValues[index] = cmbDefaultEmail->text(i); 628 slChooserValues[index] = cmbDefaultEmail->text(i);
631 629
632} 630}
633 631
634void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) { 632void ContactEditor::populateDefaultEmailCmb(){
633 cmbDefaultEmail->clear();
634 cmbDefaultEmail->insertStringList(emails);
635 for ( int i = 0; i < cmbDefaultEmail->count(); i++){
636 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",cmbDefaultEmail->text( i ).latin1(),defaultEmail.latin1());
637 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
638 cmbDefaultEmail->setCurrentItem( i );
639 qDebug("set");
640 }
641 }
642}
635 643
636 qDebug("defaultEmailChooserPosition %i, widgetPos %i ",defaultEmailChooserPosition,widgetPos); 644void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) {
637 if (slChooserNames[index] == "Default Email"){ 645 QString type = slChooserNames[index];
646 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",type.latin1(),textChanged.latin1(), index, widgetPos );
647 if ( type == "Default Email"){
648 defaultEmail = textChanged;
638 if (cmbDefaultEmail) delete cmbDefaultEmail; 649 if (cmbDefaultEmail) delete cmbDefaultEmail;
639 cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); 650 cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
640 cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); 651 cmbDefaultEmail->setGeometry(inputWid->frameGeometry());
641 cmbDefaultEmail->insertStringList(ent.emailList());
642 connect(cmbDefaultEmail,SIGNAL(activated(int)),
643 SLOT(defaultEmailChanged(int)));
644 QString demail = ent.defaultEmail();
645 for ( int i = 0; i < cmbDefaultEmail->count(); i++)
646 if ( cmbDefaultEmail->text( i ) == demail )
647 cmbDefaultEmail->setCurrentItem( i );
648
649 cmbDefaultEmail->show(); 652 cmbDefaultEmail->show();
653 populateDefaultEmailCmb();
654 connect(cmbDefaultEmail,SIGNAL(activated(int)),
655 SLOT(defaultEmailChanged(int)));
650 defaultEmailChooserPosition = widgetPos; 656 defaultEmailChooserPosition = widgetPos;
651 }else if (defaultEmailChooserPosition == widgetPos){ 657 }else if (defaultEmailChooserPosition == widgetPos){
652 qDebug("cmbDefaultEmail->hide()"); 658 qDebug("cmbDefaultEmail->hide()");
653 if (cmbDefaultEmail) cmbDefaultEmail->hide(); 659 if (cmbDefaultEmail) cmbDefaultEmail->hide();
660 widgetPos=-1;
661 }else if (type == "Emails"){
662 qDebug("emails");
663 QString de;
664 emails = QStringList::split (",", textChanged );
665
666 populateDefaultEmailCmb();
654 } 667 }
668
655 669
656 670
657 slChooserValues[index] = textChanged; 671 slChooserValues[index] = textChanged;
658 672
659} 673}
660 674
@@ -736,12 +750,13 @@ void ContactEditor::slotCountryChange( const QString &textChanged ) {
736 slBusinessAddress[6] = textChanged; 750 slBusinessAddress[6] = textChanged;
737 } else { 751 } else {
738 slHomeAddress[6] = textChanged; 752 slHomeAddress[6] = textChanged;
739 } 753 }
740} 754}
741 755
756
742void ContactEditor::slotCmbChooser1Change( int index ) { 757void ContactEditor::slotCmbChooser1Change( int index ) {
743 758
744 txtChooserField1->setText( slChooserValues[index] ); 759 txtChooserField1->setText( slChooserValues[index] );
745 txtChooserField1->setFocus(); 760 txtChooserField1->setFocus();
746} 761}
747 762
@@ -1057,12 +1072,13 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1057 } 1072 }
1058 return QString::null; 1073 return QString::null;
1059} 1074}
1060 1075
1061void ContactEditor::cleanupFields() { 1076void ContactEditor::cleanupFields() {
1062 QStringList::Iterator it = slChooserValues.begin(); 1077 QStringList::Iterator it = slChooserValues.begin();
1078
1063 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { 1079 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
1064 (*it) = ""; 1080 (*it) = "";
1065 } 1081 }
1066 1082
1067 for ( int i = 0; i < 7; i++ ) { 1083 for ( int i = 0; i < 7; i++ ) {
1068 slHomeAddress[i] = ""; 1084 slHomeAddress[i] = "";
@@ -1099,12 +1115,19 @@ void ContactEditor::cleanupFields() {
1099void ContactEditor::setEntry( const OContact &entry ) { 1115void ContactEditor::setEntry( const OContact &entry ) {
1100 1116
1101 cleanupFields(); 1117 cleanupFields();
1102 1118
1103 ent = entry; 1119 ent = entry;
1104 1120
1121
1122
1123 emails = QStringList(ent.emailList());
1124 defaultEmail = ent.defaultEmail();
1125 if (defaultEmail.isEmpty()) defaultEmail = emails[0];
1126 qDebug("default email=%s",defaultEmail.latin1());
1127
1105 useFullName = false; 1128 useFullName = false;
1106 txtFirstName->setText( ent.firstName() ); 1129 txtFirstName->setText( ent.firstName() );
1107 txtMiddleName->setText( ent.middleName() ); 1130 txtMiddleName->setText( ent.middleName() );
1108 txtLastName->setText( ent.lastName() ); 1131 txtLastName->setText( ent.lastName() );
1109 txtSuffix->setText( ent.suffix() ); 1132 txtSuffix->setText( ent.suffix() );
1110 1133
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 {
101 void slotRemoveBirthday(); 101 void slotRemoveBirthday();
102 void slotRemoveAnniversary(); 102 void slotRemoveAnniversary();
103 void defaultEmailChanged(int); 103 void defaultEmailChanged(int);
104 104
105 private: 105 private:
106 int defaultEmailChooserPosition; 106 int defaultEmailChooserPosition;
107 void populateDefaultEmailCmb();
107 void chooserChange( const QString&, int , QLineEdit*, int ); 108 void chooserChange( const QString&, int , QLineEdit*, int );
109
108 bool useFullName; 110 bool useFullName;
109 111
110 OContact ent; 112 OContact ent;
111 113
112 QDialog *dlgNote; 114 QDialog *dlgNote;
113 QDialog *dlgName; 115 QDialog *dlgName;
@@ -121,12 +123,14 @@ class ContactEditor : public QDialog {
121 bool m_personalView; 123 bool m_personalView;
122 124
123 QStringList slHomeAddress; 125 QStringList slHomeAddress;
124 QStringList slBusinessAddress; 126 QStringList slBusinessAddress;
125 QStringList slChooserNames; 127 QStringList slChooserNames;
126 QStringList slChooserValues; 128 QStringList slChooserValues;
129 QStringList emails;
130 QString defaultEmail;
127 131
128 QMultiLineEdit *txtNote; 132 QMultiLineEdit *txtNote;
129 QLabel *lblNote; 133 QLabel *lblNote;
130 134
131 //QLineEdit *txtTitle; 135 //QLineEdit *txtTitle;
132 QLineEdit *txtFirstName; 136 QLineEdit *txtFirstName;