summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimrecord.h4
-rw-r--r--libopie2/opiepim/core/opimstate.cpp64
-rw-r--r--libopie2/opiepim/core/opimstate.h44
-rw-r--r--libopie2/opiepim/core/orecur.cpp9
-rw-r--r--libopie2/opiepim/core/orecur.h2
-rw-r--r--libopie2/opiepim/ocontact.cpp41
-rw-r--r--libopie2/opiepim/orecordlist.h2
-rw-r--r--libopie2/opiepim/otodo.cpp23
-rw-r--r--libopie2/opiepim/otodo.h27
9 files changed, 194 insertions, 22 deletions
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index dbb94ed..d9ccad4 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -4,17 +4,17 @@
4#include <qmap.h> 4#include <qmap.h>
5#include <qstring.h> 5#include <qstring.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8#include <qpe/palmtoprecord.h> 8#include <qpe/palmtoprecord.h>
9 9
10 10
11/** 11/**
12 * This is the base class for 12 * This is the base class for
13 * all PIM Records 13 * all PIM Records
14 * 14 *
15 */ 15 */
16class OPimRecord : public Qtopia::Record { 16class OPimRecord : public Qtopia::Record {
17public: 17public:
18 /** 18 /**
19 * c'tor 19 * c'tor
20 * uid of 0 isEmpty 20 * uid of 0 isEmpty
@@ -105,17 +105,17 @@ public:
105 * add a relation 105 * add a relation
106 */ 106 */
107 void addRelation( const QString& app, int id ); 107 void addRelation( const QString& app, int id );
108 108
109 /** 109 /**
110 * set the relations for an app 110 * set the relations for an app
111 */ 111 */
112 void setRelations( const QString&, QArray<int> ids ); 112 void setRelations( const QString&, QArray<int> ids );
113 113
114 /** 114 /**
115 * set the uid 115 * set the uid
116 */ 116 */
117 virtual void setUid( int uid ); 117 virtual void setUid( int uid );
118 118
119protected: 119protected:
120 Qtopia::UidGen &uidGen(); 120 Qtopia::UidGen &uidGen();
121 QString crossToString()const; 121 QString crossToString()const;
diff --git a/libopie2/opiepim/core/opimstate.cpp b/libopie2/opiepim/core/opimstate.cpp
new file mode 100644
index 0000000..6fb2feb
--- a/dev/null
+++ b/libopie2/opiepim/core/opimstate.cpp
@@ -0,0 +1,64 @@
1#include <qshared.h>
2
3#include "opimstate.h"
4
5/*
6 * for one int this does not make
7 * much sense but never the less
8 * we will do it for the future
9 */
10struct OPimState::Data : public QShared {
11 Data() : QShared(),state(Undefined) {
12 }
13 int state;
14};
15
16OPimState::OPimState( int state ) {
17 data = new Data;
18 data->state = state;
19}
20OPimState::OPimState( const OPimState& st) :
21 data( st.data ) {
22 /* ref up */
23 data->ref();
24}
25OPimState::~OPimState() {
26 if ( data->deref() ) {
27 delete data ;
28 data = 0;
29 }
30}
31bool OPimState::operator==( const OPimState& st) {
32 if ( data->state == st.data->state ) return true;
33
34 return false;
35}
36OPimState &OPimState::operator=( const OPimState& st) {
37 st.data->ref();
38 deref();
39 data = st.data;
40
41 return *this;
42}
43void OPimState::setState( int st) {
44 copyInternally();
45 data->state = st;
46}
47int OPimState::state()const {
48 return data->state;
49}
50void OPimState::deref() {
51 if ( data->deref() ) {
52 delete data;
53 data = 0l;
54 }
55}
56void OPimState::copyInternally() {
57 /* we need to change it */
58 if ( data->count != 1 ) {
59 data->deref();
60 Data* d2 = new Data;
61 d2->state = data->state;
62 data = d2;
63 }
64}
diff --git a/libopie2/opiepim/core/opimstate.h b/libopie2/opiepim/core/opimstate.h
new file mode 100644
index 0000000..731181e
--- a/dev/null
+++ b/libopie2/opiepim/core/opimstate.h
@@ -0,0 +1,44 @@
1#ifndef OPIE_PIM_STATE_H
2#define OPIE_PIM_STATE_H
3
4#include <qstring.h>
5
6/**
7 * The State of a Task
8 * This class encapsules the state of a todo
9 * and it's shared too
10 */
11/*
12 * in c a simple struct would be enough ;)
13 * g_new_state();
14 * g_do_some_thing( state_t* );
15 * ;)
16 */
17class OPimState {
18public:
19 enum State {
20 Started = 0,
21 Postponed,
22 Finished,
23 NotStarted,
24 Undefined
25 };
26 OPimState( int state = Undefined );
27 OPimState( const OPimState& );
28 ~OPimState();
29
30 bool operator==( const OPimState& );
31 OPimState &operator=( const OPimState& );
32 void setState( int state);
33 int state()const;
34private:
35 void deref();
36 inline void copyInternally();
37 struct Data;
38 Data* data;
39 class Private;
40 Private *d;
41};
42
43
44#endif
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp
index 6c81f8f..257d4fd 100644
--- a/libopie2/opiepim/core/orecur.cpp
+++ b/libopie2/opiepim/core/orecur.cpp
@@ -16,16 +16,17 @@ struct ORecur::Data : public QShared {
16 } 16 }
17 char days; // Q_UINT8 for 8 seven days;) 17 char days; // Q_UINT8 for 8 seven days;)
18 ORecur::RepeatType type; 18 ORecur::RepeatType type;
19 int freq; 19 int freq;
20 int pos; 20 int pos;
21 bool hasEnd : 1; 21 bool hasEnd : 1;
22 time_t end; 22 time_t end;
23 time_t create; 23 time_t create;
24 int rep;
24}; 25};
25 26
26 27
27ORecur::ORecur() { 28ORecur::ORecur() {
28 data = new Data; 29 data = new Data;
29} 30}
30ORecur::ORecur( const ORecur& rec) 31ORecur::ORecur( const ORecur& rec)
31 : data( rec.data ) 32 : data( rec.data )
@@ -73,16 +74,19 @@ QDate ORecur::endDate()const {
73 return TimeConversion::fromUTC( data->end ).date(); 74 return TimeConversion::fromUTC( data->end ).date();
74} 75}
75time_t ORecur::endDateUTC()const { 76time_t ORecur::endDateUTC()const {
76 return data->end; 77 return data->end;
77} 78}
78time_t ORecur::createTime()const { 79time_t ORecur::createTime()const {
79 return data->create; 80 return data->create;
80} 81}
82int ORecur::repetition()const {
83 return data->rep;
84}
81void ORecur::setType( const RepeatType& z) { 85void ORecur::setType( const RepeatType& z) {
82 checkOrModify(); 86 checkOrModify();
83 data->type = z; 87 data->type = z;
84} 88}
85void ORecur::setFrequency( int freq ) { 89void ORecur::setFrequency( int freq ) {
86 checkOrModify(); 90 checkOrModify();
87 data->freq = freq; 91 data->freq = freq;
88} 92}
@@ -105,23 +109,28 @@ void ORecur::setEndDateUTC( time_t t) {
105void ORecur::setCreateTime( time_t t) { 109void ORecur::setCreateTime( time_t t) {
106 checkOrModify(); 110 checkOrModify();
107 data->create = t; 111 data->create = t;
108} 112}
109void ORecur::setHasEndDate( bool b) { 113void ORecur::setHasEndDate( bool b) {
110 checkOrModify(); 114 checkOrModify();
111 data->hasEnd = b; 115 data->hasEnd = b;
112} 116}
117void ORecur::setRepitition( int rep ) {
118 checkOrModify();
119 data->rep = rep;
120}
113void ORecur::checkOrModify() { 121void ORecur::checkOrModify() {
114 if ( data->count != 1 ) { 122 if ( data->count != 1 ) {
115 data->deref(); 123 data->deref();
116 Data* d2 = new Data; 124 Data* d2 = new Data;
117 d2->days = data->days; 125 d2->days = data->days;
118 d2->type = data->type; 126 d2->type = data->type;
119 d2->freq = data->freq; 127 d2->freq = data->freq;
120 d2->pos = data->pos; 128 d2->pos = data->pos;
121 d2->hasEnd = data->hasEnd; 129 d2->hasEnd = data->hasEnd;
122 d2->end = data->end; 130 d2->end = data->end;
123 d2->create = data->create; 131 d2->create = data->create;
132 d2->rep = data->rep;
124 data = d2; 133 data = d2;
125 } 134 }
126} 135}
127 136
diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h
index 89258f8..d24d72d 100644
--- a/libopie2/opiepim/core/orecur.h
+++ b/libopie2/opiepim/core/orecur.h
@@ -26,25 +26,27 @@ public:
26 RepeatType type()const; 26 RepeatType type()const;
27 int frequency()const; 27 int frequency()const;
28 int position()const; 28 int position()const;
29 char days()const; 29 char days()const;
30 bool hasEndDate()const; 30 bool hasEndDate()const;
31 QDate endDate()const; 31 QDate endDate()const;
32 time_t endDateUTC()const; 32 time_t endDateUTC()const;
33 time_t createTime()const; 33 time_t createTime()const;
34 int repetition()const;
34 35
35 void setType( const RepeatType& ); 36 void setType( const RepeatType& );
36 void setFrequency( int freq ); 37 void setFrequency( int freq );
37 void setPosition( int pos ); 38 void setPosition( int pos );
38 void setDays( char c); 39 void setDays( char c);
39 void setEndDate( const QDate& dt ); 40 void setEndDate( const QDate& dt );
40 void setEndDateUTC( time_t ); 41 void setEndDateUTC( time_t );
41 void setCreateTime( time_t ); 42 void setCreateTime( time_t );
42 void setHasEndDate( bool b ); 43 void setHasEndDate( bool b );
44 void setRepitition(int );
43private: 45private:
44 void deref(); 46 void deref();
45 inline void checkOrModify(); 47 inline void checkOrModify();
46 48
47 49
48 class Data; 50 class Data;
49 Data* data; 51 Data* data;
50 class ORecurPrivate; 52 class ORecurPrivate;
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index acd65c4..cd238ef 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1122,24 +1122,24 @@ static VObject *createVObject( const OContact &c )
1122 safeAddProp( email, VCInternetProp ); 1122 safeAddProp( email, VCInternetProp );
1123 } 1123 }
1124 1124
1125 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1125 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1126 1126
1127 // Exporting Birthday regarding RFC 2425 (5.8.4) 1127 // Exporting Birthday regarding RFC 2425 (5.8.4)
1128 if ( c.birthday().isValid() ){ 1128 if ( c.birthday().isValid() ){
1129 QString birthd_rfc2425 = QString("%1-%2-%3") 1129 QString birthd_rfc2425 = QString("%1-%2-%3")
1130 .arg( c.birthday().year() ) 1130 .arg( c.birthday().year() )
1131 .arg( c.birthday().month(), 2 ) 1131 .arg( c.birthday().month(), 2 )
1132 .arg( c.birthday().day(), 2 ); 1132 .arg( c.birthday().day(), 2 );
1133 // Now replace spaces with "0"... 1133 // Now replace spaces with "0"...
1134 int pos = 0; 1134 int pos = 0;
1135 while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) 1135 while ( ( pos = birthd_rfc2425.find (' ') ) > 0 )
1136 birthd_rfc2425.replace( pos, 1, "0" ); 1136 birthd_rfc2425.replace( pos, 1, "0" );
1137 1137
1138 qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); 1138 qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
1139 safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); 1139 safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
1140 } 1140 }
1141 1141
1142 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 1142 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
1143 VObject *org = safeAddProp( vcard, VCOrgProp ); 1143 VObject *org = safeAddProp( vcard, VCOrgProp );
1144 safeAddPropValue( org, VCOrgNameProp, c.company() ); 1144 safeAddPropValue( org, VCOrgNameProp, c.company() );
1145 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 1145 safeAddPropValue( org, VCOrgUnitProp, c.department() );
@@ -1383,21 +1383,21 @@ static OContact parseVObject( VObject *obj )
1383 else if ( name == "X-Qtopia-Anniversary" ) { 1383 else if ( name == "X-Qtopia-Anniversary" ) {
1384 c.setAnniversary( TimeConversion::fromString( value ) ); 1384 c.setAnniversary( TimeConversion::fromString( value ) );
1385 } 1385 }
1386 else if ( name == "X-Qtopia-Nickname" ) { 1386 else if ( name == "X-Qtopia-Nickname" ) {
1387 c.setNickname( value ); 1387 c.setNickname( value );
1388 } 1388 }
1389 else if ( name == "X-Qtopia-Children" ) { 1389 else if ( name == "X-Qtopia-Children" ) {
1390 c.setChildren( value ); 1390 c.setChildren( value );
1391 } 1391 }
1392 else if ( name == VCBirthDateProp ) { 1392 else if ( name == VCBirthDateProp ) {
1393 // Reading Birthdate regarding RFC 2425 (5.8.4) 1393 // Reading Birthdate regarding RFC 2425 (5.8.4)
1394 c.setBirthday( convVCardDateToDate( value ) ); 1394 c.setBirthday( convVCardDateToDate( value ) );
1395 1395
1396 } 1396 }
1397 1397
1398#if 0 1398#if 0
1399 else { 1399 else {
1400 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1400 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1401 VObjectIterator nit; 1401 VObjectIterator nit;
1402 initPropIterator( &nit, o ); 1402 initPropIterator( &nit, o );
1403 while( moreIteration( &nit ) ) { 1403 while( moreIteration( &nit ) ) {
@@ -1459,17 +1459,26 @@ QValueList<OContact> OContact::readVCard( const QString &filename )
1459 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); 1459 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
1460 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1460 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
1461 1461
1462 qDebug("vobject = %p", obj ); 1462 qDebug("vobject = %p", obj );
1463 1463
1464 QValueList<OContact> contacts; 1464 QValueList<OContact> contacts;
1465 1465
1466 while ( obj ) { 1466 while ( obj ) {
1467 contacts.append( parseVObject( obj ) ); 1467 OContact con = parseVObject( obj );
1468 /*
1469 * if uid is 0 assign a new one
1470 * this at least happens on
1471 * Nokia6210
1472 */
1473 if ( con.uid() == 0 )
1474 con.setUid( 1 );
1475
1476 contacts.append(con );
1468 1477
1469 VObject *t = obj; 1478 VObject *t = obj;
1470 obj = nextVObjectInList(obj); 1479 obj = nextVObjectInList(obj);
1471 cleanVObject( t ); 1480 cleanVObject( t );
1472 } 1481 }
1473 1482
1474 return contacts; 1483 return contacts;
1475} 1484}
@@ -1522,63 +1531,63 @@ QMap<QString,QString> OContact::toExtraMap() const
1522 1531
1523class QString OContact::recordField( int pos ) const 1532class QString OContact::recordField( int pos ) const
1524{ 1533{
1525 QStringList SLFIELDS = fields(); // ?? why this ? (se) 1534 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1526 return SLFIELDS[pos]; 1535 return SLFIELDS[pos];
1527} 1536}
1528 1537
1529// In future releases, we should store birthday and anniversary 1538// In future releases, we should store birthday and anniversary
1530// internally as QDate instead of QString ! 1539// internally as QDate instead of QString !
1531// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1540// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1532 1541
1533/*! \fn void OContact::setBirthday( const QDate& date ) 1542/*! \fn void OContact::setBirthday( const QDate& date )
1534 Sets the birthday for the contact to \a date. 1543 Sets the birthday for the contact to \a date.
1535*/ 1544*/
1536void OContact::setBirthday( const QDate &v ) 1545void OContact::setBirthday( const QDate &v )
1537{ 1546{
1538 if ( ( !v.isNull() ) && ( v.isValid() ) ) 1547 if ( ( !v.isNull() ) && ( v.isValid() ) )
1539 replace( Qtopia::Birthday, TimeConversion::toString( v ) ); 1548 replace( Qtopia::Birthday, TimeConversion::toString( v ) );
1540 1549
1541} 1550}
1542 1551
1543 1552
1544/*! \fn void OContact::setAnniversary( const QDate &date ) 1553/*! \fn void OContact::setAnniversary( const QDate &date )
1545 Sets the anniversary of the contact to \a date. 1554 Sets the anniversary of the contact to \a date.
1546*/ 1555*/
1547void OContact::setAnniversary( const QDate &v ) 1556void OContact::setAnniversary( const QDate &v )
1548{ 1557{
1549 if ( ( !v.isNull() ) && ( v.isValid() ) ) 1558 if ( ( !v.isNull() ) && ( v.isValid() ) )
1550 replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); 1559 replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
1551} 1560}
1552 1561
1553/*! \fn QDate OContact::birthday() const 1562/*! \fn QDate OContact::birthday() const
1554 Returns the birthday of the contact. 1563 Returns the birthday of the contact.
1555*/ 1564*/
1556QDate OContact::birthday() const 1565QDate OContact::birthday() const
1557{ 1566{
1558 QString str = find( Qtopia::Birthday ); 1567 QString str = find( Qtopia::Birthday );
1559 qWarning ("Birthday %s", str.latin1() ); 1568 qWarning ("Birthday %s", str.latin1() );
1560 if ( !str.isEmpty() ) 1569 if ( !str.isEmpty() )
1561 return TimeConversion::fromString ( str ); 1570 return TimeConversion::fromString ( str );
1562 else 1571 else
1563 return QDate(); 1572 return QDate();
1564} 1573}
1565 1574
1566 1575
1567/*! \fn QDate OContact::anniversary() const 1576/*! \fn QDate OContact::anniversary() const
1568 Returns the anniversary of the contact. 1577 Returns the anniversary of the contact.
1569*/ 1578*/
1570QDate OContact::anniversary() const 1579QDate OContact::anniversary() const
1571{ 1580{
1572 QDate empty; 1581 QDate empty;
1573 QString str = find( Qtopia::Anniversary ); 1582 QString str = find( Qtopia::Anniversary );
1574 qWarning ("Anniversary %s", str.latin1() ); 1583 qWarning ("Anniversary %s", str.latin1() );
1575 if ( !str.isEmpty() ) 1584 if ( !str.isEmpty() )
1576 return TimeConversion::fromString ( str ); 1585 return TimeConversion::fromString ( str );
1577 else 1586 else
1578 return empty; 1587 return empty;
1579} 1588}
1580 1589
1581 1590
1582void OContact::insertEmail( const QString &v ) 1591void OContact::insertEmail( const QString &v )
1583{ 1592{
1584 //qDebug("insertEmail %s", v.latin1()); 1593 //qDebug("insertEmail %s", v.latin1());
@@ -1602,17 +1611,17 @@ void OContact::insertEmail( const QString &v )
1602} 1611}
1603 1612
1604void OContact::removeEmail( const QString &v ) 1613void OContact::removeEmail( const QString &v )
1605{ 1614{
1606 QString e = v.simplifyWhiteSpace(); 1615 QString e = v.simplifyWhiteSpace();
1607 QString def = defaultEmail(); 1616 QString def = defaultEmail();
1608 QString emailsStr = find( Qtopia::Emails ); 1617 QString emailsStr = find( Qtopia::Emails );
1609 QStringList emails = emailList(); 1618 QStringList emails = emailList();
1610 1619
1611 // otherwise, must first contain it 1620 // otherwise, must first contain it
1612 if ( !emailsStr.contains( e ) ) 1621 if ( !emailsStr.contains( e ) )
1613 return; 1622 return;
1614 1623
1615 // remove it 1624 // remove it
1616 //qDebug(" removing email from list %s", e.latin1()); 1625 //qDebug(" removing email from list %s", e.latin1());
1617 emails.remove( e ); 1626 emails.remove( e );
1618 // reset the string 1627 // reset the string
@@ -1635,19 +1644,19 @@ void OContact::clearEmails()
1635} 1644}
1636void OContact::setDefaultEmail( const QString &v ) 1645void OContact::setDefaultEmail( const QString &v )
1637{ 1646{
1638 QString e = v.simplifyWhiteSpace(); 1647 QString e = v.simplifyWhiteSpace();
1639 1648
1640 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1649 //qDebug("OContact::setDefaultEmail %s", e.latin1());
1641 replace( Qtopia::DefaultEmail, e ); 1650 replace( Qtopia::DefaultEmail, e );
1642 1651
1643 if ( !e.isEmpty() ) 1652 if ( !e.isEmpty() )
1644 insertEmail( e ); 1653 insertEmail( e );
1645 1654
1646} 1655}
1647 1656
1648void OContact::insertEmails( const QStringList &v ) 1657void OContact::insertEmails( const QStringList &v )
1649{ 1658{
1650 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1659 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1651 insertEmail( *it ); 1660 insertEmail( *it );
1652} 1661}
1653 1662
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 2f4a5d3..8ed41e2 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -229,17 +229,17 @@ template <class T>
229void ORecordListIterator<T>::setCurrent( uint cur ) { 229void ORecordListIterator<T>::setCurrent( uint cur ) {
230 if( cur < m_uids.count() ) { 230 if( cur < m_uids.count() ) {
231 m_end = false; 231 m_end = false;
232 m_current= cur; 232 m_current= cur;
233 } 233 }
234} 234}
235template <class T> 235template <class T>
236uint ORecordListIterator<T>::count()const { 236uint ORecordListIterator<T>::count()const {
237 return m_uids.count(); 237 return m_uids.count();
238} 238}
239template <class T> 239template <class T>
240ORecordList<T>::ORecordList( const QArray<int>& ids, 240ORecordList<T>::ORecordList( const QArray<int>& ids,
241 const Base* acc ) 241 const Base* acc )
242 : m_ids( ids ), m_acc( acc ) 242 : m_ids( ids ), m_acc( acc )
243{ 243{
244} 244}
245template <class T> 245template <class T>
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 765d5a9..0d5b1d3 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -7,17 +7,18 @@
7#include <qpe/palmtopuidgen.h> 7#include <qpe/palmtopuidgen.h>
8#include <qpe/stringutil.h> 8#include <qpe/stringutil.h>
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15 15#include "opimstate.h"
16#include "orecur.h"
16#include "otodo.h" 17#include "otodo.h"
17 18
18 19
19struct OTodo::OTodoData : public QShared { 20struct OTodo::OTodoData : public QShared {
20 OTodoData() : QShared() { 21 OTodoData() : QShared() {
21 }; 22 };
22 23
23 QDate date; 24 QDate date;
@@ -25,16 +26,18 @@ struct OTodo::OTodoData : public QShared {
25 bool hasDate:1; 26 bool hasDate:1;
26 int priority; 27 int priority;
27 QString desc; 28 QString desc;
28 QString sum; 29 QString sum;
29 QMap<QString, QString> extra; 30 QMap<QString, QString> extra;
30 ushort prog; 31 ushort prog;
31 bool hasAlarmDateTime :1; 32 bool hasAlarmDateTime :1;
32 QDateTime alarmDateTime; 33 QDateTime alarmDateTime;
34 OPimState state;
35 ORecur recur;
33}; 36};
34 37
35OTodo::OTodo(const OTodo &event ) 38OTodo::OTodo(const OTodo &event )
36 : OPimRecord( event ), data( event.data ) 39 : OPimRecord( event ), data( event.data )
37{ 40{
38 data->ref(); 41 data->ref();
39// qWarning("ref up"); 42// qWarning("ref up");
40} 43}
@@ -139,16 +142,22 @@ QDateTime OTodo::alarmDateTime() const
139{ 142{
140 return data->alarmDateTime; 143 return data->alarmDateTime;
141} 144}
142 145
143QString OTodo::description()const 146QString OTodo::description()const
144{ 147{
145 return data->desc; 148 return data->desc;
146} 149}
150OPimState OTodo::state()const {
151 return data->state;
152}
153ORecur OTodo::recurrence()const {
154 return data->recur;
155}
147void OTodo::setCompleted( bool completed ) 156void OTodo::setCompleted( bool completed )
148{ 157{
149 changeOrModify(); 158 changeOrModify();
150 data->isCompleted = completed; 159 data->isCompleted = completed;
151} 160}
152void OTodo::setHasDueDate( bool hasDate ) 161void OTodo::setHasDueDate( bool hasDate )
153{ 162{
154 changeOrModify(); 163 changeOrModify();
@@ -180,16 +189,24 @@ void OTodo::setDueDate( QDate date )
180 changeOrModify(); 189 changeOrModify();
181 data->date = date; 190 data->date = date;
182} 191}
183void OTodo::setAlarmDateTime( const QDateTime& alarm ) 192void OTodo::setAlarmDateTime( const QDateTime& alarm )
184{ 193{
185 changeOrModify(); 194 changeOrModify();
186 data->alarmDateTime = alarm; 195 data->alarmDateTime = alarm;
187} 196}
197void OTodo::setState( const OPimState& state ) {
198 changeOrModify();
199 data->state = state;
200}
201void OTodo::setRecurrence( const ORecur& rec) {
202 changeOrModify();
203 data->recur = rec;
204}
188bool OTodo::isOverdue( ) 205bool OTodo::isOverdue( )
189{ 206{
190 if( data->hasDate && !data->isCompleted) 207 if( data->hasDate && !data->isCompleted)
191 return QDate::currentDate() > data->date; 208 return QDate::currentDate() > data->date;
192 return false; 209 return false;
193} 210}
194void OTodo::setProgress(ushort progress ) 211void OTodo::setProgress(ushort progress )
195{ 212{
@@ -353,17 +370,17 @@ QMap<QString, QString> OTodo::toExtraMap()const {
353} 370}
354/** 371/**
355 * change or modify looks at the ref count and either 372 * change or modify looks at the ref count and either
356 * creates a new QShared Object or it can modify it 373 * creates a new QShared Object or it can modify it
357 * right in place 374 * right in place
358 */ 375 */
359void OTodo::changeOrModify() { 376void OTodo::changeOrModify() {
360 if ( data->count != 1 ) { 377 if ( data->count != 1 ) {
361// qWarning("changeOrModify"); 378 qWarning("changeOrModify");
362 data->deref(); 379 data->deref();
363 OTodoData* d2 = new OTodoData(); 380 OTodoData* d2 = new OTodoData();
364 copy(data, d2 ); 381 copy(data, d2 );
365 data = d2; 382 data = d2;
366 } 383 }
367} 384}
368void OTodo::copy( OTodoData* src, OTodoData* dest ) { 385void OTodo::copy( OTodoData* src, OTodoData* dest ) {
369 dest->date = src->date; 386 dest->date = src->date;
@@ -371,16 +388,18 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
371 dest->hasDate = src->hasDate; 388 dest->hasDate = src->hasDate;
372 dest->priority = src->priority; 389 dest->priority = src->priority;
373 dest->desc = src->desc; 390 dest->desc = src->desc;
374 dest->sum = src->sum; 391 dest->sum = src->sum;
375 dest->extra = src->extra; 392 dest->extra = src->extra;
376 dest->prog = src->prog; 393 dest->prog = src->prog;
377 dest->hasAlarmDateTime = src->hasAlarmDateTime; 394 dest->hasAlarmDateTime = src->hasAlarmDateTime;
378 dest->alarmDateTime = src->alarmDateTime; 395 dest->alarmDateTime = src->alarmDateTime;
396 dest->state = src->state;
397 dest->recur = src->recur;
379} 398}
380QString OTodo::type() const { 399QString OTodo::type() const {
381 return QString::fromLatin1("OTodo"); 400 return QString::fromLatin1("OTodo");
382} 401}
383QString OTodo::recordField(int id )const { 402QString OTodo::recordField(int id )const {
384 return QString::null; 403 return QString::null;
385} 404}
386 405
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 5bd91d6..2cdc587 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -11,16 +11,18 @@
11#include <qvaluelist.h> 11#include <qvaluelist.h>
12 12
13#include <qpe/recordfields.h> 13#include <qpe/recordfields.h>
14#include <qpe/palmtopuidgen.h> 14#include <qpe/palmtopuidgen.h>
15 15
16#include <opie/opimrecord.h> 16#include <opie/opimrecord.h>
17 17
18 18
19class OPimState;
20class ORecur;
19class OTodo : public OPimRecord { 21class OTodo : public OPimRecord {
20public: 22public:
21 typedef QValueList<OTodo> ValueList; 23 typedef QValueList<OTodo> ValueList;
22 enum RecordFields { 24 enum RecordFields {
23 Uid = Qtopia::UID_ID, 25 Uid = Qtopia::UID_ID,
24 Category = Qtopia::CATEGORY_ID, 26 Category = Qtopia::CATEGORY_ID,
25 HasDate, 27 HasDate,
26 Completed, 28 Completed,
@@ -28,17 +30,22 @@ public:
28 Summary, 30 Summary,
29 Priority, 31 Priority,
30 DateDay, 32 DateDay,
31 DateMonth, 33 DateMonth,
32 DateYear, 34 DateYear,
33 Progress, 35 Progress,
34 CrossReference, 36 CrossReference,
35 HasAlarmDateTime, 37 HasAlarmDateTime,
36 AlarmDateTime 38 AlarmDateTime,
39 State,
40 Recurrance,
41 Alarms,
42 Reminders,
43 Notifiers
37 }; 44 };
38 public: 45 public:
39 // priorities from Very low to very high 46 // priorities from Very low to very high
40 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; 47 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
41 48
42 /* Constructs a new ToDoEvent 49 /* Constructs a new ToDoEvent
43 @param completed Is the TodoEvent completed 50 @param completed Is the TodoEvent completed
44 @param priority What is the priority of this ToDoEvent 51 @param priority What is the priority of this ToDoEvent
@@ -106,16 +113,26 @@ public:
106 QDate dueDate()const; 113 QDate dueDate()const;
107 114
108 /** 115 /**
109 * Alarm Date and Time 116 * Alarm Date and Time
110 */ 117 */
111 QDateTime alarmDateTime()const; 118 QDateTime alarmDateTime()const;
112 119
113 /** 120 /**
121 * What is the state of this OTodo?
122 */
123 OPimState state()const;
124
125 /**
126 * the recurrance of this
127 */
128 ORecur recurrence()const;
129
130 /**
114 * The description of the todo 131 * The description of the todo
115 */ 132 */
116 QString description()const; 133 QString description()const;
117 134
118 /** 135 /**
119 * A small summary of the todo 136 * A small summary of the todo
120 */ 137 */
121 QString summary() const; 138 QString summary() const;
@@ -165,23 +182,31 @@ public:
165 */ 182 */
166 void setProgress( ushort progress ); 183 void setProgress( ushort progress );
167 184
168 /** 185 /**
169 * set the end date 186 * set the end date
170 */ 187 */
171 void setDueDate( QDate date ); 188 void setDueDate( QDate date );
172 189
190
191 void setRecurrence( const ORecur& );
173 /** 192 /**
174 * set the alarm time 193 * set the alarm time
175 */ 194 */
176 void setAlarmDateTime ( const QDateTime& alarm ); 195 void setAlarmDateTime ( const QDateTime& alarm );
177 196
178 void setDescription(const QString& ); 197 void setDescription(const QString& );
179 void setSummary(const QString& ); 198 void setSummary(const QString& );
199
200 /**
201 * set the state of a Todo
202 * @param state State what the todo should take
203 */
204 void setState( const OPimState& state);
180 bool isOverdue(); 205 bool isOverdue();
181 206
182 207
183 bool match( const QRegExp &r )const; 208 bool match( const QRegExp &r )const;
184 209
185 bool operator<(const OTodo &toDoEvent )const; 210 bool operator<(const OTodo &toDoEvent )const;
186 bool operator<=(const OTodo &toDoEvent )const; 211 bool operator<=(const OTodo &toDoEvent )const;
187 bool operator!=(const OTodo &toDoEvent )const; 212 bool operator!=(const OTodo &toDoEvent )const;