author | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
commit | f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf (patch) (side-by-side diff) | |
tree | 4044006e676c78370fdeccf960ea4214f13eabd2 /libopie2/opiepim/ocontact.cpp | |
parent | 2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (diff) | |
download | opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.zip opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.gz opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.bz2 |
cosmetics
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 235 |
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,6 +1,6 @@ /* 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. .>+-= @@ -27,41 +27,25 @@ Boston, MA 02111-1307, USA. */ -/********************************************************************** -** 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> #include <qstylesheet.h> #include <qfileinfo.h> #include <qmap.h> +/* STD */ #include <stdio.h> /*! @@ -76,22 +60,20 @@ */ -namespace Opie { +namespace Opie +{ /*! Creates a new, empty contact. */ -OContact::OContact() - : OPimRecord(), mMap(), d( 0 ) -{ -} +OContact::OContact():OPimRecord(), mMap(), d( 0 ) +{} /*! \internal Creates a new contact. The properties of the contact are 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 ]; if ( !cats.isEmpty() ) @@ -99,10 +81,12 @@ 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() ); // if ( !uidStr.isEmpty() ) @@ -113,8 +97,7 @@ OContact::OContact( const QMap<int, QString> &fromMap ) : Destroys a contact. */ OContact::~OContact() -{ -} +{} /*! \fn void OContact::setTitle( const QString &str ) Sets the title of the contact to \a str. @@ -481,17 +464,20 @@ QString OContact::toRichText() const text += Qtopia::escapeString(value) + " "; 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>"; // 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); marker = true; @@ -499,49 +485,62 @@ 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() ) text += "<br>"; text += Qtopia::escapeString(value); if ( state ) text += ", " + Qtopia::escapeString(state); - } else if ( !state.isEmpty() ){ + } + else if ( !state.isEmpty() ) + { text += "<br>" + Qtopia::escapeString(state); marker = true; } 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; } @@ -549,44 +548,51 @@ QString OContact::toRichText() const } } - if ( !(value = businessCountry()).isEmpty() ){ + if ( !( value = businessCountry() ).isEmpty() ) + { text += "<br>" + Qtopia::escapeString(value); marker = true; } // rest of Business data str = office(); - if ( !str.isEmpty() ){ + if ( !str.isEmpty() ) + { text += "<br><b>" + QObject::tr("Office: ") + "</b>" + Qtopia::escapeString(str); marker = true; } str = businessWebpage(); - if ( !str.isEmpty() ){ + 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() ){ + 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() ){ + 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() ){ + 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() ){ + if ( !str.isEmpty() ) + { text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>" + Qtopia::escapeString(str); marker = true; @@ -596,48 +602,61 @@ 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() ) text += "<br>"; text += Qtopia::escapeString(value); if ( !state.isEmpty() ) text += ", " + Qtopia::escapeString(state); - } else if (!state.isEmpty()) { + } + else if ( !state.isEmpty() ) + { text += "<br>" + Qtopia::escapeString(state); marker = true; } 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; } @@ -645,32 +664,37 @@ QString OContact::toRichText() const } } - if ( !(value = homeCountry()).isEmpty() ){ + if ( !( value = homeCountry() ).isEmpty() ) + { text += "<br>" + Qtopia::escapeString(value); marker = true; } // 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); marker = true; } str = homePhone(); - if ( !str.isEmpty() ){ + 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() ){ + 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() ){ + if ( !str.isEmpty() ) + { text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>" + Qtopia::escapeString(str); marker = true; @@ -697,7 +721,8 @@ QString OContact::toRichText() const text += "<br><b>" + QObject::tr("Manager: ") + "</b>" + Qtopia::escapeString(str); str = gender(); - if ( !str.isEmpty() && str.toInt() != 0 ) { + if ( !str.isEmpty() && str.toInt() != 0 ) + { text += "<br>"; if ( str.toInt() == 1 ) str = QObject::tr( "Male" ); @@ -709,12 +734,14 @@ QString OContact::toRichText() const if ( !str.isEmpty() ) 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>" + Qtopia::escapeString(str); @@ -730,13 +757,15 @@ QString OContact::toRichText() const + Qtopia::escapeString(str); // categories - if ( categoryNames("Contacts").count() ){ + if ( categoryNames( "Contacts" ).count() ) + { text += "<br><b>" + QObject::tr( "Category:") + "</b> "; text += categoryNames("Contacts").join(", "); } // notes last - if ( !(value = notes()).isEmpty() ) { + if ( !( value = notes() ).isEmpty() ) + { text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; QRegExp reg("\n"); @@ -837,22 +866,26 @@ QString OContact::fullName() const QString suffix = find( Qtopia::Suffix ); 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 += " "; name += suffix; @@ -900,7 +933,8 @@ QStringList OContact::emailList() const QString emailStr = emails(); QStringList r; - if ( !emailStr.isEmpty() ) { + if ( !emailStr.isEmpty() ) + { qDebug(" emailstr "); QStringList l = QStringList::split( emailSeparator(), emailStr ); for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) @@ -946,10 +980,12 @@ 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 ) { + 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; @@ -1061,8 +1097,10 @@ 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 ) { + for ( it = mMap.begin(); it != mMap.end(); ++it ) + { + if ( ( *it ).find( r ) > -1 ) + { setLastHitField( it.key() ); match = true; break; @@ -1076,13 +1114,14 @@ QString OContact::toShortText() const { return ( fullName() ); } + + QString OContact::type() const { return QString::fromLatin1( "OContact" ); } - class QString OContact::recordField( int pos ) const { QStringList SLFIELDS = fields(); // ?? why this ? (se) @@ -1099,7 +1138,8 @@ 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 ); return; @@ -1117,7 +1157,8 @@ 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 ); return; @@ -1127,6 +1168,7 @@ void OContact::setAnniversary( const QDate &v ) replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); } + /*! \fn QDate OContact::birthday() const Returns the birthday of the contact. */ @@ -1163,7 +1205,8 @@ void OContact::insertEmail( const QString &v ) QString def = defaultEmail(); // 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; } @@ -1178,6 +1221,7 @@ void OContact::insertEmail( const QString &v ) replace( Qtopia::Emails, emailsStr ); } + void OContact::removeEmail( const QString &v ) { QString e = v.simplifyWhiteSpace(); @@ -1197,7 +1241,8 @@ void OContact::removeEmail( const QString &v ) replace( Qtopia::Emails, emailsStr ); // 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() ) clearEmails(); @@ -1205,11 +1250,15 @@ void OContact::removeEmail( const QString &v ) setDefaultEmail( emails.first() ); } } + + void OContact::clearEmails() { mMap.remove( Qtopia::DefaultEmail ); mMap.remove( Qtopia::Emails ); } + + void OContact::setDefaultEmail( const QString &v ) { QString e = v.simplifyWhiteSpace(); @@ -1222,14 +1271,20 @@ void OContact::setDefaultEmail( const QString &v ) } + void OContact::insertEmails( const QStringList &v ) { for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) insertEmail( *it ); } -int OContact::rtti() { + + +int OContact::rtti() +{ return OPimResolver::AddressBook; } + + void OContact::setUid( int i ) { OPimRecord::setUid(i); |