summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp168
-rw-r--r--libopie/pim/ocontact.h82
2 files changed, 147 insertions, 103 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
@@ -2,2 +2,3 @@
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
3** 4**
@@ -28,2 +29,3 @@
28#include <qpe/timeconversion.h> 29#include <qpe/timeconversion.h>
30#include <qpe/timestring.h>
29 31
@@ -227,10 +229,2 @@ OContact::~OContact()
227 229
228/*! \fn void OContact::setBirthday( const QString &str )
229 Sets the birthday for the contact to \a str.
230*/
231
232/*! \fn void OContact::setAnniversary( const QString &str )
233 Sets the anniversary of the contact to \a str.
234*/
235
236/*! \fn void OContact::setNickname( const QString &str ) 230/*! \fn void OContact::setNickname( const QString &str )
@@ -388,10 +382,2 @@ OContact::~OContact()
388 382
389/*! \fn QString OContact::birthday() const
390 Returns the birthday of the contact.
391*/
392
393/*! \fn QString OContact::anniversary() const
394 Returns the anniversary of the contact.
395*/
396
397/*! \fn QString OContact::nickname() const 383/*! \fn QString OContact::nickname() const
@@ -587,10 +573,12 @@ QString OContact::toRichText() const
587 + Qtopia::escapeString(str) + "<br>"; 573 + Qtopia::escapeString(str) + "<br>";
588 str = birthday(); 574 if ( !birthday().isNull() ){
589 if ( !str.isEmpty() ) 575 str = TimeString::numberDateString( birthday() );
590 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 576 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
591 + Qtopia::escapeString(str) + "<br>"; 577 + Qtopia::escapeString(str) + "<br>";
592 str = anniversary(); 578 }
593 if ( !str.isEmpty() ) 579 if ( !anniversary().isNull() ){
594 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 580 str = TimeString::numberDateString( anniversary() );
595 + Qtopia::escapeString(str) + "<br>"; 581 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
582 + Qtopia::escapeString(str) + "<br>";
583 }
596 str = nickname(); 584 str = nickname();
@@ -1136,3 +1124,3 @@ static VObject *createVObject( const OContact &c )
1136 1124
1137 safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); 1125 safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) );
1138 1126
@@ -1152,3 +1140,3 @@ static VObject *createVObject( const OContact &c )
1152 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 1140 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
1153 safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); 1141 safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
1154 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 1142 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
@@ -1355,3 +1343,3 @@ static OContact parseVObject( VObject *obj )
1355 else if ( name == "X-Qtopia-Anniversary" ) { 1343 else if ( name == "X-Qtopia-Anniversary" ) {
1356 c.setAnniversary( value ); 1344 c.setAnniversary( TimeConversion::fromString( value ) );
1357 } 1345 }
@@ -1495 +1483,127 @@ class QString OContact::recordField( int pos ) const
1495} 1483}
1484
1485// In future releases, we should store birthday and anniversary
1486// internally as QDate instead of QString !
1487// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1488
1489/*! \fn void OContact::setBirthday( const QDate& date )
1490 Sets the birthday for the contact to \a date.
1491*/
1492void OContact::setBirthday( const QDate &v )
1493{
1494 if ( ( !v.isNull() ) && ( v.isValid() ) )
1495 replace( Qtopia::Birthday, TimeConversion::toString( v ) );
1496
1497}
1498
1499
1500/*! \fn void OContact::setAnniversary( const QDate &date )
1501 Sets the anniversary of the contact to \a date.
1502*/
1503void OContact::setAnniversary( const QDate &v )
1504{
1505 if ( ( !v.isNull() ) && ( v.isValid() ) )
1506 replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
1507}
1508
1509/*! \fn QDate OContact::birthday() const
1510 Returns the birthday of the contact.
1511*/
1512QDate OContact::birthday() const
1513{
1514 QDate empty;
1515 QString str = find( Qtopia::Birthday );
1516 qWarning ("Birthday %s", str.latin1() );
1517 if ( !str.isEmpty() )
1518 return TimeConversion::fromString ( str );
1519 else
1520 return empty;
1521}
1522
1523
1524/*! \fn QDate OContact::anniversary() const
1525 Returns the anniversary of the contact.
1526*/
1527QDate OContact::anniversary() const
1528{
1529 QDate empty;
1530 QString str = find( Qtopia::Anniversary );
1531 qWarning ("Anniversary %s", str.latin1() );
1532 if ( !str.isEmpty() )
1533 return TimeConversion::fromString ( str );
1534 else
1535 return empty;
1536}
1537
1538
1539void OContact::insertEmail( const QString &v )
1540{
1541 //qDebug("insertEmail %s", v.latin1());
1542 QString e = v.simplifyWhiteSpace();
1543 QString def = defaultEmail();
1544
1545 // if no default, set it as the default email and don't insert
1546 if ( def.isEmpty() ) {
1547 setDefaultEmail( e ); // will insert into the list for us
1548 return;
1549 }
1550
1551 // otherwise, insert assuming doesn't already exist
1552 QString emailsStr = find( Qtopia::Emails );
1553 if ( emailsStr.contains( e ))
1554 return;
1555 if ( !emailsStr.isEmpty() )
1556 emailsStr += emailSeparator();
1557 emailsStr += e;
1558 replace( Qtopia::Emails, emailsStr );
1559}
1560
1561void OContact::removeEmail( const QString &v )
1562{
1563 QString e = v.simplifyWhiteSpace();
1564 QString def = defaultEmail();
1565 QString emailsStr = find( Qtopia::Emails );
1566 QStringList emails = emailList();
1567
1568 // otherwise, must first contain it
1569 if ( !emailsStr.contains( e ) )
1570 return;
1571
1572 // remove it
1573 //qDebug(" removing email from list %s", e.latin1());
1574 emails.remove( e );
1575 // reset the string
1576 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
1577 replace( Qtopia::Emails, emailsStr );
1578
1579 // if default, then replace the default email with the first one
1580 if ( def == e ) {
1581 //qDebug("removeEmail is default; setting new default");
1582 if ( !emails.count() )
1583 clearEmails();
1584 else // setDefaultEmail will remove e from the list
1585 setDefaultEmail( emails.first() );
1586 }
1587}
1588void OContact::clearEmails()
1589{
1590 mMap.remove( Qtopia::DefaultEmail );
1591 mMap.remove( Qtopia::Emails );
1592}
1593void OContact::setDefaultEmail( const QString &v )
1594{
1595 QString e = v.simplifyWhiteSpace();
1596
1597 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1598 replace( Qtopia::DefaultEmail, e );
1599
1600 if ( !e.isEmpty() )
1601 insertEmail( e );
1602
1603}
1604
1605void OContact::insertEmails( const QStringList &v )
1606{
1607 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1608 insertEmail( *it );
1609}
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
@@ -2,2 +2,3 @@
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
3** 4**
@@ -26,2 +27,3 @@
26 27
28#include <qdatetime.h>
27#include <qstringlist.h> 29#include <qstringlist.h>
@@ -98,4 +100,4 @@ public:
98 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 100 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
99 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } 101 void setBirthday( const QDate &v );
100 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } 102 void setAnniversary( const QDate &v );
101 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 103 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
@@ -175,4 +177,4 @@ public:
175 QString gender() const { return find( Qtopia::Gender ); } 177 QString gender() const { return find( Qtopia::Gender ); }
176 QString birthday() const { return find( Qtopia::Birthday ); } 178 QDate birthday() const;
177 QString anniversary() const { return find( Qtopia::Anniversary ); } 179 QDate anniversary() const;
178 QString nickname() const { return find( Qtopia::Nickname ); } 180 QString nickname() const { return find( Qtopia::Nickname ); }
@@ -241,74 +243,2 @@ private:
241 243
242// these methods are inlined to keep binary compatability with Qtopia 1.5
243inline void OContact::insertEmail( const QString &v )
244{
245 //qDebug("insertEmail %s", v.latin1());
246 QString e = v.simplifyWhiteSpace();
247 QString def = defaultEmail();
248
249 // if no default, set it as the default email and don't insert
250 if ( def.isEmpty() ) {
251 setDefaultEmail( e ); // will insert into the list for us
252 return;
253 }
254
255 // otherwise, insert assuming doesn't already exist
256 QString emailsStr = find( Qtopia::Emails );
257 if ( emailsStr.contains( e ))
258 return;
259 if ( !emailsStr.isEmpty() )
260 emailsStr += emailSeparator();
261 emailsStr += e;
262 replace( Qtopia::Emails, emailsStr );
263}
264
265inline void OContact::removeEmail( const QString &v )
266{
267 QString e = v.simplifyWhiteSpace();
268 QString def = defaultEmail();
269 QString emailsStr = find( Qtopia::Emails );
270 QStringList emails = emailList();
271
272 // otherwise, must first contain it
273 if ( !emailsStr.contains( e ) )
274 return;
275
276 // remove it
277 //qDebug(" removing email from list %s", e.latin1());
278 emails.remove( e );
279 // reset the string
280 emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
281 replace( Qtopia::Emails, emailsStr );
282
283 // if default, then replace the default email with the first one
284 if ( def == e ) {
285 //qDebug("removeEmail is default; setting new default");
286 if ( !emails.count() )
287 clearEmails();
288 else // setDefaultEmail will remove e from the list
289 setDefaultEmail( emails.first() );
290 }
291}
292inline void OContact::clearEmails()
293{
294 mMap.remove( Qtopia::DefaultEmail );
295 mMap.remove( Qtopia::Emails );
296}
297inline void OContact::setDefaultEmail( const QString &v )
298{
299 QString e = v.simplifyWhiteSpace();
300
301 //qDebug("OContact::setDefaultEmail %s", e.latin1());
302 replace( Qtopia::DefaultEmail, e );
303
304 if ( !e.isEmpty() )
305 insertEmail( e );
306
307}
308
309inline void OContact::insertEmails( const QStringList &v )
310{
311 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
312 insertEmail( *it );
313}
314 244