-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 | |||
@@ -546,66 +546,80 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
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 ); |
@@ -1032,49 +1046,51 @@ void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | |||
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() |
@@ -1143,67 +1159,80 @@ void KOTodoView::setNewPriority(int index) | |||
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) |