-rw-r--r-- | libopie/pim/otodo.cpp | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index 3c93838..8239ba6 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -15,47 +15,66 @@ | |||
15 | 15 | ||
16 | #include "otodo.h" | 16 | #include "otodo.h" |
17 | 17 | ||
18 | 18 | ||
19 | struct OTodo::OTodoData : public QShared { | 19 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | 20 | OTodoData() : QShared() { |
21 | }; | 21 | }; |
22 | 22 | ||
23 | QDate date; | 23 | QDate date; |
24 | bool isCompleted:1; | 24 | bool isCompleted:1; |
25 | bool hasDate:1; | 25 | bool hasDate:1; |
26 | int priority; | 26 | int priority; |
27 | QStringList category; | ||
28 | QString desc; | 27 | QString desc; |
29 | QString sum; | 28 | QString sum; |
30 | QMap<QString, QString> extra; | 29 | QMap<QString, QString> extra; |
31 | ushort prog; | 30 | ushort prog; |
32 | bool hasAlarmDateTime :1; | 31 | bool hasAlarmDateTime :1; |
33 | QDateTime alarmDateTime; | 32 | QDateTime alarmDateTime; |
34 | }; | 33 | }; |
35 | 34 | ||
36 | OTodo::OTodo(const OTodo &event ) | 35 | OTodo::OTodo(const OTodo &event ) |
37 | : OPimRecord( event ), data( event.data ) | 36 | : OPimRecord( event ), data( event.data ) |
38 | { | 37 | { |
39 | data->ref(); | 38 | data->ref(); |
40 | //qWarning("ref up"); | 39 | //qWarning("ref up"); |
41 | } | 40 | } |
42 | OTodo::~OTodo() { | 41 | OTodo::~OTodo() { |
43 | if ( data->deref() ) { | 42 | if ( data->deref() ) { |
44 | //qWarning("OTodo::dereffing"); | 43 | //qWarning("OTodo::dereffing"); |
45 | delete data; | 44 | delete data; |
46 | data = 0l; | 45 | data = 0l; |
47 | } | 46 | } |
48 | } | 47 | } |
48 | OTodo::OTodo(bool completed, int priority, | ||
49 | const QArray<int> &category, | ||
50 | const QString& summary, | ||
51 | const QString &description, | ||
52 | ushort progress, | ||
53 | bool hasDate, QDate date, int uid ) | ||
54 | : OPimRecord( uid ) | ||
55 | { | ||
56 | //qWarning("OTodoData"); | ||
57 | setCategories( category ); | ||
58 | data = new OTodoData; | ||
59 | data->date = date; | ||
60 | data->isCompleted = completed; | ||
61 | data->hasDate = hasDate; | ||
62 | data->priority = priority; | ||
63 | data->sum = summary; | ||
64 | data->prog = progress; | ||
65 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | ||
66 | data->hasAlarmDateTime = false; | ||
49 | 67 | ||
68 | } | ||
50 | OTodo::OTodo(bool completed, int priority, | 69 | OTodo::OTodo(bool completed, int priority, |
51 | const QStringList &category, | 70 | const QStringList &category, |
52 | const QString& summary, | 71 | const QString& summary, |
53 | const QString &description, | 72 | const QString &description, |
54 | ushort progress, | 73 | ushort progress, |
55 | bool hasDate, QDate date, int uid ) | 74 | bool hasDate, QDate date, int uid ) |
56 | : OPimRecord( uid ) | 75 | : OPimRecord( uid ) |
57 | { | 76 | { |
58 | //qWarning("OTodoData"); | 77 | //qWarning("OTodoData"); |
59 | setCategories( idsFromString( category.join(";") ) ); | 78 | setCategories( idsFromString( category.join(";") ) ); |
60 | data = new OTodoData; | 79 | data = new OTodoData; |
61 | data->date = date; | 80 | data->date = date; |
@@ -258,37 +277,37 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const | |||
258 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 277 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
259 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 278 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
260 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 279 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
261 | return priority() > toDoEvent.priority(); | 280 | return priority() > toDoEvent.priority(); |
262 | }else{ | 281 | }else{ |
263 | return dueDate() > toDoEvent.dueDate(); | 282 | return dueDate() > toDoEvent.dueDate(); |
264 | } | 283 | } |
265 | } | 284 | } |
266 | return true; | 285 | return true; |
267 | } | 286 | } |
268 | bool OTodo::operator==(const OTodo &toDoEvent )const | 287 | bool OTodo::operator==(const OTodo &toDoEvent )const |
269 | { | 288 | { |
270 | if( data->priority == toDoEvent.data->priority && | 289 | if ( data->priority != toDoEvent.data->priority ) return false; |
271 | data->priority == toDoEvent.data->prog && | 290 | if ( data->priority != toDoEvent.data->prog ) return false; |
272 | data->isCompleted == toDoEvent.data->isCompleted && | 291 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; |
273 | data->hasDate == toDoEvent.data->hasDate && | 292 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; |
274 | data->date == toDoEvent.data->date && | 293 | if ( data->date != toDoEvent.data->date ) return false; |
275 | data->category == toDoEvent.data->category && | 294 | if ( data->sum != toDoEvent.data->sum ) return false; |
276 | data->sum == toDoEvent.data->sum && | 295 | if ( data->desc != toDoEvent.data->desc ) return false; |
277 | data->desc == toDoEvent.data->desc && | 296 | if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) |
278 | data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && | 297 | return false; |
279 | data->alarmDateTime == toDoEvent.data->alarmDateTime ) | 298 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) |
280 | return true; | ||
281 | |||
282 | return false; | 299 | return false; |
300 | |||
301 | return OPimRecord::operator==( toDoEvent ); | ||
283 | } | 302 | } |
284 | void OTodo::deref() { | 303 | void OTodo::deref() { |
285 | 304 | ||
286 | //qWarning("deref in ToDoEvent"); | 305 | //qWarning("deref in ToDoEvent"); |
287 | if ( data->deref() ) { | 306 | if ( data->deref() ) { |
288 | //qWarning("deleting"); | 307 | //qWarning("deleting"); |
289 | delete data; | 308 | delete data; |
290 | d= 0; | 309 | d= 0; |
291 | } | 310 | } |
292 | } | 311 | } |
293 | OTodo &OTodo::operator=(const OTodo &item ) | 312 | OTodo &OTodo::operator=(const OTodo &item ) |
294 | { | 313 | { |
@@ -341,14 +360,19 @@ void OTodo::changeOrModify() { | |||
341 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 360 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
342 | dest->date = src->date; | 361 | dest->date = src->date; |
343 | dest->isCompleted = src->isCompleted; | 362 | dest->isCompleted = src->isCompleted; |
344 | dest->hasDate = src->hasDate; | 363 | dest->hasDate = src->hasDate; |
345 | dest->priority = src->priority; | 364 | dest->priority = src->priority; |
346 | dest->desc = src->desc; | 365 | dest->desc = src->desc; |
347 | dest->sum = src->sum; | 366 | dest->sum = src->sum; |
348 | dest->extra = src->extra; | 367 | dest->extra = src->extra; |
349 | dest->prog = src->prog; | 368 | dest->prog = src->prog; |
350 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 369 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
351 | dest->alarmDateTime = src->alarmDateTime; | 370 | dest->alarmDateTime = src->alarmDateTime; |
352 | } | 371 | } |
353 | 372 | QString OTodo::type() const { | |
373 | return QString::fromLatin1("OTodo"); | ||
374 | } | ||
375 | QString OTodo::recordField(int id )const { | ||
376 | return QString::null; | ||
377 | } | ||
354 | 378 | ||