-rw-r--r-- | library/backend/contact.h | 4 | ||||
-rw-r--r-- | library/backend/timeconversion.cpp | 15 | ||||
-rw-r--r-- | library/library.pro | 2 |
3 files changed, 16 insertions, 5 deletions
diff --git a/library/backend/contact.h b/library/backend/contact.h index 4999430..2294986 100644 --- a/library/backend/contact.h +++ b/library/backend/contact.h @@ -14,293 +14,293 @@ ** 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 __CONTACT_H__ #define __CONTACT_H__ #include <qtopia/private/palmtoprecord.h> #include <qtopia/private/recordfields.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; class QPC_EXPORT Contact : public Qtopia::Record { friend class DataSet; public: Contact(); Contact( const QMap<int, QString> &fromMap ); virtual ~Contact(); static void writeVCard( const QString &filename, const QValueList<Contact> &contacts); static void writeVCard( const QString &filename, const Contact &c ); static QValueList<Contact> readVCard( const QString &filename ); enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } void setFileAs(); // default email address void setDefaultEmail( const QString &v ); // inserts email to list and ensure's doesn't already exist void insertEmail( const QString &v ); void removeEmail( const QString &v ); void clearEmails(); void insertEmails( const QStringList &v ); // home void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 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 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 ®exp ) const; // DON'T ATTEMPT TO USE THIS #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 3c25922..df7b0d5 100644 --- a/library/backend/timeconversion.cpp +++ b/library/backend/timeconversion.cpp @@ -1,228 +1,237 @@ /**********************************************************************
** 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 r = QString::number( d.day() ) + "." +
+ 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;
+ //qDebug("TimeConversion::toString %s", r.latin1());
+
+ return r;
}
QDate TimeConversion::fromString( const QString &datestr )
{
+ 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();
#else
tzset();
#endif
struct tm thetime;
QCString str = s.copy();
str.replace(QRegExp("-"), "" );
str.replace(QRegExp(":"), "" );
str.stripWhiteSpace();
str = str.lower();
int i = str.find( "t" );
QCString date;
QCString timestr;
if ( i != -1 ) {
date = str.left( i );
timestr = str.mid( i+1 );
} else {
date = str;
}
// qDebug("--- parsing ISO time---");
memset( &thetime, 0, sizeof(tm) );
thetime.tm_year = 100;
thetime.tm_mon = 0;
thetime.tm_mday = 0;
thetime.tm_hour = 0;
thetime.tm_min = 0;
thetime.tm_sec = 0;
// qDebug("date = %s", date.data() );
switch( date.length() ) {
case 8:
thetime.tm_mday = date.right( 2 ).toInt();
case 6:
thetime.tm_mon = date.mid( 4, 2 ).toInt() - 1;
case 4:
thetime.tm_year = date.left( 4 ).toInt();
thetime.tm_year -= 1900;
break;
default:
break;
}
int tzoff = 0;
bool inLocalTime = FALSE;
if ( timestr.find( 'z' ) == (int)timestr.length() - 1 )
// UTC
timestr = timestr.left( timestr.length() -1 );
else {
int plus = timestr.find( "+" );
int minus = timestr.find( "-" );
if ( plus != -1 || minus != -1 ) {
// have a timezone offset
plus = (plus != -1) ? plus : minus;
QCString off = timestr.mid( plus );
timestr = timestr.left( plus );
int tzoffhour = 0;
int tzoffmin = 0;
switch( off.length() ) {
case 5:
tzoffmin = off.mid(3).toInt();
case 3:
tzoffhour = off.left(3).toInt();
default:
break;
}
tzoff = 60*tzoffhour + tzoffmin;
} else
inLocalTime = TRUE;
}
// get the time:
switch( timestr.length() ) {
case 6:
thetime.tm_sec = timestr.mid( 4 ).toInt();
case 4:
thetime.tm_min = timestr.mid( 2, 2 ).toInt();
case 2:
thetime.tm_hour = timestr.left( 2 ).toInt();
default:
break;
}
int tzloc = 0;
time_t tmp = time( 0 );
if ( !inLocalTime ) {
// have to get the offset between gmt and local time
struct tm *lt = localtime( &tmp );
tzloc = mktime( lt );
struct tm *ut = gmtime( &tmp );
tzloc -= mktime( ut );
}
// qDebug("time: %d %d %d, tzloc=%d, tzoff=%d", thetime->tm_hour, thetime->tm_min, thetime->tm_sec,
diff --git a/library/library.pro b/library/library.pro index fba98f8..142c609 100644 --- a/library/library.pro +++ b/library/library.pro @@ -1,141 +1,143 @@ TEMPLATE = lib CONFIG += qt warn_on release HEADERS = calendar.h \ global.h \ resource.h \ xmlreader.h \ mimetype.h \ menubutton.h \ network.h \ networkinterface.h \ filemanager.h \ fontmanager.h \ qdawg.h \ datebookmonth.h \ fileselector.h \ fileselector_p.h \ imageedit.h \ qcopenvelope_qws.h \ qpedecoration_qws.h \ qpeapplication.h \ qpestyle.h \ qpedialog.h \ lightstyle.h \ config.h \ applnk.h \ sound.h \ tzselect.h \ qmath.h \ datebookdb.h \ alarmserver.h \ process.h \ password.h \ timestring.h \ fontfactoryinterface.h \ fontdatabase.h \ power.h \ storage.h \ qpemessagebox.h \ timeconversion.h \ qpedebug.h \ qpemenubar.h \ qpetoolbar.h \ backend/categories.h \ stringutil.h \ backend/palmtoprecord.h \ backend/task.h \ backend/event.h \ backend/contact.h\ categorymenu.h \ categoryedit_p.h \ categoryselect.h \ categorywidget.h \ ir.h \ backend/vobject_p.h \ findwidget_p.h \ finddialog.h \ lnkproperties.h \ windowdecorationinterface.h \ textcodecinterface.h \ imagecodecinterface.h SOURCES = calendar.cpp \ global.cpp \ xmlreader.cpp \ mimetype.cpp \ menubutton.cpp \ network.cpp \ networkinterface.cpp \ filemanager.cpp \ fontmanager.cpp \ qdawg.cpp \ datebookmonth.cpp \ fileselector.cpp \ imageedit.cpp \ resource.cpp \ qpedecoration_qws.cpp \ qcopenvelope_qws.cpp \ qpeapplication.cpp \ qpestyle.cpp \ qpedialog.cpp \ lightstyle.cpp \ config.cpp \ applnk.cpp \ sound.cpp \ tzselect.cpp \ qmath.c \ datebookdb.cpp \ alarmserver.cpp \ password.cpp \ process.cpp \ process_unix.cpp \ timestring.cpp \ fontdatabase.cpp \ power.cpp \ storage.cpp \ qpemessagebox.cpp \ backend/timeconversion.cpp \ qpedebug.cpp \ qpemenubar.cpp \ qpetoolbar.cpp \ backend/categories.cpp \ backend/stringutil.cpp \ backend/palmtoprecord.cpp \ backend/task.cpp \ backend/event.cpp \ backend/contact.cpp \ categorymenu.cpp \ categoryedit_p.cpp \ categoryselect.cpp \ categorywidget.cpp \ ir.cpp \ backend/vcc_yacc.cpp \ backend/vobject.cpp \ findwidget_p.cpp \ finddialog.cpp \ lnkproperties.cpp +# QPE crashes on my Notebook if it tries to play sound +DEFINES = QT_NO_SOUND # Qt 3 compatibility HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp INCLUDEPATH += $(OPIEDIR)/include backend LIBS += -ldl -lcrypt -lm INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui TARGET = qpe DESTDIR = $(QTDIR)/lib$(PROJMAK) # This is set by configure$(OPIEDIR). VERSION = 1.5.0.1 TRANSLATIONS = ../i18n/de/libqpe.ts \ ../i18n/en/libqpe.ts \ ../i18n/es/libqpe.ts \ ../i18n/fr/libqpe.ts \ ../i18n/hu/libqpe.ts \ ../i18n/ja/libqpe.ts \ ../i18n/ko/libqpe.ts \ ../i18n/no/libqpe.ts \ ../i18n/pl/libqpe.ts \ ../i18n/pt/libqpe.ts \ ../i18n/pt_BR/libqpe.ts \ ../i18n/sl/libqpe.ts \ ../i18n/zh_CN/libqpe.ts \ ../i18n/it/libqpe.ts \ ../i18n/zh_TW/libqpe.ts |