summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimtodo.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp
index 16ca987..5bdc648 100644
--- a/libopie2/opiepim/core/opimtodo.cpp
+++ b/libopie2/opiepim/core/opimtodo.cpp
@@ -56,150 +56,158 @@ struct OPimTodo::OPimTodoData : public QShared
56 { 56 {
57 recur = 0; 57 recur = 0;
58 state = 0; 58 state = 0;
59 maintainer = 0; 59 maintainer = 0;
60 notifiers = 0; 60 notifiers = 0;
61 }; 61 };
62 ~OPimTodoData() 62 ~OPimTodoData()
63 { 63 {
64 delete recur; 64 delete recur;
65 delete maintainer; 65 delete maintainer;
66 delete notifiers; 66 delete notifiers;
67 delete state; 67 delete state;
68 } 68 }
69 69
70 QDate date; 70 QDate date;
71 bool isCompleted: 1; 71 bool isCompleted: 1;
72 bool hasDate: 1; 72 bool hasDate: 1;
73 int priority; 73 int priority;
74 QString desc; 74 QString desc;
75 QString sum; 75 QString sum;
76 QMap<QString, QString> extra; 76 QMap<QString, QString> extra;
77 ushort prog; 77 ushort prog;
78 OPimState *state; 78 OPimState *state;
79 OPimRecurrence *recur; 79 OPimRecurrence *recur;
80 OPimMaintainer *maintainer; 80 OPimMaintainer *maintainer;
81 QDate start; 81 QDate start;
82 QDate completed; 82 QDate completed;
83 OPimNotifyManager *notifiers; 83 OPimNotifyManager *notifiers;
84}; 84};
85 85
86 86
87OPimTodo::OPimTodo( const OPimTodo &event ) 87OPimTodo::OPimTodo( const OPimTodo &event )
88 : OPimRecord( event ), data( event.data ) 88 : OPimRecord( event ), data( event.data )
89{ 89{
90 data->ref(); 90 data->ref();
91} 91}
92 92
93 93
94OPimTodo::~OPimTodo() 94OPimTodo::~OPimTodo()
95{ 95{
96 96
97 if ( data->deref() ) 97 if ( data->deref() )
98 { 98 {
99 delete data; 99 delete data;
100 data = 0l; 100 data = 0l;
101 } 101 }
102} 102}
103 103
104 104
105OPimTodo::OPimTodo( bool completed, int priority, 105OPimTodo::OPimTodo( bool completed, int priority,
106 const QArray<int> &category, 106 const QArray<int> &category,
107 const QString& summary, 107 const QString& summary,
108 const QString &description, 108 const QString &description,
109 ushort progress, 109 ushort progress,
110 bool hasDate, QDate date, int uid ) 110 bool hasDate, QDate date, int uid )
111 : OPimRecord( uid ) 111 : OPimRecord( uid )
112{ 112{
113 setCategories( category ); 113 setCategories( category );
114 114
115 data = new OPimTodoData; 115 data = new OPimTodoData;
116 116
117 data->date = date; 117 data->date = date;
118 data->isCompleted = completed; 118 data->isCompleted = completed;
119 data->hasDate = hasDate; 119 data->hasDate = hasDate;
120 if ( priority < 1 )
121 priority = 1;
122 else if ( priority > 5 )
123 priority = 5;
120 data->priority = priority; 124 data->priority = priority;
121 data->sum = summary; 125 data->sum = summary;
122 data->prog = progress; 126 data->prog = progress;
123 data->desc = Qtopia::simplifyMultiLineSpace( description ); 127 data->desc = Qtopia::simplifyMultiLineSpace( description );
124} 128}
125 129
126 130
127OPimTodo::OPimTodo( bool completed, int priority, 131OPimTodo::OPimTodo( bool completed, int priority,
128 const QStringList &category, 132 const QStringList &category,
129 const QString& summary, 133 const QString& summary,
130 const QString &description, 134 const QString &description,
131 ushort progress, 135 ushort progress,
132 bool hasDate, QDate date, int uid ) 136 bool hasDate, QDate date, int uid )
133 : OPimRecord( uid ) 137 : OPimRecord( uid )
134{ 138{
135 setCategories( idsFromString( category.join( ";" ) ) ); 139 setCategories( idsFromString( category.join( ";" ) ) );
136 140
137 data = new OPimTodoData; 141 data = new OPimTodoData;
138 142
139 data->date = date; 143 data->date = date;
140 data->isCompleted = completed; 144 data->isCompleted = completed;
141 data->hasDate = hasDate; 145 data->hasDate = hasDate;
146 if ( priority < 1 )
147 priority = 1;
148 else if ( priority > 5 )
149 priority = 5;
142 data->priority = priority; 150 data->priority = priority;
143 data->sum = summary; 151 data->sum = summary;
144 data->prog = progress; 152 data->prog = progress;
145 data->desc = Qtopia::simplifyMultiLineSpace( description ); 153 data->desc = Qtopia::simplifyMultiLineSpace( description );
146} 154}
147 155
148 156
149bool OPimTodo::match( const QRegExp &regExp ) const 157bool OPimTodo::match( const QRegExp &regExp ) const
150{ 158{
151 if ( QString::number( data->priority ).find( regExp ) != -1 ) 159 if ( QString::number( data->priority ).find( regExp ) != -1 )
152 { 160 {
153 setLastHitField( Priority ); 161 setLastHitField( Priority );
154 return true; 162 return true;
155 } 163 }
156 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) 164 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 )
157 { 165 {
158 setLastHitField( HasDate ); 166 setLastHitField( HasDate );
159 return true; 167 return true;
160 } 168 }
161 else if ( data->desc.find( regExp ) != -1 ) 169 else if ( data->desc.find( regExp ) != -1 )
162 { 170 {
163 setLastHitField( Description ); 171 setLastHitField( Description );
164 return true; 172 return true;
165 } 173 }
166 else if ( data->sum.find( regExp ) != -1 ) 174 else if ( data->sum.find( regExp ) != -1 )
167 { 175 {
168 setLastHitField( Summary ); 176 setLastHitField( Summary );
169 return true; 177 return true;
170 } 178 }
171 return false; 179 return false;
172} 180}
173 181
174 182
175bool OPimTodo::isCompleted() const 183bool OPimTodo::isCompleted() const
176{ 184{
177 return data->isCompleted; 185 return data->isCompleted;
178} 186}
179 187
180 188
181bool OPimTodo::hasDueDate() const 189bool OPimTodo::hasDueDate() const
182{ 190{
183 return data->hasDate; 191 return data->hasDate;
184} 192}
185 193
186/** 194/**
187 * \brief Does this Todo have a start date 195 * \brief Does this Todo have a start date
188 * 196 *
189 * Does this Todo have a start date. The decision 197 * Does this Todo have a start date. The decision
190 * is based on if the internal startDate isValid 198 * is based on if the internal startDate isValid
191 * in the sense of QDate::isValid. 199 * in the sense of QDate::isValid.
192 * 200 *
193 * @return True if the startDate isValid 201 * @return True if the startDate isValid
194 * @see startDate 202 * @see startDate
195 * @see setStartDate 203 * @see setStartDate
196 * @see QDate::isValid() 204 * @see QDate::isValid()
197 */ 205 */
198bool OPimTodo::hasStartDate() const 206bool OPimTodo::hasStartDate() const
199{ 207{
200 return data->start.isValid(); 208 return data->start.isValid();
201} 209}
202 210
203/** 211/**
204 * \brief Does this Todo have a Date when it was completed 212 * \brief Does this Todo have a Date when it was completed
205 * 213 *
@@ -278,128 +286,132 @@ OPimState OPimTodo::state() const
278 286
279 287
280bool OPimTodo::hasRecurrence() const 288bool OPimTodo::hasRecurrence() const
281{ 289{
282 if ( !data->recur ) return false; 290 if ( !data->recur ) return false;
283 return data->recur->doesRecur(); 291 return data->recur->doesRecur();
284} 292}
285 293
286 294
287OPimRecurrence OPimTodo::recurrence() const 295OPimRecurrence OPimTodo::recurrence() const
288{ 296{
289 if ( !data->recur ) return OPimRecurrence(); 297 if ( !data->recur ) return OPimRecurrence();
290 298
291 return ( *data->recur ); 299 return ( *data->recur );
292} 300}
293 301
294 302
295bool OPimTodo::hasMaintainer() const 303bool OPimTodo::hasMaintainer() const
296{ 304{
297 if ( !data->maintainer ) return false; 305 if ( !data->maintainer ) return false;
298 306
299 return ( data->maintainer->mode() != OPimMaintainer::Undefined ); 307 return ( data->maintainer->mode() != OPimMaintainer::Undefined );
300} 308}
301 309
302 310
303OPimMaintainer OPimTodo::maintainer() const 311OPimMaintainer OPimTodo::maintainer() const
304{ 312{
305 if ( !data->maintainer ) return OPimMaintainer(); 313 if ( !data->maintainer ) return OPimMaintainer();
306 314
307 return ( *data->maintainer ); 315 return ( *data->maintainer );
308} 316}
309 317
310 318
311void OPimTodo::setCompleted( bool completed ) 319void OPimTodo::setCompleted( bool completed )
312{ 320{
313 changeOrModify(); 321 changeOrModify();
314 data->isCompleted = completed; 322 data->isCompleted = completed;
315} 323}
316 324
317 325
318void OPimTodo::setHasDueDate( bool hasDate ) 326void OPimTodo::setHasDueDate( bool hasDate )
319{ 327{
320 changeOrModify(); 328 changeOrModify();
321 data->hasDate = hasDate; 329 data->hasDate = hasDate;
322} 330}
323 331
324 332
325void OPimTodo::setDescription( const QString &desc ) 333void OPimTodo::setDescription( const QString &desc )
326{ 334{
327 changeOrModify(); 335 changeOrModify();
328 data->desc = Qtopia::simplifyMultiLineSpace( desc ); 336 data->desc = Qtopia::simplifyMultiLineSpace( desc );
329} 337}
330 338
331 339
332void OPimTodo::setSummary( const QString& sum ) 340void OPimTodo::setSummary( const QString& sum )
333{ 341{
334 changeOrModify(); 342 changeOrModify();
335 data->sum = sum; 343 data->sum = sum;
336} 344}
337 345
338 346
339void OPimTodo::setPriority( int prio ) 347void OPimTodo::setPriority( int prio )
340{ 348{
341 changeOrModify(); 349 changeOrModify();
350 if ( prio < 1 )
351 prio = 1;
352 else if ( prio > 5 )
353 prio = 5;
342 data->priority = prio; 354 data->priority = prio;
343} 355}
344 356
345 357
346void OPimTodo::setDueDate( const QDate& date ) 358void OPimTodo::setDueDate( const QDate& date )
347{ 359{
348 changeOrModify(); 360 changeOrModify();
349 data->date = date; 361 data->date = date;
350} 362}
351 363
352 364
353void OPimTodo::setStartDate( const QDate& date ) 365void OPimTodo::setStartDate( const QDate& date )
354{ 366{
355 changeOrModify(); 367 changeOrModify();
356 data->start = date; 368 data->start = date;
357} 369}
358 370
359 371
360void OPimTodo::setCompletedDate( const QDate& date ) 372void OPimTodo::setCompletedDate( const QDate& date )
361{ 373{
362 changeOrModify(); 374 changeOrModify();
363 data->completed = date; 375 data->completed = date;
364} 376}
365 377
366 378
367void OPimTodo::setState( const OPimState& state ) 379void OPimTodo::setState( const OPimState& state )
368{ 380{
369 changeOrModify(); 381 changeOrModify();
370 if ( data->state ) 382 if ( data->state )
371 ( *data->state ) = state; 383 ( *data->state ) = state;
372 else 384 else
373 data->state = new OPimState( state ); 385 data->state = new OPimState( state );
374} 386}
375 387
376 388
377void OPimTodo::setRecurrence( const OPimRecurrence& rec ) 389void OPimTodo::setRecurrence( const OPimRecurrence& rec )
378{ 390{
379 changeOrModify(); 391 changeOrModify();
380 if ( data->recur ) 392 if ( data->recur )
381 ( *data->recur ) = rec; 393 ( *data->recur ) = rec;
382 else 394 else
383 data->recur = new OPimRecurrence( rec ); 395 data->recur = new OPimRecurrence( rec );
384} 396}
385 397
386 398
387void OPimTodo::setMaintainer( const OPimMaintainer& pim ) 399void OPimTodo::setMaintainer( const OPimMaintainer& pim )
388{ 400{
389 changeOrModify(); 401 changeOrModify();
390 402
391 if ( data->maintainer ) 403 if ( data->maintainer )
392 ( *data->maintainer ) = pim; 404 ( *data->maintainer ) = pim;
393 else 405 else
394 data->maintainer = new OPimMaintainer( pim ); 406 data->maintainer = new OPimMaintainer( pim );
395} 407}
396 408
397 409
398bool OPimTodo::isOverdue( )const 410bool OPimTodo::isOverdue( )const
399{ 411{
400 if ( data->hasDate && !data->isCompleted ) 412 if ( data->hasDate && !data->isCompleted )
401 return QDate::currentDate() > data->date; 413 return QDate::currentDate() > data->date;
402 return false; 414 return false;
403} 415}
404 416
405 417