summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp168
-rw-r--r--libopie/pim/ocontact.h82
-rw-r--r--libopie2/opiepim/ocontact.cpp168
-rw-r--r--libopie2/opiepim/ocontact.h82
4 files changed, 294 insertions, 206 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 6f648ac..21fc088 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1,4 +1,5 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
**
** This file is part of the Qtopia Environment.
@@ -27,4 +28,5 @@
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
+#include <qpe/timestring.h>
#include <qobject.h>
@@ -226,12 +228,4 @@ OContact::~OContact()
*/
-/*! \fn void OContact::setBirthday( const QString &str )
- Sets the birthday for the contact to \a str.
-*/
-
-/*! \fn void OContact::setAnniversary( const QString &str )
- Sets the anniversary of the contact to \a str.
-*/
-
/*! \fn void OContact::setNickname( const QString &str )
Sets the nickname of the contact to \a str.
@@ -387,12 +381,4 @@ OContact::~OContact()
*/
-/*! \fn QString OContact::birthday() const
- Returns the birthday of the contact.
-*/
-
-/*! \fn QString OContact::anniversary() const
- Returns the anniversary of the contact.
-*/
-
/*! \fn QString OContact::nickname() const
Returns the nickname of the contact.
@@ -586,12 +572,14 @@ QString OContact::toRichText() const
text += "<b>" + QObject::tr("Spouse: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
- str = birthday();
- if ( !str.isEmpty() )
- text += "<b>" + QObject::tr("Birthday: ") + "</b>"
- + Qtopia::escapeString(str) + "<br>";
- str = anniversary();
- if ( !str.isEmpty() )
- text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
- + Qtopia::escapeString(str) + "<br>";
+ if ( !birthday().isNull() ){
+ str = TimeString::numberDateString( birthday() );
+ text += "<b>" + QObject::tr("Birthday: ") + "</b>"
+ + Qtopia::escapeString(str) + "<br>";
+ }
+ if ( !anniversary().isNull() ){
+ str = TimeString::numberDateString( anniversary() );
+ text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
+ + Qtopia::escapeString(str) + "<br>";
+ }
str = nickname();
if ( !str.isEmpty() )
@@ -1135,5 +1123,5 @@ static VObject *createVObject( const OContact &c )
safeAddPropValue( vcard, VCNoteProp, c.notes() );
- safeAddPropValue( vcard, VCBirthDateProp, c.birthday() );
+ safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) );
if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
@@ -1151,5 +1139,5 @@ static VObject *createVObject( const OContact &c )
safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
- safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() );
+ safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
@@ -1354,5 +1342,5 @@ static OContact parseVObject( VObject *obj )
}
else if ( name == "X-Qtopia-Anniversary" ) {
- c.setAnniversary( value );
+ c.setAnniversary( TimeConversion::fromString( value ) );
}
else if ( name == "X-Qtopia-Nickname" ) {
@@ -1494,2 +1482,128 @@ class QString OContact::recordField( int pos ) const
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.
+*/
+void OContact::setBirthday( const QDate &v )
+{
+ if ( ( !v.isNull() ) && ( v.isValid() ) )
+ replace( Qtopia::Birthday, TimeConversion::toString( v ) );
+
+}
+
+
+/*! \fn void OContact::setAnniversary( const QDate &date )
+ Sets the anniversary of the contact to \a date.
+*/
+void OContact::setAnniversary( const QDate &v )
+{
+ if ( ( !v.isNull() ) && ( v.isValid() ) )
+ replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
+}
+
+/*! \fn QDate OContact::birthday() const
+ Returns the birthday of the contact.
+*/
+QDate OContact::birthday() const
+{
+ QDate empty;
+ QString str = find( Qtopia::Birthday );
+ qWarning ("Birthday %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return TimeConversion::fromString ( str );
+ else
+ return empty;
+}
+
+
+/*! \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 TimeConversion::fromString ( 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;
+ replace( Qtopia::Emails, emailsStr );
+}
+
+void OContact::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() );
+ }
+}
+void OContact::clearEmails()
+{
+ mMap.remove( Qtopia::DefaultEmail );
+ mMap.remove( Qtopia::Emails );
+}
+void OContact::setDefaultEmail( const QString &v )
+{
+ QString e = v.simplifyWhiteSpace();
+
+ //qDebug("OContact::setDefaultEmail %s", e.latin1());
+ replace( Qtopia::DefaultEmail, e );
+
+ if ( !e.isEmpty() )
+ insertEmail( e );
+
+}
+
+void OContact::insertEmails( const QStringList &v )
+{
+ for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
+ insertEmail( *it );
+}
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index f916cf2..9e83150 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -1,4 +1,5 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
**
** This file is part of the Qtopia Environment.
@@ -25,4 +26,5 @@
#include <qpe/recordfields.h>
+#include <qdatetime.h>
#include <qstringlist.h>
@@ -97,6 +99,6 @@ public:
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 setBirthday( const QDate &v );
+ void setAnniversary( const QDate &v );
void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
void setChildren( const QString &v );
@@ -174,6 +176,6 @@ public:
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 ); }
+ QDate birthday() const;
+ QDate anniversary() const;
QString nickname() const { return find( Qtopia::Nickname ); }
QString children() const { return find( Qtopia::Children ); }
@@ -240,76 +242,4 @@ private:
};
-// these methods are inlined to keep binary compatability with Qtopia 1.5
-inline 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;
- replace( Qtopia::Emails, emailsStr );
-}
-
-inline void OContact::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 OContact::clearEmails()
-{
- mMap.remove( Qtopia::DefaultEmail );
- mMap.remove( Qtopia::Emails );
-}
-inline void OContact::setDefaultEmail( const QString &v )
-{
- QString e = v.simplifyWhiteSpace();
-
- //qDebug("OContact::setDefaultEmail %s", e.latin1());
- replace( Qtopia::DefaultEmail, e );
-
- if ( !e.isEmpty() )
- insertEmail( e );
-
-}
-
-inline void OContact::insertEmails( const QStringList &v )
-{
- for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
- insertEmail( *it );
-}
#endif
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 6f648ac..21fc088 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1,4 +1,5 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
**
** This file is part of the Qtopia Environment.
@@ -27,4 +28,5 @@
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
+#include <qpe/timestring.h>
#include <qobject.h>
@@ -226,12 +228,4 @@ OContact::~OContact()
*/
-/*! \fn void OContact::setBirthday( const QString &str )
- Sets the birthday for the contact to \a str.
-*/
-
-/*! \fn void OContact::setAnniversary( const QString &str )
- Sets the anniversary of the contact to \a str.
-*/
-
/*! \fn void OContact::setNickname( const QString &str )
Sets the nickname of the contact to \a str.
@@ -387,12 +381,4 @@ OContact::~OContact()
*/
-/*! \fn QString OContact::birthday() const
- Returns the birthday of the contact.
-*/
-
-/*! \fn QString OContact::anniversary() const
- Returns the anniversary of the contact.
-*/
-
/*! \fn QString OContact::nickname() const
Returns the nickname of the contact.
@@ -586,12 +572,14 @@ QString OContact::toRichText() const
text += "<b>" + QObject::tr("Spouse: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
- str = birthday();
- if ( !str.isEmpty() )
- text += "<b>" + QObject::tr("Birthday: ") + "</b>"
- + Qtopia::escapeString(str) + "<br>";
- str = anniversary();
- if ( !str.isEmpty() )
- text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
- + Qtopia::escapeString(str) + "<br>";
+ if ( !birthday().isNull() ){
+ str = TimeString::numberDateString( birthday() );
+ text += "<b>" + QObject::tr("Birthday: ") + "</b>"
+ + Qtopia::escapeString(str) + "<br>";
+ }
+ if ( !anniversary().isNull() ){
+ str = TimeString::numberDateString( anniversary() );
+ text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
+ + Qtopia::escapeString(str) + "<br>";
+ }
str = nickname();
if ( !str.isEmpty() )
@@ -1135,5 +1123,5 @@ static VObject *createVObject( const OContact &c )
safeAddPropValue( vcard, VCNoteProp, c.notes() );
- safeAddPropValue( vcard, VCBirthDateProp, c.birthday() );
+ safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) );
if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
@@ -1151,5 +1139,5 @@ static VObject *createVObject( const OContact &c )
safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
- safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() );
+ safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
@@ -1354,5 +1342,5 @@ static OContact parseVObject( VObject *obj )
}
else if ( name == "X-Qtopia-Anniversary" ) {
- c.setAnniversary( value );
+ c.setAnniversary( TimeConversion::fromString( value ) );
}
else if ( name == "X-Qtopia-Nickname" ) {
@@ -1494,2 +1482,128 @@ class QString OContact::recordField( int pos ) const
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.
+*/
+void OContact::setBirthday( const QDate &v )
+{
+ if ( ( !v.isNull() ) && ( v.isValid() ) )
+ replace( Qtopia::Birthday, TimeConversion::toString( v ) );
+
+}
+
+
+/*! \fn void OContact::setAnniversary( const QDate &date )
+ Sets the anniversary of the contact to \a date.
+*/
+void OContact::setAnniversary( const QDate &v )
+{
+ if ( ( !v.isNull() ) && ( v.isValid() ) )
+ replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
+}
+
+/*! \fn QDate OContact::birthday() const
+ Returns the birthday of the contact.
+*/
+QDate OContact::birthday() const
+{
+ QDate empty;
+ QString str = find( Qtopia::Birthday );
+ qWarning ("Birthday %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return TimeConversion::fromString ( str );
+ else
+ return empty;
+}
+
+
+/*! \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 TimeConversion::fromString ( 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;
+ replace( Qtopia::Emails, emailsStr );
+}
+
+void OContact::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() );
+ }
+}
+void OContact::clearEmails()
+{
+ mMap.remove( Qtopia::DefaultEmail );
+ mMap.remove( Qtopia::Emails );
+}
+void OContact::setDefaultEmail( const QString &v )
+{
+ QString e = v.simplifyWhiteSpace();
+
+ //qDebug("OContact::setDefaultEmail %s", e.latin1());
+ replace( Qtopia::DefaultEmail, e );
+
+ if ( !e.isEmpty() )
+ insertEmail( e );
+
+}
+
+void OContact::insertEmails( const QStringList &v )
+{
+ for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
+ insertEmail( *it );
+}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index f916cf2..9e83150 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -1,4 +1,5 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
**
** This file is part of the Qtopia Environment.
@@ -25,4 +26,5 @@
#include <qpe/recordfields.h>
+#include <qdatetime.h>
#include <qstringlist.h>
@@ -97,6 +99,6 @@ public:
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 setBirthday( const QDate &v );
+ void setAnniversary( const QDate &v );
void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
void setChildren( const QString &v );
@@ -174,6 +176,6 @@ public:
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 ); }
+ QDate birthday() const;
+ QDate anniversary() const;
QString nickname() const { return find( Qtopia::Nickname ); }
QString children() const { return find( Qtopia::Children ); }
@@ -240,76 +242,4 @@ private:
};
-// these methods are inlined to keep binary compatability with Qtopia 1.5
-inline 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;
- replace( Qtopia::Emails, emailsStr );
-}
-
-inline void OContact::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 OContact::clearEmails()
-{
- mMap.remove( Qtopia::DefaultEmail );
- mMap.remove( Qtopia::Emails );
-}
-inline void OContact::setDefaultEmail( const QString &v )
-{
- QString e = v.simplifyWhiteSpace();
-
- //qDebug("OContact::setDefaultEmail %s", e.latin1());
- replace( Qtopia::DefaultEmail, e );
-
- if ( !e.isEmpty() )
- insertEmail( e );
-
-}
-
-inline void OContact::insertEmails( const QStringList &v )
-{
- for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
- insertEmail( *it );
-}
#endif