summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index c5b9a21..03a8f1c 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -438,512 +438,516 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
438 SLOT (editTodo())); 438 SLOT (editTodo()));
439 mItemPopupMenu->insertItem( i18n("Delete"), this, 439 mItemPopupMenu->insertItem( i18n("Delete"), this,
440 SLOT (deleteTodo())); 440 SLOT (deleteTodo()));
441 mItemPopupMenu->insertItem( i18n("Clone..."), this, 441 mItemPopupMenu->insertItem( i18n("Clone..."), this,
442 SLOT (cloneTodo())); 442 SLOT (cloneTodo()));
443 mItemPopupMenu->insertItem( i18n("Move..."), this, 443 mItemPopupMenu->insertItem( i18n("Move..."), this,
444 SLOT (moveTodo())); 444 SLOT (moveTodo()));
445 mItemPopupMenu->insertItem( i18n("Beam..."), this, 445 mItemPopupMenu->insertItem( i18n("Beam..."), this,
446 SLOT (beamTodo())); 446 SLOT (beamTodo()));
447 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 447 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
448 SLOT (cancelTodo())); 448 SLOT (cancelTodo()));
449 mItemPopupMenu->insertSeparator(); 449 mItemPopupMenu->insertSeparator();
450 450
451 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 451 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
452 SLOT (newTodo())); 452 SLOT (newTodo()));
453 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 453 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
454 SLOT (newSubTodo())); 454 SLOT (newSubTodo()));
455 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 455 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
456 SLOT (unparentTodo()),0,21); 456 SLOT (unparentTodo()),0,21);
457 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 457 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
458 SLOT (reparentTodo()),0,22); 458 SLOT (reparentTodo()),0,22);
459 mItemPopupMenu->insertSeparator(); 459 mItemPopupMenu->insertSeparator();
460#if 0 460#if 0
461 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 461 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
462 this, SLOT( purgeCompleted() ) ); 462 this, SLOT( purgeCompleted() ) );
463 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 463 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
464 this, SLOT( toggleCompleted() ),0, 33 ); 464 this, SLOT( toggleCompleted() ),0, 33 );
465 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 465 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
466 this, SLOT( toggleQuickTodo() ),0, 34 ); 466 this, SLOT( toggleQuickTodo() ),0, 34 );
467 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 467 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
468 this, SLOT( toggleRunning() ),0, 35 ); 468 this, SLOT( toggleRunning() ),0, 35 );
469 469
470#endif 470#endif
471 mPopupMenu = new QPopupMenu(this); 471 mPopupMenu = new QPopupMenu(this);
472 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 472 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
473 SLOT (newTodo()),0,1); 473 SLOT (newTodo()),0,1);
474 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 474 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
475 this, SLOT(purgeCompleted()),0,2); 475 this, SLOT(purgeCompleted()),0,2);
476 mPopupMenu->insertItem(i18n("Show Completed"), 476 mPopupMenu->insertItem(i18n("Show Completed"),
477 this, SLOT( toggleCompleted() ),0,3 ); 477 this, SLOT( toggleCompleted() ),0,3 );
478 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 478 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
479 this, SLOT( toggleQuickTodo() ),0,4 ); 479 this, SLOT( toggleQuickTodo() ),0,4 );
480 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 480 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
481 this, SLOT( toggleRunning() ),0,5 ); 481 this, SLOT( toggleRunning() ),0,5 );
482 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 482 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
483 this, SLOT( setAllOpen() ),0,6 ); 483 this, SLOT( setAllOpen() ),0,6 );
484 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 484 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
485 this, SLOT( setAllClose() ),0,7 ); 485 this, SLOT( setAllClose() ),0,7 );
486 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 486 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
487 this, SLOT( setAllFlat() ),0,8 ); 487 this, SLOT( setAllFlat() ),0,8 );
488 mDocPrefs = new DocPrefs( name ); 488 mDocPrefs = new DocPrefs( name );
489 489
490 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 490 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
491 mPopupMenu->setCheckable( true ); 491 mPopupMenu->setCheckable( true );
492 mItemPopupMenu->setCheckable( true ); 492 mItemPopupMenu->setCheckable( true );
493 493
494 494
495 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 495 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
496 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 496 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
497 497
498 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 498 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
499 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 499 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
500 500
501 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 501 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
502 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 502 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
503 503
504 504
505 // Double clicking conflicts with opening/closing the subtree 505 // Double clicking conflicts with opening/closing the subtree
506 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 506 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
507 SLOT( editItem( QListViewItem *) ) ); 507 SLOT( editItem( QListViewItem *) ) );
508 /* 508 /*
509 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 509 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
510 const QPoint &,int ) ), 510 const QPoint &,int ) ),
511 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 511 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
512 */ 512 */
513 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 513 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
514 const QPoint &,int ) ), 514 const QPoint &,int ) ),
515 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 515 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
516 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 516 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
517 SLOT( itemClicked( QListViewItem * ) ) ); 517 SLOT( itemClicked( QListViewItem * ) ) );
518 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 518 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
519 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 519 SLOT( itemDoubleClicked( QListViewItem * ) ) );
520 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 520 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
521 SLOT( updateView() ) ); 521 SLOT( updateView() ) );
522 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 522 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
523 SLOT( todoModified(Todo *, int) ) ); 523 SLOT( todoModified(Todo *, int) ) );
524 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 524 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
525 SLOT( itemStateChanged( QListViewItem * ) ) ); 525 SLOT( itemStateChanged( QListViewItem * ) ) );
526 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 526 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
527 SLOT( itemStateChanged( QListViewItem * ) ) ); 527 SLOT( itemStateChanged( QListViewItem * ) ) );
528 connect( mTodoListView, SIGNAL( paintNeeded() ), 528 connect( mTodoListView, SIGNAL( paintNeeded() ),
529 SLOT( paintNeeded()) ); 529 SLOT( paintNeeded()) );
530 530
531#if 0 531#if 0
532 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 532 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
533 SLOT(selectionChanged(QListViewItem *))); 533 SLOT(selectionChanged(QListViewItem *)));
534 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 534 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
535 SLOT(selectionChanged(QListViewItem *))); 535 SLOT(selectionChanged(QListViewItem *)));
536 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 536 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
537 SLOT(selectionChanged(QListViewItem *))); 537 SLOT(selectionChanged(QListViewItem *)));
538#endif 538#endif
539 539
540 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 540 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
541 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 541 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
542 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 542 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
543 543
544 connect( mTodoListView, SIGNAL(selectionChanged() ), 544 connect( mTodoListView, SIGNAL(selectionChanged() ),
545 SLOT( processSelectionChange() ) ); 545 SLOT( processSelectionChange() ) );
546 connect( mQuickAdd, SIGNAL( returnPressed () ), 546 connect( mQuickAdd, SIGNAL( returnPressed () ),
547 SLOT( addQuickTodo() ) ); 547 SLOT( addQuickTodo() ) );
548 548
549} 549}
550 550
551KOTodoView::~KOTodoView() 551KOTodoView::~KOTodoView()
552{ 552{
553 delete mDocPrefs; 553 delete mDocPrefs;
554} 554}
555QString KOTodoView::getWhatsThisText(QPoint p) 555QString KOTodoView::getWhatsThisText(QPoint p)
556{ 556{
557 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 557 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
558 if ( item ) 558 if ( item )
559 return KIncidenceFormatter::instance()->getFormattedText( item->todo() ); 559 return KIncidenceFormatter::instance()->getFormattedText( item->todo() );
560 return i18n("That is the todo view" ); 560 return i18n("That is the todo view" );
561 561
562} 562}
563 563
564void KOTodoView::jumpToDate () 564void KOTodoView::jumpToDate ()
565{ 565{
566 // if (mActiveItem) { 566 // if (mActiveItem) {
567// mActiveItem->todo()); 567// mActiveItem->todo());
568// if ( mActiveItem->todo()->hasDueDate() ) 568// if ( mActiveItem->todo()->hasDueDate() )
569// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 569// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
570} 570}
571void KOTodoView::paintNeeded() 571void KOTodoView::paintNeeded()
572{ 572{
573 if ( mPendingUpdateBeforeRepaint ) { 573 if ( mPendingUpdateBeforeRepaint ) {
574 updateView(); 574 updateView();
575 mPendingUpdateBeforeRepaint = false; 575 mPendingUpdateBeforeRepaint = false;
576 } 576 }
577} 577}
578void KOTodoView::paintEvent(QPaintEvent * pevent) 578void KOTodoView::paintEvent(QPaintEvent * pevent)
579{ 579{
580 if ( mPendingUpdateBeforeRepaint ) { 580 if ( mPendingUpdateBeforeRepaint ) {
581 updateView(); 581 updateView();
582 mPendingUpdateBeforeRepaint = false; 582 mPendingUpdateBeforeRepaint = false;
583 } 583 }
584 KOrg::BaseView::paintEvent( pevent); 584 KOrg::BaseView::paintEvent( pevent);
585} 585}
586 586
587void KOTodoView::updateView() 587void KOTodoView::updateView()
588{ 588{
589 pendingSubtodo = 0; 589 pendingSubtodo = 0;
590 if ( mBlockUpdate ) { 590 if ( mBlockUpdate ) {
591 return; 591 return;
592 } 592 }
593 if ( !isVisible() ) { 593 if ( !isVisible() ) {
594 mPendingUpdateBeforeRepaint = true; 594 mPendingUpdateBeforeRepaint = true;
595 return; 595 return;
596 } 596 }
597 //qDebug("KOTodoView::updateView() %x", this); 597 //qDebug("KOTodoView::updateView() %x", this);
598 if ( isFlatDisplay ) { 598 if ( isFlatDisplay ) {
599 setAllFlat(); 599 setAllFlat();
600 return; 600 return;
601 } 601 }
602 //qDebug("update "); 602 //qDebug("update ");
603// kdDebug() << "KOTodoView::updateView()" << endl; 603// kdDebug() << "KOTodoView::updateView()" << endl;
604 QFont fo = KOPrefs::instance()->mTodoViewFont; 604 QFont fo = KOPrefs::instance()->mTodoViewFont;
605 mTodoListView->clear(); 605 mTodoListView->clear();
606 if ( mName == "todolistsmall" ) { 606 if ( mName == "todolistsmall" ) {
607 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 607 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
608 int ps = fo.pointSize() -2; 608 int ps = fo.pointSize() -2;
609 if ( ps > 12 ) 609 if ( ps > 12 )
610 ps -= 2; 610 ps -= 2;
611 fo.setPointSize( ps ); 611 fo.setPointSize( ps );
612 } 612 }
613 } 613 }
614 614
615 mTodoListView->setFont( fo ); 615 mTodoListView->setFont( fo );
616 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 616 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
617 //mTodoListView->header()->setMaximumHeight(fm.height()); 617 //mTodoListView->header()->setMaximumHeight(fm.height());
618 QPtrList<Todo> todoList = calendar()->todos(); 618 QPtrList<Todo> todoList = calendar()->todos();
619 619
620/* 620/*
621 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 621 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
622 Event *t; 622 Event *t;
623 for(t = todoList.first(); t; t = todoList.next()) { 623 for(t = todoList.first(); t; t = todoList.next()) {
624 kdDebug() << " " << t->getSummary() << endl; 624 kdDebug() << " " << t->getSummary() << endl;
625 625
626 if (t->getRelatedTo()) { 626 if (t->getRelatedTo()) {
627 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 627 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
628 } 628 }
629 629
630 QPtrList<Event> l = t->getRelations(); 630 QPtrList<Event> l = t->getRelations();
631 Event *c; 631 Event *c;
632 for(c=l.first();c;c=l.next()) { 632 for(c=l.first();c;c=l.next()) {
633 kdDebug() << " - relation: " << c->getSummary() << endl; 633 kdDebug() << " - relation: " << c->getSummary() << endl;
634 } 634 }
635 } 635 }
636*/ 636*/
637 637
638 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 638 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
639 // specific order of events. That means that we have to generate parent items 639 // specific order of events. That means that we have to generate parent items
640 // recursively for proper hierarchical display of Todos. 640 // recursively for proper hierarchical display of Todos.
641 mTodoMap.clear(); 641 mTodoMap.clear();
642 Todo *todo; 642 Todo *todo;
643 todo = todoList.first();// todo; todo = todoList.next()) { 643 todo = todoList.first();// todo; todo = todoList.next()) {
644 while ( todo ) { 644 while ( todo ) {
645 bool next = true; 645 bool next = true;
646 // qDebug("todo %s ", todo->summary().latin1()); 646 // qDebug("todo %s ", todo->summary().latin1());
647 Incidence *incidence = todo->relatedTo(); 647 Incidence *incidence = todo->relatedTo();
648 while ( incidence ) { 648 while ( incidence ) {
649 if ( incidence->type() == "Todo") { 649 if ( incidence->type() == "Todo") {
650 //qDebug("related %s ",incidence->summary().latin1() ); 650 //qDebug("related %s ",incidence->summary().latin1() );
651 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 651 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
652 //qDebug("related not found "); 652 //qDebug("related not found ");
653 todoList.remove( ); 653 todoList.remove( );
654 todo = todoList.current(); 654 todo = todoList.current();
655 next = false; 655 next = false;
656 incidence = 0; 656 incidence = 0;
657 657
658 } else { 658 } else {
659 //qDebug("related found "); 659 //qDebug("related found ");
660 incidence = incidence->relatedTo(); 660 incidence = incidence->relatedTo();
661 } 661 }
662 } else 662 } else
663 incidence = 0; 663 incidence = 0;
664 } 664 }
665 if ( next ) 665 if ( next )
666 todo = todoList.next(); 666 todo = todoList.next();
667 } 667 }
668// qDebug("again .... "); 668// qDebug("again .... ");
669// for(todo = todoList.first(); todo; todo = todoList.next()) { 669// for(todo = todoList.first(); todo; todo = todoList.next()) {
670 670
671// qDebug("yytodo %s ", todo->summary().latin1()); 671// qDebug("yytodo %s ", todo->summary().latin1());
672// } 672// }
673 //qDebug("for "); 673 //qDebug("for ");
674 for(todo = todoList.first(); todo; todo = todoList.next()) { 674 for(todo = todoList.first(); todo; todo = todoList.next()) {
675 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 675 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
676 { 676 {
677 insertTodoItem(todo); 677 insertTodoItem(todo);
678 } 678 }
679 } 679 }
680 //qDebug("for end "); 680 //qDebug("for end ");
681 // Restore opened/closed state 681 // Restore opened/closed state
682 mTodoListView->blockSignals( true ); 682 mTodoListView->blockSignals( true );
683 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 683 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
684 mTodoListView->blockSignals( false ); 684 mTodoListView->blockSignals( false );
685 mTodoListView->setFocus(); 685 mTodoListView->setFocus();
686 processSelectionChange(); 686 processSelectionChange();
687} 687}
688 688
689bool KOTodoView::checkTodo( Todo * todo ) 689bool KOTodoView::checkTodo( Todo * todo )
690{ 690{
691 691
692 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 692 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
693 return false; 693 return false;
694 if ( !todo->isCompleted() ) {
695 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
696 return true;
697 }
694 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 698 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
695 if ( todo->hasStartDate() ) 699 if ( todo->hasStartDate() )
696 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 700 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
697 return false; 701 return false;
698 if ( todo->hasDueDate() ) 702 if ( todo->hasDueDate() )
699 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 703 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
700 return false; 704 return false;
701 } 705 }
702 return true; 706 return true;
703} 707}
704 708
705void KOTodoView::restoreItemState( QListViewItem *item ) 709void KOTodoView::restoreItemState( QListViewItem *item )
706{ 710{
707 pendingSubtodo = 0; 711 pendingSubtodo = 0;
708 while( item ) { 712 while( item ) {
709 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 713 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
710 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 714 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
711 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 715 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
712 item = item->nextSibling(); 716 item = item->nextSibling();
713 } 717 }
714} 718}
715 719
716 720
717QMap<Todo *,KOTodoViewItem *>::ConstIterator 721QMap<Todo *,KOTodoViewItem *>::ConstIterator
718 KOTodoView::insertTodoItem(Todo *todo) 722 KOTodoView::insertTodoItem(Todo *todo)
719{ 723{
720 724
721// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 725// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
722 // TODO: Check, if dynmaic cast is necessary 726 // TODO: Check, if dynmaic cast is necessary
723 727
724 pendingSubtodo = 0; 728 pendingSubtodo = 0;
725 Incidence *incidence = todo->relatedTo(); 729 Incidence *incidence = todo->relatedTo();
726 if (incidence && incidence->type() == "Todo") { 730 if (incidence && incidence->type() == "Todo") {
727 Todo *relatedTodo = static_cast<Todo *>(incidence); 731 Todo *relatedTodo = static_cast<Todo *>(incidence);
728 732
729// kdDebug() << " has Related" << endl; 733// kdDebug() << " has Related" << endl;
730 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 734 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
731 itemIterator = mTodoMap.find(relatedTodo); 735 itemIterator = mTodoMap.find(relatedTodo);
732 if (itemIterator == mTodoMap.end()) { 736 if (itemIterator == mTodoMap.end()) {
733// kdDebug() << " related not yet in list" << endl; 737// kdDebug() << " related not yet in list" << endl;
734 itemIterator = insertTodoItem (relatedTodo); 738 itemIterator = insertTodoItem (relatedTodo);
735 } 739 }
736 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 740 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
737 // and one into the map. Sure finding is more easy but why? -zecke 741 // and one into the map. Sure finding is more easy but why? -zecke
738 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 742 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
739 return mTodoMap.insert(todo,todoItem); 743 return mTodoMap.insert(todo,todoItem);
740 } else { 744 } else {
741// kdDebug() << " no Related" << endl; 745// kdDebug() << " no Related" << endl;
742 // see above -zecke 746 // see above -zecke
743 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 747 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
744 return mTodoMap.insert(todo,todoItem); 748 return mTodoMap.insert(todo,todoItem);
745 } 749 }
746} 750}
747 751
748 752
749void KOTodoView::updateConfig() 753void KOTodoView::updateConfig()
750{ 754{
751 updateView(); 755 updateView();
752 mTodoListView->repaintContents(); 756 mTodoListView->repaintContents();
753} 757}
754 758
755QPtrList<Incidence> KOTodoView::selectedIncidences() 759QPtrList<Incidence> KOTodoView::selectedIncidences()
756{ 760{
757 QPtrList<Incidence> selected; 761 QPtrList<Incidence> selected;
758 762
759 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 763 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
760// if (!item) item = mActiveItem; 764// if (!item) item = mActiveItem;
761 if (item) selected.append(item->todo()); 765 if (item) selected.append(item->todo());
762 766
763 return selected; 767 return selected;
764} 768}
765 769
766QPtrList<Todo> KOTodoView::selectedTodos() 770QPtrList<Todo> KOTodoView::selectedTodos()
767{ 771{
768 QPtrList<Todo> selected; 772 QPtrList<Todo> selected;
769 773
770 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 774 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
771// if (!item) item = mActiveItem; 775// if (!item) item = mActiveItem;
772 if (item) selected.append(item->todo()); 776 if (item) selected.append(item->todo());
773 777
774 return selected; 778 return selected;
775} 779}
776 780
777void KOTodoView::changeEventDisplay(Event *, int) 781void KOTodoView::changeEventDisplay(Event *, int)
778{ 782{
779 updateView(); 783 updateView();
780} 784}
781 785
782void KOTodoView::showDates(const QDate &, const QDate &) 786void KOTodoView::showDates(const QDate &, const QDate &)
783{ 787{
784} 788}
785 789
786void KOTodoView::showEvents(QPtrList<Event>) 790void KOTodoView::showEvents(QPtrList<Event>)
787{ 791{
788 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 792 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
789} 793}
790 794
791void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 795void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
792 const QDate &td) 796 const QDate &td)
793{ 797{
794#ifndef KORG_NOPRINTER 798#ifndef KORG_NOPRINTER
795 calPrinter->preview(CalPrinter::Todolist, fd, td); 799 calPrinter->preview(CalPrinter::Todolist, fd, td);
796#endif 800#endif
797} 801}
798 802
799void KOTodoView::editItem(QListViewItem *item ) 803void KOTodoView::editItem(QListViewItem *item )
800{ 804{
801 // qDebug("editItem(QListViewItem *item ) "); 805 // qDebug("editItem(QListViewItem *item ) ");
802 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 806 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
803} 807}
804 808
805void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 809void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
806{ 810{
807 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 811 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
808} 812}
809 813
810void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 814void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
811{ 815{
812 pendingSubtodo = 0; 816 pendingSubtodo = 0;
813 mActiveItem = (KOTodoViewItem *)item; 817 mActiveItem = (KOTodoViewItem *)item;
814 if (item) { 818 if (item) {
815 switch (column){ 819 switch (column){
816 case 1: 820 case 1:
817 mPriorityPopupMenu->popup(QCursor::pos ()); break; 821 mPriorityPopupMenu->popup(QCursor::pos ()); break;
818 case 2: 822 case 2:
819 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 823 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
820 case 3: 824 case 3:
821 moveTodo(); 825 moveTodo();
822 break; 826 break;
823 case 8: 827 case 8:
824 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 828 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
825 default: 829 default:
826 mItemPopupMenu->popup(QCursor::pos()); 830 mItemPopupMenu->popup(QCursor::pos());
827 } 831 }
828 } else mPopupMenu->popup(QCursor::pos()); 832 } else mPopupMenu->popup(QCursor::pos());
829} 833}
830void KOTodoView::newTodo() 834void KOTodoView::newTodo()
831{ 835{
832 emit newTodoSignal(); 836 emit newTodoSignal();
833} 837}
834 838
835void KOTodoView::newSubTodo() 839void KOTodoView::newSubTodo()
836{ 840{
837 if (mActiveItem) { 841 if (mActiveItem) {
838 emit newSubTodoSignal(mActiveItem->todo()); 842 emit newSubTodoSignal(mActiveItem->todo());
839 } 843 }
840} 844}
841void KOTodoView::unparentTodo() 845void KOTodoView::unparentTodo()
842{ 846{
843 if (mActiveItem) { 847 if (mActiveItem) {
844 emit unparentTodoSignal(mActiveItem->todo()); 848 emit unparentTodoSignal(mActiveItem->todo());
845 } 849 }
846} 850}
847 851
848void KOTodoView::reparentTodo() 852void KOTodoView::reparentTodo()
849{ 853{
850 if (mActiveItem) { 854 if (mActiveItem) {
851 qDebug("KOTodoView::reparentTodo() "); 855 qDebug("KOTodoView::reparentTodo() ");
852 topLevelWidget()->setCaption(i18n("Click on new parent item")); 856 topLevelWidget()->setCaption(i18n("Click on new parent item"));
853 pendingSubtodo = mActiveItem; 857 pendingSubtodo = mActiveItem;
854 } 858 }
855} 859}
856void KOTodoView::editTodo() 860void KOTodoView::editTodo()
857{ 861{
858 if (mActiveItem) { 862 if (mActiveItem) {
859 emit editTodoSignal(mActiveItem->todo()); 863 emit editTodoSignal(mActiveItem->todo());
860 } 864 }
861} 865}
862void KOTodoView::cloneTodo() 866void KOTodoView::cloneTodo()
863{ 867{
864 if (mActiveItem) { 868 if (mActiveItem) {
865 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 869 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
866 } 870 }
867} 871}
868void KOTodoView::cancelTodo() 872void KOTodoView::cancelTodo()
869{ 873{
870 if (mActiveItem) { 874 if (mActiveItem) {
871 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 875 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
872 } 876 }
873} 877}
874void KOTodoView::moveTodo() 878void KOTodoView::moveTodo()
875{ 879{
876 if (mActiveItem) { 880 if (mActiveItem) {
877 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 881 emit moveTodoSignal((Incidence*)mActiveItem->todo());
878 } 882 }
879} 883}
880void KOTodoView::beamTodo() 884void KOTodoView::beamTodo()
881{ 885{
882 if (mActiveItem) { 886 if (mActiveItem) {
883 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 887 emit beamTodoSignal((Incidence*)mActiveItem->todo());
884 } 888 }
885} 889}
886 890
887 891
888void KOTodoView::showTodo() 892void KOTodoView::showTodo()
889{ 893{
890 if (mActiveItem) { 894 if (mActiveItem) {
891 emit showTodoSignal(mActiveItem->todo()); 895 emit showTodoSignal(mActiveItem->todo());
892 } 896 }
893} 897}
894 898
895void KOTodoView::deleteTodo() 899void KOTodoView::deleteTodo()
896{ 900{
897 if (mActiveItem) { 901 if (mActiveItem) {
898 emit deleteTodoSignal(mActiveItem->todo()); 902 emit deleteTodoSignal(mActiveItem->todo());
899 } 903 }
900} 904}
901 905
902void KOTodoView::setNewPriority(int index) 906void KOTodoView::setNewPriority(int index)
903{ 907{
904 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 908 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
905 mActiveItem->todo()->setPriority(mPriority[index]); 909 mActiveItem->todo()->setPriority(mPriority[index]);
906 mActiveItem->construct(); 910 mActiveItem->construct();
907 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 911 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
908 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 912 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
909 } 913 }
910} 914}
911 915
912void KOTodoView::setNewPercentage(int index) 916void KOTodoView::setNewPercentage(int index)
913{ 917{
914 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 918 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
915 919
916 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 920 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
917 mActiveItem->setOn( true ); 921 mActiveItem->setOn( true );
918 return; 922 return;
919 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 923 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
920 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 924 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
921 if ( par && par->isOn() ) 925 if ( par && par->isOn() )
922 par->setOn( false ); 926 par->setOn( false );
923 } 927 }
924 if (mPercentage[index] == 100) { 928 if (mPercentage[index] == 100) {
925 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 929 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
926 } else { 930 } else {
927 mActiveItem->todo()->setCompleted(false); 931 mActiveItem->todo()->setCompleted(false);
928 } 932 }
929 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 933 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
930 mActiveItem->construct(); 934 mActiveItem->construct();
931 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 935 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
932 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 936 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
933 } 937 }
934} 938}
935 939
936 940
937QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 941QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
938{ 942{
939 QPopupMenu* tempMenu = new QPopupMenu (this); 943 QPopupMenu* tempMenu = new QPopupMenu (this);
940 QStringList checkedCategories = todoItem->todo()->categories (); 944 QStringList checkedCategories = todoItem->todo()->categories ();
941 945
942 tempMenu->setCheckable (true); 946 tempMenu->setCheckable (true);
943 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 947 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
944 it != KOPrefs::instance()->mCustomCategories.end (); 948 it != KOPrefs::instance()->mCustomCategories.end ();
945 ++it) { 949 ++it) {
946 int index = tempMenu->insertItem (*it); 950 int index = tempMenu->insertItem (*it);
947 mCategory[index] = *it; 951 mCategory[index] = *it;
948 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 952 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
949 } 953 }