summaryrefslogtreecommitdiff
path: root/core/pim
authoreilers <eilers>2003-01-04 14:24:36 (UTC)
committer eilers <eilers>2003-01-04 14:24:36 (UTC)
commit4a9e13d7b9220b45cbbbdfab5f2ea56ea415d6a7 (patch) (unidiff)
tree00babfde2cfd15687cb87d73800e75630afdab0b /core/pim
parent851c182383c34fd4925677713bb5f6fd603c86a0 (diff)
downloadopie-4a9e13d7b9220b45cbbbdfab5f2ea56ea415d6a7.zip
opie-4a9e13d7b9220b45cbbbdfab5f2ea56ea415d6a7.tar.gz
opie-4a9e13d7b9220b45cbbbdfab5f2ea56ea415d6a7.tar.bz2
Hope I fixed the default-email bugs..
Diffstat (limited to 'core/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO2
-rw-r--r--core/pim/addressbook/contacteditor.cpp224
-rw-r--r--core/pim/addressbook/contacteditor.h2
3 files changed, 186 insertions, 42 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 1eb537f..76247c1 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -38,6 +38,8 @@ ContactEditor:
38Important: 38Important:
39---------- 39----------
40 40
41- If new contact is added (contacteditor closed): focus (table, card) to
42 this entry !
41- Implement a picker/combo for the default email. 43- Implement a picker/combo for the default email.
42- After search (Started with Return): KeyFocus should be on Tabelle 44- After search (Started with Return): KeyFocus should be on Tabelle
43 45
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index c5ad0c4..37e3a54 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -46,6 +46,7 @@
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#include <qmessagebox.h>
49 50
50#include <assert.h> 51#include <assert.h>
51 52
@@ -644,73 +645,190 @@ void ContactEditor::init() {
644} 645}
645 646
646void ContactEditor::defaultEmailChanged(int i){ 647void ContactEditor::defaultEmailChanged(int i){
647 qDebug("defaultEmailChanged"); 648 qDebug("defaultEmailChanged");
649
648 int index = cmbChooserField1->currentItem(); 650 int index = cmbChooserField1->currentItem();
649 slChooserValues[index] = cmbDefaultEmail->text(i); 651 slChooserValues[index] = cmbDefaultEmail->text(i);
650 652
653 defaultEmail = cmbDefaultEmail->text(i);
654 qDebug ("Changed to: %s", defaultEmail.latin1());
655
651} 656}
652 657
653void ContactEditor::populateDefaultEmailCmb(){ 658void ContactEditor::populateDefaultEmailCmb(){
659
660 // if the default-email combo was not selected and therfore not created
661 // we get a lot of trouble.. Therfore create an invisible one..
662 if ( !cmbDefaultEmail ){
663 cmbDefaultEmail = new QComboBox(this);
664 cmbDefaultEmail -> hide();
665 }
654 cmbDefaultEmail->clear(); 666 cmbDefaultEmail->clear();
655 cmbDefaultEmail->insertStringList(emails); 667 cmbDefaultEmail->insertStringList( emails );
668 // cmbDefaultEmail->show();
669
670 // Select default email in combo..
671 bool found = false;
656 for ( int i = 0; i < cmbDefaultEmail->count(); i++){ 672 for ( int i = 0; i < cmbDefaultEmail->count(); i++){
657 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",cmbDefaultEmail->text( i ).latin1(),defaultEmail.latin1()); 673 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",
658 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ 674 cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1());
659 cmbDefaultEmail->setCurrentItem( i ); 675
660 qDebug("set"); 676 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
677 cmbDefaultEmail->setCurrentItem( i );
678 qDebug("set");
679 found = true;
661 } 680 }
662 } 681 }
682
683 // If the current default email is not found in the list, we choose the
684 // first one..
685 if ( !found )
686 defaultEmail = cmbDefaultEmail->text(0);
687}
688
689// Called when any combobox was changed.
690// "true" returned if the change was chandled by this function, else it should
691// be handled by something else..
692bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) {
693 QString type = slChooserNames[index];
694 qWarning("ContactEditor::cmbChooserChange -> Type: %s", type.latin1() );
695
696 // Create and connect combobox for selecting the default email
697 if ( type == "Default Email"){
698 qWarning("Choosing default-email ");
699
700 // More than one defaul-email chooser is not allowed !
701 if ( ( defaultEmailChooserPosition != -1 ) &&
702 defaultEmailChooserPosition != widgetPos ){
703 chooserError( widgetPos );
704 return true;
705 }
706
707 if ( cmbDefaultEmail ){
708 delete cmbDefaultEmail;
709 cmbDefaultEmail = 0l;
710 }
711 cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
712 cmbDefaultEmail->setGeometry(inputWid->frameGeometry());
713
714 connect( cmbDefaultEmail,SIGNAL( activated(int) ),
715 SLOT( defaultEmailChanged(int) ) );
716
717 cmbDefaultEmail->clear();
718 cmbDefaultEmail->insertStringList( emails );
719 cmbDefaultEmail->show();
720
721 defaultEmailChooserPosition = widgetPos;
722
723 // Set current default email
724 populateDefaultEmailCmb();
725
726
727 } else {
728 // Something else was selected: Hide combo..
729 qWarning(" Hiding default-email combo" );
730 if ( defaultEmailChooserPosition == widgetPos ){
731 defaultEmailChooserPosition = -1;
732 if ( cmbDefaultEmail )
733 cmbDefaultEmail->hide();
734
735 }
736
737 // Caller should initialize the responsible textfield, therefore
738 // "false" is returned
739 return false;
740 }
741
742 // Everything is worked off ..
743 return true;
744
745}
746
747// Currently accessed when we select default-email more than once !
748void ContactEditor::chooserError( int index )
749{
750 qWarning("ContactEditor::chooserError( %d )", index);
751 QMessageBox::warning( this, "Chooser Error",
752 "Multiple selection of this\n"
753 "Item is not allowed !\n\n"
754 "First deselect the previous one !",
755 "&OK", 0, 0,
756 0, 0 );
757
758 // Reset the selected Chooser. Unfortunately the chooser
759 // generates no signal, therfore we have to
760 // call the cmbChooserChange function manually..
761 switch( index ){
762 case 1:
763 cmbChooserField1 -> setCurrentItem( 0 );
764 slotCmbChooser1Change( 0 );
765 break;
766 case 2:
767 cmbChooserField2 -> setCurrentItem( 0 );
768 slotCmbChooser2Change( 0 );
769 break;
770 case 3:
771 cmbChooserField3 -> setCurrentItem( 0 );
772 slotCmbChooser3Change( 0 );
773 break;
774 case 4:
775 cmbChooserField4 -> setCurrentItem( 0 );
776 slotCmbChooser4Change( 0 );
777 break;
778 }
663} 779}
664 780
665void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) { 781// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
782void ContactEditor::chooserChange( const QString &textChanged, int index,
783 QLineEdit* , int widgetPos ) {
784
666 QString type = slChooserNames[index]; 785 QString type = slChooserNames[index];
667 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",type.latin1(),textChanged.latin1(), index, widgetPos ); 786 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",
787 type.latin1(),textChanged.latin1(), index, widgetPos );
788
668 if ( type == "Default Email"){ 789 if ( type == "Default Email"){
669 defaultEmail = textChanged; 790 qWarning ("??? Wozu??: %s", textChanged.latin1());
670 if (cmbDefaultEmail){ 791 defaultEmail = textChanged;
671 delete cmbDefaultEmail; 792
672 cmbDefaultEmail = 0l; 793 populateDefaultEmailCmb();
673 } 794
674 cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
675 cmbDefaultEmail->setGeometry(inputWid->frameGeometry());
676 cmbDefaultEmail->show();
677 populateDefaultEmailCmb();
678 connect(cmbDefaultEmail,SIGNAL(activated(int)),
679 SLOT(defaultEmailChanged(int)));
680 defaultEmailChooserPosition = widgetPos;
681 }else if (defaultEmailChooserPosition == widgetPos){ 795 }else if (defaultEmailChooserPosition == widgetPos){
682 qDebug("cmbDefaultEmail->hide()"); 796 qDebug("cmbDefaultEmail->hide()");
683 if (cmbDefaultEmail) cmbDefaultEmail->hide(); 797
684 widgetPos=-1; 798 if (cmbDefaultEmail) cmbDefaultEmail->hide();
799 widgetPos=-1;
800
685 }else if (type == "Emails"){ 801 }else if (type == "Emails"){
686 qDebug("emails"); 802 qDebug("emails");
687 QString de; 803
688 emails = QStringList::split (",", textChanged ); 804 QString de;
805 emails = QStringList::split (",", textChanged );
689 806
690 if ( cmbDefaultEmail ) 807 populateDefaultEmailCmb();
691 populateDefaultEmailCmb();
692 } 808 }
693 809
694
695
696 slChooserValues[index] = textChanged; 810 slChooserValues[index] = textChanged;
697 811
698} 812}
699 813
700void ContactEditor::slotChooser1Change( const QString &textChanged ) { 814void ContactEditor::slotChooser1Change( const QString &textChanged ) {
815 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1());
701 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); 816 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
702} 817}
703 818
704void ContactEditor::slotChooser2Change( const QString &textChanged ) { 819void ContactEditor::slotChooser2Change( const QString &textChanged ) {
820 qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1());
705 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); 821 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
706 822
707} 823}
708 824
709void ContactEditor::slotChooser3Change( const QString &textChanged ) { 825void ContactEditor::slotChooser3Change( const QString &textChanged ) {
826 qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1());
710 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); 827 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
711} 828}
712 829
713void ContactEditor::slotChooser4Change( const QString &textChanged ) { 830void ContactEditor::slotChooser4Change( const QString &textChanged ) {
831 qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1());
714 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); 832 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4);
715} 833}
716 834
@@ -780,29 +898,48 @@ void ContactEditor::slotCountryChange( const QString &textChanged ) {
780 898
781 899
782void ContactEditor::slotCmbChooser1Change( int index ) { 900void ContactEditor::slotCmbChooser1Change( int index ) {
901 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index);
902
903 if ( !cmbChooserChange( cmbChooserField1->currentItem(), txtChooserField1, 1) ){
904
905 txtChooserField1->setText( slChooserValues[index] );
906 txtChooserField1->setFocus();
907
908 }
783 909
784 txtChooserField1->setText( slChooserValues[index] );
785 txtChooserField1->setFocus();
786} 910}
787 911
788void ContactEditor::slotCmbChooser2Change( int index ) { 912void ContactEditor::slotCmbChooser2Change( int index ) {
913 qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
914
915 if ( !cmbChooserChange( cmbChooserField2->currentItem(), txtChooserField2, 2) ){
789 916
790 txtChooserField2->setText( slChooserValues[index] ); 917 txtChooserField2->setText( slChooserValues[index] );
791 txtChooserField2->setFocus(); 918 txtChooserField2->setFocus();
919
920 }
792} 921}
793 922
794void ContactEditor::slotCmbChooser3Change( int index ) { 923void ContactEditor::slotCmbChooser3Change( int index ) {
924 qWarning("ContactEditor::slotCmbChooser3Change( %d )", index);
925
926 if ( !cmbChooserChange( cmbChooserField3->currentItem(), txtChooserField3, 3) ){
795 927
796 txtChooserField3->setText( slChooserValues[index] ); 928 txtChooserField3->setText( slChooserValues[index] );
797 txtChooserField3->setFocus(); 929 txtChooserField3->setFocus();
798 930
931 }
799} 932}
800 933
801void ContactEditor::slotCmbChooser4Change( int index ) { 934void ContactEditor::slotCmbChooser4Change( int index ) {
935 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
936
937 if ( !cmbChooserChange( cmbChooserField4->currentItem(), txtChooserField4, 4) ){
802 938
803 txtChooserField4->setText( slChooserValues[index] ); 939 txtChooserField4->setText( slChooserValues[index] );
804 txtChooserField4->setFocus(); 940 txtChooserField4->setFocus();
805 941
942 }
806} 943}
807 944
808void ContactEditor::slotAddressTypeChange( int index ) { 945void ContactEditor::slotAddressTypeChange( int index ) {
@@ -1448,14 +1585,17 @@ void ContactEditor::saveEntry() {
1448 if ( *it == "Emails" ){ 1585 if ( *it == "Emails" ){
1449 QString allemail; 1586 QString allemail;
1450 QString defaultmail; 1587 QString defaultmail;
1451 parseEmailFrom( *itV, defaultmail, allemail ); 1588 parseEmailFrom( emails.join(","), defaultmail, allemail );
1452 // ent.clearEmails(); 1589 if ( defaultEmail.isEmpty() ){
1453 // ent.setDefaultEmail( defaultmail ); 1590 qWarning("Default email was not set by user!");
1591 qWarning("Using first email in list: %s", defaultmail.latin1());
1592 ent.setDefaultEmail( defaultmail );
1593 }
1454 ent.setEmails( allemail ); 1594 ent.setEmails( allemail );
1455 } 1595 }
1456 1596
1457 if ( *it == "Default Email") 1597 if ( *it == "Default Email")
1458 ent.setDefaultEmail( *itV ); 1598 ent.setDefaultEmail( defaultEmail /* *itV */ );
1459 1599
1460 if ( *it == "Home Phone" ) 1600 if ( *it == "Home Phone" )
1461 ent.setHomePhone( *itV ); 1601 ent.setHomePhone( *itV );
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index bcef679..4fa48d1 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -78,6 +78,7 @@ class ContactEditor : public QDialog {
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 void chooserError( int index );
81 private slots: 82 private slots:
82 void slotChooser1Change( const QString &textChanged ); 83 void slotChooser1Change( const QString &textChanged );
83 void slotChooser2Change( const QString &textChanged ); 84 void slotChooser2Change( const QString &textChanged );
@@ -106,6 +107,7 @@ class ContactEditor : public QDialog {
106 int defaultEmailChooserPosition; 107 int defaultEmailChooserPosition;
107 void populateDefaultEmailCmb(); 108 void populateDefaultEmailCmb();
108 void chooserChange( const QString&, int , QLineEdit*, int ); 109 void chooserChange( const QString&, int , QLineEdit*, int );
110 bool cmbChooserChange( int , QLineEdit*, int );
109 111
110 bool useFullName; 112 bool useFullName;
111 113