Diffstat (limited to 'core/pim/addressbook/contacteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 153 |
1 files changed, 123 insertions, 30 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index e7f2ebd..a59a927 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -21,24 +21,26 @@ | |||
21 | #include "contacteditor.h" | 21 | #include "contacteditor.h" |
22 | #include "addresspicker.h" | 22 | #include "addresspicker.h" |
23 | 23 | ||
24 | #include <qpe/categoryselect.h> | 24 | #include <qpe/categoryselect.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qpedialog.h> | 26 | #include <qpe/qpedialog.h> |
27 | #include <qpe/timeconversion.h> | ||
27 | 28 | ||
28 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
29 | #include <qlabel.h> | 30 | #include <qlabel.h> |
30 | #include <qtabwidget.h> | 31 | #include <qtabwidget.h> |
31 | #include <qlayout.h> | 32 | #include <qlayout.h> |
32 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
33 | #include <qmultilineedit.h> | 34 | #include <qmultilineedit.h> |
34 | #include <qscrollview.h> | 35 | #include <qscrollview.h> |
35 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
36 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
37 | #include <qmainwindow.h> | 38 | #include <qmainwindow.h> |
38 | #include <qvaluelist.h> | 39 | #include <qvaluelist.h> |
40 | #include <qpopupmenu.h> | ||
39 | 41 | ||
40 | static inline bool containsAlphaNum( const QString &str ); | 42 | static inline bool containsAlphaNum( const QString &str ); |
41 | static inline bool constainsWhiteSpace( const QString &str ); | 43 | static inline bool constainsWhiteSpace( const QString &str ); |
42 | 44 | ||
43 | // helper functions, convert our comma delimited list to proper | 45 | // helper functions, convert our comma delimited list to proper |
44 | // file format... | 46 | // file format... |
@@ -54,13 +56,14 @@ ContactEditor::ContactEditor( const OContact &entry, | |||
54 | QStringList *slNewOrdered, | 56 | QStringList *slNewOrdered, |
55 | QWidget *parent, | 57 | QWidget *parent, |
56 | const char *name, | 58 | const char *name, |
57 | WFlags fl ) | 59 | WFlags fl ) |
58 | : QDialog( parent, name, TRUE, fl ), | 60 | : QDialog( parent, name, TRUE, fl ), |
59 | orderedValues( newOrderedValues ), | 61 | orderedValues( newOrderedValues ), |
60 | slOrdered( *slNewOrdered ) | 62 | slOrdered( *slNewOrdered ), |
63 | m_personalView ( false ) | ||
61 | { | 64 | { |
62 | 65 | ||
63 | init(); | 66 | init(); |
64 | initMap(); | 67 | initMap(); |
65 | setEntry( entry ); | 68 | setEntry( entry ); |
66 | qDebug("finish"); | 69 | qDebug("finish"); |
@@ -203,13 +206,22 @@ void ContactEditor::init() { | |||
203 | slChooserNames.append( *it ); | 206 | slChooserNames.append( *it ); |
204 | slChooserValues.append( "" ); | 207 | slChooserValues.append( "" ); |
205 | //slDynamicEntries->remove( it ); | 208 | //slDynamicEntries->remove( it ); |
206 | continue; | 209 | continue; |
207 | } | 210 | } |
208 | 211 | ||
209 | if ( *it == "Name Title" || *it == "First Name" || *it == "Middle Name" || *it == "Last Name" || *it == "File As" || *it == "Default Email" || *it == "Emails" || *it == "Groups" ) | 212 | if ( *it == "Name Title" || |
213 | *it == "First Name" || | ||
214 | *it == "Middle Name" || | ||
215 | *it == "Last Name" || | ||
216 | *it == "File As" || | ||
217 | *it == "Default Email" || | ||
218 | *it == "Emails" || | ||
219 | *it == "Groups" || | ||
220 | *it == "Anniversary" || | ||
221 | *it == "Birthday" ) | ||
210 | continue; | 222 | continue; |
211 | 223 | ||
212 | if ( *it == "Name Title" ) { | 224 | if ( *it == "Name Title" ) { |
213 | //slDynamicEntries->remove( it ); | 225 | //slDynamicEntries->remove( it ); |
214 | continue; | 226 | continue; |
215 | } | 227 | } |
@@ -399,17 +411,27 @@ void ContactEditor::init() { | |||
399 | 411 | ||
400 | l = new QLabel( tr( "File As" ), container ); | 412 | l = new QLabel( tr( "File As" ), container ); |
401 | gl->addWidget( l, 6, 0 ); | 413 | gl->addWidget( l, 6, 0 ); |
402 | cmbFileAs = new QComboBox( TRUE, container ); | 414 | cmbFileAs = new QComboBox( TRUE, container ); |
403 | gl->addWidget( cmbFileAs, 6, 1 ); | 415 | gl->addWidget( cmbFileAs, 6, 1 ); |
404 | 416 | ||
405 | l = new QLabel( tr( "Category" ), container ); | 417 | labCat = new QLabel( tr( "Category" ), container ); |
406 | gl->addWidget( l, 7, 0 ); | 418 | gl->addWidget( labCat, 7, 0 ); |
407 | cmbCat = new CategorySelect( container ); | 419 | cmbCat = new CategorySelect( container ); |
408 | gl->addWidget( cmbCat, 7, 1 ); | 420 | gl->addWidget( cmbCat, 7, 1 ); |
409 | 421 | ||
422 | // We don't need categories for the personal view | ||
423 | if ( m_personalView ){ | ||
424 | qWarning("Disable Category.."); | ||
425 | labCat->hide(); | ||
426 | cmbCat->hide(); | ||
427 | } else { | ||
428 | labCat->show(); | ||
429 | cmbCat->show(); | ||
430 | } | ||
431 | |||
410 | btnNote = new QPushButton( tr( "Notes..." ), container ); | 432 | btnNote = new QPushButton( tr( "Notes..." ), container ); |
411 | gl->addWidget( btnNote, 8, 1 ); | 433 | gl->addWidget( btnNote, 8, 1 ); |
412 | 434 | ||
413 | tabMain->insertTab( tabViewport, tr( "General" ) ); | 435 | tabMain->insertTab( tabViewport, tr( "General" ) ); |
414 | 436 | ||
415 | tabViewport = new QWidget ( tabMain ); | 437 | tabViewport = new QWidget ( tabMain ); |
@@ -704,32 +726,72 @@ void ContactEditor::init() { | |||
704 | 726 | ||
705 | container = new QWidget( svDetails->viewport() ); | 727 | container = new QWidget( svDetails->viewport() ); |
706 | svDetails->addChild( container ); | 728 | svDetails->addChild( container ); |
707 | 729 | ||
708 | gl = new QGridLayout( container, 1, 2, 2, 4 ); | 730 | gl = new QGridLayout( container, 1, 2, 2, 4 ); |
709 | 731 | ||
732 | int counter = 0; | ||
733 | |||
734 | // Birthday | ||
735 | l = new QLabel( tr("Birthday"), container ); | ||
736 | gl->addWidget( l, counter, 0 ); | ||
737 | |||
738 | QPopupMenu* m1 = new QPopupMenu( container ); | ||
739 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); | ||
740 | m1->insertItem( birthdayPicker ); | ||
741 | |||
742 | birthdayButton= new QToolButton( container, "buttonStart" ); | ||
743 | birthdayButton->setPopup( m1 ); | ||
744 | birthdayButton->setPopupDelay(0); | ||
745 | gl->addWidget( birthdayButton, counter , 1 ); | ||
746 | connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), | ||
747 | this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); | ||
748 | |||
749 | ++counter; | ||
750 | |||
751 | // Anniversary | ||
752 | l = new QLabel( tr("Anniversary"), container ); | ||
753 | gl->addWidget( l, counter, 0 ); | ||
754 | |||
755 | m1 = new QPopupMenu( container ); | ||
756 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); | ||
757 | m1->insertItem( anniversaryPicker ); | ||
758 | |||
759 | anniversaryButton= new QToolButton( container, "buttonStart" ); | ||
760 | anniversaryButton->setPopup( m1 ); | ||
761 | anniversaryButton->setPopupDelay(0); | ||
762 | gl->addWidget( anniversaryButton, counter , 1 ); | ||
763 | connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), | ||
764 | this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); | ||
765 | |||
766 | ++counter; | ||
767 | |||
768 | // Gender | ||
769 | l = new QLabel( tr("Gender"), container ); | ||
770 | gl->addWidget( l, counter, 0 ); | ||
771 | cmbGender = new QComboBox( container ); | ||
772 | cmbGender->insertItem( "", 0 ); | ||
773 | cmbGender->insertItem( tr("Male"), 1); | ||
774 | cmbGender->insertItem( tr("Female"), 2); | ||
775 | gl->addWidget( cmbGender, counter, 1 ); | ||
776 | |||
777 | ++counter; | ||
778 | |||
710 | // Create Labels and lineedit fields for every dynamic entry | 779 | // Create Labels and lineedit fields for every dynamic entry |
711 | QStringList::ConstIterator it = slDynamicEntries.begin(); | 780 | QStringList::ConstIterator it = slDynamicEntries.begin(); |
712 | for (i = 0; it != slDynamicEntries.end(); i++, ++it) { | 781 | for (i = counter; it != slDynamicEntries.end(); i++, ++it) { |
713 | l = new QLabel( QString::null , container ); | 782 | l = new QLabel( QString::null , container ); |
714 | listName.append( l ); | 783 | listName.append( l ); |
715 | gl->addWidget( l, i, 0 ); | 784 | gl->addWidget( l, i, 0 ); |
716 | QLineEdit *e = new QLineEdit( container ); | 785 | QLineEdit *e = new QLineEdit( container ); |
717 | listValue.append( e ); | 786 | listValue.append( e ); |
718 | gl->addWidget( e, i, 1); | 787 | gl->addWidget( e, i, 1); |
719 | } | 788 | } |
720 | // Fill labels with names.. | 789 | // Fill labels with names.. |
721 | loadFields(); | 790 | loadFields(); |
722 | 791 | ||
723 | l = new QLabel( tr("Gender"), container ); | ||
724 | gl->addWidget( l, slDynamicEntries.count(), 0 ); | ||
725 | cmbGender = new QComboBox( container ); | ||
726 | cmbGender->insertItem( "", 0 ); | ||
727 | cmbGender->insertItem( tr("Male"), 1); | ||
728 | cmbGender->insertItem( tr("Female"), 2); | ||
729 | gl->addWidget( cmbGender, slDynamicEntries.count(), 1 ); | ||
730 | 792 | ||
731 | tabMain->insertTab( tabViewport, tr( "Details" ) ); | 793 | tabMain->insertTab( tabViewport, tr( "Details" ) ); |
732 | 794 | ||
733 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 795 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
734 | dlgNote->setCaption( tr("Enter Note") ); | 796 | dlgNote->setCaption( tr("Enter Note") ); |
735 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 797 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
@@ -1006,12 +1068,13 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) { | |||
1006 | cmbFileAs->setCurrentItem( index ); | 1068 | cmbFileAs->setCurrentItem( index ); |
1007 | 1069 | ||
1008 | useFullName = TRUE; | 1070 | useFullName = TRUE; |
1009 | 1071 | ||
1010 | } | 1072 | } |
1011 | 1073 | ||
1074 | // Loads the detail fields | ||
1012 | void ContactEditor::loadFields() { | 1075 | void ContactEditor::loadFields() { |
1013 | 1076 | ||
1014 | QStringList::ConstIterator it; | 1077 | QStringList::ConstIterator it; |
1015 | QListIterator<QLabel> lit( listName ); | 1078 | QListIterator<QLabel> lit( listName ); |
1016 | for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) { | 1079 | for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) { |
1017 | 1080 | ||
@@ -1033,24 +1096,33 @@ void ContactEditor::loadFields() { | |||
1033 | if ( *it == "Manager" ) | 1096 | if ( *it == "Manager" ) |
1034 | (*lit)->setText( tr( "Manager" ) ); | 1097 | (*lit)->setText( tr( "Manager" ) ); |
1035 | 1098 | ||
1036 | if ( *it == "Spouse" ) | 1099 | if ( *it == "Spouse" ) |
1037 | (*lit)->setText( tr( "Spouse" ) ); | 1100 | (*lit)->setText( tr( "Spouse" ) ); |
1038 | 1101 | ||
1039 | if ( *it == "Birthday" ) | ||
1040 | (*lit)->setText( tr( "Birthday" ) ); | ||
1041 | |||
1042 | if ( *it == "Anniversary" ) | ||
1043 | (*lit)->setText( tr( "Anniversary" ) ); | ||
1044 | |||
1045 | if ( *it == "Nickname" ) | 1102 | if ( *it == "Nickname" ) |
1046 | (*lit)->setText( tr( "Nickname" ) ); | 1103 | (*lit)->setText( tr( "Nickname" ) ); |
1047 | 1104 | ||
1048 | if ( *it == "Children" ) | 1105 | if ( *it == "Children" ) |
1049 | (*lit)->setText( tr( "Children" ) ); | 1106 | (*lit)->setText( tr( "Children" ) ); |
1050 | } | 1107 | } |
1108 | // Set DatePicker | ||
1109 | qWarning ("**Info: %s", ent.birthday().latin1() ); | ||
1110 | if ( !ent.birthday().isEmpty() ){ | ||
1111 | birthdayButton->setText( ent.birthday() ); | ||
1112 | birthdayPicker->setDate( TimeConversion::fromString ( ent.birthday() ) ); | ||
1113 | } else | ||
1114 | birthdayButton->setText( tr ("Unknown") ); | ||
1115 | |||
1116 | qWarning ("**Info: %s", ent.anniversary().latin1() ); | ||
1117 | if ( !ent.anniversary().isEmpty() ){ | ||
1118 | anniversaryButton->setText( ent.anniversary() ); | ||
1119 | anniversaryPicker->setDate( TimeConversion::fromString ( ent.birthday() ) ); | ||
1120 | } else | ||
1121 | anniversaryButton->setText( tr ("Unknown") ); | ||
1122 | |||
1051 | } | 1123 | } |
1052 | 1124 | ||
1053 | void ContactEditor::accept() { | 1125 | void ContactEditor::accept() { |
1054 | 1126 | ||
1055 | if ( isEmpty() ) { | 1127 | if ( isEmpty() ) { |
1056 | cleanupFields(); | 1128 | cleanupFields(); |
@@ -1426,18 +1498,12 @@ void ContactEditor::setEntry( const OContact &entry ) { | |||
1426 | if ( *it == "Manager" ) | 1498 | if ( *it == "Manager" ) |
1427 | (*itLE)->setText( ent.manager() ); | 1499 | (*itLE)->setText( ent.manager() ); |
1428 | 1500 | ||
1429 | if ( *it == "Spouse" ) | 1501 | if ( *it == "Spouse" ) |
1430 | (*itLE)->setText( ent.spouse() ); | 1502 | (*itLE)->setText( ent.spouse() ); |
1431 | 1503 | ||
1432 | if ( *it == "Birthday" ) | ||
1433 | (*itLE)->setText( ent.birthday() ); | ||
1434 | |||
1435 | if ( *it == "Anniversary" ) | ||
1436 | (*itLE)->setText( ent.anniversary() ); | ||
1437 | |||
1438 | if ( *it == "Nickname" ) | 1504 | if ( *it == "Nickname" ) |
1439 | (*itLE)->setText( ent.nickname() ); | 1505 | (*itLE)->setText( ent.nickname() ); |
1440 | 1506 | ||
1441 | if ( *it == "Children" ) | 1507 | if ( *it == "Children" ) |
1442 | (*itLE)->setText( ent.children() ); | 1508 | (*itLE)->setText( ent.children() ); |
1443 | 1509 | ||
@@ -1515,12 +1581,13 @@ void ContactEditor::setEntry( const OContact &entry ) { | |||
1515 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) | 1581 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) |
1516 | *itV = ent.businessWebpage(); | 1582 | *itV = ent.businessWebpage(); |
1517 | 1583 | ||
1518 | 1584 | ||
1519 | } | 1585 | } |
1520 | 1586 | ||
1587 | |||
1521 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); | 1588 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); |
1522 | 1589 | ||
1523 | QString gender = ent.gender(); | 1590 | QString gender = ent.gender(); |
1524 | cmbGender->setCurrentItem( gender.toInt() ); | 1591 | cmbGender->setCurrentItem( gender.toInt() ); |
1525 | 1592 | ||
1526 | txtNote->setText( ent.notes() ); | 1593 | txtNote->setText( ent.notes() ); |
@@ -1528,12 +1595,14 @@ void ContactEditor::setEntry( const OContact &entry ) { | |||
1528 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); | 1595 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); |
1529 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); | 1596 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); |
1530 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); | 1597 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); |
1531 | 1598 | ||
1532 | slotAddressTypeChange( cmbAddress->currentItem() ); | 1599 | slotAddressTypeChange( cmbAddress->currentItem() ); |
1533 | 1600 | ||
1601 | loadFields(); | ||
1602 | |||
1534 | } | 1603 | } |
1535 | 1604 | ||
1536 | void ContactEditor::saveEntry() { | 1605 | void ContactEditor::saveEntry() { |
1537 | 1606 | ||
1538 | if ( useFullName == TRUE ) { | 1607 | if ( useFullName == TRUE ) { |
1539 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); | 1608 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); |
@@ -1624,18 +1693,12 @@ void ContactEditor::saveEntry() { | |||
1624 | if ( *it == "Manager" ) | 1693 | if ( *it == "Manager" ) |
1625 | ent.setManager( (*itLE)->text() ); | 1694 | ent.setManager( (*itLE)->text() ); |
1626 | 1695 | ||
1627 | if ( *it == "Spouse" ) | 1696 | if ( *it == "Spouse" ) |
1628 | ent.setSpouse( (*itLE)->text() ); | 1697 | ent.setSpouse( (*itLE)->text() ); |
1629 | 1698 | ||
1630 | if ( *it == "Birthday" ) | ||
1631 | ent.setBirthday( (*itLE)->text() ); | ||
1632 | |||
1633 | if ( *it == "Anniversary" ) | ||
1634 | ent.setAnniversary( (*itLE)->text() ); | ||
1635 | |||
1636 | if ( *it == "Nickname" ) | 1699 | if ( *it == "Nickname" ) |
1637 | ent.setNickname( (*itLE)->text() ); | 1700 | ent.setNickname( (*itLE)->text() ); |
1638 | 1701 | ||
1639 | if ( *it == "Children" ) | 1702 | if ( *it == "Children" ) |
1640 | ent.setChildren( (*itLE)->text() ); | 1703 | ent.setChildren( (*itLE)->text() ); |
1641 | 1704 | ||
@@ -1803,6 +1866,36 @@ static inline bool constainsWhiteSpace( const QString &str ) | |||
1803 | for (i = 0; i < count; i++ ) | 1866 | for (i = 0; i < count; i++ ) |
1804 | if ( str[i].isSpace() ) | 1867 | if ( str[i].isSpace() ) |
1805 | return TRUE; | 1868 | return TRUE; |
1806 | return FALSE; | 1869 | return FALSE; |
1807 | } | 1870 | } |
1808 | 1871 | ||
1872 | void ContactEditor::setPersonalView( bool personal ) | ||
1873 | { | ||
1874 | m_personalView = personal; | ||
1875 | if ( personal ){ | ||
1876 | cmbCat->hide(); | ||
1877 | labCat->hide(); | ||
1878 | } else{ | ||
1879 | cmbCat->show(); | ||
1880 | labCat->show(); | ||
1881 | |||
1882 | } | ||
1883 | } | ||
1884 | |||
1885 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) | ||
1886 | { | ||
1887 | QDate date; | ||
1888 | date.setYMD( year, month, day ); | ||
1889 | QString dateString = TimeString::numberDateString( date ); | ||
1890 | anniversaryButton->setText( dateString ); | ||
1891 | ent.setAnniversary ( dateString ); | ||
1892 | } | ||
1893 | |||
1894 | void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) | ||
1895 | { | ||
1896 | QDate date; | ||
1897 | date.setYMD( year, month, day ); | ||
1898 | QString dateString = TimeString::numberDateString( date ); | ||
1899 | birthdayButton->setText( dateString ); | ||
1900 | ent.setBirthday ( dateString ); | ||
1901 | } | ||