summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/ocontact.cpp
authormickeyl <mickeyl>2004-02-23 13:15:42 (UTC)
committer mickeyl <mickeyl>2004-02-23 13:15:42 (UTC)
commitf9f0c26d9ac94586ffc36efa1b582ece3dbc43cf (patch) (side-by-side diff)
tree4044006e676c78370fdeccf960ea4214f13eabd2 /libopie2/opiepim/ocontact.cpp
parent2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (diff)
downloadopie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.zip
opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.gz
opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.bz2
cosmetics
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
@@ -1,5 +1,5 @@
/*
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>
.=l.
@@ -28,33 +28,16 @@
*/
-/**********************************************************************
-** 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>
#include <qpe/timestring.h>
#include <qpe/config.h>
+/* QT */
#include <qobject.h>
#include <qregexp.h>
@@ -63,4 +46,5 @@
#include <qmap.h>
+/* STD */
#include <stdio.h>
@@ -77,12 +61,11 @@
-namespace Opie {
+namespace Opie
+{
/*!
Creates a new, empty contact.
*/
-OContact::OContact()
- : OPimRecord(), mMap(), d( 0 )
-{
-}
+OContact::OContact():OPimRecord(), mMap(), d( 0 )
+{}
/*!
@@ -91,6 +74,5 @@ OContact::OContact()
set from \a fromMap.
*/
-OContact::OContact( const QMap<int, QString> &fromMap ) :
- OPimRecord(), mMap( fromMap ), d( 0 )
+OContact::OContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
{
QString cats = mMap[ Qtopia::AddressCategory ];
@@ -100,8 +82,10 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
QString uidStr = find( Qtopia::AddressUid );
- if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
+ if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
+ {
qWarning( "Invalid UID found. Generate new one.." );
setUid( uidGen().generate() );
- }else
+ }
+ else
setUid( uidStr.toInt() );
@@ -114,6 +98,5 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
*/
OContact::~OContact()
-{
-}
+{}
/*! \fn void OContact::setTitle( const QString &str )
@@ -482,9 +465,11 @@ QString OContact::toRichText() const
comp = company();
- if ( !(value = department()).isEmpty() ) {
+ if ( !( value = department() ).isEmpty() )
+ {
text += Qtopia::escapeString(value);
if ( comp )
text += ", " + Qtopia::escapeString(comp);
- }else if ( comp )
+ }
+ else if ( comp )
text += "<br>" + Qtopia::escapeString(comp);
text += "<br><hr>";
@@ -492,5 +477,6 @@ QString OContact::toRichText() const
// defailt email
QString defEmail = defaultEmail();
- if ( !defEmail.isEmpty() ){
+ if ( !defEmail.isEmpty() )
+ {
text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>"
+ Qtopia::escapeString(defEmail);
@@ -500,23 +486,29 @@ QString OContact::toRichText() const
// business address
if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
- !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
+ !businessZip().isEmpty() || !businessCountry().isEmpty() )
+ {
text += QObject::tr( "<br><b>Work Address:</b>" );
marker = true;
}
- if ( !(value = businessStreet()).isEmpty() ){
+ if ( !( value = businessStreet() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
}
- switch( addressformat ){
- case Zip_City_State:{ // Zip_Code City, State
+ switch ( addressformat )
+ {
+ case Zip_City_State:
+ { // Zip_Code City, State
state = businessState();
- if ( !(value = businessZip()).isEmpty() ){
+ if ( !( value = businessZip() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value) + " ";
marker = true;
}
- if ( !(value = businessCity()).isEmpty() ) {
+ if ( !( value = businessCity() ).isEmpty() )
+ {
marker = true;
if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
@@ -525,5 +517,7 @@ QString OContact::toRichText() const
if ( state )
text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
@@ -531,16 +525,21 @@ QString OContact::toRichText() const
break;
}
- case City_State_Zip:{ // City, State Zip_Code
+ case City_State_Zip:
+ { // City, State Zip_Code
state = businessState();
- if ( !(value = businessCity()).isEmpty() ) {
+ if ( !( value = businessCity() ).isEmpty() )
+ {
marker = true;
text += "<br>" + Qtopia::escapeString(value);
if ( state )
text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
}
- if ( !(value = businessZip()).isEmpty() ){
+ if ( !( value = businessZip() ).isEmpty() )
+ {
text += " " + Qtopia::escapeString(value);
marker = true;
@@ -550,5 +549,6 @@ QString OContact::toRichText() const
}
- if ( !(value = businessCountry()).isEmpty() ){
+ if ( !( value = businessCountry() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
@@ -557,5 +557,6 @@ QString OContact::toRichText() const
// rest of Business data
str = office();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b>" + QObject::tr("Office: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -563,5 +564,6 @@ QString OContact::toRichText() const
}
str = businessWebpage();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -569,5 +571,6 @@ QString OContact::toRichText() const
}
str = businessPhone();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -575,5 +578,6 @@ QString OContact::toRichText() const
}
str = businessFax();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -581,5 +585,6 @@ QString OContact::toRichText() const
}
str = businessMobile();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -587,5 +592,6 @@ QString OContact::toRichText() const
}
str = businessPager();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -597,22 +603,28 @@ QString OContact::toRichText() const
// home address
if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
- !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
+ !homeZip().isEmpty() || !homeCountry().isEmpty() )
+ {
text += QObject::tr( "<br><b>Home Address:</b>" );
marker = true;
}
- if ( !(value = homeStreet()).isEmpty() ){
+ if ( !( value = homeStreet() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
}
- switch( addressformat ){
- case Zip_City_State:{ // Zip_Code City, State
+ switch ( addressformat )
+ {
+ case Zip_City_State:
+ { // Zip_Code City, State
state = homeState();
- if ( !(value = homeZip()).isEmpty() ){
+ if ( !( value = homeZip() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value) + " ";
marker = true;
}
- if ( !(value = homeCity()).isEmpty() ) {
+ if ( !( value = homeCity() ).isEmpty() )
+ {
marker = true;
if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
@@ -621,5 +633,7 @@ QString OContact::toRichText() const
if ( !state.isEmpty() )
text += ", " + Qtopia::escapeString(state);
- } else if (!state.isEmpty()) {
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
@@ -627,16 +641,21 @@ QString OContact::toRichText() const
break;
}
- case City_State_Zip:{ // City, State Zip_Code
+ case City_State_Zip:
+ { // City, State Zip_Code
state = homeState();
- if ( !(value = homeCity()).isEmpty() ) {
+ if ( !( value = homeCity() ).isEmpty() )
+ {
marker = true;
text += "<br>" + Qtopia::escapeString(value);
if ( state )
text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
}
- if ( !(value = homeZip()).isEmpty() ){
+ if ( !( value = homeZip() ).isEmpty() )
+ {
text += " " + Qtopia::escapeString(value);
marker = true;
@@ -646,5 +665,6 @@ QString OContact::toRichText() const
}
- if ( !(value = homeCountry()).isEmpty() ){
+ if ( !( value = homeCountry() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
@@ -653,5 +673,6 @@ QString OContact::toRichText() const
// rest of Home data
str = homeWebpage();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -659,5 +680,6 @@ QString OContact::toRichText() const
}
str = homePhone();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -665,5 +687,6 @@ QString OContact::toRichText() const
}
str = homeFax();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -671,5 +694,6 @@ QString OContact::toRichText() const
}
str = homeMobile();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -698,5 +722,6 @@ QString OContact::toRichText() const
+ Qtopia::escapeString(str);
str = gender();
- if ( !str.isEmpty() && str.toInt() != 0 ) {
+ if ( !str.isEmpty() && str.toInt() != 0 )
+ {
text += "<br>";
if ( str.toInt() == 1 )
@@ -710,10 +735,12 @@ QString OContact::toRichText() const
text += "<br><b>" + QObject::tr("Spouse: ") + "</b>"
+ Qtopia::escapeString(str);
- if ( birthday().isValid() ){
+ if ( birthday().isValid() )
+ {
str = TimeString::numberDateString( birthday() );
text += "<br><b>" + QObject::tr("Birthday: ") + "</b>"
+ Qtopia::escapeString(str);
}
- if ( anniversary().isValid() ){
+ if ( anniversary().isValid() )
+ {
str = TimeString::numberDateString( anniversary() );
text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>"
@@ -731,5 +758,6 @@ QString OContact::toRichText() const
// categories
- if ( categoryNames("Contacts").count() ){
+ if ( categoryNames( "Contacts" ).count() )
+ {
text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames("Contacts").join(", ");
@@ -737,5 +765,6 @@ QString OContact::toRichText() const
// notes last
- if ( !(value = notes()).isEmpty() ) {
+ if ( !( value = notes() ).isEmpty() )
+ {
text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
QRegExp reg("\n");
@@ -838,20 +867,24 @@ QString OContact::fullName() const
QString name = title;
- if ( !firstName.isEmpty() ) {
+ if ( !firstName.isEmpty() )
+ {
if ( !name.isEmpty() )
name += " ";
name += firstName;
}
- if ( !middleName.isEmpty() ) {
+ if ( !middleName.isEmpty() )
+ {
if ( !name.isEmpty() )
name += " ";
name += middleName;
}
- if ( !lastName.isEmpty() ) {
+ if ( !lastName.isEmpty() )
+ {
if ( !name.isEmpty() )
name += " ";
name += lastName;
}
- if ( !suffix.isEmpty() ) {
+ if ( !suffix.isEmpty() )
+ {
if ( !name.isEmpty() )
name += " ";
@@ -901,5 +934,6 @@ QStringList OContact::emailList() const
QStringList r;
- if ( !emailStr.isEmpty() ) {
+ if ( !emailStr.isEmpty() )
+ {
qDebug(" emailstr ");
QStringList l = QStringList::split( emailSeparator(), emailStr );
@@ -947,8 +981,10 @@ void OContact::save( QString &buf ) const
// I'm expecting "<Contact " in front of this...
for ( QMap<int, QString>::ConstIterator it = mMap.begin();
- it != mMap.end(); ++it ) {
+ it != mMap.end(); ++it )
+ {
const QString &value = it.data();
int key = it.key();
- if ( !value.isEmpty() ) {
+ if ( !value.isEmpty() )
+ {
if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
continue;
@@ -1062,6 +1098,8 @@ bool OContact::match( const QRegExp &r ) const
match = false;
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;
@@ -1077,4 +1115,6 @@ QString OContact::toShortText() const
return ( fullName() );
}
+
+
QString OContact::type() const
{
@@ -1083,5 +1123,4 @@ QString OContact::type() const
-
class QString OContact::recordField( int pos ) const
{
@@ -1100,5 +1139,6 @@ class QString OContact::recordField( int pos ) const
void OContact::setBirthday( const QDate &v )
{
- if ( v.isNull() ){
+ if ( v.isNull() )
+ {
qWarning( "Remove Birthday");
replace( Qtopia::Birthday, QString::null );
@@ -1118,5 +1158,6 @@ void OContact::setBirthday( const QDate &v )
void OContact::setAnniversary( const QDate &v )
{
- if ( v.isNull() ){
+ if ( v.isNull() )
+ {
qWarning( "Remove Anniversary");
replace( Qtopia::Anniversary, QString::null );
@@ -1128,4 +1169,5 @@ void OContact::setAnniversary( const QDate &v )
}
+
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
@@ -1164,5 +1206,6 @@ void OContact::insertEmail( const QString &v )
// if no default, set it as the default email and don't insert
- if ( def.isEmpty() ) {
+ if ( def.isEmpty() )
+ {
setDefaultEmail( e ); // will insert into the list for us
return;
@@ -1179,4 +1222,5 @@ void OContact::insertEmail( const QString &v )
}
+
void OContact::removeEmail( const QString &v )
{
@@ -1198,5 +1242,6 @@ void OContact::removeEmail( const QString &v )
// if default, then replace the default email with the first one
- if ( def == e ) {
+ if ( def == e )
+ {
//qDebug("removeEmail is default; setting new default");
if ( !emails.count() )
@@ -1206,4 +1251,6 @@ void OContact::removeEmail( const QString &v )
}
}
+
+
void OContact::clearEmails()
{
@@ -1211,4 +1258,6 @@ void OContact::clearEmails()
mMap.remove( Qtopia::Emails );
}
+
+
void OContact::setDefaultEmail( const QString &v )
{
@@ -1223,4 +1272,5 @@ void OContact::setDefaultEmail( const QString &v )
}
+
void OContact::insertEmails( const QStringList &v )
{
@@ -1228,7 +1278,12 @@ void OContact::insertEmails( const QStringList &v )
insertEmail( *it );
}
-int OContact::rtti() {
+
+
+int OContact::rtti()
+{
return OPimResolver::AddressBook;
}
+
+
void OContact::setUid( int i )
{