-rw-r--r-- | libopie2/opiepim/otodo.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index b3c14e6..cc46b21 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -27,71 +27,72 @@ struct OTodo::OTodoData : public QShared { | |||
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 | |
43 | // qWarning("~OTodo " ); | ||
43 | if ( data->deref() ) { | 44 | if ( data->deref() ) { |
44 | qWarning("OTodo::dereffing"); | 45 | // qWarning("OTodo::dereffing"); |
45 | delete data; | 46 | delete data; |
46 | data = 0l; | 47 | data = 0l; |
47 | } | 48 | } |
48 | } | 49 | } |
49 | OTodo::OTodo(bool completed, int priority, | 50 | OTodo::OTodo(bool completed, int priority, |
50 | const QArray<int> &category, | 51 | const QArray<int> &category, |
51 | const QString& summary, | 52 | const QString& summary, |
52 | const QString &description, | 53 | const QString &description, |
53 | ushort progress, | 54 | ushort progress, |
54 | bool hasDate, QDate date, int uid ) | 55 | bool hasDate, QDate date, int uid ) |
55 | : OPimRecord( uid ) | 56 | : OPimRecord( uid ) |
56 | { | 57 | { |
57 | qWarning("OTodoData " + summary); | 58 | // qWarning("OTodoData " + summary); |
58 | setCategories( category ); | 59 | setCategories( category ); |
59 | 60 | ||
60 | data = new OTodoData; | 61 | data = new OTodoData; |
61 | 62 | ||
62 | data->date = date; | 63 | data->date = date; |
63 | data->isCompleted = completed; | 64 | data->isCompleted = completed; |
64 | data->hasDate = hasDate; | 65 | data->hasDate = hasDate; |
65 | data->priority = priority; | 66 | data->priority = priority; |
66 | data->sum = summary; | 67 | data->sum = summary; |
67 | data->prog = progress; | 68 | data->prog = progress; |
68 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 69 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
69 | data->hasAlarmDateTime = false; | 70 | data->hasAlarmDateTime = false; |
70 | 71 | ||
71 | } | 72 | } |
72 | OTodo::OTodo(bool completed, int priority, | 73 | OTodo::OTodo(bool completed, int priority, |
73 | const QStringList &category, | 74 | const QStringList &category, |
74 | const QString& summary, | 75 | const QString& summary, |
75 | const QString &description, | 76 | const QString &description, |
76 | ushort progress, | 77 | ushort progress, |
77 | bool hasDate, QDate date, int uid ) | 78 | bool hasDate, QDate date, int uid ) |
78 | : OPimRecord( uid ) | 79 | : OPimRecord( uid ) |
79 | { | 80 | { |
80 | qWarning("OTodoData" + summary); | 81 | // qWarning("OTodoData" + summary); |
81 | setCategories( idsFromString( category.join(";") ) ); | 82 | setCategories( idsFromString( category.join(";") ) ); |
82 | 83 | ||
83 | data = new OTodoData; | 84 | data = new OTodoData; |
84 | data->date = date; | ||
85 | 85 | ||
86 | data->date = date; | ||
86 | data->isCompleted = completed; | 87 | data->isCompleted = completed; |
87 | data->hasDate = hasDate; | 88 | data->hasDate = hasDate; |
88 | data->priority = priority; | 89 | data->priority = priority; |
89 | data->sum = summary; | 90 | data->sum = summary; |
90 | data->prog = progress; | 91 | data->prog = progress; |
91 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 92 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
92 | data->hasAlarmDateTime = false; | 93 | data->hasAlarmDateTime = false; |
93 | 94 | ||
94 | } | 95 | } |
95 | bool OTodo::match( const QRegExp ®Exp )const | 96 | bool OTodo::match( const QRegExp ®Exp )const |
96 | { | 97 | { |
97 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 98 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
@@ -151,24 +152,25 @@ void OTodo::setCompleted( bool completed ) | |||
151 | void OTodo::setHasDueDate( bool hasDate ) | 152 | void OTodo::setHasDueDate( bool hasDate ) |
152 | { | 153 | { |
153 | changeOrModify(); | 154 | changeOrModify(); |
154 | data->hasDate = hasDate; | 155 | data->hasDate = hasDate; |
155 | } | 156 | } |
156 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) | 157 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) |
157 | { | 158 | { |
158 | changeOrModify(); | 159 | changeOrModify(); |
159 | data->hasAlarmDateTime = hasAlarmDateTime; | 160 | data->hasAlarmDateTime = hasAlarmDateTime; |
160 | } | 161 | } |
161 | void OTodo::setDescription(const QString &desc ) | 162 | void OTodo::setDescription(const QString &desc ) |
162 | { | 163 | { |
164 | qWarning( "desc " + desc ); | ||
163 | changeOrModify(); | 165 | changeOrModify(); |
164 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 166 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
165 | } | 167 | } |
166 | void OTodo::setSummary( const QString& sum ) | 168 | void OTodo::setSummary( const QString& sum ) |
167 | { | 169 | { |
168 | changeOrModify(); | 170 | changeOrModify(); |
169 | data->sum = sum; | 171 | data->sum = sum; |
170 | } | 172 | } |
171 | void OTodo::setPriority(int prio ) | 173 | void OTodo::setPriority(int prio ) |
172 | { | 174 | { |
173 | changeOrModify(); | 175 | changeOrModify(); |
174 | data->priority = prio; | 176 | data->priority = prio; |
@@ -302,33 +304,34 @@ bool OTodo::operator==(const OTodo &toDoEvent )const | |||
302 | return false; | 304 | return false; |
303 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) | 305 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) |
304 | return false; | 306 | return false; |
305 | 307 | ||
306 | return OPimRecord::operator==( toDoEvent ); | 308 | return OPimRecord::operator==( toDoEvent ); |
307 | } | 309 | } |
308 | void OTodo::deref() { | 310 | void OTodo::deref() { |
309 | 311 | ||
310 | //qWarning("deref in ToDoEvent"); | 312 | //qWarning("deref in ToDoEvent"); |
311 | if ( data->deref() ) { | 313 | if ( data->deref() ) { |
312 | //qWarning("deleting"); | 314 | //qWarning("deleting"); |
313 | delete data; | 315 | delete data; |
314 | d= 0; | 316 | data= 0; |
315 | } | 317 | } |
316 | } | 318 | } |
317 | OTodo &OTodo::operator=(const OTodo &item ) | 319 | OTodo &OTodo::operator=(const OTodo &item ) |
318 | { | 320 | { |
319 | OPimRecord::operator=( item ); | 321 | // OPimRecord::operator=( item ); |
320 | //qWarning("operator= ref "); | 322 | //qWarning("operator= ref "); |
321 | item.data->ref(); | 323 | item.data->ref(); |
322 | deref(); | 324 | deref(); |
325 | data = item.data; | ||
323 | 326 | ||
324 | return *this; | 327 | return *this; |
325 | } | 328 | } |
326 | 329 | ||
327 | QMap<int, QString> OTodo::toMap() const { | 330 | QMap<int, QString> OTodo::toMap() const { |
328 | QMap<int, QString> map; | 331 | QMap<int, QString> map; |
329 | 332 | ||
330 | map.insert( Uid, QString::number( uid() ) ); | 333 | map.insert( Uid, QString::number( uid() ) ); |
331 | map.insert( Category, idsToString( categories() ) ); | 334 | map.insert( Category, idsToString( categories() ) ); |
332 | map.insert( HasDate, QString::number( data->hasDate ) ); | 335 | map.insert( HasDate, QString::number( data->hasDate ) ); |
333 | map.insert( Completed, QString::number( data->isCompleted ) ); | 336 | map.insert( Completed, QString::number( data->isCompleted ) ); |
334 | map.insert( Description, data->desc ); | 337 | map.insert( Description, data->desc ); |
@@ -346,25 +349,25 @@ QMap<int, QString> OTodo::toMap() const { | |||
346 | } | 349 | } |
347 | 350 | ||
348 | QMap<QString, QString> OTodo::toExtraMap()const { | 351 | QMap<QString, QString> OTodo::toExtraMap()const { |
349 | return data->extra; | 352 | return data->extra; |
350 | } | 353 | } |
351 | /** | 354 | /** |
352 | * change or modify looks at the ref count and either | 355 | * change or modify looks at the ref count and either |
353 | * creates a new QShared Object or it can modify it | 356 | * creates a new QShared Object or it can modify it |
354 | * right in place | 357 | * right in place |
355 | */ | 358 | */ |
356 | void OTodo::changeOrModify() { | 359 | void OTodo::changeOrModify() { |
357 | if ( data->count != 1 ) { | 360 | if ( data->count != 1 ) { |
358 | qWarning("changeOrModify"); | 361 | // qWarning("changeOrModify"); |
359 | data->deref(); | 362 | data->deref(); |
360 | OTodoData* d2 = new OTodoData(); | 363 | OTodoData* d2 = new OTodoData(); |
361 | copy(data, d2 ); | 364 | copy(data, d2 ); |
362 | data = d2; | 365 | data = d2; |
363 | } | 366 | } |
364 | } | 367 | } |
365 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 368 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
366 | dest->date = src->date; | 369 | dest->date = src->date; |
367 | dest->isCompleted = src->isCompleted; | 370 | dest->isCompleted = src->isCompleted; |
368 | dest->hasDate = src->hasDate; | 371 | dest->hasDate = src->hasDate; |
369 | dest->priority = src->priority; | 372 | dest->priority = src->priority; |
370 | dest->desc = src->desc; | 373 | dest->desc = src->desc; |