summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodo.cpp2
-rw-r--r--libopie2/opiepim/otodo.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 5a18c37..189bf94 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -34,487 +34,487 @@ struct OTodo::OTodoData : public QShared {
34 delete notifiers; 34 delete notifiers;
35 } 35 }
36 36
37 QDate date; 37 QDate date;
38 bool isCompleted:1; 38 bool isCompleted:1;
39 bool hasDate:1; 39 bool hasDate:1;
40 int priority; 40 int priority;
41 QString desc; 41 QString desc;
42 QString sum; 42 QString sum;
43 QMap<QString, QString> extra; 43 QMap<QString, QString> extra;
44 ushort prog; 44 ushort prog;
45 OPimState *state; 45 OPimState *state;
46 ORecur *recur; 46 ORecur *recur;
47 OPimMaintainer *maintainer; 47 OPimMaintainer *maintainer;
48 QDate start; 48 QDate start;
49 QDate completed; 49 QDate completed;
50 OPimNotifyManager *notifiers; 50 OPimNotifyManager *notifiers;
51}; 51};
52 52
53OTodo::OTodo(const OTodo &event ) 53OTodo::OTodo(const OTodo &event )
54 : OPimRecord( event ), data( event.data ) 54 : OPimRecord( event ), data( event.data )
55{ 55{
56 data->ref(); 56 data->ref();
57// qWarning("ref up"); 57// qWarning("ref up");
58} 58}
59OTodo::~OTodo() { 59OTodo::~OTodo() {
60 60
61// qWarning("~OTodo " ); 61// qWarning("~OTodo " );
62 if ( data->deref() ) { 62 if ( data->deref() ) {
63// qWarning("OTodo::dereffing"); 63// qWarning("OTodo::dereffing");
64 delete data; 64 delete data;
65 data = 0l; 65 data = 0l;
66 } 66 }
67} 67}
68OTodo::OTodo(bool completed, int priority, 68OTodo::OTodo(bool completed, int priority,
69 const QArray<int> &category, 69 const QArray<int> &category,
70 const QString& summary, 70 const QString& summary,
71 const QString &description, 71 const QString &description,
72 ushort progress, 72 ushort progress,
73 bool hasDate, QDate date, int uid ) 73 bool hasDate, QDate date, int uid )
74 : OPimRecord( uid ) 74 : OPimRecord( uid )
75{ 75{
76// qWarning("OTodoData " + summary); 76// qWarning("OTodoData " + summary);
77 setCategories( category ); 77 setCategories( category );
78 78
79 data = new OTodoData; 79 data = new OTodoData;
80 80
81 data->date = date; 81 data->date = date;
82 data->isCompleted = completed; 82 data->isCompleted = completed;
83 data->hasDate = hasDate; 83 data->hasDate = hasDate;
84 data->priority = priority; 84 data->priority = priority;
85 data->sum = summary; 85 data->sum = summary;
86 data->prog = progress; 86 data->prog = progress;
87 data->desc = Qtopia::simplifyMultiLineSpace(description ); 87 data->desc = Qtopia::simplifyMultiLineSpace(description );
88} 88}
89OTodo::OTodo(bool completed, int priority, 89OTodo::OTodo(bool completed, int priority,
90 const QStringList &category, 90 const QStringList &category,
91 const QString& summary, 91 const QString& summary,
92 const QString &description, 92 const QString &description,
93 ushort progress, 93 ushort progress,
94 bool hasDate, QDate date, int uid ) 94 bool hasDate, QDate date, int uid )
95 : OPimRecord( uid ) 95 : OPimRecord( uid )
96{ 96{
97// qWarning("OTodoData" + summary); 97// qWarning("OTodoData" + summary);
98 setCategories( idsFromString( category.join(";") ) ); 98 setCategories( idsFromString( category.join(";") ) );
99 99
100 data = new OTodoData; 100 data = new OTodoData;
101 101
102 data->date = date; 102 data->date = date;
103 data->isCompleted = completed; 103 data->isCompleted = completed;
104 data->hasDate = hasDate; 104 data->hasDate = hasDate;
105 data->priority = priority; 105 data->priority = priority;
106 data->sum = summary; 106 data->sum = summary;
107 data->prog = progress; 107 data->prog = progress;
108 data->desc = Qtopia::simplifyMultiLineSpace(description ); 108 data->desc = Qtopia::simplifyMultiLineSpace(description );
109} 109}
110bool OTodo::match( const QRegExp &regExp )const 110bool OTodo::match( const QRegExp &regExp )const
111{ 111{
112 if( QString::number( data->priority ).find( regExp ) != -1 ){ 112 if( QString::number( data->priority ).find( regExp ) != -1 ){
113 setLastHitField( Priority ); 113 setLastHitField( Priority );
114 return true; 114 return true;
115 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 115 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
116 setLastHitField( HasDate ); 116 setLastHitField( HasDate );
117 return true; 117 return true;
118 }else if(data->desc.find( regExp ) != -1 ){ 118 }else if(data->desc.find( regExp ) != -1 ){
119 setLastHitField( Description ); 119 setLastHitField( Description );
120 return true; 120 return true;
121 }else if(data->sum.find( regExp ) != -1 ) { 121 }else if(data->sum.find( regExp ) != -1 ) {
122 setLastHitField( Summary ); 122 setLastHitField( Summary );
123 return true; 123 return true;
124 } 124 }
125 return false; 125 return false;
126} 126}
127bool OTodo::isCompleted() const 127bool OTodo::isCompleted() const
128{ 128{
129 return data->isCompleted; 129 return data->isCompleted;
130} 130}
131bool OTodo::hasDueDate() const 131bool OTodo::hasDueDate() const
132{ 132{
133 return data->hasDate; 133 return data->hasDate;
134} 134}
135bool OTodo::hasStartDate()const { 135bool OTodo::hasStartDate()const {
136 return data->start.isValid(); 136 return data->start.isValid();
137} 137}
138bool OTodo::hasCompletedDate()const { 138bool OTodo::hasCompletedDate()const {
139 return data->completed.isValid(); 139 return data->completed.isValid();
140} 140}
141int OTodo::priority()const 141int OTodo::priority()const
142{ 142{
143 return data->priority; 143 return data->priority;
144} 144}
145QString OTodo::summary() const 145QString OTodo::summary() const
146{ 146{
147 return data->sum; 147 return data->sum;
148} 148}
149ushort OTodo::progress() const 149ushort OTodo::progress() const
150{ 150{
151 return data->prog; 151 return data->prog;
152} 152}
153QDate OTodo::dueDate()const 153QDate OTodo::dueDate()const
154{ 154{
155 return data->date; 155 return data->date;
156} 156}
157QDate OTodo::startDate()const { 157QDate OTodo::startDate()const {
158 return data->start; 158 return data->start;
159} 159}
160QDate OTodo::completedDate()const { 160QDate OTodo::completedDate()const {
161 return data->completed; 161 return data->completed;
162} 162}
163QString OTodo::description()const 163QString OTodo::description()const
164{ 164{
165 return data->desc; 165 return data->desc;
166} 166}
167bool OTodo::hasState() const{ 167bool OTodo::hasState() const{
168 if (!data->state ) return false; 168 if (!data->state ) return false;
169 return ( data->state->state() != OPimState::Undefined ); 169 return ( data->state->state() != OPimState::Undefined );
170} 170}
171OPimState OTodo::state()const { 171OPimState OTodo::state()const {
172 if (!data->state ) { 172 if (!data->state ) {
173 OPimState state; 173 OPimState state;
174 return state; 174 return state;
175 } 175 }
176 176
177 return (*data->state); 177 return (*data->state);
178} 178}
179bool OTodo::hasRecurrence()const { 179bool OTodo::hasRecurrence()const {
180 if (!data->recur) return false; 180 if (!data->recur) return false;
181 return data->recur->doesRecur(); 181 return data->recur->doesRecur();
182} 182}
183ORecur OTodo::recurrence()const { 183ORecur OTodo::recurrence()const {
184 if (!data->recur) return ORecur(); 184 if (!data->recur) return ORecur();
185 185
186 return (*data->recur); 186 return (*data->recur);
187} 187}
188bool OTodo::hasMaintainer()const { 188bool OTodo::hasMaintainer()const {
189 if (!data->maintainer) return false; 189 if (!data->maintainer) return false;
190 190
191 return (data->maintainer->mode() != OPimMaintainer::Undefined ); 191 return (data->maintainer->mode() != OPimMaintainer::Undefined );
192} 192}
193OPimMaintainer OTodo::maintainer()const { 193OPimMaintainer OTodo::maintainer()const {
194 if (!data->maintainer) return OPimMaintainer(); 194 if (!data->maintainer) return OPimMaintainer();
195 195
196 return (*data->maintainer); 196 return (*data->maintainer);
197} 197}
198void OTodo::setCompleted( bool completed ) 198void OTodo::setCompleted( bool completed )
199{ 199{
200 changeOrModify(); 200 changeOrModify();
201 data->isCompleted = completed; 201 data->isCompleted = completed;
202} 202}
203void OTodo::setHasDueDate( bool hasDate ) 203void OTodo::setHasDueDate( bool hasDate )
204{ 204{
205 changeOrModify(); 205 changeOrModify();
206 data->hasDate = hasDate; 206 data->hasDate = hasDate;
207} 207}
208void OTodo::setDescription(const QString &desc ) 208void OTodo::setDescription(const QString &desc )
209{ 209{
210// qWarning( "desc " + desc ); 210// qWarning( "desc " + desc );
211 changeOrModify(); 211 changeOrModify();
212 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 212 data->desc = Qtopia::simplifyMultiLineSpace(desc );
213} 213}
214void OTodo::setSummary( const QString& sum ) 214void OTodo::setSummary( const QString& sum )
215{ 215{
216 changeOrModify(); 216 changeOrModify();
217 data->sum = sum; 217 data->sum = sum;
218} 218}
219void OTodo::setPriority(int prio ) 219void OTodo::setPriority(int prio )
220{ 220{
221 changeOrModify(); 221 changeOrModify();
222 data->priority = prio; 222 data->priority = prio;
223} 223}
224void OTodo::setDueDate( const QDate& date ) 224void OTodo::setDueDate( const QDate& date )
225{ 225{
226 changeOrModify(); 226 changeOrModify();
227 data->date = date; 227 data->date = date;
228} 228}
229void OTodo::setStartDate( const QDate& date ) { 229void OTodo::setStartDate( const QDate& date ) {
230 changeOrModify(); 230 changeOrModify();
231 data->start = date; 231 data->start = date;
232} 232}
233void OTodo::setCompletedDate( const QDate& date ) { 233void OTodo::setCompletedDate( const QDate& date ) {
234 changeOrModify(); 234 changeOrModify();
235 data->completed = date; 235 data->completed = date;
236} 236}
237void OTodo::setState( const OPimState& state ) { 237void OTodo::setState( const OPimState& state ) {
238 changeOrModify(); 238 changeOrModify();
239 if (data->state ) 239 if (data->state )
240 (*data->state) = state; 240 (*data->state) = state;
241 else 241 else
242 data->state = new OPimState( state ); 242 data->state = new OPimState( state );
243} 243}
244void OTodo::setRecurrence( const ORecur& rec) { 244void OTodo::setRecurrence( const ORecur& rec) {
245 changeOrModify(); 245 changeOrModify();
246 if (data->recur ) 246 if (data->recur )
247 (*data->recur) = rec; 247 (*data->recur) = rec;
248 else 248 else
249 data->recur = new ORecur( rec ); 249 data->recur = new ORecur( rec );
250} 250}
251void OTodo::setMaintainer( const OPimMaintainer& pim ) { 251void OTodo::setMaintainer( const OPimMaintainer& pim ) {
252 changeOrModify(); 252 changeOrModify();
253 253
254 if (data->maintainer ) 254 if (data->maintainer )
255 (*data->maintainer) = pim; 255 (*data->maintainer) = pim;
256 else 256 else
257 data->maintainer = new OPimMaintainer( pim ); 257 data->maintainer = new OPimMaintainer( pim );
258} 258}
259bool OTodo::isOverdue( ) 259bool OTodo::isOverdue( )
260{ 260{
261 if( data->hasDate && !data->isCompleted) 261 if( data->hasDate && !data->isCompleted)
262 return QDate::currentDate() > data->date; 262 return QDate::currentDate() > data->date;
263 return false; 263 return false;
264} 264}
265void OTodo::setProgress(ushort progress ) 265void OTodo::setProgress(ushort progress )
266{ 266{
267 changeOrModify(); 267 changeOrModify();
268 data->prog = progress; 268 data->prog = progress;
269} 269}
270QString OTodo::toShortText() const { 270QString OTodo::toShortText() const {
271 return summary(); 271 return summary();
272} 272}
273/*! 273/*!
274 Returns a richt text string 274 Returns a richt text string
275*/ 275*/
276QString OTodo::toRichText() const 276QString OTodo::toRichText() const
277{ 277{
278 QString text; 278 QString text;
279 QStringList catlist; 279 QStringList catlist;
280 280
281 // summary 281 // summary
282 text += "<b><h3><img src=\"todo/TodoList\"> "; 282 text += "<b><h3><img src=\"todo/TodoList\"> ";
283 if ( !summary().isEmpty() ) { 283 if ( !summary().isEmpty() ) {
284 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); 284 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
285 } 285 }
286 text += "</h3></b><br><hr><br>"; 286 text += "</h3></b><br><hr><br>";
287 287
288 // description 288 // description
289 if( !description().isEmpty() ){ 289 if( !description().isEmpty() ){
290 text += "<b>" + QObject::tr( "Notes:" ) + "</b><br>"; 290 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
291 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 291 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
292 } 292 }
293 293
294 // priority 294 // priority
295 int priorityval = priority(); 295 int priorityval = priority();
296 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + 296 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" +
297 QString::number( priorityval ) + "\"> "; 297 QString::number( priorityval ) + "\"> ";
298 298
299 switch ( priorityval ) 299 switch ( priorityval )
300 { 300 {
301 case 1 : text += QObject::tr( "Very high" ); 301 case 1 : text += QObject::tr( "Very high" );
302 break; 302 break;
303 case 2 : text += QObject::tr( "High" ); 303 case 2 : text += QObject::tr( "High" );
304 break; 304 break;
305 case 3 : text += QObject::tr( "Normal" ); 305 case 3 : text += QObject::tr( "Normal" );
306 break; 306 break;
307 case 4 : text += QObject::tr( "Low" ); 307 case 4 : text += QObject::tr( "Low" );
308 break; 308 break;
309 case 5 : text += QObject::tr( "Very low" ); 309 case 5 : text += QObject::tr( "Very low" );
310 break; 310 break;
311 }; 311 };
312 text += "<br>"; 312 text += "<br>";
313 313
314 // progress 314 // progress
315 text += "<b>" + QObject::tr( "Progress:") + " </b>" 315 text += "<b>" + QObject::tr( "Progress:") + " </b>"
316 + QString::number( progress() ) + " %<br>"; 316 + QString::number( progress() ) + " %<br>";
317 317
318 // due date 318 // due date
319 if (hasDueDate() ){ 319 if (hasDueDate() ){
320 QDate dd = dueDate(); 320 QDate dd = dueDate();
321 int off = QDate::currentDate().daysTo( dd ); 321 int off = QDate::currentDate().daysTo( dd );
322 322
323 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; 323 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
324 if ( off < 0 ) 324 if ( off < 0 )
325 text += "#FF0000"; 325 text += "#FF0000";
326 else if ( off == 0 ) 326 else if ( off == 0 )
327 text += "#FFFF00"; 327 text += "#FFFF00";
328 else if ( off > 0 ) 328 else if ( off > 0 )
329 text += "#00FF00"; 329 text += "#00FF00";
330 330
331 text += "\">" + dd.toString() + "</font><br>"; 331 text += "\">" + dd.toString() + "</font><br>";
332 } 332 }
333 333
334 // categories 334 // categories
335 text += "<b>" + QObject::tr( "Category:") + "</b> "; 335 text += "<b>" + QObject::tr( "Category:") + "</b> ";
336 text += categoryNames( "Todo List" ).join(", "); 336 text += categoryNames( "Todo List" ).join(", ");
337 text += "<br>"; 337 text += "<br>";
338 338
339 return text; 339 return text;
340} 340}
341bool OTodo::hasNotifiers()const { 341bool OTodo::hasNotifiers()const {
342 if (!data->notifiers) return false; 342 if (!data->notifiers) return false;
343 return !data->notifiers->isEmpty(); 343 return !data->notifiers->isEmpty();
344} 344}
345OPimNotifyManager& OTodo::notifiers() { 345OPimNotifyManager& OTodo::notifiers() {
346 if (!data->notifiers ) 346 if (!data->notifiers )
347 data->notifiers = new OPimNotifyManager; 347 data->notifiers = new OPimNotifyManager;
348 return (*data->notifiers); 348 return (*data->notifiers);
349} 349}
350const OPimNotifyManager& OTodo::notifiers()const{ 350const OPimNotifyManager& OTodo::notifiers()const{
351 if (!data->notifiers ) 351 if (!data->notifiers )
352 data->notifiers = new OPimNotifyManager; 352 data->notifiers = new OPimNotifyManager;
353 353
354 return (*data->notifiers); 354 return (*data->notifiers);
355} 355}
356 356
357bool OTodo::operator<( const OTodo &toDoEvent )const{ 357bool OTodo::operator<( const OTodo &toDoEvent )const{
358 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 358 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
359 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 359 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
360 if( hasDueDate() && toDoEvent.hasDueDate() ){ 360 if( hasDueDate() && toDoEvent.hasDueDate() ){
361 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 361 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
362 return priority() < toDoEvent.priority(); 362 return priority() < toDoEvent.priority();
363 }else{ 363 }else{
364 return dueDate() < toDoEvent.dueDate(); 364 return dueDate() < toDoEvent.dueDate();
365 } 365 }
366 } 366 }
367 return false; 367 return false;
368} 368}
369bool OTodo::operator<=(const OTodo &toDoEvent )const 369bool OTodo::operator<=(const OTodo &toDoEvent )const
370{ 370{
371 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 371 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
372 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 372 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
373 if( hasDueDate() && toDoEvent.hasDueDate() ){ 373 if( hasDueDate() && toDoEvent.hasDueDate() ){
374 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 374 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
375 return priority() <= toDoEvent.priority(); 375 return priority() <= toDoEvent.priority();
376 }else{ 376 }else{
377 return dueDate() <= toDoEvent.dueDate(); 377 return dueDate() <= toDoEvent.dueDate();
378 } 378 }
379 } 379 }
380 return true; 380 return true;
381} 381}
382bool OTodo::operator>(const OTodo &toDoEvent )const 382bool OTodo::operator>(const OTodo &toDoEvent )const
383{ 383{
384 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 384 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
385 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 385 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
386 if( hasDueDate() && toDoEvent.hasDueDate() ){ 386 if( hasDueDate() && toDoEvent.hasDueDate() ){
387 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 387 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
388 return priority() > toDoEvent.priority(); 388 return priority() > toDoEvent.priority();
389 }else{ 389 }else{
390 return dueDate() > toDoEvent.dueDate(); 390 return dueDate() > toDoEvent.dueDate();
391 } 391 }
392 } 392 }
393 return false; 393 return false;
394} 394}
395bool OTodo::operator>=(const OTodo &toDoEvent )const 395bool OTodo::operator>=(const OTodo &toDoEvent )const
396{ 396{
397 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 397 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
398 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 398 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
399 if( hasDueDate() && toDoEvent.hasDueDate() ){ 399 if( hasDueDate() && toDoEvent.hasDueDate() ){
400 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 400 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
401 return priority() > toDoEvent.priority(); 401 return priority() > toDoEvent.priority();
402 }else{ 402 }else{
403 return dueDate() > toDoEvent.dueDate(); 403 return dueDate() > toDoEvent.dueDate();
404 } 404 }
405 } 405 }
406 return true; 406 return true;
407} 407}
408bool OTodo::operator==(const OTodo &toDoEvent )const 408bool OTodo::operator==(const OTodo &toDoEvent )const
409{ 409{
410 if ( data->priority != toDoEvent.data->priority ) return false; 410 if ( data->priority != toDoEvent.data->priority ) return false;
411 if ( data->priority != toDoEvent.data->prog ) return false; 411 if ( data->priority != toDoEvent.data->prog ) return false;
412 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 412 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
413 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 413 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
414 if ( data->date != toDoEvent.data->date ) return false; 414 if ( data->date != toDoEvent.data->date ) return false;
415 if ( data->sum != toDoEvent.data->sum ) return false; 415 if ( data->sum != toDoEvent.data->sum ) return false;
416 if ( data->desc != toDoEvent.data->desc ) return false; 416 if ( data->desc != toDoEvent.data->desc ) return false;
417 if ( data->maintainer != toDoEvent.data->maintainer ) 417 if ( data->maintainer != toDoEvent.data->maintainer )
418 return false; 418 return false;
419 419
420 return OPimRecord::operator==( toDoEvent ); 420 return OPimRecord::operator==( toDoEvent );
421} 421}
422void OTodo::deref() { 422void OTodo::deref() {
423 423
424// qWarning("deref in ToDoEvent"); 424// qWarning("deref in ToDoEvent");
425 if ( data->deref() ) { 425 if ( data->deref() ) {
426// qWarning("deleting"); 426// qWarning("deleting");
427 delete data; 427 delete data;
428 data= 0; 428 data= 0;
429 } 429 }
430} 430}
431OTodo &OTodo::operator=(const OTodo &item ) 431OTodo &OTodo::operator=(const OTodo &item )
432{ 432{
433 if ( this == &item ) return *this; 433 if ( this == &item ) return *this;
434 434
435 OPimRecord::operator=( item ); 435 OPimRecord::operator=( item );
436 //qWarning("operator= ref "); 436 //qWarning("operator= ref ");
437 item.data->ref(); 437 item.data->ref();
438 deref(); 438 deref();
439 data = item.data; 439 data = item.data;
440 440
441 return *this; 441 return *this;
442} 442}
443 443
444QMap<int, QString> OTodo::toMap() const { 444QMap<int, QString> OTodo::toMap() const {
445 QMap<int, QString> map; 445 QMap<int, QString> map;
446 446
447 map.insert( Uid, QString::number( uid() ) ); 447 map.insert( Uid, QString::number( uid() ) );
448 map.insert( Category, idsToString( categories() ) ); 448 map.insert( Category, idsToString( categories() ) );
449 map.insert( HasDate, QString::number( data->hasDate ) ); 449 map.insert( HasDate, QString::number( data->hasDate ) );
450 map.insert( Completed, QString::number( data->isCompleted ) ); 450 map.insert( Completed, QString::number( data->isCompleted ) );
451 map.insert( Description, data->desc ); 451 map.insert( Description, data->desc );
452 map.insert( Summary, data->sum ); 452 map.insert( Summary, data->sum );
453 map.insert( Priority, QString::number( data->priority ) ); 453 map.insert( Priority, QString::number( data->priority ) );
454 map.insert( DateDay, QString::number( data->date.day() ) ); 454 map.insert( DateDay, QString::number( data->date.day() ) );
455 map.insert( DateMonth, QString::number( data->date.month() ) ); 455 map.insert( DateMonth, QString::number( data->date.month() ) );
456 map.insert( DateYear, QString::number( data->date.year() ) ); 456 map.insert( DateYear, QString::number( data->date.year() ) );
457 map.insert( Progress, QString::number( data->prog ) ); 457 map.insert( Progress, QString::number( data->prog ) );
458// map.insert( CrossReference, crossToString() ); 458// map.insert( CrossReference, crossToString() );
459 /* FIXME!!! map.insert( State, ); 459 /* FIXME!!! map.insert( State, );
460 map.insert( Recurrence, ); 460 map.insert( Recurrence, );
461 map.insert( Reminders, ); 461 map.insert( Reminders, );
462 map. 462 map.
463 */ 463 */
464 return map; 464 return map;
465} 465}
466 466
467/** 467/**
468 * change or modify looks at the ref count and either 468 * change or modify looks at the ref count and either
469 * creates a new QShared Object or it can modify it 469 * creates a new QShared Object or it can modify it
470 * right in place 470 * right in place
471 */ 471 */
472void OTodo::changeOrModify() { 472void OTodo::changeOrModify() {
473 if ( data->count != 1 ) { 473 if ( data->count != 1 ) {
474 qWarning("changeOrModify"); 474 qWarning("changeOrModify");
475 data->deref(); 475 data->deref();
476 OTodoData* d2 = new OTodoData(); 476 OTodoData* d2 = new OTodoData();
477 copy(data, d2 ); 477 copy(data, d2 );
478 data = d2; 478 data = d2;
479 } 479 }
480} 480}
481// WATCHOUT 481// WATCHOUT
482/* 482/*
483 * if you add something to the Data struct 483 * if you add something to the Data struct
484 * be sure to copy it here 484 * be sure to copy it here
485 */ 485 */
486void OTodo::copy( OTodoData* src, OTodoData* dest ) { 486void OTodo::copy( OTodoData* src, OTodoData* dest ) {
487 dest->date = src->date; 487 dest->date = src->date;
488 dest->isCompleted = src->isCompleted; 488 dest->isCompleted = src->isCompleted;
489 dest->hasDate = src->hasDate; 489 dest->hasDate = src->hasDate;
490 dest->priority = src->priority; 490 dest->priority = src->priority;
491 dest->desc = src->desc; 491 dest->desc = src->desc;
492 dest->sum = src->sum; 492 dest->sum = src->sum;
493 dest->extra = src->extra; 493 dest->extra = src->extra;
494 dest->prog = src->prog; 494 dest->prog = src->prog;
495 495
496 if (src->state ) 496 if (src->state )
497 dest->state = new OPimState( *src->state ); 497 dest->state = new OPimState( *src->state );
498 498
499 if (src->recur ) 499 if (src->recur )
500 dest->recur = new ORecur( *src->recur ); 500 dest->recur = new ORecur( *src->recur );
501 501
502 if (src->maintainer ) 502 if (src->maintainer )
503 dest->maintainer = new OPimMaintainer( *src->maintainer ) 503 dest->maintainer = new OPimMaintainer( *src->maintainer )
504 ; 504 ;
505 dest->start = src->start; 505 dest->start = src->start;
506 dest->completed = src->completed; 506 dest->completed = src->completed;
507 507
508 if (src->notifiers ) 508 if (src->notifiers )
509 dest->notifiers = new OPimNotifyManager( *src->notifiers ); 509 dest->notifiers = new OPimNotifyManager( *src->notifiers );
510} 510}
511QString OTodo::type() const { 511QString OTodo::type() const {
512 return QString::fromLatin1("OTodo"); 512 return QString::fromLatin1("OTodo");
513} 513}
514QString OTodo::recordField(int /*id*/ )const { 514QString OTodo::recordField(int /*id*/ )const {
515 return QString::null; 515 return QString::null;
516} 516}
517 517
518int OTodo::rtti(){ 518int OTodo::rtti(){
519 return OPimResolver::TodoList; 519 return OPimResolver::TodoList;
520} 520}
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 5a18c37..189bf94 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -34,487 +34,487 @@ struct OTodo::OTodoData : public QShared {
34 delete notifiers; 34 delete notifiers;
35 } 35 }
36 36
37 QDate date; 37 QDate date;
38 bool isCompleted:1; 38 bool isCompleted:1;
39 bool hasDate:1; 39 bool hasDate:1;
40 int priority; 40 int priority;
41 QString desc; 41 QString desc;
42 QString sum; 42 QString sum;
43 QMap<QString, QString> extra; 43 QMap<QString, QString> extra;
44 ushort prog; 44 ushort prog;
45 OPimState *state; 45 OPimState *state;
46 ORecur *recur; 46 ORecur *recur;
47 OPimMaintainer *maintainer; 47 OPimMaintainer *maintainer;
48 QDate start; 48 QDate start;
49 QDate completed; 49 QDate completed;
50 OPimNotifyManager *notifiers; 50 OPimNotifyManager *notifiers;
51}; 51};
52 52
53OTodo::OTodo(const OTodo &event ) 53OTodo::OTodo(const OTodo &event )
54 : OPimRecord( event ), data( event.data ) 54 : OPimRecord( event ), data( event.data )
55{ 55{
56 data->ref(); 56 data->ref();
57// qWarning("ref up"); 57// qWarning("ref up");
58} 58}
59OTodo::~OTodo() { 59OTodo::~OTodo() {
60 60
61// qWarning("~OTodo " ); 61// qWarning("~OTodo " );
62 if ( data->deref() ) { 62 if ( data->deref() ) {
63// qWarning("OTodo::dereffing"); 63// qWarning("OTodo::dereffing");
64 delete data; 64 delete data;
65 data = 0l; 65 data = 0l;
66 } 66 }
67} 67}
68OTodo::OTodo(bool completed, int priority, 68OTodo::OTodo(bool completed, int priority,
69 const QArray<int> &category, 69 const QArray<int> &category,
70 const QString& summary, 70 const QString& summary,
71 const QString &description, 71 const QString &description,
72 ushort progress, 72 ushort progress,
73 bool hasDate, QDate date, int uid ) 73 bool hasDate, QDate date, int uid )
74 : OPimRecord( uid ) 74 : OPimRecord( uid )
75{ 75{
76// qWarning("OTodoData " + summary); 76// qWarning("OTodoData " + summary);
77 setCategories( category ); 77 setCategories( category );
78 78
79 data = new OTodoData; 79 data = new OTodoData;
80 80
81 data->date = date; 81 data->date = date;
82 data->isCompleted = completed; 82 data->isCompleted = completed;
83 data->hasDate = hasDate; 83 data->hasDate = hasDate;
84 data->priority = priority; 84 data->priority = priority;
85 data->sum = summary; 85 data->sum = summary;
86 data->prog = progress; 86 data->prog = progress;
87 data->desc = Qtopia::simplifyMultiLineSpace(description ); 87 data->desc = Qtopia::simplifyMultiLineSpace(description );
88} 88}
89OTodo::OTodo(bool completed, int priority, 89OTodo::OTodo(bool completed, int priority,
90 const QStringList &category, 90 const QStringList &category,
91 const QString& summary, 91 const QString& summary,
92 const QString &description, 92 const QString &description,
93 ushort progress, 93 ushort progress,
94 bool hasDate, QDate date, int uid ) 94 bool hasDate, QDate date, int uid )
95 : OPimRecord( uid ) 95 : OPimRecord( uid )
96{ 96{
97// qWarning("OTodoData" + summary); 97// qWarning("OTodoData" + summary);
98 setCategories( idsFromString( category.join(";") ) ); 98 setCategories( idsFromString( category.join(";") ) );
99 99
100 data = new OTodoData; 100 data = new OTodoData;
101 101
102 data->date = date; 102 data->date = date;
103 data->isCompleted = completed; 103 data->isCompleted = completed;
104 data->hasDate = hasDate; 104 data->hasDate = hasDate;
105 data->priority = priority; 105 data->priority = priority;
106 data->sum = summary; 106 data->sum = summary;
107 data->prog = progress; 107 data->prog = progress;
108 data->desc = Qtopia::simplifyMultiLineSpace(description ); 108 data->desc = Qtopia::simplifyMultiLineSpace(description );
109} 109}
110bool OTodo::match( const QRegExp &regExp )const 110bool OTodo::match( const QRegExp &regExp )const
111{ 111{
112 if( QString::number( data->priority ).find( regExp ) != -1 ){ 112 if( QString::number( data->priority ).find( regExp ) != -1 ){
113 setLastHitField( Priority ); 113 setLastHitField( Priority );
114 return true; 114 return true;
115 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 115 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
116 setLastHitField( HasDate ); 116 setLastHitField( HasDate );
117 return true; 117 return true;
118 }else if(data->desc.find( regExp ) != -1 ){ 118 }else if(data->desc.find( regExp ) != -1 ){
119 setLastHitField( Description ); 119 setLastHitField( Description );
120 return true; 120 return true;
121 }else if(data->sum.find( regExp ) != -1 ) { 121 }else if(data->sum.find( regExp ) != -1 ) {
122 setLastHitField( Summary ); 122 setLastHitField( Summary );
123 return true; 123 return true;
124 } 124 }
125 return false; 125 return false;
126} 126}
127bool OTodo::isCompleted() const 127bool OTodo::isCompleted() const
128{ 128{
129 return data->isCompleted; 129 return data->isCompleted;
130} 130}
131bool OTodo::hasDueDate() const 131bool OTodo::hasDueDate() const
132{ 132{
133 return data->hasDate; 133 return data->hasDate;
134} 134}
135bool OTodo::hasStartDate()const { 135bool OTodo::hasStartDate()const {
136 return data->start.isValid(); 136 return data->start.isValid();
137} 137}
138bool OTodo::hasCompletedDate()const { 138bool OTodo::hasCompletedDate()const {
139 return data->completed.isValid(); 139 return data->completed.isValid();
140} 140}
141int OTodo::priority()const 141int OTodo::priority()const
142{ 142{
143 return data->priority; 143 return data->priority;
144} 144}
145QString OTodo::summary() const 145QString OTodo::summary() const
146{ 146{
147 return data->sum; 147 return data->sum;
148} 148}
149ushort OTodo::progress() const 149ushort OTodo::progress() const
150{ 150{
151 return data->prog; 151 return data->prog;
152} 152}
153QDate OTodo::dueDate()const 153QDate OTodo::dueDate()const
154{ 154{
155 return data->date; 155 return data->date;
156} 156}
157QDate OTodo::startDate()const { 157QDate OTodo::startDate()const {
158 return data->start; 158 return data->start;
159} 159}
160QDate OTodo::completedDate()const { 160QDate OTodo::completedDate()const {
161 return data->completed; 161 return data->completed;
162} 162}
163QString OTodo::description()const 163QString OTodo::description()const
164{ 164{
165 return data->desc; 165 return data->desc;
166} 166}
167bool OTodo::hasState() const{ 167bool OTodo::hasState() const{
168 if (!data->state ) return false; 168 if (!data->state ) return false;
169 return ( data->state->state() != OPimState::Undefined ); 169 return ( data->state->state() != OPimState::Undefined );
170} 170}
171OPimState OTodo::state()const { 171OPimState OTodo::state()const {
172 if (!data->state ) { 172 if (!data->state ) {
173 OPimState state; 173 OPimState state;
174 return state; 174 return state;
175 } 175 }
176 176
177 return (*data->state); 177 return (*data->state);
178} 178}
179bool OTodo::hasRecurrence()const { 179bool OTodo::hasRecurrence()const {
180 if (!data->recur) return false; 180 if (!data->recur) return false;
181 return data->recur->doesRecur(); 181 return data->recur->doesRecur();
182} 182}
183ORecur OTodo::recurrence()const { 183ORecur OTodo::recurrence()const {
184 if (!data->recur) return ORecur(); 184 if (!data->recur) return ORecur();
185 185
186 return (*data->recur); 186 return (*data->recur);
187} 187}
188bool OTodo::hasMaintainer()const { 188bool OTodo::hasMaintainer()const {
189 if (!data->maintainer) return false; 189 if (!data->maintainer) return false;
190 190
191 return (data->maintainer->mode() != OPimMaintainer::Undefined ); 191 return (data->maintainer->mode() != OPimMaintainer::Undefined );
192} 192}
193OPimMaintainer OTodo::maintainer()const { 193OPimMaintainer OTodo::maintainer()const {
194 if (!data->maintainer) return OPimMaintainer(); 194 if (!data->maintainer) return OPimMaintainer();
195 195
196 return (*data->maintainer); 196 return (*data->maintainer);
197} 197}
198void OTodo::setCompleted( bool completed ) 198void OTodo::setCompleted( bool completed )
199{ 199{
200 changeOrModify(); 200 changeOrModify();
201 data->isCompleted = completed; 201 data->isCompleted = completed;
202} 202}
203void OTodo::setHasDueDate( bool hasDate ) 203void OTodo::setHasDueDate( bool hasDate )
204{ 204{
205 changeOrModify(); 205 changeOrModify();
206 data->hasDate = hasDate; 206 data->hasDate = hasDate;
207} 207}
208void OTodo::setDescription(const QString &desc ) 208void OTodo::setDescription(const QString &desc )
209{ 209{
210// qWarning( "desc " + desc ); 210// qWarning( "desc " + desc );
211 changeOrModify(); 211 changeOrModify();
212 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 212 data->desc = Qtopia::simplifyMultiLineSpace(desc );
213} 213}
214void OTodo::setSummary( const QString& sum ) 214void OTodo::setSummary( const QString& sum )
215{ 215{
216 changeOrModify(); 216 changeOrModify();
217 data->sum = sum; 217 data->sum = sum;
218} 218}
219void OTodo::setPriority(int prio ) 219void OTodo::setPriority(int prio )
220{ 220{
221 changeOrModify(); 221 changeOrModify();
222 data->priority = prio; 222 data->priority = prio;
223} 223}
224void OTodo::setDueDate( const QDate& date ) 224void OTodo::setDueDate( const QDate& date )
225{ 225{
226 changeOrModify(); 226 changeOrModify();
227 data->date = date; 227 data->date = date;
228} 228}
229void OTodo::setStartDate( const QDate& date ) { 229void OTodo::setStartDate( const QDate& date ) {
230 changeOrModify(); 230 changeOrModify();
231 data->start = date; 231 data->start = date;
232} 232}
233void OTodo::setCompletedDate( const QDate& date ) { 233void OTodo::setCompletedDate( const QDate& date ) {
234 changeOrModify(); 234 changeOrModify();
235 data->completed = date; 235 data->completed = date;
236} 236}
237void OTodo::setState( const OPimState& state ) { 237void OTodo::setState( const OPimState& state ) {
238 changeOrModify(); 238 changeOrModify();
239 if (data->state ) 239 if (data->state )
240 (*data->state) = state; 240 (*data->state) = state;
241 else 241 else
242 data->state = new OPimState( state ); 242 data->state = new OPimState( state );
243} 243}
244void OTodo::setRecurrence( const ORecur& rec) { 244void OTodo::setRecurrence( const ORecur& rec) {
245 changeOrModify(); 245 changeOrModify();
246 if (data->recur ) 246 if (data->recur )
247 (*data->recur) = rec; 247 (*data->recur) = rec;
248 else 248 else
249 data->recur = new ORecur( rec ); 249 data->recur = new ORecur( rec );
250} 250}
251void OTodo::setMaintainer( const OPimMaintainer& pim ) { 251void OTodo::setMaintainer( const OPimMaintainer& pim ) {
252 changeOrModify(); 252 changeOrModify();
253 253
254 if (data->maintainer ) 254 if (data->maintainer )
255 (*data->maintainer) = pim; 255 (*data->maintainer) = pim;
256 else 256 else
257 data->maintainer = new OPimMaintainer( pim ); 257 data->maintainer = new OPimMaintainer( pim );
258} 258}
259bool OTodo::isOverdue( ) 259bool OTodo::isOverdue( )
260{ 260{
261 if( data->hasDate && !data->isCompleted) 261 if( data->hasDate && !data->isCompleted)
262 return QDate::currentDate() > data->date; 262 return QDate::currentDate() > data->date;
263 return false; 263 return false;
264} 264}
265void OTodo::setProgress(ushort progress ) 265void OTodo::setProgress(ushort progress )
266{ 266{
267 changeOrModify(); 267 changeOrModify();
268 data->prog = progress; 268 data->prog = progress;
269} 269}
270QString OTodo::toShortText() const { 270QString OTodo::toShortText() const {
271 return summary(); 271 return summary();
272} 272}
273/*! 273/*!
274 Returns a richt text string 274 Returns a richt text string
275*/ 275*/
276QString OTodo::toRichText() const 276QString OTodo::toRichText() const
277{ 277{
278 QString text; 278 QString text;
279 QStringList catlist; 279 QStringList catlist;
280 280
281 // summary 281 // summary
282 text += "<b><h3><img src=\"todo/TodoList\"> "; 282 text += "<b><h3><img src=\"todo/TodoList\"> ";
283 if ( !summary().isEmpty() ) { 283 if ( !summary().isEmpty() ) {
284 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); 284 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
285 } 285 }
286 text += "</h3></b><br><hr><br>"; 286 text += "</h3></b><br><hr><br>";
287 287
288 // description 288 // description
289 if( !description().isEmpty() ){ 289 if( !description().isEmpty() ){
290 text += "<b>" + QObject::tr( "Notes:" ) + "</b><br>"; 290 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
291 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 291 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
292 } 292 }
293 293
294 // priority 294 // priority
295 int priorityval = priority(); 295 int priorityval = priority();
296 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + 296 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" +
297 QString::number( priorityval ) + "\"> "; 297 QString::number( priorityval ) + "\"> ";
298 298
299 switch ( priorityval ) 299 switch ( priorityval )
300 { 300 {
301 case 1 : text += QObject::tr( "Very high" ); 301 case 1 : text += QObject::tr( "Very high" );
302 break; 302 break;
303 case 2 : text += QObject::tr( "High" ); 303 case 2 : text += QObject::tr( "High" );
304 break; 304 break;
305 case 3 : text += QObject::tr( "Normal" ); 305 case 3 : text += QObject::tr( "Normal" );
306 break; 306 break;
307 case 4 : text += QObject::tr( "Low" ); 307 case 4 : text += QObject::tr( "Low" );
308 break; 308 break;
309 case 5 : text += QObject::tr( "Very low" ); 309 case 5 : text += QObject::tr( "Very low" );
310 break; 310 break;
311 }; 311 };
312 text += "<br>"; 312 text += "<br>";
313 313
314 // progress 314 // progress
315 text += "<b>" + QObject::tr( "Progress:") + " </b>" 315 text += "<b>" + QObject::tr( "Progress:") + " </b>"
316 + QString::number( progress() ) + " %<br>"; 316 + QString::number( progress() ) + " %<br>";
317 317
318 // due date 318 // due date
319 if (hasDueDate() ){ 319 if (hasDueDate() ){
320 QDate dd = dueDate(); 320 QDate dd = dueDate();
321 int off = QDate::currentDate().daysTo( dd ); 321 int off = QDate::currentDate().daysTo( dd );
322 322
323 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; 323 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
324 if ( off < 0 ) 324 if ( off < 0 )
325 text += "#FF0000"; 325 text += "#FF0000";
326 else if ( off == 0 ) 326 else if ( off == 0 )
327 text += "#FFFF00"; 327 text += "#FFFF00";
328 else if ( off > 0 ) 328 else if ( off > 0 )
329 text += "#00FF00"; 329 text += "#00FF00";
330 330
331 text += "\">" + dd.toString() + "</font><br>"; 331 text += "\">" + dd.toString() + "</font><br>";
332 } 332 }
333 333
334 // categories 334 // categories
335 text += "<b>" + QObject::tr( "Category:") + "</b> "; 335 text += "<b>" + QObject::tr( "Category:") + "</b> ";
336 text += categoryNames( "Todo List" ).join(", "); 336 text += categoryNames( "Todo List" ).join(", ");
337 text += "<br>"; 337 text += "<br>";
338 338
339 return text; 339 return text;
340} 340}
341bool OTodo::hasNotifiers()const { 341bool OTodo::hasNotifiers()const {
342 if (!data->notifiers) return false; 342 if (!data->notifiers) return false;
343 return !data->notifiers->isEmpty(); 343 return !data->notifiers->isEmpty();
344} 344}
345OPimNotifyManager& OTodo::notifiers() { 345OPimNotifyManager& OTodo::notifiers() {
346 if (!data->notifiers ) 346 if (!data->notifiers )
347 data->notifiers = new OPimNotifyManager; 347 data->notifiers = new OPimNotifyManager;
348 return (*data->notifiers); 348 return (*data->notifiers);
349} 349}
350const OPimNotifyManager& OTodo::notifiers()const{ 350const OPimNotifyManager& OTodo::notifiers()const{
351 if (!data->notifiers ) 351 if (!data->notifiers )
352 data->notifiers = new OPimNotifyManager; 352 data->notifiers = new OPimNotifyManager;
353 353
354 return (*data->notifiers); 354 return (*data->notifiers);
355} 355}
356 356
357bool OTodo::operator<( const OTodo &toDoEvent )const{ 357bool OTodo::operator<( const OTodo &toDoEvent )const{
358 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 358 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
359 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 359 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
360 if( hasDueDate() && toDoEvent.hasDueDate() ){ 360 if( hasDueDate() && toDoEvent.hasDueDate() ){
361 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 361 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
362 return priority() < toDoEvent.priority(); 362 return priority() < toDoEvent.priority();
363 }else{ 363 }else{
364 return dueDate() < toDoEvent.dueDate(); 364 return dueDate() < toDoEvent.dueDate();
365 } 365 }
366 } 366 }
367 return false; 367 return false;
368} 368}
369bool OTodo::operator<=(const OTodo &toDoEvent )const 369bool OTodo::operator<=(const OTodo &toDoEvent )const
370{ 370{
371 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 371 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
372 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 372 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
373 if( hasDueDate() && toDoEvent.hasDueDate() ){ 373 if( hasDueDate() && toDoEvent.hasDueDate() ){
374 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 374 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
375 return priority() <= toDoEvent.priority(); 375 return priority() <= toDoEvent.priority();
376 }else{ 376 }else{
377 return dueDate() <= toDoEvent.dueDate(); 377 return dueDate() <= toDoEvent.dueDate();
378 } 378 }
379 } 379 }
380 return true; 380 return true;
381} 381}
382bool OTodo::operator>(const OTodo &toDoEvent )const 382bool OTodo::operator>(const OTodo &toDoEvent )const
383{ 383{
384 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 384 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
385 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 385 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
386 if( hasDueDate() && toDoEvent.hasDueDate() ){ 386 if( hasDueDate() && toDoEvent.hasDueDate() ){
387 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 387 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
388 return priority() > toDoEvent.priority(); 388 return priority() > toDoEvent.priority();
389 }else{ 389 }else{
390 return dueDate() > toDoEvent.dueDate(); 390 return dueDate() > toDoEvent.dueDate();
391 } 391 }
392 } 392 }
393 return false; 393 return false;
394} 394}
395bool OTodo::operator>=(const OTodo &toDoEvent )const 395bool OTodo::operator>=(const OTodo &toDoEvent )const
396{ 396{
397 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 397 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
398 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 398 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
399 if( hasDueDate() && toDoEvent.hasDueDate() ){ 399 if( hasDueDate() && toDoEvent.hasDueDate() ){
400 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 400 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
401 return priority() > toDoEvent.priority(); 401 return priority() > toDoEvent.priority();
402 }else{ 402 }else{
403 return dueDate() > toDoEvent.dueDate(); 403 return dueDate() > toDoEvent.dueDate();
404 } 404 }
405 } 405 }
406 return true; 406 return true;
407} 407}
408bool OTodo::operator==(const OTodo &toDoEvent )const 408bool OTodo::operator==(const OTodo &toDoEvent )const
409{ 409{
410 if ( data->priority != toDoEvent.data->priority ) return false; 410 if ( data->priority != toDoEvent.data->priority ) return false;
411 if ( data->priority != toDoEvent.data->prog ) return false; 411 if ( data->priority != toDoEvent.data->prog ) return false;
412 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 412 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
413 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 413 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
414 if ( data->date != toDoEvent.data->date ) return false; 414 if ( data->date != toDoEvent.data->date ) return false;
415 if ( data->sum != toDoEvent.data->sum ) return false; 415 if ( data->sum != toDoEvent.data->sum ) return false;
416 if ( data->desc != toDoEvent.data->desc ) return false; 416 if ( data->desc != toDoEvent.data->desc ) return false;
417 if ( data->maintainer != toDoEvent.data->maintainer ) 417 if ( data->maintainer != toDoEvent.data->maintainer )
418 return false; 418 return false;
419 419
420 return OPimRecord::operator==( toDoEvent ); 420 return OPimRecord::operator==( toDoEvent );
421} 421}
422void OTodo::deref() { 422void OTodo::deref() {
423 423
424// qWarning("deref in ToDoEvent"); 424// qWarning("deref in ToDoEvent");
425 if ( data->deref() ) { 425 if ( data->deref() ) {
426// qWarning("deleting"); 426// qWarning("deleting");
427 delete data; 427 delete data;
428 data= 0; 428 data= 0;
429 } 429 }
430} 430}
431OTodo &OTodo::operator=(const OTodo &item ) 431OTodo &OTodo::operator=(const OTodo &item )
432{ 432{
433 if ( this == &item ) return *this; 433 if ( this == &item ) return *this;
434 434
435 OPimRecord::operator=( item ); 435 OPimRecord::operator=( item );
436 //qWarning("operator= ref "); 436 //qWarning("operator= ref ");
437 item.data->ref(); 437 item.data->ref();
438 deref(); 438 deref();
439 data = item.data; 439 data = item.data;
440 440
441 return *this; 441 return *this;
442} 442}
443 443
444QMap<int, QString> OTodo::toMap() const { 444QMap<int, QString> OTodo::toMap() const {
445 QMap<int, QString> map; 445 QMap<int, QString> map;
446 446
447 map.insert( Uid, QString::number( uid() ) ); 447 map.insert( Uid, QString::number( uid() ) );
448 map.insert( Category, idsToString( categories() ) ); 448 map.insert( Category, idsToString( categories() ) );
449 map.insert( HasDate, QString::number( data->hasDate ) ); 449 map.insert( HasDate, QString::number( data->hasDate ) );
450 map.insert( Completed, QString::number( data->isCompleted ) ); 450 map.insert( Completed, QString::number( data->isCompleted ) );
451 map.insert( Description, data->desc ); 451 map.insert( Description, data->desc );
452 map.insert( Summary, data->sum ); 452 map.insert( Summary, data->sum );
453 map.insert( Priority, QString::number( data->priority ) ); 453 map.insert( Priority, QString::number( data->priority ) );
454 map.insert( DateDay, QString::number( data->date.day() ) ); 454 map.insert( DateDay, QString::number( data->date.day() ) );
455 map.insert( DateMonth, QString::number( data->date.month() ) ); 455 map.insert( DateMonth, QString::number( data->date.month() ) );
456 map.insert( DateYear, QString::number( data->date.year() ) ); 456 map.insert( DateYear, QString::number( data->date.year() ) );
457 map.insert( Progress, QString::number( data->prog ) ); 457 map.insert( Progress, QString::number( data->prog ) );
458// map.insert( CrossReference, crossToString() ); 458// map.insert( CrossReference, crossToString() );
459 /* FIXME!!! map.insert( State, ); 459 /* FIXME!!! map.insert( State, );
460 map.insert( Recurrence, ); 460 map.insert( Recurrence, );
461 map.insert( Reminders, ); 461 map.insert( Reminders, );
462 map. 462 map.
463 */ 463 */
464 return map; 464 return map;
465} 465}
466 466
467/** 467/**
468 * change or modify looks at the ref count and either 468 * change or modify looks at the ref count and either
469 * creates a new QShared Object or it can modify it 469 * creates a new QShared Object or it can modify it
470 * right in place 470 * right in place
471 */ 471 */
472void OTodo::changeOrModify() { 472void OTodo::changeOrModify() {
473 if ( data->count != 1 ) { 473 if ( data->count != 1 ) {
474 qWarning("changeOrModify"); 474 qWarning("changeOrModify");
475 data->deref(); 475 data->deref();
476 OTodoData* d2 = new OTodoData(); 476 OTodoData* d2 = new OTodoData();
477 copy(data, d2 ); 477 copy(data, d2 );
478 data = d2; 478 data = d2;
479 } 479 }
480} 480}
481// WATCHOUT 481// WATCHOUT
482/* 482/*
483 * if you add something to the Data struct 483 * if you add something to the Data struct
484 * be sure to copy it here 484 * be sure to copy it here
485 */ 485 */
486void OTodo::copy( OTodoData* src, OTodoData* dest ) { 486void OTodo::copy( OTodoData* src, OTodoData* dest ) {
487 dest->date = src->date; 487 dest->date = src->date;
488 dest->isCompleted = src->isCompleted; 488 dest->isCompleted = src->isCompleted;
489 dest->hasDate = src->hasDate; 489 dest->hasDate = src->hasDate;
490 dest->priority = src->priority; 490 dest->priority = src->priority;
491 dest->desc = src->desc; 491 dest->desc = src->desc;
492 dest->sum = src->sum; 492 dest->sum = src->sum;
493 dest->extra = src->extra; 493 dest->extra = src->extra;
494 dest->prog = src->prog; 494 dest->prog = src->prog;
495 495
496 if (src->state ) 496 if (src->state )
497 dest->state = new OPimState( *src->state ); 497 dest->state = new OPimState( *src->state );
498 498
499 if (src->recur ) 499 if (src->recur )
500 dest->recur = new ORecur( *src->recur ); 500 dest->recur = new ORecur( *src->recur );
501 501
502 if (src->maintainer ) 502 if (src->maintainer )
503 dest->maintainer = new OPimMaintainer( *src->maintainer ) 503 dest->maintainer = new OPimMaintainer( *src->maintainer )
504 ; 504 ;
505 dest->start = src->start; 505 dest->start = src->start;
506 dest->completed = src->completed; 506 dest->completed = src->completed;
507 507
508 if (src->notifiers ) 508 if (src->notifiers )
509 dest->notifiers = new OPimNotifyManager( *src->notifiers ); 509 dest->notifiers = new OPimNotifyManager( *src->notifiers );
510} 510}
511QString OTodo::type() const { 511QString OTodo::type() const {
512 return QString::fromLatin1("OTodo"); 512 return QString::fromLatin1("OTodo");
513} 513}
514QString OTodo::recordField(int /*id*/ )const { 514QString OTodo::recordField(int /*id*/ )const {
515 return QString::null; 515 return QString::null;
516} 516}
517 517
518int OTodo::rtti(){ 518int OTodo::rtti(){
519 return OPimResolver::TodoList; 519 return OPimResolver::TodoList;
520} 520}