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.cpp61
1 files changed, 39 insertions, 22 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 5a7bf1a..7338eeb 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -35,50 +35,50 @@
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
50static inline bool containsAlphaNum( const QString &str ); 50static inline bool containsAlphaNum( const QString &str );
51static inline bool constainsWhiteSpace( const QString &str ); 51static 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...
55void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 55void 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...
59void 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 init(); 70 init();
71 setEntry( entry ); 71 setEntry( entry );
72} 72}
73 73
74ContactEditor::~ContactEditor() { 74ContactEditor::~ContactEditor() {
75} 75}
76 76
77void ContactEditor::init() { 77void ContactEditor::init() {
78 78
79 useFullName = true; 79 useFullName = true;
80 80
81 uint i = 0; 81 uint i = 0;
82 82
83 QStringList trlChooserNames; 83 QStringList trlChooserNames;
84 84
@@ -600,78 +600,92 @@ void ContactEditor::init() {
600 connect( txtState, SIGNAL(textChanged(const QString &)), 600 connect( txtState, SIGNAL(textChanged(const QString &)),
601 this, SLOT(slotStateChange(const QString &)) ); 601 this, SLOT(slotStateChange(const QString &)) );
602 connect( txtZip, SIGNAL(textChanged(const QString &)), 602 connect( txtZip, SIGNAL(textChanged(const QString &)),
603 this, SLOT(slotZipChange(const QString &)) ); 603 this, SLOT(slotZipChange(const QString &)) );
604 connect( cmbCountry, SIGNAL(textChanged(const QString &)), 604 connect( cmbCountry, SIGNAL(textChanged(const QString &)),
605 this, SLOT(slotCountryChange(const QString &)) ); 605 this, SLOT(slotCountryChange(const QString &)) );
606 connect( cmbCountry, SIGNAL(activated(const QString &)), 606 connect( cmbCountry, SIGNAL(activated(const QString &)),
607 this, SLOT(slotCountryChange(const QString &)) ); 607 this, SLOT(slotCountryChange(const QString &)) );
608 connect( cmbChooserField1, SIGNAL(activated(int)), 608 connect( cmbChooserField1, SIGNAL(activated(int)),
609 this, SLOT(slotCmbChooser1Change(int)) ); 609 this, SLOT(slotCmbChooser1Change(int)) );
610 connect( cmbChooserField2, SIGNAL(activated(int)), 610 connect( cmbChooserField2, SIGNAL(activated(int)),
611 this, SLOT(slotCmbChooser2Change(int)) ); 611 this, SLOT(slotCmbChooser2Change(int)) );
612 connect( cmbChooserField3, SIGNAL(activated(int)), 612 connect( cmbChooserField3, SIGNAL(activated(int)),
613 this, SLOT(slotCmbChooser3Change(int)) ); 613 this, SLOT(slotCmbChooser3Change(int)) );
614 connect( cmbChooserField4, SIGNAL(activated(int)), 614 connect( cmbChooserField4, SIGNAL(activated(int)),
615 this, SLOT(slotCmbChooser4Change(int)) ); 615 this, SLOT(slotCmbChooser4Change(int)) );
616 connect( cmbAddress, SIGNAL(activated(int)), 616 connect( cmbAddress, SIGNAL(activated(int)),
617 this, SLOT(slotAddressTypeChange(int)) ); 617 this, SLOT(slotAddressTypeChange(int)) );
618 618
619 new QPEDialogListener(this); 619 new QPEDialogListener(this);
620 620
621 setPersonalView ( m_personalView ); 621 setPersonalView ( m_personalView );
622} 622}
623 623
624void ContactEditor::slotChooser1Change( const QString &textChanged ) { 624void ContactEditor::defaultEmailChanged(int i){
625 625 qDebug("defaultEmailChanged");
626 int index = cmbChooserField1->currentItem(); 626 int index = cmbChooserField1->currentItem();
627 627 slChooserValues[index] = cmbDefaultEmail->text(i);
628 slChooserValues[index] = textChanged;
629 628
630} 629}
631 630
632void ContactEditor::slotChooser2Change( const QString &textChanged ) { 631void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid ) {
632
633 if (slChooserNames[index] == "Default Email"){
634 delete cmbDefaultEmail;
635 cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
636 cmbDefaultEmail->setGeometry(inputWid->frameGeometry());
637 cmbDefaultEmail->insertStringList(ent.emailList());
638 connect(cmbDefaultEmail,SIGNAL(activated(int)),
639 SLOT(defaultEmailChanged(int)));
640 QString demail = ent.defaultEmail();
641 for ( int i = 0; i < cmbDefaultEmail->count(); i++)
642 if ( cmbDefaultEmail->text( i ) == demail )
643 cmbDefaultEmail->setCurrentItem( i );
644
645 cmbDefaultEmail->show();
646 }
633 647
634 int index = cmbChooserField2->currentItem();
635 648
636 slChooserValues[index] = textChanged; 649 slChooserValues[index] = textChanged;
637 650
638} 651}
639 652
640void ContactEditor::slotChooser3Change( const QString &textChanged ) { 653void ContactEditor::slotChooser1Change( const QString &textChanged ) {
654 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1);
655}
641 656
642 int index = cmbChooserField3->currentItem(); 657void ContactEditor::slotChooser2Change( const QString &textChanged ) {
658 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2);
643 659
644 slChooserValues[index] = textChanged; 660}
645 661
662void ContactEditor::slotChooser3Change( const QString &textChanged ) {
663 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3);
646} 664}
647 665
648void ContactEditor::slotChooser4Change( const QString &textChanged ) { 666void ContactEditor::slotChooser4Change( const QString &textChanged ) {
649 667 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4);
650 int index = cmbChooserField4->currentItem();
651
652 slChooserValues[index] = textChanged;
653
654} 668}
655 669
656void ContactEditor::slotAddressChange( const QString &textChanged ) { 670void ContactEditor::slotAddressChange( const QString &textChanged ) {
657 671
658 if ( cmbAddress->currentItem() == 0 ) { 672 if ( cmbAddress->currentItem() == 0 ) {
659 slBusinessAddress[0] = textChanged; 673 slBusinessAddress[0] = textChanged;
660 } else { 674 } else {
661 slHomeAddress[0] = textChanged; 675 slHomeAddress[0] = textChanged;
662 } 676 }
663} 677}
664 678
665void ContactEditor::slotAddress2Change( const QString &textChanged ) { 679void ContactEditor::slotAddress2Change( const QString &textChanged ) {
666 680
667 if ( cmbAddress->currentItem() == 0 ) { 681 if ( cmbAddress->currentItem() == 0 ) {
668 slBusinessAddress[1] = textChanged; 682 slBusinessAddress[1] = textChanged;
669 } else { 683 } else {
670 slHomeAddress[1] = textChanged; 684 slHomeAddress[1] = textChanged;
671 } 685 }
672} 686}
673 687
674void ContactEditor::slotPOBoxChange( const QString &textChanged ) { 688void ContactEditor::slotPOBoxChange( const QString &textChanged ) {
675 689
676 if ( cmbAddress->currentItem() == 0 ) { 690 if ( cmbAddress->currentItem() == 0 ) {
677 slBusinessAddress[2] = textChanged; 691 slBusinessAddress[2] = textChanged;
@@ -1350,56 +1364,59 @@ void ContactEditor::saveEntry() {
1350 ent.setSpouse( (*itLE)->text() ); 1364 ent.setSpouse( (*itLE)->text() );
1351 1365
1352 if ( *it == "Nickname" ) 1366 if ( *it == "Nickname" )
1353 ent.setNickname( (*itLE)->text() ); 1367 ent.setNickname( (*itLE)->text() );
1354 1368
1355 if ( *it == "Children" ) 1369 if ( *it == "Children" )
1356 ent.setChildren( (*itLE)->text() ); 1370 ent.setChildren( (*itLE)->text() );
1357 1371
1358 } 1372 }
1359 1373
1360 1374
1361 QStringList::ConstIterator itV; 1375 QStringList::ConstIterator itV;
1362 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1376 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1363 1377
1364 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) 1378 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) )
1365 ent.setBusinessPhone( *itV ); 1379 ent.setBusinessPhone( *itV );
1366 1380
1367 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) 1381 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
1368 ent.setBusinessFax( *itV ); 1382 ent.setBusinessFax( *itV );
1369 1383
1370 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) 1384 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
1371 ent.setBusinessMobile( *itV ); 1385 ent.setBusinessMobile( *itV );
1372 1386
1373 if ( *it == "Emails" ){ 1387 if ( *it == "Emails" ){
1374 QString allemail; 1388 QString allemail;
1375 QString defaultmail; 1389 QString defaultmail;
1376 parseEmailFrom( *itV, defaultmail, allemail ); 1390 parseEmailFrom( *itV, defaultmail, allemail );
1377 // ent.clearEmails(); 1391 // ent.clearEmails();
1378 ent.setDefaultEmail( defaultmail ); 1392 // ent.setDefaultEmail( defaultmail );
1379 ent.setEmails( allemail ); 1393 ent.setEmails( allemail );
1380 } 1394 }
1381 1395
1396 if ( *it == "Default Email")
1397 ent.setDefaultEmail( *itV );
1398
1382 if ( *it == "Home Phone" ) 1399 if ( *it == "Home Phone" )
1383 ent.setHomePhone( *itV ); 1400 ent.setHomePhone( *itV );
1384 1401
1385 if ( *it == "Home Fax" ) 1402 if ( *it == "Home Fax" )
1386 ent.setHomeFax( *itV ); 1403 ent.setHomeFax( *itV );
1387 1404
1388 if ( *it == "Home Mobile" ) 1405 if ( *it == "Home Mobile" )
1389 ent.setHomeMobile( *itV ); 1406 ent.setHomeMobile( *itV );
1390 1407
1391 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1408 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1392 ent.setBusinessPager( *itV ); 1409 ent.setBusinessPager( *itV );
1393 1410
1394 if ( *it == "Home Web Page" ) 1411 if ( *it == "Home Web Page" )
1395 ent.setHomeWebpage( *itV ); 1412 ent.setHomeWebpage( *itV );
1396 1413
1397 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1414 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1398 ent.setBusinessWebpage( *itV ); 1415 ent.setBusinessWebpage( *itV );
1399 1416
1400 1417
1401 } 1418 }
1402 1419
1403 int gender = cmbGender->currentItem(); 1420 int gender = cmbGender->currentItem();
1404 ent.setGender( QString::number( gender ) ); 1421 ent.setGender( QString::number( gender ) );
1405 1422