-rw-r--r-- | korganizer/kotodoview.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1bfdef9..873a776 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -452,96 +452,97 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | |||
452 | e->ignore(); | 452 | e->ignore(); |
453 | } | 453 | } |
454 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 454 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
455 | { | 455 | { |
456 | QListView::contentsMouseReleaseEvent(e); | 456 | QListView::contentsMouseReleaseEvent(e); |
457 | mMousePressed = false; | 457 | mMousePressed = false; |
458 | } | 458 | } |
459 | 459 | ||
460 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | if (!e) return; | 462 | if (!e) return; |
463 | 463 | ||
464 | QPoint vp = contentsToViewport(e->pos()); | 464 | QPoint vp = contentsToViewport(e->pos()); |
465 | 465 | ||
466 | QListViewItem *item = itemAt(vp); | 466 | QListViewItem *item = itemAt(vp); |
467 | 467 | ||
468 | emit double_Clicked(item); | 468 | emit double_Clicked(item); |
469 | if (!item) return; | 469 | if (!item) return; |
470 | 470 | ||
471 | emit doubleClicked(item,vp,0); | 471 | emit doubleClicked(item,vp,0); |
472 | } | 472 | } |
473 | 473 | ||
474 | ///////////////////////////////////////////////////////////////////////////// | 474 | ///////////////////////////////////////////////////////////////////////////// |
475 | 475 | ||
476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
477 | QLineEdit(parent) | 477 | QLineEdit(parent) |
478 | { | 478 | { |
479 | setText(i18n("Click to add a new Todo")); | 479 | setText(i18n("Click to add a new Todo")); |
480 | } | 480 | } |
481 | 481 | ||
482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
483 | { | 483 | { |
484 | if ( text()==i18n("Click to add a new Todo") ) | 484 | if ( text()==i18n("Click to add a new Todo") ) |
485 | setText(""); | 485 | setText(""); |
486 | QLineEdit::focusInEvent(ev); | 486 | QLineEdit::focusInEvent(ev); |
487 | } | 487 | } |
488 | 488 | ||
489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
490 | { | 490 | { |
491 | setText(i18n("Click to add a new Todo")); | 491 | setText(i18n("Click to add a new Todo")); |
492 | QLineEdit::focusOutEvent(ev); | 492 | QLineEdit::focusOutEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | ///////////////////////////////////////////////////////////////////////////// | 495 | ///////////////////////////////////////////////////////////////////////////// |
496 | 496 | ||
497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
498 | KOrg::BaseView(calendar,parent,name) | 498 | KOrg::BaseView(calendar,parent,name) |
499 | { | 499 | { |
500 | mCategoryPopupMenu = 0; | ||
500 | mPendingUpdateBeforeRepaint = false; | 501 | mPendingUpdateBeforeRepaint = false; |
501 | isFlatDisplay = false; | 502 | isFlatDisplay = false; |
502 | mNavigator = 0; | 503 | mNavigator = 0; |
503 | QBoxLayout *topLayout = new QVBoxLayout(this); | 504 | QBoxLayout *topLayout = new QVBoxLayout(this); |
504 | mName = QString ( name ); | 505 | mName = QString ( name ); |
505 | mBlockUpdate = false; | 506 | mBlockUpdate = false; |
506 | mQuickAdd = new KOQuickTodo(this); | 507 | mQuickAdd = new KOQuickTodo(this); |
507 | topLayout->addWidget(mQuickAdd); | 508 | topLayout->addWidget(mQuickAdd); |
508 | 509 | ||
509 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 510 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
510 | 511 | ||
511 | mTodoListView = new KOTodoListView(calendar,this, name ); | 512 | mTodoListView = new KOTodoListView(calendar,this, name ); |
512 | topLayout->addWidget(mTodoListView); | 513 | topLayout->addWidget(mTodoListView); |
513 | //mTodoListView->header()->setMaximumHeight(30); | 514 | //mTodoListView->header()->setMaximumHeight(30); |
514 | mTodoListView->setRootIsDecorated(true); | 515 | mTodoListView->setRootIsDecorated(true); |
515 | mTodoListView->setAllColumnsShowFocus(true); | 516 | mTodoListView->setAllColumnsShowFocus(true); |
516 | 517 | ||
517 | mTodoListView->setShowSortIndicator(true); | 518 | mTodoListView->setShowSortIndicator(true); |
518 | 519 | ||
519 | mTodoListView->addColumn(i18n("Todo")); | 520 | mTodoListView->addColumn(i18n("Todo")); |
520 | mTodoListView->addColumn(i18n("Prio")); | 521 | mTodoListView->addColumn(i18n("Prio")); |
521 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 522 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
522 | mTodoListView->addColumn(i18n("Complete")); | 523 | mTodoListView->addColumn(i18n("Complete")); |
523 | mTodoListView->setColumnAlignment(2,AlignCenter); | 524 | mTodoListView->setColumnAlignment(2,AlignCenter); |
524 | 525 | ||
525 | mTodoListView->addColumn(i18n("Due Date")); | 526 | mTodoListView->addColumn(i18n("Due Date")); |
526 | mTodoListView->setColumnAlignment(3,AlignLeft); | 527 | mTodoListView->setColumnAlignment(3,AlignLeft); |
527 | mTodoListView->addColumn(i18n("Due Time")); | 528 | mTodoListView->addColumn(i18n("Due Time")); |
528 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 529 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
529 | 530 | ||
530 | mTodoListView->addColumn(i18n("Start Date")); | 531 | mTodoListView->addColumn(i18n("Start Date")); |
531 | mTodoListView->setColumnAlignment(5,AlignLeft); | 532 | mTodoListView->setColumnAlignment(5,AlignLeft); |
532 | mTodoListView->addColumn(i18n("Start Time")); | 533 | mTodoListView->addColumn(i18n("Start Time")); |
533 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 534 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
534 | 535 | ||
535 | mTodoListView->addColumn(i18n("Cancelled")); | 536 | mTodoListView->addColumn(i18n("Cancelled")); |
536 | mTodoListView->addColumn(i18n("Categories")); | 537 | mTodoListView->addColumn(i18n("Categories")); |
537 | mTodoListView->addColumn(i18n("Calendar")); | 538 | mTodoListView->addColumn(i18n("Calendar")); |
538 | #if 0 | 539 | #if 0 |
539 | mTodoListView->addColumn(i18n("Sort Id")); | 540 | mTodoListView->addColumn(i18n("Sort Id")); |
540 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 541 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
541 | #endif | 542 | #endif |
542 | 543 | ||
543 | mTodoListView->setMinimumHeight( 60 ); | 544 | mTodoListView->setMinimumHeight( 60 ); |
544 | mTodoListView->setItemsRenameable( true ); | 545 | mTodoListView->setItemsRenameable( true ); |
545 | mTodoListView->setRenameable( 0 ); | 546 | mTodoListView->setRenameable( 0 ); |
546 | mTodoListView->setColumnWidth( 0, 120 ); | 547 | mTodoListView->setColumnWidth( 0, 120 ); |
547 | int iii = 0; | 548 | int iii = 0; |
@@ -1113,112 +1114,112 @@ void KOTodoView::showTodo() | |||
1113 | emit showTodoSignal(mActiveItem->todo()); | 1114 | emit showTodoSignal(mActiveItem->todo()); |
1114 | } | 1115 | } |
1115 | } | 1116 | } |
1116 | 1117 | ||
1117 | void KOTodoView::deleteTodo() | 1118 | void KOTodoView::deleteTodo() |
1118 | { | 1119 | { |
1119 | if (mActiveItem) { | 1120 | if (mActiveItem) { |
1120 | emit deleteTodoSignal(mActiveItem->todo()); | 1121 | emit deleteTodoSignal(mActiveItem->todo()); |
1121 | } | 1122 | } |
1122 | } | 1123 | } |
1123 | 1124 | ||
1124 | void KOTodoView::setNewPriority(int index) | 1125 | void KOTodoView::setNewPriority(int index) |
1125 | { | 1126 | { |
1126 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1127 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1127 | mActiveItem->todo()->setPriority(mPriority[index]); | 1128 | mActiveItem->todo()->setPriority(mPriority[index]); |
1128 | mActiveItem->construct(); | 1129 | mActiveItem->construct(); |
1129 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1130 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1130 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1131 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1131 | } | 1132 | } |
1132 | } | 1133 | } |
1133 | 1134 | ||
1134 | void KOTodoView::setNewPercentage(int index) | 1135 | void KOTodoView::setNewPercentage(int index) |
1135 | { | 1136 | { |
1136 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1137 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1137 | 1138 | ||
1138 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1139 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1139 | mActiveItem->setOn( true ); | 1140 | mActiveItem->setOn( true ); |
1140 | return; | 1141 | return; |
1141 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1142 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1142 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1143 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1143 | if ( par && par->isOn() ) | 1144 | if ( par && par->isOn() ) |
1144 | par->setOn( false ); | 1145 | par->setOn( false ); |
1145 | } | 1146 | } |
1146 | if (mPercentage[index] == 100) { | 1147 | if (mPercentage[index] == 100) { |
1147 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1148 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1148 | } else { | 1149 | } else { |
1149 | mActiveItem->todo()->setCompleted(false); | 1150 | mActiveItem->todo()->setCompleted(false); |
1150 | } | 1151 | } |
1151 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1152 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1152 | mActiveItem->construct(); | 1153 | mActiveItem->construct(); |
1153 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1154 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1154 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1155 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1155 | } | 1156 | } |
1156 | } | 1157 | } |
1157 | 1158 | ||
1158 | 1159 | ||
1159 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1160 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1160 | { | 1161 | { |
1161 | QPopupMenu* tempMenu = new QPopupMenu (this); | 1162 | if ( !mCategoryPopupMenu ) { |
1162 | QStringList checkedCategories = todoItem->todo()->categories (); | 1163 | mCategoryPopupMenu = new QPopupMenu (this); |
1163 | 1164 | mCategoryPopupMenu->setCheckable (true); | |
1164 | tempMenu->setCheckable (true); | 1165 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1165 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1166 | } |
1166 | it != KOPrefs::instance()->mCustomCategories.end (); | 1167 | mCategoryPopupMenu->clear(); |
1167 | ++it) { | 1168 | QStringList checkedCategories = todoItem->todo()->categories (); |
1168 | int index = tempMenu->insertItem (*it); | 1169 | |
1169 | mCategory[index] = *it; | 1170 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1170 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 1171 | it != KOPrefs::instance()->mCustomCategories.end (); |
1171 | } | 1172 | ++it) { |
1172 | 1173 | int index = mCategoryPopupMenu->insertItem (*it); | |
1173 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1174 | mCategory[index] = *it; |
1174 | return tempMenu; | 1175 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1175 | 1176 | } | |
1176 | 1177 | return mCategoryPopupMenu; | |
1177 | } | 1178 | } |
1178 | void KOTodoView::changedCategories(int index) | 1179 | void KOTodoView::changedCategories(int index) |
1179 | { | 1180 | { |
1180 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1181 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1181 | QStringList categories = mActiveItem->todo()->categories (); | 1182 | QStringList categories = mActiveItem->todo()->categories (); |
1182 | QString colcat = categories.first(); | 1183 | QString colcat = categories.first(); |
1183 | if (categories.find (mCategory[index]) != categories.end ()) | 1184 | if (categories.find (mCategory[index]) != categories.end ()) |
1184 | categories.remove (mCategory[index]); | 1185 | categories.remove (mCategory[index]); |
1185 | else | 1186 | else |
1186 | categories.insert (categories.end(), mCategory[index]); | 1187 | categories.insert (categories.end(), mCategory[index]); |
1187 | categories.sort (); | 1188 | categories.sort (); |
1188 | if ( !colcat.isEmpty() ) { | 1189 | if ( !colcat.isEmpty() ) { |
1189 | if ( categories.find ( colcat ) != categories.end () ) { | 1190 | if ( categories.find ( colcat ) != categories.end () ) { |
1190 | categories.remove( colcat ); | 1191 | categories.remove( colcat ); |
1191 | categories.prepend( colcat ); | 1192 | categories.prepend( colcat ); |
1192 | } | 1193 | } |
1193 | } | 1194 | } |
1194 | mActiveItem->todo()->setCategories (categories); | 1195 | mActiveItem->todo()->setCategories (categories); |
1195 | mActiveItem->construct(); | 1196 | mActiveItem->construct(); |
1196 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1197 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1197 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1198 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1198 | } | 1199 | } |
1199 | } | 1200 | } |
1200 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1201 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1201 | { | 1202 | { |
1202 | if ( pendingSubtodo != 0 ) { | 1203 | if ( pendingSubtodo != 0 ) { |
1203 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1204 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1204 | } | 1205 | } |
1205 | pendingSubtodo = 0; | 1206 | pendingSubtodo = 0; |
1206 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1207 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1207 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1208 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1208 | //qDebug("ROW %d ", row); | 1209 | //qDebug("ROW %d ", row); |
1209 | if (!item) { | 1210 | if (!item) { |
1210 | newTodo(); | 1211 | newTodo(); |
1211 | return; | 1212 | return; |
1212 | } else { | 1213 | } else { |
1213 | if ( row == 1 ) { | 1214 | if ( row == 1 ) { |
1214 | mActiveItem = (KOTodoViewItem *) item; | 1215 | mActiveItem = (KOTodoViewItem *) item; |
1215 | newSubTodo(); | 1216 | newSubTodo(); |
1216 | return; | 1217 | return; |
1217 | } | 1218 | } |
1218 | if ( row == 5 || row == 6 || row == 2) { | 1219 | if ( row == 5 || row == 6 || row == 2) { |
1219 | mActiveItem = (KOTodoViewItem *) item; | 1220 | mActiveItem = (KOTodoViewItem *) item; |
1220 | Todo * t = mActiveItem->todo(); | 1221 | Todo * t = mActiveItem->todo(); |
1221 | if ( t->isRunning() ) { | 1222 | if ( t->isRunning() ) { |
1222 | if ( t->runTime() < 15) { | 1223 | if ( t->runTime() < 15) { |
1223 | t->stopRunning(); | 1224 | t->stopRunning(); |
1224 | mActiveItem->construct(); | 1225 | mActiveItem->construct(); |