author | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
commit | f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf (patch) (unidiff) | |
tree | 4044006e676c78370fdeccf960ea4214f13eabd2 /libopie2/opiepim/otodo.cpp | |
parent | 2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (diff) | |
download | opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.zip opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.gz opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.bz2 |
cosmetics
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 602 |
1 files changed, 382 insertions, 220 deletions
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index 3eb0026..f534067 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -28,7 +28,11 @@ | |||
28 | */ | 28 | */ |
29 | #include <qobject.h> | ||
30 | #include <qshared.h> | ||
31 | |||
32 | 29 | ||
30 | #include "otodo.h" | ||
33 | 31 | ||
32 | /* OPIE */ | ||
33 | #include <opie2/opimstate.h> | ||
34 | #include <opie2/orecur.h> | ||
35 | #include <opie2/opimmaintainer.h> | ||
36 | #include <opie2/opimnotifymanager.h> | ||
37 | #include <opie2/opimresolver.h> | ||
34 | #include <qpe/palmtopuidgen.h> | 38 | #include <qpe/palmtopuidgen.h> |
@@ -40,15 +44,13 @@ | |||
40 | 44 | ||
45 | /* QT */ | ||
46 | #include <qobject.h> | ||
47 | #include <qshared.h> | ||
41 | 48 | ||
42 | #include <opie2/opimstate.h> | 49 | namespace Opie |
43 | #include <opie2/orecur.h> | 50 | { |
44 | #include <opie2/opimmaintainer.h> | ||
45 | #include <opie2/opimnotifymanager.h> | ||
46 | #include <opie2/opimresolver.h> | ||
47 | |||
48 | #include <opie2/otodo.h> | ||
49 | |||
50 | namespace Opie { | ||
51 | 51 | ||
52 | struct OTodo::OTodoData : public QShared { | 52 | struct OTodo::OTodoData : public QShared |
53 | OTodoData() : QShared() { | 53 | { |
54 | OTodoData() : QShared() | ||
55 | { | ||
54 | recur = 0; | 56 | recur = 0; |
@@ -58,3 +60,4 @@ struct OTodo::OTodoData : public QShared { | |||
58 | }; | 60 | }; |
59 | ~OTodoData() { | 61 | ~OTodoData() |
62 | { | ||
60 | delete recur; | 63 | delete recur; |
@@ -65,4 +68,4 @@ struct OTodo::OTodoData : public QShared { | |||
65 | QDate date; | 68 | QDate date; |
66 | bool isCompleted:1; | 69 | bool isCompleted: 1; |
67 | bool hasDate:1; | 70 | bool hasDate: 1; |
68 | int priority; | 71 | int priority; |
@@ -80,13 +83,18 @@ struct OTodo::OTodoData : public QShared { | |||
80 | 83 | ||
81 | OTodo::OTodo(const OTodo &event ) | 84 | |
82 | : OPimRecord( event ), data( event.data ) | 85 | OTodo::OTodo( const OTodo &event ) |
86 | : OPimRecord( event ), data( event.data ) | ||
83 | { | 87 | { |
84 | data->ref(); | 88 | data->ref(); |
85 | // qWarning("ref up"); | 89 | // qWarning("ref up"); |
86 | } | 90 | } |
87 | OTodo::~OTodo() { | ||
88 | 91 | ||
89 | // qWarning("~OTodo " ); | 92 | |
90 | if ( data->deref() ) { | 93 | OTodo::~OTodo() |
91 | // qWarning("OTodo::dereffing"); | 94 | { |
95 | |||
96 | // qWarning("~OTodo " ); | ||
97 | if ( data->deref() ) | ||
98 | { | ||
99 | // qWarning("OTodo::dereffing"); | ||
92 | delete data; | 100 | delete data; |
@@ -95,11 +103,13 @@ OTodo::~OTodo() { | |||
95 | } | 103 | } |
96 | OTodo::OTodo(bool completed, int priority, | 104 | |
97 | const QArray<int> &category, | 105 | |
98 | const QString& summary, | 106 | OTodo::OTodo( bool completed, int priority, |
99 | const QString &description, | 107 | const QArray<int> &category, |
100 | ushort progress, | 108 | const QString& summary, |
101 | bool hasDate, QDate date, int uid ) | 109 | const QString &description, |
102 | : OPimRecord( uid ) | 110 | ushort progress, |
111 | bool hasDate, QDate date, int uid ) | ||
112 | : OPimRecord( uid ) | ||
103 | { | 113 | { |
104 | // qWarning("OTodoData " + summary); | 114 | // qWarning("OTodoData " + summary); |
105 | setCategories( category ); | 115 | setCategories( category ); |
@@ -114,14 +124,16 @@ OTodo::OTodo(bool completed, int priority, | |||
114 | data->prog = progress; | 124 | data->prog = progress; |
115 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 125 | data->desc = Qtopia::simplifyMultiLineSpace( description ); |
116 | } | 126 | } |
117 | OTodo::OTodo(bool completed, int priority, | 127 | |
118 | const QStringList &category, | 128 | |
119 | const QString& summary, | 129 | OTodo::OTodo( bool completed, int priority, |
120 | const QString &description, | 130 | const QStringList &category, |
121 | ushort progress, | 131 | const QString& summary, |
122 | bool hasDate, QDate date, int uid ) | 132 | const QString &description, |
123 | : OPimRecord( uid ) | 133 | ushort progress, |
134 | bool hasDate, QDate date, int uid ) | ||
135 | : OPimRecord( uid ) | ||
124 | { | 136 | { |
125 | // qWarning("OTodoData" + summary); | 137 | // qWarning("OTodoData" + summary); |
126 | setCategories( idsFromString( category.join(";") ) ); | 138 | setCategories( idsFromString( category.join( ";" ) ) ); |
127 | 139 | ||
@@ -135,21 +147,32 @@ OTodo::OTodo(bool completed, int priority, | |||
135 | data->prog = progress; | 147 | data->prog = progress; |
136 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 148 | data->desc = Qtopia::simplifyMultiLineSpace( description ); |
137 | } | 149 | } |
138 | bool OTodo::match( const QRegExp ®Exp )const | 150 | |
151 | |||
152 | bool OTodo::match( const QRegExp ®Exp ) const | ||
139 | { | 153 | { |
140 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 154 | if ( QString::number( data->priority ).find( regExp ) != -1 ) |
141 | setLastHitField( Priority ); | 155 | { |
142 | return true; | 156 | setLastHitField( Priority ); |
143 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 157 | return true; |
144 | setLastHitField( HasDate ); | 158 | } |
145 | return true; | 159 | else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) |
146 | }else if(data->desc.find( regExp ) != -1 ){ | 160 | { |
161 | setLastHitField( HasDate ); | ||
162 | return true; | ||
163 | } | ||
164 | else if ( data->desc.find( regExp ) != -1 ) | ||
165 | { | ||
147 | setLastHitField( Description ); | 166 | setLastHitField( Description ); |
148 | return true; | 167 | return true; |
149 | }else if(data->sum.find( regExp ) != -1 ) { | 168 | } |
169 | else if ( data->sum.find( regExp ) != -1 ) | ||
170 | { | ||
150 | setLastHitField( Summary ); | 171 | setLastHitField( Summary ); |
151 | return true; | 172 | return true; |
152 | } | 173 | } |
153 | return false; | 174 | return false; |
154 | } | 175 | } |
176 | |||
177 | |||
155 | bool OTodo::isCompleted() const | 178 | bool OTodo::isCompleted() const |
@@ -158,2 +181,4 @@ bool OTodo::isCompleted() const | |||
158 | } | 181 | } |
182 | |||
183 | |||
159 | bool OTodo::hasDueDate() const | 184 | bool OTodo::hasDueDate() const |
@@ -162,9 +187,17 @@ bool OTodo::hasDueDate() const | |||
162 | } | 187 | } |
163 | bool OTodo::hasStartDate()const { | 188 | |
189 | |||
190 | bool OTodo::hasStartDate() const | ||
191 | { | ||
164 | return data->start.isValid(); | 192 | return data->start.isValid(); |
165 | } | 193 | } |
166 | bool OTodo::hasCompletedDate()const { | 194 | |
195 | |||
196 | bool OTodo::hasCompletedDate() const | ||
197 | { | ||
167 | return data->completed.isValid(); | 198 | return data->completed.isValid(); |
168 | } | 199 | } |
169 | int OTodo::priority()const | 200 | |
201 | |||
202 | int OTodo::priority() const | ||
170 | { | 203 | { |
@@ -172,2 +205,4 @@ int OTodo::priority()const | |||
172 | } | 205 | } |
206 | |||
207 | |||
173 | QString OTodo::summary() const | 208 | QString OTodo::summary() const |
@@ -176,2 +211,4 @@ QString OTodo::summary() const | |||
176 | } | 211 | } |
212 | |||
213 | |||
177 | ushort OTodo::progress() const | 214 | ushort OTodo::progress() const |
@@ -180,3 +217,5 @@ ushort OTodo::progress() const | |||
180 | } | 217 | } |
181 | QDate OTodo::dueDate()const | 218 | |
219 | |||
220 | QDate OTodo::dueDate() const | ||
182 | { | 221 | { |
@@ -184,9 +223,17 @@ QDate OTodo::dueDate()const | |||
184 | } | 223 | } |
185 | QDate OTodo::startDate()const { | 224 | |
225 | |||
226 | QDate OTodo::startDate() const | ||
227 | { | ||
186 | return data->start; | 228 | return data->start; |
187 | } | 229 | } |
188 | QDate OTodo::completedDate()const { | 230 | |
231 | |||
232 | QDate OTodo::completedDate() const | ||
233 | { | ||
189 | return data->completed; | 234 | return data->completed; |
190 | } | 235 | } |
191 | QString OTodo::description()const | 236 | |
237 | |||
238 | QString OTodo::description() const | ||
192 | { | 239 | { |
@@ -194,8 +241,15 @@ QString OTodo::description()const | |||
194 | } | 241 | } |
195 | bool OTodo::hasState() const{ | 242 | |
196 | if (!data->state ) return false; | 243 | |
244 | bool OTodo::hasState() const | ||
245 | { | ||
246 | if ( !data->state ) return false; | ||
197 | return ( data->state->state() != OPimState::Undefined ); | 247 | return ( data->state->state() != OPimState::Undefined ); |
198 | } | 248 | } |
199 | OPimState OTodo::state()const { | 249 | |
200 | if (!data->state ) { | 250 | |
251 | OPimState OTodo::state() const | ||
252 | { | ||
253 | if ( !data->state ) | ||
254 | { | ||
201 | OPimState state; | 255 | OPimState state; |
@@ -204,23 +258,37 @@ OPimState OTodo::state()const { | |||
204 | 258 | ||
205 | return (*data->state); | 259 | return ( *data->state ); |
206 | } | 260 | } |
207 | bool OTodo::hasRecurrence()const { | 261 | |
208 | if (!data->recur) return false; | 262 | |
263 | bool OTodo::hasRecurrence() const | ||
264 | { | ||
265 | if ( !data->recur ) return false; | ||
209 | return data->recur->doesRecur(); | 266 | return data->recur->doesRecur(); |
210 | } | 267 | } |
211 | ORecur OTodo::recurrence()const { | ||
212 | if (!data->recur) return ORecur(); | ||
213 | 268 | ||
214 | return (*data->recur); | 269 | |
270 | ORecur OTodo::recurrence() const | ||
271 | { | ||
272 | if ( !data->recur ) return ORecur(); | ||
273 | |||
274 | return ( *data->recur ); | ||
215 | } | 275 | } |
216 | bool OTodo::hasMaintainer()const { | ||
217 | if (!data->maintainer) return false; | ||
218 | 276 | ||
219 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | 277 | |
278 | bool OTodo::hasMaintainer() const | ||
279 | { | ||
280 | if ( !data->maintainer ) return false; | ||
281 | |||
282 | return ( data->maintainer->mode() != OPimMaintainer::Undefined ); | ||
220 | } | 283 | } |
221 | OPimMaintainer OTodo::maintainer()const { | ||
222 | if (!data->maintainer) return OPimMaintainer(); | ||
223 | 284 | ||
224 | return (*data->maintainer); | 285 | |
286 | OPimMaintainer OTodo::maintainer() const | ||
287 | { | ||
288 | if ( !data->maintainer ) return OPimMaintainer(); | ||
289 | |||
290 | return ( *data->maintainer ); | ||
225 | } | 291 | } |
292 | |||
293 | |||
226 | void OTodo::setCompleted( bool completed ) | 294 | void OTodo::setCompleted( bool completed ) |
@@ -230,2 +298,4 @@ void OTodo::setCompleted( bool completed ) | |||
230 | } | 298 | } |
299 | |||
300 | |||
231 | void OTodo::setHasDueDate( bool hasDate ) | 301 | void OTodo::setHasDueDate( bool hasDate ) |
@@ -235,8 +305,12 @@ void OTodo::setHasDueDate( bool hasDate ) | |||
235 | } | 305 | } |
236 | void OTodo::setDescription(const QString &desc ) | 306 | |
307 | |||
308 | void OTodo::setDescription( const QString &desc ) | ||
237 | { | 309 | { |
238 | // qWarning( "desc " + desc ); | 310 | // qWarning( "desc " + desc ); |
239 | changeOrModify(); | 311 | changeOrModify(); |
240 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 312 | data->desc = Qtopia::simplifyMultiLineSpace( desc ); |
241 | } | 313 | } |
314 | |||
315 | |||
242 | void OTodo::setSummary( const QString& sum ) | 316 | void OTodo::setSummary( const QString& sum ) |
@@ -246,3 +320,5 @@ void OTodo::setSummary( const QString& sum ) | |||
246 | } | 320 | } |
247 | void OTodo::setPriority(int prio ) | 321 | |
322 | |||
323 | void OTodo::setPriority( int prio ) | ||
248 | { | 324 | { |
@@ -251,2 +327,4 @@ void OTodo::setPriority(int prio ) | |||
251 | } | 327 | } |
328 | |||
329 | |||
252 | void OTodo::setDueDate( const QDate& date ) | 330 | void OTodo::setDueDate( const QDate& date ) |
@@ -256,3 +334,6 @@ void OTodo::setDueDate( const QDate& date ) | |||
256 | } | 334 | } |
257 | void OTodo::setStartDate( const QDate& date ) { | 335 | |
336 | |||
337 | void OTodo::setStartDate( const QDate& date ) | ||
338 | { | ||
258 | changeOrModify(); | 339 | changeOrModify(); |
@@ -260,3 +341,6 @@ void OTodo::setStartDate( const QDate& date ) { | |||
260 | } | 341 | } |
261 | void OTodo::setCompletedDate( const QDate& date ) { | 342 | |
343 | |||
344 | void OTodo::setCompletedDate( const QDate& date ) | ||
345 | { | ||
262 | changeOrModify(); | 346 | changeOrModify(); |
@@ -264,6 +348,9 @@ void OTodo::setCompletedDate( const QDate& date ) { | |||
264 | } | 348 | } |
265 | void OTodo::setState( const OPimState& state ) { | 349 | |
350 | |||
351 | void OTodo::setState( const OPimState& state ) | ||
352 | { | ||
266 | changeOrModify(); | 353 | changeOrModify(); |
267 | if (data->state ) | 354 | if ( data->state ) |
268 | (*data->state) = state; | 355 | ( *data->state ) = state; |
269 | else | 356 | else |
@@ -271,6 +358,9 @@ void OTodo::setState( const OPimState& state ) { | |||
271 | } | 358 | } |
272 | void OTodo::setRecurrence( const ORecur& rec) { | 359 | |
360 | |||
361 | void OTodo::setRecurrence( const ORecur& rec ) | ||
362 | { | ||
273 | changeOrModify(); | 363 | changeOrModify(); |
274 | if (data->recur ) | 364 | if ( data->recur ) |
275 | (*data->recur) = rec; | 365 | ( *data->recur ) = rec; |
276 | else | 366 | else |
@@ -278,7 +368,10 @@ void OTodo::setRecurrence( const ORecur& rec) { | |||
278 | } | 368 | } |
279 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 369 | |
370 | |||
371 | void OTodo::setMaintainer( const OPimMaintainer& pim ) | ||
372 | { | ||
280 | changeOrModify(); | 373 | changeOrModify(); |
281 | 374 | ||
282 | if (data->maintainer ) | 375 | if ( data->maintainer ) |
283 | (*data->maintainer) = pim; | 376 | ( *data->maintainer ) = pim; |
284 | else | 377 | else |
@@ -286,9 +379,13 @@ void OTodo::setMaintainer( const OPimMaintainer& pim ) { | |||
286 | } | 379 | } |
380 | |||
381 | |||
287 | bool OTodo::isOverdue( ) | 382 | bool OTodo::isOverdue( ) |
288 | { | 383 | { |
289 | if( data->hasDate && !data->isCompleted) | 384 | if ( data->hasDate && !data->isCompleted ) |
290 | return QDate::currentDate() > data->date; | 385 | return QDate::currentDate() > data->date; |
291 | return false; | 386 | return false; |
292 | } | 387 | } |
293 | void OTodo::setProgress(ushort progress ) | 388 | |
389 | |||
390 | void OTodo::setProgress( ushort progress ) | ||
294 | { | 391 | { |
@@ -297,5 +394,10 @@ void OTodo::setProgress(ushort progress ) | |||
297 | } | 394 | } |
298 | QString OTodo::toShortText() const { | 395 | |
299 | return summary(); | 396 | |
397 | QString OTodo::toShortText() const | ||
398 | { | ||
399 | return summary(); | ||
300 | } | 400 | } |
401 | |||
402 | |||
301 | /*! | 403 | /*! |
@@ -305,25 +407,27 @@ QString OTodo::toRichText() const | |||
305 | { | 407 | { |
306 | QString text; | 408 | QString text; |
307 | QStringList catlist; | 409 | QStringList catlist; |
308 | 410 | ||
309 | // summary | 411 | // summary |
310 | text += "<b><h3><img src=\"todo/TodoList\"> "; | 412 | text += "<b><h3><img src=\"todo/TodoList\"> "; |
311 | if ( !summary().isEmpty() ) { | 413 | if ( !summary().isEmpty() ) |
312 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); | 414 | { |
313 | } | 415 | text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" ); |
314 | text += "</h3></b><br><hr><br>"; | 416 | } |
315 | 417 | text += "</h3></b><br><hr><br>"; | |
316 | // description | 418 | |
317 | if( !description().isEmpty() ){ | 419 | // description |
318 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 420 | if ( !description().isEmpty() ) |
319 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 421 | { |
320 | } | 422 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
321 | 423 | text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; | |
322 | // priority | 424 | } |
323 | int priorityval = priority(); | 425 | |
324 | text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + | 426 | // priority |
325 | QString::number( priorityval ) + "\"> "; | 427 | int priorityval = priority(); |
326 | 428 | text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" + | |
327 | switch ( priorityval ) | 429 | QString::number( priorityval ) + "\"> "; |
328 | { | 430 | |
431 | switch ( priorityval ) | ||
432 | { | ||
329 | case 1 : text += QObject::tr( "Very high" ); | 433 | case 1 : text += QObject::tr( "Very high" ); |
@@ -338,57 +442,73 @@ QString OTodo::toRichText() const | |||
338 | break; | 442 | break; |
339 | }; | 443 | }; |
340 | text += "<br>"; | 444 | text += "<br>"; |
341 | 445 | ||
342 | // progress | 446 | // progress |
343 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 447 | text += "<b>" + QObject::tr( "Progress:" ) + " </b>" |
344 | + QString::number( progress() ) + " %<br>"; | 448 | + QString::number( progress() ) + " %<br>"; |
345 | 449 | ||
346 | // due date | 450 | // due date |
347 | if (hasDueDate() ){ | 451 | if ( hasDueDate() ) |
348 | QDate dd = dueDate(); | 452 | { |
349 | int off = QDate::currentDate().daysTo( dd ); | 453 | QDate dd = dueDate(); |
350 | 454 | int off = QDate::currentDate().daysTo( dd ); | |
351 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; | 455 | |
352 | if ( off < 0 ) | 456 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; |
353 | text += "#FF0000"; | 457 | if ( off < 0 ) |
354 | else if ( off == 0 ) | 458 | text += "#FF0000"; |
355 | text += "#FFFF00"; | 459 | else if ( off == 0 ) |
356 | else if ( off > 0 ) | 460 | text += "#FFFF00"; |
357 | text += "#00FF00"; | 461 | else if ( off > 0 ) |
358 | 462 | text += "#00FF00"; | |
359 | text += "\">" + dd.toString() + "</font><br>"; | 463 | |
360 | } | 464 | text += "\">" + dd.toString() + "</font><br>"; |
361 | 465 | } | |
362 | // categories | 466 | |
363 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 467 | // categories |
364 | text += categoryNames( "Todo List" ).join(", "); | 468 | text += "<b>" + QObject::tr( "Category:" ) + "</b> "; |
365 | text += "<br>"; | 469 | text += categoryNames( "Todo List" ).join( ", " ); |
366 | 470 | text += "<br>"; | |
367 | return text; | 471 | |
368 | } | 472 | return text; |
369 | bool OTodo::hasNotifiers()const { | 473 | } |
370 | if (!data->notifiers) return false; | 474 | |
475 | |||
476 | bool OTodo::hasNotifiers() const | ||
477 | { | ||
478 | if ( !data->notifiers ) return false; | ||
371 | return !data->notifiers->isEmpty(); | 479 | return !data->notifiers->isEmpty(); |
372 | } | 480 | } |
373 | OPimNotifyManager& OTodo::notifiers() { | 481 | |
374 | if (!data->notifiers ) | 482 | |
483 | OPimNotifyManager& OTodo::notifiers() | ||
484 | { | ||
485 | if ( !data->notifiers ) | ||
375 | data->notifiers = new OPimNotifyManager; | 486 | data->notifiers = new OPimNotifyManager; |
376 | return (*data->notifiers); | 487 | return ( *data->notifiers ); |
377 | } | 488 | } |
378 | const OPimNotifyManager& OTodo::notifiers()const{ | 489 | |
379 | if (!data->notifiers ) | 490 | |
491 | const OPimNotifyManager& OTodo::notifiers() const | ||
492 | { | ||
493 | if ( !data->notifiers ) | ||
380 | data->notifiers = new OPimNotifyManager; | 494 | data->notifiers = new OPimNotifyManager; |
381 | 495 | ||
382 | return (*data->notifiers); | 496 | return ( *data->notifiers ); |
383 | } | 497 | } |
384 | 498 | ||
385 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 499 | |
386 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 500 | bool OTodo::operator<( const OTodo &toDoEvent ) const |
387 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 501 | { |
388 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 502 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
389 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 503 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
390 | return priority() < toDoEvent.priority(); | 504 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
391 | }else{ | 505 | { |
392 | return dueDate() < toDoEvent.dueDate(); | 506 | if ( dueDate() == toDoEvent.dueDate() ) |
393 | } | 507 | { // let's the priority decide |
508 | return priority() < toDoEvent.priority(); | ||
509 | } | ||
510 | else | ||
511 | { | ||
512 | return dueDate() < toDoEvent.dueDate(); | ||
513 | } | ||
394 | } | 514 | } |
@@ -396,12 +516,18 @@ bool OTodo::operator<( const OTodo &toDoEvent )const{ | |||
396 | } | 516 | } |
397 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 517 | |
518 | |||
519 | bool OTodo::operator<=( const OTodo &toDoEvent ) const | ||
398 | { | 520 | { |
399 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 521 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
400 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 522 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
401 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 523 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
402 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 524 | { |
403 | return priority() <= toDoEvent.priority(); | 525 | if ( dueDate() == toDoEvent.dueDate() ) |
404 | }else{ | 526 | { // let's the priority decide |
405 | return dueDate() <= toDoEvent.dueDate(); | 527 | return priority() <= toDoEvent.priority(); |
406 | } | 528 | } |
529 | else | ||
530 | { | ||
531 | return dueDate() <= toDoEvent.dueDate(); | ||
532 | } | ||
407 | } | 533 | } |
@@ -409,12 +535,18 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const | |||
409 | } | 535 | } |
410 | bool OTodo::operator>(const OTodo &toDoEvent )const | 536 | |
537 | |||
538 | bool OTodo::operator>( const OTodo &toDoEvent ) const | ||
411 | { | 539 | { |
412 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 540 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
413 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 541 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
414 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 542 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
415 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 543 | { |
416 | return priority() > toDoEvent.priority(); | 544 | if ( dueDate() == toDoEvent.dueDate() ) |
417 | }else{ | 545 | { // let's the priority decide |
418 | return dueDate() > toDoEvent.dueDate(); | 546 | return priority() > toDoEvent.priority(); |
419 | } | 547 | } |
548 | else | ||
549 | { | ||
550 | return dueDate() > toDoEvent.dueDate(); | ||
551 | } | ||
420 | } | 552 | } |
@@ -422,12 +554,18 @@ bool OTodo::operator>(const OTodo &toDoEvent )const | |||
422 | } | 554 | } |
423 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 555 | |
556 | |||
557 | bool OTodo::operator>=( const OTodo &toDoEvent ) const | ||
424 | { | 558 | { |
425 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 559 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
426 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 560 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
427 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 561 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
428 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 562 | { |
429 | return priority() > toDoEvent.priority(); | 563 | if ( dueDate() == toDoEvent.dueDate() ) |
430 | }else{ | 564 | { // let's the priority decide |
431 | return dueDate() > toDoEvent.dueDate(); | 565 | return priority() > toDoEvent.priority(); |
432 | } | 566 | } |
567 | else | ||
568 | { | ||
569 | return dueDate() > toDoEvent.dueDate(); | ||
570 | } | ||
433 | } | 571 | } |
@@ -435,3 +573,5 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const | |||
435 | } | 573 | } |
436 | bool OTodo::operator==(const OTodo &toDoEvent )const | 574 | |
575 | |||
576 | bool OTodo::operator==( const OTodo &toDoEvent ) const | ||
437 | { | 577 | { |
@@ -444,3 +584,3 @@ bool OTodo::operator==(const OTodo &toDoEvent )const | |||
444 | if ( data->desc != toDoEvent.data->desc ) return false; | 584 | if ( data->desc != toDoEvent.data->desc ) return false; |
445 | if ( data->maintainer != toDoEvent.data->maintainer ) | 585 | if ( data->maintainer != toDoEvent.data->maintainer ) |
446 | return false; | 586 | return false; |
@@ -449,14 +589,20 @@ bool OTodo::operator==(const OTodo &toDoEvent )const | |||
449 | } | 589 | } |
450 | void OTodo::deref() { | ||
451 | 590 | ||
452 | // qWarning("deref in ToDoEvent"); | 591 | |
453 | if ( data->deref() ) { | 592 | void OTodo::deref() |
454 | // qWarning("deleting"); | 593 | { |
594 | |||
595 | // qWarning("deref in ToDoEvent"); | ||
596 | if ( data->deref() ) | ||
597 | { | ||
598 | // qWarning("deleting"); | ||
455 | delete data; | 599 | delete data; |
456 | data= 0; | 600 | data = 0; |
457 | } | 601 | } |
458 | } | 602 | } |
459 | OTodo &OTodo::operator=(const OTodo &item ) | 603 | |
604 | |||
605 | OTodo &OTodo::operator=( const OTodo &item ) | ||
460 | { | 606 | { |
461 | if ( this == &item ) return *this; | 607 | if ( this == &item ) return * this; |
462 | 608 | ||
@@ -471,3 +617,5 @@ OTodo &OTodo::operator=(const OTodo &item ) | |||
471 | 617 | ||
472 | QMap<int, QString> OTodo::toMap() const { | 618 | |
619 | QMap<int, QString> OTodo::toMap() const | ||
620 | { | ||
473 | QMap<int, QString> map; | 621 | QMap<int, QString> map; |
@@ -475,3 +623,3 @@ QMap<int, QString> OTodo::toMap() const { | |||
475 | map.insert( Uid, QString::number( uid() ) ); | 623 | map.insert( Uid, QString::number( uid() ) ); |
476 | map.insert( Category, idsToString( categories() ) ); | 624 | map.insert( Category, idsToString( categories() ) ); |
477 | map.insert( HasDate, QString::number( data->hasDate ) ); | 625 | map.insert( HasDate, QString::number( data->hasDate ) ); |
@@ -481,3 +629,3 @@ QMap<int, QString> OTodo::toMap() const { | |||
481 | map.insert( Priority, QString::number( data->priority ) ); | 629 | map.insert( Priority, QString::number( data->priority ) ); |
482 | map.insert( DateDay, QString::number( data->date.day() ) ); | 630 | map.insert( DateDay, QString::number( data->date.day() ) ); |
483 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 631 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
@@ -485,3 +633,3 @@ QMap<int, QString> OTodo::toMap() const { | |||
485 | map.insert( Progress, QString::number( data->prog ) ); | 633 | map.insert( Progress, QString::number( data->prog ) ); |
486 | // map.insert( CrossReference, crossToString() ); | 634 | // map.insert( CrossReference, crossToString() ); |
487 | /* FIXME!!! map.insert( State, ); | 635 | /* FIXME!!! map.insert( State, ); |
@@ -494,2 +642,3 @@ QMap<int, QString> OTodo::toMap() const { | |||
494 | 642 | ||
643 | |||
495 | /** | 644 | /** |
@@ -499,8 +648,10 @@ QMap<int, QString> OTodo::toMap() const { | |||
499 | */ | 648 | */ |
500 | void OTodo::changeOrModify() { | 649 | void OTodo::changeOrModify() |
501 | if ( data->count != 1 ) { | 650 | { |
502 | qWarning("changeOrModify"); | 651 | if ( data->count != 1 ) |
652 | { | ||
653 | qWarning( "changeOrModify" ); | ||
503 | data->deref(); | 654 | data->deref(); |
504 | OTodoData* d2 = new OTodoData(); | 655 | OTodoData* d2 = new OTodoData(); |
505 | copy(data, d2 ); | 656 | copy( data, d2 ); |
506 | data = d2; | 657 | data = d2; |
@@ -508,2 +659,4 @@ void OTodo::changeOrModify() { | |||
508 | } | 659 | } |
660 | |||
661 | |||
509 | // WATCHOUT | 662 | // WATCHOUT |
@@ -513,3 +666,4 @@ void OTodo::changeOrModify() { | |||
513 | */ | 666 | */ |
514 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 667 | void OTodo::copy( OTodoData* src, OTodoData* dest ) |
668 | { | ||
515 | dest->date = src->date; | 669 | dest->date = src->date; |
@@ -523,9 +677,9 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { | |||
523 | 677 | ||
524 | if (src->state ) | 678 | if ( src->state ) |
525 | dest->state = new OPimState( *src->state ); | 679 | dest->state = new OPimState( *src->state ); |
526 | 680 | ||
527 | if (src->recur ) | 681 | if ( src->recur ) |
528 | dest->recur = new ORecur( *src->recur ); | 682 | dest->recur = new ORecur( *src->recur ); |
529 | 683 | ||
530 | if (src->maintainer ) | 684 | if ( src->maintainer ) |
531 | dest->maintainer = new OPimMaintainer( *src->maintainer ) | 685 | dest->maintainer = new OPimMaintainer( *src->maintainer ) |
@@ -535,9 +689,15 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { | |||
535 | 689 | ||
536 | if (src->notifiers ) | 690 | if ( src->notifiers ) |
537 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); | 691 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); |
538 | } | 692 | } |
539 | QString OTodo::type() const { | 693 | |
540 | return QString::fromLatin1("OTodo"); | 694 | |
695 | QString OTodo::type() const | ||
696 | { | ||
697 | return QString::fromLatin1( "OTodo" ); | ||
541 | } | 698 | } |
542 | QString OTodo::recordField(int /*id*/ )const { | 699 | |
700 | |||
701 | QString OTodo::recordField( int /*id*/ ) const | ||
702 | { | ||
543 | return QString::null; | 703 | return QString::null; |
@@ -545,3 +705,5 @@ QString OTodo::recordField(int /*id*/ )const { | |||
545 | 705 | ||
546 | int OTodo::rtti(){ | 706 | |
707 | int OTodo::rtti() | ||
708 | { | ||
547 | return OPimResolver::TodoList; | 709 | return OPimResolver::TodoList; |