summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/ocontact.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/ocontact.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ocontact.cpp749
1 files changed, 402 insertions, 347 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 @@
This file is part of the Opie Project
- Copyright (C) The Main Author <main-author@whereever.org>
+ Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
@@ -29,27 +29,9 @@
-/**********************************************************************
-** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
-** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
#define QTOPIA_INTERNAL_CONTACT_MRE
-#include <opie2/ocontact.h>
+#include "ocontact.h"
+
+/* OPIE */
#include <opie2/opimresolver.h>
#include <opie2/oconversion.h>
-
#include <qpe/stringutil.h>
@@ -58,2 +40,3 @@
+/* QT */
#include <qobject.h>
@@ -64,2 +47,3 @@
+/* STD */
#include <stdio.h>
@@ -78,3 +62,4 @@
-namespace Opie {
+namespace Opie
+{
/*!
@@ -82,6 +67,4 @@ namespace Opie {
*/
-OContact::OContact()
- : OPimRecord(), mMap(), d( 0 )
-{
-}
+OContact::OContact():OPimRecord(), mMap(), d( 0 )
+{}
@@ -92,4 +75,3 @@ OContact::OContact()
*/
-OContact::OContact( const QMap<int, QString> &fromMap ) :
- OPimRecord(), mMap( fromMap ), d( 0 )
+OContact::OContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
{
@@ -97,3 +79,3 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
if ( !cats.isEmpty() )
- setCategories( idsFromString( cats ) );
+ setCategories( idsFromString( cats ) );
@@ -101,10 +83,12 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
- if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
- qWarning( "Invalid UID found. Generate new one.." );
- setUid( uidGen().generate() );
- }else
- setUid( uidStr.toInt() );
+ if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
+ {
+ qWarning( "Invalid UID found. Generate new one.." );
+ setUid( uidGen().generate() );
+ }
+ else
+ setUid( uidStr.toInt() );
-// if ( !uidStr.isEmpty() )
-// setUid( uidStr.toInt() );
+ // if ( !uidStr.isEmpty() )
+ // setUid( uidStr.toInt() );
}
@@ -115,4 +99,3 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
OContact::~OContact()
-{
-}
+{}
@@ -457,3 +440,3 @@ QMap<int, QString> OContact::toMap() const
if ( !cats.isEmpty() )
- map.insert( Qtopia::AddressCategory, cats );
+ map.insert( Qtopia::AddressCategory, cats );
return map;
@@ -471,4 +454,4 @@ QString OContact::toRichText() const
- Config cfg("qpe");
- cfg.setGroup("Appearance");
+ Config cfg( "qpe" );
+ cfg.setGroup( "Appearance" );
int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State );
@@ -476,15 +459,17 @@ QString OContact::toRichText() const
// name, jobtitle and company
- if ( !(value = fullName()).isEmpty() )
- text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>";
-
- if ( !(value = jobTitle()).isEmpty() )
- text += Qtopia::escapeString(value) + " ";
+ if ( !( value = fullName() ).isEmpty() )
+ text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString( value ) + "</h3></b>";
+
+ if ( !( value = jobTitle() ).isEmpty() )
+ text += Qtopia::escapeString( value ) + " ";
comp = company();
- if ( !(value = department()).isEmpty() ) {
- text += Qtopia::escapeString(value);
- if ( comp )
- text += ", " + Qtopia::escapeString(comp);
- }else if ( comp )
- text += "<br>" + Qtopia::escapeString(comp);
+ if ( !( value = department() ).isEmpty() )
+ {
+ text += Qtopia::escapeString( value );
+ if ( comp )
+ text += ", " + Qtopia::escapeString( comp );
+ }
+ else if ( comp )
+ text += "<br>" + Qtopia::escapeString( comp );
text += "<br><hr>";
@@ -493,6 +478,7 @@ QString OContact::toRichText() const
QString defEmail = defaultEmail();
- if ( !defEmail.isEmpty() ){
- text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>"
- + Qtopia::escapeString(defEmail);
- marker = true;
+ if ( !defEmail.isEmpty() )
+ {
+ text += "<b><img src=\"addressbook/email\"> " + QObject::tr( "Default Email: " ) + "</b>"
+ + Qtopia::escapeString( defEmail );
+ marker = true;
}
@@ -501,55 +487,69 @@ QString OContact::toRichText() const
if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
- !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
- text += QObject::tr( "<br><b>Work Address:</b>" );
- marker = true;
+ !businessZip().isEmpty() || !businessCountry().isEmpty() )
+ {
+ text += QObject::tr( "<br><b>Work Address:</b>" );
+ marker = true;
}
- if ( !(value = businessStreet()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value);
- marker = true;
+ if ( !( value = businessStreet() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value );
+ marker = true;
}
- switch( addressformat ){
- case Zip_City_State:{ // Zip_Code City, State
- state = businessState();
- if ( !(value = businessZip()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value) + " ";
- marker = true;
-
- }
- if ( !(value = businessCity()).isEmpty() ) {
- marker = true;
- if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
- text += "<br>";
- text += Qtopia::escapeString(value);
- if ( state )
- text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
- text += "<br>" + Qtopia::escapeString(state);
- marker = true;
- }
- break;
- }
- case City_State_Zip:{ // City, State Zip_Code
- state = businessState();
- if ( !(value = businessCity()).isEmpty() ) {
- marker = true;
- text += "<br>" + Qtopia::escapeString(value);
- if ( state )
- text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
- text += "<br>" + Qtopia::escapeString(state);
- marker = true;
- }
- if ( !(value = businessZip()).isEmpty() ){
- text += " " + Qtopia::escapeString(value);
- marker = true;
- }
- break;
- }
+ switch ( addressformat )
+ {
+ case Zip_City_State:
+ { // Zip_Code City, State
+ state = businessState();
+ if ( !( value = businessZip() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value ) + " ";
+ marker = true;
+
+ }
+ if ( !( value = businessCity() ).isEmpty() )
+ {
+ marker = true;
+ if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
+ text += "<br>";
+ text += Qtopia::escapeString( value );
+ if ( state )
+ text += ", " + Qtopia::escapeString( state );
+ }
+ else if ( !state.isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( state );
+ marker = true;
+ }
+ break;
+ }
+ case City_State_Zip:
+ { // City, State Zip_Code
+ state = businessState();
+ if ( !( value = businessCity() ).isEmpty() )
+ {
+ marker = true;
+ text += "<br>" + Qtopia::escapeString( value );
+ if ( state )
+ text += ", " + Qtopia::escapeString( state );
+ }
+ else if ( !state.isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( state );
+ marker = true;
+ }
+ if ( !( value = businessZip() ).isEmpty() )
+ {
+ text += " " + Qtopia::escapeString( value );
+ marker = true;
+ }
+ break;
+ }
}
- if ( !(value = businessCountry()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value);
- marker = true;
+ if ( !( value = businessCountry() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value );
+ marker = true;
}
@@ -558,36 +558,42 @@ QString OContact::toRichText() const
str = office();
- if ( !str.isEmpty() ){
- text += "<br><b>" + QObject::tr("Office: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b>" + QObject::tr( "Office: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessWebpage();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr( "Business Web Page: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessPhone();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr( "Business Phone: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessFax();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr( "Business Fax: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessMobile();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr( "Business Mobile: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessPager();
- if ( !str.isEmpty() ){
- text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b>" + QObject::tr( "Business Pager: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
@@ -598,54 +604,68 @@ QString OContact::toRichText() const
if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
- !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
- text += QObject::tr( "<br><b>Home Address:</b>" );
- marker = true;
+ !homeZip().isEmpty() || !homeCountry().isEmpty() )
+ {
+ text += QObject::tr( "<br><b>Home Address:</b>" );
+ marker = true;
}
- if ( !(value = homeStreet()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value);
- marker = true;
+ if ( !( value = homeStreet() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value );
+ marker = true;
}
- switch( addressformat ){
- case Zip_City_State:{ // Zip_Code City, State
- state = homeState();
- if ( !(value = homeZip()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value) + " ";
- marker = true;
- }
- if ( !(value = homeCity()).isEmpty() ) {
- marker = true;
- if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
- text += "<br>";
- text += Qtopia::escapeString(value);
- if ( !state.isEmpty() )
- text += ", " + Qtopia::escapeString(state);
- } else if (!state.isEmpty()) {
- text += "<br>" + Qtopia::escapeString(state);
- marker = true;
- }
- break;
- }
- case City_State_Zip:{ // City, State Zip_Code
- state = homeState();
- if ( !(value = homeCity()).isEmpty() ) {
- marker = true;
- text += "<br>" + Qtopia::escapeString(value);
- if ( state )
- text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
- text += "<br>" + Qtopia::escapeString(state);
- marker = true;
- }
- if ( !(value = homeZip()).isEmpty() ){
- text += " " + Qtopia::escapeString(value);
- marker = true;
- }
- break;
- }
+ switch ( addressformat )
+ {
+ case Zip_City_State:
+ { // Zip_Code City, State
+ state = homeState();
+ if ( !( value = homeZip() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value ) + " ";
+ marker = true;
+ }
+ if ( !( value = homeCity() ).isEmpty() )
+ {
+ marker = true;
+ if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
+ text += "<br>";
+ text += Qtopia::escapeString( value );
+ if ( !state.isEmpty() )
+ text += ", " + Qtopia::escapeString( state );
+ }
+ else if ( !state.isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( state );
+ marker = true;
+ }
+ break;
+ }
+ case City_State_Zip:
+ { // City, State Zip_Code
+ state = homeState();
+ if ( !( value = homeCity() ).isEmpty() )
+ {
+ marker = true;
+ text += "<br>" + Qtopia::escapeString( value );
+ if ( state )
+ text += ", " + Qtopia::escapeString( state );
+ }
+ else if ( !state.isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( state );
+ marker = true;
+ }
+ if ( !( value = homeZip() ).isEmpty() )
+ {
+ text += " " + Qtopia::escapeString( value );
+ marker = true;
+ }
+ break;
+ }
}
-
- if ( !(value = homeCountry()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value);
- marker = true;
+
+ if ( !( value = homeCountry() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value );
+ marker = true;
}
@@ -654,24 +674,28 @@ QString OContact::toRichText() const
str = homeWebpage();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr( "Home Web Page: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = homePhone();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr( "Home Phone: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = homeFax();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr( "Home Fax: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = homeMobile();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr( "Home Mobile: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
@@ -679,3 +703,3 @@ QString OContact::toRichText() const
if ( marker )
- text += "<br><hr>";
+ text += "<br><hr>";
@@ -684,24 +708,25 @@ QString OContact::toRichText() const
if ( !str.isEmpty() && ( str != defEmail ) )
- text += "<br><b>" + QObject::tr("All Emails: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "All Emails: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = profession();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Profession: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Profession: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = assistant();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Assistant: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Assistant: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = manager();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Manager: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Manager: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = gender();
- if ( !str.isEmpty() && str.toInt() != 0 ) {
- text += "<br>";
- if ( str.toInt() == 1 )
- str = QObject::tr( "Male" );
- else if ( str.toInt() == 2 )
- str = QObject::tr( "Female" );
- text += "<b>" + QObject::tr("Gender: ") + "</b>" + str;
+ if ( !str.isEmpty() && str.toInt() != 0 )
+ {
+ text += "<br>";
+ if ( str.toInt() == 1 )
+ str = QObject::tr( "Male" );
+ else if ( str.toInt() == 2 )
+ str = QObject::tr( "Female" );
+ text += "<b>" + QObject::tr( "Gender: " ) + "</b>" + str;
}
@@ -709,13 +734,15 @@ QString OContact::toRichText() const
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Spouse: ") + "</b>"
- + Qtopia::escapeString(str);
- if ( birthday().isValid() ){
- str = TimeString::numberDateString( birthday() );
- text += "<br><b>" + QObject::tr("Birthday: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Spouse: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ if ( birthday().isValid() )
+ {
+ str = TimeString::numberDateString( birthday() );
+ text += "<br><b>" + QObject::tr( "Birthday: " ) + "</b>"
+ + Qtopia::escapeString( str );
}
- if ( anniversary().isValid() ){
- str = TimeString::numberDateString( anniversary() );
- text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>"
- + Qtopia::escapeString(str);
+ if ( anniversary().isValid() )
+ {
+ str = TimeString::numberDateString( anniversary() );
+ text += "<br><b>" + QObject::tr( "Anniversary: " ) + "</b>"
+ + Qtopia::escapeString( str );
}
@@ -723,4 +750,4 @@ QString OContact::toRichText() const
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Children: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Children: " ) + "</b>"
+ + Qtopia::escapeString( str );
@@ -728,9 +755,10 @@ QString OContact::toRichText() const
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Nickname: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Nickname: " ) + "</b>"
+ + Qtopia::escapeString( str );
// categories
- if ( categoryNames("Contacts").count() ){
- text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
- text += categoryNames("Contacts").join(", ");
+ if ( categoryNames( "Contacts" ).count() )
+ {
+ text += "<br><b>" + QObject::tr( "Category:" ) + "</b> ";
+ text += categoryNames( "Contacts" ).join( ", " );
}
@@ -738,10 +766,11 @@ QString OContact::toRichText() const
// notes last
- if ( !(value = notes()).isEmpty() ) {
- text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
- QRegExp reg("\n");
-
- //QString tmp = Qtopia::escapeString(value);
- QString tmp = QStyleSheet::convertFromPlainText(value);
- //tmp.replace( reg, "<br>" );
- text += "<br>" + tmp + "<br>";
+ if ( !( value = notes() ).isEmpty() )
+ {
+ text += "<br><hr><b>" + QObject::tr( "Notes:" ) + "</b> ";
+ QRegExp reg( "\n" );
+
+ //QString tmp = Qtopia::escapeString(value);
+ QString tmp = QStyleSheet::convertFromPlainText( value );
+ //tmp.replace( reg, "<br>" );
+ text += "<br>" + tmp + "<br>";
}
@@ -757,5 +786,5 @@ void OContact::insert( int key, const QString &v )
if ( value.isEmpty() )
- mMap.remove( key );
+ mMap.remove( key );
else
- mMap.insert( key, value );
+ mMap.insert( key, value );
}
@@ -769,5 +798,5 @@ void OContact::replace( int key, const QString & v )
if ( value.isEmpty() )
- mMap.remove( key );
+ mMap.remove( key );
else
- mMap.replace( key, value );
+ mMap.replace( key, value );
}
@@ -779,3 +808,3 @@ QString OContact::find( int key ) const
{
- return mMap[key];
+ return mMap[ key ];
}
@@ -786,6 +815,6 @@ QString OContact::find( int key ) const
QString OContact::displayAddress( const QString &street,
- const QString &city,
- const QString &state,
- const QString &zip,
- const QString &country ) const
+ const QString &city,
+ const QString &state,
+ const QString &zip,
+ const QString &country ) const
{
@@ -793,12 +822,12 @@ QString OContact::displayAddress( const QString &street,
if ( !street.isEmpty() )
- s+= "\n";
+ s += "\n";
s += city;
if ( !city.isEmpty() && !state.isEmpty() )
- s += ", ";
+ s += ", ";
s += state;
if ( !state.isEmpty() && !zip.isEmpty() )
- s += " ";
+ s += " ";
s += zip;
if ( !country.isEmpty() && !s.isEmpty() )
- s += "\n";
+ s += "\n";
s += country;
@@ -813,4 +842,4 @@ QString OContact::displayBusinessAddress() const
return displayAddress( businessStreet(), businessCity(),
- businessState(), businessZip(),
- businessCountry() );
+ businessState(), businessZip(),
+ businessCountry() );
}
@@ -823,4 +852,4 @@ QString OContact::displayHomeAddress() const
return displayAddress( homeStreet(), homeCity(),
- homeState(), homeZip(),
- homeCountry() );
+ homeState(), homeZip(),
+ homeCountry() );
}
@@ -839,21 +868,25 @@ QString OContact::fullName() const
QString name = title;
- if ( !firstName.isEmpty() ) {
- if ( !name.isEmpty() )
- name += " ";
- name += firstName;
+ if ( !firstName.isEmpty() )
+ {
+ if ( !name.isEmpty() )
+ name += " ";
+ name += firstName;
}
- if ( !middleName.isEmpty() ) {
- if ( !name.isEmpty() )
- name += " ";
- name += middleName;
+ if ( !middleName.isEmpty() )
+ {
+ if ( !name.isEmpty() )
+ name += " ";
+ name += middleName;
}
- if ( !lastName.isEmpty() ) {
- if ( !name.isEmpty() )
- name += " ";
- name += lastName;
+ if ( !lastName.isEmpty() )
+ {
+ if ( !name.isEmpty() )
+ name += " ";
+ name += lastName;
}
- if ( !suffix.isEmpty() ) {
- if ( !name.isEmpty() )
- name += " ";
- name += suffix;
+ if ( !suffix.isEmpty() )
+ {
+ if ( !name.isEmpty() )
+ name += " ";
+ name += suffix;
}
@@ -902,7 +935,8 @@ QStringList OContact::emailList() const
QStringList r;
- if ( !emailStr.isEmpty() ) {
- qDebug(" emailstr ");
- QStringList l = QStringList::split( emailSeparator(), emailStr );
- for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
- r += (*it).simplifyWhiteSpace();
+ if ( !emailStr.isEmpty() )
+ {
+ qDebug( " emailstr " );
+ QStringList l = QStringList::split( emailSeparator(), emailStr );
+ for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
+ r += ( *it ).simplifyWhiteSpace();
}
@@ -926,11 +960,11 @@ void OContact::setFileAs()
if ( !lastName.isEmpty() && !firstName.isEmpty()
- && !middleName.isEmpty() )
- fileas = lastName + ", " + firstName + " " + middleName;
+ && !middleName.isEmpty() )
+ fileas = lastName + ", " + firstName + " " + middleName;
else if ( !lastName.isEmpty() && !firstName.isEmpty() )
- fileas = lastName + ", " + firstName;
+ fileas = lastName + ", " + firstName;
else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
- !middleName.isEmpty() )
- fileas = firstName + ( firstName.isEmpty() ? "" : " " )
- + middleName + ( middleName.isEmpty() ? "" : " " )
- + lastName;
+ !middleName.isEmpty() )
+ fileas = firstName + ( firstName.isEmpty() ? "" : " " )
+ + middleName + ( middleName.isEmpty() ? "" : " " )
+ + lastName;
@@ -948,13 +982,15 @@ void OContact::save( QString &buf ) const
for ( QMap<int, QString>::ConstIterator it = mMap.begin();
- it != mMap.end(); ++it ) {
- const QString &value = it.data();
- int key = it.key();
- if ( !value.isEmpty() ) {
- if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
- continue;
-
- key -= Qtopia::AddressCategory+1;
- buf += SLFIELDS[key];
- buf += "=\"" + Qtopia::escapeString(value) + "\" ";
- }
+ it != mMap.end(); ++it )
+ {
+ const QString &value = it.data();
+ int key = it.key();
+ if ( !value.isEmpty() )
+ {
+ if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid )
+ continue;
+
+ key -= Qtopia::AddressCategory + 1;
+ buf += SLFIELDS[ key ];
+ buf += "=\"" + Qtopia::escapeString( value ) + "\" ";
+ }
}
@@ -962,3 +998,3 @@ void OContact::save( QString &buf ) const
if ( categories().count() > 0 )
- buf += "Categories=\"" + idsToString( categories() ) + "\" ";
+ buf += "Categories=\"" + idsToString( categories() ) + "\" ";
buf += "Uid=\"" + QString::number( uid() ) + "\" ";
@@ -1063,8 +1099,10 @@ bool OContact::match( const QRegExp &r ) const
QMap<int, QString>::ConstIterator it;
- for ( it = mMap.begin(); it != mMap.end(); ++it ) {
- if ( (*it).find( r ) > -1 ) {
+ for ( it = mMap.begin(); it != mMap.end(); ++it )
+ {
+ if ( ( *it ).find( r ) > -1 )
+ {
setLastHitField( it.key() );
- match = true;
- break;
- }
+ match = true;
+ break;
+ }
}
@@ -1076,7 +1114,9 @@ QString OContact::toShortText() const
{
- return ( fullName() );
+ return ( fullName() );
}
+
+
QString OContact::type() const
{
- return QString::fromLatin1( "OContact" );
+ return QString::fromLatin1( "OContact" );
}
@@ -1084,7 +1124,6 @@ QString OContact::type() const
-
class QString OContact::recordField( int pos ) const
{
- QStringList SLFIELDS = fields(); // ?? why this ? (se)
- return SLFIELDS[pos];
+ QStringList SLFIELDS = fields(); // ?? why this ? (se)
+ return SLFIELDS[ pos ];
}
@@ -1101,10 +1140,11 @@ void OContact::setBirthday( const QDate &v )
{
- if ( v.isNull() ){
- qWarning( "Remove Birthday");
- replace( Qtopia::Birthday, QString::null );
- return;
- }
+ if ( v.isNull() )
+ {
+ qWarning( "Remove Birthday" );
+ replace( Qtopia::Birthday, QString::null );
+ return ;
+ }
- if ( v.isValid() )
- replace( Qtopia::Birthday, OConversion::dateToString( v ) );
+ if ( v.isValid() )
+ replace( Qtopia::Birthday, OConversion::dateToString( v ) );
@@ -1119,12 +1159,14 @@ void OContact::setAnniversary( const QDate &v )
{
- if ( v.isNull() ){
- qWarning( "Remove Anniversary");
- replace( Qtopia::Anniversary, QString::null );
- return;
- }
-
- if ( v.isValid() )
- replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
+ if ( v.isNull() )
+ {
+ qWarning( "Remove Anniversary" );
+ replace( Qtopia::Anniversary, QString::null );
+ return ;
+ }
+
+ if ( v.isValid() )
+ replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
}
+
/*! \fn QDate OContact::birthday() const
@@ -1134,8 +1176,8 @@ QDate OContact::birthday() const
{
- QString str = find( Qtopia::Birthday );
- // qWarning ("Birthday %s", str.latin1() );
- if ( !str.isEmpty() )
- return OConversion::dateFromString ( str );
- else
- return QDate();
+ QString str = find( Qtopia::Birthday );
+ // qWarning ("Birthday %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return OConversion::dateFromString ( str );
+ else
+ return QDate();
}
@@ -1148,9 +1190,9 @@ QDate OContact::anniversary() const
{
- QDate empty;
- QString str = find( Qtopia::Anniversary );
- // qWarning ("Anniversary %s", str.latin1() );
- if ( !str.isEmpty() )
- return OConversion::dateFromString ( str );
- else
- return empty;
+ QDate empty;
+ QString str = find( Qtopia::Anniversary );
+ // qWarning ("Anniversary %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return OConversion::dateFromString ( str );
+ else
+ return empty;
}
@@ -1165,5 +1207,6 @@ void OContact::insertEmail( const QString &v )
// if no default, set it as the default email and don't insert
- if ( def.isEmpty() ) {
- setDefaultEmail( e ); // will insert into the list for us
- return;
+ if ( def.isEmpty() )
+ {
+ setDefaultEmail( e ); // will insert into the list for us
+ return ;
}
@@ -1172,6 +1215,6 @@ void OContact::insertEmail( const QString &v )
QString emailsStr = find( Qtopia::Emails );
- if ( emailsStr.contains( e ))
- return;
+ if ( emailsStr.contains( e ) )
+ return ;
if ( !emailsStr.isEmpty() )
- emailsStr += emailSeparator();
+ emailsStr += emailSeparator();
emailsStr += e;
@@ -1180,3 +1223,4 @@ void OContact::insertEmail( const QString &v )
-void OContact::removeEmail( const QString &v )
+
+ void OContact::removeEmail( const QString &v )
{
@@ -1189,3 +1233,3 @@ void OContact::removeEmail( const QString &v )
if ( !emailsStr.contains( e ) )
- return;
+ return ;
@@ -1195,3 +1239,3 @@ void OContact::removeEmail( const QString &v )
// reset the string
- emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
+ emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator
replace( Qtopia::Emails, emailsStr );
@@ -1199,10 +1243,13 @@ void OContact::removeEmail( const QString &v )
// if default, then replace the default email with the first one
- if ( def == e ) {
- //qDebug("removeEmail is default; setting new default");
- if ( !emails.count() )
- clearEmails();
- else // setDefaultEmail will remove e from the list
- setDefaultEmail( emails.first() );
+ if ( def == e )
+ {
+ //qDebug("removeEmail is default; setting new default");
+ if ( !emails.count() )
+ clearEmails();
+ else // setDefaultEmail will remove e from the list
+ setDefaultEmail( emails.first() );
}
}
+
+
void OContact::clearEmails()
@@ -1212,2 +1259,4 @@ void OContact::clearEmails()
}
+
+
void OContact::setDefaultEmail( const QString &v )
@@ -1220,3 +1269,3 @@ void OContact::setDefaultEmail( const QString &v )
if ( !e.isEmpty() )
- insertEmail( e );
+ insertEmail( e );
@@ -1224,2 +1273,3 @@ void OContact::setDefaultEmail( const QString &v )
+
void OContact::insertEmails( const QStringList &v )
@@ -1227,11 +1277,16 @@ void OContact::insertEmails( const QStringList &v )
for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
- insertEmail( *it );
+ insertEmail( *it );
}
-int OContact::rtti() {
+
+
+int OContact::rtti()
+{
return OPimResolver::AddressBook;
}
+
+
void OContact::setUid( int i )
{
- OPimRecord::setUid(i);
- replace( Qtopia::AddressUid , QString::number(i));
+ OPimRecord::setUid( i );
+ replace( Qtopia::AddressUid , QString::number( i ) );
}