summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimcontact.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/core/opimcontact.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimcontact.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp
index c1e06c8..48a74d0 100644
--- a/libopie2/opiepim/core/opimcontact.cpp
+++ b/libopie2/opiepim/core/opimcontact.cpp
@@ -13,101 +13,103 @@
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#define QTOPIA_INTERNAL_CONTACT_MRE
#include "opimcontact.h"
/* OPIE */
#include <opie2/opimresolver.h>
#include <opie2/opimdateconversion.h>
+#include <opie2/odebug.h>
+
#include <qpe/stringutil.h>
#include <qpe/timestring.h>
#include <qpe/config.h>
/* QT */
#include <qstylesheet.h>
/* STD */
#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
*/
namespace Opie
{
/*!
Creates a new, empty contact.
*/
OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 )
{}
/*!
\internal
Creates a new contact. The properties of the contact are
set from \a fromMap.
*/
OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
{
QString cats = mMap[ Qtopia::AddressCategory ];
if ( !cats.isEmpty() )
setCategories( idsFromString( cats ) );
QString uidStr = find( Qtopia::AddressUid );
if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
{
- qWarning( "Invalid UID found. Generate new one.." );
+ owarn << "Invalid UID found. Generate new one.." << oendl;
setUid( uidGen().generate() );
}
else
setUid( uidStr.toInt() );
// if ( !uidStr.isEmpty() )
- // setUid( uidStr.toInt() );
+ // setUid( uidStr.toInt() );
}
/*!
Destroys a contact.
*/
OPimContact::~OPimContact()
{}
/*! \fn void OPimContact::setTitle( const QString &str )
Sets the title of the contact to \a str.
*/
/*! \fn void OPimContact::setFirstName( const QString &str )
Sets the first name of the contact to \a str.
*/
/*! \fn void OPimContact::setMiddleName( const QString &str )
Sets the middle name of the contact to \a str.
*/
/*! \fn void OPimContact::setLastName( const QString &str )
Sets the last name of the contact to \a str.
*/
@@ -910,49 +912,49 @@ QStringList OPimContact::childrenList() const
email list
*/
/*! \fn void OPimContact::clearEmails()
Clears the email list.
*/
/*! \fn void OPimContact::insertEmails( const QStringList &emailList )
Appends the \a emailList to the exiting email list
*/
/*!
Returns a list of email addresses belonging to the contact, including
the default email address.
*/
QStringList OPimContact::emailList() const
{
QString emailStr = emails();
QStringList r;
if ( !emailStr.isEmpty() )
{
- qDebug( " emailstr " );
+ odebug << " emailstr " << oendl;
QStringList l = QStringList::split( emailSeparator(), emailStr );
for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
r += ( *it ).simplifyWhiteSpace();
}
return r;
}
/*!
\overload
Generates the string for the contact to be filed as from the first,
middle and last name of the contact.
*/
void OPimContact::setFileAs()
{
QString lastName, firstName, middleName, fileas;
lastName = find( Qtopia::LastName );
firstName = find( Qtopia::FirstName );
middleName = find( Qtopia::MiddleName );
if ( !lastName.isEmpty() && !firstName.isEmpty()
&& !middleName.isEmpty() )
fileas = lastName + ", " + firstName + " " + middleName;
@@ -1115,172 +1117,172 @@ QString OPimContact::toShortText() const
QString OPimContact::type() const
{
return QString::fromLatin1( "OPimContact" );
}
class QString OPimContact::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 OPimContact::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 OPimContact::setBirthday( const QDate &v )
{
if ( v.isNull() )
{
- qWarning( "Remove Birthday" );
+ owarn << "Remove Birthday" << oendl;
replace( Qtopia::Birthday, QString::null );
return ;
}
if ( v.isValid() )
replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) );
}
/*! \fn void OPimContact::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 OPimContact::setAnniversary( const QDate &v )
{
if ( v.isNull() )
{
- qWarning( "Remove Anniversary" );
+ owarn << "Remove Anniversary" << oendl;
replace( Qtopia::Anniversary, QString::null );
return ;
}
if ( v.isValid() )
replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) );
}
/*! \fn QDate OPimContact::birthday() const
Returns the birthday of the contact.
*/
QDate OPimContact::birthday() const
{
QString str = find( Qtopia::Birthday );
// qWarning ("Birthday %s", str.latin1() );
if ( !str.isEmpty() )
return OPimDateConversion::dateFromString ( str );
else
return QDate();
}
/*! \fn QDate OPimContact::anniversary() const
Returns the anniversary of the contact.
*/
QDate OPimContact::anniversary() const
{
QDate empty;
QString str = find( Qtopia::Anniversary );
// qWarning ("Anniversary %s", str.latin1() );
if ( !str.isEmpty() )
return OPimDateConversion::dateFromString ( str );
else
return empty;
}
void OPimContact::insertEmail( const QString &v )
{
- //qDebug("insertEmail %s", v.latin1());
+ //odebug << "insertEmail " << v << "" << oendl;
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 OPimContact::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());
+ //odebug << " removing email from list " << e << "" << oendl;
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");
+ //odebug << "removeEmail is default; setting new default" << oendl;
if ( !emails.count() )
clearEmails();
else // setDefaultEmail will remove e from the list
setDefaultEmail( emails.first() );
}
}
void OPimContact::clearEmails()
{
mMap.remove( Qtopia::DefaultEmail );
mMap.remove( Qtopia::Emails );
}
void OPimContact::setDefaultEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
- //qDebug("OPimContact::setDefaultEmail %s", e.latin1());
+ //odebug << "OPimContact::setDefaultEmail " << e << "" << oendl;
replace( Qtopia::DefaultEmail, e );
if ( !e.isEmpty() )
insertEmail( e );
}
void OPimContact::insertEmails( const QStringList &v )
{
for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
insertEmail( *it );
}
int OPimContact::rtti() const
{
return OPimResolver::AddressBook;
}
void OPimContact::setUid( int i )
{
OPimRecord::setUid( i );