summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/ocontact.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/ocontact.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/ocontact.cpp235
1 files changed, 145 insertions, 90 deletions
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index f1a22a7..fa5313f 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -2,3 +2,3 @@
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
@@ -29,27 +29,9 @@
29 29
30/**********************************************************************
31** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
32** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
33**
34** This file may be distributed and/or modified under the terms of the
35** GNU General Public License version 2 as published by the Free Software
36** Foundation and appearing in the file LICENSE.GPL included in the
37** packaging of this file.
38**
39** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
40** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
41**
42** See http://www.trolltech.com/gpl/ for GPL licensing information.
43**
44** Contact info@trolltech.com if any conditions of this licensing are
45** not clear to you.
46**
47**********************************************************************/
48
49#define QTOPIA_INTERNAL_CONTACT_MRE 30#define QTOPIA_INTERNAL_CONTACT_MRE
50 31
51#include <opie2/ocontact.h> 32#include "ocontact.h"
33
34/* OPIE */
52#include <opie2/opimresolver.h> 35#include <opie2/opimresolver.h>
53#include <opie2/oconversion.h> 36#include <opie2/oconversion.h>
54
55#include <qpe/stringutil.h> 37#include <qpe/stringutil.h>
@@ -58,2 +40,3 @@
58 40
41/* QT */
59#include <qobject.h> 42#include <qobject.h>
@@ -64,2 +47,3 @@
64 47
48/* STD */
65#include <stdio.h> 49#include <stdio.h>
@@ -78,3 +62,4 @@
78 62
79namespace Opie { 63namespace Opie
64{
80/*! 65/*!
@@ -82,6 +67,4 @@ namespace Opie {
82*/ 67*/
83OContact::OContact() 68OContact::OContact():OPimRecord(), mMap(), d( 0 )
84 : OPimRecord(), mMap(), d( 0 ) 69{}
85{
86}
87 70
@@ -92,4 +75,3 @@ OContact::OContact()
92*/ 75*/
93OContact::OContact( const QMap<int, QString> &fromMap ) : 76OContact::OContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
94 OPimRecord(), mMap( fromMap ), d( 0 )
95{ 77{
@@ -101,6 +83,8 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
101 83
102 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ 84 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
85 {
103 qWarning( "Invalid UID found. Generate new one.." ); 86 qWarning( "Invalid UID found. Generate new one.." );
104 setUid( uidGen().generate() ); 87 setUid( uidGen().generate() );
105 }else 88 }
89 else
106 setUid( uidStr.toInt() ); 90 setUid( uidStr.toInt() );
@@ -115,4 +99,3 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
115OContact::~OContact() 99OContact::~OContact()
116{ 100{}
117}
118 101
@@ -483,3 +466,4 @@ QString OContact::toRichText() const
483 comp = company(); 466 comp = company();
484 if ( !(value = department()).isEmpty() ) { 467 if ( !( value = department() ).isEmpty() )
468 {
485 text += Qtopia::escapeString(value); 469 text += Qtopia::escapeString(value);
@@ -487,3 +471,4 @@ QString OContact::toRichText() const
487 text += ", " + Qtopia::escapeString(comp); 471 text += ", " + Qtopia::escapeString(comp);
488 }else if ( comp ) 472 }
473 else if ( comp )
489 text += "<br>" + Qtopia::escapeString(comp); 474 text += "<br>" + Qtopia::escapeString(comp);
@@ -493,3 +478,4 @@ QString OContact::toRichText() const
493 QString defEmail = defaultEmail(); 478 QString defEmail = defaultEmail();
494 if ( !defEmail.isEmpty() ){ 479 if ( !defEmail.isEmpty() )
480 {
495 text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>" 481 text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>"
@@ -501,3 +487,4 @@ QString OContact::toRichText() const
501 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 487 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
502 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 488 !businessZip().isEmpty() || !businessCountry().isEmpty() )
489 {
503 text += QObject::tr( "<br><b>Work Address:</b>" ); 490 text += QObject::tr( "<br><b>Work Address:</b>" );
@@ -506,3 +493,4 @@ QString OContact::toRichText() const
506 493
507 if ( !(value = businessStreet()).isEmpty() ){ 494 if ( !( value = businessStreet() ).isEmpty() )
495 {
508 text += "<br>" + Qtopia::escapeString(value); 496 text += "<br>" + Qtopia::escapeString(value);
@@ -511,6 +499,9 @@ QString OContact::toRichText() const
511 499
512 switch( addressformat ){ 500 switch ( addressformat )
513 case Zip_City_State:{ // Zip_Code City, State 501 {
502 case Zip_City_State:
503 { // Zip_Code City, State
514 state = businessState(); 504 state = businessState();
515 if ( !(value = businessZip()).isEmpty() ){ 505 if ( !( value = businessZip() ).isEmpty() )
506 {
516 text += "<br>" + Qtopia::escapeString(value) + " "; 507 text += "<br>" + Qtopia::escapeString(value) + " ";
@@ -519,3 +510,4 @@ QString OContact::toRichText() const
519 } 510 }
520 if ( !(value = businessCity()).isEmpty() ) { 511 if ( !( value = businessCity() ).isEmpty() )
512 {
521 marker = true; 513 marker = true;
@@ -526,3 +518,5 @@ QString OContact::toRichText() const
526 text += ", " + Qtopia::escapeString(state); 518 text += ", " + Qtopia::escapeString(state);
527 } else if ( !state.isEmpty() ){ 519 }
520 else if ( !state.isEmpty() )
521 {
528 text += "<br>" + Qtopia::escapeString(state); 522 text += "<br>" + Qtopia::escapeString(state);
@@ -532,5 +526,7 @@ QString OContact::toRichText() const
532 } 526 }
533 case City_State_Zip:{ // City, State Zip_Code 527 case City_State_Zip:
528 { // City, State Zip_Code
534 state = businessState(); 529 state = businessState();
535 if ( !(value = businessCity()).isEmpty() ) { 530 if ( !( value = businessCity() ).isEmpty() )
531 {
536 marker = true; 532 marker = true;
@@ -539,3 +535,5 @@ QString OContact::toRichText() const
539 text += ", " + Qtopia::escapeString(state); 535 text += ", " + Qtopia::escapeString(state);
540 } else if ( !state.isEmpty() ){ 536 }
537 else if ( !state.isEmpty() )
538 {
541 text += "<br>" + Qtopia::escapeString(state); 539 text += "<br>" + Qtopia::escapeString(state);
@@ -543,3 +541,4 @@ QString OContact::toRichText() const
543 } 541 }
544 if ( !(value = businessZip()).isEmpty() ){ 542 if ( !( value = businessZip() ).isEmpty() )
543 {
545 text += " " + Qtopia::escapeString(value); 544 text += " " + Qtopia::escapeString(value);
@@ -551,3 +550,4 @@ QString OContact::toRichText() const
551 550
552 if ( !(value = businessCountry()).isEmpty() ){ 551 if ( !( value = businessCountry() ).isEmpty() )
552 {
553 text += "<br>" + Qtopia::escapeString(value); 553 text += "<br>" + Qtopia::escapeString(value);
@@ -558,3 +558,4 @@ QString OContact::toRichText() const
558 str = office(); 558 str = office();
559 if ( !str.isEmpty() ){ 559 if ( !str.isEmpty() )
560 {
560 text += "<br><b>" + QObject::tr("Office: ") + "</b>" 561 text += "<br><b>" + QObject::tr("Office: ") + "</b>"
@@ -564,3 +565,4 @@ QString OContact::toRichText() const
564 str = businessWebpage(); 565 str = businessWebpage();
565 if ( !str.isEmpty() ){ 566 if ( !str.isEmpty() )
567 {
566 text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>" 568 text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>"
@@ -570,3 +572,4 @@ QString OContact::toRichText() const
570 str = businessPhone(); 572 str = businessPhone();
571 if ( !str.isEmpty() ){ 573 if ( !str.isEmpty() )
574 {
572 text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>" 575 text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>"
@@ -576,3 +579,4 @@ QString OContact::toRichText() const
576 str = businessFax(); 579 str = businessFax();
577 if ( !str.isEmpty() ){ 580 if ( !str.isEmpty() )
581 {
578 text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>" 582 text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>"
@@ -582,3 +586,4 @@ QString OContact::toRichText() const
582 str = businessMobile(); 586 str = businessMobile();
583 if ( !str.isEmpty() ){ 587 if ( !str.isEmpty() )
588 {
584 text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>" 589 text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>"
@@ -588,3 +593,4 @@ QString OContact::toRichText() const
588 str = businessPager(); 593 str = businessPager();
589 if ( !str.isEmpty() ){ 594 if ( !str.isEmpty() )
595 {
590 text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>" 596 text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
@@ -598,3 +604,4 @@ QString OContact::toRichText() const
598 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 604 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
599 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 605 !homeZip().isEmpty() || !homeCountry().isEmpty() )
606 {
600 text += QObject::tr( "<br><b>Home Address:</b>" ); 607 text += QObject::tr( "<br><b>Home Address:</b>" );
@@ -603,3 +610,4 @@ QString OContact::toRichText() const
603 610
604 if ( !(value = homeStreet()).isEmpty() ){ 611 if ( !( value = homeStreet() ).isEmpty() )
612 {
605 text += "<br>" + Qtopia::escapeString(value); 613 text += "<br>" + Qtopia::escapeString(value);
@@ -608,6 +616,9 @@ QString OContact::toRichText() const
608 616
609 switch( addressformat ){ 617 switch ( addressformat )
610 case Zip_City_State:{ // Zip_Code City, State 618 {
619 case Zip_City_State:
620 { // Zip_Code City, State
611 state = homeState(); 621 state = homeState();
612 if ( !(value = homeZip()).isEmpty() ){ 622 if ( !( value = homeZip() ).isEmpty() )
623 {
613 text += "<br>" + Qtopia::escapeString(value) + " "; 624 text += "<br>" + Qtopia::escapeString(value) + " ";
@@ -615,3 +626,4 @@ QString OContact::toRichText() const
615 } 626 }
616 if ( !(value = homeCity()).isEmpty() ) { 627 if ( !( value = homeCity() ).isEmpty() )
628 {
617 marker = true; 629 marker = true;
@@ -622,3 +634,5 @@ QString OContact::toRichText() const
622 text += ", " + Qtopia::escapeString(state); 634 text += ", " + Qtopia::escapeString(state);
623 } else if (!state.isEmpty()) { 635 }
636 else if ( !state.isEmpty() )
637 {
624 text += "<br>" + Qtopia::escapeString(state); 638 text += "<br>" + Qtopia::escapeString(state);
@@ -628,5 +642,7 @@ QString OContact::toRichText() const
628 } 642 }
629 case City_State_Zip:{ // City, State Zip_Code 643 case City_State_Zip:
644 { // City, State Zip_Code
630 state = homeState(); 645 state = homeState();
631 if ( !(value = homeCity()).isEmpty() ) { 646 if ( !( value = homeCity() ).isEmpty() )
647 {
632 marker = true; 648 marker = true;
@@ -635,3 +651,5 @@ QString OContact::toRichText() const
635 text += ", " + Qtopia::escapeString(state); 651 text += ", " + Qtopia::escapeString(state);
636 } else if ( !state.isEmpty() ){ 652 }
653 else if ( !state.isEmpty() )
654 {
637 text += "<br>" + Qtopia::escapeString(state); 655 text += "<br>" + Qtopia::escapeString(state);
@@ -639,3 +657,4 @@ QString OContact::toRichText() const
639 } 657 }
640 if ( !(value = homeZip()).isEmpty() ){ 658 if ( !( value = homeZip() ).isEmpty() )
659 {
641 text += " " + Qtopia::escapeString(value); 660 text += " " + Qtopia::escapeString(value);
@@ -647,3 +666,4 @@ QString OContact::toRichText() const
647 666
648 if ( !(value = homeCountry()).isEmpty() ){ 667 if ( !( value = homeCountry() ).isEmpty() )
668 {
649 text += "<br>" + Qtopia::escapeString(value); 669 text += "<br>" + Qtopia::escapeString(value);
@@ -654,3 +674,4 @@ QString OContact::toRichText() const
654 str = homeWebpage(); 674 str = homeWebpage();
655 if ( !str.isEmpty() ){ 675 if ( !str.isEmpty() )
676 {
656 text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>" 677 text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>"
@@ -660,3 +681,4 @@ QString OContact::toRichText() const
660 str = homePhone(); 681 str = homePhone();
661 if ( !str.isEmpty() ){ 682 if ( !str.isEmpty() )
683 {
662 text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>" 684 text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>"
@@ -666,3 +688,4 @@ QString OContact::toRichText() const
666 str = homeFax(); 688 str = homeFax();
667 if ( !str.isEmpty() ){ 689 if ( !str.isEmpty() )
690 {
668 text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>" 691 text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>"
@@ -672,3 +695,4 @@ QString OContact::toRichText() const
672 str = homeMobile(); 695 str = homeMobile();
673 if ( !str.isEmpty() ){ 696 if ( !str.isEmpty() )
697 {
674 text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>" 698 text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
@@ -699,3 +723,4 @@ QString OContact::toRichText() const
699 str = gender(); 723 str = gender();
700 if ( !str.isEmpty() && str.toInt() != 0 ) { 724 if ( !str.isEmpty() && str.toInt() != 0 )
725 {
701 text += "<br>"; 726 text += "<br>";
@@ -711,3 +736,4 @@ QString OContact::toRichText() const
711 + Qtopia::escapeString(str); 736 + Qtopia::escapeString(str);
712 if ( birthday().isValid() ){ 737 if ( birthday().isValid() )
738 {
713 str = TimeString::numberDateString( birthday() ); 739 str = TimeString::numberDateString( birthday() );
@@ -716,3 +742,4 @@ QString OContact::toRichText() const
716 } 742 }
717 if ( anniversary().isValid() ){ 743 if ( anniversary().isValid() )
744 {
718 str = TimeString::numberDateString( anniversary() ); 745 str = TimeString::numberDateString( anniversary() );
@@ -732,3 +759,4 @@ QString OContact::toRichText() const
732 // categories 759 // categories
733 if ( categoryNames("Contacts").count() ){ 760 if ( categoryNames( "Contacts" ).count() )
761 {
734 text += "<br><b>" + QObject::tr( "Category:") + "</b> "; 762 text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
@@ -738,3 +766,4 @@ QString OContact::toRichText() const
738 // notes last 766 // notes last
739 if ( !(value = notes()).isEmpty() ) { 767 if ( !( value = notes() ).isEmpty() )
768 {
740 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; 769 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
@@ -839,3 +868,4 @@ QString OContact::fullName() const
839 QString name = title; 868 QString name = title;
840 if ( !firstName.isEmpty() ) { 869 if ( !firstName.isEmpty() )
870 {
841 if ( !name.isEmpty() ) 871 if ( !name.isEmpty() )
@@ -844,3 +874,4 @@ QString OContact::fullName() const
844 } 874 }
845 if ( !middleName.isEmpty() ) { 875 if ( !middleName.isEmpty() )
876 {
846 if ( !name.isEmpty() ) 877 if ( !name.isEmpty() )
@@ -849,3 +880,4 @@ QString OContact::fullName() const
849 } 880 }
850 if ( !lastName.isEmpty() ) { 881 if ( !lastName.isEmpty() )
882 {
851 if ( !name.isEmpty() ) 883 if ( !name.isEmpty() )
@@ -854,3 +886,4 @@ QString OContact::fullName() const
854 } 886 }
855 if ( !suffix.isEmpty() ) { 887 if ( !suffix.isEmpty() )
888 {
856 if ( !name.isEmpty() ) 889 if ( !name.isEmpty() )
@@ -902,3 +935,4 @@ QStringList OContact::emailList() const
902 QStringList r; 935 QStringList r;
903 if ( !emailStr.isEmpty() ) { 936 if ( !emailStr.isEmpty() )
937 {
904 qDebug(" emailstr "); 938 qDebug(" emailstr ");
@@ -948,6 +982,8 @@ void OContact::save( QString &buf ) const
948 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 982 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
949 it != mMap.end(); ++it ) { 983 it != mMap.end(); ++it )
984 {
950 const QString &value = it.data(); 985 const QString &value = it.data();
951 int key = it.key(); 986 int key = it.key();
952 if ( !value.isEmpty() ) { 987 if ( !value.isEmpty() )
988 {
953 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 989 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
@@ -1063,4 +1099,6 @@ bool OContact::match( const QRegExp &r ) const
1063 QMap<int, QString>::ConstIterator it; 1099 QMap<int, QString>::ConstIterator it;
1064 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 1100 for ( it = mMap.begin(); it != mMap.end(); ++it )
1065 if ( (*it).find( r ) > -1 ) { 1101 {
1102 if ( ( *it ).find( r ) > -1 )
1103 {
1066 setLastHitField( it.key() ); 1104 setLastHitField( it.key() );
@@ -1078,2 +1116,4 @@ QString OContact::toShortText() const
1078} 1116}
1117
1118
1079QString OContact::type() const 1119QString OContact::type() const
@@ -1084,3 +1124,2 @@ QString OContact::type() const
1084 1124
1085
1086class QString OContact::recordField( int pos ) const 1125class QString OContact::recordField( int pos ) const
@@ -1101,3 +1140,4 @@ void OContact::setBirthday( const QDate &v )
1101{ 1140{
1102 if ( v.isNull() ){ 1141 if ( v.isNull() )
1142 {
1103 qWarning( "Remove Birthday"); 1143 qWarning( "Remove Birthday");
@@ -1119,3 +1159,4 @@ void OContact::setAnniversary( const QDate &v )
1119{ 1159{
1120 if ( v.isNull() ){ 1160 if ( v.isNull() )
1161 {
1121 qWarning( "Remove Anniversary"); 1162 qWarning( "Remove Anniversary");
@@ -1129,2 +1170,3 @@ void OContact::setAnniversary( const QDate &v )
1129 1170
1171
1130/*! \fn QDate OContact::birthday() const 1172/*! \fn QDate OContact::birthday() const
@@ -1165,3 +1207,4 @@ void OContact::insertEmail( const QString &v )
1165 // if no default, set it as the default email and don't insert 1207 // if no default, set it as the default email and don't insert
1166 if ( def.isEmpty() ) { 1208 if ( def.isEmpty() )
1209 {
1167 setDefaultEmail( e ); // will insert into the list for us 1210 setDefaultEmail( e ); // will insert into the list for us
@@ -1180,2 +1223,3 @@ void OContact::insertEmail( const QString &v )
1180 1223
1224
1181void OContact::removeEmail( const QString &v ) 1225void OContact::removeEmail( const QString &v )
@@ -1199,3 +1243,4 @@ void OContact::removeEmail( const QString &v )
1199 // if default, then replace the default email with the first one 1243 // if default, then replace the default email with the first one
1200 if ( def == e ) { 1244 if ( def == e )
1245 {
1201 //qDebug("removeEmail is default; setting new default"); 1246 //qDebug("removeEmail is default; setting new default");
@@ -1207,2 +1252,4 @@ void OContact::removeEmail( const QString &v )
1207} 1252}
1253
1254
1208void OContact::clearEmails() 1255void OContact::clearEmails()
@@ -1212,2 +1259,4 @@ void OContact::clearEmails()
1212} 1259}
1260
1261
1213void OContact::setDefaultEmail( const QString &v ) 1262void OContact::setDefaultEmail( const QString &v )
@@ -1224,2 +1273,3 @@ void OContact::setDefaultEmail( const QString &v )
1224 1273
1274
1225void OContact::insertEmails( const QStringList &v ) 1275void OContact::insertEmails( const QStringList &v )
@@ -1229,5 +1279,10 @@ void OContact::insertEmails( const QStringList &v )
1229} 1279}
1230int OContact::rtti() { 1280
1281
1282int OContact::rtti()
1283{
1231 return OPimResolver::AddressBook; 1284 return OPimResolver::AddressBook;
1232} 1285}
1286
1287
1233void OContact::setUid( int i ) 1288void OContact::setUid( int i )