-rw-r--r-- | library/backend/contact.h | 4 | ||||
-rw-r--r-- | library/backend/timeconversion.cpp | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/library/backend/contact.h b/library/backend/contact.h index 2294986..4999430 100644 --- a/library/backend/contact.h +++ b/library/backend/contact.h @@ -110,197 +110,197 @@ public: #ifdef QTOPIA_INTERNAL_CONTACT_MRE bool match( const QRegExp ®exp ) 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 ); } QString fileAs() const { return find( Qtopia::FileAs ); } // email QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } QStringList emailList() const; // home QString homeStreet() const { return find( Qtopia::HomeStreet ); } QString homeCity() const { return find( Qtopia::HomeCity ); } QString homeState() const { return find( Qtopia::HomeState ); } QString homeZip() const { return find( Qtopia::HomeZip ); } QString homeCountry() const { return find( Qtopia::HomeCountry ); } QString homePhone() const { return find( Qtopia::HomePhone ); } QString homeFax() const { return find( Qtopia::HomeFax ); } QString homeMobile() const { return find( Qtopia::HomeMobile ); } QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } /** Multi line string containing all non-empty address info in the form * Street * City, State Zip * Country */ QString displayHomeAddress() const; // business QString company() const { return find( Qtopia::Company ); } QString businessStreet() const { return find( Qtopia::BusinessStreet ); } QString businessCity() const { return find( Qtopia::BusinessCity ); } 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 ); } 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(); 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 ); void save( QString &buf ) const; void setUid( int i ) { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } - void setEmails( const QString &v ); - QString emails() const { return find( Qtopia::Emails ); } private: friend class AbEditor; friend class AbTable; friend class AddressBookAccessPrivate; friend class XMLIO; QString emailSeparator() const { return " "; } // the emails should be seperated by a comma + void setEmails( const QString &v ); + QString emails() const { return find( Qtopia::Emails ); } 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 Contact::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 Contact::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 Contact::clearEmails() { mMap.remove( Qtopia::DefaultEmail ); mMap.remove( Qtopia::Emails ); } inline void Contact::setDefaultEmail( const QString &v ) { QString e = v.simplifyWhiteSpace(); //qDebug("Contact::setDefaultEmail %s", e.latin1()); replace( Qtopia::DefaultEmail, e ); if ( !e.isEmpty() ) insertEmail( e ); } inline void Contact::insertEmails( const QStringList &v ) { for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) insertEmail( *it ); } #endif diff --git a/library/backend/timeconversion.cpp b/library/backend/timeconversion.cpp index df7b0d5..6551697 100644 --- a/library/backend/timeconversion.cpp +++ b/library/backend/timeconversion.cpp @@ -1,140 +1,140 @@ /**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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.
**
**********************************************************************/
#include <qglobal.h>
#include <qtopia/timeconversion.h>
#include <qregexp.h>
#include <stdlib.h>
QString TimeConversion::toString( const QDate &d )
{
- QString empty;
- if ( d.isNull() )
- return empty;
+// QString empty;
+// if ( d.isNull() )
+// return empty;
QString r = QString::number( d.day() ) + "." +
QString::number( d.month() ) + "." +
QString::number( d.year() );
//qDebug("TimeConversion::toString %s", r.latin1());
return r;
}
QDate TimeConversion::fromString( const QString &datestr )
{
- QDate empty;
- if ( datestr.isEmpty() )
- return empty;
+// QDate empty;
+// if ( datestr.isEmpty() )
+// return empty;
int monthPos = datestr.find('.');
int yearPos = datestr.find('.', monthPos+1 );
if ( monthPos == -1 || yearPos == -1 ) {
qDebug("fromString didn't find . in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, yearPos );
return QDate();
}
int d = datestr.left( monthPos ).toInt();
int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt();
int y = datestr.mid( yearPos+1 ).toInt();
QDate date ( y,m,d );
//qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, yearPos);
return date;
}
time_t TimeConversion::toUTC( const QDateTime& dt )
{
time_t tmp;
struct tm *lt;
#if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64)
_tzset();
#else
tzset();
#endif
// get a tm structure from the system to get the correct tz_name
tmp = time( 0 );
lt = localtime( &tmp );
lt->tm_sec = dt.time().second();
lt->tm_min = dt.time().minute();
lt->tm_hour = dt.time().hour();
lt->tm_mday = dt.date().day();
lt->tm_mon = dt.date().month() - 1; // 0-11 instead of 1-12
lt->tm_year = dt.date().year() - 1900; // year - 1900
//lt->tm_wday = dt.date().dayOfWeek(); ignored anyway
//lt->tm_yday = dt.date().dayOfYear(); ignored anyway
lt->tm_wday = -1;
lt->tm_yday = -1;
// tm_isdst negative -> mktime will find out about DST
lt->tm_isdst = -1;
// keep tm_zone and tm_gmtoff
tmp = mktime( lt );
return tmp;
}
QDateTime TimeConversion::fromUTC( time_t time )
{
struct tm *lt;
#if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64)
_tzset();
#else
tzset();
#endif
lt = localtime( &time );
QDateTime dt;
dt.setDate( QDate( lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday ) );
dt.setTime( QTime( lt->tm_hour, lt->tm_min, lt->tm_sec ) );
return dt;
}
int TimeConversion::secsTo( const QDateTime &from, const QDateTime &to )
{
return toUTC( to ) - toUTC( from );
}
QCString TimeConversion::toISO8601( const QDate &d )
{
time_t tmp = toUTC( d );
struct tm *utc = gmtime( &tmp );
QCString str;
str.sprintf("%04d%02d%02d", (utc->tm_year + 1900), utc->tm_mon+1, utc->tm_mday );
return str;
}
QCString TimeConversion::toISO8601( const QDateTime &dt )
{
time_t tmp = toUTC( dt );
struct tm *utc = gmtime( &tmp );
QCString str;
str.sprintf("%04d%02d%02dT%02d%02d%02dZ",
(utc->tm_year + 1900), utc->tm_mon+1, utc->tm_mday,
utc->tm_hour, utc->tm_min, utc->tm_sec );
return str;
}
QDateTime TimeConversion::fromISO8601( const QCString &s )
{
#if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64)
_tzset();
|