author | zautrix <zautrix> | 2005-02-03 00:58:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-03 00:58:41 (UTC) |
commit | 7e3c508b7ee613c534c2bf0cacf38f96efaef613 (patch) (unidiff) | |
tree | 5e70a8653c9620fda7ce2e4c1c427efbbb2127b6 | |
parent | ca3c58c09b1b7d2733eeacc9e8ca568134926e93 (diff) | |
download | kdepimpi-7e3c508b7ee613c534c2bf0cacf38f96efaef613.zip kdepimpi-7e3c508b7ee613c534c2bf0cacf38f96efaef613.tar.gz kdepimpi-7e3c508b7ee613c534c2bf0cacf38f96efaef613.tar.bz2 |
todo fix
-rw-r--r-- | korganizer/kotodoview.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index c5b9a21..03a8f1c 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -630,128 +630,132 @@ void KOTodoView::updateView() | |||
630 | QPtrList<Event> l = t->getRelations(); | 630 | QPtrList<Event> l = t->getRelations(); |
631 | Event *c; | 631 | Event *c; |
632 | for(c=l.first();c;c=l.next()) { | 632 | for(c=l.first();c;c=l.next()) { |
633 | kdDebug() << " - relation: " << c->getSummary() << endl; | 633 | kdDebug() << " - relation: " << c->getSummary() << endl; |
634 | } | 634 | } |
635 | } | 635 | } |
636 | */ | 636 | */ |
637 | 637 | ||
638 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 638 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
639 | // specific order of events. That means that we have to generate parent items | 639 | // specific order of events. That means that we have to generate parent items |
640 | // recursively for proper hierarchical display of Todos. | 640 | // recursively for proper hierarchical display of Todos. |
641 | mTodoMap.clear(); | 641 | mTodoMap.clear(); |
642 | Todo *todo; | 642 | Todo *todo; |
643 | todo = todoList.first();// todo; todo = todoList.next()) { | 643 | todo = todoList.first();// todo; todo = todoList.next()) { |
644 | while ( todo ) { | 644 | while ( todo ) { |
645 | bool next = true; | 645 | bool next = true; |
646 | // qDebug("todo %s ", todo->summary().latin1()); | 646 | // qDebug("todo %s ", todo->summary().latin1()); |
647 | Incidence *incidence = todo->relatedTo(); | 647 | Incidence *incidence = todo->relatedTo(); |
648 | while ( incidence ) { | 648 | while ( incidence ) { |
649 | if ( incidence->type() == "Todo") { | 649 | if ( incidence->type() == "Todo") { |
650 | //qDebug("related %s ",incidence->summary().latin1() ); | 650 | //qDebug("related %s ",incidence->summary().latin1() ); |
651 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 651 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
652 | //qDebug("related not found "); | 652 | //qDebug("related not found "); |
653 | todoList.remove( ); | 653 | todoList.remove( ); |
654 | todo = todoList.current(); | 654 | todo = todoList.current(); |
655 | next = false; | 655 | next = false; |
656 | incidence = 0; | 656 | incidence = 0; |
657 | 657 | ||
658 | } else { | 658 | } else { |
659 | //qDebug("related found "); | 659 | //qDebug("related found "); |
660 | incidence = incidence->relatedTo(); | 660 | incidence = incidence->relatedTo(); |
661 | } | 661 | } |
662 | } else | 662 | } else |
663 | incidence = 0; | 663 | incidence = 0; |
664 | } | 664 | } |
665 | if ( next ) | 665 | if ( next ) |
666 | todo = todoList.next(); | 666 | todo = todoList.next(); |
667 | } | 667 | } |
668 | // qDebug("again .... "); | 668 | // qDebug("again .... "); |
669 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 669 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
670 | 670 | ||
671 | // qDebug("yytodo %s ", todo->summary().latin1()); | 671 | // qDebug("yytodo %s ", todo->summary().latin1()); |
672 | // } | 672 | // } |
673 | //qDebug("for "); | 673 | //qDebug("for "); |
674 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 674 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
675 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 675 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
676 | { | 676 | { |
677 | insertTodoItem(todo); | 677 | insertTodoItem(todo); |
678 | } | 678 | } |
679 | } | 679 | } |
680 | //qDebug("for end "); | 680 | //qDebug("for end "); |
681 | // Restore opened/closed state | 681 | // Restore opened/closed state |
682 | mTodoListView->blockSignals( true ); | 682 | mTodoListView->blockSignals( true ); |
683 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 683 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
684 | mTodoListView->blockSignals( false ); | 684 | mTodoListView->blockSignals( false ); |
685 | mTodoListView->setFocus(); | 685 | mTodoListView->setFocus(); |
686 | processSelectionChange(); | 686 | processSelectionChange(); |
687 | } | 687 | } |
688 | 688 | ||
689 | bool KOTodoView::checkTodo( Todo * todo ) | 689 | bool KOTodoView::checkTodo( Todo * todo ) |
690 | { | 690 | { |
691 | 691 | ||
692 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 692 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
693 | return false; | 693 | return false; |
694 | if ( !todo->isCompleted() ) { | ||
695 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | ||
696 | return true; | ||
697 | } | ||
694 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 698 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
695 | if ( todo->hasStartDate() ) | 699 | if ( todo->hasStartDate() ) |
696 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 700 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
697 | return false; | 701 | return false; |
698 | if ( todo->hasDueDate() ) | 702 | if ( todo->hasDueDate() ) |
699 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 703 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
700 | return false; | 704 | return false; |
701 | } | 705 | } |
702 | return true; | 706 | return true; |
703 | } | 707 | } |
704 | 708 | ||
705 | void KOTodoView::restoreItemState( QListViewItem *item ) | 709 | void KOTodoView::restoreItemState( QListViewItem *item ) |
706 | { | 710 | { |
707 | pendingSubtodo = 0; | 711 | pendingSubtodo = 0; |
708 | while( item ) { | 712 | while( item ) { |
709 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 713 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
710 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 714 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
711 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 715 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
712 | item = item->nextSibling(); | 716 | item = item->nextSibling(); |
713 | } | 717 | } |
714 | } | 718 | } |
715 | 719 | ||
716 | 720 | ||
717 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 721 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
718 | KOTodoView::insertTodoItem(Todo *todo) | 722 | KOTodoView::insertTodoItem(Todo *todo) |
719 | { | 723 | { |
720 | 724 | ||
721 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 725 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
722 | // TODO: Check, if dynmaic cast is necessary | 726 | // TODO: Check, if dynmaic cast is necessary |
723 | 727 | ||
724 | pendingSubtodo = 0; | 728 | pendingSubtodo = 0; |
725 | Incidence *incidence = todo->relatedTo(); | 729 | Incidence *incidence = todo->relatedTo(); |
726 | if (incidence && incidence->type() == "Todo") { | 730 | if (incidence && incidence->type() == "Todo") { |
727 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 731 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
728 | 732 | ||
729 | // kdDebug() << " has Related" << endl; | 733 | // kdDebug() << " has Related" << endl; |
730 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 734 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
731 | itemIterator = mTodoMap.find(relatedTodo); | 735 | itemIterator = mTodoMap.find(relatedTodo); |
732 | if (itemIterator == mTodoMap.end()) { | 736 | if (itemIterator == mTodoMap.end()) { |
733 | // kdDebug() << " related not yet in list" << endl; | 737 | // kdDebug() << " related not yet in list" << endl; |
734 | itemIterator = insertTodoItem (relatedTodo); | 738 | itemIterator = insertTodoItem (relatedTodo); |
735 | } | 739 | } |
736 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 740 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
737 | // and one into the map. Sure finding is more easy but why? -zecke | 741 | // and one into the map. Sure finding is more easy but why? -zecke |
738 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 742 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
739 | return mTodoMap.insert(todo,todoItem); | 743 | return mTodoMap.insert(todo,todoItem); |
740 | } else { | 744 | } else { |
741 | // kdDebug() << " no Related" << endl; | 745 | // kdDebug() << " no Related" << endl; |
742 | // see above -zecke | 746 | // see above -zecke |
743 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 747 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
744 | return mTodoMap.insert(todo,todoItem); | 748 | return mTodoMap.insert(todo,todoItem); |
745 | } | 749 | } |
746 | } | 750 | } |
747 | 751 | ||
748 | 752 | ||
749 | void KOTodoView::updateConfig() | 753 | void KOTodoView::updateConfig() |
750 | { | 754 | { |
751 | updateView(); | 755 | updateView(); |
752 | mTodoListView->repaintContents(); | 756 | mTodoListView->repaintContents(); |
753 | } | 757 | } |
754 | 758 | ||
755 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 759 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
756 | { | 760 | { |
757 | QPtrList<Incidence> selected; | 761 | QPtrList<Incidence> selected; |