-rw-r--r-- | korganizer/kotodoview.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1a1bce5..3011458 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -916,101 +916,108 @@ void KOTodoView::setNewPriority(int index) | |||
916 | void KOTodoView::setNewPercentage(int index) | 916 | void KOTodoView::setNewPercentage(int index) |
917 | { | 917 | { |
918 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 918 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
919 | 919 | ||
920 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 920 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
921 | mActiveItem->setOn( true ); | 921 | mActiveItem->setOn( true ); |
922 | return; | 922 | return; |
923 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 923 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
924 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 924 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
925 | if ( par && par->isOn() ) | 925 | if ( par && par->isOn() ) |
926 | par->setOn( false ); | 926 | par->setOn( false ); |
927 | } | 927 | } |
928 | if (mPercentage[index] == 100) { | 928 | if (mPercentage[index] == 100) { |
929 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 929 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
930 | } else { | 930 | } else { |
931 | mActiveItem->todo()->setCompleted(false); | 931 | mActiveItem->todo()->setCompleted(false); |
932 | } | 932 | } |
933 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 933 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
934 | mActiveItem->construct(); | 934 | mActiveItem->construct(); |
935 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 935 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
936 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 936 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | 939 | ||
940 | 940 | ||
941 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 941 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
942 | { | 942 | { |
943 | QPopupMenu* tempMenu = new QPopupMenu (this); | 943 | QPopupMenu* tempMenu = new QPopupMenu (this); |
944 | QStringList checkedCategories = todoItem->todo()->categories (); | 944 | QStringList checkedCategories = todoItem->todo()->categories (); |
945 | 945 | ||
946 | tempMenu->setCheckable (true); | 946 | tempMenu->setCheckable (true); |
947 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 947 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
948 | it != KOPrefs::instance()->mCustomCategories.end (); | 948 | it != KOPrefs::instance()->mCustomCategories.end (); |
949 | ++it) { | 949 | ++it) { |
950 | int index = tempMenu->insertItem (*it); | 950 | int index = tempMenu->insertItem (*it); |
951 | mCategory[index] = *it; | 951 | mCategory[index] = *it; |
952 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 952 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
953 | } | 953 | } |
954 | 954 | ||
955 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 955 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
956 | return tempMenu; | 956 | return tempMenu; |
957 | 957 | ||
958 | 958 | ||
959 | } | 959 | } |
960 | void KOTodoView::changedCategories(int index) | 960 | void KOTodoView::changedCategories(int index) |
961 | { | 961 | { |
962 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 962 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
963 | QStringList categories = mActiveItem->todo()->categories (); | 963 | QStringList categories = mActiveItem->todo()->categories (); |
964 | QString colcat = categories.first(); | ||
964 | if (categories.find (mCategory[index]) != categories.end ()) | 965 | if (categories.find (mCategory[index]) != categories.end ()) |
965 | categories.remove (mCategory[index]); | 966 | categories.remove (mCategory[index]); |
966 | else | 967 | else |
967 | categories.insert (categories.end(), mCategory[index]); | 968 | categories.insert (categories.end(), mCategory[index]); |
968 | categories.sort (); | 969 | categories.sort (); |
970 | if ( !colcat.isEmpty() ) { | ||
971 | if ( categories.find ( colcat ) != categories.end () ) { | ||
972 | categories.remove( colcat ); | ||
973 | categories.prepend( colcat ); | ||
974 | } | ||
975 | } | ||
969 | mActiveItem->todo()->setCategories (categories); | 976 | mActiveItem->todo()->setCategories (categories); |
970 | mActiveItem->construct(); | 977 | mActiveItem->construct(); |
971 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 978 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
972 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 979 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
973 | } | 980 | } |
974 | } | 981 | } |
975 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 982 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
976 | { | 983 | { |
977 | if ( pendingSubtodo != 0 ) { | 984 | if ( pendingSubtodo != 0 ) { |
978 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 985 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
979 | } | 986 | } |
980 | pendingSubtodo = 0; | 987 | pendingSubtodo = 0; |
981 | if (!item) { | 988 | if (!item) { |
982 | newTodo(); | 989 | newTodo(); |
983 | return; | 990 | return; |
984 | } | 991 | } |
985 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 992 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
986 | editItem( item ); | 993 | editItem( item ); |
987 | else | 994 | else |
988 | showItem( item , QPoint(), 0 ); | 995 | showItem( item , QPoint(), 0 ); |
989 | } | 996 | } |
990 | void KOTodoView::itemClicked(QListViewItem *item) | 997 | void KOTodoView::itemClicked(QListViewItem *item) |
991 | { | 998 | { |
992 | 999 | ||
993 | if (!item) { | 1000 | if (!item) { |
994 | if ( pendingSubtodo != 0 ) { | 1001 | if ( pendingSubtodo != 0 ) { |
995 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1002 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
996 | } | 1003 | } |
997 | pendingSubtodo = 0; | 1004 | pendingSubtodo = 0; |
998 | return; | 1005 | return; |
999 | } | 1006 | } |
1000 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1007 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1001 | if ( pendingSubtodo != 0 ) { | 1008 | if ( pendingSubtodo != 0 ) { |
1002 | bool allowReparent = true; | 1009 | bool allowReparent = true; |
1003 | QListViewItem *par = item; | 1010 | QListViewItem *par = item; |
1004 | while ( par ) { | 1011 | while ( par ) { |
1005 | if ( par == pendingSubtodo ) { | 1012 | if ( par == pendingSubtodo ) { |
1006 | allowReparent = false; | 1013 | allowReparent = false; |
1007 | break; | 1014 | break; |
1008 | } | 1015 | } |
1009 | par = par->parent(); | 1016 | par = par->parent(); |
1010 | } | 1017 | } |
1011 | if ( !allowReparent ) { | 1018 | if ( !allowReparent ) { |
1012 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1019 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1013 | qDebug("Recursive reparenting not possible "); | 1020 | qDebug("Recursive reparenting not possible "); |
1014 | pendingSubtodo = 0; | 1021 | pendingSubtodo = 0; |
1015 | } else { | 1022 | } else { |
1016 | Todo* newParent = todoItem->todo(); | 1023 | Todo* newParent = todoItem->todo(); |