Diffstat (limited to 'core/pim/addressbook/contacteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 75 |
1 files changed, 59 insertions, 16 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index d14ac51..d830ad3 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -67,20 +67,27 @@ ContactEditor::ContactEditor( const OContact &entry, | |||
67 | const char *name, | 67 | const char *name, |
68 | WFlags fl ) | 68 | WFlags fl ) |
69 | : QDialog( parent, name, TRUE, fl ), | 69 | : QDialog( parent, name, TRUE, fl ), |
70 | m_personalView ( false ) | 70 | defaultEmailChooserPosition( -1 ), |
71 | 71 | m_personalView ( false ), | |
72 | cmbDefaultEmail( 0 ), | ||
73 | initializing ( false ) | ||
72 | { | 74 | { |
73 | 75 | ||
76 | initializing = true; | ||
77 | |||
74 | init(); | 78 | init(); |
75 | setEntry( entry ); | 79 | setEntry( entry ); |
76 | cmbDefaultEmail = 0; | 80 | // cmbDefaultEmail = 0; |
77 | defaultEmailChooserPosition = -1; | 81 | // defaultEmailChooserPosition = -1; |
82 | |||
83 | initializing = false; | ||
78 | } | 84 | } |
79 | 85 | ||
80 | ContactEditor::~ContactEditor() { | 86 | ContactEditor::~ContactEditor() { |
81 | } | 87 | } |
82 | 88 | ||
83 | void ContactEditor::init() { | 89 | void ContactEditor::init() { |
90 | qWarning("init() START"); | ||
84 | 91 | ||
85 | useFullName = true; | 92 | useFullName = true; |
86 | 93 | ||
@@ -600,9 +607,9 @@ void ContactEditor::init() { | |||
600 | cmbChooserField3->insertStringList( trlChooserNames ); | 607 | cmbChooserField3->insertStringList( trlChooserNames ); |
601 | cmbChooserField4->insertStringList( trlChooserNames ); | 608 | cmbChooserField4->insertStringList( trlChooserNames ); |
602 | 609 | ||
603 | cmbChooserField1->setCurrentItem( 0 ); | 610 | cmbChooserField1->setCurrentItem( 0 ); |
604 | cmbChooserField2->setCurrentItem( 1 ); | 611 | cmbChooserField2->setCurrentItem( 1 ); |
605 | cmbChooserField3->setCurrentItem( 2 ); | 612 | cmbChooserField3->setCurrentItem( 2 ); |
606 | 613 | ||
607 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); | 614 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); |
608 | 615 | ||
@@ -642,6 +649,8 @@ void ContactEditor::init() { | |||
642 | new QPEDialogListener(this); | 649 | new QPEDialogListener(this); |
643 | 650 | ||
644 | setPersonalView ( m_personalView ); | 651 | setPersonalView ( m_personalView ); |
652 | |||
653 | qWarning("init() END"); | ||
645 | } | 654 | } |
646 | 655 | ||
647 | void ContactEditor::defaultEmailChanged(int i){ | 656 | void ContactEditor::defaultEmailChanged(int i){ |
@@ -692,15 +701,18 @@ void ContactEditor::populateDefaultEmailCmb(){ | |||
692 | // be handled by something else.. | 701 | // be handled by something else.. |
693 | bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) { | 702 | bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) { |
694 | QString type = slChooserNames[index]; | 703 | QString type = slChooserNames[index]; |
695 | qWarning("ContactEditor::cmbChooserChange -> Type: %s", type.latin1() ); | 704 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); |
705 | |||
706 | if ( !initializing ) | ||
707 | contactfields.setFieldOrder( widgetPos-1, index ); | ||
696 | 708 | ||
697 | // Create and connect combobox for selecting the default email | 709 | // Create and connect combobox for selecting the default email |
698 | if ( type == "Default Email"){ | 710 | if ( type == "Default Email"){ |
699 | qWarning("Choosing default-email "); | 711 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); |
700 | 712 | ||
701 | // More than one defaul-email chooser is not allowed ! | 713 | // More than one defaul-email chooser is not allowed ! |
702 | if ( ( defaultEmailChooserPosition != -1 ) && | 714 | if ( ( defaultEmailChooserPosition != -1 ) && |
703 | defaultEmailChooserPosition != widgetPos ){ | 715 | defaultEmailChooserPosition != widgetPos && !initializing){ |
704 | chooserError( widgetPos ); | 716 | chooserError( widgetPos ); |
705 | return true; | 717 | return true; |
706 | } | 718 | } |
@@ -710,7 +722,13 @@ bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widget | |||
710 | cmbDefaultEmail = 0l; | 722 | cmbDefaultEmail = 0l; |
711 | } | 723 | } |
712 | cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); | 724 | cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); |
713 | cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); | 725 | cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); /* :SX */ |
726 | |||
727 | QRect rect = inputWid->frameGeometry(); | ||
728 | qWarning("Geometrie: X=%d, Y=%d, Left=%d, Top=%d, Right=%d, Bottom=%d", | ||
729 | rect.x(), rect.y(), rect.left(), rect.top(), rect.right(), rect.bottom()); | ||
730 | QPoint pnt = inputWid->pos(); | ||
731 | qWarning("Position : X=%d, Y=%d", pnt.x(), pnt.y() ); | ||
714 | 732 | ||
715 | connect( cmbDefaultEmail,SIGNAL( activated(int) ), | 733 | connect( cmbDefaultEmail,SIGNAL( activated(int) ), |
716 | SLOT( defaultEmailChanged(int) ) ); | 734 | SLOT( defaultEmailChanged(int) ) ); |
@@ -944,6 +962,11 @@ void ContactEditor::slotCmbChooser4Change( int index ) { | |||
944 | 962 | ||
945 | void ContactEditor::slotAddressTypeChange( int index ) { | 963 | void ContactEditor::slotAddressTypeChange( int index ) { |
946 | 964 | ||
965 | |||
966 | if ( !initializing ) | ||
967 | contactfields.setFieldOrder( 4, index ); | ||
968 | |||
969 | |||
947 | if ( index == 0 ) { | 970 | if ( index == 0 ) { |
948 | 971 | ||
949 | txtAddress->setText( slBusinessAddress[0] ); | 972 | txtAddress->setText( slBusinessAddress[0] ); |
@@ -1276,12 +1299,12 @@ void ContactEditor::cleanupFields() { | |||
1276 | 1299 | ||
1277 | void ContactEditor::setEntry( const OContact &entry ) { | 1300 | void ContactEditor::setEntry( const OContact &entry ) { |
1278 | 1301 | ||
1302 | initializing = true; | ||
1303 | |||
1279 | cleanupFields(); | 1304 | cleanupFields(); |
1280 | 1305 | ||
1281 | ent = entry; | 1306 | ent = entry; |
1282 | 1307 | ||
1283 | |||
1284 | |||
1285 | emails = QStringList(ent.emailList()); | 1308 | emails = QStringList(ent.emailList()); |
1286 | defaultEmail = ent.defaultEmail(); | 1309 | defaultEmail = ent.defaultEmail(); |
1287 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; | 1310 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; |
@@ -1455,14 +1478,32 @@ void ContactEditor::setEntry( const OContact &entry ) { | |||
1455 | 1478 | ||
1456 | txtNote->setText( ent.notes() ); | 1479 | txtNote->setText( ent.notes() ); |
1457 | 1480 | ||
1481 | slotAddressTypeChange( cmbAddress->currentItem() ); | ||
1482 | |||
1483 | // Calling "show()" to arrange all widgets. Otherwise we will get | ||
1484 | // a wrong position of the textfields and are unable to put our | ||
1485 | // default-email combo over it.. This is very ugly ! | ||
1486 | // Does anybody has a better solution ? | ||
1487 | // Basically we should rethink the strategy to hide | ||
1488 | // a textfield with overwriting.. (se) | ||
1489 | show(); | ||
1490 | |||
1491 | // Get combo-settings from contact and set preset.. | ||
1492 | contactfields.loadFromRecord( ent ); | ||
1493 | cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 0) ); | ||
1494 | cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 1) ); | ||
1495 | cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 2) ); | ||
1496 | cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 5) ); | ||
1497 | cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) ); | ||
1458 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); | 1498 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); |
1459 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); | 1499 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); |
1460 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); | 1500 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); |
1461 | 1501 | slotCmbChooser4Change( cmbChooserField4->currentItem() ); | |
1462 | slotAddressTypeChange( cmbAddress->currentItem() ); | 1502 | slotAddressTypeChange( cmbAddress->currentItem() ); |
1463 | 1503 | ||
1464 | // loadFields(); :SX | ||
1465 | updateDatePicker(); | 1504 | updateDatePicker(); |
1505 | |||
1506 | initializing = false; | ||
1466 | } | 1507 | } |
1467 | void ContactEditor::updateDatePicker() | 1508 | void ContactEditor::updateDatePicker() |
1468 | { | 1509 | { |
@@ -1483,7 +1524,9 @@ void ContactEditor::updateDatePicker() | |||
1483 | 1524 | ||
1484 | void ContactEditor::saveEntry() { | 1525 | void ContactEditor::saveEntry() { |
1485 | 1526 | ||
1486 | 1527 | // Store current combo into contact | |
1528 | contactfields.saveToRecord( ent ); | ||
1529 | |||
1487 | if ( useFullName ) { | 1530 | if ( useFullName ) { |
1488 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); | 1531 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); |
1489 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); | 1532 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); |