-rw-r--r-- | libopie2/opiepim/otodo.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
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 | |||
@@ -3,42 +3,45 @@ | |||
3 | #include <qshared.h> | 3 | #include <qshared.h> |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
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 | ||
19 | struct OTodo::OTodoData : public QShared { | 20 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | 21 | OTodoData() : QShared() { |
21 | }; | 22 | }; |
22 | 23 | ||
23 | QDate date; | 24 | QDate date; |
24 | bool isCompleted:1; | 25 | bool isCompleted:1; |
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 | ||
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(); |
39 | // qWarning("ref up"); | 42 | // qWarning("ref up"); |
40 | } | 43 | } |
41 | OTodo::~OTodo() { | 44 | OTodo::~OTodo() { |
42 | 45 | ||
43 | // qWarning("~OTodo " ); | 46 | // qWarning("~OTodo " ); |
44 | if ( data->deref() ) { | 47 | if ( data->deref() ) { |
@@ -135,24 +138,30 @@ QDate OTodo::dueDate()const | |||
135 | return data->date; | 138 | return data->date; |
136 | } | 139 | } |
137 | 140 | ||
138 | QDateTime OTodo::alarmDateTime() const | 141 | QDateTime OTodo::alarmDateTime() const |
139 | { | 142 | { |
140 | return data->alarmDateTime; | 143 | return data->alarmDateTime; |
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 ) |
153 | { | 162 | { |
154 | changeOrModify(); | 163 | changeOrModify(); |
155 | data->hasDate = hasDate; | 164 | data->hasDate = hasDate; |
156 | } | 165 | } |
157 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) | 166 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) |
158 | { | 167 | { |
@@ -176,24 +185,32 @@ void OTodo::setPriority(int prio ) | |||
176 | data->priority = prio; | 185 | data->priority = prio; |
177 | } | 186 | } |
178 | void OTodo::setDueDate( QDate date ) | 187 | void OTodo::setDueDate( QDate date ) |
179 | { | 188 | { |
180 | changeOrModify(); | 189 | changeOrModify(); |
181 | data->date = date; | 190 | data->date = 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 | } |
194 | void OTodo::setProgress(ushort progress ) | 211 | void OTodo::setProgress(ushort progress ) |
195 | { | 212 | { |
196 | changeOrModify(); | 213 | changeOrModify(); |
197 | data->prog = progress; | 214 | data->prog = progress; |
198 | } | 215 | } |
199 | QString OTodo::toShortText() const { | 216 | QString OTodo::toShortText() const { |
@@ -349,38 +366,40 @@ QMap<int, QString> OTodo::toMap() const { | |||
349 | } | 366 | } |
350 | 367 | ||
351 | QMap<QString, QString> OTodo::toExtraMap()const { | 368 | QMap<QString, QString> OTodo::toExtraMap()const { |
352 | return data->extra; | 369 | return data->extra; |
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 | */ |
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 | } |
368 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 385 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
369 | dest->date = src->date; | 386 | dest->date = src->date; |
370 | dest->isCompleted = src->isCompleted; | 387 | dest->isCompleted = src->isCompleted; |
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 | } |
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; |
385 | } | 404 | } |
386 | 405 | ||