author | zautrix <zautrix> | 2005-04-08 11:36:36 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-08 11:36:36 (UTC) |
commit | ba04f6a4b6b651dcff11ca17103cba42330e52be (patch) (unidiff) | |
tree | c8c02a1327abbd87cf5f019399e8e7bf1940a2bc | |
parent | 59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef (diff) | |
download | kdepimpi-ba04f6a4b6b651dcff11ca17103cba42330e52be.zip kdepimpi-ba04f6a4b6b651dcff11ca17103cba42330e52be.tar.gz kdepimpi-ba04f6a4b6b651dcff11ca17103cba42330e52be.tar.bz2 |
fix
-rw-r--r-- | korganizer/kotodoview.cpp | 21 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 2 |
2 files changed, 17 insertions, 6 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 395325c..935a5f5 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -670,168 +670,179 @@ void KOTodoView::updateView() | |||
670 | 670 | ||
671 | QPtrList<Event> l = t->getRelations(); | 671 | QPtrList<Event> l = t->getRelations(); |
672 | Event *c; | 672 | Event *c; |
673 | for(c=l.first();c;c=l.next()) { | 673 | for(c=l.first();c;c=l.next()) { |
674 | kdDebug() << " - relation: " << c->getSummary() << endl; | 674 | kdDebug() << " - relation: " << c->getSummary() << endl; |
675 | } | 675 | } |
676 | } | 676 | } |
677 | */ | 677 | */ |
678 | 678 | ||
679 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 679 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
680 | // specific order of events. That means that we have to generate parent items | 680 | // specific order of events. That means that we have to generate parent items |
681 | // recursively for proper hierarchical display of Todos. | 681 | // recursively for proper hierarchical display of Todos. |
682 | mTodoMap.clear(); | 682 | mTodoMap.clear(); |
683 | Todo *todo; | 683 | Todo *todo; |
684 | todo = todoList.first();// todo; todo = todoList.next()) { | 684 | todo = todoList.first();// todo; todo = todoList.next()) { |
685 | while ( todo ) { | 685 | while ( todo ) { |
686 | bool next = true; | 686 | bool next = true; |
687 | // qDebug("todo %s ", todo->summary().latin1()); | 687 | // qDebug("todo %s ", todo->summary().latin1()); |
688 | Incidence *incidence = todo->relatedTo(); | 688 | Incidence *incidence = todo->relatedTo(); |
689 | while ( incidence ) { | 689 | while ( incidence ) { |
690 | if ( incidence->type() == "Todo") { | 690 | if ( incidence->type() == "Todo") { |
691 | //qDebug("related %s ",incidence->summary().latin1() ); | 691 | //qDebug("related %s ",incidence->summary().latin1() ); |
692 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 692 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
693 | //qDebug("related not found "); | 693 | //qDebug("related not found "); |
694 | todoList.remove( ); | 694 | todoList.remove( ); |
695 | todo = todoList.current(); | 695 | todo = todoList.current(); |
696 | next = false; | 696 | next = false; |
697 | incidence = 0; | 697 | incidence = 0; |
698 | 698 | ||
699 | } else { | 699 | } else { |
700 | //qDebug("related found "); | 700 | //qDebug("related found "); |
701 | incidence = incidence->relatedTo(); | 701 | incidence = incidence->relatedTo(); |
702 | } | 702 | } |
703 | } else | 703 | } else |
704 | incidence = 0; | 704 | incidence = 0; |
705 | } | 705 | } |
706 | if ( next ) | 706 | if ( next ) |
707 | todo = todoList.next(); | 707 | todo = todoList.next(); |
708 | } | 708 | } |
709 | // qDebug("again .... "); | 709 | // qDebug("again .... "); |
710 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 710 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
711 | 711 | ||
712 | // qDebug("yytodo %s ", todo->summary().latin1()); | 712 | // qDebug("yytodo %s ", todo->summary().latin1()); |
713 | // } | 713 | // } |
714 | //qDebug("for "); | 714 | //qDebug("for "); |
715 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 715 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
716 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 716 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
717 | { | 717 | { |
718 | insertTodoItem(todo); | 718 | insertTodoItem(todo); |
719 | } | 719 | } |
720 | } | 720 | } |
721 | //qDebug("for end "); | 721 | //qDebug("for end "); |
722 | // Restore opened/closed state | 722 | // Restore opened/closed state |
723 | mTodoListView->blockSignals( true ); | 723 | mTodoListView->blockSignals( true ); |
724 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 724 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
725 | mTodoListView->blockSignals( false ); | 725 | mTodoListView->blockSignals( false ); |
726 | resetCurrentItem(); | 726 | resetCurrentItem(); |
727 | processSelectionChange(); | 727 | processSelectionChange(); |
728 | } | 728 | } |
729 | 729 | ||
730 | void KOTodoView::storeCurrentItem() | 730 | void KOTodoView::storeCurrentItem() |
731 | { | 731 | { |
732 | mCurItem = 0; | 732 | mCurItem = 0; |
733 | mCurItemRootParent = 0; | 733 | mCurItemRootParent = 0; |
734 | mCurItemParent = 0; | ||
734 | mCurItemAbove = 0; | 735 | mCurItemAbove = 0; |
735 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 736 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
736 | if (mActiveItem) { | 737 | if (mActiveItem) { |
737 | mCurItem = mActiveItem->todo(); | 738 | mCurItem = mActiveItem->todo(); |
738 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 739 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
739 | if ( activeItemAbove ) | 740 | if ( activeItemAbove ) |
740 | mCurItemAbove = activeItemAbove->todo(); | 741 | mCurItemAbove = activeItemAbove->todo(); |
741 | mCurItemRootParent = mCurItem; | 742 | mCurItemRootParent = mCurItem; |
743 | mCurItemParent = mCurItemRootParent->relatedTo(); | ||
742 | while ( mCurItemRootParent->relatedTo() != 0 ) | 744 | while ( mCurItemRootParent->relatedTo() != 0 ) |
743 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 745 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
744 | } | 746 | } |
745 | mActiveItem = 0; | 747 | mActiveItem = 0; |
746 | } | 748 | } |
747 | 749 | ||
748 | void KOTodoView::resetCurrentItem() | 750 | void KOTodoView::resetCurrentItem() |
749 | { | 751 | { |
750 | mTodoListView->setFocus(); | 752 | mTodoListView->setFocus(); |
751 | KOTodoViewItem* foundItem = 0; | 753 | KOTodoViewItem* foundItem = 0; |
752 | KOTodoViewItem* foundItemRoot = 0; | 754 | KOTodoViewItem* foundItemRoot = 0; |
755 | KOTodoViewItem* foundItemParent = 0; | ||
753 | KOTodoViewItem* foundItemAbove = 0; | 756 | KOTodoViewItem* foundItemAbove = 0; |
754 | if ( mTodoListView->firstChild () ) { | 757 | if ( mTodoListView->firstChild () ) { |
755 | if ( mCurItem ) { | 758 | if ( mCurItem ) { |
756 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 759 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
757 | while ( item ) { | 760 | while ( item ) { |
758 | if ( item->todo() == mCurItem ) { | 761 | if ( item->todo() == mCurItem ) { |
759 | foundItem = item; | 762 | foundItem = item; |
760 | break; | 763 | break; |
761 | } else if ( item->todo() == mCurItemAbove ) { | 764 | } else if ( item->todo() == mCurItemAbove ) { |
762 | foundItemAbove = item; | 765 | foundItemAbove = item; |
763 | 766 | ||
764 | } else if ( item->todo() == mCurItemRootParent ) { | 767 | } |
768 | if ( item->todo() == mCurItemRootParent ) { | ||
765 | foundItemRoot = item; | 769 | foundItemRoot = item; |
766 | } | 770 | } |
771 | if ( item->todo() == mCurItemParent ) { | ||
772 | foundItemParent = item; | ||
773 | } | ||
767 | item = (KOTodoViewItem*)item->itemBelow(); | 774 | item = (KOTodoViewItem*)item->itemBelow(); |
768 | } | 775 | } |
769 | if ( ! foundItem ) { | 776 | if ( ! foundItem ) { |
770 | if ( foundItemRoot ) | 777 | if ( foundItemParent ) { |
771 | foundItem = foundItemRoot; | 778 | foundItem = foundItemParent; |
772 | else | 779 | } else { |
773 | foundItem = foundItemAbove; | 780 | if ( foundItemRoot ) |
781 | foundItem = foundItemRoot; | ||
782 | else | ||
783 | foundItem = foundItemAbove; | ||
784 | } | ||
774 | } | 785 | } |
775 | } | 786 | } |
776 | if ( foundItem ) { | 787 | if ( foundItem ) { |
777 | mTodoListView->setCurrentItem( foundItem ); | 788 | mTodoListView->setCurrentItem( foundItem ); |
778 | mTodoListView->ensureItemVisible( foundItem ); | 789 | mTodoListView->ensureItemVisible( foundItem ); |
779 | } else { | 790 | } else { |
780 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 791 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
781 | } | 792 | } |
782 | } | 793 | } |
783 | mTodoListView->setFocus(); | 794 | mTodoListView->setFocus(); |
784 | } | 795 | } |
785 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 796 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
786 | bool KOTodoView::checkTodo( Todo * todo ) | 797 | bool KOTodoView::checkTodo( Todo * todo ) |
787 | { | 798 | { |
788 | 799 | ||
789 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 800 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
790 | return false; | 801 | return false; |
791 | if ( !todo->isCompleted() ) { | 802 | if ( !todo->isCompleted() ) { |
792 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 803 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
793 | return true; | 804 | return true; |
794 | } | 805 | } |
795 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 806 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
796 | if ( todo->hasStartDate() ) | 807 | if ( todo->hasStartDate() ) |
797 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 808 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
798 | return false; | 809 | return false; |
799 | if ( todo->hasDueDate() ) | 810 | if ( todo->hasDueDate() ) |
800 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 811 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
801 | return false; | 812 | return false; |
802 | } | 813 | } |
803 | return true; | 814 | return true; |
804 | } | 815 | } |
805 | 816 | ||
806 | void KOTodoView::restoreItemState( QListViewItem *item ) | 817 | void KOTodoView::restoreItemState( QListViewItem *item ) |
807 | { | 818 | { |
808 | pendingSubtodo = 0; | 819 | pendingSubtodo = 0; |
809 | while( item ) { | 820 | while( item ) { |
810 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 821 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
811 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 822 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
812 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 823 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
813 | item = item->nextSibling(); | 824 | item = item->nextSibling(); |
814 | } | 825 | } |
815 | } | 826 | } |
816 | 827 | ||
817 | 828 | ||
818 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 829 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
819 | KOTodoView::insertTodoItem(Todo *todo) | 830 | KOTodoView::insertTodoItem(Todo *todo) |
820 | { | 831 | { |
821 | 832 | ||
822 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 833 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
823 | // TODO: Check, if dynmaic cast is necessary | 834 | // TODO: Check, if dynmaic cast is necessary |
824 | 835 | ||
825 | pendingSubtodo = 0; | 836 | pendingSubtodo = 0; |
826 | Incidence *incidence = todo->relatedTo(); | 837 | Incidence *incidence = todo->relatedTo(); |
827 | if (incidence && incidence->type() == "Todo") { | 838 | if (incidence && incidence->type() == "Todo") { |
828 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 839 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
829 | 840 | ||
830 | // kdDebug() << " has Related" << endl; | 841 | // kdDebug() << " has Related" << endl; |
831 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 842 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
832 | itemIterator = mTodoMap.find(relatedTodo); | 843 | itemIterator = mTodoMap.find(relatedTodo); |
833 | if (itemIterator == mTodoMap.end()) { | 844 | if (itemIterator == mTodoMap.end()) { |
834 | // kdDebug() << " related not yet in list" << endl; | 845 | // kdDebug() << " related not yet in list" << endl; |
835 | itemIterator = insertTodoItem (relatedTodo); | 846 | itemIterator = insertTodoItem (relatedTodo); |
836 | } | 847 | } |
837 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 848 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 39976cf..d0788a9 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -196,68 +196,68 @@ class KOTodoView : public KOrg::BaseView | |||
196 | 196 | ||
197 | void editTodoSignal(Todo *); | 197 | void editTodoSignal(Todo *); |
198 | void deleteTodoSignal(Todo *); | 198 | void deleteTodoSignal(Todo *); |
199 | void todoModifiedSignal (Todo *, int); | 199 | void todoModifiedSignal (Todo *, int); |
200 | 200 | ||
201 | void isModified(bool); | 201 | void isModified(bool); |
202 | void cloneTodoSignal( Incidence * ); | 202 | void cloneTodoSignal( Incidence * ); |
203 | void cancelTodoSignal( Incidence * ); | 203 | void cancelTodoSignal( Incidence * ); |
204 | void moveTodoSignal( Incidence * ); | 204 | void moveTodoSignal( Incidence * ); |
205 | void beamTodoSignal( Incidence * ); | 205 | void beamTodoSignal( Incidence * ); |
206 | void purgeCompletedSignal(); | 206 | void purgeCompletedSignal(); |
207 | 207 | ||
208 | protected slots: | 208 | protected slots: |
209 | void paintNeeded(); | 209 | void paintNeeded(); |
210 | void processSelectionChange(); | 210 | void processSelectionChange(); |
211 | void addQuickTodo(); | 211 | void addQuickTodo(); |
212 | void setTodoModified( Todo* ); | 212 | void setTodoModified( Todo* ); |
213 | void todoModified(Todo *, int ); | 213 | void todoModified(Todo *, int ); |
214 | 214 | ||
215 | private: | 215 | private: |
216 | /* | 216 | /* |
217 | * the TodoEditor approach is rather unscaling in the long | 217 | * the TodoEditor approach is rather unscaling in the long |
218 | * run. | 218 | * run. |
219 | * Korganizer keeps it in memory and we need to update | 219 | * Korganizer keeps it in memory and we need to update |
220 | * 1. make KOTodoViewItem a QObject again? | 220 | * 1. make KOTodoViewItem a QObject again? |
221 | * 2. add a public method for setting one todo modified? | 221 | * 2. add a public method for setting one todo modified? |
222 | * 3. add a private method for setting a todo modified + friend here? | 222 | * 3. add a private method for setting a todo modified + friend here? |
223 | * -- zecke 2002-07-08 | 223 | * -- zecke 2002-07-08 |
224 | */ | 224 | */ |
225 | KOTodoViewWhatsThis* mKOTodoViewWhatsThis; | 225 | KOTodoViewWhatsThis* mKOTodoViewWhatsThis; |
226 | friend class KOTodoListView; | 226 | friend class KOTodoListView; |
227 | void paintEvent(QPaintEvent * pevent); | 227 | void paintEvent(QPaintEvent * pevent); |
228 | bool mPendingUpdateBeforeRepaint; | 228 | bool mPendingUpdateBeforeRepaint; |
229 | friend class KOTodoViewItem; | 229 | friend class KOTodoViewItem; |
230 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); | 230 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); |
231 | void restoreItemState( QListViewItem * ); | 231 | void restoreItemState( QListViewItem * ); |
232 | 232 | ||
233 | bool checkTodo( Todo * ); | 233 | bool checkTodo( Todo * ); |
234 | bool isFlatDisplay; | 234 | bool isFlatDisplay; |
235 | void setOpen( QListViewItem*, bool setOpen); | 235 | void setOpen( QListViewItem*, bool setOpen); |
236 | KOTodoListView *mTodoListView; | 236 | KOTodoListView *mTodoListView; |
237 | QPopupMenu *mItemPopupMenu; | 237 | QPopupMenu *mItemPopupMenu; |
238 | QPopupMenu *mPopupMenu; | 238 | QPopupMenu *mPopupMenu; |
239 | QPopupMenu *mPriorityPopupMenu; | 239 | QPopupMenu *mPriorityPopupMenu; |
240 | QPopupMenu *mPercentageCompletedPopupMenu; | 240 | QPopupMenu *mPercentageCompletedPopupMenu; |
241 | QPopupMenu *mCategoryPopupMenu; | 241 | QPopupMenu *mCategoryPopupMenu; |
242 | 242 | ||
243 | QMap<int, int> mPercentage; | 243 | QMap<int, int> mPercentage; |
244 | QMap<int, int> mPriority; | 244 | QMap<int, int> mPriority; |
245 | QMap<int, QString> mCategory; | 245 | QMap<int, QString> mCategory; |
246 | KOTodoViewItem *mActiveItem; | 246 | KOTodoViewItem *mActiveItem; |
247 | 247 | ||
248 | QMap<Todo *,KOTodoViewItem *> mTodoMap; | 248 | QMap<Todo *,KOTodoViewItem *> mTodoMap; |
249 | QString mName; | 249 | QString mName; |
250 | 250 | ||
251 | DocPrefs *mDocPrefs; | 251 | DocPrefs *mDocPrefs; |
252 | QString mCurrentDoc; | 252 | QString mCurrentDoc; |
253 | KOQuickTodo *mQuickAdd; | 253 | KOQuickTodo *mQuickAdd; |
254 | bool mBlockUpdate; | 254 | bool mBlockUpdate; |
255 | void keyPressEvent ( QKeyEvent * ) ; | 255 | void keyPressEvent ( QKeyEvent * ) ; |
256 | KOTodoViewItem * pendingSubtodo; | 256 | KOTodoViewItem * pendingSubtodo; |
257 | DateNavigator* mNavigator; | 257 | DateNavigator* mNavigator; |
258 | void storeCurrentItem(); | 258 | void storeCurrentItem(); |
259 | void resetCurrentItem(); | 259 | void resetCurrentItem(); |
260 | Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 260 | Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; |
261 | }; | 261 | }; |
262 | 262 | ||
263 | #endif | 263 | #endif |