summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp168
-rw-r--r--libopie/pim/ocontact.h82
-rw-r--r--libopie2/opiepim/ocontact.cpp168
-rw-r--r--libopie2/opiepim/ocontact.h82
4 files changed, 294 insertions, 206 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 6f648ac..21fc088 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1,52 +1,54 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
**
** This file is part of the Qtopia Environment.
**
** 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 "ocontact.h"
#include "../../library/backend/vobject_p.h"
#include "../../library/backend/qfiledirect_p.h"
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
+#include <qpe/timestring.h>
#include <qobject.h>
#include <qregexp.h>
#include <qstylesheet.h>
#include <qfileinfo.h>
#include <qmap.h>
#include <stdio.h>
/*!
\class Contact contact.h
\brief The Contact class holds the data of an address book entry.
This data includes information the name of the person, contact
information, and business information such as deparment and job title.
\ingroup qtopiaemb
\ingroup qtopiadesktop
*/
Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia );
/*!
Creates a new, empty contact.
@@ -204,56 +206,48 @@ OContact::~OContact()
/*! \fn void OContact::setBusinessWebpage( const QString &str )
Sets the business webpage of the contact to \a str.
*/
/*! \fn void OContact::setProfession( const QString &str )
Sets the profession of the contact to \a str.
*/
/*! \fn void OContact::setAssistant( const QString &str )
Sets the assistant of the contact to \a str.
*/
/*! \fn void OContact::setManager( const QString &str )
Sets the manager of the contact to \a str.
*/
/*! \fn void OContact::setSpouse( const QString &str )
Sets the spouse of the contact to \a str.
*/
/*! \fn void OContact::setGender( const QString &str )
Sets the gender of the contact to \a str.
*/
-/*! \fn void OContact::setBirthday( const QString &str )
- Sets the birthday for the contact to \a str.
-*/
-
-/*! \fn void OContact::setAnniversary( const QString &str )
- Sets the anniversary of the contact to \a str.
-*/
-
/*! \fn void OContact::setNickname( const QString &str )
Sets the nickname of the contact to \a str.
*/
/*! \fn void OContact::setNotes( const QString &str )
Sets the notes about the contact to \a str.
*/
/*! \fn QString OContact::title() const
Returns the title of the contact.
*/
/*! \fn QString OContact::firstName() const
Returns the first name of the contact.
*/
/*! \fn QString OContact::middleName() const
Returns the middle name of the contact.
*/
/*! \fn QString OContact::lastName() const
Returns the last name of the contact.
*/
@@ -365,56 +359,48 @@ OContact::~OContact()
/*! \fn QString OContact::businessFax() const
Returns the business fax number of the contact.
*/
/*! \fn QString OContact::businessMobile() const
Returns the business mobile number of the contact.
*/
/*! \fn QString OContact::businessPager() const
Returns the business pager number of the contact.
*/
/*! \fn QString OContact::businessWebpage() const
Returns the business webpage of the contact.
*/
/*! \fn QString OContact::spouse() const
Returns the spouse of the contact.
*/
/*! \fn QString OContact::gender() const
Returns the gender of the contact.
*/
-/*! \fn QString OContact::birthday() const
- Returns the birthday of the contact.
-*/
-
-/*! \fn QString OContact::anniversary() const
- Returns the anniversary of the contact.
-*/
-
/*! \fn QString OContact::nickname() const
Returns the nickname of the contact.
*/
/*! \fn QString OContact::children() const
Returns the children of the contact.
*/
/*! \fn QString OContact::notes() const
Returns the notes relating to the the contact.
*/
/*! \fn QString OContact::groups() const
\internal
Returns the groups for the contact.
*/
/*! \fn QStringList OContact::groupList() const
\internal
*/
/*! \fn QString OContact::field(int) const
\internal
*/
@@ -564,56 +550,58 @@ QString OContact::toRichText() const
str = profession();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Profession: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = assistant();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Assistant: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = manager();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Manager: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = gender();
if ( !str.isEmpty() && str.toInt() != 0 ) {
if ( str.toInt() == 1 )
str = QObject::tr( "Male" );
else if ( str.toInt() == 2 )
str = QObject::tr( "Female" );
text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
}
str = spouse();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Spouse: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
- str = birthday();
- if ( !str.isEmpty() )
- text += "<b>" + QObject::tr("Birthday: ") + "</b>"
- + Qtopia::escapeString(str) + "<br>";
- str = anniversary();
- if ( !str.isEmpty() )
- text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
- + Qtopia::escapeString(str) + "<br>";
+ if ( !birthday().isNull() ){
+ str = TimeString::numberDateString( birthday() );
+ text += "<b>" + QObject::tr("Birthday: ") + "</b>"
+ + Qtopia::escapeString(str) + "<br>";
+ }
+ if ( !anniversary().isNull() ){
+ str = TimeString::numberDateString( anniversary() );
+ text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
+ + Qtopia::escapeString(str) + "<br>";
+ }
str = nickname();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Nickname: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
// notes last
if ( (value = notes()) ) {
QRegExp reg("\n");
//QString tmp = Qtopia::escapeString(value);
QString tmp = QStyleSheet::convertFromPlainText(value);
//tmp.replace( reg, "<br>" );
text += "<br>" + tmp + "<br>";
}
return text;
}
/*!
\internal
*/
void OContact::insert( int key, const QString &v )
{
QString value = v.stripWhiteSpace();
if ( value.isEmpty() )
@@ -1113,65 +1101,65 @@ static VObject *createVObject( const OContact &c )
safeAddProp( work_phone, VCCellularProp );
work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
safeAddProp( work_phone, VCWorkProp );
safeAddProp( work_phone, VCFaxProp );
work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
safeAddProp( work_phone, VCWorkProp );
safeAddProp( work_phone, VCPagerProp );
url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
safeAddProp( url, VCWorkProp );
VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
safeAddProp( title, VCWorkProp );
QStringList emails = c.emailList();
emails.prepend( c.defaultEmail() );
for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
safeAddProp( email, VCInternetProp );
}
safeAddPropValue( vcard, VCNoteProp, c.notes() );
- safeAddPropValue( vcard, VCBirthDateProp, c.birthday() );
+ safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) );
if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
VObject *org = safeAddProp( vcard, VCOrgProp );
safeAddPropValue( org, VCOrgNameProp, c.company() );
safeAddPropValue( org, VCOrgUnitProp, c.department() );
safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
}
// some values we have to export as custom fields
safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
- safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() );
+ safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
return vcard;
}
/*!
\internal
*/
static OContact parseVObject( VObject *obj )
{
OContact c;
VObjectIterator it;
initPropIterator( &it, obj );
while( moreIteration( &it ) ) {
VObject *o = nextVObject( &it );
QCString name = vObjectName( o );
QCString value = vObjectStringZValue( o );
if ( name == VCNameProp ) {
VObjectIterator nit;
initPropIterator( &nit, o );
while( moreIteration( &nit ) ) {
@@ -1332,49 +1320,49 @@ static OContact parseVObject( VObject *obj )
c.setDepartment( value );
else if ( name == VCOrgUnit2Prop )
c.setOffice( value );
}
}
else if ( name == VCTitleProp ) {
c.setJobTitle( value );
}
else if ( name == "X-Qtopia-Profession" ) {
c.setProfession( value );
}
else if ( name == "X-Qtopia-Manager" ) {
c.setManager( value );
}
else if ( name == "X-Qtopia-Assistant" ) {
c.setAssistant( value );
}
else if ( name == "X-Qtopia-Spouse" ) {
c.setSpouse( value );
}
else if ( name == "X-Qtopia-Gender" ) {
c.setGender( value );
}
else if ( name == "X-Qtopia-Anniversary" ) {
- c.setAnniversary( value );
+ c.setAnniversary( TimeConversion::fromString( value ) );
}
else if ( name == "X-Qtopia-Nickname" ) {
c.setNickname( value );
}
else if ( name == "X-Qtopia-Children" ) {
c.setChildren( value );
}
#if 0
else {
printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
VObjectIterator nit;
initPropIterator( &nit, o );
while( moreIteration( &nit ) ) {
VObject *o = nextVObject( &nit );
QCString name = vObjectName( o );
QString value = vObjectStringZValue( o );
printf(" subprop: %s = %s\n", name.data(), value.latin1() );
}
}
#endif
}
c.setFileAs();
@@ -1472,24 +1460,150 @@ bool OContact::match( const QRegExp &r ) const
QString OContact::toShortText() const
{
return ( fullName() );
}
QString OContact::type() const
{
return QString::fromLatin1( "OContact" );
}
// Definition is missing ! (se)
QMap<QString,QString> OContact::toExtraMap() const
{
qWarning ("Function not implemented: OContact::toExtraMap()");
QMap <QString,QString> useless;
return useless;
}
class QString OContact::recordField( int pos ) const
{
QStringList SLFIELDS = fields(); // ?? why this ? (se)
return SLFIELDS[pos];
}
+
+// In future releases, we should store birthday and anniversary
+// internally as QDate instead of QString !
+// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
+
+/*! \fn void OContact::setBirthday( const QDate& date )
+ Sets the birthday for the contact to \a date.
+*/
+void OContact::setBirthday( const QDate &v )
+{
+ if ( ( !v.isNull() ) && ( v.isValid() ) )
+ replace( Qtopia::Birthday, TimeConversion::toString( v ) );
+
+}
+
+
+/*! \fn void OContact::setAnniversary( const QDate &date )
+ Sets the anniversary of the contact to \a date.
+*/
+void OContact::setAnniversary( const QDate &v )
+{
+ if ( ( !v.isNull() ) && ( v.isValid() ) )
+ replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
+}
+
+/*! \fn QDate OContact::birthday() const
+ Returns the birthday of the contact.
+*/
+QDate OContact::birthday() const
+{
+ QDate empty;
+ QString str = find( Qtopia::Birthday );
+ qWarning ("Birthday %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return TimeConversion::fromString ( str );
+ else
+ return empty;
+}
+
+
+/*! \fn QDate OContact::anniversary() const
+ Returns the anniversary of the contact.
+*/
+QDate OContact::anniversary() const
+{
+ QDate empty;
+ QString str = find( Qtopia::Anniversary );
+ qWarning ("Anniversary %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return TimeConversion::fromString ( str );
+ else
+ return empty;
+}
+
+
+void OContact::insertEmail( const QString &v )
+{
+ //qDebug("insertEmail %s", v.latin1());
+ QString e = v.simplifyWhiteSpace();
+ QString def = defaultEmail();
+
+ // 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;
+ }
+
+ // otherwise, insert assuming doesn't already exist
+ QString emailsStr = find( Qtopia::Emails );
+ if ( emailsStr.contains( e ))
+ return;
+ if ( !emailsStr.isEmpty() )
+ emailsStr += emailSeparator();
+ emailsStr += e;
+ replace( Qtopia::Emails, emailsStr );
+}
+
+void OContact::removeEmail( const QString &v )
+{
+ QString e = v.simplifyWhiteSpace();
+ QString def = defaultEmail();
+ QString emailsStr = find( Qtopia::Emails );
+ QStringList emails = emailList();
+
+ // otherwise, must first contain it
+ if ( !emailsStr.contains( e ) )
+ return;
+
+ // remove it
+ //qDebug(" removing email from list %s", e.latin1());
+ emails.remove( e );
+ // reset the string
+ emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
+ replace( Qtopia::Emails, emailsStr );
+
+ // 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() );
+ }
+}
+void OContact::clearEmails()
+{
+ mMap.remove( Qtopia::DefaultEmail );
+ mMap.remove( Qtopia::Emails );
+}
+void OContact::setDefaultEmail( const QString &v )
+{
+ QString e = v.simplifyWhiteSpace();
+
+ //qDebug("OContact::setDefaultEmail %s", e.latin1());
+ replace( Qtopia::DefaultEmail, e );
+
+ if ( !e.isEmpty() )
+ insertEmail( e );
+
+}
+
+void OContact::insertEmails( const QStringList &v )
+{
+ for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
+ insertEmail( *it );
+}
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index f916cf2..9e83150 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -1,50 +1,52 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
**
** This file is part of the Qtopia Environment.
**
** 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.
**
**********************************************************************/
#ifndef __OCONTACT_H__
#define __OCONTACT_H__
#include <opie/opimrecord.h>
#include <qpe/recordfields.h>
+#include <qdatetime.h>
#include <qstringlist.h>
#if defined(QPC_TEMPLATEDLL)
// MOC_SKIP_BEGIN
QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
// MOC_SKIP_END
#endif
class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se)
class QPC_EXPORT OContact : public OPimRecord
{
friend class DataSet;
public:
OContact();
OContact( const QMap<int, QString> &fromMap );
virtual ~OContact();
static void writeVCard( const QString &filename, const QValueList<OContact> &contacts);
static void writeVCard( const QString &filename, const OContact &c );
static QValueList<OContact> readVCard( const QString &filename );
enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
@@ -75,50 +77,50 @@ public:
void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
// business
void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
// personal
void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
- void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); }
- void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); }
+ void setBirthday( const QDate &v );
+ void setAnniversary( const QDate &v );
void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
void setChildren( const QString &v );
// other
void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
bool match( const QString &regexp ) const;
// DON'T ATTEMPT TO USE THIS
#ifdef QTOPIA_INTERNAL_CONTACT_MRE
bool match( const QRegExp &regexp ) const;
#endif
// // custom
// void setCustomField( const QString &key, const QString &v )
// { replace(Custom- + key, v ); }
// name
QString fullName() const;
QString title() const { return find( Qtopia::Title ); }
QString firstName() const { return find( Qtopia::FirstName ); }
QString middleName() const { return find( Qtopia::MiddleName ); }
QString lastName() const { return find( Qtopia::LastName ); }
QString suffix() const { return find( Qtopia::Suffix ); }
@@ -152,50 +154,50 @@ public:
QString businessState() const { return find( Qtopia::BusinessState ); }
QString businessZip() const { return find( Qtopia::BusinessZip ); }
QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
QString jobTitle() const { return find( Qtopia::JobTitle ); }
QString department() const { return find( Qtopia::Department ); }
QString office() const { return find( Qtopia::Office ); }
QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
QString businessFax() const { return find( Qtopia::BusinessFax ); }
QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
QString businessPager() const { return find( Qtopia::BusinessPager ); }
QString profession() const { return find( Qtopia::Profession ); }
QString assistant() const { return find( Qtopia::Assistant ); }
QString manager() const { return find( Qtopia::Manager ); }
/** Multi line string containing all non-empty address info in the form
* Street
* City, State Zip
* Country
*/
QString displayBusinessAddress() const;
//personal
QString spouse() const { return find( Qtopia::Spouse ); }
QString gender() const { return find( Qtopia::Gender ); }
- QString birthday() const { return find( Qtopia::Birthday ); }
- QString anniversary() const { return find( Qtopia::Anniversary ); }
+ QDate birthday() const;
+ QDate anniversary() const;
QString nickname() const { return find( Qtopia::Nickname ); }
QString children() const { return find( Qtopia::Children ); }
QStringList childrenList() const;
// other
QString notes() const { return find( Qtopia::Notes ); }
QString groups() const { return find( Qtopia::Groups ); }
QStringList groupList() const;
// // custom
// const QString &customField( const QString &key )
// { return find( Custom- + key ); }
static QStringList fields();
static QStringList trfields();
static QStringList untrfields();
QString toRichText() const;
QMap<int, QString> toMap() const;
QString field( int key ) const { return find( key ); }
// journaling...
void saveJournal( journal_action action, const QString &key = QString::null );
@@ -218,98 +220,26 @@ public:
private:
friend class AbEditor;
friend class AbTable;
friend class AddressBookAccessPrivate;
friend class XMLIO;
void insert( int key, const QString &value );
void replace( int key, const QString &value );
QString find( int key ) const;
QString displayAddress( const QString &street,
const QString &city,
const QString &state,
const QString &zip,
const QString &country ) const;
Qtopia::UidGen &uidGen() { return sUidGen; }
static Qtopia::UidGen sUidGen;
QMap<int, QString> mMap;
ContactPrivate *d;
};
-// these methods are inlined to keep binary compatability with Qtopia 1.5
-inline void OContact::insertEmail( const QString &v )
-{
- //qDebug("insertEmail %s", v.latin1());
- QString e = v.simplifyWhiteSpace();
- QString def = defaultEmail();
-
- // 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;
- }
-
- // otherwise, insert assuming doesn't already exist
- QString emailsStr = find( Qtopia::Emails );
- if ( emailsStr.contains( e ))
- return;
- if ( !emailsStr.isEmpty() )
- emailsStr += emailSeparator();
- emailsStr += e;
- replace( Qtopia::Emails, emailsStr );
-}
-
-inline void OContact::removeEmail( const QString &v )
-{
- QString e = v.simplifyWhiteSpace();
- QString def = defaultEmail();
- QString emailsStr = find( Qtopia::Emails );
- QStringList emails = emailList();
-
- // otherwise, must first contain it
- if ( !emailsStr.contains( e ) )
- return;
-
- // remove it
- //qDebug(" removing email from list %s", e.latin1());
- emails.remove( e );
- // reset the string
- emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
- replace( Qtopia::Emails, emailsStr );
-
- // 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() );
- }
-}
-inline void OContact::clearEmails()
-{
- mMap.remove( Qtopia::DefaultEmail );
- mMap.remove( Qtopia::Emails );
-}
-inline void OContact::setDefaultEmail( const QString &v )
-{
- QString e = v.simplifyWhiteSpace();
-
- //qDebug("OContact::setDefaultEmail %s", e.latin1());
- replace( Qtopia::DefaultEmail, e );
-
- if ( !e.isEmpty() )
- insertEmail( e );
-
-}
-
-inline void OContact::insertEmails( const QStringList &v )
-{
- for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
- insertEmail( *it );
-}
#endif
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 6f648ac..21fc088 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1,52 +1,54 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
**
** This file is part of the Qtopia Environment.
**
** 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 "ocontact.h"
#include "../../library/backend/vobject_p.h"
#include "../../library/backend/qfiledirect_p.h"
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
+#include <qpe/timestring.h>
#include <qobject.h>
#include <qregexp.h>
#include <qstylesheet.h>
#include <qfileinfo.h>
#include <qmap.h>
#include <stdio.h>
/*!
\class Contact contact.h
\brief The Contact class holds the data of an address book entry.
This data includes information the name of the person, contact
information, and business information such as deparment and job title.
\ingroup qtopiaemb
\ingroup qtopiadesktop
*/
Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia );
/*!
Creates a new, empty contact.
@@ -204,56 +206,48 @@ OContact::~OContact()
/*! \fn void OContact::setBusinessWebpage( const QString &str )
Sets the business webpage of the contact to \a str.
*/
/*! \fn void OContact::setProfession( const QString &str )
Sets the profession of the contact to \a str.
*/
/*! \fn void OContact::setAssistant( const QString &str )
Sets the assistant of the contact to \a str.
*/
/*! \fn void OContact::setManager( const QString &str )
Sets the manager of the contact to \a str.
*/
/*! \fn void OContact::setSpouse( const QString &str )
Sets the spouse of the contact to \a str.
*/
/*! \fn void OContact::setGender( const QString &str )
Sets the gender of the contact to \a str.
*/
-/*! \fn void OContact::setBirthday( const QString &str )
- Sets the birthday for the contact to \a str.
-*/
-
-/*! \fn void OContact::setAnniversary( const QString &str )
- Sets the anniversary of the contact to \a str.
-*/
-
/*! \fn void OContact::setNickname( const QString &str )
Sets the nickname of the contact to \a str.
*/
/*! \fn void OContact::setNotes( const QString &str )
Sets the notes about the contact to \a str.
*/
/*! \fn QString OContact::title() const
Returns the title of the contact.
*/
/*! \fn QString OContact::firstName() const
Returns the first name of the contact.
*/
/*! \fn QString OContact::middleName() const
Returns the middle name of the contact.
*/
/*! \fn QString OContact::lastName() const
Returns the last name of the contact.
*/
@@ -365,56 +359,48 @@ OContact::~OContact()
/*! \fn QString OContact::businessFax() const
Returns the business fax number of the contact.
*/
/*! \fn QString OContact::businessMobile() const
Returns the business mobile number of the contact.
*/
/*! \fn QString OContact::businessPager() const
Returns the business pager number of the contact.
*/
/*! \fn QString OContact::businessWebpage() const
Returns the business webpage of the contact.
*/
/*! \fn QString OContact::spouse() const
Returns the spouse of the contact.
*/
/*! \fn QString OContact::gender() const
Returns the gender of the contact.
*/
-/*! \fn QString OContact::birthday() const
- Returns the birthday of the contact.
-*/
-
-/*! \fn QString OContact::anniversary() const
- Returns the anniversary of the contact.
-*/
-
/*! \fn QString OContact::nickname() const
Returns the nickname of the contact.
*/
/*! \fn QString OContact::children() const
Returns the children of the contact.
*/
/*! \fn QString OContact::notes() const
Returns the notes relating to the the contact.
*/
/*! \fn QString OContact::groups() const
\internal
Returns the groups for the contact.
*/
/*! \fn QStringList OContact::groupList() const
\internal
*/
/*! \fn QString OContact::field(int) const
\internal
*/
@@ -564,56 +550,58 @@ QString OContact::toRichText() const
str = profession();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Profession: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = assistant();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Assistant: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = manager();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Manager: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = gender();
if ( !str.isEmpty() && str.toInt() != 0 ) {
if ( str.toInt() == 1 )
str = QObject::tr( "Male" );
else if ( str.toInt() == 2 )
str = QObject::tr( "Female" );
text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
}
str = spouse();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Spouse: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
- str = birthday();
- if ( !str.isEmpty() )
- text += "<b>" + QObject::tr("Birthday: ") + "</b>"
- + Qtopia::escapeString(str) + "<br>";
- str = anniversary();
- if ( !str.isEmpty() )
- text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
- + Qtopia::escapeString(str) + "<br>";
+ if ( !birthday().isNull() ){
+ str = TimeString::numberDateString( birthday() );
+ text += "<b>" + QObject::tr("Birthday: ") + "</b>"
+ + Qtopia::escapeString(str) + "<br>";
+ }
+ if ( !anniversary().isNull() ){
+ str = TimeString::numberDateString( anniversary() );
+ text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
+ + Qtopia::escapeString(str) + "<br>";
+ }
str = nickname();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Nickname: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
// notes last
if ( (value = notes()) ) {
QRegExp reg("\n");
//QString tmp = Qtopia::escapeString(value);
QString tmp = QStyleSheet::convertFromPlainText(value);
//tmp.replace( reg, "<br>" );
text += "<br>" + tmp + "<br>";
}
return text;
}
/*!
\internal
*/
void OContact::insert( int key, const QString &v )
{
QString value = v.stripWhiteSpace();
if ( value.isEmpty() )
@@ -1113,65 +1101,65 @@ static VObject *createVObject( const OContact &c )
safeAddProp( work_phone, VCCellularProp );
work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
safeAddProp( work_phone, VCWorkProp );
safeAddProp( work_phone, VCFaxProp );
work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
safeAddProp( work_phone, VCWorkProp );
safeAddProp( work_phone, VCPagerProp );
url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
safeAddProp( url, VCWorkProp );
VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
safeAddProp( title, VCWorkProp );
QStringList emails = c.emailList();
emails.prepend( c.defaultEmail() );
for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
safeAddProp( email, VCInternetProp );
}
safeAddPropValue( vcard, VCNoteProp, c.notes() );
- safeAddPropValue( vcard, VCBirthDateProp, c.birthday() );
+ safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) );
if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
VObject *org = safeAddProp( vcard, VCOrgProp );
safeAddPropValue( org, VCOrgNameProp, c.company() );
safeAddPropValue( org, VCOrgUnitProp, c.department() );
safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
}
// some values we have to export as custom fields
safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
- safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() );
+ safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
return vcard;
}
/*!
\internal
*/
static OContact parseVObject( VObject *obj )
{
OContact c;
VObjectIterator it;
initPropIterator( &it, obj );
while( moreIteration( &it ) ) {
VObject *o = nextVObject( &it );
QCString name = vObjectName( o );
QCString value = vObjectStringZValue( o );
if ( name == VCNameProp ) {
VObjectIterator nit;
initPropIterator( &nit, o );
while( moreIteration( &nit ) ) {
@@ -1332,49 +1320,49 @@ static OContact parseVObject( VObject *obj )
c.setDepartment( value );
else if ( name == VCOrgUnit2Prop )
c.setOffice( value );
}
}
else if ( name == VCTitleProp ) {
c.setJobTitle( value );
}
else if ( name == "X-Qtopia-Profession" ) {
c.setProfession( value );
}
else if ( name == "X-Qtopia-Manager" ) {
c.setManager( value );
}
else if ( name == "X-Qtopia-Assistant" ) {
c.setAssistant( value );
}
else if ( name == "X-Qtopia-Spouse" ) {
c.setSpouse( value );
}
else if ( name == "X-Qtopia-Gender" ) {
c.setGender( value );
}
else if ( name == "X-Qtopia-Anniversary" ) {
- c.setAnniversary( value );
+ c.setAnniversary( TimeConversion::fromString( value ) );
}
else if ( name == "X-Qtopia-Nickname" ) {
c.setNickname( value );
}
else if ( name == "X-Qtopia-Children" ) {
c.setChildren( value );
}
#if 0
else {
printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
VObjectIterator nit;
initPropIterator( &nit, o );
while( moreIteration( &nit ) ) {
VObject *o = nextVObject( &nit );
QCString name = vObjectName( o );
QString value = vObjectStringZValue( o );
printf(" subprop: %s = %s\n", name.data(), value.latin1() );
}
}
#endif
}
c.setFileAs();
@@ -1472,24 +1460,150 @@ bool OContact::match( const QRegExp &r ) const
QString OContact::toShortText() const
{
return ( fullName() );
}
QString OContact::type() const
{
return QString::fromLatin1( "OContact" );
}
// Definition is missing ! (se)
QMap<QString,QString> OContact::toExtraMap() const
{
qWarning ("Function not implemented: OContact::toExtraMap()");
QMap <QString,QString> useless;
return useless;
}
class QString OContact::recordField( int pos ) const
{
QStringList SLFIELDS = fields(); // ?? why this ? (se)
return SLFIELDS[pos];
}
+
+// In future releases, we should store birthday and anniversary
+// internally as QDate instead of QString !
+// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
+
+/*! \fn void OContact::setBirthday( const QDate& date )
+ Sets the birthday for the contact to \a date.
+*/
+void OContact::setBirthday( const QDate &v )
+{
+ if ( ( !v.isNull() ) && ( v.isValid() ) )
+ replace( Qtopia::Birthday, TimeConversion::toString( v ) );
+
+}
+
+
+/*! \fn void OContact::setAnniversary( const QDate &date )
+ Sets the anniversary of the contact to \a date.
+*/
+void OContact::setAnniversary( const QDate &v )
+{
+ if ( ( !v.isNull() ) && ( v.isValid() ) )
+ replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
+}
+
+/*! \fn QDate OContact::birthday() const
+ Returns the birthday of the contact.
+*/
+QDate OContact::birthday() const
+{
+ QDate empty;
+ QString str = find( Qtopia::Birthday );
+ qWarning ("Birthday %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return TimeConversion::fromString ( str );
+ else
+ return empty;
+}
+
+
+/*! \fn QDate OContact::anniversary() const
+ Returns the anniversary of the contact.
+*/
+QDate OContact::anniversary() const
+{
+ QDate empty;
+ QString str = find( Qtopia::Anniversary );
+ qWarning ("Anniversary %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return TimeConversion::fromString ( str );
+ else
+ return empty;
+}
+
+
+void OContact::insertEmail( const QString &v )
+{
+ //qDebug("insertEmail %s", v.latin1());
+ QString e = v.simplifyWhiteSpace();
+ QString def = defaultEmail();
+
+ // 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;
+ }
+
+ // otherwise, insert assuming doesn't already exist
+ QString emailsStr = find( Qtopia::Emails );
+ if ( emailsStr.contains( e ))
+ return;
+ if ( !emailsStr.isEmpty() )
+ emailsStr += emailSeparator();
+ emailsStr += e;
+ replace( Qtopia::Emails, emailsStr );
+}
+
+void OContact::removeEmail( const QString &v )
+{
+ QString e = v.simplifyWhiteSpace();
+ QString def = defaultEmail();
+ QString emailsStr = find( Qtopia::Emails );
+ QStringList emails = emailList();
+
+ // otherwise, must first contain it
+ if ( !emailsStr.contains( e ) )
+ return;
+
+ // remove it
+ //qDebug(" removing email from list %s", e.latin1());
+ emails.remove( e );
+ // reset the string
+ emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
+ replace( Qtopia::Emails, emailsStr );
+
+ // 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() );
+ }
+}
+void OContact::clearEmails()
+{
+ mMap.remove( Qtopia::DefaultEmail );
+ mMap.remove( Qtopia::Emails );
+}
+void OContact::setDefaultEmail( const QString &v )
+{
+ QString e = v.simplifyWhiteSpace();
+
+ //qDebug("OContact::setDefaultEmail %s", e.latin1());
+ replace( Qtopia::DefaultEmail, e );
+
+ if ( !e.isEmpty() )
+ insertEmail( e );
+
+}
+
+void OContact::insertEmails( const QStringList &v )
+{
+ for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
+ insertEmail( *it );
+}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index f916cf2..9e83150 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -1,50 +1,52 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
**
** This file is part of the Qtopia Environment.
**
** 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.
**
**********************************************************************/
#ifndef __OCONTACT_H__
#define __OCONTACT_H__
#include <opie/opimrecord.h>
#include <qpe/recordfields.h>
+#include <qdatetime.h>
#include <qstringlist.h>
#if defined(QPC_TEMPLATEDLL)
// MOC_SKIP_BEGIN
QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
// MOC_SKIP_END
#endif
class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se)
class QPC_EXPORT OContact : public OPimRecord
{
friend class DataSet;
public:
OContact();
OContact( const QMap<int, QString> &fromMap );
virtual ~OContact();
static void writeVCard( const QString &filename, const QValueList<OContact> &contacts);
static void writeVCard( const QString &filename, const OContact &c );
static QValueList<OContact> readVCard( const QString &filename );
enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
@@ -75,50 +77,50 @@ public:
void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
// business
void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
// personal
void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
- void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); }
- void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); }
+ void setBirthday( const QDate &v );
+ void setAnniversary( const QDate &v );
void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
void setChildren( const QString &v );
// other
void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
bool match( const QString &regexp ) const;
// DON'T ATTEMPT TO USE THIS
#ifdef QTOPIA_INTERNAL_CONTACT_MRE
bool match( const QRegExp &regexp ) const;
#endif
// // custom
// void setCustomField( const QString &key, const QString &v )
// { replace(Custom- + key, v ); }
// name
QString fullName() const;
QString title() const { return find( Qtopia::Title ); }
QString firstName() const { return find( Qtopia::FirstName ); }
QString middleName() const { return find( Qtopia::MiddleName ); }
QString lastName() const { return find( Qtopia::LastName ); }
QString suffix() const { return find( Qtopia::Suffix ); }
@@ -152,50 +154,50 @@ public:
QString businessState() const { return find( Qtopia::BusinessState ); }
QString businessZip() const { return find( Qtopia::BusinessZip ); }
QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
QString jobTitle() const { return find( Qtopia::JobTitle ); }
QString department() const { return find( Qtopia::Department ); }
QString office() const { return find( Qtopia::Office ); }
QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
QString businessFax() const { return find( Qtopia::BusinessFax ); }
QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
QString businessPager() const { return find( Qtopia::BusinessPager ); }
QString profession() const { return find( Qtopia::Profession ); }
QString assistant() const { return find( Qtopia::Assistant ); }
QString manager() const { return find( Qtopia::Manager ); }
/** Multi line string containing all non-empty address info in the form
* Street
* City, State Zip
* Country
*/
QString displayBusinessAddress() const;
//personal
QString spouse() const { return find( Qtopia::Spouse ); }
QString gender() const { return find( Qtopia::Gender ); }
- QString birthday() const { return find( Qtopia::Birthday ); }
- QString anniversary() const { return find( Qtopia::Anniversary ); }
+ QDate birthday() const;
+ QDate anniversary() const;
QString nickname() const { return find( Qtopia::Nickname ); }
QString children() const { return find( Qtopia::Children ); }
QStringList childrenList() const;
// other
QString notes() const { return find( Qtopia::Notes ); }
QString groups() const { return find( Qtopia::Groups ); }
QStringList groupList() const;
// // custom
// const QString &customField( const QString &key )
// { return find( Custom- + key ); }
static QStringList fields();
static QStringList trfields();
static QStringList untrfields();
QString toRichText() const;
QMap<int, QString> toMap() const;
QString field( int key ) const { return find( key ); }
// journaling...
void saveJournal( journal_action action, const QString &key = QString::null );
@@ -218,98 +220,26 @@ public:
private:
friend class AbEditor;
friend class AbTable;
friend class AddressBookAccessPrivate;
friend class XMLIO;
void insert( int key, const QString &value );
void replace( int key, const QString &value );
QString find( int key ) const;
QString displayAddress( const QString &street,
const QString &city,
const QString &state,
const QString &zip,
const QString &country ) const;
Qtopia::UidGen &uidGen() { return sUidGen; }
static Qtopia::UidGen sUidGen;
QMap<int, QString> mMap;
ContactPrivate *d;
};
-// these methods are inlined to keep binary compatability with Qtopia 1.5
-inline void OContact::insertEmail( const QString &v )
-{
- //qDebug("insertEmail %s", v.latin1());
- QString e = v.simplifyWhiteSpace();
- QString def = defaultEmail();
-
- // 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;
- }
-
- // otherwise, insert assuming doesn't already exist
- QString emailsStr = find( Qtopia::Emails );
- if ( emailsStr.contains( e ))
- return;
- if ( !emailsStr.isEmpty() )
- emailsStr += emailSeparator();
- emailsStr += e;
- replace( Qtopia::Emails, emailsStr );
-}
-
-inline void OContact::removeEmail( const QString &v )
-{
- QString e = v.simplifyWhiteSpace();
- QString def = defaultEmail();
- QString emailsStr = find( Qtopia::Emails );
- QStringList emails = emailList();
-
- // otherwise, must first contain it
- if ( !emailsStr.contains( e ) )
- return;
-
- // remove it
- //qDebug(" removing email from list %s", e.latin1());
- emails.remove( e );
- // reset the string
- emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
- replace( Qtopia::Emails, emailsStr );
-
- // 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() );
- }
-}
-inline void OContact::clearEmails()
-{
- mMap.remove( Qtopia::DefaultEmail );
- mMap.remove( Qtopia::Emails );
-}
-inline void OContact::setDefaultEmail( const QString &v )
-{
- QString e = v.simplifyWhiteSpace();
-
- //qDebug("OContact::setDefaultEmail %s", e.latin1());
- replace( Qtopia::DefaultEmail, e );
-
- if ( !e.isEmpty() )
- insertEmail( e );
-
-}
-
-inline void OContact::insertEmails( const QStringList &v )
-{
- for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
- insertEmail( *it );
-}
#endif