Diffstat (limited to 'core/pim/addressbook/contacteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 107 |
1 files changed, 63 insertions, 44 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index b60f2dd..d1338f6 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -163,21 +163,39 @@ void ContactEditor::init() { | |||
163 | gl->addWidget( txtOrganization, 2, 1 ); | 163 | gl->addWidget( txtOrganization, 2, 1 ); |
164 | 164 | ||
165 | // Chooser 1 | ||
165 | cmbChooserField1 = new QComboBox( FALSE, container ); | 166 | cmbChooserField1 = new QComboBox( FALSE, container ); |
166 | cmbChooserField1->setMaximumWidth( 90 ); | 167 | cmbChooserField1->setMaximumWidth( 90 ); |
167 | gl->addWidget( cmbChooserField1, 3, 0 ); | 168 | gl->addWidget( cmbChooserField1, 3, 0 ); |
168 | txtChooserField1 = new QLineEdit( container ); | 169 | // Textfield for chooser 1. |
169 | gl->addWidget( txtChooserField1, 3, 1 ); | 170 | // Now use Widgetstack to contain the textfield and the default-email combo ! |
170 | 171 | m_widgetStack1 = new QWidgetStack( container ); | |
172 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); | ||
173 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); | ||
174 | gl->addWidget( m_widgetStack1, 3, 1 ); | ||
175 | m_widgetStack1 -> raiseWidget( TextField ); | ||
176 | |||
177 | // Chooser 2 | ||
171 | cmbChooserField2 = new QComboBox( FALSE, container ); | 178 | cmbChooserField2 = new QComboBox( FALSE, container ); |
172 | cmbChooserField2->setMaximumWidth( 90 ); | 179 | cmbChooserField2->setMaximumWidth( 90 ); |
173 | gl->addWidget( cmbChooserField2, 4, 0 ); | 180 | gl->addWidget( cmbChooserField2, 4, 0 ); |
174 | txtChooserField2 = new QLineEdit( container ); | 181 | // Textfield for chooser 2 |
175 | gl->addWidget( txtChooserField2, 4, 1 ); | 182 | // Now use WidgetStack to contain the textfield and the default-email combo! |
176 | 183 | m_widgetStack2 = new QWidgetStack( container ); | |
184 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); | ||
185 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); | ||
186 | gl->addWidget( m_widgetStack2, 4, 1 ); | ||
187 | m_widgetStack2 -> raiseWidget( TextField ); | ||
188 | |||
189 | // Chooser 3 | ||
177 | cmbChooserField3 = new QComboBox( FALSE, container ); | 190 | cmbChooserField3 = new QComboBox( FALSE, container ); |
178 | cmbChooserField3->setMaximumWidth( 90 ); | 191 | cmbChooserField3->setMaximumWidth( 90 ); |
179 | gl->addWidget( cmbChooserField3, 5, 0 ); | 192 | gl->addWidget( cmbChooserField3, 5, 0 ); |
180 | txtChooserField3 = new QLineEdit( container ); | 193 | // Textfield for chooser 2 |
181 | gl->addWidget( txtChooserField3, 5, 1 ); | 194 | // Now use WidgetStack to contain the textfield and the default-email combo! |
195 | m_widgetStack3 = new QWidgetStack( container ); | ||
196 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); | ||
197 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); | ||
198 | gl->addWidget( m_widgetStack3, 5, 1 ); | ||
199 | m_widgetStack3 -> raiseWidget( TextField ); | ||
182 | 200 | ||
183 | l = new QLabel( tr( "File As" ), container ); | 201 | l = new QLabel( tr( "File As" ), container ); |
@@ -458,9 +476,15 @@ void ContactEditor::init() { | |||
458 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); | 476 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); |
459 | 477 | ||
478 | // Chooser 4 | ||
460 | cmbChooserField4 = new QComboBox( FALSE, container ); | 479 | cmbChooserField4 = new QComboBox( FALSE, container ); |
461 | cmbChooserField4->setMaximumWidth( 90 ); | 480 | cmbChooserField4->setMaximumWidth( 90 ); |
462 | gl->addWidget( cmbChooserField4, 6, 0 ); | 481 | gl->addWidget( cmbChooserField4, 6, 0 ); |
463 | txtChooserField4 = new QLineEdit( container ); | 482 | // Textfield for chooser 2 |
464 | gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 ); | 483 | // Now use WidgetStack to contain the textfield and the default-email combo! |
484 | m_widgetStack4 = new QWidgetStack( container ); | ||
485 | txtChooserField4 = new QLineEdit( m_widgetStack4 ); | ||
486 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); | ||
487 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); | ||
488 | m_widgetStack4 -> raiseWidget( TextField ); | ||
465 | 489 | ||
466 | QSpacerItem *space = new QSpacerItem(1,1, | 490 | QSpacerItem *space = new QSpacerItem(1,1, |
@@ -701,5 +725,5 @@ void ContactEditor::populateDefaultEmailCmb(){ | |||
701 | // "true" returned if the change was chandled by this function, else it should | 725 | // "true" returned if the change was chandled by this function, else it should |
702 | // be handled by something else.. | 726 | // be handled by something else.. |
703 | bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) { | 727 | bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { |
704 | QString type = slChooserNames[index]; | 728 | QString type = slChooserNames[index]; |
705 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); | 729 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); |
@@ -712,5 +736,5 @@ bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widget | |||
712 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); | 736 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); |
713 | 737 | ||
714 | // More than one defaul-email chooser is not allowed ! | 738 | // More than one default-email chooser is not allowed ! |
715 | if ( ( defaultEmailChooserPosition != -1 ) && | 739 | if ( ( defaultEmailChooserPosition != -1 ) && |
716 | defaultEmailChooserPosition != widgetPos && !initializing){ | 740 | defaultEmailChooserPosition != widgetPos && !initializing){ |
@@ -719,25 +743,21 @@ bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widget | |||
719 | } | 743 | } |
720 | 744 | ||
721 | if ( cmbDefaultEmail ){ | 745 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); |
722 | delete cmbDefaultEmail; | 746 | if ( cmbo ){ |
723 | cmbDefaultEmail = 0l; | 747 | inputStack->raiseWidget( TextField ); |
748 | inputStack -> removeWidget( cmbo ); | ||
749 | delete cmbo; | ||
724 | } | 750 | } |
725 | cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); | 751 | cmbo = new QComboBox( inputStack ); |
726 | cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); /* :SX */ | 752 | cmbo -> insertStringList( emails ); |
727 | |||
728 | QRect rect = inputWid->frameGeometry(); | ||
729 | qWarning("Geometrie: X=%d, Y=%d, Left=%d, Top=%d, Right=%d, Bottom=%d", | ||
730 | rect.x(), rect.y(), rect.left(), rect.top(), rect.right(), rect.bottom()); | ||
731 | QPoint pnt = inputWid->pos(); | ||
732 | qWarning("Position : X=%d, Y=%d", pnt.x(), pnt.y() ); | ||
733 | |||
734 | connect( cmbDefaultEmail,SIGNAL( activated(int) ), | ||
735 | SLOT( defaultEmailChanged(int) ) ); | ||
736 | 753 | ||
737 | cmbDefaultEmail->clear(); | 754 | inputStack -> addWidget( cmbo, Combo ); |
738 | cmbDefaultEmail->insertStringList( emails ); | 755 | inputStack -> raiseWidget( Combo ); |
739 | cmbDefaultEmail->show(); | ||
740 | 756 | ||
741 | defaultEmailChooserPosition = widgetPos; | 757 | defaultEmailChooserPosition = widgetPos; |
758 | cmbDefaultEmail = cmbo; | ||
759 | |||
760 | connect( cmbo,SIGNAL( activated(int) ), | ||
761 | SLOT( defaultEmailChanged(int) ) ); | ||
742 | 762 | ||
743 | // Set current default email | 763 | // Set current default email |
@@ -750,6 +770,11 @@ bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widget | |||
750 | if ( defaultEmailChooserPosition == widgetPos ){ | 770 | if ( defaultEmailChooserPosition == widgetPos ){ |
751 | defaultEmailChooserPosition = -1; | 771 | defaultEmailChooserPosition = -1; |
752 | if ( cmbDefaultEmail ) | 772 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); |
753 | cmbDefaultEmail->hide(); | 773 | if ( cmbo ){ |
774 | inputStack->raiseWidget( TextField ); | ||
775 | inputStack -> removeWidget( cmbo ); | ||
776 | cmbDefaultEmail = 0l; | ||
777 | delete cmbo; | ||
778 | } | ||
754 | 779 | ||
755 | } | 780 | } |
@@ -803,5 +828,5 @@ void ContactEditor::chooserChange( const QString &textChanged, int index, | |||
803 | QLineEdit* , int widgetPos ) { | 828 | QLineEdit* , int widgetPos ) { |
804 | 829 | ||
805 | QString type = slChooserNames[index]; | 830 | QString type = slChooserNames[index]; // :SX |
806 | qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", | 831 | qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", |
807 | type.latin1(),textChanged.latin1(), index, widgetPos ); | 832 | type.latin1(),textChanged.latin1(), index, widgetPos ); |
@@ -813,11 +838,5 @@ void ContactEditor::chooserChange( const QString &textChanged, int index, | |||
813 | populateDefaultEmailCmb(); | 838 | populateDefaultEmailCmb(); |
814 | 839 | ||
815 | }else if (defaultEmailChooserPosition == widgetPos){ | 840 | }else if (type == "Emails"){ |
816 | qDebug("cmbDefaultEmail->hide()"); | ||
817 | |||
818 | if (cmbDefaultEmail) cmbDefaultEmail->hide(); | ||
819 | widgetPos=-1; | ||
820 | |||
821 | }else if (type == "Emails"){ | ||
822 | qDebug("emails"); | 841 | qDebug("emails"); |
823 | 842 | ||
@@ -920,6 +939,6 @@ void ContactEditor::slotCountryChange( const QString &textChanged ) { | |||
920 | void ContactEditor::slotCmbChooser1Change( int index ) { | 939 | void ContactEditor::slotCmbChooser1Change( int index ) { |
921 | qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); | 940 | qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); |
922 | if ( !cmbChooserChange( cmbChooserField1->currentItem(), txtChooserField1, 1) ){ | 941 | if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){ |
923 | 942 | ||
924 | txtChooserField1->setText( slChooserValues[index] ); | 943 | txtChooserField1->setText( slChooserValues[index] ); |
925 | txtChooserField1->setFocus(); | 944 | txtChooserField1->setFocus(); |
@@ -932,5 +951,5 @@ void ContactEditor::slotCmbChooser2Change( int index ) { | |||
932 | qWarning("ContactEditor::slotCmbChooser2Change( %d )", index); | 951 | qWarning("ContactEditor::slotCmbChooser2Change( %d )", index); |
933 | 952 | ||
934 | if ( !cmbChooserChange( cmbChooserField2->currentItem(), txtChooserField2, 2) ){ | 953 | if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){ |
935 | 954 | ||
936 | txtChooserField2->setText( slChooserValues[index] ); | 955 | txtChooserField2->setText( slChooserValues[index] ); |
@@ -943,5 +962,5 @@ void ContactEditor::slotCmbChooser3Change( int index ) { | |||
943 | qWarning("ContactEditor::slotCmbChooser3Change( %d )", index); | 962 | qWarning("ContactEditor::slotCmbChooser3Change( %d )", index); |
944 | 963 | ||
945 | if ( !cmbChooserChange( cmbChooserField3->currentItem(), txtChooserField3, 3) ){ | 964 | if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){ |
946 | 965 | ||
947 | txtChooserField3->setText( slChooserValues[index] ); | 966 | txtChooserField3->setText( slChooserValues[index] ); |
@@ -954,5 +973,5 @@ void ContactEditor::slotCmbChooser4Change( int index ) { | |||
954 | qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); | 973 | qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); |
955 | 974 | ||
956 | if ( !cmbChooserChange( cmbChooserField4->currentItem(), txtChooserField4, 4) ){ | 975 | if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){ |
957 | 976 | ||
958 | txtChooserField4->setText( slChooserValues[index] ); | 977 | txtChooserField4->setText( slChooserValues[index] ); |