author | tille <tille> | 2002-12-19 00:00:42 (UTC) |
---|---|---|
committer | tille <tille> | 2002-12-19 00:00:42 (UTC) |
commit | 4fc6648f5953d453a31edaf288480ff2458c431f (patch) (unidiff) | |
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 @@ | |||
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/qpedialog.h> | 28 | #include <qpe/qpedialog.h> |
29 | #include <qpe/timeconversion.h> | 29 | #include <qpe/timeconversion.h> |
30 | #include <opie/ocontact.h> | 30 | #include <opie/ocontact.h> |
31 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
32 | 32 | ||
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qmultilineedit.h> | 38 | #include <qmultilineedit.h> |
39 | #include <qscrollview.h> | 39 | #include <qscrollview.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qmainwindow.h> | 42 | #include <qmainwindow.h> |
43 | #include <qvaluelist.h> | 43 | #include <qvaluelist.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qlistbox.h> | 45 | #include <qlistbox.h> |
46 | #include <qhbox.h> | 46 | #include <qhbox.h> |
47 | #include <qaction.h> | 47 | #include <qaction.h> |
48 | #include <qiconset.h> | 48 | #include <qiconset.h> |
49 | 49 | ||
50 | static inline bool containsAlphaNum( const QString &str ); | 50 | static inline bool containsAlphaNum( const QString &str ); |
51 | static inline bool constainsWhiteSpace( const QString &str ); | 51 | static inline bool constainsWhiteSpace( const QString &str ); |
52 | 52 | ||
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... |
55 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 55 | void 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, | 59 | void 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 ), |
67 | m_personalView ( false ) | 67 | m_personalView ( false ) |
68 | 68 | ||
69 | { | 69 | { |
70 | 70 | ||
71 | init(); | 71 | init(); |
72 | setEntry( entry ); | 72 | setEntry( entry ); |
73 | cmbDefaultEmail = 0; | 73 | cmbDefaultEmail = 0; |
74 | defaultEmailChooserPosition = -1; | 74 | defaultEmailChooserPosition = -1; |
75 | } | 75 | } |
76 | 76 | ||
77 | ContactEditor::~ContactEditor() { | 77 | ContactEditor::~ContactEditor() { |
78 | } | 78 | } |
79 | 79 | ||
80 | void ContactEditor::init() { | 80 | void 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 | ||
88 | for (i = 0; i <= 6; i++) { | 88 | for (i = 0; i <= 6; i++) { |
89 | slHomeAddress.append( "" ); | 89 | slHomeAddress.append( "" ); |
90 | slBusinessAddress.append( "" ); | 90 | slBusinessAddress.append( "" ); |
91 | } | 91 | } |
92 | 92 | ||
93 | trlChooserNames = OContactFields::trphonefields(); | 93 | trlChooserNames = OContactFields::trphonefields(); |
94 | slChooserNames = OContactFields::untrphonefields(); | 94 | slChooserNames = OContactFields::untrphonefields(); |
95 | slDynamicEntries = OContactFields::untrdetailsfields(); | 95 | slDynamicEntries = OContactFields::untrdetailsfields(); |
96 | trlDynamicEntries = OContactFields::trdetailsfields(); | 96 | trlDynamicEntries = OContactFields::trdetailsfields(); |
97 | for (i = 0; i < slChooserNames.count(); i++) | 97 | for (i = 0; i < slChooserNames.count(); i++) |
98 | slChooserValues.append(""); | 98 | slChooserValues.append(""); |
99 | 99 | ||
100 | 100 | ||
101 | QVBoxLayout *vb = new QVBoxLayout( this ); | 101 | QVBoxLayout *vb = new QVBoxLayout( this ); |
102 | 102 | ||
103 | tabMain = new QTabWidget( this ); | 103 | tabMain = new QTabWidget( this ); |
104 | vb->addWidget( tabMain ); | 104 | vb->addWidget( tabMain ); |
105 | 105 | ||
106 | QWidget *tabViewport = new QWidget ( tabMain ); | 106 | QWidget *tabViewport = new QWidget ( tabMain ); |
107 | 107 | ||
108 | vb = new QVBoxLayout( tabViewport ); | 108 | vb = new QVBoxLayout( tabViewport ); |
109 | 109 | ||
110 | svGeneral = new QScrollView( tabViewport ); | 110 | svGeneral = new QScrollView( tabViewport ); |
111 | vb->addWidget( svGeneral, 0, 0 ); | 111 | vb->addWidget( svGeneral, 0, 0 ); |
112 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); | 112 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); |
113 | svGeneral->setFrameStyle( QFrame::NoFrame ); | 113 | svGeneral->setFrameStyle( QFrame::NoFrame ); |
@@ -567,120 +567,134 @@ void ContactEditor::init() { | |||
567 | l = new QLabel( tr("Suffix"), dlgName ); | 567 | l = new QLabel( tr("Suffix"), dlgName ); |
568 | gl->addWidget( l, 3, 0 ); | 568 | gl->addWidget( l, 3, 0 ); |
569 | txtSuffix = new QLineEdit( dlgName ); | 569 | txtSuffix = new QLineEdit( dlgName ); |
570 | gl->addWidget( txtSuffix, 3, 1 ); | 570 | gl->addWidget( txtSuffix, 3, 1 ); |
571 | space = new QSpacerItem(1,1, | 571 | space = new QSpacerItem(1,1, |
572 | QSizePolicy::Maximum, | 572 | QSizePolicy::Maximum, |
573 | QSizePolicy::MinimumExpanding ); | 573 | QSizePolicy::MinimumExpanding ); |
574 | gl->addItem( space, 4, 0 ); | 574 | gl->addItem( space, 4, 0 ); |
575 | 575 | ||
576 | cmbChooserField1->insertStringList( trlChooserNames ); | 576 | cmbChooserField1->insertStringList( trlChooserNames ); |
577 | cmbChooserField2->insertStringList( trlChooserNames ); | 577 | cmbChooserField2->insertStringList( trlChooserNames ); |
578 | cmbChooserField3->insertStringList( trlChooserNames ); | 578 | cmbChooserField3->insertStringList( trlChooserNames ); |
579 | cmbChooserField4->insertStringList( trlChooserNames ); | 579 | cmbChooserField4->insertStringList( trlChooserNames ); |
580 | 580 | ||
581 | cmbChooserField1->setCurrentItem( 0 ); | 581 | cmbChooserField1->setCurrentItem( 0 ); |
582 | cmbChooserField2->setCurrentItem( 1 ); | 582 | cmbChooserField2->setCurrentItem( 1 ); |
583 | cmbChooserField3->setCurrentItem( 2 ); | 583 | cmbChooserField3->setCurrentItem( 2 ); |
584 | 584 | ||
585 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); | 585 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); |
586 | 586 | ||
587 | connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); | 587 | connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); |
588 | 588 | ||
589 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), | 589 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), |
590 | this, SLOT(slotChooser1Change(const QString &)) ); | 590 | this, SLOT(slotChooser1Change(const QString &)) ); |
591 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), | 591 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), |
592 | this, SLOT(slotChooser2Change(const QString &)) ); | 592 | this, SLOT(slotChooser2Change(const QString &)) ); |
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 &)) ); |
607 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), | 605 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), |
608 | this, SLOT(slotCountryChange(const QString &)) ); | 606 | this, SLOT(slotCountryChange(const QString &)) ); |
609 | connect( cmbCountry, SIGNAL(activated(const QString &)), | 607 | connect( cmbCountry, SIGNAL(activated(const QString &)), |
610 | this, SLOT(slotCountryChange(const QString &)) ); | 608 | this, SLOT(slotCountryChange(const QString &)) ); |
611 | connect( cmbChooserField1, SIGNAL(activated(int)), | 609 | connect( cmbChooserField1, SIGNAL(activated(int)), |
612 | this, SLOT(slotCmbChooser1Change(int)) ); | 610 | this, SLOT(slotCmbChooser1Change(int)) ); |
613 | connect( cmbChooserField2, SIGNAL(activated(int)), | 611 | connect( cmbChooserField2, SIGNAL(activated(int)), |
614 | this, SLOT(slotCmbChooser2Change(int)) ); | 612 | this, SLOT(slotCmbChooser2Change(int)) ); |
615 | connect( cmbChooserField3, SIGNAL(activated(int)), | 613 | connect( cmbChooserField3, SIGNAL(activated(int)), |
616 | this, SLOT(slotCmbChooser3Change(int)) ); | 614 | this, SLOT(slotCmbChooser3Change(int)) ); |
617 | connect( cmbChooserField4, SIGNAL(activated(int)), | 615 | connect( cmbChooserField4, SIGNAL(activated(int)), |
618 | this, SLOT(slotCmbChooser4Change(int)) ); | 616 | this, SLOT(slotCmbChooser4Change(int)) ); |
619 | connect( cmbAddress, SIGNAL(activated(int)), | 617 | connect( cmbAddress, SIGNAL(activated(int)), |
620 | this, SLOT(slotAddressTypeChange(int)) ); | 618 | this, SLOT(slotAddressTypeChange(int)) ); |
621 | 619 | ||
622 | new QPEDialogListener(this); | 620 | new QPEDialogListener(this); |
623 | 621 | ||
624 | setPersonalView ( m_personalView ); | 622 | setPersonalView ( m_personalView ); |
625 | } | 623 | } |
626 | 624 | ||
627 | void ContactEditor::defaultEmailChanged(int i){ | 625 | 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 | ||
634 | void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) { | 632 | void 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); | 644 | void 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 | ||
661 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { | 675 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { |
662 | chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); | 676 | chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); |
663 | } | 677 | } |
664 | 678 | ||
665 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { | 679 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { |
666 | chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); | 680 | chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); |
667 | 681 | ||
668 | } | 682 | } |
669 | 683 | ||
670 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { | 684 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { |
671 | chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); | 685 | chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); |
672 | } | 686 | } |
673 | 687 | ||
674 | void ContactEditor::slotChooser4Change( const QString &textChanged ) { | 688 | void ContactEditor::slotChooser4Change( const QString &textChanged ) { |
675 | chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); | 689 | chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); |
676 | } | 690 | } |
677 | 691 | ||
678 | void ContactEditor::slotAddressChange( const QString &textChanged ) { | 692 | void ContactEditor::slotAddressChange( const QString &textChanged ) { |
679 | 693 | ||
680 | if ( cmbAddress->currentItem() == 0 ) { | 694 | if ( cmbAddress->currentItem() == 0 ) { |
681 | slBusinessAddress[0] = textChanged; | 695 | slBusinessAddress[0] = textChanged; |
682 | } else { | 696 | } else { |
683 | slHomeAddress[0] = textChanged; | 697 | slHomeAddress[0] = textChanged; |
684 | } | 698 | } |
685 | } | 699 | } |
686 | 700 | ||
@@ -710,64 +724,65 @@ void ContactEditor::slotCityChange( const QString &textChanged ) { | |||
710 | slHomeAddress[3] = textChanged; | 724 | slHomeAddress[3] = textChanged; |
711 | } | 725 | } |
712 | } | 726 | } |
713 | 727 | ||
714 | void ContactEditor::slotStateChange( const QString &textChanged ) { | 728 | void ContactEditor::slotStateChange( const QString &textChanged ) { |
715 | 729 | ||
716 | 730 | ||
717 | if ( cmbAddress->currentItem() == 0 ) { | 731 | if ( cmbAddress->currentItem() == 0 ) { |
718 | slBusinessAddress[4] = textChanged; | 732 | slBusinessAddress[4] = textChanged; |
719 | } else { | 733 | } else { |
720 | slHomeAddress[4] = textChanged; | 734 | slHomeAddress[4] = textChanged; |
721 | } | 735 | } |
722 | } | 736 | } |
723 | 737 | ||
724 | void ContactEditor::slotZipChange( const QString &textChanged ) { | 738 | void ContactEditor::slotZipChange( const QString &textChanged ) { |
725 | 739 | ||
726 | if ( cmbAddress->currentItem() == 0 ) { | 740 | if ( cmbAddress->currentItem() == 0 ) { |
727 | slBusinessAddress[5] = textChanged; | 741 | slBusinessAddress[5] = textChanged; |
728 | } else { | 742 | } else { |
729 | slHomeAddress[5] = textChanged; | 743 | slHomeAddress[5] = textChanged; |
730 | } | 744 | } |
731 | } | 745 | } |
732 | 746 | ||
733 | void ContactEditor::slotCountryChange( const QString &textChanged ) { | 747 | void ContactEditor::slotCountryChange( const QString &textChanged ) { |
734 | 748 | ||
735 | if ( cmbAddress->currentItem() == 0 ) { | 749 | if ( cmbAddress->currentItem() == 0 ) { |
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 | |||
742 | void ContactEditor::slotCmbChooser1Change( int index ) { | 757 | void 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 | ||
748 | void ContactEditor::slotCmbChooser2Change( int index ) { | 763 | void ContactEditor::slotCmbChooser2Change( int index ) { |
749 | 764 | ||
750 | txtChooserField2->setText( slChooserValues[index] ); | 765 | txtChooserField2->setText( slChooserValues[index] ); |
751 | txtChooserField2->setFocus(); | 766 | txtChooserField2->setFocus(); |
752 | } | 767 | } |
753 | 768 | ||
754 | void ContactEditor::slotCmbChooser3Change( int index ) { | 769 | void ContactEditor::slotCmbChooser3Change( int index ) { |
755 | 770 | ||
756 | txtChooserField3->setText( slChooserValues[index] ); | 771 | txtChooserField3->setText( slChooserValues[index] ); |
757 | txtChooserField3->setFocus(); | 772 | txtChooserField3->setFocus(); |
758 | 773 | ||
759 | } | 774 | } |
760 | 775 | ||
761 | void ContactEditor::slotCmbChooser4Change( int index ) { | 776 | void ContactEditor::slotCmbChooser4Change( int index ) { |
762 | 777 | ||
763 | txtChooserField4->setText( slChooserValues[index] ); | 778 | txtChooserField4->setText( slChooserValues[index] ); |
764 | txtChooserField4->setFocus(); | 779 | txtChooserField4->setFocus(); |
765 | 780 | ||
766 | } | 781 | } |
767 | 782 | ||
768 | void ContactEditor::slotAddressTypeChange( int index ) { | 783 | void ContactEditor::slotAddressTypeChange( int index ) { |
769 | 784 | ||
770 | if ( index == 0 ) { | 785 | if ( index == 0 ) { |
771 | 786 | ||
772 | txtAddress->setText( slBusinessAddress[0] ); | 787 | txtAddress->setText( slBusinessAddress[0] ); |
773 | //txtAddress2->setText( (*slBusinessAddress)[1] ); | 788 | //txtAddress2->setText( (*slBusinessAddress)[1] ); |
@@ -1031,106 +1046,114 @@ QString ContactEditor::parseName( const QString fullName, int type ) { | |||
1031 | } | 1046 | } |
1032 | switch (type) { | 1047 | switch (type) { |
1033 | case NAME_FL: | 1048 | case NAME_FL: |
1034 | return strFirstName + " " + strLastName; | 1049 | return strFirstName + " " + strLastName; |
1035 | 1050 | ||
1036 | case NAME_LF: | 1051 | case NAME_LF: |
1037 | return strLastName + ", " + strFirstName; | 1052 | return strLastName + ", " + strFirstName; |
1038 | 1053 | ||
1039 | case NAME_LFM: | 1054 | case NAME_LFM: |
1040 | return strLastName + ", " + strFirstName + " " + strMiddleName; | 1055 | return strLastName + ", " + strFirstName + " " + strMiddleName; |
1041 | 1056 | ||
1042 | case NAME_FMLS: | 1057 | case NAME_FMLS: |
1043 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; | 1058 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; |
1044 | 1059 | ||
1045 | case NAME_F: | 1060 | case NAME_F: |
1046 | return strFirstName; | 1061 | return strFirstName; |
1047 | 1062 | ||
1048 | case NAME_M: | 1063 | case NAME_M: |
1049 | return strMiddleName; | 1064 | return strMiddleName; |
1050 | 1065 | ||
1051 | case NAME_L: | 1066 | case NAME_L: |
1052 | return strLastName; | 1067 | return strLastName; |
1053 | 1068 | ||
1054 | case NAME_S: | 1069 | case NAME_S: |
1055 | return strSuffix; | 1070 | return strSuffix; |
1056 | 1071 | ||
1057 | } | 1072 | } |
1058 | return QString::null; | 1073 | return QString::null; |
1059 | } | 1074 | } |
1060 | 1075 | ||
1061 | void ContactEditor::cleanupFields() { | 1076 | void 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] = ""; |
1069 | slBusinessAddress[i] = ""; | 1085 | slBusinessAddress[i] = ""; |
1070 | } | 1086 | } |
1071 | 1087 | ||
1072 | QListIterator<QLineEdit> itLV( listValue ); | 1088 | QListIterator<QLineEdit> itLV( listValue ); |
1073 | for ( ; itLV.current(); ++itLV ) { | 1089 | for ( ; itLV.current(); ++itLV ) { |
1074 | (*itLV)->setText( "" ); | 1090 | (*itLV)->setText( "" ); |
1075 | } | 1091 | } |
1076 | 1092 | ||
1077 | txtFirstName->setText(""); | 1093 | txtFirstName->setText(""); |
1078 | txtMiddleName->setText(""); | 1094 | txtMiddleName->setText(""); |
1079 | txtLastName->setText(""); | 1095 | txtLastName->setText(""); |
1080 | txtSuffix->setText(""); | 1096 | txtSuffix->setText(""); |
1081 | txtNote->setText(""); | 1097 | txtNote->setText(""); |
1082 | txtFullName->setText(""); | 1098 | txtFullName->setText(""); |
1083 | txtJobTitle->setText(""); | 1099 | txtJobTitle->setText(""); |
1084 | txtOrganization->setText(""); | 1100 | txtOrganization->setText(""); |
1085 | txtChooserField1->setText(""); | 1101 | txtChooserField1->setText(""); |
1086 | txtChooserField2->setText(""); | 1102 | txtChooserField2->setText(""); |
1087 | txtChooserField3->setText(""); | 1103 | txtChooserField3->setText(""); |
1088 | txtAddress->setText(""); | 1104 | txtAddress->setText(""); |
1089 | txtCity->setText(""); | 1105 | txtCity->setText(""); |
1090 | txtState->setText(""); | 1106 | txtState->setText(""); |
1091 | txtZip->setText(""); | 1107 | txtZip->setText(""); |
1092 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1108 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1093 | txtTmp->setText(""); | 1109 | txtTmp->setText(""); |
1094 | txtTmp = cmbFileAs->lineEdit(); | 1110 | txtTmp = cmbFileAs->lineEdit(); |
1095 | txtTmp->setText(""); | 1111 | txtTmp->setText(""); |
1096 | 1112 | ||
1097 | } | 1113 | } |
1098 | 1114 | ||
1099 | void ContactEditor::setEntry( const OContact &entry ) { | 1115 | void 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 | ||
1111 | QString *tmpString = new QString; | 1134 | QString *tmpString = new QString; |
1112 | *tmpString = ent.firstName() + " " + ent.middleName() + | 1135 | *tmpString = ent.firstName() + " " + ent.middleName() + |
1113 | + " " + ent.lastName() + " " + ent.suffix(); | 1136 | + " " + ent.lastName() + " " + ent.suffix(); |
1114 | 1137 | ||
1115 | txtFullName->setText( tmpString->simplifyWhiteSpace() ); | 1138 | txtFullName->setText( tmpString->simplifyWhiteSpace() ); |
1116 | 1139 | ||
1117 | cmbFileAs->setEditText( ent.fileAs() ); | 1140 | cmbFileAs->setEditText( ent.fileAs() ); |
1118 | 1141 | ||
1119 | //if (hasTitle) | 1142 | //if (hasTitle) |
1120 | txtJobTitle->setText( ent.jobTitle() ); | 1143 | txtJobTitle->setText( ent.jobTitle() ); |
1121 | 1144 | ||
1122 | //if (hasCompany) | 1145 | //if (hasCompany) |
1123 | txtOrganization->setText( ent.company() ); | 1146 | txtOrganization->setText( ent.company() ); |
1124 | 1147 | ||
1125 | //if (hasNotes) | 1148 | //if (hasNotes) |
1126 | txtNote->setText( ent.notes() ); | 1149 | txtNote->setText( ent.notes() ); |
1127 | 1150 | ||
1128 | //if (hasStreet) { | 1151 | //if (hasStreet) { |
1129 | slHomeAddress[0] = ent.homeStreet(); | 1152 | slHomeAddress[0] = ent.homeStreet(); |
1130 | slBusinessAddress[0] = ent.businessStreet(); | 1153 | slBusinessAddress[0] = ent.businessStreet(); |
1131 | //} | 1154 | //} |
1132 | 1155 | ||
1133 | //if (hasCity) { | 1156 | //if (hasCity) { |
1134 | slHomeAddress[3] = ent.homeCity(); | 1157 | slHomeAddress[3] = ent.homeCity(); |
1135 | slBusinessAddress[3] = ent.businessCity(); | 1158 | slBusinessAddress[3] = ent.businessCity(); |
1136 | //} | 1159 | //} |
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 { | |||
75 | void init(); | 75 | void init(); |
76 | void saveEntry(); | 76 | void saveEntry(); |
77 | bool isEmpty(); | 77 | bool isEmpty(); |
78 | void cleanupFields(); | 78 | void cleanupFields(); |
79 | void updateDatePicker(); | 79 | void updateDatePicker(); |
80 | QString parseName( QString fullName, int type ); | 80 | QString parseName( QString fullName, int type ); |
81 | private slots: | 81 | private slots: |
82 | void slotChooser1Change( const QString &textChanged ); | 82 | void slotChooser1Change( const QString &textChanged ); |
83 | void slotChooser2Change( const QString &textChanged ); | 83 | void slotChooser2Change( const QString &textChanged ); |
84 | void slotChooser3Change( const QString &textChanged ); | 84 | void slotChooser3Change( const QString &textChanged ); |
85 | void slotChooser4Change( const QString &textChanged ); | 85 | void slotChooser4Change( const QString &textChanged ); |
86 | void slotCmbChooser1Change( int index ); | 86 | void slotCmbChooser1Change( int index ); |
87 | void slotCmbChooser2Change( int index ); | 87 | void slotCmbChooser2Change( int index ); |
88 | void slotCmbChooser3Change( int index ); | 88 | void slotCmbChooser3Change( int index ); |
89 | void slotCmbChooser4Change( int index ); | 89 | void slotCmbChooser4Change( int index ); |
90 | void slotAddressTypeChange( int index ); | 90 | void slotAddressTypeChange( int index ); |
91 | void slotAddressChange( const QString &textChanged ); | 91 | void slotAddressChange( const QString &textChanged ); |
92 | void slotAddress2Change( const QString &textChanged ); | 92 | void slotAddress2Change( const QString &textChanged ); |
93 | void slotPOBoxChange( const QString &textChanged ); | 93 | void slotPOBoxChange( const QString &textChanged ); |
94 | void slotCityChange( const QString &textChanged ); | 94 | void slotCityChange( const QString &textChanged ); |
95 | void slotStateChange( const QString &textChanged ); | 95 | void slotStateChange( const QString &textChanged ); |
96 | void slotZipChange( const QString &textChanged ); | 96 | void slotZipChange( const QString &textChanged ); |
97 | void slotCountryChange( const QString &textChanged ); | 97 | void slotCountryChange( const QString &textChanged ); |
98 | void slotFullNameChange( const QString &textChanged ); | 98 | void slotFullNameChange( const QString &textChanged ); |
99 | void slotAnniversaryDateChanged( int year, int month, int day); | 99 | void slotAnniversaryDateChanged( int year, int month, int day); |
100 | void slotBirthdayDateChanged( int year, int month, int day); | 100 | void slotBirthdayDateChanged( int year, int month, int day); |
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; |
114 | 116 | ||
115 | QList<QLineEdit> listValue; | 117 | QList<QLineEdit> listValue; |
116 | QList<QLabel> listName; | 118 | QList<QLabel> listName; |
117 | 119 | ||
118 | QStringList slDynamicEntries; | 120 | QStringList slDynamicEntries; |
119 | QStringList trlDynamicEntries; | 121 | QStringList trlDynamicEntries; |
120 | 122 | ||
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; |
133 | QLineEdit *txtMiddleName; | 137 | QLineEdit *txtMiddleName; |
134 | QLineEdit *txtLastName; | 138 | QLineEdit *txtLastName; |
135 | QLineEdit *txtSuffix; | 139 | QLineEdit *txtSuffix; |
136 | 140 | ||
137 | QTabWidget *tabMain; | 141 | QTabWidget *tabMain; |
138 | QScrollView *svGeneral; | 142 | QScrollView *svGeneral; |
139 | QPushButton *btnFullName; | 143 | QPushButton *btnFullName; |
140 | QPushButton *btnNote; | 144 | QPushButton *btnNote; |
141 | QLineEdit *txtFullName; | 145 | QLineEdit *txtFullName; |
142 | QLineEdit *txtJobTitle; | 146 | QLineEdit *txtJobTitle; |
143 | QLineEdit *txtOrganization; | 147 | QLineEdit *txtOrganization; |
144 | QLineEdit *txtChooserField1; | 148 | QLineEdit *txtChooserField1; |
145 | QLineEdit *txtChooserField2; | 149 | QLineEdit *txtChooserField2; |
146 | QLineEdit *txtChooserField3; | 150 | QLineEdit *txtChooserField3; |
147 | QLineEdit *txtChooserField4; | 151 | QLineEdit *txtChooserField4; |
148 | QComboBox *cmbChooserField1; | 152 | QComboBox *cmbChooserField1; |
149 | QComboBox *cmbChooserField2; | 153 | QComboBox *cmbChooserField2; |
150 | QComboBox *cmbChooserField3; | 154 | QComboBox *cmbChooserField3; |
151 | QComboBox *cmbChooserField4; | 155 | QComboBox *cmbChooserField4; |
152 | QComboBox *cmbDefaultEmail; | 156 | QComboBox *cmbDefaultEmail; |
153 | QComboBox *cmbFileAs; | 157 | QComboBox *cmbFileAs; |
154 | CategorySelect *cmbCat; | 158 | CategorySelect *cmbCat; |
155 | QLabel *labCat; | 159 | QLabel *labCat; |
156 | 160 | ||
157 | QScrollView *svAddress; | 161 | QScrollView *svAddress; |
158 | QLineEdit *txtAddress; | 162 | QLineEdit *txtAddress; |