-rw-r--r-- | korganizer/kotodoview.cpp | 26 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 1 |
2 files changed, 17 insertions, 10 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 8d354c8..e2966f8 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -703,250 +703,258 @@ KOTodoView::~KOTodoView() | |||
703 | 703 | ||
704 | delete mDocPrefs; | 704 | delete mDocPrefs; |
705 | } | 705 | } |
706 | QString KOTodoView::getWhatsThisText(QPoint p) | 706 | QString KOTodoView::getWhatsThisText(QPoint p) |
707 | { | 707 | { |
708 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 708 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
709 | if ( item ) | 709 | if ( item ) |
710 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 710 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
711 | KOPrefs::instance()->mWTshowDetails, | 711 | KOPrefs::instance()->mWTshowDetails, |
712 | KOPrefs::instance()->mWTshowCreated, | 712 | KOPrefs::instance()->mWTshowCreated, |
713 | KOPrefs::instance()->mWTshowChanged); | 713 | KOPrefs::instance()->mWTshowChanged); |
714 | return i18n("That is the todo view" ); | 714 | return i18n("That is the todo view" ); |
715 | 715 | ||
716 | } | 716 | } |
717 | 717 | ||
718 | void KOTodoView::jumpToDate () | 718 | void KOTodoView::jumpToDate () |
719 | { | 719 | { |
720 | // if (mActiveItem) { | 720 | // if (mActiveItem) { |
721 | // mActiveItem->todo()); | 721 | // mActiveItem->todo()); |
722 | // if ( mActiveItem->todo()->hasDueDate() ) | 722 | // if ( mActiveItem->todo()->hasDueDate() ) |
723 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 723 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
724 | } | 724 | } |
725 | void KOTodoView::paintNeeded() | 725 | void KOTodoView::paintNeeded() |
726 | { | 726 | { |
727 | if ( mPendingUpdateBeforeRepaint ) { | 727 | if ( mPendingUpdateBeforeRepaint ) { |
728 | updateView(); | 728 | updateView(); |
729 | mPendingUpdateBeforeRepaint = false; | 729 | mPendingUpdateBeforeRepaint = false; |
730 | } | 730 | } |
731 | } | 731 | } |
732 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 732 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
733 | { | 733 | { |
734 | if ( mPendingUpdateBeforeRepaint ) { | 734 | if ( mPendingUpdateBeforeRepaint ) { |
735 | updateView(); | 735 | updateView(); |
736 | mPendingUpdateBeforeRepaint = false; | 736 | mPendingUpdateBeforeRepaint = false; |
737 | } | 737 | } |
738 | KOrg::BaseView::paintEvent( pevent); | 738 | KOrg::BaseView::paintEvent( pevent); |
739 | } | 739 | } |
740 | 740 | ||
741 | void KOTodoView::updateView() | 741 | void KOTodoView::updateView() |
742 | { | 742 | { |
743 | pendingSubtodo = 0; | 743 | pendingSubtodo = 0; |
744 | if ( mBlockUpdate ) { | 744 | if ( mBlockUpdate ) { |
745 | return; | 745 | return; |
746 | } | 746 | } |
747 | if ( !isVisible() ) { | 747 | if ( !isVisible() ) { |
748 | mPendingUpdateBeforeRepaint = true; | 748 | mPendingUpdateBeforeRepaint = true; |
749 | return; | 749 | return; |
750 | } | 750 | } |
751 | storeCurrentItem(); | ||
752 | //qDebug("KOTodoView::updateView() %x", this); | 751 | //qDebug("KOTodoView::updateView() %x", this); |
753 | if ( isFlatDisplay ) { | 752 | if ( isFlatDisplay ) { |
754 | displayAllFlat(); | 753 | displayAllFlat(); |
755 | resetCurrentItem(); | ||
756 | return; | 754 | return; |
757 | } | 755 | } |
756 | storeCurrentItem(); | ||
758 | //qDebug("update "); | 757 | //qDebug("update "); |
759 | // kdDebug() << "KOTodoView::updateView()" << endl; | 758 | // kdDebug() << "KOTodoView::updateView()" << endl; |
760 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 759 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
761 | 760 | ||
762 | 761 | ||
763 | mTodoListView->clear(); | 762 | mTodoListView->clear(); |
764 | if ( mName == "todolistsmall" ) { | 763 | if ( mName == "todolistsmall" ) { |
765 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 764 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
766 | int ps = fo.pointSize() -2; | 765 | int ps = fo.pointSize() -2; |
767 | if ( ps > 12 ) | 766 | if ( ps > 12 ) |
768 | ps -= 2; | 767 | ps -= 2; |
769 | fo.setPointSize( ps ); | 768 | fo.setPointSize( ps ); |
770 | } | 769 | } |
771 | } | 770 | } |
772 | 771 | ||
773 | mTodoListView->setFont( fo ); | 772 | mTodoListView->setFont( fo ); |
774 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 773 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
775 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 774 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
776 | QPtrList<Todo> todoList = calendar()->todos(); | 775 | QPtrList<Todo> todoList = calendar()->todos(); |
777 | 776 | ||
778 | /* | 777 | /* |
779 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 778 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
780 | Event *t; | 779 | Event *t; |
781 | for(t = todoList.first(); t; t = todoList.next()) { | 780 | for(t = todoList.first(); t; t = todoList.next()) { |
782 | kdDebug() << " " << t->getSummary() << endl; | 781 | kdDebug() << " " << t->getSummary() << endl; |
783 | 782 | ||
784 | if (t->getRelatedTo()) { | 783 | if (t->getRelatedTo()) { |
785 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 784 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
786 | } | 785 | } |
787 | 786 | ||
788 | QPtrList<Event> l = t->getRelations(); | 787 | QPtrList<Event> l = t->getRelations(); |
789 | Event *c; | 788 | Event *c; |
790 | for(c=l.first();c;c=l.next()) { | 789 | for(c=l.first();c;c=l.next()) { |
791 | kdDebug() << " - relation: " << c->getSummary() << endl; | 790 | kdDebug() << " - relation: " << c->getSummary() << endl; |
792 | } | 791 | } |
793 | } | 792 | } |
794 | */ | 793 | */ |
795 | 794 | ||
796 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 795 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
797 | // specific order of events. That means that we have to generate parent items | 796 | // specific order of events. That means that we have to generate parent items |
798 | // recursively for proper hierarchical display of Todos. | 797 | // recursively for proper hierarchical display of Todos. |
799 | mTodoMap.clear(); | 798 | mTodoMap.clear(); |
800 | Todo *todo; | 799 | Todo *todo; |
801 | todo = todoList.first();// todo; todo = todoList.next()) { | 800 | todo = todoList.first();// todo; todo = todoList.next()) { |
802 | while ( todo ) { | 801 | while ( todo ) { |
803 | bool next = true; | 802 | bool next = true; |
804 | // qDebug("todo %s ", todo->summary().latin1()); | 803 | // qDebug("todo %s ", todo->summary().latin1()); |
805 | Incidence *incidence = todo->relatedTo(); | 804 | Incidence *incidence = todo->relatedTo(); |
806 | while ( incidence ) { | 805 | while ( incidence ) { |
807 | if ( incidence->typeID() == todoID ) { | 806 | if ( incidence->typeID() == todoID ) { |
808 | //qDebug("related %s ",incidence->summary().latin1() ); | 807 | //qDebug("related %s ",incidence->summary().latin1() ); |
809 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 808 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
810 | //qDebug("related not found "); | 809 | //qDebug("related not found "); |
811 | todoList.remove( ); | 810 | todoList.remove( ); |
812 | todo = todoList.current(); | 811 | todo = todoList.current(); |
813 | next = false; | 812 | next = false; |
814 | incidence = 0; | 813 | incidence = 0; |
815 | 814 | ||
816 | } else { | 815 | } else { |
817 | //qDebug("related found "); | 816 | //qDebug("related found "); |
818 | incidence = incidence->relatedTo(); | 817 | incidence = incidence->relatedTo(); |
819 | } | 818 | } |
820 | } else | 819 | } else |
821 | incidence = 0; | 820 | incidence = 0; |
822 | } | 821 | } |
823 | if ( next ) | 822 | if ( next ) |
824 | todo = todoList.next(); | 823 | todo = todoList.next(); |
825 | } | 824 | } |
826 | 825 | ||
827 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 826 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
828 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 827 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
829 | { | 828 | { |
830 | insertTodoItem(todo); | 829 | insertTodoItem(todo); |
831 | } | 830 | } |
832 | } | 831 | } |
833 | // Restore opened/closed state | 832 | // Restore opened/closed state |
834 | mTodoListView->blockSignals( true ); | 833 | mTodoListView->blockSignals( true ); |
835 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 834 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
836 | mTodoListView->blockSignals( false ); | 835 | mTodoListView->blockSignals( false ); |
837 | resetCurrentItem(); | 836 | resetCurrentItem(); |
838 | processSelectionChange(); | ||
839 | } | 837 | } |
840 | 838 | ||
841 | void KOTodoView::storeCurrentItem() | 839 | void KOTodoView::storeCurrentItem() |
842 | { | 840 | { |
843 | mCurItem = 0; | 841 | mCurItem = 0; |
844 | mCurItemRootParent = 0; | 842 | mCurItemRootParent = 0; |
845 | mCurItemParent = 0; | 843 | mCurItemParent = 0; |
846 | mCurItemAbove = 0; | 844 | mCurItemAbove = 0; |
847 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 845 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
848 | if (mActiveItem) { | 846 | if (mActiveItem) { |
849 | mCurItem = mActiveItem->todo(); | 847 | mCurItem = mActiveItem->todo(); |
850 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 848 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
851 | if ( activeItemAbove ) | 849 | if ( activeItemAbove ) |
852 | mCurItemAbove = activeItemAbove->todo(); | 850 | mCurItemAbove = activeItemAbove->todo(); |
853 | mCurItemRootParent = mCurItem; | 851 | mCurItemRootParent = mCurItem; |
854 | mCurItemParent = mCurItemRootParent->relatedTo(); | 852 | mCurItemParent = mCurItemRootParent->relatedTo(); |
855 | while ( mCurItemRootParent->relatedTo() != 0 ) | 853 | while ( mCurItemRootParent->relatedTo() != 0 ) |
856 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 854 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
857 | } | 855 | } |
858 | mActiveItem = 0; | 856 | mActiveItem = 0; |
859 | } | 857 | } |
860 | 858 | ||
861 | void KOTodoView::resetCurrentItem() | 859 | void KOTodoView::resetCurrentItem() |
862 | { | 860 | { |
863 | mTodoListView->setFocus(); | 861 | //mTodoListView->setFocus(); |
864 | KOTodoViewItem* foundItem = 0; | 862 | KOTodoViewItem* foundItem = 0; |
865 | KOTodoViewItem* foundItemRoot = 0; | 863 | KOTodoViewItem* foundItemRoot = 0; |
866 | KOTodoViewItem* foundItemParent = 0; | 864 | KOTodoViewItem* foundItemParent = 0; |
867 | KOTodoViewItem* foundItemAbove = 0; | 865 | KOTodoViewItem* foundItemAbove = 0; |
868 | if ( mTodoListView->firstChild () ) { | 866 | if ( mTodoListView->firstChild () ) { |
869 | if ( mCurItem ) { | 867 | if ( mCurItem ) { |
870 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 868 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
871 | while ( item ) { | 869 | while ( item ) { |
872 | if ( item->todo() == mCurItem ) { | 870 | if ( item->todo() == mCurItem ) { |
873 | foundItem = item; | 871 | foundItem = item; |
874 | break; | 872 | break; |
875 | } else if ( item->todo() == mCurItemAbove ) { | 873 | } else if ( item->todo() == mCurItemAbove ) { |
876 | foundItemAbove = item; | 874 | foundItemAbove = item; |
877 | 875 | ||
878 | } | 876 | } |
879 | if ( item->todo() == mCurItemRootParent ) { | 877 | if ( item->todo() == mCurItemRootParent ) { |
880 | foundItemRoot = item; | 878 | foundItemRoot = item; |
881 | } | 879 | } |
882 | if ( item->todo() == mCurItemParent ) { | 880 | if ( item->todo() == mCurItemParent ) { |
883 | foundItemParent = item; | 881 | foundItemParent = item; |
884 | } | 882 | } |
885 | item = (KOTodoViewItem*)item->itemBelow(); | 883 | item = (KOTodoViewItem*)item->itemBelow(); |
886 | } | 884 | } |
887 | if ( ! foundItem ) { | 885 | if ( ! foundItem ) { |
888 | if ( foundItemParent ) { | 886 | if ( foundItemParent ) { |
889 | foundItem = foundItemParent; | 887 | foundItem = foundItemParent; |
890 | } else { | 888 | } else { |
891 | if ( foundItemRoot ) | 889 | if ( foundItemRoot ) |
892 | foundItem = foundItemRoot; | 890 | foundItem = foundItemRoot; |
893 | else | 891 | else |
894 | foundItem = foundItemAbove; | 892 | foundItem = foundItemAbove; |
895 | } | 893 | } |
896 | } | 894 | } |
897 | } | 895 | } |
898 | if ( foundItem ) { | 896 | if ( foundItem ) { |
897 | mTodoListView->setSelected ( foundItem, true ); | ||
899 | mTodoListView->setCurrentItem( foundItem ); | 898 | mTodoListView->setCurrentItem( foundItem ); |
900 | mTodoListView->ensureItemVisible( foundItem ); | 899 | mTodoListView->ensureItemVisible( foundItem ); |
901 | } else { | 900 | } else { |
902 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 901 | if ( mTodoListView->firstChild () ) { |
902 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | ||
903 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | ||
904 | } | ||
903 | } | 905 | } |
904 | } | 906 | } |
907 | processSelectionChange(); | ||
908 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | ||
909 | } | ||
910 | void KOTodoView::resetFocusToList() | ||
911 | { | ||
912 | topLevelWidget()->setActiveWindow(); | ||
905 | mTodoListView->setFocus(); | 913 | mTodoListView->setFocus(); |
906 | } | 914 | } |
907 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 915 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
908 | bool KOTodoView::checkTodo( Todo * todo ) | 916 | bool KOTodoView::checkTodo( Todo * todo ) |
909 | { | 917 | { |
910 | 918 | ||
911 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 919 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
912 | return false; | 920 | return false; |
913 | if ( !todo->isCompleted() ) { | 921 | if ( !todo->isCompleted() ) { |
914 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 922 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
915 | return true; | 923 | return true; |
916 | } | 924 | } |
917 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 925 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
918 | if ( todo->hasStartDate() ) | 926 | if ( todo->hasStartDate() ) |
919 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 927 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
920 | return false; | 928 | return false; |
921 | if ( todo->hasDueDate() ) | 929 | if ( todo->hasDueDate() ) |
922 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 930 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
923 | return false; | 931 | return false; |
924 | } | 932 | } |
925 | return true; | 933 | return true; |
926 | } | 934 | } |
927 | 935 | ||
928 | void KOTodoView::restoreItemState( QListViewItem *item ) | 936 | void KOTodoView::restoreItemState( QListViewItem *item ) |
929 | { | 937 | { |
930 | pendingSubtodo = 0; | 938 | pendingSubtodo = 0; |
931 | while( item ) { | 939 | while( item ) { |
932 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 940 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
933 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 941 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
934 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 942 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
935 | item = item->nextSibling(); | 943 | item = item->nextSibling(); |
936 | } | 944 | } |
937 | } | 945 | } |
938 | 946 | ||
939 | 947 | ||
940 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 948 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
941 | KOTodoView::insertTodoItem(Todo *todo) | 949 | KOTodoView::insertTodoItem(Todo *todo) |
942 | { | 950 | { |
943 | 951 | ||
944 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 952 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
945 | // TODO: Check, if dynmaic cast is necessary | 953 | // TODO: Check, if dynmaic cast is necessary |
946 | 954 | ||
947 | pendingSubtodo = 0; | 955 | pendingSubtodo = 0; |
948 | Incidence *incidence = todo->relatedTo(); | 956 | Incidence *incidence = todo->relatedTo(); |
949 | while ( incidence && !incidence->calEnabled() ) | 957 | while ( incidence && !incidence->calEnabled() ) |
950 | incidence = incidence->relatedTo(); | 958 | incidence = incidence->relatedTo(); |
951 | if (incidence && incidence->typeID() == todoID ) { | 959 | if (incidence && incidence->typeID() == todoID ) { |
952 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 960 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
@@ -1359,125 +1367,123 @@ void KOTodoView::processSelectionChange() | |||
1359 | void KOTodoView::modified(bool b) | 1367 | void KOTodoView::modified(bool b) |
1360 | { | 1368 | { |
1361 | emit isModified(b); | 1369 | emit isModified(b); |
1362 | } | 1370 | } |
1363 | void KOTodoView::setTodoModified( Todo* todo ) | 1371 | void KOTodoView::setTodoModified( Todo* todo ) |
1364 | { | 1372 | { |
1365 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1373 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1366 | } | 1374 | } |
1367 | void KOTodoView::clearSelection() | 1375 | void KOTodoView::clearSelection() |
1368 | { | 1376 | { |
1369 | mTodoListView->selectAll( false ); | 1377 | mTodoListView->selectAll( false ); |
1370 | } | 1378 | } |
1371 | void KOTodoView::setAllOpen() | 1379 | void KOTodoView::setAllOpen() |
1372 | { | 1380 | { |
1373 | if ( isFlatDisplay ) { | 1381 | if ( isFlatDisplay ) { |
1374 | isFlatDisplay = false; | 1382 | isFlatDisplay = false; |
1375 | mPopupMenu->setItemChecked( 8,false ); | 1383 | mPopupMenu->setItemChecked( 8,false ); |
1376 | updateView(); | 1384 | updateView(); |
1377 | } else { | 1385 | } else { |
1378 | storeCurrentItem(); | 1386 | storeCurrentItem(); |
1379 | } | 1387 | } |
1380 | setOpen(mTodoListView->firstChild(), true); | 1388 | setOpen(mTodoListView->firstChild(), true); |
1381 | resetCurrentItem(); | 1389 | resetCurrentItem(); |
1382 | } | 1390 | } |
1383 | void KOTodoView::setAllClose() | 1391 | void KOTodoView::setAllClose() |
1384 | { | 1392 | { |
1385 | if ( isFlatDisplay ) { | 1393 | if ( isFlatDisplay ) { |
1386 | isFlatDisplay = false; | 1394 | isFlatDisplay = false; |
1387 | mPopupMenu->setItemChecked( 8,false ); | 1395 | mPopupMenu->setItemChecked( 8,false ); |
1388 | updateView(); | 1396 | updateView(); |
1389 | } else { | 1397 | } else { |
1390 | storeCurrentItem(); | 1398 | storeCurrentItem(); |
1391 | } | 1399 | } |
1392 | setOpen(mTodoListView->firstChild(), false); | 1400 | setOpen(mTodoListView->firstChild(), false); |
1393 | resetCurrentItem(); | 1401 | resetCurrentItem(); |
1394 | } | 1402 | } |
1395 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1403 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1396 | { | 1404 | { |
1397 | 1405 | ||
1398 | while ( item ) { | 1406 | while ( item ) { |
1399 | setOpen( item->firstChild(), setOpenI ); | 1407 | setOpen( item->firstChild(), setOpenI ); |
1400 | item->setOpen( setOpenI ); | 1408 | item->setOpen( setOpenI ); |
1401 | item = item->nextSibling(); | 1409 | item = item->nextSibling(); |
1402 | } | 1410 | } |
1403 | } | 1411 | } |
1404 | 1412 | ||
1405 | void KOTodoView::displayAllFlat() | 1413 | void KOTodoView::displayAllFlat() |
1406 | { | 1414 | { |
1415 | storeCurrentItem(); | ||
1407 | pendingSubtodo = 0; | 1416 | pendingSubtodo = 0; |
1408 | if ( mBlockUpdate ) { | 1417 | if ( mBlockUpdate ) { |
1409 | return; | 1418 | return; |
1410 | } | 1419 | } |
1411 | mPopupMenu->setItemChecked( 8,true ); | 1420 | mPopupMenu->setItemChecked( 8,true ); |
1412 | isFlatDisplay = true; | 1421 | isFlatDisplay = true; |
1413 | QPtrList<Todo> todoList = calendar()->todos(); | 1422 | QPtrList<Todo> todoList = calendar()->todos(); |
1414 | mTodoMap.clear(); | 1423 | mTodoMap.clear(); |
1415 | mTodoListView->clear(); | 1424 | mTodoListView->clear(); |
1416 | Todo *todo; | 1425 | Todo *todo; |
1417 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1426 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1418 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1427 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1419 | mTodoMap.insert(todo,todoItem); | 1428 | mTodoMap.insert(todo,todoItem); |
1420 | } | 1429 | } |
1421 | mTodoListView->setFocus(); | 1430 | resetCurrentItem(); |
1422 | processSelectionChange(); | ||
1423 | } | 1431 | } |
1424 | 1432 | ||
1425 | void KOTodoView::setAllFlat() | 1433 | void KOTodoView::setAllFlat() |
1426 | { | 1434 | { |
1427 | if ( isFlatDisplay ) { | 1435 | if ( isFlatDisplay ) { |
1428 | isFlatDisplay = false; | 1436 | isFlatDisplay = false; |
1429 | mPopupMenu->setItemChecked( 8,false ); | 1437 | mPopupMenu->setItemChecked( 8,false ); |
1430 | updateView(); | 1438 | updateView(); |
1431 | return; | 1439 | return; |
1432 | } | 1440 | } |
1433 | storeCurrentItem(); | ||
1434 | displayAllFlat(); | 1441 | displayAllFlat(); |
1435 | resetCurrentItem(); | ||
1436 | } | 1442 | } |
1437 | 1443 | ||
1438 | void KOTodoView::purgeCompleted() | 1444 | void KOTodoView::purgeCompleted() |
1439 | { | 1445 | { |
1440 | emit purgeCompletedSignal(); | 1446 | emit purgeCompletedSignal(); |
1441 | 1447 | ||
1442 | } | 1448 | } |
1443 | void KOTodoView::toggleQuickTodo() | 1449 | void KOTodoView::toggleQuickTodo() |
1444 | { | 1450 | { |
1445 | if ( mQuickAdd->isVisible() ) { | 1451 | if ( mQuickAdd->isVisible() ) { |
1446 | mQuickAdd->hide(); | 1452 | mQuickAdd->hide(); |
1447 | KOPrefs::instance()->mEnableQuickTodo = false; | 1453 | KOPrefs::instance()->mEnableQuickTodo = false; |
1448 | } | 1454 | } |
1449 | else { | 1455 | else { |
1450 | mQuickAdd->show(); | 1456 | mQuickAdd->show(); |
1451 | KOPrefs::instance()->mEnableQuickTodo = true; | 1457 | KOPrefs::instance()->mEnableQuickTodo = true; |
1452 | } | 1458 | } |
1453 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1459 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1454 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1460 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1455 | } | 1461 | } |
1456 | 1462 | ||
1457 | void KOTodoView::toggleRunning() | 1463 | void KOTodoView::toggleRunning() |
1458 | { | 1464 | { |
1459 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1465 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1460 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1466 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1461 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1467 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1462 | updateView(); | 1468 | updateView(); |
1463 | } | 1469 | } |
1464 | 1470 | ||
1465 | void KOTodoView::toggleCompleted() | 1471 | void KOTodoView::toggleCompleted() |
1466 | { | 1472 | { |
1467 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1473 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1468 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1474 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1469 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1475 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1470 | updateView(); | 1476 | updateView(); |
1471 | } | 1477 | } |
1472 | 1478 | ||
1473 | void KOTodoView::addQuickTodo() | 1479 | void KOTodoView::addQuickTodo() |
1474 | { | 1480 | { |
1475 | Todo *todo = new Todo(); | 1481 | Todo *todo = new Todo(); |
1476 | todo->setSummary(mQuickAdd->text()); | 1482 | todo->setSummary(mQuickAdd->text()); |
1477 | todo->setOrganizer(KOPrefs::instance()->email()); | 1483 | todo->setOrganizer(KOPrefs::instance()->email()); |
1478 | CalFilter * cf = mCalendar->filter(); | 1484 | CalFilter * cf = mCalendar->filter(); |
1479 | if ( cf ) { | 1485 | if ( cf ) { |
1480 | if ( cf->isEnabled()&& cf->showCategories()) { | 1486 | if ( cf->isEnabled()&& cf->showCategories()) { |
1481 | todo->setCategories(cf->categoryList()); | 1487 | todo->setCategories(cf->categoryList()); |
1482 | } | 1488 | } |
1483 | if ( cf->isEnabled() ) | 1489 | if ( cf->isEnabled() ) |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 1b31d0d..9ae7f53 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -179,96 +179,97 @@ class KOTodoView : public KOrg::BaseView | |||
179 | void clearList() {mTodoListView->clear(); } | 179 | void clearList() {mTodoListView->clear(); } |
180 | 180 | ||
181 | public slots: | 181 | public slots: |
182 | void updateView(); | 182 | void updateView(); |
183 | void updateConfig(); | 183 | void updateConfig(); |
184 | 184 | ||
185 | void changeEventDisplay(Event *, int); | 185 | void changeEventDisplay(Event *, int); |
186 | 186 | ||
187 | void showDates(const QDate &start, const QDate &end); | 187 | void showDates(const QDate &start, const QDate &end); |
188 | void showEvents(QPtrList<Event> eventList); | 188 | void showEvents(QPtrList<Event> eventList); |
189 | 189 | ||
190 | void clearSelection(); | 190 | void clearSelection(); |
191 | void jumpToDate (); | 191 | void jumpToDate (); |
192 | 192 | ||
193 | void editItem(QListViewItem *item); | 193 | void editItem(QListViewItem *item); |
194 | void showItem(QListViewItem *item,const QPoint &,int); | 194 | void showItem(QListViewItem *item,const QPoint &,int); |
195 | void popupMenu(QListViewItem *item,const QPoint &,int); | 195 | void popupMenu(QListViewItem *item,const QPoint &,int); |
196 | void newTodo(); | 196 | void newTodo(); |
197 | void newSubTodo(); | 197 | void newSubTodo(); |
198 | void unparentTodo(); | 198 | void unparentTodo(); |
199 | void reparentTodo(); | 199 | void reparentTodo(); |
200 | void showTodo(); | 200 | void showTodo(); |
201 | void editTodo(); | 201 | void editTodo(); |
202 | void cloneTodo(); | 202 | void cloneTodo(); |
203 | void cancelTodo(); | 203 | void cancelTodo(); |
204 | void moveTodo(); | 204 | void moveTodo(); |
205 | void beamTodo(); | 205 | void beamTodo(); |
206 | void deleteTodo(); | 206 | void deleteTodo(); |
207 | 207 | ||
208 | void setNewPriority(int); | 208 | void setNewPriority(int); |
209 | void setNewPercentage(int); | 209 | void setNewPercentage(int); |
210 | void changedCategories(int); | 210 | void changedCategories(int); |
211 | 211 | ||
212 | void setAllOpen(); | 212 | void setAllOpen(); |
213 | void setAllClose(); | 213 | void setAllClose(); |
214 | void setAllFlat(); | 214 | void setAllFlat(); |
215 | void displayAllFlat(); | 215 | void displayAllFlat(); |
216 | 216 | ||
217 | void purgeCompleted(); | 217 | void purgeCompleted(); |
218 | void toggleCompleted(); | 218 | void toggleCompleted(); |
219 | void toggleRunning(); | 219 | void toggleRunning(); |
220 | void toggleQuickTodo(); | 220 | void toggleQuickTodo(); |
221 | void updateTodo( Todo *, int ); | 221 | void updateTodo( Todo *, int ); |
222 | 222 | ||
223 | void itemClicked(QListViewItem *); | 223 | void itemClicked(QListViewItem *); |
224 | void itemStateChanged(QListViewItem *); | 224 | void itemStateChanged(QListViewItem *); |
225 | void modified(bool); | 225 | void modified(bool); |
226 | void itemDoubleClicked(QListViewItem *item); | 226 | void itemDoubleClicked(QListViewItem *item); |
227 | void resetFocusToList(); | ||
227 | 228 | ||
228 | signals: | 229 | signals: |
229 | void newTodoSignal(); | 230 | void newTodoSignal(); |
230 | void newSubTodoSignal(Todo *); | 231 | void newSubTodoSignal(Todo *); |
231 | void unparentTodoSignal(Todo *); | 232 | void unparentTodoSignal(Todo *); |
232 | void reparentTodoSignal( Todo *,Todo * ); | 233 | void reparentTodoSignal( Todo *,Todo * ); |
233 | void showTodoSignal(Todo *); | 234 | void showTodoSignal(Todo *); |
234 | 235 | ||
235 | void editTodoSignal(Todo *); | 236 | void editTodoSignal(Todo *); |
236 | void deleteTodoSignal(Todo *); | 237 | void deleteTodoSignal(Todo *); |
237 | void todoModifiedSignal (Todo *, int); | 238 | void todoModifiedSignal (Todo *, int); |
238 | 239 | ||
239 | void isModified(bool); | 240 | void isModified(bool); |
240 | void cloneTodoSignal( Incidence * ); | 241 | void cloneTodoSignal( Incidence * ); |
241 | void cancelTodoSignal( Incidence * ); | 242 | void cancelTodoSignal( Incidence * ); |
242 | void moveTodoSignal( Incidence * ); | 243 | void moveTodoSignal( Incidence * ); |
243 | void beamTodoSignal( Incidence * ); | 244 | void beamTodoSignal( Incidence * ); |
244 | void purgeCompletedSignal(); | 245 | void purgeCompletedSignal(); |
245 | 246 | ||
246 | protected slots: | 247 | protected slots: |
247 | void toggleRunningItem(); | 248 | void toggleRunningItem(); |
248 | void paintNeeded(); | 249 | void paintNeeded(); |
249 | void processSelectionChange(); | 250 | void processSelectionChange(); |
250 | void addQuickTodo(); | 251 | void addQuickTodo(); |
251 | void setTodoModified( Todo* ); | 252 | void setTodoModified( Todo* ); |
252 | void todoModified(Todo *, int ); | 253 | void todoModified(Todo *, int ); |
253 | 254 | ||
254 | private: | 255 | private: |
255 | /* | 256 | /* |
256 | * the TodoEditor approach is rather unscaling in the long | 257 | * the TodoEditor approach is rather unscaling in the long |
257 | * run. | 258 | * run. |
258 | * Korganizer keeps it in memory and we need to update | 259 | * Korganizer keeps it in memory and we need to update |
259 | * 1. make KOTodoViewItem a QObject again? | 260 | * 1. make KOTodoViewItem a QObject again? |
260 | * 2. add a public method for setting one todo modified? | 261 | * 2. add a public method for setting one todo modified? |
261 | * 3. add a private method for setting a todo modified + friend here? | 262 | * 3. add a private method for setting a todo modified + friend here? |
262 | * -- zecke 2002-07-08 | 263 | * -- zecke 2002-07-08 |
263 | */ | 264 | */ |
264 | KOTodoViewWhatsThis* mKOTodoViewWhatsThis; | 265 | KOTodoViewWhatsThis* mKOTodoViewWhatsThis; |
265 | friend class KOTodoListView; | 266 | friend class KOTodoListView; |
266 | void paintEvent(QPaintEvent * pevent); | 267 | void paintEvent(QPaintEvent * pevent); |
267 | bool mPendingUpdateBeforeRepaint; | 268 | bool mPendingUpdateBeforeRepaint; |
268 | friend class KOTodoViewItem; | 269 | friend class KOTodoViewItem; |
269 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); | 270 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); |
270 | void restoreItemState( QListViewItem * ); | 271 | void restoreItemState( QListViewItem * ); |
271 | 272 | ||
272 | bool checkTodo( Todo * ); | 273 | bool checkTodo( Todo * ); |
273 | bool isFlatDisplay; | 274 | bool isFlatDisplay; |
274 | void setOpen( QListViewItem*, bool setOpen); | 275 | void setOpen( QListViewItem*, bool setOpen); |