author | eilers <eilers> | 2002-10-27 16:18:51 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-27 16:18:51 (UTC) |
commit | cc01384d8c2b421d5f455f32631d8c2ec4b7e844 (patch) (unidiff) | |
tree | 0917ecf78c54b17620a583e584198881db24fee2 /core/pim | |
parent | 5f09fc992af19fc208315217eb46635a762f1e55 (diff) | |
download | opie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.zip opie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.tar.gz opie-cc01384d8c2b421d5f455f32631d8c2ec4b7e844.tar.bz2 |
OContact now uses QDate to avoid wrong interpreted strings
A lot of inline functions moved into the library..
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 5 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 34 |
2 files changed, 20 insertions, 19 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 4feadeb..5222f16 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -3,48 +3,49 @@ | |||
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_CONTACT_MRE | 21 | #define QTOPIA_INTERNAL_CONTACT_MRE |
22 | 22 | ||
23 | #include <qpe/categoryselect.h> | 23 | #include <qpe/categoryselect.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/timestring.h> | ||
27 | 28 | ||
28 | #include <opie/orecordlist.h> | 29 | #include <opie/orecordlist.h> |
29 | 30 | ||
30 | #include <qasciidict.h> | 31 | #include <qasciidict.h> |
31 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
32 | #include <qfile.h> | 33 | #include <qfile.h> |
33 | #include <qregexp.h> | 34 | #include <qregexp.h> |
34 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
35 | 36 | ||
36 | #include "abtable.h" | 37 | #include "abtable.h" |
37 | 38 | ||
38 | #include <errno.h> | 39 | #include <errno.h> |
39 | #include <fcntl.h> | 40 | #include <fcntl.h> |
40 | #include <unistd.h> | 41 | #include <unistd.h> |
41 | #include <stdlib.h> | 42 | #include <stdlib.h> |
42 | 43 | ||
43 | #include <ctype.h> //toupper() for key hack | 44 | #include <ctype.h> //toupper() for key hack |
44 | 45 | ||
45 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); | 46 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); |
46 | 47 | ||
47 | 48 | ||
48 | /*! | 49 | /*! |
49 | \class AbTableItem abtable.h | 50 | \class AbTableItem abtable.h |
50 | 51 | ||
@@ -429,52 +430,52 @@ QString AbTable::findContactContact( const OContact &entry, int /* row */ ) | |||
429 | value = entry.businessFax(); | 430 | value = entry.businessFax(); |
430 | break; | 431 | break; |
431 | case Qtopia::BusinessMobile: | 432 | case Qtopia::BusinessMobile: |
432 | value = entry.businessMobile(); | 433 | value = entry.businessMobile(); |
433 | break; | 434 | break; |
434 | case Qtopia::BusinessPager: | 435 | case Qtopia::BusinessPager: |
435 | value = entry.businessPager(); | 436 | value = entry.businessPager(); |
436 | break; | 437 | break; |
437 | case Qtopia::Profession: | 438 | case Qtopia::Profession: |
438 | value = entry.profession(); | 439 | value = entry.profession(); |
439 | break; | 440 | break; |
440 | case Qtopia::Assistant: | 441 | case Qtopia::Assistant: |
441 | value = entry.assistant(); | 442 | value = entry.assistant(); |
442 | break; | 443 | break; |
443 | case Qtopia::Manager: | 444 | case Qtopia::Manager: |
444 | value = entry.manager(); | 445 | value = entry.manager(); |
445 | break; | 446 | break; |
446 | case Qtopia::Spouse: | 447 | case Qtopia::Spouse: |
447 | value = entry.spouse(); | 448 | value = entry.spouse(); |
448 | break; | 449 | break; |
449 | case Qtopia::Gender: | 450 | case Qtopia::Gender: |
450 | value = entry.gender(); | 451 | value = entry.gender(); |
451 | break; | 452 | break; |
452 | case Qtopia::Birthday: | 453 | case Qtopia::Birthday: |
453 | value = entry.birthday(); | 454 | value = TimeString::numberDateString( entry.birthday() ); |
454 | break; | 455 | break; |
455 | case Qtopia::Anniversary: | 456 | case Qtopia::Anniversary: |
456 | value = entry.anniversary(); | 457 | value = TimeString::numberDateString( entry.anniversary() ); |
457 | break; | 458 | break; |
458 | case Qtopia::Nickname: | 459 | case Qtopia::Nickname: |
459 | value = entry.nickname(); | 460 | value = entry.nickname(); |
460 | break; | 461 | break; |
461 | case Qtopia::Children: | 462 | case Qtopia::Children: |
462 | value = entry.children(); | 463 | value = entry.children(); |
463 | break; | 464 | break; |
464 | case Qtopia::Notes: | 465 | case Qtopia::Notes: |
465 | value = entry.notes(); | 466 | value = entry.notes(); |
466 | break; | 467 | break; |
467 | } | 468 | } |
468 | if ( !value.isEmpty() ) | 469 | if ( !value.isEmpty() ) |
469 | break; | 470 | break; |
470 | } | 471 | } |
471 | return value; | 472 | return value; |
472 | } | 473 | } |
473 | 474 | ||
474 | void AbTable::addEntry( const OContact &newCnt ) | 475 | void AbTable::addEntry( const OContact &newCnt ) |
475 | { | 476 | { |
476 | int row = numRows(); | 477 | int row = numRows(); |
477 | 478 | ||
478 | setNumRows( row + 1 ); | 479 | setNumRows( row + 1 ); |
479 | insertIntoTable( newCnt, row ); | 480 | insertIntoTable( newCnt, row ); |
480 | 481 | ||
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 52ab0f2..e034b35 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -1,26 +1,27 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> | 2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> |
3 | * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | ||
3 | * | 4 | * |
4 | * This file is an add-on for the OPIE Palmtop Environment | 5 | * This file is an add-on for the OPIE Palmtop Environment |
5 | * | 6 | * |
6 | * This file may be distributed and/or modified under the terms of the | 7 | * This file may be distributed and/or modified under the terms of the |
7 | * GNU General Public License version 2 as published by the Free Software | 8 | * GNU General Public License version 2 as published by the Free Software |
8 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging | 9 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging |
9 | * of this file. | 10 | * of this file. |
10 | * | 11 | * |
11 | * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | * | 14 | * |
14 | * | 15 | * |
15 | * This is a rewrite of the abeditor.h file, modified to provide a more | 16 | * This is a rewrite of the abeditor.h file, modified to provide a more |
16 | * intuitive interface to TrollTech's original Address Book editor. This | 17 | * intuitive interface to TrollTech's original Address Book editor. This |
17 | * 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. |
18 | * | 19 | * |
19 | */ | 20 | */ |
20 | 21 | ||
21 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
22 | #include "addresspicker.h" | 23 | #include "addresspicker.h" |
23 | 24 | ||
24 | #include <qpe/categoryselect.h> | 25 | #include <qpe/categoryselect.h> |
25 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qpedialog.h> | 27 | #include <qpe/qpedialog.h> |
@@ -1087,62 +1088,48 @@ void ContactEditor::loadFields() { | |||
1087 | if ( *it == "Company" ) | 1088 | if ( *it == "Company" ) |
1088 | (*lit)->setText( tr( "Company" ) ); | 1089 | (*lit)->setText( tr( "Company" ) ); |
1089 | 1090 | ||
1090 | if ( *it == "Office" ) | 1091 | if ( *it == "Office" ) |
1091 | (*lit)->setText( tr( "Office" ) ); | 1092 | (*lit)->setText( tr( "Office" ) ); |
1092 | 1093 | ||
1093 | if ( *it == "Profession" ) | 1094 | if ( *it == "Profession" ) |
1094 | (*lit)->setText( tr( "Profession" ) ); | 1095 | (*lit)->setText( tr( "Profession" ) ); |
1095 | 1096 | ||
1096 | if ( *it == "Assistant" ) | 1097 | if ( *it == "Assistant" ) |
1097 | (*lit)->setText( tr( "Assistant" ) ); | 1098 | (*lit)->setText( tr( "Assistant" ) ); |
1098 | 1099 | ||
1099 | if ( *it == "Manager" ) | 1100 | if ( *it == "Manager" ) |
1100 | (*lit)->setText( tr( "Manager" ) ); | 1101 | (*lit)->setText( tr( "Manager" ) ); |
1101 | 1102 | ||
1102 | if ( *it == "Spouse" ) | 1103 | if ( *it == "Spouse" ) |
1103 | (*lit)->setText( tr( "Spouse" ) ); | 1104 | (*lit)->setText( tr( "Spouse" ) ); |
1104 | 1105 | ||
1105 | if ( *it == "Nickname" ) | 1106 | if ( *it == "Nickname" ) |
1106 | (*lit)->setText( tr( "Nickname" ) ); | 1107 | (*lit)->setText( tr( "Nickname" ) ); |
1107 | 1108 | ||
1108 | if ( *it == "Children" ) | 1109 | if ( *it == "Children" ) |
1109 | (*lit)->setText( tr( "Children" ) ); | 1110 | (*lit)->setText( tr( "Children" ) ); |
1110 | } | 1111 | } |
1111 | // Set DatePicker | ||
1112 | qWarning ("**Info: %s", ent.birthday().latin1() ); | ||
1113 | if ( !ent.birthday().isEmpty() ){ | ||
1114 | birthdayButton->setText( ent.birthday() ); | ||
1115 | birthdayPicker->setDate( TimeConversion::fromString ( ent.birthday() ) ); | ||
1116 | } else | ||
1117 | birthdayButton->setText( tr ("Unknown") ); | ||
1118 | |||
1119 | qWarning ("**Info: %s", ent.anniversary().latin1() ); | ||
1120 | if ( !ent.anniversary().isEmpty() ){ | ||
1121 | anniversaryButton->setText( ent.anniversary() ); | ||
1122 | anniversaryPicker->setDate( TimeConversion::fromString ( ent.birthday() ) ); | ||
1123 | } else | ||
1124 | anniversaryButton->setText( tr ("Unknown") ); | ||
1125 | 1112 | ||
1126 | } | 1113 | } |
1127 | 1114 | ||
1128 | void ContactEditor::accept() { | 1115 | void ContactEditor::accept() { |
1129 | 1116 | ||
1130 | if ( isEmpty() ) { | 1117 | if ( isEmpty() ) { |
1131 | cleanupFields(); | 1118 | cleanupFields(); |
1132 | reject(); | 1119 | reject(); |
1133 | } else { | 1120 | } else { |
1134 | saveEntry(); | 1121 | saveEntry(); |
1135 | cleanupFields(); | 1122 | cleanupFields(); |
1136 | QDialog::accept(); | 1123 | QDialog::accept(); |
1137 | } | 1124 | } |
1138 | 1125 | ||
1139 | } | 1126 | } |
1140 | 1127 | ||
1141 | void ContactEditor::slotNote() { | 1128 | void ContactEditor::slotNote() { |
1142 | 1129 | ||
1143 | dlgNote->showMaximized(); | 1130 | dlgNote->showMaximized(); |
1144 | if ( !dlgNote->exec() ) { | 1131 | if ( !dlgNote->exec() ) { |
1145 | txtNote->setText( ent.notes() ); | 1132 | txtNote->setText( ent.notes() ); |
1146 | } | 1133 | } |
1147 | } | 1134 | } |
1148 | 1135 | ||
@@ -1580,49 +1567,62 @@ void ContactEditor::setEntry( const OContact &entry ) { | |||
1580 | */ | 1567 | */ |
1581 | if ( *it == "Home Web Page" ) | 1568 | if ( *it == "Home Web Page" ) |
1582 | *itV = ent.homeWebpage(); | 1569 | *itV = ent.homeWebpage(); |
1583 | 1570 | ||
1584 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) | 1571 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) |
1585 | *itV = ent.businessWebpage(); | 1572 | *itV = ent.businessWebpage(); |
1586 | 1573 | ||
1587 | 1574 | ||
1588 | } | 1575 | } |
1589 | 1576 | ||
1590 | 1577 | ||
1591 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); | 1578 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); |
1592 | 1579 | ||
1593 | QString gender = ent.gender(); | 1580 | QString gender = ent.gender(); |
1594 | cmbGender->setCurrentItem( gender.toInt() ); | 1581 | cmbGender->setCurrentItem( gender.toInt() ); |
1595 | 1582 | ||
1596 | txtNote->setText( ent.notes() ); | 1583 | txtNote->setText( ent.notes() ); |
1597 | 1584 | ||
1598 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); | 1585 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); |
1599 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); | 1586 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); |
1600 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); | 1587 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); |
1601 | 1588 | ||
1602 | slotAddressTypeChange( cmbAddress->currentItem() ); | 1589 | slotAddressTypeChange( cmbAddress->currentItem() ); |
1603 | 1590 | ||
1604 | loadFields(); | 1591 | // loadFields(); :SX |
1592 | |||
1593 | // Set DatePicker | ||
1594 | if ( !ent.birthday().isNull() ){ | ||
1595 | birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); | ||
1596 | birthdayPicker->setDate( ent.birthday() ); | ||
1597 | } else | ||
1598 | birthdayButton->setText( tr ("Unknown") ); | ||
1599 | |||
1600 | if ( !ent.anniversary().isNull() ){ | ||
1601 | anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); | ||
1602 | anniversaryPicker->setDate( ent.anniversary() ); | ||
1603 | } else | ||
1604 | anniversaryButton->setText( tr ("Unknown") ); | ||
1605 | 1605 | ||
1606 | } | 1606 | } |
1607 | 1607 | ||
1608 | void ContactEditor::saveEntry() { | 1608 | void ContactEditor::saveEntry() { |
1609 | 1609 | ||
1610 | if ( useFullName == TRUE ) { | 1610 | if ( useFullName == TRUE ) { |
1611 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); | 1611 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); |
1612 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); | 1612 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); |
1613 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); | 1613 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); |
1614 | txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); | 1614 | txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); |
1615 | 1615 | ||
1616 | useFullName = FALSE; | 1616 | useFullName = FALSE; |
1617 | } | 1617 | } |
1618 | 1618 | ||
1619 | /*if ( ent.firstName() != txtFirstName->text() || | 1619 | /*if ( ent.firstName() != txtFirstName->text() || |
1620 | ent.lastName != txtLastName->text() || | 1620 | ent.lastName != txtLastName->text() || |
1621 | ent.middleName != txtMiddleName->text() ) { | 1621 | ent.middleName != txtMiddleName->text() ) { |
1622 | */ | 1622 | */ |
1623 | ent.setFirstName( txtFirstName->text() ); | 1623 | ent.setFirstName( txtFirstName->text() ); |
1624 | ent.setLastName( txtLastName->text() ); | 1624 | ent.setLastName( txtLastName->text() ); |
1625 | ent.setMiddleName( txtMiddleName->text() ); | 1625 | ent.setMiddleName( txtMiddleName->text() ); |
1626 | ent.setSuffix( txtSuffix->text() ); | 1626 | ent.setSuffix( txtSuffix->text() ); |
1627 | 1627 | ||
1628 | //} | 1628 | //} |
@@ -1870,35 +1870,35 @@ static inline bool constainsWhiteSpace( const QString &str ) | |||
1870 | if ( str[i].isSpace() ) | 1870 | if ( str[i].isSpace() ) |
1871 | return TRUE; | 1871 | return TRUE; |
1872 | return FALSE; | 1872 | return FALSE; |
1873 | } | 1873 | } |
1874 | 1874 | ||
1875 | void ContactEditor::setPersonalView( bool personal ) | 1875 | void ContactEditor::setPersonalView( bool personal ) |
1876 | { | 1876 | { |
1877 | m_personalView = personal; | 1877 | m_personalView = personal; |
1878 | if ( personal ){ | 1878 | if ( personal ){ |
1879 | cmbCat->hide(); | 1879 | cmbCat->hide(); |
1880 | labCat->hide(); | 1880 | labCat->hide(); |
1881 | } else{ | 1881 | } else{ |
1882 | cmbCat->show(); | 1882 | cmbCat->show(); |
1883 | labCat->show(); | 1883 | labCat->show(); |
1884 | 1884 | ||
1885 | } | 1885 | } |
1886 | } | 1886 | } |
1887 | 1887 | ||
1888 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) | 1888 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) |
1889 | { | 1889 | { |
1890 | QDate date; | 1890 | QDate date; |
1891 | date.setYMD( year, month, day ); | 1891 | date.setYMD( year, month, day ); |
1892 | QString dateString = TimeString::numberDateString( date ); | 1892 | QString dateString = TimeString::numberDateString( date ); |
1893 | anniversaryButton->setText( dateString ); | 1893 | anniversaryButton->setText( dateString ); |
1894 | ent.setAnniversary ( dateString ); | 1894 | ent.setAnniversary ( date ); |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) | 1897 | void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) |
1898 | { | 1898 | { |
1899 | QDate date; | 1899 | QDate date; |
1900 | date.setYMD( year, month, day ); | 1900 | date.setYMD( year, month, day ); |
1901 | QString dateString = TimeString::numberDateString( date ); | 1901 | QString dateString = TimeString::numberDateString( date ); |
1902 | birthdayButton->setText( dateString ); | 1902 | birthdayButton->setText( dateString ); |
1903 | ent.setBirthday ( dateString ); | 1903 | ent.setBirthday ( date ); |
1904 | } | 1904 | } |