-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 80b8599..f3b0783 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -192,357 +192,358 @@ QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) { | |||
192 | return ids; | 192 | return ids; |
193 | } | 193 | } |
194 | OTodo OTodoAccessXML::find( int uid )const { | 194 | OTodo OTodoAccessXML::find( int uid )const { |
195 | OTodo todo; | 195 | OTodo todo; |
196 | todo.setUid( 0 ); // isEmpty() | 196 | todo.setUid( 0 ); // isEmpty() |
197 | QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); | 197 | QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); |
198 | if ( it != m_events.end() ) | 198 | if ( it != m_events.end() ) |
199 | todo = it.data(); | 199 | todo = it.data(); |
200 | 200 | ||
201 | return todo; | 201 | return todo; |
202 | } | 202 | } |
203 | void OTodoAccessXML::clear() { | 203 | void OTodoAccessXML::clear() { |
204 | if (m_opened ) | 204 | if (m_opened ) |
205 | m_changed = true; | 205 | m_changed = true; |
206 | 206 | ||
207 | m_events.clear(); | 207 | m_events.clear(); |
208 | } | 208 | } |
209 | bool OTodoAccessXML::add( const OTodo& todo ) { | 209 | bool OTodoAccessXML::add( const OTodo& todo ) { |
210 | // qWarning("add"); | 210 | // qWarning("add"); |
211 | m_changed = true; | 211 | m_changed = true; |
212 | m_events.insert( todo.uid(), todo ); | 212 | m_events.insert( todo.uid(), todo ); |
213 | 213 | ||
214 | return true; | 214 | return true; |
215 | } | 215 | } |
216 | bool OTodoAccessXML::remove( int uid ) { | 216 | bool OTodoAccessXML::remove( int uid ) { |
217 | m_changed = true; | 217 | m_changed = true; |
218 | m_events.remove( uid ); | 218 | m_events.remove( uid ); |
219 | 219 | ||
220 | return true; | 220 | return true; |
221 | } | 221 | } |
222 | bool OTodoAccessXML::replace( const OTodo& todo) { | 222 | bool OTodoAccessXML::replace( const OTodo& todo) { |
223 | m_changed = true; | 223 | m_changed = true; |
224 | m_events.replace( todo.uid(), todo ); | 224 | m_events.replace( todo.uid(), todo ); |
225 | 225 | ||
226 | return true; | 226 | return true; |
227 | } | 227 | } |
228 | QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, | 228 | QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, |
229 | const QDate& end, | 229 | const QDate& end, |
230 | bool includeNoDates ) { | 230 | bool includeNoDates ) { |
231 | QArray<int> ids( m_events.count() ); | 231 | QArray<int> ids( m_events.count() ); |
232 | QMap<int, OTodo>::Iterator it; | 232 | QMap<int, OTodo>::Iterator it; |
233 | 233 | ||
234 | int i = 0; | 234 | int i = 0; |
235 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 235 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
236 | if ( !it.data().hasDueDate() ) { | 236 | if ( !it.data().hasDueDate() ) { |
237 | if ( includeNoDates ) { | 237 | if ( includeNoDates ) { |
238 | ids[i] = it.key(); | 238 | ids[i] = it.key(); |
239 | i++; | 239 | i++; |
240 | } | 240 | } |
241 | }else if ( it.data().dueDate() >= start && | 241 | }else if ( it.data().dueDate() >= start && |
242 | it.data().dueDate() <= end ) { | 242 | it.data().dueDate() <= end ) { |
243 | ids[i] = it.key(); | 243 | ids[i] = it.key(); |
244 | i++; | 244 | i++; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | ids.resize( i ); | 247 | ids.resize( i ); |
248 | return ids; | 248 | return ids; |
249 | } | 249 | } |
250 | QArray<int> OTodoAccessXML::overDue() { | 250 | QArray<int> OTodoAccessXML::overDue() { |
251 | QArray<int> ids( m_events.count() ); | 251 | QArray<int> ids( m_events.count() ); |
252 | int i = 0; | 252 | int i = 0; |
253 | 253 | ||
254 | QMap<int, OTodo>::Iterator it; | 254 | QMap<int, OTodo>::Iterator it; |
255 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 255 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
256 | if ( it.data().isOverdue() ) { | 256 | if ( it.data().isOverdue() ) { |
257 | ids[i] = it.key(); | 257 | ids[i] = it.key(); |
258 | i++; | 258 | i++; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | ids.resize( i ); | 261 | ids.resize( i ); |
262 | return ids; | 262 | return ids; |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | /* private */ | 266 | /* private */ |
267 | void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | 267 | void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, |
268 | const QCString& attr, const QString& val) { | 268 | const QCString& attr, const QString& val) { |
269 | // qWarning("parse to do from XMLElement" ); | 269 | // qWarning("parse to do from XMLElement" ); |
270 | 270 | ||
271 | int *find=0; | 271 | int *find=0; |
272 | 272 | ||
273 | find = (*dict)[ attr.data() ]; | 273 | find = (*dict)[ attr.data() ]; |
274 | if (!find ) { | 274 | if (!find ) { |
275 | // qWarning("Unknown option" + it.key() ); | 275 | // qWarning("Unknown option" + it.key() ); |
276 | ev.setCustomField( attr, val ); | 276 | ev.setCustomField( attr, val ); |
277 | return; | 277 | return; |
278 | } | 278 | } |
279 | 279 | ||
280 | switch( *find ) { | 280 | switch( *find ) { |
281 | case OTodo::Uid: | 281 | case OTodo::Uid: |
282 | ev.setUid( val.toInt() ); | 282 | ev.setUid( val.toInt() ); |
283 | break; | 283 | break; |
284 | case OTodo::Category: | 284 | case OTodo::Category: |
285 | ev.setCategories( ev.idsFromString( val ) ); | 285 | ev.setCategories( ev.idsFromString( val ) ); |
286 | break; | 286 | break; |
287 | case OTodo::HasDate: | 287 | case OTodo::HasDate: |
288 | ev.setHasDueDate( val.toInt() ); | 288 | ev.setHasDueDate( val.toInt() ); |
289 | break; | 289 | break; |
290 | case OTodo::Completed: | 290 | case OTodo::Completed: |
291 | ev.setCompleted( val.toInt() ); | 291 | ev.setCompleted( val.toInt() ); |
292 | break; | 292 | break; |
293 | case OTodo::Description: | 293 | case OTodo::Description: |
294 | ev.setDescription( val ); | 294 | ev.setDescription( val ); |
295 | break; | 295 | break; |
296 | case OTodo::Summary: | 296 | case OTodo::Summary: |
297 | ev.setSummary( val ); | 297 | ev.setSummary( val ); |
298 | break; | 298 | break; |
299 | case OTodo::Priority: | 299 | case OTodo::Priority: |
300 | ev.setPriority( val.toInt() ); | 300 | ev.setPriority( val.toInt() ); |
301 | break; | 301 | break; |
302 | case OTodo::DateDay: | 302 | case OTodo::DateDay: |
303 | m_day = val.toInt(); | 303 | m_day = val.toInt(); |
304 | break; | 304 | break; |
305 | case OTodo::DateMonth: | 305 | case OTodo::DateMonth: |
306 | m_month = val.toInt(); | 306 | m_month = val.toInt(); |
307 | break; | 307 | break; |
308 | case OTodo::DateYear: | 308 | case OTodo::DateYear: |
309 | m_year = val.toInt(); | 309 | m_year = val.toInt(); |
310 | break; | 310 | break; |
311 | case OTodo::Progress: | 311 | case OTodo::Progress: |
312 | ev.setProgress( val.toInt() ); | 312 | ev.setProgress( val.toInt() ); |
313 | break; | 313 | break; |
314 | case OTodo::CrossReference: | 314 | case OTodo::CrossReference: |
315 | { | 315 | { |
316 | /* | 316 | /* |
317 | * A cross refernce looks like | 317 | * A cross refernce looks like |
318 | * appname,id;appname,id | 318 | * appname,id;appname,id |
319 | * we need to split it up | 319 | * we need to split it up |
320 | */ | 320 | */ |
321 | QStringList refs = QStringList::split(';', val ); | 321 | QStringList refs = QStringList::split(';', val ); |
322 | QStringList::Iterator strIt; | 322 | QStringList::Iterator strIt; |
323 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { | 323 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { |
324 | int pos = (*strIt).find(','); | 324 | int pos = (*strIt).find(','); |
325 | if ( pos > -1 ) | 325 | if ( pos > -1 ) |
326 | ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); | 326 | ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); |
327 | 327 | ||
328 | } | 328 | } |
329 | break; | 329 | break; |
330 | } | 330 | } |
331 | case OTodo::HasAlarmDateTime: | 331 | case OTodo::HasAlarmDateTime: |
332 | ev.setHasAlarmDateTime( val.toInt() ); | 332 | ev.setHasAlarmDateTime( val.toInt() ); |
333 | break; | 333 | break; |
334 | case OTodo::AlarmDateTime: { | 334 | case OTodo::AlarmDateTime: { |
335 | /* this sounds better ;) zecke */ | 335 | /* this sounds better ;) zecke */ |
336 | ev.setAlarmDateTime( TimeConversion::fromISO8601( val.local8Bit() ) ); | 336 | ev.setAlarmDateTime( TimeConversion::fromISO8601( val.local8Bit() ) ); |
337 | break; | 337 | break; |
338 | } | 338 | } |
339 | default: | 339 | default: |
340 | break; | 340 | break; |
341 | } | 341 | } |
342 | 342 | ||
343 | if ( ev.hasDueDate() ) { | 343 | if ( ev.hasDueDate() ) { |
344 | QDate date( m_year, m_month, m_day ); | 344 | QDate date( m_year, m_month, m_day ); |
345 | ev.setDueDate( date ); | 345 | ev.setDueDate( date ); |
346 | } | 346 | } |
347 | } | 347 | } |
348 | QString OTodoAccessXML::toString( const OTodo& ev )const { | 348 | QString OTodoAccessXML::toString( const OTodo& ev )const { |
349 | QString str; | 349 | QString str; |
350 | 350 | ||
351 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; | 351 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; |
352 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; | 352 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; |
353 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; | 353 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; |
354 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; | 354 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; |
355 | 355 | ||
356 | str += "Categories=\"" + toString( ev.categories() ) + "\" "; | 356 | str += "Categories=\"" + toString( ev.categories() ) + "\" "; |
357 | str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; | 357 | str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; |
358 | str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; | 358 | str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; |
359 | 359 | ||
360 | if ( ev.hasDueDate() ) { | 360 | if ( ev.hasDueDate() ) { |
361 | str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; | 361 | str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; |
362 | str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; | 362 | str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; |
363 | str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; | 363 | str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; |
364 | } | 364 | } |
365 | // qWarning( "Uid %d", ev.uid() ); | 365 | // qWarning( "Uid %d", ev.uid() ); |
366 | str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; | 366 | str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; |
367 | 367 | ||
368 | // append the extra options | 368 | // append the extra options |
369 | /* FIXME Qtopia::Record this is currently not | 369 | /* FIXME Qtopia::Record this is currently not |
370 | * possible you can set custom fields | 370 | * possible you can set custom fields |
371 | * but don' iterate over the list | 371 | * but don' iterate over the list |
372 | * I may do #define private protected | 372 | * I may do #define private protected |
373 | * for this case - cough --zecke | 373 | * for this case - cough --zecke |
374 | */ | 374 | */ |
375 | /* | 375 | /* |
376 | QMap<QString, QString> extras = ev.extras(); | 376 | QMap<QString, QString> extras = ev.extras(); |
377 | QMap<QString, QString>::Iterator extIt; | 377 | QMap<QString, QString>::Iterator extIt; |
378 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) | 378 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) |
379 | str += extIt.key() + "=\"" + extIt.data() + "\" "; | 379 | str += extIt.key() + "=\"" + extIt.data() + "\" "; |
380 | */ | 380 | */ |
381 | // cross refernce | 381 | // cross refernce |
382 | QStringList list = ev.relatedApps(); | 382 | QStringList list = ev.relatedApps(); |
383 | QStringList::Iterator listIt; | 383 | QStringList::Iterator listIt; |
384 | QString refs; | 384 | QString refs; |
385 | str += "CrossReference=\""; | 385 | str += "CrossReference=\""; |
386 | bool added = false; | 386 | bool added = false; |
387 | for ( listIt = list.begin(); listIt != list.end(); ++listIt ) { | 387 | for ( listIt = list.begin(); listIt != list.end(); ++listIt ) { |
388 | added = true; | 388 | added = true; |
389 | QArray<int> ints = ev.relations( (*listIt) ); | 389 | QArray<int> ints = ev.relations( (*listIt) ); |
390 | for ( uint i = 0; i< ints.count(); i++ ) { | 390 | for ( uint i = 0; i< ints.count(); i++ ) { |
391 | str += (*listIt) + "," + QString::number( i ) + ";"; | 391 | str += (*listIt) + "," + QString::number( i ) + ";"; |
392 | } | 392 | } |
393 | } | 393 | } |
394 | if ( added ) | 394 | if ( added ) |
395 | str = str.remove( str.length()-1, 1 ); | 395 | str = str.remove( str.length()-1, 1 ); |
396 | 396 | ||
397 | str += "\" "; | 397 | str += "\" "; |
398 | 398 | ||
399 | str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" "; | 399 | str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" "; |
400 | 400 | ||
401 | return str; | 401 | return str; |
402 | } | 402 | } |
403 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { | 403 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { |
404 | return Qtopia::Record::idsToString( ints ); | 404 | return Qtopia::Record::idsToString( ints ); |
405 | } | 405 | } |
406 | 406 | ||
407 | /* internal class for sorting */ | 407 | /* internal class for sorting */ |
408 | 408 | ||
409 | struct OTodoXMLContainer { | 409 | struct OTodoXMLContainer { |
410 | OTodo todo; | 410 | OTodo todo; |
411 | }; | 411 | }; |
412 | /* | 412 | /* |
413 | * Returns: | 413 | * Returns: |
414 | * 0 if item1 == item2 | 414 | * 0 if item1 == item2 |
415 | * | 415 | * |
416 | * non-zero if item1 != item2 | 416 | * non-zero if item1 != item2 |
417 | * | 417 | * |
418 | * This function returns int rather than bool so that reimplementations | 418 | * This function returns int rather than bool so that reimplementations |
419 | * can return one of three values and use it to sort by: | 419 | * can return one of three values and use it to sort by: |
420 | * | 420 | * |
421 | * 0 if item1 == item2 | 421 | * 0 if item1 == item2 |
422 | * | 422 | * |
423 | * > 0 (positive integer) if item1 > item2 | 423 | * > 0 (positive integer) if item1 > item2 |
424 | * | 424 | * |
425 | * < 0 (negative integer) if item1 < item2 | 425 | * < 0 (negative integer) if item1 < item2 |
426 | * | 426 | * |
427 | */ | 427 | */ |
428 | class OTodoXMLVector : public QVector<OTodoXMLContainer> { | 428 | class OTodoXMLVector : public QVector<OTodoXMLContainer> { |
429 | public: | 429 | public: |
430 | OTodoXMLVector(int size, bool asc, int sort) | 430 | OTodoXMLVector(int size, bool asc, int sort) |
431 | : QVector<OTodoXMLContainer>( size ) | 431 | : QVector<OTodoXMLContainer>( size ) |
432 | { | 432 | { |
433 | setAutoDelete( true ); | 433 | setAutoDelete( true ); |
434 | m_asc = asc; | 434 | m_asc = asc; |
435 | m_sort = sort; | 435 | m_sort = sort; |
436 | } | 436 | } |
437 | /* return the summary/description */ | 437 | /* return the summary/description */ |
438 | QString string( const OTodo& todo) { | 438 | QString string( const OTodo& todo) { |
439 | return todo.summary().isEmpty() ? | 439 | return todo.summary().isEmpty() ? |
440 | todo.description().left(20 ) : | 440 | todo.description().left(20 ) : |
441 | todo.summary(); | 441 | todo.summary(); |
442 | } | 442 | } |
443 | /** | 443 | /** |
444 | * we take the sortorder( switch on it ) | 444 | * we take the sortorder( switch on it ) |
445 | * | 445 | * |
446 | */ | 446 | */ |
447 | int compareItems( Item d1, Item d2 ) { | 447 | int compareItems( Item d1, Item d2 ) { |
448 | qWarning("compare items"); | ||
449 | int ret =0; | 448 | int ret =0; |
450 | OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1; | 449 | OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1; |
451 | OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2; | 450 | OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2; |
452 | 451 | ||
453 | /* same item */ | 452 | /* same item */ |
454 | if ( con1->todo.uid() == con2->todo.uid() ) | 453 | if ( con1->todo.uid() == con2->todo.uid() ) |
455 | return 0; | 454 | return 0; |
456 | qWarning("m_sort %d", m_sort ); | ||
457 | 455 | ||
458 | switch ( m_sort ) { | 456 | switch ( m_sort ) { |
459 | /* completed */ | 457 | /* completed */ |
460 | case 0: { | 458 | case 0: { |
461 | ret = 0; | 459 | ret = 0; |
462 | if ( con1->todo.isCompleted() ) ret++; | 460 | if ( con1->todo.isCompleted() ) ret++; |
463 | if ( con2->todo.isCompleted() ) ret--; | 461 | if ( con2->todo.isCompleted() ) ret--; |
464 | break; | 462 | break; |
465 | } | 463 | } |
466 | /* priority */ | 464 | /* priority */ |
467 | case 1: { | 465 | case 1: { |
468 | ret = con1->todo.priority() - con2->todo.priority(); | 466 | ret = con1->todo.priority() - con2->todo.priority(); |
469 | qWarning(" priority %d %d %d", ret, | 467 | qWarning(" priority %d %d %d", ret, |
470 | con1->todo.priority(), | 468 | con1->todo.priority(), |
471 | con2->todo.priority() | 469 | con2->todo.priority() |
472 | ); | 470 | ); |
473 | break; | 471 | break; |
474 | } | 472 | } |
475 | /* description */ | 473 | /* description */ |
476 | case 2: { | 474 | case 2: { |
477 | QString str1 = string( con1->todo ); | 475 | QString str1 = string( con1->todo ); |
478 | QString str2 = string( con2->todo ); | 476 | QString str2 = string( con2->todo ); |
479 | ret = QString::compare( str1, str2 ); | 477 | ret = QString::compare( str1, str2 ); |
480 | break; | 478 | break; |
481 | } | 479 | } |
482 | /* deadline */ | 480 | /* deadline */ |
483 | case 3: { | 481 | case 3: { |
484 | /* either bot got a dueDate | 482 | /* either bot got a dueDate |
485 | * or one of them got one | 483 | * or one of them got one |
486 | */ | 484 | */ |
487 | if ( con1->todo.hasDueDate() && | 485 | if ( con1->todo.hasDueDate() && |
488 | con2->todo.hasDueDate() ) | 486 | con2->todo.hasDueDate() ) |
489 | ret = con1->todo.dueDate().daysTo( con2->todo.dueDate() ); | 487 | ret = con1->todo.dueDate().daysTo( con2->todo.dueDate() ); |
488 | |||
489 | |||
490 | else if ( con1->todo.hasDueDate() ) | 490 | else if ( con1->todo.hasDueDate() ) |
491 | ret = -1; | 491 | ret = -1; |
492 | else if ( con2->todo.hasDueDate() ) | 492 | else if ( con2->todo.hasDueDate() ) |
493 | ret = 0; | 493 | ret = 0; |
494 | break; | 494 | break; |
495 | } | 495 | } |
496 | default: | 496 | default: |
497 | ret = 0; | 497 | ret = 0; |
498 | break; | 498 | break; |
499 | }; | 499 | }; |
500 | 500 | ||
501 | /* twist it we're not ascending*/ | 501 | /* twist it we're not ascending*/ |
502 | if (!m_asc) | 502 | if (!m_asc) |
503 | ret = ret * -1; | 503 | ret = ret * -1; |
504 | return ret; | 504 | return ret; |
505 | } | 505 | } |
506 | private: | 506 | private: |
507 | bool m_asc; | 507 | bool m_asc; |
508 | int m_sort; | 508 | int m_sort; |
509 | 509 | ||
510 | }; | 510 | }; |
511 | 511 | ||
512 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 512 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, |
513 | int sortFilter, int cat ) { | 513 | int sortFilter, int cat ) { |
514 | qWarning("sorted! %d cat", cat); | ||
514 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 515 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
515 | QMap<int, OTodo>::Iterator it; | 516 | QMap<int, OTodo>::Iterator it; |
516 | int item = 0; | 517 | int item = 0; |
517 | 518 | ||
518 | bool bCat = sortFilter & 1 ? true : false; | 519 | bool bCat = sortFilter & 1 ? true : false; |
519 | bool bOver = sortFilter & 0 ? true : false; | ||
520 | bool bOnly = sortFilter & 2 ? true : false; | 520 | bool bOnly = sortFilter & 2 ? true : false; |
521 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 521 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
522 | 522 | ||
523 | /* show category */ | 523 | /* show category */ |
524 | if ( bCat ) | 524 | if ( bCat && cat != 0) |
525 | if (!(*it).categories().contains( cat ) ) | 525 | if (!(*it).categories().contains( cat ) ) |
526 | continue; | 526 | continue; |
527 | /* isOverdue but we should not show overdue */ | 527 | /* isOverdue but we should not show overdue */ |
528 | if ( (*it).isOverdue() && ( !bOver || !bOnly ) ) | 528 | if ( (*it).isOverdue() && !bOnly ) |
529 | continue; | 529 | continue; |
530 | if ( !(*it).isOverdue() && bOnly ) | 530 | if ( !(*it).isOverdue() && bOnly ) |
531 | continue; | 531 | continue; |
532 | 532 | ||
533 | 533 | ||
534 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 534 | OTodoXMLContainer* con = new OTodoXMLContainer(); |
535 | con->todo = (*it); | 535 | con->todo = (*it); |
536 | vector.insert(item, con ); | 536 | vector.insert(item, con ); |
537 | item++; | 537 | item++; |
538 | } | 538 | } |
539 | vector.resize( item ); | 539 | vector.resize( item ); |
540 | /* sort it now */ | 540 | /* sort it now */ |
541 | vector.sort(); | 541 | vector.sort(); |
542 | /* now get the uids */ | 542 | /* now get the uids */ |
543 | QArray<int> array( vector.count() ); | 543 | QArray<int> array( vector.count() ); |
544 | for (uint i= 0; i < vector.count(); i++ ) { | 544 | for (uint i= 0; i < vector.count(); i++ ) { |
545 | array[i] = ( vector.at(i) )->todo.uid(); | 545 | array[i] = ( vector.at(i) )->todo.uid(); |
546 | } | 546 | } |
547 | qWarning("array count = %d %d", array.count(), vector.count() ); | ||
547 | return array; | 548 | return array; |
548 | }; | 549 | }; |