-rw-r--r-- | korganizer/kotodoview.cpp | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index e2966f8..4f42c83 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -522,114 +522,128 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
522 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 522 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
523 | mTodoListView->addColumn(i18n("Complete")); | 523 | mTodoListView->addColumn(i18n("Complete")); |
524 | mTodoListView->setColumnAlignment(2,AlignCenter); | 524 | mTodoListView->setColumnAlignment(2,AlignCenter); |
525 | 525 | ||
526 | mTodoListView->addColumn(i18n("Due Date")); | 526 | mTodoListView->addColumn(i18n("Due Date")); |
527 | mTodoListView->setColumnAlignment(3,AlignLeft); | 527 | mTodoListView->setColumnAlignment(3,AlignLeft); |
528 | mTodoListView->addColumn(i18n("Due Time")); | 528 | mTodoListView->addColumn(i18n("Due Time")); |
529 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 529 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
530 | 530 | ||
531 | mTodoListView->addColumn(i18n("Start Date")); | 531 | mTodoListView->addColumn(i18n("Start Date")); |
532 | mTodoListView->setColumnAlignment(5,AlignLeft); | 532 | mTodoListView->setColumnAlignment(5,AlignLeft); |
533 | mTodoListView->addColumn(i18n("Start Time")); | 533 | mTodoListView->addColumn(i18n("Start Time")); |
534 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 534 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
535 | 535 | ||
536 | mTodoListView->addColumn(i18n("Cancelled")); | 536 | mTodoListView->addColumn(i18n("Cancelled")); |
537 | mTodoListView->addColumn(i18n("Categories")); | 537 | mTodoListView->addColumn(i18n("Categories")); |
538 | mTodoListView->addColumn(i18n("Calendar")); | 538 | mTodoListView->addColumn(i18n("Calendar")); |
539 | #if 0 | 539 | #if 0 |
540 | mTodoListView->addColumn(i18n("Sort Id")); | 540 | mTodoListView->addColumn(i18n("Sort Id")); |
541 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 541 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
542 | #endif | 542 | #endif |
543 | 543 | ||
544 | mTodoListView->setMinimumHeight( 60 ); | 544 | mTodoListView->setMinimumHeight( 60 ); |
545 | mTodoListView->setItemsRenameable( true ); | 545 | mTodoListView->setItemsRenameable( true ); |
546 | mTodoListView->setRenameable( 0 ); | 546 | mTodoListView->setRenameable( 0 ); |
547 | mTodoListView->setColumnWidth( 0, 120 ); | 547 | mTodoListView->setColumnWidth( 0, 120 ); |
548 | int iii = 0; | 548 | int iii = 0; |
549 | for ( iii = 0; iii< 10 ; ++iii ) | 549 | for ( iii = 0; iii< 10 ; ++iii ) |
550 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 550 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
551 | 551 | ||
552 | 552 | ||
553 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 553 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
554 | 554 | ||
555 | mPriorityPopupMenu = new QPopupMenu(this); | 555 | mPriorityPopupMenu = new QPopupMenu(this); |
556 | for (int i = 1; i <= 5; i++) { | 556 | for (int i = 1; i <= 5; i++) { |
557 | QString label = QString ("%1").arg (i); | 557 | QString label = QString ("%1").arg (i); |
558 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 558 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
559 | } | 559 | } |
560 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 560 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
561 | 561 | ||
562 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 562 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
563 | for (int i = 0; i <= 100; i+=20) { | 563 | for (int i = 0; i <= 100; i+=20) { |
564 | QString label = QString ("%1 %").arg (i); | 564 | QString label = QString ("%1 %").arg (i); |
565 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 565 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
566 | } | 566 | } |
567 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 567 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
568 | 568 | ||
569 | 569 | ||
570 | mCategoryPopupMenu = new QPopupMenu (this); | ||
571 | mCategoryPopupMenu->setCheckable (true); | ||
572 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | ||
573 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | ||
574 | |||
575 | mCalPopupMenu = new QPopupMenu (this); | ||
576 | mCalPopupMenu->setCheckable (true); | ||
577 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | ||
578 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | ||
579 | |||
580 | |||
581 | |||
570 | 582 | ||
571 | mItemPopupMenu = new QPopupMenu(this); | 583 | mItemPopupMenu = new QPopupMenu(this); |
572 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 584 | mItemPopupMenu->insertItem(i18n("Show"), this, |
573 | SLOT (showTodo())); | 585 | SLOT (showTodo())); |
574 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 586 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
575 | SLOT (editTodo())); | 587 | SLOT (editTodo())); |
576 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 588 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
577 | SLOT (deleteTodo())); | 589 | SLOT (deleteTodo())); |
578 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 590 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
579 | SLOT (cloneTodo())); | 591 | SLOT (cloneTodo())); |
580 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 592 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
581 | SLOT (moveTodo())); | 593 | SLOT (moveTodo())); |
582 | #ifndef DESKTOP_VERSION | 594 | #ifndef DESKTOP_VERSION |
583 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 595 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
584 | SLOT (beamTodo())); | 596 | SLOT (beamTodo())); |
585 | #endif | 597 | #endif |
586 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 598 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
587 | SLOT (cancelTodo())); | 599 | SLOT (cancelTodo())); |
600 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | ||
601 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | ||
588 | mItemPopupMenu->insertSeparator(); | 602 | mItemPopupMenu->insertSeparator(); |
589 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 603 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
590 | SLOT (toggleRunningItem())); | 604 | SLOT (toggleRunningItem())); |
591 | mItemPopupMenu->insertSeparator(); | 605 | mItemPopupMenu->insertSeparator(); |
592 | /* | 606 | /* |
593 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 607 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
594 | SLOT (newTodo())); | 608 | SLOT (newTodo())); |
595 | */ | 609 | */ |
596 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 610 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
597 | SLOT (newSubTodo())); | 611 | SLOT (newSubTodo())); |
598 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 612 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
599 | SLOT (unparentTodo()),0,21); | 613 | SLOT (unparentTodo()),0,21); |
600 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 614 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
601 | SLOT (reparentTodo()),0,22); | 615 | SLOT (reparentTodo()),0,22); |
602 | mItemPopupMenu->insertSeparator(); | 616 | mItemPopupMenu->insertSeparator(); |
603 | #if 0 | 617 | #if 0 |
604 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 618 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
605 | this, SLOT( purgeCompleted() ) ); | 619 | this, SLOT( purgeCompleted() ) ); |
606 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 620 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
607 | this, SLOT( toggleCompleted() ),0, 33 ); | 621 | this, SLOT( toggleCompleted() ),0, 33 ); |
608 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 622 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
609 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 623 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
610 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 624 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
611 | this, SLOT( toggleRunning() ),0, 35 ); | 625 | this, SLOT( toggleRunning() ),0, 35 ); |
612 | 626 | ||
613 | #endif | 627 | #endif |
614 | mPopupMenu = new QPopupMenu(this); | 628 | mPopupMenu = new QPopupMenu(this); |
615 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 629 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
616 | SLOT (newTodo()),0,1); | 630 | SLOT (newTodo()),0,1); |
617 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 631 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
618 | this, SLOT(purgeCompleted()),0,2); | 632 | this, SLOT(purgeCompleted()),0,2); |
619 | mPopupMenu->insertItem(i18n("Show Completed"), | 633 | mPopupMenu->insertItem(i18n("Show Completed"), |
620 | this, SLOT( toggleCompleted() ),0,3 ); | 634 | this, SLOT( toggleCompleted() ),0,3 ); |
621 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 635 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
622 | this, SLOT( toggleRunning() ),0,5 ); | 636 | this, SLOT( toggleRunning() ),0,5 ); |
623 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 637 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
624 | this, SLOT( setAllOpen() ),0,6 ); | 638 | this, SLOT( setAllOpen() ),0,6 ); |
625 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 639 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
626 | this, SLOT( setAllClose() ),0,7 ); | 640 | this, SLOT( setAllClose() ),0,7 ); |
627 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 641 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
628 | this, SLOT( setAllFlat() ),0,8 ); | 642 | this, SLOT( setAllFlat() ),0,8 ); |
629 | mPopupMenu->insertSeparator(); | 643 | mPopupMenu->insertSeparator(); |
630 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 644 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
631 | this, SLOT( toggleQuickTodo() ),0,4 ); | 645 | this, SLOT( toggleQuickTodo() ),0,4 ); |
632 | mDocPrefs = new DocPrefs( name ); | 646 | mDocPrefs = new DocPrefs( name ); |
633 | 647 | ||
634 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 648 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
635 | mPopupMenu->setCheckable( true ); | 649 | mPopupMenu->setCheckable( true ); |
@@ -1008,97 +1022,99 @@ QPtrList<Todo> KOTodoView::selectedTodos() | |||
1008 | } | 1022 | } |
1009 | 1023 | ||
1010 | void KOTodoView::changeEventDisplay(Event *, int) | 1024 | void KOTodoView::changeEventDisplay(Event *, int) |
1011 | { | 1025 | { |
1012 | updateView(); | 1026 | updateView(); |
1013 | } | 1027 | } |
1014 | 1028 | ||
1015 | void KOTodoView::showDates(const QDate &, const QDate &) | 1029 | void KOTodoView::showDates(const QDate &, const QDate &) |
1016 | { | 1030 | { |
1017 | } | 1031 | } |
1018 | 1032 | ||
1019 | void KOTodoView::showEvents(QPtrList<Event>) | 1033 | void KOTodoView::showEvents(QPtrList<Event>) |
1020 | { | 1034 | { |
1021 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1035 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1022 | } | 1036 | } |
1023 | 1037 | ||
1024 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1038 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1025 | const QDate &td) | 1039 | const QDate &td) |
1026 | { | 1040 | { |
1027 | #ifndef KORG_NOPRINTER | 1041 | #ifndef KORG_NOPRINTER |
1028 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1042 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1029 | #endif | 1043 | #endif |
1030 | } | 1044 | } |
1031 | 1045 | ||
1032 | void KOTodoView::editItem(QListViewItem *item ) | 1046 | void KOTodoView::editItem(QListViewItem *item ) |
1033 | { | 1047 | { |
1034 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1048 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1035 | } | 1049 | } |
1036 | 1050 | ||
1037 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1051 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1038 | { | 1052 | { |
1039 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1053 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1040 | } | 1054 | } |
1041 | 1055 | ||
1042 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1056 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1043 | { | 1057 | { |
1044 | pendingSubtodo = 0; | 1058 | pendingSubtodo = 0; |
1045 | mActiveItem = (KOTodoViewItem *)item; | 1059 | mActiveItem = (KOTodoViewItem *)item; |
1046 | if (item) { | 1060 | if (item) { |
1047 | switch (column){ | 1061 | switch (column){ |
1048 | case 1: | 1062 | case 1: |
1049 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1063 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1050 | case 2: | 1064 | case 2: |
1051 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1065 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1052 | case 3: | 1066 | case 3: |
1053 | moveTodo(); | 1067 | moveTodo(); |
1054 | break; | 1068 | break; |
1055 | case 8: | 1069 | case 8: |
1056 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 1070 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1071 | case 9: | ||
1072 | mCalPopupMenu->popup(QCursor::pos ()); break; | ||
1057 | default: | 1073 | default: |
1058 | mItemPopupMenu->popup(QCursor::pos()); | 1074 | mItemPopupMenu->popup(QCursor::pos()); |
1059 | } | 1075 | } |
1060 | } else mPopupMenu->popup(QCursor::pos()); | 1076 | } else mPopupMenu->popup(QCursor::pos()); |
1061 | } | 1077 | } |
1062 | void KOTodoView::newTodo() | 1078 | void KOTodoView::newTodo() |
1063 | { | 1079 | { |
1064 | emit newTodoSignal(); | 1080 | emit newTodoSignal(); |
1065 | } | 1081 | } |
1066 | 1082 | ||
1067 | void KOTodoView::newSubTodo() | 1083 | void KOTodoView::newSubTodo() |
1068 | { | 1084 | { |
1069 | if (mActiveItem) { | 1085 | if (mActiveItem) { |
1070 | emit newSubTodoSignal(mActiveItem->todo()); | 1086 | emit newSubTodoSignal(mActiveItem->todo()); |
1071 | } | 1087 | } |
1072 | } | 1088 | } |
1073 | void KOTodoView::unparentTodo() | 1089 | void KOTodoView::unparentTodo() |
1074 | { | 1090 | { |
1075 | if (mActiveItem) { | 1091 | if (mActiveItem) { |
1076 | emit unparentTodoSignal(mActiveItem->todo()); | 1092 | emit unparentTodoSignal(mActiveItem->todo()); |
1077 | } | 1093 | } |
1078 | } | 1094 | } |
1079 | 1095 | ||
1080 | void KOTodoView::reparentTodo() | 1096 | void KOTodoView::reparentTodo() |
1081 | { | 1097 | { |
1082 | if (mActiveItem) { | 1098 | if (mActiveItem) { |
1083 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1099 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1084 | pendingSubtodo = mActiveItem; | 1100 | pendingSubtodo = mActiveItem; |
1085 | } | 1101 | } |
1086 | } | 1102 | } |
1087 | void KOTodoView::editTodo() | 1103 | void KOTodoView::editTodo() |
1088 | { | 1104 | { |
1089 | if (mActiveItem) { | 1105 | if (mActiveItem) { |
1090 | emit editTodoSignal(mActiveItem->todo()); | 1106 | emit editTodoSignal(mActiveItem->todo()); |
1091 | } | 1107 | } |
1092 | } | 1108 | } |
1093 | void KOTodoView::cloneTodo() | 1109 | void KOTodoView::cloneTodo() |
1094 | { | 1110 | { |
1095 | if (mActiveItem) { | 1111 | if (mActiveItem) { |
1096 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1112 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1097 | } | 1113 | } |
1098 | } | 1114 | } |
1099 | void KOTodoView::cancelTodo() | 1115 | void KOTodoView::cancelTodo() |
1100 | { | 1116 | { |
1101 | if (mActiveItem) { | 1117 | if (mActiveItem) { |
1102 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1118 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1103 | } | 1119 | } |
1104 | } | 1120 | } |
@@ -1119,115 +1135,128 @@ void KOTodoView::beamTodo() | |||
1119 | void KOTodoView::showTodo() | 1135 | void KOTodoView::showTodo() |
1120 | { | 1136 | { |
1121 | if (mActiveItem) { | 1137 | if (mActiveItem) { |
1122 | emit showTodoSignal(mActiveItem->todo()); | 1138 | emit showTodoSignal(mActiveItem->todo()); |
1123 | } | 1139 | } |
1124 | } | 1140 | } |
1125 | 1141 | ||
1126 | void KOTodoView::deleteTodo() | 1142 | void KOTodoView::deleteTodo() |
1127 | { | 1143 | { |
1128 | if (mActiveItem) { | 1144 | if (mActiveItem) { |
1129 | emit deleteTodoSignal(mActiveItem->todo()); | 1145 | emit deleteTodoSignal(mActiveItem->todo()); |
1130 | } | 1146 | } |
1131 | } | 1147 | } |
1132 | 1148 | ||
1133 | void KOTodoView::setNewPriority(int index) | 1149 | void KOTodoView::setNewPriority(int index) |
1134 | { | 1150 | { |
1135 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1151 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1136 | mActiveItem->todo()->setPriority(mPriority[index]); | 1152 | mActiveItem->todo()->setPriority(mPriority[index]); |
1137 | mActiveItem->construct(); | 1153 | mActiveItem->construct(); |
1138 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1154 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1139 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1155 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1140 | } | 1156 | } |
1141 | } | 1157 | } |
1142 | 1158 | ||
1143 | void KOTodoView::setNewPercentage(int index) | 1159 | void KOTodoView::setNewPercentage(int index) |
1144 | { | 1160 | { |
1145 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1161 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1146 | 1162 | ||
1147 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1163 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1148 | mActiveItem->setOn( true ); | 1164 | mActiveItem->setOn( true ); |
1149 | return; | 1165 | return; |
1150 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1166 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1151 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1167 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1152 | if ( par && par->isOn() ) | 1168 | if ( par && par->isOn() ) |
1153 | par->setOn( false ); | 1169 | par->setOn( false ); |
1154 | } | 1170 | } |
1155 | if (mPercentage[index] == 100) { | 1171 | if (mPercentage[index] == 100) { |
1156 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1172 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1157 | } else { | 1173 | } else { |
1158 | mActiveItem->todo()->setCompleted(false); | 1174 | mActiveItem->todo()->setCompleted(false); |
1159 | } | 1175 | } |
1160 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1176 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1161 | mActiveItem->construct(); | 1177 | mActiveItem->construct(); |
1162 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1178 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1163 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1179 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1164 | } | 1180 | } |
1165 | } | 1181 | } |
1166 | 1182 | ||
1167 | 1183 | void KOTodoView::fillCategories () | |
1168 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | ||
1169 | { | 1184 | { |
1170 | if ( !mCategoryPopupMenu ) { | ||
1171 | mCategoryPopupMenu = new QPopupMenu (this); | ||
1172 | mCategoryPopupMenu->setCheckable (true); | ||
1173 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | ||
1174 | } | ||
1175 | mCategoryPopupMenu->clear(); | 1185 | mCategoryPopupMenu->clear(); |
1176 | QStringList checkedCategories = todoItem->todo()->categories (); | 1186 | if ( ! mActiveItem ) return; |
1177 | 1187 | QStringList checkedCategories = mActiveItem->todo()->categories (); | |
1178 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1188 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1179 | it != KOPrefs::instance()->mCustomCategories.end (); | 1189 | it != KOPrefs::instance()->mCustomCategories.end (); |
1180 | ++it) { | 1190 | ++it) { |
1181 | int index = mCategoryPopupMenu->insertItem (*it); | 1191 | int index = mCategoryPopupMenu->insertItem (*it); |
1182 | mCategory[index] = *it; | 1192 | mCategory[index] = *it; |
1183 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1193 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1184 | } | 1194 | } |
1185 | return mCategoryPopupMenu; | 1195 | } |
1196 | void KOTodoView::fillCal () | ||
1197 | { | ||
1198 | mCalPopupMenu->clear(); | ||
1199 | if (!mActiveItem) return; | ||
1200 | bool readO = mActiveItem->todo()->isReadOnly(); | ||
1201 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | ||
1202 | while ( kkf ) { | ||
1203 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); | ||
1204 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) | ||
1205 | mCalPopupMenu->setItemEnabled( index, false ); | ||
1206 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); | ||
1207 | kkf = KOPrefs::instance()->mCalendars.next(); | ||
1208 | } | ||
1209 | } | ||
1210 | void KOTodoView::changedCal (int index ) | ||
1211 | { | ||
1212 | if (!mActiveItem) return; | ||
1213 | mActiveItem->todo()->setCalID( index ); | ||
1214 | mActiveItem->construct(); | ||
1186 | } | 1215 | } |
1187 | void KOTodoView::changedCategories(int index) | 1216 | void KOTodoView::changedCategories(int index) |
1188 | { | 1217 | { |
1189 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1218 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1190 | QStringList categories = mActiveItem->todo()->categories (); | 1219 | QStringList categories = mActiveItem->todo()->categories (); |
1191 | QString colcat = categories.first(); | 1220 | QString colcat = categories.first(); |
1192 | if (categories.find (mCategory[index]) != categories.end ()) | 1221 | if (categories.find (mCategory[index]) != categories.end ()) |
1193 | categories.remove (mCategory[index]); | 1222 | categories.remove (mCategory[index]); |
1194 | else | 1223 | else |
1195 | categories.insert (categories.end(), mCategory[index]); | 1224 | categories.insert (categories.end(), mCategory[index]); |
1196 | categories.sort (); | 1225 | categories.sort (); |
1197 | if ( !colcat.isEmpty() ) { | 1226 | if ( !colcat.isEmpty() ) { |
1198 | if ( categories.find ( colcat ) != categories.end () ) { | 1227 | if ( categories.find ( colcat ) != categories.end () ) { |
1199 | categories.remove( colcat ); | 1228 | categories.remove( colcat ); |
1200 | categories.prepend( colcat ); | 1229 | categories.prepend( colcat ); |
1201 | } | 1230 | } |
1202 | } | 1231 | } |
1203 | mActiveItem->todo()->setCategories (categories); | 1232 | mActiveItem->todo()->setCategories (categories); |
1204 | mActiveItem->construct(); | 1233 | mActiveItem->construct(); |
1205 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1234 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1206 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1235 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1207 | } | 1236 | } |
1208 | } | 1237 | } |
1209 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1238 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1210 | { | 1239 | { |
1211 | if ( pendingSubtodo != 0 ) { | 1240 | if ( pendingSubtodo != 0 ) { |
1212 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1241 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1213 | } | 1242 | } |
1214 | pendingSubtodo = 0; | 1243 | pendingSubtodo = 0; |
1215 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1244 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1216 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1245 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1217 | //qDebug("ROW %d ", row); | 1246 | //qDebug("ROW %d ", row); |
1218 | if (!item) { | 1247 | if (!item) { |
1219 | newTodo(); | 1248 | newTodo(); |
1220 | return; | 1249 | return; |
1221 | } else { | 1250 | } else { |
1222 | if ( row == 1 ) { | 1251 | if ( row == 1 ) { |
1223 | mActiveItem = (KOTodoViewItem *) item; | 1252 | mActiveItem = (KOTodoViewItem *) item; |
1224 | newSubTodo(); | 1253 | newSubTodo(); |
1225 | return; | 1254 | return; |
1226 | } | 1255 | } |
1227 | if ( row == 5 || row == 6 || row == 2) { | 1256 | if ( row == 5 || row == 6 || row == 2) { |
1228 | mActiveItem = (KOTodoViewItem *) item; | 1257 | mActiveItem = (KOTodoViewItem *) item; |
1229 | Todo * t = mActiveItem->todo(); | 1258 | Todo * t = mActiveItem->todo(); |
1230 | if ( t->isRunning() ) { | 1259 | if ( t->isRunning() ) { |
1231 | if ( t->runTime() < 15) { | 1260 | if ( t->runTime() < 15) { |
1232 | t->stopRunning(); | 1261 | t->stopRunning(); |
1233 | mActiveItem->construct(); | 1262 | mActiveItem->construct(); |