-rw-r--r-- | libopie2/opiepim/otodo.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index 4d5cb79..6fcf9f6 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -5,43 +5,46 @@ | |||
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 | #include "opimstate.h" | 15 | #include "opimstate.h" |
16 | #include "orecur.h" | 16 | #include "orecur.h" |
17 | #include "opimmaintainer.h" | ||
18 | |||
17 | #include "otodo.h" | 19 | #include "otodo.h" |
18 | 20 | ||
19 | 21 | ||
20 | struct OTodo::OTodoData : public QShared { | 22 | struct OTodo::OTodoData : public QShared { |
21 | OTodoData() : QShared() { | 23 | OTodoData() : QShared() { |
22 | }; | 24 | }; |
23 | 25 | ||
24 | QDate date; | 26 | QDate date; |
25 | bool isCompleted:1; | 27 | bool isCompleted:1; |
26 | bool hasDate:1; | 28 | bool hasDate:1; |
27 | int priority; | 29 | int priority; |
28 | QString desc; | 30 | QString desc; |
29 | QString sum; | 31 | QString sum; |
30 | QMap<QString, QString> extra; | 32 | QMap<QString, QString> extra; |
31 | ushort prog; | 33 | ushort prog; |
32 | bool hasAlarmDateTime :1; | 34 | bool hasAlarmDateTime :1; |
33 | QDateTime alarmDateTime; | 35 | QDateTime alarmDateTime; |
34 | OPimState state; | 36 | OPimState state; |
35 | ORecur recur; | 37 | ORecur recur; |
38 | OPimMaintainer maintainer; | ||
36 | }; | 39 | }; |
37 | 40 | ||
38 | OTodo::OTodo(const OTodo &event ) | 41 | OTodo::OTodo(const OTodo &event ) |
39 | : OPimRecord( event ), data( event.data ) | 42 | : OPimRecord( event ), data( event.data ) |
40 | { | 43 | { |
41 | data->ref(); | 44 | data->ref(); |
42 | // qWarning("ref up"); | 45 | // qWarning("ref up"); |
43 | } | 46 | } |
44 | OTodo::~OTodo() { | 47 | OTodo::~OTodo() { |
45 | 48 | ||
46 | // qWarning("~OTodo " ); | 49 | // qWarning("~OTodo " ); |
47 | if ( data->deref() ) { | 50 | if ( data->deref() ) { |
@@ -144,24 +147,27 @@ QDateTime OTodo::alarmDateTime() const | |||
144 | } | 147 | } |
145 | 148 | ||
146 | QString OTodo::description()const | 149 | QString OTodo::description()const |
147 | { | 150 | { |
148 | return data->desc; | 151 | return data->desc; |
149 | } | 152 | } |
150 | OPimState OTodo::state()const { | 153 | OPimState OTodo::state()const { |
151 | return data->state; | 154 | return data->state; |
152 | } | 155 | } |
153 | ORecur OTodo::recurrence()const { | 156 | ORecur OTodo::recurrence()const { |
154 | return data->recur; | 157 | return data->recur; |
155 | } | 158 | } |
159 | OPimMaintainer OTodo::maintainer()const { | ||
160 | return data->maintainer; | ||
161 | } | ||
156 | void OTodo::setCompleted( bool completed ) | 162 | void OTodo::setCompleted( bool completed ) |
157 | { | 163 | { |
158 | changeOrModify(); | 164 | changeOrModify(); |
159 | data->isCompleted = completed; | 165 | data->isCompleted = completed; |
160 | } | 166 | } |
161 | void OTodo::setHasDueDate( bool hasDate ) | 167 | void OTodo::setHasDueDate( bool hasDate ) |
162 | { | 168 | { |
163 | changeOrModify(); | 169 | changeOrModify(); |
164 | data->hasDate = hasDate; | 170 | data->hasDate = hasDate; |
165 | } | 171 | } |
166 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) | 172 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) |
167 | { | 173 | { |
@@ -193,24 +199,28 @@ void OTodo::setAlarmDateTime( const QDateTime& alarm ) | |||
193 | { | 199 | { |
194 | changeOrModify(); | 200 | changeOrModify(); |
195 | data->alarmDateTime = alarm; | 201 | data->alarmDateTime = alarm; |
196 | } | 202 | } |
197 | void OTodo::setState( const OPimState& state ) { | 203 | void OTodo::setState( const OPimState& state ) { |
198 | changeOrModify(); | 204 | changeOrModify(); |
199 | data->state = state; | 205 | data->state = state; |
200 | } | 206 | } |
201 | void OTodo::setRecurrence( const ORecur& rec) { | 207 | void OTodo::setRecurrence( const ORecur& rec) { |
202 | changeOrModify(); | 208 | changeOrModify(); |
203 | data->recur = rec; | 209 | data->recur = rec; |
204 | } | 210 | } |
211 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | ||
212 | changeOrModify(); | ||
213 | data->maintainer = pim; | ||
214 | } | ||
205 | bool OTodo::isOverdue( ) | 215 | bool OTodo::isOverdue( ) |
206 | { | 216 | { |
207 | if( data->hasDate && !data->isCompleted) | 217 | if( data->hasDate && !data->isCompleted) |
208 | return QDate::currentDate() > data->date; | 218 | return QDate::currentDate() > data->date; |
209 | return false; | 219 | return false; |
210 | } | 220 | } |
211 | void OTodo::setProgress(ushort progress ) | 221 | void OTodo::setProgress(ushort progress ) |
212 | { | 222 | { |
213 | changeOrModify(); | 223 | changeOrModify(); |
214 | data->prog = progress; | 224 | data->prog = progress; |
215 | } | 225 | } |
216 | QString OTodo::toShortText() const { | 226 | QString OTodo::toShortText() const { |
@@ -312,24 +322,26 @@ bool OTodo::operator==(const OTodo &toDoEvent )const | |||
312 | { | 322 | { |
313 | if ( data->priority != toDoEvent.data->priority ) return false; | 323 | if ( data->priority != toDoEvent.data->priority ) return false; |
314 | if ( data->priority != toDoEvent.data->prog ) return false; | 324 | if ( data->priority != toDoEvent.data->prog ) return false; |
315 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; | 325 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; |
316 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; | 326 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; |
317 | if ( data->date != toDoEvent.data->date ) return false; | 327 | if ( data->date != toDoEvent.data->date ) return false; |
318 | if ( data->sum != toDoEvent.data->sum ) return false; | 328 | if ( data->sum != toDoEvent.data->sum ) return false; |
319 | if ( data->desc != toDoEvent.data->desc ) return false; | 329 | if ( data->desc != toDoEvent.data->desc ) return false; |
320 | if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) | 330 | if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) |
321 | return false; | 331 | return false; |
322 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) | 332 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) |
323 | return false; | 333 | return false; |
334 | if ( data->maintainer != toDoEvent.data->maintainer ) | ||
335 | return false; | ||
324 | 336 | ||
325 | return OPimRecord::operator==( toDoEvent ); | 337 | return OPimRecord::operator==( toDoEvent ); |
326 | } | 338 | } |
327 | void OTodo::deref() { | 339 | void OTodo::deref() { |
328 | 340 | ||
329 | // qWarning("deref in ToDoEvent"); | 341 | // qWarning("deref in ToDoEvent"); |
330 | if ( data->deref() ) { | 342 | if ( data->deref() ) { |
331 | // qWarning("deleting"); | 343 | // qWarning("deleting"); |
332 | delete data; | 344 | delete data; |
333 | data= 0; | 345 | data= 0; |
334 | } | 346 | } |
335 | } | 347 | } |
@@ -349,57 +361,63 @@ QMap<int, QString> OTodo::toMap() const { | |||
349 | 361 | ||
350 | map.insert( Uid, QString::number( uid() ) ); | 362 | map.insert( Uid, QString::number( uid() ) ); |
351 | map.insert( Category, idsToString( categories() ) ); | 363 | map.insert( Category, idsToString( categories() ) ); |
352 | map.insert( HasDate, QString::number( data->hasDate ) ); | 364 | map.insert( HasDate, QString::number( data->hasDate ) ); |
353 | map.insert( Completed, QString::number( data->isCompleted ) ); | 365 | map.insert( Completed, QString::number( data->isCompleted ) ); |
354 | map.insert( Description, data->desc ); | 366 | map.insert( Description, data->desc ); |
355 | map.insert( Summary, data->sum ); | 367 | map.insert( Summary, data->sum ); |
356 | map.insert( Priority, QString::number( data->priority ) ); | 368 | map.insert( Priority, QString::number( data->priority ) ); |
357 | map.insert( DateDay, QString::number( data->date.day() ) ); | 369 | map.insert( DateDay, QString::number( data->date.day() ) ); |
358 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 370 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
359 | map.insert( DateYear, QString::number( data->date.year() ) ); | 371 | map.insert( DateYear, QString::number( data->date.year() ) ); |
360 | map.insert( Progress, QString::number( data->prog ) ); | 372 | map.insert( Progress, QString::number( data->prog ) ); |
361 | map.insert( CrossReference, crossToString() ); | 373 | // map.insert( CrossReference, crossToString() ); |
362 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); | 374 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); |
363 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); | 375 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); |
364 | 376 | ||
365 | return map; | 377 | return map; |
366 | } | 378 | } |
367 | 379 | ||
368 | QMap<QString, QString> OTodo::toExtraMap()const { | 380 | QMap<QString, QString> OTodo::toExtraMap()const { |
369 | return data->extra; | 381 | return data->extra; |
370 | } | 382 | } |
371 | /** | 383 | /** |
372 | * change or modify looks at the ref count and either | 384 | * change or modify looks at the ref count and either |
373 | * creates a new QShared Object or it can modify it | 385 | * creates a new QShared Object or it can modify it |
374 | * right in place | 386 | * right in place |
375 | */ | 387 | */ |
376 | void OTodo::changeOrModify() { | 388 | void OTodo::changeOrModify() { |
377 | if ( data->count != 1 ) { | 389 | if ( data->count != 1 ) { |
378 | qWarning("changeOrModify"); | 390 | qWarning("changeOrModify"); |
379 | data->deref(); | 391 | data->deref(); |
380 | OTodoData* d2 = new OTodoData(); | 392 | OTodoData* d2 = new OTodoData(); |
381 | copy(data, d2 ); | 393 | copy(data, d2 ); |
382 | data = d2; | 394 | data = d2; |
383 | } | 395 | } |
384 | } | 396 | } |
397 | // WATCHOUT | ||
398 | /* | ||
399 | * if you add something to the Data struct | ||
400 | * be sure to copy it here | ||
401 | */ | ||
385 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 402 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
386 | dest->date = src->date; | 403 | dest->date = src->date; |
387 | dest->isCompleted = src->isCompleted; | 404 | dest->isCompleted = src->isCompleted; |
388 | dest->hasDate = src->hasDate; | 405 | dest->hasDate = src->hasDate; |
389 | dest->priority = src->priority; | 406 | dest->priority = src->priority; |
390 | dest->desc = src->desc; | 407 | dest->desc = src->desc; |
391 | dest->sum = src->sum; | 408 | dest->sum = src->sum; |
392 | dest->extra = src->extra; | 409 | dest->extra = src->extra; |
393 | dest->prog = src->prog; | 410 | dest->prog = src->prog; |
394 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 411 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
395 | dest->alarmDateTime = src->alarmDateTime; | 412 | dest->alarmDateTime = src->alarmDateTime; |
396 | dest->state = src->state; | 413 | dest->state = src->state; |
397 | dest->recur = src->recur; | 414 | dest->recur = src->recur; |
415 | dest->maintainer = src->maintainer; | ||
398 | } | 416 | } |
399 | QString OTodo::type() const { | 417 | QString OTodo::type() const { |
400 | return QString::fromLatin1("OTodo"); | 418 | return QString::fromLatin1("OTodo"); |
401 | } | 419 | } |
402 | QString OTodo::recordField(int /*id*/ )const { | 420 | QString OTodo::recordField(int /*id*/ )const { |
403 | return QString::null; | 421 | return QString::null; |
404 | } | 422 | } |
405 | 423 | ||