summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/contacteditor.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/contacteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp327
1 files changed, 164 insertions, 163 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 8acf570..534666d 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -18,26 +18,27 @@
18 * is made to operate exactly in interface with the exception of name. 18 * is made to operate exactly in interface with the exception of name.
19 * 19 *
20 */ 20 */
21 21
22#include "contacteditor.h" 22#include "contacteditor.h"
23 23
24#include <opie2/opimcontact.h>
25
24#include <qpe/categoryselect.h> 26#include <qpe/categoryselect.h>
25#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
26#include <qpe/qpedialog.h> 28#include <qpe/qpedialog.h>
27#include <opie/ocontact.h>
28#include <qpe/resource.h> 29#include <qpe/resource.h>
29 30
30#include <qlabel.h> 31#include <qlabel.h>
31#include <qtabwidget.h> 32#include <qtabwidget.h>
32#include <qlayout.h> 33#include <qlayout.h>
33#include <qlineedit.h> 34#include <qlineedit.h>
34#include <qmultilineedit.h> 35#include <qmultilineedit.h>
35#include <qtoolbutton.h> 36#include <qtoolbutton.h>
36#include <qlistbox.h> 37#include <qlistbox.h>
37#include <qmessagebox.h> 38#include <qmessagebox.h>
38#include <qwhatsthis.h> 39#include <qwhatsthis.h>
39 40
40#include <assert.h> 41#include <assert.h>
41 42
42static inline bool containsAlphaNum( const QString &str ); 43static inline bool containsAlphaNum( const QString &str );
43static inline bool constainsWhiteSpace( const QString &str ); 44static inline bool constainsWhiteSpace( const QString &str );
@@ -48,13 +49,13 @@ void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
48 QString &strAll ); 49 QString &strAll );
49 50
50// helper convert from file format to comma delimited... 51// helper convert from file format to comma delimited...
51void parseEmailTo( const QString &strDefaultEmail, 52void parseEmailTo( const QString &strDefaultEmail,
52 const QString &strOtherEmail, QString &strBack ); 53 const QString &strOtherEmail, QString &strBack );
53 54
54 ContactEditor::ContactEditor(const OContact &entry, 55 ContactEditor::ContactEditor(const Opie::OPimContact &entry,
55 QWidget *parent, 56 QWidget *parent,
56 const char *name, 57 const char *name,
57 WFlags ) 58 WFlags )
58 : QDialog( parent, name, TRUE, WStyle_ContextHelp ), 59 : QDialog( parent, name, TRUE, WStyle_ContextHelp ),
59 defaultEmailChooserPosition( -1 ), 60 defaultEmailChooserPosition( -1 ),
60 m_personalView ( false ), 61 m_personalView ( false ),
@@ -74,37 +75,37 @@ ContactEditor::ContactEditor( const OContact &entry,
74 75
75ContactEditor::~ContactEditor() { 76ContactEditor::~ContactEditor() {
76} 77}
77 78
78void ContactEditor::init() { 79void ContactEditor::init() {
79 qWarning("init() START"); 80 qWarning("init() START");
80 81
81 uint i = 0; 82 uint i = 0;
82 83
83 QStringList trlChooserNames; 84 QStringList trlChooserNames;
84 85
85 for (i = 0; i <= 6; i++) { 86 for (i = 0; i <= 6; i++) {
86 slHomeAddress.append( "" ); 87 slHomeAddress.append( "" );
87 slBusinessAddress.append( "" ); 88 slBusinessAddress.append( "" );
88 } 89 }
89 90
90 trlChooserNames = OContactFields::trphonefields( false ); 91 trlChooserNames = Opie::OPimContactFields::trphonefields( false );
91 slChooserNames = OContactFields::untrphonefields( false ); 92 slChooserNames = Opie::OPimContactFields::untrphonefields( false );
92 slDynamicEntries = OContactFields::untrdetailsfields( false ); 93 slDynamicEntries = Opie::OPimContactFields::untrdetailsfields( false );
93 trlDynamicEntries = OContactFields::trdetailsfields( false ); 94 trlDynamicEntries = Opie::OPimContactFields::trdetailsfields( false );
94 95
95 // Ok, we have to remove elements from the list of dynamic entries 96 // Ok, we have to remove elements from the list of dynamic entries
96 // which are now stored in special (not dynamic) widgets.. 97 // which are now stored in special (not dynamic) widgets..
97 // Otherwise we will get problems with field assignments! (se) 98 // Otherwise we will get problems with field assignments! (se)
98 slDynamicEntries.remove("Anniversary"); 99 slDynamicEntries.remove("Anniversary");
99 slDynamicEntries.remove("Birthday"); 100 slDynamicEntries.remove("Birthday");
100 slDynamicEntries.remove("Gender"); 101 slDynamicEntries.remove("Gender");
101 102
102 // The same with translated fields.. But I will 103 // The same with translated fields.. But I will
103 // use the translation map to avoid mismatches.. 104 // use the translation map to avoid mismatches..
104 QMap<int, QString> translMap = OContactFields::idToTrFields(); 105 QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields();
105 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); 106 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] );
106 trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); 107 trlDynamicEntries.remove( translMap[Qtopia::Birthday] );
107 trlDynamicEntries.remove( translMap[Qtopia::Gender] ); 108 trlDynamicEntries.remove( translMap[Qtopia::Gender] );
108 109
109 // Last Check to be sure.. 110 // Last Check to be sure..
110 assert( slDynamicEntries.count() == trlDynamicEntries.count() ); 111 assert( slDynamicEntries.count() == trlDynamicEntries.count() );
@@ -161,13 +162,13 @@ void ContactEditor::init() {
161 QWhatsThis::add( l, tr( "The working place of the contact" ) ); 162 QWhatsThis::add( l, tr( "The working place of the contact" ) );
162 gl->addWidget( l, 3, 0 ); 163 gl->addWidget( l, 3, 0 );
163 txtOrganization = new QLineEdit( container ); 164 txtOrganization = new QLineEdit( container );
164 QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); 165 QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) );
165 gl->addWidget( txtOrganization, 3, 1 ); 166 gl->addWidget( txtOrganization, 3, 1 );
166 167
167 // Chooser 1 168 // Chooser 1
168 cmbChooserField1 = new QComboBox( FALSE, container ); 169 cmbChooserField1 = new QComboBox( FALSE, container );
169 QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); 170 QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) );
170 cmbChooserField1->setMaximumWidth( 90 ); 171 cmbChooserField1->setMaximumWidth( 90 );
171 gl->addWidget( cmbChooserField1, 4, 0 ); 172 gl->addWidget( cmbChooserField1, 4, 0 );
172 // Textfield for chooser 1. 173 // Textfield for chooser 1.
173 // Now use Widgetstack to contain the textfield and the default-email combo ! 174 // Now use Widgetstack to contain the textfield and the default-email combo !
@@ -526,13 +527,13 @@ void ContactEditor::init() {
526 m1->insertItem( birthdayPicker ); 527 m1->insertItem( birthdayPicker );
527 528
528 birthdayButton= new QToolButton( hBox, "buttonStart" ); 529 birthdayButton= new QToolButton( hBox, "buttonStart" );
529 birthdayButton->setPopup( m1 ); 530 birthdayButton->setPopup( m1 );
530 birthdayButton->setPopupDelay(0); 531 birthdayButton->setPopupDelay(0);
531 532
532 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 533 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
533 tr( "Delete" ), 534 tr( "Delete" ),
534 hBox, 0 ); 535 hBox, 0 );
535 536
536 gl->addWidget( hBox, counter , 1 ); 537 gl->addWidget( hBox, counter , 1 );
537 538
538 connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ), 539 connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ),
@@ -551,13 +552,13 @@ void ContactEditor::init() {
551 m1->insertItem( anniversaryPicker ); 552 m1->insertItem( anniversaryPicker );
552 553
553 anniversaryButton= new QToolButton( hBox, "buttonStart" ); 554 anniversaryButton= new QToolButton( hBox, "buttonStart" );
554 anniversaryButton->setPopup( m1 ); 555 anniversaryButton->setPopup( m1 );
555 anniversaryButton->setPopupDelay(0); 556 anniversaryButton->setPopupDelay(0);
556 557
557 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 558 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
558 tr( "Delete" ), 559 tr( "Delete" ),
559 hBox, 0 ); 560 hBox, 0 );
560 gl->addWidget( hBox, counter , 1 ); 561 gl->addWidget( hBox, counter , 1 );
561 562
562 connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), 563 connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ),
563 this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); 564 this, SLOT( slotAnniversaryDateChanged(int,int,int) ) );
@@ -575,17 +576,17 @@ void ContactEditor::init() {
575 gl->addWidget( cmbGender, counter, 1 ); 576 gl->addWidget( cmbGender, counter, 1 );
576 577
577 ++counter; 578 ++counter;
578 579
579 // Create Labels and lineedit fields for every dynamic entry 580 // Create Labels and lineedit fields for every dynamic entry
580 QStringList::ConstIterator it = slDynamicEntries.begin(); 581 QStringList::ConstIterator it = slDynamicEntries.begin();
581 QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); 582 QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId();
582 QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); 583 QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields();
583 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { 584 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) {
584 585
585 if (((*it) == "Anniversary") || 586 if (((*it) == "Anniversary") ||
586 ((*it) == "Birthday")|| ((*it) == "Gender")) continue; 587 ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
587 588
588 l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); 589 l = new QLabel( mapIdToStr[mapStrToID[*it]], container );
589 listName.append( l ); 590 listName.append( l );
590 gl->addWidget( l, i, 0 ); 591 gl->addWidget( l, i, 0 );
591 QLineEdit *e = new QLineEdit( container ); 592 QLineEdit *e = new QLineEdit( container );
@@ -641,17 +642,17 @@ void ContactEditor::init() {
641 cmbChooserField1->setCurrentItem( 0 ); 642 cmbChooserField1->setCurrentItem( 0 );
642 cmbChooserField2->setCurrentItem( 1 ); 643 cmbChooserField2->setCurrentItem( 1 );
643 cmbChooserField3->setCurrentItem( 2 ); 644 cmbChooserField3->setCurrentItem( 2 );
644 645
645 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 646 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
646 647
647 connect( txtFullName, SIGNAL(textChanged(const QString&)), 648 connect( txtFullName, SIGNAL(textChanged(const QString&)),
648 this, SLOT(slotFullNameChange(const QString&)) ); 649 this, SLOT(slotFullNameChange(const QString&)) );
649 connect( txtSuffix, SIGNAL(textChanged(const QString&)), 650 connect( txtSuffix, SIGNAL(textChanged(const QString&)),
650 this, SLOT(slotSuffixChange(const QString&)) ); 651 this, SLOT(slotSuffixChange(const QString&)) );
651 connect( txtOrganization, SIGNAL(textChanged(const QString&)), 652 connect( txtOrganization, SIGNAL(textChanged(const QString&)),
652 this, SLOT(slotOrganizationChange(const QString&)) ); 653 this, SLOT(slotOrganizationChange(const QString&)) );
653 connect( txtChooserField1, SIGNAL(textChanged(const QString&)), 654 connect( txtChooserField1, SIGNAL(textChanged(const QString&)),
654 this, SLOT(slotChooser1Change(const QString&)) ); 655 this, SLOT(slotChooser1Change(const QString&)) );
655 connect( txtChooserField2, SIGNAL(textChanged(const QString&)), 656 connect( txtChooserField2, SIGNAL(textChanged(const QString&)),
656 this, SLOT(slotChooser2Change(const QString&)) ); 657 this, SLOT(slotChooser2Change(const QString&)) );
657 connect( txtChooserField3, SIGNAL(textChanged(const QString&)), 658 connect( txtChooserField3, SIGNAL(textChanged(const QString&)),
@@ -697,21 +698,21 @@ void ContactEditor::defaultEmailChanged(int i){
697 698
698 defaultEmail = cmbDefaultEmail->text(i); 699 defaultEmail = cmbDefaultEmail->text(i);
699 qDebug ("Changed to: %s", defaultEmail.latin1()); 700 qDebug ("Changed to: %s", defaultEmail.latin1());
700 701
701} 702}
702 703
703void ContactEditor::populateDefaultEmailCmb(){ 704void ContactEditor::populateDefaultEmailCmb(){
704 705
705 // if the default-email combo was not selected and therfore not created 706 // if the default-email combo was not selected and therfore not created
706 // we get a lot of trouble.. Therfore create an invisible one.. 707 // we get a lot of trouble.. Therfore create an invisible one..
707 if ( !cmbDefaultEmail ){ 708 if ( !cmbDefaultEmail ){
708 cmbDefaultEmail = new QComboBox(this); 709 cmbDefaultEmail = new QComboBox(this);
709 cmbDefaultEmail -> hide(); 710 cmbDefaultEmail -> hide();
710 } 711 }
711 cmbDefaultEmail->clear(); 712 cmbDefaultEmail->clear();
712 cmbDefaultEmail->insertStringList( emails ); 713 cmbDefaultEmail->insertStringList( emails );
713 // cmbDefaultEmail->show(); 714 // cmbDefaultEmail->show();
714 715
715 // Select default email in combo.. 716 // Select default email in combo..
716 bool found = false; 717 bool found = false;
717 for ( int i = 0; i < cmbDefaultEmail->count(); i++){ 718 for ( int i = 0; i < cmbDefaultEmail->count(); i++){
@@ -721,13 +722,13 @@ void ContactEditor::populateDefaultEmailCmb(){
721 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ 722 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
722 cmbDefaultEmail->setCurrentItem( i ); 723 cmbDefaultEmail->setCurrentItem( i );
723 qDebug("set"); 724 qDebug("set");
724 found = true; 725 found = true;
725 } 726 }
726 } 727 }
727 728
728 // If the current default email is not found in the list, we choose the 729 // If the current default email is not found in the list, we choose the
729 // first one.. 730 // first one..
730 if ( !found ) 731 if ( !found )
731 defaultEmail = cmbDefaultEmail->text(0); 732 defaultEmail = cmbDefaultEmail->text(0);
732} 733}
733 734
@@ -738,25 +739,25 @@ bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int w
738 QString type = slChooserNames[index]; 739 QString type = slChooserNames[index];
739 qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); 740 qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos );
740 741
741 if ( !initializing ) 742 if ( !initializing )
742 contactfields.setFieldOrder( widgetPos-1, index ); 743 contactfields.setFieldOrder( widgetPos-1, index );
743 744
744 // Create and connect combobox for selecting the default email 745 // Create and connect combobox for selecting the default email
745 if ( type == "Default Email"){ 746 if ( type == "Default Email"){
746 qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); 747 qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition);
747 748
748 // More than one default-email chooser is not allowed ! 749 // More than one default-email chooser is not allowed !
749 if ( ( defaultEmailChooserPosition != -1 ) && 750 if ( ( defaultEmailChooserPosition != -1 ) &&
750 defaultEmailChooserPosition != widgetPos && !initializing){ 751 defaultEmailChooserPosition != widgetPos && !initializing){
751 chooserError( widgetPos ); 752 chooserError( widgetPos );
752 return true; 753 return true;
753 } 754 }
754 755
755 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); 756 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
756 if ( cmbo ){ 757 if ( cmbo ){
757 inputStack->raiseWidget( TextField ); 758 inputStack->raiseWidget( TextField );
758 inputStack -> removeWidget( cmbo ); 759 inputStack -> removeWidget( cmbo );
759 delete cmbo; 760 delete cmbo;
760 } 761 }
761 cmbo = new QComboBox( inputStack ); 762 cmbo = new QComboBox( inputStack );
762 cmbo -> insertStringList( emails ); 763 cmbo -> insertStringList( emails );
@@ -765,26 +766,26 @@ bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int w
765 inputStack -> raiseWidget( Combo ); 766 inputStack -> raiseWidget( Combo );
766 767
767 defaultEmailChooserPosition = widgetPos; 768 defaultEmailChooserPosition = widgetPos;
768 cmbDefaultEmail = cmbo; 769 cmbDefaultEmail = cmbo;
769 770
770 connect( cmbo,SIGNAL( activated(int) ), 771 connect( cmbo,SIGNAL( activated(int) ),
771 SLOT( defaultEmailChanged(int) ) ); 772 SLOT( defaultEmailChanged(int) ) );
772 773
773 // Set current default email 774 // Set current default email
774 populateDefaultEmailCmb(); 775 populateDefaultEmailCmb();
775 776
776 777
777 } else { 778 } else {
778 // Something else was selected: Hide combo.. 779 // Something else was selected: Hide combo..
779 qWarning(" Hiding default-email combo" ); 780 qWarning(" Hiding default-email combo" );
780 if ( defaultEmailChooserPosition == widgetPos ){ 781 if ( defaultEmailChooserPosition == widgetPos ){
781 defaultEmailChooserPosition = -1; 782 defaultEmailChooserPosition = -1;
782 } 783 }
783 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); 784 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
784 if ( cmbo ){ 785 if ( cmbo ){
785 inputStack->raiseWidget( TextField ); 786 inputStack->raiseWidget( TextField );
786 inputStack -> removeWidget( cmbo ); 787 inputStack -> removeWidget( cmbo );
787 cmbDefaultEmail = 0l; 788 cmbDefaultEmail = 0l;
788 delete cmbo; 789 delete cmbo;
789 } 790 }
790 791
@@ -798,52 +799,52 @@ bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int w
798 799
799} 800}
800 801
801// Currently accessed when we select default-email more than once ! 802// Currently accessed when we select default-email more than once !
802void ContactEditor::chooserError( int index ) 803void ContactEditor::chooserError( int index )
803{ 804{
804 qWarning("ContactEditor::chooserError( %d )", index); 805 qWarning("ContactEditor::chooserError( %d )", index);
805 QMessageBox::warning( this, "Chooser Error", 806 QMessageBox::warning( this, "Chooser Error",
806 "Multiple selection of this\n" 807 "Multiple selection of this\n"
807 "Item is not allowed !\n\n" 808 "Item is not allowed !\n\n"
808 "First deselect the previous one !", 809 "First deselect the previous one !",
809 "&OK", 0, 0, 810 "&OK", 0, 0,
810 0, 0 ); 811 0, 0 );
811 812
812 // Reset the selected Chooser. Unfortunately the chooser 813 // Reset the selected Chooser. Unfortunately the chooser
813 // generates no signal, therfore we have to 814 // generates no signal, therfore we have to
814 // call the cmbChooserChange function manually.. 815 // call the cmbChooserChange function manually..
815 switch( index ){ 816 switch( index ){
816 case 1: 817 case 1:
817 cmbChooserField1 -> setCurrentItem( 0 ); 818 cmbChooserField1 -> setCurrentItem( 0 );
818 slotCmbChooser1Change( 0 ); 819 slotCmbChooser1Change( 0 );
819 break; 820 break;
820 case 2: 821 case 2:
821 cmbChooserField2 -> setCurrentItem( 0 ); 822 cmbChooserField2 -> setCurrentItem( 0 );
822 slotCmbChooser2Change( 0 ); 823 slotCmbChooser2Change( 0 );
823 break; 824 break;
824 case 3: 825 case 3:
825 cmbChooserField3 -> setCurrentItem( 0 ); 826 cmbChooserField3 -> setCurrentItem( 0 );
826 slotCmbChooser3Change( 0 ); 827 slotCmbChooser3Change( 0 );
827 break; 828 break;
828 case 4: 829 case 4:
829 cmbChooserField4 -> setCurrentItem( 0 ); 830 cmbChooserField4 -> setCurrentItem( 0 );
830 slotCmbChooser4Change( 0 ); 831 slotCmbChooser4Change( 0 );
831 break; 832 break;
832 } 833 }
833} 834}
834 835
835// Called when something was changed in a textfield (shouldn't it called textchanged? (se)) 836// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
836void ContactEditor::chooserChange( const QString &textChanged, int index, 837void ContactEditor::chooserChange( const QString &textChanged, int index,
837 QLineEdit* , int widgetPos ) { 838 QLineEdit* , int widgetPos ) {
838 839
839 QString type = slChooserNames[index]; // :SX 840 QString type = slChooserNames[index]; // :SX
840 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", 841 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",
841 type.latin1(),textChanged.latin1(), index, widgetPos ); 842 type.latin1(),textChanged.latin1(), index, widgetPos );
842 843
843 if ( type == "Default Email"){ 844 if ( type == "Default Email"){
844 qWarning ("??? Wozu??: %s", textChanged.latin1()); 845 qWarning ("??? Wozu??: %s", textChanged.latin1());
845 defaultEmail = textChanged; 846 defaultEmail = textChanged;
846 847
847 populateDefaultEmailCmb(); 848 populateDefaultEmailCmb();
848 849
849 }else if (type == "Emails"){ 850 }else if (type == "Emails"){
@@ -851,13 +852,13 @@ void ContactEditor::chooserChange( const QString &textChanged, int index,
851 852
852 QString de; 853 QString de;
853 emails = QStringList::split (",", textChanged ); 854 emails = QStringList::split (",", textChanged );
854 855
855 populateDefaultEmailCmb(); 856 populateDefaultEmailCmb();
856 } 857 }
857 858
858 slChooserValues[index] = textChanged; 859 slChooserValues[index] = textChanged;
859 860
860} 861}
861 862
862void ContactEditor::slotChooser1Change( const QString &textChanged ) { 863void ContactEditor::slotChooser1Change( const QString &textChanged ) {
863 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); 864 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1());
@@ -945,13 +946,13 @@ void ContactEditor::slotCountryChange( const QString &textChanged ) {
945} 946}
946 947
947 948
948void ContactEditor::slotCmbChooser1Change( int index ) { 949void ContactEditor::slotCmbChooser1Change( int index ) {
949 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); 950 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index);
950 if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){ 951 if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){
951 952
952 txtChooserField1->setText( slChooserValues[index] ); 953 txtChooserField1->setText( slChooserValues[index] );
953 txtChooserField1->setFocus(); 954 txtChooserField1->setFocus();
954 955
955 } 956 }
956 957
957} 958}
@@ -1046,18 +1047,18 @@ void ContactEditor::slotSuffixChange( const QString& ) {
1046 // Just want to update the FileAs combo if the suffix was changed.. 1047 // Just want to update the FileAs combo if the suffix was changed..
1047 slotFullNameChange( txtFullName->text() ); 1048 slotFullNameChange( txtFullName->text() );
1048} 1049}
1049 1050
1050void ContactEditor::slotOrganizationChange( const QString &textChanged ){ 1051void ContactEditor::slotOrganizationChange( const QString &textChanged ){
1051 qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() ); 1052 qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() );
1052 // Special handling for storing Companies: 1053 // Special handling for storing Companies:
1053 // If no Fullname is given, we store the Company-Name as lastname 1054 // If no Fullname is given, we store the Company-Name as lastname
1054 // to handle it like a person.. 1055 // to handle it like a person..
1055 if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) ) 1056 if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) )
1056 txtFullName->setText( textChanged ); 1057 txtFullName->setText( textChanged );
1057 1058
1058} 1059}
1059 1060
1060void ContactEditor::accept() { 1061void ContactEditor::accept() {
1061 1062
1062 if ( isEmpty() ) { 1063 if ( isEmpty() ) {
1063 cleanupFields(); 1064 cleanupFields();
@@ -1134,13 +1135,13 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1134 1135
1135 commapos = simplifiedName.find( ',', 0, TRUE); 1136 commapos = simplifiedName.find( ',', 0, TRUE);
1136 if ( commapos >= 0 ) { 1137 if ( commapos >= 0 ) {
1137 qWarning(" Commapos: %d", commapos ); 1138 qWarning(" Commapos: %d", commapos );
1138 1139
1139 // A comma (",") separates the lastname from one or 1140 // A comma (",") separates the lastname from one or
1140 // many first names. Thus, remove the lastname from the 1141 // many first names. Thus, remove the lastname from the
1141 // String and parse the firstnames. 1142 // String and parse the firstnames.
1142 1143
1143 strLastName = simplifiedName.left( commapos ); 1144 strLastName = simplifiedName.left( commapos );
1144 simplifiedName= simplifiedName.mid( commapos + 1 ); 1145 simplifiedName= simplifiedName.mid( commapos + 1 );
1145 haveLastName = true; 1146 haveLastName = true;
1146 qWarning("Fullname without ',': %s", simplifiedName.latin1()); 1147 qWarning("Fullname without ',': %s", simplifiedName.latin1());
@@ -1151,30 +1152,30 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1151 QStringList allFirstNames = QStringList::split(" ", simplifiedName); 1152 QStringList allFirstNames = QStringList::split(" ", simplifiedName);
1152 QStringList::Iterator it = allFirstNames.begin(); 1153 QStringList::Iterator it = allFirstNames.begin();
1153 strFirstName = *it++; 1154 strFirstName = *it++;
1154 QStringList allSecondNames; 1155 QStringList allSecondNames;
1155 for ( ; it != allFirstNames.end(); ++it ) 1156 for ( ; it != allFirstNames.end(); ++it )
1156 allSecondNames.append( *it ); 1157 allSecondNames.append( *it );
1157 1158
1158 strMiddleName = allSecondNames.join(" "); 1159 strMiddleName = allSecondNames.join(" ");
1159 1160
1160 } else { 1161 } else {
1161 1162
1162 // No comma separator used: We use the first word as firstname, the 1163 // No comma separator used: We use the first word as firstname, the
1163 // last as second/lastname and everything in the middle as middlename 1164 // last as second/lastname and everything in the middle as middlename
1164 1165
1165 QStringList allNames = QStringList::split(" ", simplifiedName); 1166 QStringList allNames = QStringList::split(" ", simplifiedName);
1166 QStringList::Iterator it = allNames.begin(); 1167 QStringList::Iterator it = allNames.begin();
1167 strFirstName = *it++; 1168 strFirstName = *it++;
1168 QStringList allSecondNames; 1169 QStringList allSecondNames;
1169 for ( ; it != --allNames.end(); ++it ) 1170 for ( ; it != --allNames.end(); ++it )
1170 allSecondNames.append( *it ); 1171 allSecondNames.append( *it );
1171 1172
1172 strMiddleName = allSecondNames.join(" "); 1173 strMiddleName = allSecondNames.join(" ");
1173 strLastName = *(--allNames.end()); 1174 strLastName = *(--allNames.end());
1174 1175
1175 } 1176 }
1176 1177
1177 if ( strFirstName == strLastName ) 1178 if ( strFirstName == strLastName )
1178 strFirstName = ""; 1179 strFirstName = "";
1179 1180
1180 qWarning(" strFirstName: %s", strFirstName.latin1()); 1181 qWarning(" strFirstName: %s", strFirstName.latin1());
@@ -1182,55 +1183,55 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
1182 qWarning(" strLastName: %s", strLastName.latin1()); 1183 qWarning(" strLastName: %s", strLastName.latin1());
1183 qWarning(" strTitle: %s", strTitle.latin1()); 1184 qWarning(" strTitle: %s", strTitle.latin1());
1184 1185
1185 switch (type) { 1186 switch (type) {
1186 case NAME_FL: 1187 case NAME_FL:
1187 return strFirstName + " " + strLastName; 1188 return strFirstName + " " + strLastName;
1188 1189
1189 case NAME_LF: 1190 case NAME_LF:
1190 return strLastName + ", " + strFirstName; 1191 return strLastName + ", " + strFirstName;
1191 1192
1192 case NAME_LFM: 1193 case NAME_LFM:
1193 return strLastName + ", " + strFirstName + " " + strMiddleName; 1194 return strLastName + ", " + strFirstName + " " + strMiddleName;
1194 1195
1195 case NAME_FML: 1196 case NAME_FML:
1196 return strFirstName + " " + strMiddleName + " " + strLastName ; 1197 return strFirstName + " " + strMiddleName + " " + strLastName ;
1197 1198
1198 case NAME_F: 1199 case NAME_F:
1199 return strFirstName; 1200 return strFirstName;
1200 1201
1201 case NAME_M: 1202 case NAME_M:
1202 return strMiddleName; 1203 return strMiddleName;
1203 1204
1204 case NAME_L: 1205 case NAME_L:
1205 return strLastName; 1206 return strLastName;
1206 1207
1207 case NAME_S: 1208 case NAME_S:
1208 return txtSuffix->text(); 1209 return txtSuffix->text();
1209 1210
1210 } 1211 }
1211 return QString::null; 1212 return QString::null;
1212} 1213}
1213 1214
1214void ContactEditor::cleanupFields() { 1215void ContactEditor::cleanupFields() {
1215 QStringList::Iterator it = slChooserValues.begin(); 1216 QStringList::Iterator it = slChooserValues.begin();
1216 1217
1217 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { 1218 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
1218 (*it) = ""; 1219 (*it) = "";
1219 } 1220 }
1220 1221
1221 for ( int i = 0; i < 7; i++ ) { 1222 for ( int i = 0; i < 7; i++ ) {
1222 slHomeAddress[i] = ""; 1223 slHomeAddress[i] = "";
1223 slBusinessAddress[i] = ""; 1224 slBusinessAddress[i] = "";
1224 } 1225 }
1225 1226
1226 QListIterator<QLineEdit> itLV( listValue ); 1227 QListIterator<QLineEdit> itLV( listValue );
1227 for ( ; itLV.current(); ++itLV ) { 1228 for ( ; itLV.current(); ++itLV ) {
1228 (*itLV)->setText( "" ); 1229 (*itLV)->setText( "" );
1229 } 1230 }
1230 1231
1231 txtFirstName->setText(""); 1232 txtFirstName->setText("");
1232 txtMiddleName->setText(""); 1233 txtMiddleName->setText("");
1233 txtLastName->setText(""); 1234 txtLastName->setText("");
1234 txtSuffix->setText(""); 1235 txtSuffix->setText("");
1235 txtNote->setText(""); 1236 txtNote->setText("");
1236 txtFullName->setText(""); 1237 txtFullName->setText("");
@@ -1244,383 +1245,383 @@ void ContactEditor::cleanupFields() {
1244 txtState->setText(""); 1245 txtState->setText("");
1245 txtZip->setText(""); 1246 txtZip->setText("");
1246 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1247 QLineEdit *txtTmp = cmbCountry->lineEdit();
1247 txtTmp->setText(""); 1248 txtTmp->setText("");
1248 txtTmp = cmbFileAs->lineEdit(); 1249 txtTmp = cmbFileAs->lineEdit();
1249 txtTmp->setText(""); 1250 txtTmp->setText("");
1250 1251
1251} 1252}
1252 1253
1253void ContactEditor::setEntry( const OContact &entry ) { 1254void ContactEditor::setEntry( const Opie::OPimContact &entry ) {
1254 1255
1255 initializing = true; 1256 initializing = true;
1256 1257
1257 // Cleanup and activate the general Page .. 1258 // Cleanup and activate the general Page ..
1258 cleanupFields(); 1259 cleanupFields();
1259 tabMain->setCurrentPage( 0 ); 1260 tabMain->setCurrentPage( 0 );
1260 1261
1261 ent = entry; 1262 ent = entry;
1262 1263
1263 emails = QStringList(ent.emailList()); 1264 emails = QStringList(ent.emailList());
1264 defaultEmail = ent.defaultEmail(); 1265 defaultEmail = ent.defaultEmail();
1265 if (defaultEmail.isEmpty()) defaultEmail = emails[0]; 1266 if (defaultEmail.isEmpty()) defaultEmail = emails[0];
1266 qDebug("default email=%s",defaultEmail.latin1()); 1267 qDebug("default email=%s",defaultEmail.latin1());
1267 1268
1268 txtFirstName->setText( ent.firstName() ); 1269 txtFirstName->setText( ent.firstName() );
1269 txtMiddleName->setText( ent.middleName() ); 1270 txtMiddleName->setText( ent.middleName() );
1270 txtLastName->setText( ent.lastName() ); 1271 txtLastName->setText( ent.lastName() );
1271 txtSuffix->setText( ent.suffix() ); 1272 txtSuffix->setText( ent.suffix() );
1272 1273
1273 // QString *tmpString = new QString; 1274 // QString *tmpString = new QString;
1274 // *tmpString = ent.firstName() + " " + ent.middleName() + 1275 // *tmpString = ent.firstName() + " " + ent.middleName() +
1275 // + " " + ent.lastName() + " " + ent.suffix(); 1276 // + " " + ent.lastName() + " " + ent.suffix();
1276 //txtFullName->setText( tmpString->simplifyWhiteSpace() ); 1277 //txtFullName->setText( tmpString->simplifyWhiteSpace() );
1277 1278
1278 if ( !ent.isEmpty() ){ 1279 if ( !ent.isEmpty() ){
1279 // Lastnames with multiple words need to be protected by a comma ! 1280 // Lastnames with multiple words need to be protected by a comma !
1280 if ( ent.lastName().contains( ' ', TRUE ) ) 1281 if ( ent.lastName().contains( ' ', TRUE ) )
1281 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); 1282 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
1282 else 1283 else
1283 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); 1284 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
1284 } 1285 }
1285 1286
1286 cmbFileAs->setEditText( ent.fileAs() ); 1287 cmbFileAs->setEditText( ent.fileAs() );
1287 1288
1288 //if (hasTitle) 1289 //if (hasTitle)
1289 txtJobTitle->setText( ent.jobTitle() ); 1290 txtJobTitle->setText( ent.jobTitle() );
1290 1291
1291 //if (hasCompany) 1292 //if (hasCompany)
1292 txtOrganization->setText( ent.company() ); 1293 txtOrganization->setText( ent.company() );
1293 1294
1294 //if (hasNotes) 1295 //if (hasNotes)
1295 txtNote->setText( ent.notes() ); 1296 txtNote->setText( ent.notes() );
1296 1297
1297 //if (hasStreet) { 1298 //if (hasStreet) {
1298 slHomeAddress[0] = ent.homeStreet(); 1299 slHomeAddress[0] = ent.homeStreet();
1299 slBusinessAddress[0] = ent.businessStreet(); 1300 slBusinessAddress[0] = ent.businessStreet();
1300 //} 1301 //}
1301 1302
1302 //if (hasCity) { 1303 //if (hasCity) {
1303 slHomeAddress[3] = ent.homeCity(); 1304 slHomeAddress[3] = ent.homeCity();
1304 slBusinessAddress[3] = ent.businessCity(); 1305 slBusinessAddress[3] = ent.businessCity();
1305 //} 1306 //}
1306 1307
1307 //if (hasState) { 1308 //if (hasState) {
1308 slHomeAddress[4] = ent.homeState(); 1309 slHomeAddress[4] = ent.homeState();
1309 slBusinessAddress[4] = ent.businessState(); 1310 slBusinessAddress[4] = ent.businessState();
1310 //} 1311 //}
1311 1312
1312 //if (hasZip) { 1313 //if (hasZip) {
1313 slHomeAddress[5] = ent.homeZip(); 1314 slHomeAddress[5] = ent.homeZip();
1314 slBusinessAddress[5] = ent.businessZip(); 1315 slBusinessAddress[5] = ent.businessZip();
1315 //} 1316 //}
1316 1317
1317 //if (hasCountry) { 1318 //if (hasCountry) {
1318 slHomeAddress[6] = ent.homeCountry(); 1319 slHomeAddress[6] = ent.homeCountry();
1319 slBusinessAddress[6] = ent.businessCountry(); 1320 slBusinessAddress[6] = ent.businessCountry();
1320 //} 1321 //}
1321 1322
1322 QStringList::ConstIterator it; 1323 QStringList::ConstIterator it;
1323 QListIterator<QLineEdit> itLE( listValue ); 1324 QListIterator<QLineEdit> itLE( listValue );
1324 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { 1325 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
1325 1326
1326 qWarning(" Filling dynamic Field: %s", (*it).latin1() ); 1327 qWarning(" Filling dynamic Field: %s", (*it).latin1() );
1327 1328
1328 if ( *it == "Department" ) 1329 if ( *it == "Department" )
1329 (*itLE)->setText( ent.department() ); 1330 (*itLE)->setText( ent.department() );
1330 1331
1331 if ( *it == "Company" ) 1332 if ( *it == "Company" )
1332 (*itLE)->setText( ent.company() ); 1333 (*itLE)->setText( ent.company() );
1333 1334
1334 if ( *it == "Office" ) 1335 if ( *it == "Office" )
1335 (*itLE)->setText( ent.office() ); 1336 (*itLE)->setText( ent.office() );
1336 1337
1337 if ( *it == "Profession" ) 1338 if ( *it == "Profession" )
1338 (*itLE)->setText( ent.profession() ); 1339 (*itLE)->setText( ent.profession() );
1339 1340
1340 if ( *it == "Assistant" ) 1341 if ( *it == "Assistant" )
1341 (*itLE)->setText( ent.assistant() ); 1342 (*itLE)->setText( ent.assistant() );
1342 1343
1343 if ( *it == "Manager" ) 1344 if ( *it == "Manager" )
1344 (*itLE)->setText( ent.manager() ); 1345 (*itLE)->setText( ent.manager() );
1345 1346
1346 if ( *it == "Spouse" ) 1347 if ( *it == "Spouse" )
1347 (*itLE)->setText( ent.spouse() ); 1348 (*itLE)->setText( ent.spouse() );
1348 1349
1349 if ( *it == "Nickname" ){ 1350 if ( *it == "Nickname" ){
1350 qWarning("**** Nichname: %s", ent.nickname().latin1() ); 1351 qWarning("**** Nichname: %s", ent.nickname().latin1() );
1351 (*itLE)->setText( ent.nickname() ); 1352 (*itLE)->setText( ent.nickname() );
1352 } 1353 }
1353 1354
1354 if ( *it == "Children" ) 1355 if ( *it == "Children" )
1355 (*itLE)->setText( ent.children() ); 1356 (*itLE)->setText( ent.children() );
1356 1357
1357 } 1358 }
1358 1359
1359 QStringList::Iterator itV; 1360 QStringList::Iterator itV;
1360 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1361 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1361 1362
1362 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) 1363 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) )
1363 *itV = ent.businessPhone(); 1364 *itV = ent.businessPhone();
1364 /* 1365 /*
1365 if ( *it == "Business 2 Phone" ) 1366 if ( *it == "Business 2 Phone" )
1366 *itV = ent.business2Phone(); 1367 *itV = ent.business2Phone();
1367 */ 1368 */
1368 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) 1369 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) )
1369 *itV = ent.businessFax(); 1370 *itV = ent.businessFax();
1370 1371
1371 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) 1372 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) )
1372 *itV = ent.businessMobile(); 1373 *itV = ent.businessMobile();
1373 /* 1374 /*
1374 if ( *it == "Company Phone" ) 1375 if ( *it == "Company Phone" )
1375 *itV = ent.companyPhone(); 1376 *itV = ent.companyPhone();
1376 */ 1377 */
1377 if ( *it == "Default Email" ) 1378 if ( *it == "Default Email" )
1378 *itV = ent.defaultEmail(); 1379 *itV = ent.defaultEmail();
1379 1380
1380 if ( *it == "Emails" ) 1381 if ( *it == "Emails" )
1381 *itV = ent.emailList().join(", "); // :SX 1382 *itV = ent.emailList().join(", "); // :SX
1382 1383
1383 if ( *it == "Home Phone" ) 1384 if ( *it == "Home Phone" )
1384 *itV = ent.homePhone(); 1385 *itV = ent.homePhone();
1385 /* 1386 /*
1386 if ( *it == "Home 2 Phone" ) 1387 if ( *it == "Home 2 Phone" )
1387 *itV = ent.home2Phone(); 1388 *itV = ent.home2Phone();
1388 */ 1389 */
1389 if ( *it == "Home Fax" ) 1390 if ( *it == "Home Fax" )
1390 *itV = ent.homeFax(); 1391 *itV = ent.homeFax();
1391 1392
1392 if ( *it == "Home Mobile" ) 1393 if ( *it == "Home Mobile" )
1393 *itV = ent.homeMobile(); 1394 *itV = ent.homeMobile();
1394 /* 1395 /*
1395 if ( *it == "Car Phone" ) 1396 if ( *it == "Car Phone" )
1396 *itV = ent.carPhone(); 1397 *itV = ent.carPhone();
1397 1398
1398 if ( *it == "ISDN Phone" ) 1399 if ( *it == "ISDN Phone" )
1399 *itV = ent.ISDNPhone(); 1400 *itV = ent.ISDNPhone();
1400 1401
1401 if ( *it == "Other Phone" ) 1402 if ( *it == "Other Phone" )
1402 *itV = ent.otherPhone(); 1403 *itV = ent.otherPhone();
1403 */ 1404 */
1404 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1405 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1405 *itV = ent.businessPager(); 1406 *itV = ent.businessPager();
1406 /* 1407 /*
1407 if ( *it == "Home Pager") 1408 if ( *it == "Home Pager")
1408 *itV = ent.homePager(); 1409 *itV = ent.homePager();
1409 1410
1410 if ( *it == "AIM IM" ) 1411 if ( *it == "AIM IM" )
1411 *itV = ent.AIMIM(); 1412 *itV = ent.AIMIM();
1412 1413
1413 if ( *it == "ICQ IM" ) 1414 if ( *it == "ICQ IM" )
1414 *itV = ent.ICQIM(); 1415 *itV = ent.ICQIM();
1415 1416
1416 if ( *it == "Jabber IM" ) 1417 if ( *it == "Jabber IM" )
1417 *itV = ent.jabberIM(); 1418 *itV = ent.jabberIM();
1418 1419
1419 if ( *it == "MSN IM" ) 1420 if ( *it == "MSN IM" )
1420 *itV = ent.MSNIM(); 1421 *itV = ent.MSNIM();
1421 1422
1422 if ( *it == "Yahoo IM" ) 1423 if ( *it == "Yahoo IM" )
1423 *itV = ent.yahooIM(); 1424 *itV = ent.yahooIM();
1424 */ 1425 */
1425 if ( *it == "Home Web Page" ) 1426 if ( *it == "Home Web Page" )
1426 *itV = ent.homeWebpage(); 1427 *itV = ent.homeWebpage();
1427 1428
1428 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1429 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1429 *itV = ent.businessWebpage(); 1430 *itV = ent.businessWebpage();
1430 1431
1431 1432
1432 } 1433 }
1433 1434
1434 1435
1435 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); 1436 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
1436 1437
1437 QString gender = ent.gender(); 1438 QString gender = ent.gender();
1438 cmbGender->setCurrentItem( gender.toInt() ); 1439 cmbGender->setCurrentItem( gender.toInt() );
1439 1440
1440 txtNote->setText( ent.notes() ); 1441 txtNote->setText( ent.notes() );
1441 1442
1442 slotAddressTypeChange( cmbAddress->currentItem() ); 1443 slotAddressTypeChange( cmbAddress->currentItem() );
1443 1444
1444 // Get combo-settings from contact and set preset.. 1445 // Get combo-settings from contact and set preset..
1445 contactfields.loadFromRecord( ent ); 1446 contactfields.loadFromRecord( ent );
1446 cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) ); 1447 cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) );
1447 cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) ); 1448 cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) );
1448 cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) ); 1449 cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) );
1449 cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) ); 1450 cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) );
1450 cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) ); 1451 cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) );
1451 slotCmbChooser1Change( cmbChooserField1->currentItem() ); 1452 slotCmbChooser1Change( cmbChooserField1->currentItem() );
1452 slotCmbChooser2Change( cmbChooserField2->currentItem() ); 1453 slotCmbChooser2Change( cmbChooserField2->currentItem() );
1453 slotCmbChooser3Change( cmbChooserField3->currentItem() ); 1454 slotCmbChooser3Change( cmbChooserField3->currentItem() );
1454 slotCmbChooser4Change( cmbChooserField4->currentItem() ); 1455 slotCmbChooser4Change( cmbChooserField4->currentItem() );
1455 slotAddressTypeChange( cmbAddress->currentItem() ); 1456 slotAddressTypeChange( cmbAddress->currentItem() );
1456 1457
1457 updateDatePicker(); 1458 updateDatePicker();
1458 1459
1459 initializing = false; 1460 initializing = false;
1460} 1461}
1461void ContactEditor::updateDatePicker() 1462void ContactEditor::updateDatePicker()
1462{ 1463{
1463 // Set DatePicker 1464 // Set DatePicker
1464 if ( !ent.birthday().isNull() ){ 1465 if ( !ent.birthday().isNull() ){
1465 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); 1466 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) );
1466 birthdayPicker->setDate( ent.birthday() ); 1467 birthdayPicker->setDate( ent.birthday() );
1467 } else 1468 } else
1468 birthdayButton->setText( tr ("Unknown") ); 1469 birthdayButton->setText( tr ("Unknown") );
1469 1470
1470 if ( !ent.anniversary().isNull() ){ 1471 if ( !ent.anniversary().isNull() ){
1471 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); 1472 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) );
1472 anniversaryPicker->setDate( ent.anniversary() ); 1473 anniversaryPicker->setDate( ent.anniversary() );
1473 } else 1474 } else
1474 anniversaryButton->setText( tr ("Unknown") ); 1475 anniversaryButton->setText( tr ("Unknown") );
1475 1476
1476} 1477}
1477 1478
1478void ContactEditor::saveEntry() { 1479void ContactEditor::saveEntry() {
1479 1480
1480 // Store current combo into contact 1481 // Store current combo into contact
1481 contactfields.saveToRecord( ent ); 1482 contactfields.saveToRecord( ent );
1482 1483
1483 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); 1484 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) );
1484 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); 1485 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) );
1485 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); 1486 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) );
1486 // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); 1487 // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) );
1487 1488
1488 ent.setFirstName( txtFirstName->text() ); 1489 ent.setFirstName( txtFirstName->text() );
1489 ent.setLastName( txtLastName->text() ); 1490 ent.setLastName( txtLastName->text() );
1490 ent.setMiddleName( txtMiddleName->text() ); 1491 ent.setMiddleName( txtMiddleName->text() );
1491 ent.setSuffix( txtSuffix->text() ); 1492 ent.setSuffix( txtSuffix->text() );
1492 1493
1493 ent.setFileAs( cmbFileAs->currentText() ); 1494 ent.setFileAs( cmbFileAs->currentText() );
1494 1495
1495 ent.setCategories( cmbCat->currentCategories() ); 1496 ent.setCategories( cmbCat->currentCategories() );
1496 1497
1497 1498
1498 //if (hasTitle) 1499 //if (hasTitle)
1499 ent.setJobTitle( txtJobTitle->text() ); 1500 ent.setJobTitle( txtJobTitle->text() );
1500 1501
1501 //if (hasCompany) 1502 //if (hasCompany)
1502 ent.setCompany( txtOrganization->text() ); 1503 ent.setCompany( txtOrganization->text() );
1503 1504
1504 //if (hasNotes) 1505 //if (hasNotes)
1505 ent.setNotes( txtNote->text() ); 1506 ent.setNotes( txtNote->text() );
1506 1507
1507 //if (hasStreet) { 1508 //if (hasStreet) {
1508 ent.setHomeStreet( slHomeAddress[0] ); 1509 ent.setHomeStreet( slHomeAddress[0] );
1509 ent.setBusinessStreet( slBusinessAddress[0] ); 1510 ent.setBusinessStreet( slBusinessAddress[0] );
1510 //} 1511 //}
1511 1512
1512 //if (hasCity) { 1513 //if (hasCity) {
1513 ent.setHomeCity( slHomeAddress[3] ); 1514 ent.setHomeCity( slHomeAddress[3] );
1514 ent.setBusinessCity( slBusinessAddress[3] ); 1515 ent.setBusinessCity( slBusinessAddress[3] );
1515 //} 1516 //}
1516 1517
1517 //if (hasState) { 1518 //if (hasState) {
1518 ent.setHomeState( slHomeAddress[4] ); 1519 ent.setHomeState( slHomeAddress[4] );
1519 ent.setBusinessState( slBusinessAddress[4] ); 1520 ent.setBusinessState( slBusinessAddress[4] );
1520 //} 1521 //}
1521 1522
1522 //if (hasZip) { 1523 //if (hasZip) {
1523 ent.setHomeZip( slHomeAddress[5] ); 1524 ent.setHomeZip( slHomeAddress[5] );
1524 ent.setBusinessZip( slBusinessAddress[5] ); 1525 ent.setBusinessZip( slBusinessAddress[5] );
1525 //} 1526 //}
1526 1527
1527 //if (hasCountry) { 1528 //if (hasCountry) {
1528 ent.setHomeCountry( slHomeAddress[6] ); 1529 ent.setHomeCountry( slHomeAddress[6] );
1529 ent.setBusinessCountry( slBusinessAddress[6] ); 1530 ent.setBusinessCountry( slBusinessAddress[6] );
1530 //} 1531 //}
1531 1532
1532 QStringList::ConstIterator it; 1533 QStringList::ConstIterator it;
1533 QListIterator<QLineEdit> itLE( listValue ); 1534 QListIterator<QLineEdit> itLE( listValue );
1534 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) { 1535 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) {
1535 1536
1536 if ( *it == "Department" ) 1537 if ( *it == "Department" )
1537 ent.setDepartment( (*itLE)->text() ); 1538 ent.setDepartment( (*itLE)->text() );
1538 1539
1539 if ( *it == "Company" ) 1540 if ( *it == "Company" )
1540 ent.setCompany( (*itLE)->text() ); 1541 ent.setCompany( (*itLE)->text() );
1541 1542
1542 if ( *it == "Office" ) 1543 if ( *it == "Office" )
1543 ent.setOffice( (*itLE)->text() ); 1544 ent.setOffice( (*itLE)->text() );
1544 1545
1545 if ( *it == "Profession" ) 1546 if ( *it == "Profession" )
1546 ent.setProfession( (*itLE)->text() ); 1547 ent.setProfession( (*itLE)->text() );
1547 1548
1548 if ( *it == "Assistant" ) 1549 if ( *it == "Assistant" )
1549 ent.setAssistant( (*itLE)->text() ); 1550 ent.setAssistant( (*itLE)->text() );
1550 1551
1551 if ( *it == "Manager" ) 1552 if ( *it == "Manager" )
1552 ent.setManager( (*itLE)->text() ); 1553 ent.setManager( (*itLE)->text() );
1553 1554
1554 if ( *it == "Spouse" ) 1555 if ( *it == "Spouse" )
1555 ent.setSpouse( (*itLE)->text() ); 1556 ent.setSpouse( (*itLE)->text() );
1556 1557
1557 if ( *it == "Nickname" ) 1558 if ( *it == "Nickname" )
1558 ent.setNickname( (*itLE)->text() ); 1559 ent.setNickname( (*itLE)->text() );
1559 1560
1560 if ( *it == "Children" ) 1561 if ( *it == "Children" )
1561 ent.setChildren( (*itLE)->text() ); 1562 ent.setChildren( (*itLE)->text() );
1562 1563
1563 } 1564 }
1564 1565
1565 1566
1566 QStringList::ConstIterator itV; 1567 QStringList::ConstIterator itV;
1567 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1568 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1568 1569
1569 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) 1570 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) )
1570 ent.setBusinessPhone( *itV ); 1571 ent.setBusinessPhone( *itV );
1571 1572
1572 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) 1573 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
1573 ent.setBusinessFax( *itV ); 1574 ent.setBusinessFax( *itV );
1574 1575
1575 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) 1576 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
1576 ent.setBusinessMobile( *itV ); 1577 ent.setBusinessMobile( *itV );
1577 1578
1578 if ( *it == "Emails" ){ 1579 if ( *it == "Emails" ){
1579 QString allemail; 1580 QString allemail;
1580 QString defaultmail; 1581 QString defaultmail;
1581 parseEmailFrom( emails.join(","), defaultmail, allemail ); 1582 parseEmailFrom( emails.join(","), defaultmail, allemail );
1582 if ( defaultEmail.isEmpty() ){ 1583 if ( defaultEmail.isEmpty() ){
1583 qWarning("Default email was not set by user!"); 1584 qWarning("Default email was not set by user!");
1584 qWarning("Using first email in list: %s", defaultmail.latin1()); 1585 qWarning("Using first email in list: %s", defaultmail.latin1());
1585 ent.setDefaultEmail( defaultmail ); 1586 ent.setDefaultEmail( defaultmail );
1586 } 1587 }
1587 ent.setEmails( allemail ); 1588 ent.setEmails( allemail );
1588 } 1589 }
1589 1590
1590 if ( *it == "Default Email") 1591 if ( *it == "Default Email")
1591 ent.setDefaultEmail( defaultEmail /* *itV */ ); 1592 ent.setDefaultEmail( defaultEmail /* *itV */ );
1592 1593
1593 if ( *it == "Home Phone" ) 1594 if ( *it == "Home Phone" )
1594 ent.setHomePhone( *itV ); 1595 ent.setHomePhone( *itV );
1595 1596
1596 if ( *it == "Home Fax" ) 1597 if ( *it == "Home Fax" )
1597 ent.setHomeFax( *itV ); 1598 ent.setHomeFax( *itV );
1598 1599
1599 if ( *it == "Home Mobile" ) 1600 if ( *it == "Home Mobile" )
1600 ent.setHomeMobile( *itV ); 1601 ent.setHomeMobile( *itV );
1601 1602
1602 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1603 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1603 ent.setBusinessPager( *itV ); 1604 ent.setBusinessPager( *itV );
1604 1605
1605 if ( *it == "Home Web Page" ) 1606 if ( *it == "Home Web Page" )
1606 ent.setHomeWebpage( *itV ); 1607 ent.setHomeWebpage( *itV );
1607 1608
1608 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1609 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1609 ent.setBusinessWebpage( *itV ); 1610 ent.setBusinessWebpage( *itV );
1610 1611
1611 1612
1612 } 1613 }
1613 1614
1614 int gender = cmbGender->currentItem(); 1615 int gender = cmbGender->currentItem();
1615 ent.setGender( QString::number( gender ) ); 1616 ent.setGender( QString::number( gender ) );
1616 1617
1617 QString str = txtNote->text(); 1618 QString str = txtNote->text();
1618 if ( !str.isNull() ) 1619 if ( !str.isNull() )
1619 ent.setNotes( str ); 1620 ent.setNotes( str );
1620 1621
1621} 1622}
1622 1623
1623void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 1624void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
1624 QString &strAll ) 1625 QString &strAll )
1625{ 1626{
1626 int where, 1627 int where,
@@ -1695,24 +1696,24 @@ static inline bool constainsWhiteSpace( const QString &str )
1695 return FALSE; 1696 return FALSE;
1696} 1697}
1697 1698
1698void ContactEditor::setPersonalView( bool personal ) 1699void ContactEditor::setPersonalView( bool personal )
1699{ 1700{
1700 m_personalView = personal; 1701 m_personalView = personal;
1701 1702
1702 // Currently disbled due to the fact that 1703 // Currently disbled due to the fact that
1703 // show will not work... 1704 // show will not work...
1704 return; 1705 return;
1705 1706
1706 if ( personal ){ 1707 if ( personal ){
1707 cmbCat->hide(); 1708 cmbCat->hide();
1708 labCat->hide(); 1709 labCat->hide();
1709 1710
1710 } else{ 1711 } else{
1711 cmbCat->show(); 1712 cmbCat->show();
1712 labCat->show(); 1713 labCat->show();
1713 } 1714 }
1714} 1715}
1715 1716
1716void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) 1717void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
1717{ 1718{
1718 QDate date; 1719 QDate date;