-rw-r--r-- | korganizer/kotodoview.cpp | 78 |
1 files changed, 56 insertions, 22 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 9cafc60..5d7b066 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -327,16 +327,17 @@ void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | |||
327 | QLineEdit::focusOutEvent(ev); | 327 | QLineEdit::focusOutEvent(ev); |
328 | } | 328 | } |
329 | 329 | ||
330 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
331 | 331 | ||
332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
333 | KOrg::BaseView(calendar,parent,name) | 333 | KOrg::BaseView(calendar,parent,name) |
334 | { | 334 | { |
335 | mNavigator = 0; | ||
335 | QBoxLayout *topLayout = new QVBoxLayout(this); | 336 | QBoxLayout *topLayout = new QVBoxLayout(this); |
336 | mName = QString ( name ); | 337 | mName = QString ( name ); |
337 | mBlockUpdate = false; | 338 | mBlockUpdate = false; |
338 | mQuickAdd = new KOQuickTodo(this); | 339 | mQuickAdd = new KOQuickTodo(this); |
339 | topLayout->addWidget(mQuickAdd); | 340 | topLayout->addWidget(mQuickAdd); |
340 | 341 | ||
341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 342 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
342 | 343 | ||
@@ -347,21 +348,28 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
347 | mTodoListView->setAllColumnsShowFocus(true); | 348 | mTodoListView->setAllColumnsShowFocus(true); |
348 | 349 | ||
349 | mTodoListView->setShowSortIndicator(true); | 350 | mTodoListView->setShowSortIndicator(true); |
350 | 351 | ||
351 | mTodoListView->addColumn(i18n("Todo")); | 352 | mTodoListView->addColumn(i18n("Todo")); |
352 | mTodoListView->addColumn(i18n("Prio")); | 353 | mTodoListView->addColumn(i18n("Prio")); |
353 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 354 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
354 | mTodoListView->addColumn(i18n("Complete")); | 355 | mTodoListView->addColumn(i18n("Complete")); |
355 | mTodoListView->setColumnAlignment(2,AlignHCenter); | 356 | mTodoListView->setColumnAlignment(2,AlignCenter); |
357 | |||
356 | mTodoListView->addColumn(i18n("Due Date")); | 358 | mTodoListView->addColumn(i18n("Due Date")); |
357 | mTodoListView->setColumnAlignment(3,AlignLeft); | 359 | mTodoListView->setColumnAlignment(3,AlignLeft); |
358 | mTodoListView->addColumn(i18n("Due Time")); | 360 | mTodoListView->addColumn(i18n("Due Time")); |
359 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 361 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
362 | |||
363 | mTodoListView->addColumn(i18n("Start Date")); | ||
364 | mTodoListView->setColumnAlignment(5,AlignLeft); | ||
365 | mTodoListView->addColumn(i18n("Start Time")); | ||
366 | mTodoListView->setColumnAlignment(6,AlignHCenter); | ||
367 | |||
360 | mTodoListView->addColumn(i18n("Cancelled")); | 368 | mTodoListView->addColumn(i18n("Cancelled")); |
361 | mTodoListView->addColumn(i18n("Categories")); | 369 | mTodoListView->addColumn(i18n("Categories")); |
362 | #if 0 | 370 | #if 0 |
363 | mTodoListView->addColumn(i18n("Sort Id")); | 371 | mTodoListView->addColumn(i18n("Sort Id")); |
364 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 372 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
365 | #endif | 373 | #endif |
366 | 374 | ||
367 | mTodoListView->setMinimumHeight( 60 ); | 375 | mTodoListView->setMinimumHeight( 60 ); |
@@ -370,20 +378,19 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
370 | mTodoListView->setColumnWidth( 0, 120 ); | 378 | mTodoListView->setColumnWidth( 0, 120 ); |
371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 379 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 380 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 381 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 382 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 383 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 384 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
377 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 385 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
378 | mTodoListView->setColumnAlignment( 2, AlignCenter ); | 386 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
379 | #if 0 | 387 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
380 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 388 | |
381 | #endif | ||
382 | 389 | ||
383 | mPriorityPopupMenu = new QPopupMenu(this); | 390 | mPriorityPopupMenu = new QPopupMenu(this); |
384 | for (int i = 1; i <= 5; i++) { | 391 | for (int i = 1; i <= 5; i++) { |
385 | QString label = QString ("%1").arg (i); | 392 | QString label = QString ("%1").arg (i); |
386 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 393 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
387 | } | 394 | } |
388 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 395 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
389 | 396 | ||
@@ -423,30 +430,46 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
423 | SLOT (reparentTodo()),0,22); | 430 | SLOT (reparentTodo()),0,22); |
424 | mItemPopupMenu->insertSeparator(); | 431 | mItemPopupMenu->insertSeparator(); |
425 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 432 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
426 | this, SLOT( purgeCompleted() ) ); | 433 | this, SLOT( purgeCompleted() ) ); |
427 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 434 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
428 | this, SLOT( toggleCompleted() ),0, 33 ); | 435 | this, SLOT( toggleCompleted() ),0, 33 ); |
429 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 436 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
430 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 437 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
438 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | ||
439 | this, SLOT( toggleRunning() ),0, 35 ); | ||
431 | 440 | ||
432 | mPopupMenu = new QPopupMenu(this); | 441 | mPopupMenu = new QPopupMenu(this); |
433 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 442 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
434 | SLOT (newTodo()),0,1); | 443 | SLOT (newTodo()),0,1); |
435 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 444 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
436 | this, SLOT(purgeCompleted()),0,2); | 445 | this, SLOT(purgeCompleted()),0,2); |
437 | mPopupMenu->insertItem(i18n("Show Completed"), | 446 | mPopupMenu->insertItem(i18n("Show Completed"), |
438 | this, SLOT( toggleCompleted() ),0,3 ); | 447 | this, SLOT( toggleCompleted() ),0,3 ); |
439 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 448 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
440 | this, SLOT( toggleQuickTodo() ),0,4 ); | 449 | this, SLOT( toggleQuickTodo() ),0,4 ); |
450 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | ||
451 | this, SLOT( toggleRunning() ),0,5 ); | ||
441 | mDocPrefs = new DocPrefs( name ); | 452 | mDocPrefs = new DocPrefs( name ); |
442 | 453 | ||
443 | mPopupMenu->setCheckable( true ); | 454 | mPopupMenu->setCheckable( true ); |
444 | mItemPopupMenu->setCheckable( true ); | 455 | mItemPopupMenu->setCheckable( true ); |
456 | |||
457 | |||
458 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | ||
459 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | ||
460 | |||
461 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | ||
462 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | ||
463 | |||
464 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | ||
465 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | ||
466 | |||
467 | |||
445 | // Double clicking conflicts with opening/closing the subtree | 468 | // Double clicking conflicts with opening/closing the subtree |
446 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 469 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
447 | SLOT( editItem( QListViewItem *) ) ); | 470 | SLOT( editItem( QListViewItem *) ) ); |
448 | /* | 471 | /* |
449 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 472 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
450 | const QPoint &,int ) ), | 473 | const QPoint &,int ) ), |
451 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 474 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
452 | */ | 475 | */ |
@@ -471,47 +494,32 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
471 | SLOT(selectionChanged(QListViewItem *))); | 494 | SLOT(selectionChanged(QListViewItem *))); |
472 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 495 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
473 | SLOT(selectionChanged(QListViewItem *))); | 496 | SLOT(selectionChanged(QListViewItem *))); |
474 | #endif | 497 | #endif |
475 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 498 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
476 | SLOT( processSelectionChange() ) ); | 499 | SLOT( processSelectionChange() ) ); |
477 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 500 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
478 | SLOT( addQuickTodo() ) ); | 501 | SLOT( addQuickTodo() ) ); |
479 | // if ( QApplication::desktop()->width() < 480 ) { | ||
480 | // setNarrow(); | ||
481 | // mTodoListView->setColumnWidth( 0, 100 ); | ||
482 | |||
483 | // } | ||
484 | 502 | ||
485 | } | 503 | } |
486 | 504 | ||
487 | KOTodoView::~KOTodoView() | 505 | KOTodoView::~KOTodoView() |
488 | { | 506 | { |
489 | delete mDocPrefs; | 507 | delete mDocPrefs; |
490 | } | 508 | } |
491 | 509 | ||
492 | void KOTodoView::jumpToDate () | 510 | void KOTodoView::jumpToDate () |
493 | { | 511 | { |
494 | // if (mActiveItem) { | 512 | // if (mActiveItem) { |
495 | // mActiveItem->todo()); | 513 | // mActiveItem->todo()); |
496 | // if ( mActiveItem->todo()->hasDueDate() ) | 514 | // if ( mActiveItem->todo()->hasDueDate() ) |
497 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 515 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
498 | } | 516 | } |
499 | 517 | ||
500 | void KOTodoView::setNarrow() | ||
501 | { | ||
502 | //mTodoListView->setColumnWidth( 0, 120 ); | ||
503 | mTodoListView->setColumnWidth( 1, 35 ); | ||
504 | mTodoListView->setColumnWidth( 2, 40 ); | ||
505 | mTodoListView->setColumnWidth( 3, 80 ); | ||
506 | mTodoListView->setColumnWidth( 4, 40 ); | ||
507 | mTodoListView->setColumnWidth( 5, 90 ); | ||
508 | |||
509 | } | ||
510 | void KOTodoView::updateView() | 518 | void KOTodoView::updateView() |
511 | { | 519 | { |
512 | pendingSubtodo = 0; | 520 | pendingSubtodo = 0; |
513 | if ( mBlockUpdate ) { | 521 | if ( mBlockUpdate ) { |
514 | //qDebug("blocked "); | 522 | //qDebug("blocked "); |
515 | return; | 523 | return; |
516 | } | 524 | } |
517 | //qDebug("update "); | 525 | //qDebug("update "); |
@@ -582,45 +590,62 @@ void KOTodoView::updateView() | |||
582 | } | 590 | } |
583 | // qDebug("again .... "); | 591 | // qDebug("again .... "); |
584 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 592 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
585 | 593 | ||
586 | // qDebug("yytodo %s ", todo->summary().latin1()); | 594 | // qDebug("yytodo %s ", todo->summary().latin1()); |
587 | // } | 595 | // } |
588 | //qDebug("for "); | 596 | //qDebug("for "); |
589 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 597 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
590 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) | 598 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
591 | { | 599 | { |
592 | insertTodoItem(todo); | 600 | insertTodoItem(todo); |
593 | } | 601 | } |
594 | } | 602 | } |
595 | //qDebug("for end "); | 603 | //qDebug("for end "); |
596 | // Restore opened/closed state | 604 | // Restore opened/closed state |
597 | mTodoListView->blockSignals( true ); | 605 | mTodoListView->blockSignals( true ); |
598 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 606 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
599 | mTodoListView->blockSignals( false ); | 607 | mTodoListView->blockSignals( false ); |
600 | mTodoListView->setFocus(); | 608 | mTodoListView->setFocus(); |
601 | processSelectionChange(); | 609 | processSelectionChange(); |
602 | } | 610 | } |
603 | 611 | ||
612 | bool KOTodoView::checkTodo( Todo * todo ) | ||
613 | { | ||
614 | |||
615 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | ||
616 | return false; | ||
617 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | ||
618 | if ( todo->hasStartDate() ) | ||
619 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | ||
620 | return false; | ||
621 | if ( todo->hasDueDate() ) | ||
622 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | ||
623 | return false; | ||
624 | } | ||
625 | return true; | ||
626 | } | ||
627 | |||
604 | void KOTodoView::restoreItemState( QListViewItem *item ) | 628 | void KOTodoView::restoreItemState( QListViewItem *item ) |
605 | { | 629 | { |
606 | pendingSubtodo = 0; | 630 | pendingSubtodo = 0; |
607 | while( item ) { | 631 | while( item ) { |
608 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 632 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
609 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 633 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
610 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 634 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
611 | item = item->nextSibling(); | 635 | item = item->nextSibling(); |
612 | } | 636 | } |
613 | } | 637 | } |
614 | 638 | ||
615 | 639 | ||
616 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 640 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
617 | KOTodoView::insertTodoItem(Todo *todo) | 641 | KOTodoView::insertTodoItem(Todo *todo) |
618 | { | 642 | { |
643 | |||
619 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 644 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
620 | // TODO: Check, if dynmaic cast is necessary | 645 | // TODO: Check, if dynmaic cast is necessary |
621 | 646 | ||
622 | pendingSubtodo = 0; | 647 | pendingSubtodo = 0; |
623 | Incidence *incidence = todo->relatedTo(); | 648 | Incidence *incidence = todo->relatedTo(); |
624 | if (incidence && incidence->type() == "Todo") { | 649 | if (incidence && incidence->type() == "Todo") { |
625 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 650 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
626 | 651 | ||
@@ -713,17 +738,17 @@ void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | |||
713 | switch (column){ | 738 | switch (column){ |
714 | case 1: | 739 | case 1: |
715 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 740 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
716 | case 2: | 741 | case 2: |
717 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 742 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
718 | case 3: | 743 | case 3: |
719 | moveTodo(); | 744 | moveTodo(); |
720 | break; | 745 | break; |
721 | case 6: | 746 | case 8: |
722 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 747 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
723 | default: | 748 | default: |
724 | mItemPopupMenu->popup(QCursor::pos()); | 749 | mItemPopupMenu->popup(QCursor::pos()); |
725 | } | 750 | } |
726 | } else mPopupMenu->popup(QCursor::pos()); | 751 | } else mPopupMenu->popup(QCursor::pos()); |
727 | } | 752 | } |
728 | void KOTodoView::newTodo() | 753 | void KOTodoView::newTodo() |
729 | { | 754 | { |
@@ -990,16 +1015,25 @@ void KOTodoView::toggleQuickTodo() | |||
990 | } | 1015 | } |
991 | else { | 1016 | else { |
992 | mQuickAdd->show(); | 1017 | mQuickAdd->show(); |
993 | KOPrefs::instance()->mEnableQuickTodo = true; | 1018 | KOPrefs::instance()->mEnableQuickTodo = true; |
994 | } | 1019 | } |
995 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1020 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
996 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1021 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
997 | } | 1022 | } |
1023 | |||
1024 | void KOTodoView::toggleRunning() | ||
1025 | { | ||
1026 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | ||
1027 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | ||
1028 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | ||
1029 | updateView(); | ||
1030 | } | ||
1031 | |||
998 | void KOTodoView::toggleCompleted() | 1032 | void KOTodoView::toggleCompleted() |
999 | { | 1033 | { |
1000 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1034 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1001 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1035 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1002 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1036 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1003 | updateView(); | 1037 | updateView(); |
1004 | } | 1038 | } |
1005 | 1039 | ||