-rw-r--r-- | libopie/pim/otodoaccessxml.cpp | 11 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index 80b8599..f3b0783 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp | |||
@@ -432,41 +432,39 @@ public: | |||
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 | ); |
@@ -474,75 +472,78 @@ public: | |||
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 | }; |
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 | |||
@@ -432,41 +432,39 @@ public: | |||
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 | ); |
@@ -474,75 +472,78 @@ public: | |||
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 | }; |