summaryrefslogtreecommitdiff
path: root/libopie/pim/ocontact.cpp
Side-by-side diff
Diffstat (limited to 'libopie/pim/ocontact.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp9
1 files changed, 0 insertions, 9 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 96a5f65..a38b62b 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -822,265 +822,256 @@ void OContact::setFileAs()
if ( !lastName.isEmpty() && !firstName.isEmpty()
&& !middleName.isEmpty() )
fileas = lastName + ", " + firstName + " " + middleName;
else if ( !lastName.isEmpty() && !firstName.isEmpty() )
fileas = lastName + ", " + firstName;
else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
!middleName.isEmpty() )
fileas = firstName + ( firstName.isEmpty() ? "" : " " )
+ middleName + ( middleName.isEmpty() ? "" : " " )
+ lastName;
replace( Qtopia::FileAs, fileas );
}
/*!
\internal
Appends the contact information to \a buf.
*/
void OContact::save( QString &buf ) const
{
static const QStringList SLFIELDS = fields();
// I'm expecting "<Contact " in front of this...
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) + "\" ";
}
}
buf += customToXml();
if ( categories().count() > 0 )
buf += "Categories=\"" + idsToString( categories() ) + "\" ";
buf += "Uid=\"" + QString::number( uid() ) + "\" ";
// You need to close this yourself
}
/*!
\internal
Returns the list of fields belonging to a contact
Never change order of this list ! It has to be regarding
enum AddressBookFields !!
*/
QStringList OContact::fields()
{
QStringList list;
list.append( "Title" ); // Not Used!
list.append( "FirstName" );
list.append( "MiddleName" );
list.append( "LastName" );
list.append( "Suffix" );
list.append( "FileAs" );
list.append( "JobTitle" );
list.append( "Department" );
list.append( "Company" );
list.append( "BusinessPhone" );
list.append( "BusinessFax" );
list.append( "BusinessMobile" );
list.append( "DefaultEmail" );
list.append( "Emails" );
list.append( "HomePhone" );
list.append( "HomeFax" );
list.append( "HomeMobile" );
list.append( "BusinessStreet" );
list.append( "BusinessCity" );
list.append( "BusinessState" );
list.append( "BusinessZip" );
list.append( "BusinessCountry" );
list.append( "BusinessPager" );
list.append( "BusinessWebPage" );
list.append( "Office" );
list.append( "Profession" );
list.append( "Assistant" );
list.append( "Manager" );
list.append( "HomeStreet" );
list.append( "HomeCity" );
list.append( "HomeState" );
list.append( "HomeZip" );
list.append( "HomeCountry" );
list.append( "HomeWebPage" );
list.append( "Spouse" );
list.append( "Gender" );
list.append( "Birthday" );
list.append( "Anniversary" );
list.append( "Nickname" );
list.append( "Children" );
list.append( "Notes" );
list.append( "Groups" );
return list;
}
/*!
Sets the list of email address for contact to those contained in \a str.
Email address should be separated by ';'s.
*/
void OContact::setEmails( const QString &str )
{
replace( Qtopia::Emails, str );
if ( str.isEmpty() )
setDefaultEmail( QString::null );
}
/*!
Sets the list of children for the contact to those contained in \a str.
*/
void OContact::setChildren( const QString &str )
{
replace( Qtopia::Children, str );
}
/*!
- Returns TRUE if the contact matches the regular expression \a regexp.
- Otherwise returns FALSE.
-*/
-bool OContact::match( const QString &regexp ) const
-{
- return match(QRegExp(regexp));
-}
-
-/*!
\overload
Returns TRUE if the contact matches the regular expression \a regexp.
Otherwise returns FALSE.
*/
bool OContact::match( const QRegExp &r ) const
{
bool match;
match = false;
QMap<int, QString>::ConstIterator it;
for ( it = mMap.begin(); it != mMap.end(); ++it ) {
if ( (*it).find( r ) > -1 ) {
match = true;
break;
}
}
return match;
}
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. If date is null
the current stored date will be removed.
*/
void OContact::setBirthday( const QDate &v )
{
if ( v.isNull() ){
qWarning( "Remove Birthday");
replace( Qtopia::Birthday, QString::null );
return;
}
if ( v.isValid() )
replace( Qtopia::Birthday, OConversion::dateToString( v ) );
}
/*! \fn void OContact::setAnniversary( const QDate &date )
Sets the anniversary of the contact to \a date. If date is
null, the current stored date will be removed.
*/
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 ) );
}
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
*/
QDate OContact::birthday() const
{
QString str = find( Qtopia::Birthday );
qWarning ("Birthday %s", str.latin1() );
if ( !str.isEmpty() )
return OConversion::dateFromString ( str );
else
return QDate();
}
/*! \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 OConversion::dateFromString ( 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;