-rw-r--r-- | libopie/pim/otodo.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index 8239ba6..b3c14e6 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -1,128 +1,133 @@ | |||
1 | 1 | ||
2 | #include <qobject.h> | 2 | #include <qobject.h> |
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 | ||
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 | QString desc; | 27 | QString desc; |
28 | QString sum; | 28 | QString sum; |
29 | QMap<QString, QString> extra; | 29 | QMap<QString, QString> extra; |
30 | ushort prog; | 30 | ushort prog; |
31 | bool hasAlarmDateTime :1; | 31 | bool hasAlarmDateTime :1; |
32 | QDateTime alarmDateTime; | 32 | QDateTime alarmDateTime; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | OTodo::OTodo(const OTodo &event ) | 35 | OTodo::OTodo(const OTodo &event ) |
36 | : OPimRecord( event ), data( event.data ) | 36 | : OPimRecord( event ), data( event.data ) |
37 | { | 37 | { |
38 | data->ref(); | 38 | data->ref(); |
39 | //qWarning("ref up"); | 39 | qWarning("ref up"); |
40 | } | 40 | } |
41 | OTodo::~OTodo() { | 41 | OTodo::~OTodo() { |
42 | qWarning("~OTodo " + data->sum ); | ||
42 | if ( data->deref() ) { | 43 | if ( data->deref() ) { |
43 | //qWarning("OTodo::dereffing"); | 44 | qWarning("OTodo::dereffing"); |
44 | delete data; | 45 | delete data; |
45 | data = 0l; | 46 | data = 0l; |
46 | } | 47 | } |
47 | } | 48 | } |
48 | OTodo::OTodo(bool completed, int priority, | 49 | OTodo::OTodo(bool completed, int priority, |
49 | const QArray<int> &category, | 50 | const QArray<int> &category, |
50 | const QString& summary, | 51 | const QString& summary, |
51 | const QString &description, | 52 | const QString &description, |
52 | ushort progress, | 53 | ushort progress, |
53 | bool hasDate, QDate date, int uid ) | 54 | bool hasDate, QDate date, int uid ) |
54 | : OPimRecord( uid ) | 55 | : OPimRecord( uid ) |
55 | { | 56 | { |
56 | //qWarning("OTodoData"); | 57 | qWarning("OTodoData " + summary); |
57 | setCategories( category ); | 58 | setCategories( category ); |
59 | |||
58 | data = new OTodoData; | 60 | data = new OTodoData; |
61 | |||
59 | data->date = date; | 62 | data->date = date; |
60 | data->isCompleted = completed; | 63 | data->isCompleted = completed; |
61 | data->hasDate = hasDate; | 64 | data->hasDate = hasDate; |
62 | data->priority = priority; | 65 | data->priority = priority; |
63 | data->sum = summary; | 66 | data->sum = summary; |
64 | data->prog = progress; | 67 | data->prog = progress; |
65 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 68 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
66 | data->hasAlarmDateTime = false; | 69 | data->hasAlarmDateTime = false; |
67 | 70 | ||
68 | } | 71 | } |
69 | OTodo::OTodo(bool completed, int priority, | 72 | OTodo::OTodo(bool completed, int priority, |
70 | const QStringList &category, | 73 | const QStringList &category, |
71 | const QString& summary, | 74 | const QString& summary, |
72 | const QString &description, | 75 | const QString &description, |
73 | ushort progress, | 76 | ushort progress, |
74 | bool hasDate, QDate date, int uid ) | 77 | bool hasDate, QDate date, int uid ) |
75 | : OPimRecord( uid ) | 78 | : OPimRecord( uid ) |
76 | { | 79 | { |
77 | //qWarning("OTodoData"); | 80 | qWarning("OTodoData" + summary); |
78 | setCategories( idsFromString( category.join(";") ) ); | 81 | setCategories( idsFromString( category.join(";") ) ); |
82 | |||
79 | data = new OTodoData; | 83 | data = new OTodoData; |
80 | data->date = date; | 84 | data->date = date; |
85 | |||
81 | data->isCompleted = completed; | 86 | data->isCompleted = completed; |
82 | data->hasDate = hasDate; | 87 | data->hasDate = hasDate; |
83 | data->priority = priority; | 88 | data->priority = priority; |
84 | data->sum = summary; | 89 | data->sum = summary; |
85 | data->prog = progress; | 90 | data->prog = progress; |
86 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 91 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
87 | data->hasAlarmDateTime = false; | 92 | data->hasAlarmDateTime = false; |
88 | 93 | ||
89 | } | 94 | } |
90 | bool OTodo::match( const QRegExp ®Exp )const | 95 | bool OTodo::match( const QRegExp ®Exp )const |
91 | { | 96 | { |
92 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 97 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
93 | return true; | 98 | return true; |
94 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 99 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
95 | return true; | 100 | return true; |
96 | }else if(data->desc.find( regExp ) != -1 ){ | 101 | }else if(data->desc.find( regExp ) != -1 ){ |
97 | return true; | 102 | return true; |
98 | }else if(data->sum.find( regExp ) != -1 ) { | 103 | }else if(data->sum.find( regExp ) != -1 ) { |
99 | return true; | 104 | return true; |
100 | } | 105 | } |
101 | return false; | 106 | return false; |
102 | } | 107 | } |
103 | bool OTodo::isCompleted() const | 108 | bool OTodo::isCompleted() const |
104 | { | 109 | { |
105 | return data->isCompleted; | 110 | return data->isCompleted; |
106 | } | 111 | } |
107 | bool OTodo::hasDueDate() const | 112 | bool OTodo::hasDueDate() const |
108 | { | 113 | { |
109 | return data->hasDate; | 114 | return data->hasDate; |
110 | } | 115 | } |
111 | bool OTodo::hasAlarmDateTime() const | 116 | bool OTodo::hasAlarmDateTime() const |
112 | { | 117 | { |
113 | return data->hasAlarmDateTime; | 118 | return data->hasAlarmDateTime; |
114 | } | 119 | } |
115 | int OTodo::priority()const | 120 | int OTodo::priority()const |
116 | { | 121 | { |
117 | return data->priority; | 122 | return data->priority; |
118 | } | 123 | } |
119 | QString OTodo::summary() const | 124 | QString OTodo::summary() const |
120 | { | 125 | { |
121 | return data->sum; | 126 | return data->sum; |
122 | } | 127 | } |
123 | ushort OTodo::progress() const | 128 | ushort OTodo::progress() const |
124 | { | 129 | { |
125 | return data->prog; | 130 | return data->prog; |
126 | } | 131 | } |
127 | QDate OTodo::dueDate()const | 132 | QDate OTodo::dueDate()const |
128 | { | 133 | { |
@@ -305,74 +310,74 @@ void OTodo::deref() { | |||
305 | //qWarning("deref in ToDoEvent"); | 310 | //qWarning("deref in ToDoEvent"); |
306 | if ( data->deref() ) { | 311 | if ( data->deref() ) { |
307 | //qWarning("deleting"); | 312 | //qWarning("deleting"); |
308 | delete data; | 313 | delete data; |
309 | d= 0; | 314 | d= 0; |
310 | } | 315 | } |
311 | } | 316 | } |
312 | OTodo &OTodo::operator=(const OTodo &item ) | 317 | OTodo &OTodo::operator=(const OTodo &item ) |
313 | { | 318 | { |
314 | OPimRecord::operator=( item ); | 319 | OPimRecord::operator=( item ); |
315 | //qWarning("operator= ref "); | 320 | //qWarning("operator= ref "); |
316 | item.data->ref(); | 321 | item.data->ref(); |
317 | deref(); | 322 | deref(); |
318 | 323 | ||
319 | return *this; | 324 | return *this; |
320 | } | 325 | } |
321 | 326 | ||
322 | QMap<int, QString> OTodo::toMap() const { | 327 | QMap<int, QString> OTodo::toMap() const { |
323 | QMap<int, QString> map; | 328 | QMap<int, QString> map; |
324 | 329 | ||
325 | map.insert( Uid, QString::number( uid() ) ); | 330 | map.insert( Uid, QString::number( uid() ) ); |
326 | map.insert( Category, idsToString( categories() ) ); | 331 | map.insert( Category, idsToString( categories() ) ); |
327 | map.insert( HasDate, QString::number( data->hasDate ) ); | 332 | map.insert( HasDate, QString::number( data->hasDate ) ); |
328 | map.insert( Completed, QString::number( data->isCompleted ) ); | 333 | map.insert( Completed, QString::number( data->isCompleted ) ); |
329 | map.insert( Description, data->desc ); | 334 | map.insert( Description, data->desc ); |
330 | map.insert( Summary, data->sum ); | 335 | map.insert( Summary, data->sum ); |
331 | map.insert( Priority, QString::number( data->priority ) ); | 336 | map.insert( Priority, QString::number( data->priority ) ); |
332 | map.insert( DateDay, QString::number( data->date.day() ) ); | 337 | map.insert( DateDay, QString::number( data->date.day() ) ); |
333 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 338 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
334 | map.insert( DateYear, QString::number( data->date.year() ) ); | 339 | map.insert( DateYear, QString::number( data->date.year() ) ); |
335 | map.insert( Progress, QString::number( data->prog ) ); | 340 | map.insert( Progress, QString::number( data->prog ) ); |
336 | map.insert( CrossReference, crossToString() ); | 341 | map.insert( CrossReference, crossToString() ); |
337 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); | 342 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); |
338 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); | 343 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); |
339 | 344 | ||
340 | return map; | 345 | return map; |
341 | } | 346 | } |
342 | 347 | ||
343 | QMap<QString, QString> OTodo::toExtraMap()const { | 348 | QMap<QString, QString> OTodo::toExtraMap()const { |
344 | return data->extra; | 349 | return data->extra; |
345 | } | 350 | } |
346 | /** | 351 | /** |
347 | * change or modify looks at the ref count and either | 352 | * change or modify looks at the ref count and either |
348 | * creates a new QShared Object or it can modify it | 353 | * creates a new QShared Object or it can modify it |
349 | * right in place | 354 | * right in place |
350 | */ | 355 | */ |
351 | void OTodo::changeOrModify() { | 356 | void OTodo::changeOrModify() { |
352 | if ( data->count != 1 ) { | 357 | if ( data->count != 1 ) { |
353 | //qWarning("changeOrModify"); | 358 | qWarning("changeOrModify"); |
354 | data->deref(); | 359 | data->deref(); |
355 | OTodoData* d2 = new OTodoData(); | 360 | OTodoData* d2 = new OTodoData(); |
356 | copy(data, d2 ); | 361 | copy(data, d2 ); |
357 | data = d2; | 362 | data = d2; |
358 | } | 363 | } |
359 | } | 364 | } |
360 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 365 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
361 | dest->date = src->date; | 366 | dest->date = src->date; |
362 | dest->isCompleted = src->isCompleted; | 367 | dest->isCompleted = src->isCompleted; |
363 | dest->hasDate = src->hasDate; | 368 | dest->hasDate = src->hasDate; |
364 | dest->priority = src->priority; | 369 | dest->priority = src->priority; |
365 | dest->desc = src->desc; | 370 | dest->desc = src->desc; |
366 | dest->sum = src->sum; | 371 | dest->sum = src->sum; |
367 | dest->extra = src->extra; | 372 | dest->extra = src->extra; |
368 | dest->prog = src->prog; | 373 | dest->prog = src->prog; |
369 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 374 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
370 | dest->alarmDateTime = src->alarmDateTime; | 375 | dest->alarmDateTime = src->alarmDateTime; |
371 | } | 376 | } |
372 | QString OTodo::type() const { | 377 | QString OTodo::type() const { |
373 | return QString::fromLatin1("OTodo"); | 378 | return QString::fromLatin1("OTodo"); |
374 | } | 379 | } |
375 | QString OTodo::recordField(int id )const { | 380 | QString OTodo::recordField(int id )const { |
376 | return QString::null; | 381 | return QString::null; |
377 | } | 382 | } |
378 | 383 | ||