-rw-r--r-- | libopie/pim/ocontact.cpp | 11 | ||||
-rw-r--r-- | libopie/pim/opimrecord.h | 0 | ||||
-rw-r--r-- | libopie/pim/opimstate.cpp | 64 | ||||
-rw-r--r-- | libopie/pim/opimstate.h | 44 | ||||
-rw-r--r-- | libopie/pim/orecordlist.h | 0 | ||||
-rw-r--r-- | libopie/pim/orecur.cpp | 9 | ||||
-rw-r--r-- | libopie/pim/orecur.h | 2 | ||||
-rw-r--r-- | libopie/pim/otodo.cpp | 23 | ||||
-rw-r--r-- | libopie/pim/otodo.h | 27 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 0 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimstate.cpp | 64 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimstate.h | 44 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 9 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 11 | ||||
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 0 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 23 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 27 |
18 files changed, 352 insertions, 8 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index acd65c4..cd238ef 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -1461,13 +1461,22 @@ QValueList<OContact> OContact::readVCard( const QString &filename ) | |||
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 | ||
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h index dbb94ed..d9ccad4 100644 --- a/libopie/pim/opimrecord.h +++ b/libopie/pim/opimrecord.h | |||
diff --git a/libopie/pim/opimstate.cpp b/libopie/pim/opimstate.cpp new file mode 100644 index 0000000..6fb2feb --- a/dev/null +++ b/libopie/pim/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 | */ | ||
10 | struct OPimState::Data : public QShared { | ||
11 | Data() : QShared(),state(Undefined) { | ||
12 | } | ||
13 | int state; | ||
14 | }; | ||
15 | |||
16 | OPimState::OPimState( int state ) { | ||
17 | data = new Data; | ||
18 | data->state = state; | ||
19 | } | ||
20 | OPimState::OPimState( const OPimState& st) : | ||
21 | data( st.data ) { | ||
22 | /* ref up */ | ||
23 | data->ref(); | ||
24 | } | ||
25 | OPimState::~OPimState() { | ||
26 | if ( data->deref() ) { | ||
27 | delete data ; | ||
28 | data = 0; | ||
29 | } | ||
30 | } | ||
31 | bool OPimState::operator==( const OPimState& st) { | ||
32 | if ( data->state == st.data->state ) return true; | ||
33 | |||
34 | return false; | ||
35 | } | ||
36 | OPimState &OPimState::operator=( const OPimState& st) { | ||
37 | st.data->ref(); | ||
38 | deref(); | ||
39 | data = st.data; | ||
40 | |||
41 | return *this; | ||
42 | } | ||
43 | void OPimState::setState( int st) { | ||
44 | copyInternally(); | ||
45 | data->state = st; | ||
46 | } | ||
47 | int OPimState::state()const { | ||
48 | return data->state; | ||
49 | } | ||
50 | void OPimState::deref() { | ||
51 | if ( data->deref() ) { | ||
52 | delete data; | ||
53 | data = 0l; | ||
54 | } | ||
55 | } | ||
56 | void 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/libopie/pim/opimstate.h b/libopie/pim/opimstate.h new file mode 100644 index 0000000..731181e --- a/dev/null +++ b/libopie/pim/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 | */ | ||
17 | class OPimState { | ||
18 | public: | ||
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; | ||
34 | private: | ||
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/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index 2f4a5d3..8ed41e2 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h | |||
diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp index 6c81f8f..257d4fd 100644 --- a/libopie/pim/orecur.cpp +++ b/libopie/pim/orecur.cpp | |||
@@ -18,12 +18,13 @@ struct ORecur::Data : public QShared { | |||
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 | ||
27 | ORecur::ORecur() { | 28 | ORecur::ORecur() { |
28 | data = new Data; | 29 | data = new Data; |
29 | } | 30 | } |
@@ -75,12 +76,15 @@ QDate ORecur::endDate()const { | |||
75 | time_t ORecur::endDateUTC()const { | 76 | time_t ORecur::endDateUTC()const { |
76 | return data->end; | 77 | return data->end; |
77 | } | 78 | } |
78 | time_t ORecur::createTime()const { | 79 | time_t ORecur::createTime()const { |
79 | return data->create; | 80 | return data->create; |
80 | } | 81 | } |
82 | int ORecur::repetition()const { | ||
83 | return data->rep; | ||
84 | } | ||
81 | void ORecur::setType( const RepeatType& z) { | 85 | void ORecur::setType( const RepeatType& z) { |
82 | checkOrModify(); | 86 | checkOrModify(); |
83 | data->type = z; | 87 | data->type = z; |
84 | } | 88 | } |
85 | void ORecur::setFrequency( int freq ) { | 89 | void ORecur::setFrequency( int freq ) { |
86 | checkOrModify(); | 90 | checkOrModify(); |
@@ -107,21 +111,26 @@ void ORecur::setCreateTime( time_t t) { | |||
107 | data->create = t; | 111 | data->create = t; |
108 | } | 112 | } |
109 | void ORecur::setHasEndDate( bool b) { | 113 | void ORecur::setHasEndDate( bool b) { |
110 | checkOrModify(); | 114 | checkOrModify(); |
111 | data->hasEnd = b; | 115 | data->hasEnd = b; |
112 | } | 116 | } |
117 | void ORecur::setRepitition( int rep ) { | ||
118 | checkOrModify(); | ||
119 | data->rep = rep; | ||
120 | } | ||
113 | void ORecur::checkOrModify() { | 121 | void 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/libopie/pim/orecur.h b/libopie/pim/orecur.h index 89258f8..d24d72d 100644 --- a/libopie/pim/orecur.h +++ b/libopie/pim/orecur.h | |||
@@ -28,21 +28,23 @@ public: | |||
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 ); | ||
43 | private: | 45 | private: |
44 | void deref(); | 46 | void deref(); |
45 | inline void checkOrModify(); | 47 | inline void checkOrModify(); |
46 | 48 | ||
47 | 49 | ||
48 | class Data; | 50 | class Data; |
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index 765d5a9..0d5b1d3 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -9,13 +9,14 @@ | |||
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 | ||
19 | struct OTodo::OTodoData : public QShared { | 20 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | 21 | OTodoData() : QShared() { |
21 | }; | 22 | }; |
@@ -27,12 +28,14 @@ struct OTodo::OTodoData : public QShared { | |||
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 | ||
35 | OTodo::OTodo(const OTodo &event ) | 38 | OTodo::OTodo(const OTodo &event ) |
36 | : OPimRecord( event ), data( event.data ) | 39 | : OPimRecord( event ), data( event.data ) |
37 | { | 40 | { |
38 | data->ref(); | 41 | data->ref(); |
@@ -141,12 +144,18 @@ QDateTime OTodo::alarmDateTime() const | |||
141 | } | 144 | } |
142 | 145 | ||
143 | QString OTodo::description()const | 146 | QString OTodo::description()const |
144 | { | 147 | { |
145 | return data->desc; | 148 | return data->desc; |
146 | } | 149 | } |
150 | OPimState OTodo::state()const { | ||
151 | return data->state; | ||
152 | } | ||
153 | ORecur OTodo::recurrence()const { | ||
154 | return data->recur; | ||
155 | } | ||
147 | void OTodo::setCompleted( bool completed ) | 156 | void OTodo::setCompleted( bool completed ) |
148 | { | 157 | { |
149 | changeOrModify(); | 158 | changeOrModify(); |
150 | data->isCompleted = completed; | 159 | data->isCompleted = completed; |
151 | } | 160 | } |
152 | void OTodo::setHasDueDate( bool hasDate ) | 161 | void OTodo::setHasDueDate( bool hasDate ) |
@@ -182,12 +191,20 @@ void OTodo::setDueDate( QDate date ) | |||
182 | } | 191 | } |
183 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) | 192 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) |
184 | { | 193 | { |
185 | changeOrModify(); | 194 | changeOrModify(); |
186 | data->alarmDateTime = alarm; | 195 | data->alarmDateTime = alarm; |
187 | } | 196 | } |
197 | void OTodo::setState( const OPimState& state ) { | ||
198 | changeOrModify(); | ||
199 | data->state = state; | ||
200 | } | ||
201 | void OTodo::setRecurrence( const ORecur& rec) { | ||
202 | changeOrModify(); | ||
203 | data->recur = rec; | ||
204 | } | ||
188 | bool OTodo::isOverdue( ) | 205 | bool 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 | } |
@@ -355,13 +372,13 @@ QMap<QString, QString> OTodo::toExtraMap()const { | |||
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 | */ |
359 | void OTodo::changeOrModify() { | 376 | void 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 | } |
@@ -373,12 +390,14 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { | |||
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 | } |
380 | QString OTodo::type() const { | 399 | QString OTodo::type() const { |
381 | return QString::fromLatin1("OTodo"); | 400 | return QString::fromLatin1("OTodo"); |
382 | } | 401 | } |
383 | QString OTodo::recordField(int id )const { | 402 | QString OTodo::recordField(int id )const { |
384 | return QString::null; | 403 | return QString::null; |
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h index 5bd91d6..2cdc587 100644 --- a/libopie/pim/otodo.h +++ b/libopie/pim/otodo.h | |||
@@ -13,12 +13,14 @@ | |||
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 | ||
19 | class OPimState; | ||
20 | class ORecur; | ||
19 | class OTodo : public OPimRecord { | 21 | class OTodo : public OPimRecord { |
20 | public: | 22 | public: |
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, |
@@ -30,13 +32,18 @@ public: | |||
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 |
@@ -108,12 +115,22 @@ public: | |||
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 |
@@ -167,19 +184,27 @@ public: | |||
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; |
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 | |||
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 | */ | ||
10 | struct OPimState::Data : public QShared { | ||
11 | Data() : QShared(),state(Undefined) { | ||
12 | } | ||
13 | int state; | ||
14 | }; | ||
15 | |||
16 | OPimState::OPimState( int state ) { | ||
17 | data = new Data; | ||
18 | data->state = state; | ||
19 | } | ||
20 | OPimState::OPimState( const OPimState& st) : | ||
21 | data( st.data ) { | ||
22 | /* ref up */ | ||
23 | data->ref(); | ||
24 | } | ||
25 | OPimState::~OPimState() { | ||
26 | if ( data->deref() ) { | ||
27 | delete data ; | ||
28 | data = 0; | ||
29 | } | ||
30 | } | ||
31 | bool OPimState::operator==( const OPimState& st) { | ||
32 | if ( data->state == st.data->state ) return true; | ||
33 | |||
34 | return false; | ||
35 | } | ||
36 | OPimState &OPimState::operator=( const OPimState& st) { | ||
37 | st.data->ref(); | ||
38 | deref(); | ||
39 | data = st.data; | ||
40 | |||
41 | return *this; | ||
42 | } | ||
43 | void OPimState::setState( int st) { | ||
44 | copyInternally(); | ||
45 | data->state = st; | ||
46 | } | ||
47 | int OPimState::state()const { | ||
48 | return data->state; | ||
49 | } | ||
50 | void OPimState::deref() { | ||
51 | if ( data->deref() ) { | ||
52 | delete data; | ||
53 | data = 0l; | ||
54 | } | ||
55 | } | ||
56 | void 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 | */ | ||
17 | class OPimState { | ||
18 | public: | ||
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; | ||
34 | private: | ||
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 | |||
@@ -18,12 +18,13 @@ struct ORecur::Data : public QShared { | |||
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 | ||
27 | ORecur::ORecur() { | 28 | ORecur::ORecur() { |
28 | data = new Data; | 29 | data = new Data; |
29 | } | 30 | } |
@@ -75,12 +76,15 @@ QDate ORecur::endDate()const { | |||
75 | time_t ORecur::endDateUTC()const { | 76 | time_t ORecur::endDateUTC()const { |
76 | return data->end; | 77 | return data->end; |
77 | } | 78 | } |
78 | time_t ORecur::createTime()const { | 79 | time_t ORecur::createTime()const { |
79 | return data->create; | 80 | return data->create; |
80 | } | 81 | } |
82 | int ORecur::repetition()const { | ||
83 | return data->rep; | ||
84 | } | ||
81 | void ORecur::setType( const RepeatType& z) { | 85 | void ORecur::setType( const RepeatType& z) { |
82 | checkOrModify(); | 86 | checkOrModify(); |
83 | data->type = z; | 87 | data->type = z; |
84 | } | 88 | } |
85 | void ORecur::setFrequency( int freq ) { | 89 | void ORecur::setFrequency( int freq ) { |
86 | checkOrModify(); | 90 | checkOrModify(); |
@@ -107,21 +111,26 @@ void ORecur::setCreateTime( time_t t) { | |||
107 | data->create = t; | 111 | data->create = t; |
108 | } | 112 | } |
109 | void ORecur::setHasEndDate( bool b) { | 113 | void ORecur::setHasEndDate( bool b) { |
110 | checkOrModify(); | 114 | checkOrModify(); |
111 | data->hasEnd = b; | 115 | data->hasEnd = b; |
112 | } | 116 | } |
117 | void ORecur::setRepitition( int rep ) { | ||
118 | checkOrModify(); | ||
119 | data->rep = rep; | ||
120 | } | ||
113 | void ORecur::checkOrModify() { | 121 | void 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 | |||
@@ -28,21 +28,23 @@ public: | |||
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 ); | ||
43 | private: | 45 | private: |
44 | void deref(); | 46 | void deref(); |
45 | inline void checkOrModify(); | 47 | inline void checkOrModify(); |
46 | 48 | ||
47 | 49 | ||
48 | class Data; | 50 | class Data; |
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 | |||
@@ -1461,13 +1461,22 @@ QValueList<OContact> OContact::readVCard( const QString &filename ) | |||
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 | ||
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 | |||
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 | |||
@@ -9,13 +9,14 @@ | |||
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 | ||
19 | struct OTodo::OTodoData : public QShared { | 20 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | 21 | OTodoData() : QShared() { |
21 | }; | 22 | }; |
@@ -27,12 +28,14 @@ struct OTodo::OTodoData : public QShared { | |||
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 | ||
35 | OTodo::OTodo(const OTodo &event ) | 38 | OTodo::OTodo(const OTodo &event ) |
36 | : OPimRecord( event ), data( event.data ) | 39 | : OPimRecord( event ), data( event.data ) |
37 | { | 40 | { |
38 | data->ref(); | 41 | data->ref(); |
@@ -141,12 +144,18 @@ QDateTime OTodo::alarmDateTime() const | |||
141 | } | 144 | } |
142 | 145 | ||
143 | QString OTodo::description()const | 146 | QString OTodo::description()const |
144 | { | 147 | { |
145 | return data->desc; | 148 | return data->desc; |
146 | } | 149 | } |
150 | OPimState OTodo::state()const { | ||
151 | return data->state; | ||
152 | } | ||
153 | ORecur OTodo::recurrence()const { | ||
154 | return data->recur; | ||
155 | } | ||
147 | void OTodo::setCompleted( bool completed ) | 156 | void OTodo::setCompleted( bool completed ) |
148 | { | 157 | { |
149 | changeOrModify(); | 158 | changeOrModify(); |
150 | data->isCompleted = completed; | 159 | data->isCompleted = completed; |
151 | } | 160 | } |
152 | void OTodo::setHasDueDate( bool hasDate ) | 161 | void OTodo::setHasDueDate( bool hasDate ) |
@@ -182,12 +191,20 @@ void OTodo::setDueDate( QDate date ) | |||
182 | } | 191 | } |
183 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) | 192 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) |
184 | { | 193 | { |
185 | changeOrModify(); | 194 | changeOrModify(); |
186 | data->alarmDateTime = alarm; | 195 | data->alarmDateTime = alarm; |
187 | } | 196 | } |
197 | void OTodo::setState( const OPimState& state ) { | ||
198 | changeOrModify(); | ||
199 | data->state = state; | ||
200 | } | ||
201 | void OTodo::setRecurrence( const ORecur& rec) { | ||
202 | changeOrModify(); | ||
203 | data->recur = rec; | ||
204 | } | ||
188 | bool OTodo::isOverdue( ) | 205 | bool 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 | } |
@@ -355,13 +372,13 @@ QMap<QString, QString> OTodo::toExtraMap()const { | |||
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 | */ |
359 | void OTodo::changeOrModify() { | 376 | void 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 | } |
@@ -373,12 +390,14 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { | |||
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 | } |
380 | QString OTodo::type() const { | 399 | QString OTodo::type() const { |
381 | return QString::fromLatin1("OTodo"); | 400 | return QString::fromLatin1("OTodo"); |
382 | } | 401 | } |
383 | QString OTodo::recordField(int id )const { | 402 | QString OTodo::recordField(int id )const { |
384 | return QString::null; | 403 | return QString::null; |
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 | |||
@@ -13,12 +13,14 @@ | |||
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 | ||
19 | class OPimState; | ||
20 | class ORecur; | ||
19 | class OTodo : public OPimRecord { | 21 | class OTodo : public OPimRecord { |
20 | public: | 22 | public: |
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, |
@@ -30,13 +32,18 @@ public: | |||
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 |
@@ -108,12 +115,22 @@ public: | |||
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 |
@@ -167,19 +184,27 @@ public: | |||
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; |